All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MCTruthEmEveIdCalculator.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file MCTruthEmEveIdCalculator.h
3 /// \brief Example routine for calculating the "ultimate e-m mother" of a particle in a simulated event.
4 ///
5 /// \version $Id: MCTruthEmEveIdCalculator.h,v 1.2 2010/05/13 16:42:22 seligman Exp $
6 /// \author seligman@nevis.columbia.edu
7 ////////////////////////////////////////////////////////////////////////
8 ///
9 /// ********************************************************************
10 /// *** This class has been lifted from nutools and modified so that it
11 /// *** does NOT take ownwership of the MCParticles that are added to it
12 /// *** so we can avoid duplicating them
13 /// ********************************************************************
14 ///
15 /// If you haven't done so already, read the comments in front of
16 /// Simulation/EveIdCalculator.h.
17 
18 /// The default calculator for the eve ID, EveIdCalculator, goes up
19 /// the chain of particles in an event to return the track ID of a
20 /// primary particle from the event generator. But what if you want
21 /// different defintion of the eve ID? There's a way to substitute
22 /// your own calculation; this class is an example of how to do it.
23 
24 /// This particular class attempts to find the "ultimate mother" for
25 /// electromagnetic showers. It goes up the chain of particles in an
26 /// event, until it encounters a particle that is either primary or
27 /// was not produced by a "trivial" e-m process.
28 
29 /// To create your own eve ID calculation, copy this header file and
30 /// change the name from "MCTruthEmEveIdCalculator" to whatever name you
31 /// prefer. Then copy the implementation file "MCTruthEmEveIdCalculator.cxx",
32 /// again changing the name to your class. Then revise the
33 /// calculation in the DoCalculateEveId method to whatever you want.
34 
35 /// To use this new calculation within sim::ParticleList, use the
36 /// following statement:
37 
38 // sim::ParticleList::AdoptEveIdCalculator( new sim::MCTruthEmEveIdCalculator );
39 
40 /// If you've written your own calculator, subtitute it for
41 /// "sim::MCTruthEmEveIdCalculator" in the above statement.
42 
43 /// Just do this once, in the initialization portion of your
44 /// program. (You can call it for every event, but you'll be wasting
45 /// time.)
46 
47 /// It may look like there's a memory leak in the above statement, but
48 /// there isn't: the "Adopt" in the method name means that
49 /// ParticleList will take control of the pointer. Don't delete it;
50 /// ParticleList will do that.
51 
52 /// If you're familiar with design patterns, this class makes use of
53 /// the Template Method. No, this has nothing to do with C++
54 /// templates; see "Design Patterns" by Gemma et al., or "Effective
55 /// C++" by Scott Meyers.
56 
57 /// If you're a good enough programmer to contemplate buffering of
58 /// results or lazy evaluation, don't bother; ParticleList and
59 /// EveIdCalculator already take care of this.
60 
61 #ifndef TRUTH_MCTruthEmEveIdCalculator_H
62 #define TRUTH_MCTruthEmEveIdCalculator_H
63 
65 
66 ///Monte Carlo Simulation
67 namespace truth {
68 
70  {
71  public:
72  // Constructor and destructor, which here do nothing.
74  : MCTruthEveIdCalculator() // Make sure the parent class constructor is called
75  {}
77 
78  private:
79  // This is the method that does the actual eve ID calculation.
80  virtual int DoCalculateEveId( const int trackID );
81  };
82 
83 } // namespace sim
84 
85 #endif // SIM_MCTruthEmEveIdCalculator_H
Interface for calculating the "ultimate mother" of a particle in a simulated event.
virtual int DoCalculateEveId(const int trackID)