source: trunk/examples/extended/eventgenerator/HepMC/MCTruth/README @ 1161

Last change on this file since 1161 was 807, checked in by garnier, 16 years ago

update

File size: 8.2 KB
Line 
1$Id: README,v 1.1 2006/11/22 14:51:26 gcosmo Exp $
2-------------------------------------------------------------------
3
4     =========================================================
5     Geant4 - an Object-Oriented Toolkit for Simulation in HEP
6     =========================================================
7
8                          MCTRUTH using HepMC
9                          -------------------
10
11This example demonstrates a mechanism for Monte Carlo truth handling
12using HepMC as the event record. The user does not interact directly
13with the HepMC classes but with the MCTruthManager class which takes
14care with storing all the necessary information about particles,
15vertices and relations between them. A specialized tracking action is
16used to test whether given particle is to be stored or not. The
17decision criteria for storing particle are configurable via the
18MCTruthConfig class.
19
20HOW TO BUILD THE EXAMPLE ?
21
22- install HepMC event record (version 1.27)
23
24- set HEPMC_DIR variable to point to the directory where HepMC is installed;
25  add the path "$HEPMC_DIR/lib" to your LD_LIBRARY_PATH variable.
26
27- compile and link to generate the executable:
28        % gmake
29
30- execute the application:
31        % mctruthex
32
33DESCRIPTION OF THE MCTRUTH HANDLING MECHANISM
34 
35The main element of the MC truth handling machinery is the
36MCTruthManager class. This class is responsible for all the
37interaction with the HepMC event and does not depend on Geant4. It is
38a singleton, therefore it is guaranteed to be instanciated only once
39and the static 'GetInstance' method allows to access it from anywhere
40in the code. It contains methods like 'NewEvent' to start a new event,
41'AddParticle' to add particle to the current event, as well as
42'PrintEvent' for the purpose of the debugging.  The core of the
43algorithm which deals with building up the MC truth event tree within
44the HepMC event is implemented in AddParticle method.
45 
46The AddParticle method is called with the following arguments:
47four-momentum, production position and 'end' position of the particle,
48PDG code of the particle, as well as the particle ID (unique identifier,
49as we will see later, corresponding to Geant4 TrackID) and the ID of
50the mother. Finally, there is a boolean flag specifying whether the
51direct mother of the given particle has been stored, or not.
52 
53The first step, which always takes place, is to instanciate a new
54HepMC::GenParticle with the barcode corresponding to particle ID, as
55well as to instanciate a new HepMC::GenVertex which will represent the
56'end' vertex of the particle. The barcode of the 'end vertex' is equal
57to minus the barcode of the particle.
58 
59We can now distinguish several cases:
60 
611) the particle is a primary in the Geant4 language, i.e. its
62   mother ID is 0
63 
64   This is the simplest case, we just instanciate a new 'primary'
65   (without any incoming particles) GenVertex, we add to it the
66   particle and we put it all in the event. Additionally we store the
67   ID of the particle in a special vector, where all the IDs of
68   primary particles will be stored, allowing quick access to each of
69   the main 'branches' of the event. We return from the method.
70 
712) the particle is not a primary
72
73   We use the 'event->barcode_to_particle(motherID)' method to get the
74   pointer to its mother.
75   
76   We check if the 'end vertex' of the mother corresponds to the
77   'production vertex' of the particle in question.
78 
79   2.1) If the two vertices do match, we attach the new particle to
80        the 'end vertex' of the mother. We return from the method.
81 
82   2.2) If the two vertices do not match, i.e. the new particle is not
83        a product of the 'end vertex' of the mother particle, we can
84        have two cases:
85               
86        2.2.1) The boolean flag says that the direct mother of the
87               particle has _not_ been stored. This means that the
88               particle has been 'adopted' by one of its ancestors, or
89               in other words, the mother ID of the particle does not
90               correspond to its direct mother (so clearly the
91               vertices cannot match). This for instance could happen
92               if we decided not to store gamma coming from pi0 decay
93               but did decide to store e+/- coming from the gamma
94               conversion (so the gamma between pi0 and e+/- was
95               missing). In such a case we instanciate (or use one of
96               the existing ones, if vertices match) a 'dummy'
97               particle (with pdg = -999999) which then acts as the
98               link between the 'adopted' particle and the
99               (non-direct) mother. In such a way, the navigability up
100               in the event is still possible, but in the same time,
101               we can clearly see that the link is not a direct
102               one. We return from the method.
103 
104        2.2.2) The boolean flag says that direct mother of the
105               particle _has_ been stored. Taking into account that
106               the vertices do not match, it can mean only one
107               thing. The new particle has been produced 'on the
108               flight', i.e. somewhere 'before' the 'end vertex' of
109               the mother. This can be the case, for instace, for
110               delta electrons, bremsstrahlung gammas, etc.  In such a
111               situation, we 'split' the mother particle in two
112               particles and create a new vertex from which the
113               secondary will be going out. The complication, however,
114               arises when we have more than one generated 'on the
115               flight' particle attached to the same mother. In such a
116               case, for each secondary we need to locate the right
117               'segment' of the mother particle (i.e. we need to find
118               between which two vertices we need to add a new
119               one). To keep track of those segmentations we introduce
120               a map where each particle ID we map into the number of
121               existing segments (in the normal case one). Each new
122               'segment' gets barcode equal to the barcode of the
123               original particle + N*10000000, where N is the segment
124               number. In such a way, one can easily follow the
125               'segmentation' (if any) of each particle.  We return
126               from the method.
127 
128This concludes the description of MCTruthManager. The MCTruthConfig
129class is a collection of criteria (minimal energy, PDG, creator
130process, etc) that we want to apply when deciding whether to store or
131not given particle. These values are used by the
132'MCTruthTrackingAction' which we describe below. This class can
133certainly be extended with other members.
134 
135The actual Geant4-dependent part of the MCTruth handling machinery
136consists of a few 'G4 user actions' as well as an implementation of
137G4VUserTrackInformation. The later one is, for the moment, used only
138to store one boolean flag indicating whether the direct mother of the
139given track has been stored or not.
140 
141The first user action is MCTruthEventAction which is only reponsible
142for calling MCTruthManager::GetInstance()->NewEvent() at the beginning
143of each event. It can also be used for printing out events for the
144purpose of debugging.
145 
146The actual 'decision making' concerning which particle to store is
147done in MCTruthTrackingAction. At the end of each track the method
148trackToBeStored(track) is called to check for various characteristics
149of the particle. These, for instance can be energy, particle ID,
150creator process, etc.
151 
152If the particle satisfies the conditions the
153MCTruthManager::GetInstance()->AddParticle is called and all the
154procedure described above is performed. The important element here is
155that the Geant4 TrackID is used as the unique particle ID in
156MCTruthManager and eventually as the barcode of the
157HepMC::GenParticle.
158 
159If the particle does not qualify to be stored, there are two actions
160performed. First the 'ParentID' of the _daughters_ is set to the
161'ParentID' of the currenly processed particle. In other words, the
162'ParentID' of the daughters is set to the ID of the last stored
163particle. Second, the 'directParent' flag from MCTruthTrackInformation
164of the __daughters__ is set to FALSE. In such a way, one is still able
165to navigate up in the event (to get the ancestors of the particle),
166but in the same time, the particle is flagged as 'not having direct
167parent'.
Note: See TracBrowser for help on using the repository browser.