run.cc
#include “run.hh”
MyRunAction::MyRunAction()
{}
MyRunAction::~MyRunAction()
{}
void MyRunAction::BegineOfRunAction(const G4Run*)
{
G4AnalysisManager *man = G4AnalysisManager::Instance();
//TFile* file = new TFile("output.root", "RECREATE");
man->OpenFile("Output.root");
man->CreateNtuple("Hits" ,"Hits");
man->CreateNtupleIColumn("fEvent");
man->CreateNtupleDColumn("fX");
man->CreateNtupleDColumn("fY");
man->CreateNtupleDColumn("fZ");
man->FinishNtuple(0);
}
void MyRunAction::EndOfRunAction(const G4Run*)
{
G4AnalysisManager *man = G4AnalysisManager::Instance();
man->Write();
man->CloseFile();
}
detector.cc
#include “detector.hh”
MySensitiveDetector::MySensitiveDetector(G4String name) : G4VSensitiveDetector(name)
{}
MySensitiveDetector::~MySensitiveDetector()
{}
G4bool MySensitiveDetector::ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist)
{
G4Track *track =aStep->GetTrack();
track->SetTrackStatus(fStopAndKill);
G4StepPoint *preStepPoint = aStep->GetPreStepPoint();
G4StepPoint *postStepPoint = aStep->GetPostStepPoint();
G4ThreeVector posPhoton =preStepPoint->GetPosition();
//G4cout << "Photon position: " << posPhoton << G4endl;
const G4VTouchable *touchable = aStep->GetPreStepPoint()->GetTouchable();
G4int copyNo = touchable->GetCopyNumber();
//G4cout << "Copy number: " << copyNo << G4endl;
G4VPhysicalVolume *physVol = touchable->GetVolume();
G4ThreeVector posDetector = physVol->GetTranslation();
G4cout << "Detector Position: " << posDetector << G4endl;
G4int evt = G4RunManager::GetRunManager()->GetCurrentEvent()->GetEventID();
**G4AnalysisManager *man = G4AnalysisManager::Instance();**
**man->FillNtupleIColumn(0, evt);**
** man->FillNtupleDColumn(1, posDetector[0]);**
** man->FillNtupleDColumn(2, posDetector[1]);**
** man->FillNtupleDColumn(3, posDetector[2]);**
** man->AddNtupleRow(0);**
return true;
}
without the above ** commands, I am getting the output. But as I input all the commands (highlights **) getting the message “code dumped”. I am also not getting any output.root file.
please suggest me how to solve the above issues.
_Geant4 Version:_11.2.2
_Operating System:_ubuntu 20.04
_Compiler/Version:_C++14
_CMake Version:_3.16.3