CMS 3D CMS Logo

PrintTrackNumberAction.cc
Go to the documentation of this file.
2 
5 
6 #include "G4Event.hh"
7 #include "G4ios.hh"
8 #include "G4Track.hh"
9 #include "G4VProcess.hh"
10 
12  : theNoTracks(0), theNoTracksThisEvent(0), theNoTracksNoUL(0), theNoTracksThisEventNoUL(0) {
13  theNoTracksToPrint = p.getUntrackedParameter<int>("EachNTrack", -1);
14  // do not count tracks killed by user limits (MinEkineCut for the moment only)
15  bNoUserLimits = p.getUntrackedParameter<bool>("NoUserLimits", true);
16  G4cout << " PrintTrackNumberAction::bNoUserLimits " << bNoUserLimits << G4endl;
17 }
18 
20 
22  const G4Track *aTrack = (*trk)();
23 
24  theNoTracks++;
26 
27  if (bNoUserLimits) {
28  bool countTrk = true;
29  // tracks that have been killed before first step (by MinEkineCut).
30  // In fact the track makes the first step, MinEkineCut process determines
31  // that the energy is too low, set it to 0, and then at the next step
32  // the 0-energy particle dies
33  if (aTrack->GetCurrentStepNumber() == 2) {
34  const G4VProcess *proccur = aTrack->GetStep()->GetPostStepPoint()->GetProcessDefinedStep();
35  if (proccur != nullptr) {
36  if (proccur->GetProcessName() == "MinEkineCut") {
37  countTrk = false;
38  } else {
39  // for e+, last step is annihil, while previous is MinEkineCut
40  const G4VProcess *procprev = aTrack->GetStep()->GetPreStepPoint()->GetProcessDefinedStep();
41  if (procprev != nullptr) {
42  if (procprev->GetProcessName() == "MinEkineCut") {
43  countTrk = false;
44  }
45  }
46  }
47  }
48  }
49  if (countTrk) {
52  if (theNoTracksToPrint > 0) {
54  G4cout << "PTNA: Simulating Track Number = " << theNoTracksThisEventNoUL << G4endl;
55  }
56  }
57  }
58  } else {
59  if (theNoTracksToPrint > 0) {
61  G4cout << "PTNA: Simulating Track Number = " << theNoTracksThisEvent << G4endl;
62  }
63  }
64  }
65 }
66 
68  const G4Event *g4e = (*e)();
69  G4cout << "PTNA: Event simulated= " << g4e->GetEventID() << " #tracks= ";
70  if (bNoUserLimits) {
71  G4cout << theNoTracksThisEventNoUL << " Total #tracks in run= " << theNoTracksNoUL
72  << " counting killed by UL= " << theNoTracks << G4endl;
74  } else {
75  G4cout << theNoTracksThisEvent << " Total #tracks in run= " << theNoTracks << G4endl;
77  }
78 }
PrintTrackNumberAction(edm::ParameterSet const &p)
void update(const EndOfTrack *trk) override
This routine will be called when the appropriate signal arrives.