![]() |
Precalibrated Ion Beam Identification Detector Simulation 1.0
A pilot study detector simulation, written in C++ with Geant4.
|
Here we can put stuff to be executed before and after each run. More...
#include <RunAction.hh>
Public Member Functions | |
RunAction () | |
Constructor, constructs the object. | |
virtual | ~RunAction () |
Destructor, destroys the object. | |
void | BeginOfRunAction (const G4Run *) |
Is invoked at the beginning of each run by the RunManager. | |
void | EndOfRunAction (const G4Run *) |
Is invoked at the end of each run by the RunManager. | |
void | SetNewResultsFileName (G4String filename) |
Sets the filename of the file to write the results to. | |
void | WriteResultsToFile (G4int eventID, AllAccumulatedStatistics *myEventStatistics) |
Invoked after each event by the EventAction class in order to write the event data from that event to the file. | |
void | SetNewVerboseResultsFileName (G4String file) |
Sets if we are using a verbose file or not. | |
void | SetVerboseFileUsage (G4bool usage) |
void | PrintToVerboseFile (G4String messageToPrint) |
void | SetParticleZ (G4int newZ) |
void | SetParticleA (G4int newA) |
Private Attributes | |
G4String | resultsFileName |
File name of the results file. | |
FILE * | resultsFile |
Results file pointer. | |
G4String | verboseResultsFileName |
The name of the verbose results file we might be using. | |
G4bool | usingVerboseFile |
True if we are using a verbose file, otherwise false. | |
FILE * | verboseFile |
The file to dump some debug output to, used if we are using a verbose file. | |
G4int | particleZ |
G4int | particleA |
RunActionMessenger * | myMessenger |
Here we can put stuff to be executed before and after each run.
Definition at line 38 of file RunAction.hh.
void RunAction::SetNewResultsFileName | ( | G4String | filename | ) |
Sets the filename of the file to write the results to.
filename | The filename of the file to write the run results to. |
Definition at line 15 of file RunAction.cc.
References resultsFileName.
Referenced by RunActionMessenger::RunActionMessenger(), and RunActionMessenger::SetNewValue().
{ resultsFileName = filename; }
void RunAction::SetNewVerboseResultsFileName | ( | G4String | file | ) | [inline] |
Sets if we are using a verbose file or not.
file | The filename to set. |
Definition at line 55 of file RunAction.hh.
References verboseResultsFileName.
Referenced by RunActionMessenger::RunActionMessenger(), and RunActionMessenger::SetNewValue().
void RunAction::SetVerboseFileUsage | ( | G4bool | usage | ) | [inline] |
usage | Tells if we are using a verbose file. |
Definition at line 59 of file RunAction.hh.
References usingVerboseFile.
Referenced by RunActionMessenger::RunActionMessenger(), and RunActionMessenger::SetNewValue().
{usingVerboseFile = usage;}
void RunAction::WriteResultsToFile | ( | G4int | eventID, |
AllAccumulatedStatistics * | myEventStatistics | ||
) |
Invoked after each event by the EventAction class in order to write the event data from that event to the file.
Sets the new VerboseResultsFileName
eventID | The event ID. |
myEventStatistics | Write the event data to the file. |
Definition at line 30 of file RunAction.cc.
References AllAccumulatedStatistics::GetEventHits(), and resultsFile.
Referenced by EventAction::EndOfEventAction().
{ std::vector<EventHit> eventsToWrite = myEventStatistics->GetEventHits(); for(std::vector<EventHit>::iterator it = eventsToWrite.begin(); it!=eventsToWrite.end(); it++) { fprintf(resultsFile, "%d %d %d ", eventID, particleZ, particleA); fprintf(resultsFile, "%.15e ",it->time/ns); if(it->upperFrontScintillatorPanelEnergy/MeV>1E-100) fprintf(resultsFile, "%.15e ",it->upperFrontScintillatorPanelEnergy/MeV); else fprintf(resultsFile, "%d ",0); if(it->lowerFrontScintillatorPanelEnergy/MeV>1E-100) fprintf(resultsFile, "%.15e ",it->lowerFrontScintillatorPanelEnergy/MeV); else fprintf(resultsFile, "%d ",0); if(it->backScintillatorPanelEnergy/MeV>1E-100) fprintf(resultsFile, "%.15e ",it->backScintillatorPanelEnergy/MeV); else fprintf(resultsFile, "%d ",0); if(it->geDetectorEnergy/MeV>1E-100) fprintf(resultsFile, "%.15e",it->geDetectorEnergy/MeV); else fprintf(resultsFile, "%d",0); for(std::vector<G4double>::iterator ig = it->scintillatorTubeEnergies.begin(); ig!=it->scintillatorTubeEnergies.end(); ig++) { if(*ig/MeV>1E-100) fprintf(resultsFile, " %.15e",*ig/MeV); else fprintf(resultsFile, " %d",0); } fprintf(resultsFile, "\n"); } }