GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GHepRecord.h
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \class genie::GHepRecord
5 
6 \brief GENIE's GHEP MC event record.
7 
8 \author Costas Andreopoulos <c.andreopoulos \at cern.ch>
9  University of Liverpool
10 
11 \created October 1, 2004
12 
13 \cpright Copyright (c) 2003-2024, The GENIE Collaboration
14  For the full text of the license visit http://copyright.genie-mc.org
15 */
16 //____________________________________________________________________________
17 
18 #ifndef _GHEP_RECORD_H_
19 #define _GHEP_RECORD_H_
20 
21 #include <ostream>
22 #include <vector>
23 
24 #include <TClonesArray.h>
25 #include <TBits.h>
26 
31 
32 class TRootIOCtor;
33 class TLorentzVector;
34 
35 using std::ostream;
36 using std::vector;
37 
38 namespace genie {
39 
40 class GHepRecord;
41 class GHepParticle;
42 
43 ostream & operator << (ostream & stream, const GHepRecord & event);
44 
45 class GHepRecord : public TClonesArray {
46 
47 public :
48  using TClonesArray::Print; // suppress clang 'hides overloaded virtual function [-Woverloaded-virtual]' warnings
49  using TClonesArray::Copy;
50 
51  GHepRecord();
52  GHepRecord(int size);
53  GHepRecord(const GHepRecord & record);
54  GHepRecord(TRootIOCtor*);
55  virtual ~GHepRecord();
56 
57  // Methods to attach / get summary information
58 
59  virtual Interaction * Summary (void) const;
60  virtual void AttachSummary (Interaction * interaction);
61 
62  // Provide a simplified wrapper of the 'new with placement'
63  // TClonesArray object insertion method
64  // ALWAYS use these methods to insert new particles as they check
65  // for the compactness of the daughter lists.
66  // Note that the record might be automatically re-arranged as the
67  // result of your GHepParticle insertion
68 
69  virtual void AddParticle (const GHepParticle & p);
70  virtual void AddParticle (int pdg, GHepStatus_t ist,
71  int mom1, int mom2, int dau1, int dau2,
72  const TLorentzVector & p, const TLorentzVector & v);
73  virtual void AddParticle (int pdg, GHepStatus_t ist,
74  int mom1, int mom2, int dau1, int dau2,
75  double px, double py, double pz, double E,
76  double x, double y, double z, double t);
77 
78  // Methods to search the GHEP record
79 
80  virtual GHepParticle * Particle (int position) const;
81  virtual GHepParticle * FindParticle (int pdg, GHepStatus_t ist, int start) const;
82 
83  virtual int ParticlePosition (int pdg, GHepStatus_t i, int start=0) const;
84  virtual int ParticlePosition (GHepParticle * particle, int start=0) const;
85 
86  virtual vector<int> * GetStableDescendants(int position) const;
87 
88  // Return the mode (lepton+nucleon/nucleus, hadron+nucleon/nucleus, nucleon
89  // decay etc...) by looking at the event entries
90 
92 
93  // Easy access methods for the most frequently used GHEP entries
94 
95  virtual GHepParticle * Probe (void) const;
96  virtual GHepParticle * TargetNucleus (void) const;
97  virtual GHepParticle * RemnantNucleus (void) const;
98  virtual GHepParticle * HitNucleon (void) const;
99  virtual GHepParticle * HitElectron (void) const;
100  virtual GHepParticle * FinalStatePrimaryLepton (void) const;
101  virtual GHepParticle * FinalStateHadronicSystem (void) const;
102  virtual int ProbePosition (void) const;
103  virtual int TargetNucleusPosition (void) const;
104  virtual int RemnantNucleusPosition (void) const;
105  virtual int HitNucleonPosition (void) const;
106  virtual int HitElectronPosition (void) const;
107  virtual int FinalStatePrimaryLeptonPosition (void) const;
108  virtual int FinalStateHadronicSystemPosition (void) const;
109 
110  // Number of GHepParticle occurences in GHEP
111 
112  virtual unsigned int NEntries (int pdg, GHepStatus_t ist, int start=0) const;
113  virtual unsigned int NEntries (int pdg, int start=0) const;
114 
115  // Methods to switch on/off and ask for event record flags
116 
117  virtual TBits * EventFlags (void) const { return fEventFlags; }
118  virtual TBits * EventMask (void) const { return fEventMask; }
119  virtual bool IsUnphysical (void) const { return (fEventFlags->CountBits()>0); }
120  virtual bool Accept (void) const;
121 
122  // Methods to set/get the event weight and cross sections
123 
124  virtual double Weight (void) const { return fWeight; }
125  virtual double Probability (void) const { return fProb; }
126  virtual double XSec (void) const { return fXSec; }
127  virtual double DiffXSec (void) const { return fDiffXSec; }
128  virtual KinePhaseSpace_t DiffXSecVars (void) const { return fDiffXSecPhSp; }
129 
130  virtual void SetWeight (double wght) { fWeight = (wght>0) ? wght : 0.; }
131  virtual void SetProbability (double prob) { fProb = (prob>0) ? prob : 0.; }
132  virtual void SetXSec (double xsec) { fXSec = (xsec>0) ? xsec : 0.; }
133  virtual void SetDiffXSec (double xsec, KinePhaseSpace_t ps)
134  { fDiffXSecPhSp = ps;
135  fDiffXSec = (xsec>0) ? xsec : 0.;
136  }
137 
138  // Set/get event vertex in detector coordinate system
139 
140  virtual TLorentzVector * Vertex (void) const { return fVtx; }
141 
142  virtual void SetVertex (double x, double y, double z, double t);
143  virtual void SetVertex (const TLorentzVector & vtx);
144 
145  // Common event record operations
146 
147  virtual void Copy (const GHepRecord & record);
148  virtual void Clear (Option_t * opt="");
149  virtual void ResetRecord (void);
150  virtual void CompactifyDaughterLists (void);
151  virtual void RemoveIntermediateParticles (void);
152 
153  // Set mask
154  void SetUnphysEventMask(const TBits & mask);
155 
156  // Set/Get print level
157  static void SetPrintLevel(int print_level);
158  static int GetPrintLevel();
159 
160  // Methods & operators to print the record
161 
162  void Print (ostream & stream) const;
163  friend ostream & operator << (ostream & stream, const GHepRecord & event);
164 
165 protected:
166 
167  // Attached interaction
168  Interaction * fInteraction; ///< attached summary information
169 
170  // Vertex position
171  TLorentzVector * fVtx; ///< vertex in the detector coordinate system
172 
173  // Flags (and user-specified mask) for the generated event
174  TBits * fEventFlags; ///< event flags indicating various pathologies or an unphysical event
175  TBits * fEventMask; ///< an input bit-field mask allowing one to ignore bits set in fEventFlags
176 
177  // Event weight, probability and cross-sections
178  double fWeight; ///< event weight
179  double fProb; ///< event probability (for given flux neutrino and density-weighted path-length for target element)
180  double fXSec; ///< cross section for selected event
181  double fDiffXSec; ///< differential cross section for selected event kinematics
182  KinePhaseSpace_t fDiffXSecPhSp; ///< specifies which differential cross-section (dsig/dQ2, dsig/dQ2dW, dsig/dxdy,...)
183 
184  // Utility methods
185  void InitRecord (void);
186  void CleanRecord (void);
187 
188  // Methods used by the daughter list compactifier
189  virtual void UpdateDaughterLists (void);
190  virtual bool HasCompactDaughterList (int pos);
191  virtual void SwapParticles (int i, int j);
192  virtual void FinalizeDaughterLists (void);
193  virtual int FirstNonInitStateEntry (void);
194 
195  //
196  static int fPrintLevel; //! print-level flag, see GHepRecord::Print()
197 
198 private:
199 
200 ClassDef(GHepRecord, 2)
201 
202 };
203 
204 } // genie namespace
205 
206 #endif // _GHEP_RECORD_H_
static void SetPrintLevel(int print_level)
Definition: GHepRecord.cxx:956
virtual void SetXSec(double xsec)
Definition: GHepRecord.h:132
virtual GHepParticle * Particle(int position) const
Definition: GHepRecord.cxx:104
virtual void SetWeight(double wght)
Definition: GHepRecord.h:130
virtual int ParticlePosition(int pdg, GHepStatus_t i, int start=0) const
Definition: GHepRecord.cxx:137
virtual void Copy(const GHepRecord &record)
Definition: GHepRecord.cxx:907
virtual void UpdateDaughterLists(void)
Definition: GHepRecord.cxx:556
double fProb
event probability (for given flux neutrino and density-weighted path-length for target element) ...
Definition: GHepRecord.h:179
void Print(ostream &stream) const
Definition: GHepRecord.cxx:965
virtual void SwapParticles(int i, int j)
Definition: GHepRecord.cxx:752
virtual GHepParticle * HitElectron(void) const
Definition: GHepRecord.cxx:323
virtual Interaction * Summary(void) const
Definition: GHepRecord.cxx:91
virtual GHepParticle * FindParticle(int pdg, GHepStatus_t ist, int start) const
Definition: GHepRecord.cxx:118
virtual KinePhaseSpace_t DiffXSecVars(void) const
Definition: GHepRecord.h:128
virtual int RemnantNucleusPosition(void) const
Definition: GHepRecord.cxx:397
virtual void SetProbability(double prob)
Definition: GHepRecord.h:131
virtual void RemoveIntermediateParticles(void)
Definition: GHepRecord.cxx:617
void InitRecord(void)
Definition: GHepRecord.cxx:837
virtual void FinalizeDaughterLists(void)
Definition: GHepRecord.cxx:799
TLorentzVector * fVtx
vertex in the detector coordinate system
Definition: GHepRecord.h:171
virtual int HitNucleonPosition(void) const
Definition: GHepRecord.cxx:418
virtual double Weight(void) const
Definition: GHepRecord.h:124
TBits * fEventMask
an input bit-field mask allowing one to ignore bits set in fEventFlags
Definition: GHepRecord.h:175
virtual unsigned int NEntries(int pdg, GHepStatus_t ist, int start=0) const
Definition: GHepRecord.cxx:477
enum genie::EKinePhaseSpace KinePhaseSpace_t
virtual void AttachSummary(Interaction *interaction)
Definition: GHepRecord.cxx:99
virtual ~GHepRecord()
Definition: GHepRecord.cxx:86
virtual TLorentzVector * Vertex(void) const
Definition: GHepRecord.h:140
virtual GHepParticle * Probe(void) const
Definition: GHepRecord.cxx:284
Enumeration of GENIE event generation modes.
double fXSec
cross section for selected event
Definition: GHepRecord.h:180
Summary information for an interaction.
Definition: Interaction.h:56
Interaction * fInteraction
attached summary information
Definition: GHepRecord.h:168
TBits * fEventFlags
event flags indicating various pathologies or an unphysical event
Definition: GHepRecord.h:174
virtual bool Accept(void) const
Definition: GHepRecord.cxx:947
virtual bool HasCompactDaughterList(int pos)
Definition: GHepRecord.cxx:700
virtual int FirstNonInitStateEntry(void)
Definition: GHepRecord.cxx:739
virtual GHepParticle * FinalStatePrimaryLepton(void) const
Definition: GHepRecord.cxx:333
GEvGenMode_t EventGenerationMode(void) const
Definition: GHepRecord.cxx:209
static int GetPrintLevel()
Definition: GHepRecord.cxx:960
virtual GHepParticle * TargetNucleus(void) const
Definition: GHepRecord.cxx:293
virtual double DiffXSec(void) const
Definition: GHepRecord.h:127
virtual vector< int > * GetStableDescendants(int position) const
Definition: GHepRecord.cxx:174
static constexpr double ps
Definition: Units.h:99
virtual void ResetRecord(void)
Definition: GHepRecord.cxx:874
virtual int HitElectronPosition(void) const
Definition: GHepRecord.cxx:441
virtual GHepParticle * FinalStateHadronicSystem(void) const
Definition: GHepRecord.cxx:342
virtual double Probability(void) const
Definition: GHepRecord.h:125
virtual void CompactifyDaughterLists(void)
Definition: GHepRecord.cxx:651
virtual TBits * EventFlags(void) const
Definition: GHepRecord.h:117
virtual bool IsUnphysical(void) const
Definition: GHepRecord.h:119
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)
virtual void Clear(Option_t *opt="")
Definition: GHepRecord.cxx:883
virtual GHepParticle * HitNucleon(void) const
Definition: GHepRecord.cxx:313
virtual void SetVertex(double x, double y, double z, double t)
Definition: GHepRecord.cxx:827
KinePhaseSpace_t fDiffXSecPhSp
specifies which differential cross-section (dsig/dQ2, dsig/dQ2dW, dsig/dxdy,...)
Definition: GHepRecord.h:182
virtual GHepParticle * RemnantNucleus(void) const
Definition: GHepRecord.cxx:303
virtual double XSec(void) const
Definition: GHepRecord.h:126
friend ostream & operator<<(ostream &stream, const GHepRecord &event)
Definition: GHepRecord.cxx:46
virtual void AddParticle(const GHepParticle &p)
Definition: GHepRecord.cxx:499
double fWeight
event weight
Definition: GHepRecord.h:178
virtual int ProbePosition(void) const
Definition: GHepRecord.cxx:352
void SetUnphysEventMask(const TBits &mask)
Definition: GHepRecord.cxx:938
GENIE&#39;s GHEP MC event record.
Definition: GHepRecord.h:45
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:39
virtual int FinalStateHadronicSystemPosition(void) const
Definition: GHepRecord.cxx:471
double fDiffXSec
differential cross section for selected event kinematics
Definition: GHepRecord.h:181
virtual int FinalStatePrimaryLeptonPosition(void) const
Definition: GHepRecord.cxx:459
virtual int TargetNucleusPosition(void) const
Definition: GHepRecord.cxx:370
static int fPrintLevel
Definition: GHepRecord.h:196
virtual void SetDiffXSec(double xsec, KinePhaseSpace_t ps)
Definition: GHepRecord.h:133
enum genie::EGHepStatus GHepStatus_t
virtual TBits * EventMask(void) const
Definition: GHepRecord.h:118
void CleanRecord(void)
Definition: GHepRecord.cxx:866