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 <costas.andreopoulos \at stfc.ac.uk>
9  University of Liverpool & STFC Rutherford Appleton Lab
10 
11 \created October 1, 2004
12 
13 \cpright Copyright (c) 2003-2019, The GENIE Collaboration
14  For the full text of the license visit http://copyright.genie-mc.org
15  or see $GENIE/LICENSE
16 */
17 //____________________________________________________________________________
18 
19 #ifndef _GHEP_RECORD_H_
20 #define _GHEP_RECORD_H_
21 
22 #include <ostream>
23 #include <vector>
24 
25 #include <TClonesArray.h>
26 #include <TBits.h>
27 
32 
33 class TRootIOCtor;
34 class TLorentzVector;
35 
36 using std::ostream;
37 using std::vector;
38 
39 namespace genie {
40 
41 class GHepRecord;
42 class GHepParticle;
43 
44 ostream & operator << (ostream & stream, const GHepRecord & event);
45 
46 class GHepRecord : public TClonesArray {
47 
48 public :
49  using TClonesArray::Print; // suppress clang 'hides overloaded virtual function [-Woverloaded-virtual]' warnings
50  using TClonesArray::Copy;
51 
52  GHepRecord();
53  GHepRecord(int size);
54  GHepRecord(const GHepRecord & record);
55  GHepRecord(TRootIOCtor*);
56  virtual ~GHepRecord();
57 
58  // Methods to attach / get summary information
59 
60  virtual Interaction * Summary (void) const;
61  virtual void AttachSummary (Interaction * interaction);
62 
63  // Provide a simplified wrapper of the 'new with placement'
64  // TClonesArray object insertion method
65  // ALWAYS use these methods to insert new particles as they check
66  // for the compactness of the daughter lists.
67  // Note that the record might be automatically re-arranged as the
68  // result of your GHepParticle insertion
69 
70  virtual void AddParticle (const GHepParticle & p);
71  virtual void AddParticle (int pdg, GHepStatus_t ist,
72  int mom1, int mom2, int dau1, int dau2,
73  const TLorentzVector & p, const TLorentzVector & v);
74  virtual void AddParticle (int pdg, GHepStatus_t ist,
75  int mom1, int mom2, int dau1, int dau2,
76  double px, double py, double pz, double E,
77  double x, double y, double z, double t);
78 
79  // Methods to search the GHEP record
80 
81  virtual GHepParticle * Particle (int position) const;
82  virtual GHepParticle * FindParticle (int pdg, GHepStatus_t ist, int start) const;
83 
84  virtual int ParticlePosition (int pdg, GHepStatus_t i, int start=0) const;
85  virtual int ParticlePosition (GHepParticle * particle, int start=0) const;
86 
87  virtual vector<int> * GetStableDescendants(int position) const;
88 
89  // Return the mode (lepton+nucleon/nucleus, hadron+nucleon/nucleus, nucleon
90  // decay etc...) by looking at the event entries
91 
93 
94  // Easy access methods for the most frequently used GHEP entries
95 
96  virtual GHepParticle * Probe (void) const;
97  virtual GHepParticle * TargetNucleus (void) const;
98  virtual GHepParticle * RemnantNucleus (void) const;
99  virtual GHepParticle * HitNucleon (void) const;
100  virtual GHepParticle * HitElectron (void) const;
101  virtual GHepParticle * FinalStatePrimaryLepton (void) const;
102  virtual GHepParticle * FinalStateHadronicSystem (void) const;
103  virtual int ProbePosition (void) const;
104  virtual int TargetNucleusPosition (void) const;
105  virtual int RemnantNucleusPosition (void) const;
106  virtual int HitNucleonPosition (void) const;
107  virtual int HitElectronPosition (void) const;
108  virtual int FinalStatePrimaryLeptonPosition (void) const;
109  virtual int FinalStateHadronicSystemPosition (void) const;
110 
111  // Number of GHepParticle occurences in GHEP
112 
113  virtual unsigned int NEntries (int pdg, GHepStatus_t ist, int start=0) const;
114  virtual unsigned int NEntries (int pdg, int start=0) const;
115 
116  // Methods to switch on/off and ask for event record flags
117 
118  virtual TBits * EventFlags (void) const { return fEventFlags; }
119  virtual TBits * EventMask (void) const { return fEventMask; }
120  virtual bool IsUnphysical (void) const { return (fEventFlags->CountBits()>0); }
121  virtual bool Accept (void) const;
122 
123  // Methods to set/get the event weight and cross sections
124 
125  virtual double Weight (void) const { return fWeight; }
126  virtual double Probability (void) const { return fProb; }
127  virtual double XSec (void) const { return fXSec; }
128  virtual double DiffXSec (void) const { return fDiffXSec; }
129  virtual KinePhaseSpace_t DiffXSecVars (void) const { return fDiffXSecPhSp; }
130 
131  virtual void SetWeight (double wght) { fWeight = (wght>0) ? wght : 0.; }
132  virtual void SetProbability (double prob) { fProb = (prob>0) ? prob : 0.; }
133  virtual void SetXSec (double xsec) { fXSec = (xsec>0) ? xsec : 0.; }
134  virtual void SetDiffXSec (double xsec, KinePhaseSpace_t ps)
135  { fDiffXSecPhSp = ps;
136  fDiffXSec = (xsec>0) ? xsec : 0.;
137  }
138 
139  // Set/get event vertex in detector coordinate system
140 
141  virtual TLorentzVector * Vertex (void) const { return fVtx; }
142 
143  virtual void SetVertex (double x, double y, double z, double t);
144  virtual void SetVertex (const TLorentzVector & vtx);
145 
146  // Common event record operations
147 
148  virtual void Copy (const GHepRecord & record);
149  virtual void Clear (Option_t * opt="");
150  virtual void ResetRecord (void);
151  virtual void CompactifyDaughterLists (void);
152  virtual void RemoveIntermediateParticles (void);
153 
154  // Set mask
155  void SetUnphysEventMask(const TBits & mask);
156 
157  // Set/Get print level
158  static void SetPrintLevel(int print_level);
159  static int GetPrintLevel();
160 
161  // Methods & operators to print the record
162 
163  void Print (ostream & stream) const;
164  friend ostream & operator << (ostream & stream, const GHepRecord & event);
165 
166 protected:
167 
168  // Attached interaction
169  Interaction * fInteraction; ///< attached summary information
170 
171  // Vertex position
172  TLorentzVector * fVtx; ///< vertex in the detector coordinate system
173 
174  // Flags (and user-specified mask) for the generated event
175  TBits * fEventFlags; ///< event flags indicating various pathologies or an unphysical event
176  TBits * fEventMask; ///< an input bit-field mask allowing one to ignore bits set in fEventFlags
177 
178  // Event weight, probability and cross-sections
179  double fWeight; ///< event weight
180  double fProb; ///< event probability (for given flux neutrino and density-weighted path-length for target element)
181  double fXSec; ///< cross section for selected event
182  double fDiffXSec; ///< differential cross section for selected event kinematics
183  KinePhaseSpace_t fDiffXSecPhSp; ///< specifies which differential cross-section (dsig/dQ2, dsig/dQ2dW, dsig/dxdy,...)
184 
185  // Utility methods
186  void InitRecord (void);
187  void CleanRecord (void);
188 
189  // Methods used by the daughter list compactifier
190  virtual void UpdateDaughterLists (void);
191  virtual bool HasCompactDaughterList (int pos);
192  virtual void SwapParticles (int i, int j);
193  virtual void FinalizeDaughterLists (void);
194  virtual int FirstNonInitStateEntry (void);
195 
196  //
197  static int fPrintLevel; //! print-level flag, see GHepRecord::Print()
198 
199 private:
200 
201 ClassDef(GHepRecord, 2)
202 
203 };
204 
205 } // genie namespace
206 
207 #endif // _GHEP_RECORD_H_
static void SetPrintLevel(int print_level)
Definition: GHepRecord.cxx:992
virtual void SetXSec(double xsec)
Definition: GHepRecord.h:133
virtual GHepParticle * Particle(int position) const
Definition: GHepRecord.cxx:148
virtual void SetWeight(double wght)
Definition: GHepRecord.h:131
virtual int ParticlePosition(int pdg, GHepStatus_t i, int start=0) const
Definition: GHepRecord.cxx:181
virtual void Copy(const GHepRecord &record)
Definition: GHepRecord.cxx:943
virtual void UpdateDaughterLists(void)
Definition: GHepRecord.cxx:592
double fProb
event probability (for given flux neutrino and density-weighted path-length for target element) ...
Definition: GHepRecord.h:180
void Print(ostream &stream) const
virtual void SwapParticles(int i, int j)
Definition: GHepRecord.cxx:788
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
virtual GHepParticle * HitElectron(void) const
Definition: GHepRecord.cxx:360
virtual Interaction * Summary(void) const
Definition: GHepRecord.cxx:135
virtual GHepParticle * FindParticle(int pdg, GHepStatus_t ist, int start) const
Definition: GHepRecord.cxx:162
virtual KinePhaseSpace_t DiffXSecVars(void) const
Definition: GHepRecord.h:129
virtual int RemnantNucleusPosition(void) const
Definition: GHepRecord.cxx:433
enum genie::EGHepStatus GHepStatus_t
virtual void SetProbability(double prob)
Definition: GHepRecord.h:132
const char * p
Definition: xmltok.h:285
virtual void RemoveIntermediateParticles(void)
Definition: GHepRecord.cxx:653
void InitRecord(void)
Definition: GHepRecord.cxx:873
virtual void FinalizeDaughterLists(void)
Definition: GHepRecord.cxx:835
TLorentzVector * fVtx
vertex in the detector coordinate system
Definition: GHepRecord.h:172
virtual int HitNucleonPosition(void) const
Definition: GHepRecord.cxx:454
virtual double Weight(void) const
Definition: GHepRecord.h:125
TBits * fEventMask
an input bit-field mask allowing one to ignore bits set in fEventFlags
Definition: GHepRecord.h:176
virtual unsigned int NEntries(int pdg, GHepStatus_t ist, int start=0) const
Definition: GHepRecord.cxx:513
enum genie::EKinePhaseSpace KinePhaseSpace_t
virtual void AttachSummary(Interaction *interaction)
Definition: GHepRecord.cxx:143
virtual ~GHepRecord()
Definition: GHepRecord.cxx:130
virtual TLorentzVector * Vertex(void) const
Definition: GHepRecord.h:141
virtual GHepParticle * Probe(void) const
Definition: GHepRecord.cxx:321
Enumeration of GENIE event generation modes.
double fXSec
cross section for selected event
Definition: GHepRecord.h:181
Summary information for an interaction.
Definition: Interaction.h:56
Interaction * fInteraction
attached summary information
Definition: GHepRecord.h:169
TBits * fEventFlags
event flags indicating various pathologies or an unphysical event
Definition: GHepRecord.h:175
virtual bool Accept(void) const
Definition: GHepRecord.cxx:983
Float_t E
Definition: plot.C:20
virtual bool HasCompactDaughterList(int pos)
Definition: GHepRecord.cxx:736
virtual int FirstNonInitStateEntry(void)
Definition: GHepRecord.cxx:775
virtual GHepParticle * FinalStatePrimaryLepton(void) const
Definition: GHepRecord.cxx:370
GEvGenMode_t EventGenerationMode(void) const
Definition: GHepRecord.cxx:253
static int GetPrintLevel()
Definition: GHepRecord.cxx:996
virtual GHepParticle * TargetNucleus(void) const
Definition: GHepRecord.cxx:330
virtual double DiffXSec(void) const
Definition: GHepRecord.h:128
virtual vector< int > * GetStableDescendants(int position) const
Definition: GHepRecord.cxx:218
const double j
Definition: BetheBloch.cxx:29
virtual void ResetRecord(void)
Definition: GHepRecord.cxx:910
virtual int HitElectronPosition(void) const
Definition: GHepRecord.cxx:477
virtual GHepParticle * FinalStateHadronicSystem(void) const
Definition: GHepRecord.cxx:379
z
Definition: test.py:28
Double_t xsec[nknots]
Definition: testXsec.C:47
virtual double Probability(void) const
Definition: GHepRecord.h:126
void Print(std::string prefix, std::string name, std::string suffix="")
Definition: nue_pid_effs.C:68
virtual void CompactifyDaughterLists(void)
Definition: GHepRecord.cxx:687
virtual TBits * EventFlags(void) const
Definition: GHepRecord.h:118
virtual bool IsUnphysical(void) const
Definition: GHepRecord.h:120
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)
virtual void Clear(Option_t *opt="")
Definition: GHepRecord.cxx:919
virtual GHepParticle * HitNucleon(void) const
Definition: GHepRecord.cxx:350
virtual void SetVertex(double x, double y, double z, double t)
Definition: GHepRecord.cxx:863
KinePhaseSpace_t fDiffXSecPhSp
specifies which differential cross-section (dsig/dQ2, dsig/dQ2dW, dsig/dxdy,...)
Definition: GHepRecord.h:183
virtual GHepParticle * RemnantNucleus(void) const
Definition: GHepRecord.cxx:340
virtual double XSec(void) const
Definition: GHepRecord.h:127
friend ostream & operator<<(ostream &stream, const GHepRecord &event)
Definition: GHepRecord.cxx:90
virtual void AddParticle(const GHepParticle &p)
Definition: GHepRecord.cxx:535
double fWeight
event weight
Definition: GHepRecord.h:179
virtual int ProbePosition(void) const
Definition: GHepRecord.cxx:389
void SetUnphysEventMask(const TBits &mask)
Definition: GHepRecord.cxx:974
GENIE&#39;s GHEP MC event record.
Definition: GHepRecord.h:46
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:40
virtual int FinalStateHadronicSystemPosition(void) const
Definition: GHepRecord.cxx:507
double fDiffXSec
differential cross section for selected event kinematics
Definition: GHepRecord.h:182
virtual int FinalStatePrimaryLeptonPosition(void) const
Definition: GHepRecord.cxx:495
virtual int TargetNucleusPosition(void) const
Definition: GHepRecord.cxx:406
static int fPrintLevel
Definition: GHepRecord.h:197
virtual void SetDiffXSec(double xsec, KinePhaseSpace_t ps)
Definition: GHepRecord.h:134
virtual TBits * EventMask(void) const
Definition: GHepRecord.h:119
void CleanRecord(void)
Definition: GHepRecord.cxx:902