![]() |
Precalibrated Ion Beam Identification Detector Simulation 1.0
A pilot study detector simulation, written in C++ with Geant4.
|
00001 #include "EventAction.hh" 00002 00003 EventAction::EventAction(RunAction* run, DetectorConstruction* det, G4double accumulationtime) 00004 :runAct(run),printModulo(100),eventMessenger(0), myAccumulationTime(accumulationtime) 00005 { 00006 detector=det; 00007 eventMessenger = new EventActionMessenger(this); 00008 } 00009 00010 EventAction::~EventAction() 00011 { 00012 delete eventMessenger; 00013 } 00014 00015 // Just updates the eventnumber at the beginning of each event 00016 void EventAction::BeginOfEventAction(const G4Event* evt) 00017 { 00018 G4int evtNb = evt->GetEventID(); 00019 std::stringstream ss; 00020 ss << "Event ID: " << evtNb << std::endl; 00021 runAct->PrintToVerboseFile(ss.str()); 00022 00023 if(evtNb%printModulo==0) 00024 G4cout << "Starting event " << evtNb << G4endl; 00025 00026 myStatistics = new AllAccumulatedStatistics(((detector->GetNumberOfScintillatorBoxes())*(detector->GetNumberOfScintillatorsPerBox())*2),myAccumulationTime); 00027 } 00028 00029 void EventAction::PrintToVerboseFile(G4String messageToPrint) 00030 { 00031 runAct->PrintToVerboseFile(messageToPrint); 00032 } 00033 00034 00035 void EventAction::EndOfEventAction(const G4Event* evt) 00036 { 00037 G4int evtNb = evt->GetEventID(); 00038 00039 runAct->WriteResultsToFile(evtNb,myStatistics); 00040 runAct->PrintToVerboseFile("\n"); 00041 00042 delete myStatistics; 00043 } 00044 00045 void EventAction::AddScintillatorTubeEvent(G4int scintillatorID, G4double time, G4double energy) 00046 { 00047 myStatistics->AddScintillatorTubeEvent(scintillatorID,time,energy); //a range check would probable be good here. 00048 } 00049 00050 void EventAction::AddGeDetectorEvent(G4double time, G4double energy) 00051 { 00052 myStatistics->AddGeDetectorEvent(time,energy); 00053 } 00054 00055 void EventAction::AddScintillatorPlateEvent(AllAccumulatedStatistics::ScintillatorPlate plate, G4double time, G4double energy) 00056 { 00057 myStatistics->AddScintillatorPlateEvent(plate,time,energy); 00058 }