CMS 3D CMS Logo

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