EmEveIdCalculator.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \brief Example routine for calculating the "ultimate e-m mother" of
3 /// a particle in a simulated event.
4 ///
5 /// \author seligman@nevis.columbia.edu
6 /// \date
7 ////////////////////////////////////////////////////////////////////////
9 
11 
13 
14 #include <TString.h>
15 
16 namespace sim {
17 
18  // This particular class attempts to find the "ultimate mother" for
19  // electromagnetic showers. It goes up the chain of particles in an
20  // event, until it encounters a particle that is either primary or
21  // was not produced by a "trivial" e-m process.
22 
24  {
25  // Almost any eve ID calculation will use this: Get the entire
26  // history of the particle and its ancestors in the simulated
27  // event. (m_particleNav is defined in EveIdCalculator.h)
28  const sim::ParticleHistory particleHistory( m_particleNav, trackID );
29 
30  // You can treat particleHistory like an array, and do something
31  // like:
32 
33  // for ( int i = particleHistory.size(); i >= 0; --i )
34  // { const sim::Particle* particle = particleHistory[i]; ... }
35 
36  // But we know how to use the Standard Template Library (Yes, you
37  // do! Don't doubt yourself!) so let's treat particleHistory in
38  // the most efficient manner, as an STL container. We want to scan
39  // the container from its last element to its first, from the base
40  // of the particle production chain towards the primary particle.
41 
42  for(sim::ParticleHistory::const_reverse_iterator i = particleHistory.rbegin();
43  i != particleHistory.rend(); ++i){
44  // Get the text string that describes the process that created
45  // the particle.
46  std::string process = (*i)->Process();
47 
48  LOG_DEBUG("EmEveIdCalculator") << "calculator: " << *(*i);
49 
50  // Skip it if it was created by pair production, compton
51  // scattering, photoelectric effect, bremstrahlung,
52  // annihilation, or any ionization. (The ultimate source of
53  // the process names are the physics lists used in Geant4.)
54 
55  if ( process.find("conv") != std::string::npos ||
56  process.find("LowEnConversion") != std::string::npos ||
57  process.find("Pair") != std::string::npos ||
58  process.find("compt") != std::string::npos ||
59  process.find("Compt") != std::string::npos ||
60  process.find("Brem") != std::string::npos ||
61  process.find("phot") != std::string::npos ||
62  process.find("Photo") != std::string::npos ||
63  process.find("Ion") != std::string::npos ||
64  process.find("annihil") != std::string::npos) continue;
65 
66  // If we get here, the particle wasn't created by any of the
67  // above processes. Return its ID.
68  return (*i)->TrackId();
69  }
70 
71  // If we get here, we've skipped every particle in the
72  // chain. Perhaps it was empty.
73  return 0;
74  }
75 
76 } // namespace sim
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
virtual int DoCalculateEveId(const int trackID)
const sim::ParticleNavigator * m_particleNav
The ParticleNavigator associated with the eve ID calculation.
Example routine for calculating the "ultimate e-m mother" of a particle in a simulated event...
Definition: FillTruth.h:16
Int_t trackID
Definition: plot.C:84
enum BeamMode string