![]() |
Precalibrated Ion Beam Identification Detector Simulation 1.0
A pilot study detector simulation, written in C++ with Geant4.
|
Contains information about what to do at each step in the simulation. More...
#include <SteppingAction.hh>
Public Member Functions | |
SteppingAction (DetectorConstruction *, EventAction *) | |
Constructor, constructs the object. | |
virtual | ~SteppingAction () |
Destructor, destroys the object. | |
void | UserSteppingAction (const G4Step *) |
Performs all required actions at each step. | |
Private Attributes | |
DetectorConstruction * | detector |
Contains information about the detector. | |
EventAction * | eventaction |
Pointer to an associated EventAction object. |
Contains information about what to do at each step in the simulation.
At each step the class checks if the particle is in either one of the scintillatortubes, in one of the scintillator plates, or in the germanium detector. If it is, it prints (to the screen or to a file) information about how much energy was deposited by what particle and at what time.
Definition at line 46 of file SteppingAction.hh.
SteppingAction::SteppingAction | ( | DetectorConstruction * | det, |
EventAction * | evt | ||
) |
Constructor, constructs the object.
det | Information about the detector. |
evt | Pointer to an associated EventAction object. |
Definition at line 4 of file SteppingAction.cc.
:detector(det), eventaction(evt) { }
void SteppingAction::UserSteppingAction | ( | const G4Step * | aStep | ) |
Performs all required actions at each step.
aStep | Contains information about the step in question. |
Definition at line 14 of file SteppingAction.cc.
References EventAction::AddGeDetectorEvent(), EventAction::AddScintillatorPlateEvent(), EventAction::AddScintillatorTubeEvent(), detector, eventaction, DetectorConstruction::GetBackScintillatorPlate(), DetectorConstruction::GetGermaniumDetector(), DetectorConstruction::GetLowerBetaDetector(), DetectorConstruction::GetLowerFrontScintillatorPlate(), DetectorConstruction::GetNumberOfScintillatorsPerBox(), DetectorConstruction::GetScintillator(), DetectorConstruction::GetUpperFrontScintillatorPlate(), and EventAction::PrintToVerboseFile().
{ G4cout.precision(15); //increase precision of cout. // get volume of the current step G4VPhysicalVolume* volume = aStep->GetPreStepPoint()->GetTouchableHandle()->GetVolume(); // collect energy and track length step by step //G4double edep = aStep->GetTotalEnergyDeposit(); G4double edep = aStep->GetTotalEnergyDeposit(); // record the time G4double time = aStep->GetTrack()->GetGlobalTime(); if (volume == detector->GetScintillator()) { //Determine the scintillator ID. G4int scintillatorID = aStep->GetPreStepPoint()->GetTouchable()->GetReplicaNumber(1); scintillatorID += (aStep->GetPreStepPoint()->GetTouchable()->GetReplicaNumber(2))*(detector->GetNumberOfScintillatorsPerBox()); if (aStep->GetPreStepPoint()->GetTouchable()->GetVolume(3) == detector->GetLowerBetaDetector()) scintillatorID += (detector->GetNumberOfScintillatorBoxes())*(detector->GetNumberOfScintillatorsPerBox()); eventaction->AddScintillatorTubeEvent(scintillatorID,time, edep); std::stringstream ss; ss.precision(15); ss << time/ns << " " << scintillatorID << " " << edep/MeV << " " << aStep->GetTrack()->GetDefinition()->GetParticleName().c_str() << " " << aStep->GetTrack()->GetTotalEnergy()/MeV << std::endl; eventaction->PrintToVerboseFile(ss.str()); } if (volume == detector->GetGermaniumDetector()) { eventaction->AddGeDetectorEvent(time, edep); std::stringstream ss; ss.precision(15); ss << time/ns << " GermaniumDetector " << edep/MeV << " " << aStep->GetTrack()->GetDefinition()->GetParticleName().c_str() << " " << aStep->GetTrack()->GetTotalEnergy()/MeV << std::endl; eventaction->PrintToVerboseFile(ss.str()); } if (volume == detector->GetLowerFrontScintillatorPlate()) { eventaction->AddScintillatorPlateEvent(AllAccumulatedStatistics::LowerFront,time/ns,edep); } if (volume == detector->GetUpperFrontScintillatorPlate()) { eventaction->AddScintillatorPlateEvent(AllAccumulatedStatistics::UpperFront,time, edep); } if (volume == detector->GetBackScintillatorPlate()) { eventaction->AddScintillatorPlateEvent(AllAccumulatedStatistics::Back,time, edep); } if (volume == detector->GetUpperFrontScintillatorPlate() || volume == detector->GetBackScintillatorPlate() || volume == detector->GetLowerFrontScintillatorPlate()) { if (edep/eV > 1) { std::stringstream ss; ss.precision(15); ss << time/ns << " " << volume->GetName().c_str() << " " << edep/MeV << " " << aStep->GetTrack()->GetDefinition()->GetParticleName().c_str() << " " << aStep->GetTrack()->GetTotalEnergy()/MeV << std::endl; eventaction->PrintToVerboseFile(ss.str()); } } //if (aStep->GetTrack()->GetDefinition()->GetParticleName().compare("gamma")==0) // fprintf(file, "GAMMA: Time: %.15f, Energy: %f, Region: %s \n", time, aStep->GetTrack()->GetTotalEnergy()/MeV, volume->GetName().c_str()); // G4cout << "Time: " << aStep->GetTrack()->GetGlobalTime()/s << G4endl; }