1 #include "HGCal/TBStandaloneSimulator/interface/SteppingAction.hh"
2 #include "HGCal/TBStandaloneSimulator/interface/DetectorConstruction.hh"
3 #include "HGCal/TBStandaloneSimulator/interface/EventAction.hh"
4 #include "HGCal/TBStandaloneSimulator/interface/HGCSSGenParticle.hh"
6 #include "G4RunManager.hh"
9 SteppingAction::SteppingAction()
11 eventAction_ = (EventAction*)G4RunManager::GetRunManager()->
13 eventAction_->Add( ((DetectorConstruction*)G4RunManager::GetRunManager()->
14 GetUserDetectorConstruction())->getStructure() );
15 saturationEngine =
new G4EmSaturation();
17 int hack = CLHEP::HepRandomGenActive;
23 SteppingAction::~SteppingAction()
27 void SteppingAction::UserSteppingAction(
const G4Step* aStep)
30 const G4StepPoint *thePreStepPoint = aStep->GetPreStepPoint();
31 const G4StepPoint *thePostStepPoint = aStep->GetPostStepPoint();
33 const G4Track* lTrack = aStep->GetTrack();
34 G4int trackID = lTrack->GetTrackID();
35 G4int parentID = lTrack->GetParentID();
37 G4VPhysicalVolume* volume = thePreStepPoint->GetPhysicalVolume();
38 std::string thePrePVname(
"null");
41 thePrePVname = volume->GetName();
43 G4VPhysicalVolume* postvolume = thePostStepPoint->GetPhysicalVolume();
44 std::string thePostPVname(
"null");
47 thePostPVname = postvolume->GetName();
50 G4double edep = aStep->GetTotalEnergyDeposit();
53 if (volume->GetName().find(
"Scint") != volume->GetName().npos) {
56 VisibleEnergyDeposition(lTrack->GetDefinition(),
57 lTrack->GetMaterialCutsCouple(),
58 aStep->GetStepLength(), edep, 0.);
63 if (lTrack->GetDefinition()->GetPDGCharge() != 0.)
64 stepl = aStep->GetStepLength();
66 G4int pdgId = lTrack->GetDefinition()->GetPDGEncoding();
67 G4double globalTime = lTrack->GetGlobalTime();
70 const G4ThreeVector& position = thePreStepPoint->GetPosition();
71 const G4ThreeVector& postposition = thePostStepPoint->GetPosition();
72 const G4ThreeVector& p = lTrack->GetMomentum();
73 eventAction_->Store(trackID, pdgId, globalTime, p, position, postposition);
75 HGCSSGenParticle genPart;
76 if (globalTime < timeLimit_ &&
77 thePrePVname ==
"Wphys"
78 && eventAction_->isFirstVolume(thePostPVname)) {
79 const G4ThreeVector& postposition = thePostStepPoint->GetPosition();
80 const G4ThreeVector& p = lTrack->GetMomentum();
81 G4ParticleDefinition* pd = lTrack->GetDefinition();
82 genPart.setPosition(postposition[0],
85 genPart.setMomentum(p[0], p[1], p[2]);
86 genPart.mass(pd->GetPDGMass());
87 genPart.time(globalTime);
89 genPart.charge(pd->GetPDGCharge());
90 genPart.trackID(trackID);
93 eventAction_->Detect(edep,