CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CountProcessesAction.cc
Go to the documentation of this file.
2 
6 
7 #include "G4Track.hh"
8 #include "G4Run.hh"
9 #include "G4Event.hh"
10 #include "G4Step.hh"
11 #include "G4ProcessManager.hh"
12 #include "G4ParticleTable.hh"
13 
15  : fDEBUG(p.getUntrackedParameter<bool>("DEBUG",false))
16 {}
17 
19 
21 {
22  G4ParticleTable * partTable = G4ParticleTable::GetParticleTable();
23  int siz = partTable->size();
24  for (int ii= 0; ii < siz; ii++)
25  {
26  G4ParticleDefinition * particle = partTable->GetParticle(ii);
27  std::string particleName = particle->GetParticleName();
28  if (fDEBUG)
29  std::cout << ii << " PCA " << particleName<< " " << particle->GetPDGStable()
30  << " " << particle->IsShortLived() << std::endl;
31  theParticleList[particleName] = 0;
32 
33  //--- All processes of this particle
34  G4ProcessManager * pmanager = particle->GetProcessManager();
35  G4ProcessVector * pvect = pmanager->GetProcessList();
36  int sizproc = pvect->size();
37  for (int jj = 0; jj < sizproc; jj++)
38  {
39  std::string processName = (*pvect)[jj]->GetProcessName();
40  if (fDEBUG)
41  std::cout << jj << " PCR " << processName<< std::endl;
42  theProcessList[pss(particleName,processName)] = 0;
43  }
44  }
45  DumpProcessList(0);
46 }
47 
49 {
50  //----- Fill counter of particles
51  const G4Track * aTrack = (*trk)();
52  std::string particleName = aTrack->GetDefinition()->GetParticleName();
53  theParticleList[particleName]++;
54 
55  //----- Fill counter of Creator Processes
56  const G4VProcess * proc = aTrack->GetCreatorProcess();
58  if (proc != 0) processName = proc->GetProcessName();
59  else processName = "Primary";
60  pss parproc(particleName,processName);
61  mpssi::iterator ite = theCreatorProcessList.find(parproc);
62  if (ite == theCreatorProcessList.end()) theCreatorProcessList[ parproc ] = 1;
63  else (*ite).second = (*ite).second +1;
64  if (fDEBUG)
65  std::cout << " creator " << particleName << " " << processName
66  << theCreatorProcessList.size() << std::endl;
67 }
68 
69 void CountProcessesAction::update(const G4Step* aStep )
70 {
72  if(aStep->GetPostStepPoint()->GetProcessDefinedStep() != 0)
73  processName = aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName();
74  else processName = "User Limit";
75  std::string particleName = aStep->GetTrack()->GetDefinition()->GetParticleName();
76  theProcessList[pss(particleName,processName)] = theProcessList[pss(particleName,processName)] + 1;
77 }
78 
80 {
81  DumpProcessList(1);
84 }
85 
86 void CountProcessesAction::DumpProcessList(bool printNsteps, std::ostream& out)
87 {
88  mpssi::iterator ite;
89  for (ite = theProcessList.begin(); ite != theProcessList.end(); ite++)
90  {
91  if (!printNsteps)
92  out << "PROC_LIST " << (*ite).first.first << " : "
93  << (*ite) .first.second << std::endl;
94  else if ((*ite).second != 0)
95  out << "PROC_COUNT " << (*ite).first.first << " : "
96  << (*ite) .first.second << " = " << (*ite).second << std::endl;
97  }
98 }
99 
100 void CountProcessesAction::DumpCreatorProcessList(bool printNsteps, std::ostream& out)
101 {
102  mpssi::iterator ite;
103  for (ite = theCreatorProcessList.begin(); ite != theCreatorProcessList.end(); ite++)
104  {
105  if (!printNsteps)
106  out << "PROC-CREATOR_LIST " << (*ite).first.first << " : "
107  <<(*ite) .first.second << std::endl;
108  else if ((*ite).second != 0)
109  out << "PROC_CREATOR_COUNT " << (*ite).first.first << " : "
110  <<(*ite) .first.second << " = " << (*ite).second << std::endl;
111  }
112 }
113 
115 {
116  psi::iterator ite;
117  for (ite = theParticleList.begin(); ite != theParticleList.end(); ite++)
118  {
119  if ((*ite).second != 0)
120  out << "PART_LIST: " << (*ite).first << " = " << (*ite).second << std::endl;
121  }
122 }
123 
void DumpProcessList(bool printNsteps, std::ostream &out=std::cout)
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:27
TrainProcessor *const proc
Definition: MVATrainer.cc:101
void DumpParticleList(std::ostream &out=std::cout)
int ii
Definition: cuy.py:588
void DumpCreatorProcessList(bool printNsteps, std::ostream &out=std::cout)
if(c.getParameter< edm::InputTag >("puppiValueMap").label().size()!=0)
tuple out
Definition: dbtoconf.py:99
CountProcessesAction(edm::ParameterSet const &p)
void update(const BeginOfRun *run)
This routine will be called when the appropriate signal arrives.
tuple cout
Definition: gather_cfg.py:121
volatile std::atomic< bool > shutdown_flag false