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 <constantinos.andreopoulos \at cern.ch>
9  University of Liverpool & STFC Rutherford Appleton Laboratory
10 
11 \created October 1, 2004
12 
13 \cpright Copyright (c) 2003-2020, 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 
201 
202 };
203 
204 } // genie namespace
205 
206 #endif // _GHEP_RECORD_H_
static void SetPrintLevel(int print_level)
Definition: GHepRecord.cxx:948
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:899
virtual void UpdateDaughterLists(void)
Definition: GHepRecord.cxx:548
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:957
virtual void SwapParticles(int i, int j)
Definition: GHepRecord.cxx:744
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
virtual GHepParticle * HitElectron(void) const
Definition: GHepRecord.cxx:316
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:389
virtual void SetProbability(double prob)
Definition: GHepRecord.h:131
opt
Definition: train.py:196
virtual void RemoveIntermediateParticles(void)
Definition: GHepRecord.cxx:609
void InitRecord(void)
Definition: GHepRecord.cxx:829
virtual void FinalizeDaughterLists(void)
Definition: GHepRecord.cxx:791
struct vector vector
TLorentzVector * fVtx
vertex in the detector coordinate system
Definition: GHepRecord.h:171
virtual int HitNucleonPosition(void) const
Definition: GHepRecord.cxx:410
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:469
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:277
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
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:939
virtual bool HasCompactDaughterList(int pos)
Definition: GHepRecord.cxx:692
virtual int FirstNonInitStateEntry(void)
Definition: GHepRecord.cxx:731
virtual GHepParticle * FinalStatePrimaryLepton(void) const
Definition: GHepRecord.cxx:326
GEvGenMode_t EventGenerationMode(void) const
Definition: GHepRecord.cxx:209
static int GetPrintLevel()
Definition: GHepRecord.cxx:952
p
Definition: test.py:223
virtual GHepParticle * TargetNucleus(void) const
Definition: GHepRecord.cxx:286
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:866
virtual int HitElectronPosition(void) const
Definition: GHepRecord.cxx:433
virtual GHepParticle * FinalStateHadronicSystem(void) const
Definition: GHepRecord.cxx:335
virtual double Probability(void) const
Definition: GHepRecord.h:125
virtual void CompactifyDaughterLists(void)
Definition: GHepRecord.cxx:643
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:875
virtual GHepParticle * HitNucleon(void) const
Definition: GHepRecord.cxx:306
virtual void SetVertex(double x, double y, double z, double t)
Definition: GHepRecord.cxx:819
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:296
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:491
list x
Definition: train.py:276
double fWeight
event weight
Definition: GHepRecord.h:178
virtual int ProbePosition(void) const
Definition: GHepRecord.cxx:345
void SetUnphysEventMask(const TBits &mask)
Definition: GHepRecord.cxx:930
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:463
double fDiffXSec
differential cross section for selected event kinematics
Definition: GHepRecord.h:181
virtual int FinalStatePrimaryLeptonPosition(void) const
Definition: GHepRecord.cxx:451
virtual int TargetNucleusPosition(void) const
Definition: GHepRecord.cxx:362
static int fPrintLevel
Definition: GHepRecord.h:196
Event finding and building.
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:858