CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PrintTrackNumberAction.cc
Go to the documentation of this file.
2 
5 
6 #include "G4Track.hh"
7 #include "G4Event.hh"
8 #include "G4VProcess.hh"
9 
11  : theNoTracks(0), theNoTracksThisEvent(0),
12  theNoTracksNoUL(0), theNoTracksThisEventNoUL(0)
13 {
14  theNoTracksToPrint = p.getUntrackedParameter<int>("EachNTrack",-1);
15  // do not count tracks killed by user limits (MinEkineCut for the moment only)
16  bNoUserLimits = p.getUntrackedParameter<bool>("NoUserLimits", true);
17  std::cout << " PrintTrackNumberAction::bNoUserLimits " << bNoUserLimits << std::endl;
18 }
19 
21 
23 {
24  const G4Track * aTrack = (*trk)();
25 
26  theNoTracks++;
28 
29  if (bNoUserLimits)
30  {
31  bool countTrk = 1;
32  // tracks that have been killed before first step (by MinEkineCut).
33  // In fact the track makes the first step, MinEkineCut process determines
34  // that the energy is too low, set it to 0, and then at the next step
35  // the 0-energy particle dies
36  if (aTrack->GetCurrentStepNumber() == 2)
37  {
38  const G4VProcess* proccur =
39  aTrack->GetStep()->GetPostStepPoint()->GetProcessDefinedStep();
40  if (proccur != 0)
41  {
42  if (proccur->GetProcessName() == "MinEkineCut")
43  {
44  countTrk = false;
45  }
46  else
47  {
48  // for e+, last step is annihil, while previous is MinEkineCut
49  const G4VProcess* procprev =
50  aTrack->GetStep()->GetPreStepPoint()->GetProcessDefinedStep();
51  if (procprev != 0)
52  {
53  if (procprev->GetProcessName() == "MinEkineCut")
54  {
55  countTrk = false;
56  }
57  }
58  }
59  }
60  }
61  if (countTrk)
62  {
65  if (theNoTracksToPrint > 0)
66  {
68  {
69  std::cout << "PTNA: Simulating Track Number = "
70  << theNoTracksThisEventNoUL << std::endl;
71  }
72  }
73  }
74  }
75  else
76  {
77  if (theNoTracksToPrint > 0)
78  {
80  {
81  std::cout << "PTNA: Simulating Track Number = "
82  << theNoTracksThisEvent << std::endl;
83  }
84  }
85  }
86 }
87 
88 
90 {
91  const G4Event * g4e = (*e)();
92  std::cout << "PTNA: Event simulated= " << g4e->GetEventID() << " #tracks= ";
93  if (bNoUserLimits)
94  {
95  std::cout << theNoTracksThisEventNoUL << " Total #tracks in run= "
96  << theNoTracksNoUL << " counting killed by UL= " << theNoTracks
97  << std::endl;
99  }
100  else
101  {
102  std::cout << theNoTracksThisEvent << " Total #tracks in run= "
103  << theNoTracks << std::endl;
105  }
106 }
107 
PrintTrackNumberAction(edm::ParameterSet const &p)
T getUntrackedParameter(std::string const &, T const &) const
void update(const EndOfTrack *trk)
This routine will be called when the appropriate signal arrives.
tuple cout
Definition: gather_cfg.py:121