EmEveIdCalculator.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file EmEveIdCalculator.h
3 /// \brief Example routine for calculating the "ultimate e-m mother" of a particle in a simulated event.
4 ///
5 /// \version $Id: EmEveIdCalculator.h,v 1.2 2010/05/13 16:42:22 seligman Exp $
6 /// \author seligman@nevis.columbia.edu
7 ////////////////////////////////////////////////////////////////////////
8 
9 /// If you haven't done so already, read the comments in front of
10 /// Simulation/EveIdCalculator.h.
11 
12 /// The default calculator for the eve ID, EveIdCalculator, goes up
13 /// the chain of particles in an event to return the track ID of a
14 /// primary particle from the event generator. But what if you want
15 /// different defintion of the eve ID? There's a way to substitute
16 /// your own calculation; this class is an example of how to do it.
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 
23 /// To create your own eve ID calculation, copy this header file and
24 /// change the name from "EmEveIdCalculator" to whatever name you
25 /// prefer. Then copy the implementation file "EmEveIdCalculator.cxx",
26 /// again changing the name to your class. Then revise the
27 /// calculation in the DoCalculateEveId method to whatever you want.
28 
29 /// To use this new calculation within sim::ParticleList, use the
30 /// following statement:
31 
32 // sim::ParticleList::AdoptEveIdCalculator( new sim::EmEveIdCalculator );
33 
34 /// If you've written your own calculator, subtitute it for
35 /// "sim::EmEveIdCalculator" in the above statement.
36 
37 /// Just do this once, in the initialization portion of your
38 /// program. (You can call it for every event, but you'll be wasting
39 /// time.)
40 
41 /// It may look like there's a memory leak in the above statement, but
42 /// there isn't: the "Adopt" in the method name means that
43 /// ParticleList will take control of the pointer. Don't delete it;
44 /// ParticleList will do that.
45 
46 /// If you're familiar with design patterns, this class makes use of
47 /// the Template Method. No, this has nothing to do with C++
48 /// templates; see "Design Patterns" by Gemma et al., or "Effective
49 /// C++" by Scott Meyers.
50 
51 /// If you're a good enough programmer to contemplate buffering of
52 /// results or lazy evaluation, don't bother; ParticleList and
53 /// EveIdCalculator already take care of this.
54 
55 #ifndef SIM_EmEveIdCalculator_H
56 #define SIM_EmEveIdCalculator_H
57 
58 #include "nutools/ParticleNavigation/EveIdCalculator.h"
59 
60 ///Monte Carlo Simulation
61 namespace sim {
62 
64  {
65  public:
66  // Constructor and destructor, which here do nothing.
68  : EveIdCalculator() // Make sure the parent class constructor is called
69  {}
70  virtual ~EmEveIdCalculator() {}
71 
72  private:
73  // This is the method that does the actual eve ID calculation.
74  virtual int DoCalculateEveId( const int trackID );
75  };
76 
77 } // namespace sim
78 
79 #endif // SIM_EmEveIdCalculator_H
virtual int DoCalculateEveId(const int trackID)
Monte Carlo Simulation.