GTruth.cxx
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////
2 /// \file GTruth.h
3 /// \Class to hold the additional information needed to recreate a genie::EventRecord
4 /// \author nathan.mayer@tufts.edu
5 ////////////////////////////////////////////////////////////////////////
6 
7 /// This class stores/retrieves the additional information needed (and not in MCTruth) to recreate a genie::EventRecord
8 /// for genie based event reweighting.
9 
11 
12 #include <vector>
13 #include <iostream>
14 #include <string>
15 #include <sstream> // for ostringstream
16 #include <iomanip>
17 
18 using namespace garana;
19 
20  //---------------------------------------------------------------
22  : fVertexRegion(-1)
23  , fVertex(0, 0, 0, 0)
24  , fweight(0)
25  , fprobability(0)
26  , fXsec(0)
27  , fDiffXsec(0)
28  , fGPhaseSpace(-1)
29 
30  , fProbePDG(-1)
31  , fProbeP4(0, 0, 0, 0)
32  , fTgtP4(0, 0, 0, 0)
33 
34  , ftgtZ(0)
35  , ftgtA(0)
36  , ftgtPDG(0)
37  , fHitNucPDG(kUndefinedValue)
38  , fHitQrkPDG(kUndefinedValue)
39  , fIsSeaQuark(false)
40  , fHitNucP4(0, 0, 0, 0)
41  , fHitNucPos(0)
42 
43  , fGscatter(-1)
44  , fGint(-1)
45 
46  , fgQ2(kUndefinedValue)
47  , fgq2(kUndefinedValue)
48  , fgW(kUndefinedValue)
49  , fgT(kUndefinedValue)
50  , fgX(kUndefinedValue)
51  , fgY(kUndefinedValue)
52  , fFSleptonP4(0, 0, 0, 0)
53  , fFShadSystP4(0, 0, 0, 0)
54 
55  , fIsCharm(false)
56  , fCharmHadronPdg(0)
57  , fIsStrange(false)
58  , fStrangeHadronPdg(0)
59  , fNumProton(-1)
60  , fNumNeutron(-1)
61  , fNumPi0(-1)
62  , fNumPiPlus(-1)
63  , fNumPiMinus(-1)
64  , fResNum(-1)
65  , fDecayMode(-1)
66  {}
67 
69 
70  //check if all data members still initialized from default constructor
71  // note some might retain initial values so check
72  // check if all have init values
73 
74  const TLorentzVector emptyVec(0,0,0,0); //initializes to (0,0,0,0)
75 
76  if(
77  fVertex == emptyVec
78  && fweight == 0
79  && fprobability == 0
80  && fXsec == 0
81  && fDiffXsec == 0
82  && fGPhaseSpace == -1
83  && fProbePDG == -1
84  && fProbeP4 == emptyVec
85  && fTgtP4 == emptyVec
86 
87  && ftgtZ == 0
88  && ftgtA == 0
89  && ftgtPDG == 0
92  && !fIsSeaQuark
93  && fHitNucP4 == emptyVec
94  && fHitNucPos == 0
95 
96  && fGscatter == -1
97  && fGint == -1
98 
99  && fgQ2 == kUndefinedValue
100  && fgq2 == kUndefinedValue
101  && fgW == kUndefinedValue
102  && fgT == kUndefinedValue
103  && fgX == kUndefinedValue
104  && fgY == kUndefinedValue
105  && fFSleptonP4 == emptyVec
106  && fFShadSystP4 == emptyVec
107 
108  && !fIsCharm
109  && fCharmHadronPdg == 0
110  && !fIsStrange
111  && fStrangeHadronPdg == 0
112  && fNumProton == -1
113  && fNumNeutron == -1
114  && fNumPi0 == -1
115  && fNumPiPlus == -1
116  && fNumPiMinus == -1
117  && fResNum == -1
118  && fDecayMode == -1
119  ) {
120  return false;
121  }
122 
123  return true;
124  }
125 
126  namespace gtruthaux {
127  std::string stringifyTLorentzVector(const TLorentzVector& tv4) {
128  std::ostringstream s;
129  s << "[ "
130  << std::setw(11) << tv4.X() << " "
131  << std::setw(11) << tv4.Y() << " "
132  << std::setw(11) << tv4.Z() << " "
133  << std::setw(11) << tv4.T() << " ]";
134  return s.str();
135  }
136  }
137  //......................................................................
138  std::ostream& operator<< (std::ostream& output, const garana::GTruth &gtruth)
139  {
140  output
141  << "GTruth:" << std::endl
142  // 123456789012
143  << " Vertex " << gtruthaux::stringifyTLorentzVector(gtruth.fVertex) << std::endl
144  << " weight " << std::setw(11) << gtruth.fweight << " "
145  << " prob " << std::setw(11) << gtruth.fprobability << std::endl
146  << " Xsec " << std::setw(11) << gtruth.fXsec << " "
147  << " DiffXsec " << std::setw(11) << gtruth.fDiffXsec << " "
148  << " GPhaseSpace " << std::setw(9) << gtruth.fGPhaseSpace << std::endl
149 
150  << " probe " << std::setw(11) << gtruth.fProbePDG << std::endl
151  << " ProbeP4 " << gtruthaux::stringifyTLorentzVector(gtruth.fProbeP4) << std::endl
152  << " TgtP4 " << gtruthaux::stringifyTLorentzVector(gtruth.fTgtP4) << std::endl
153 
154  << " Z A PDG (nuc,qrk) " << std::setw(4) << gtruth.ftgtZ << " "
155  << std::setw(4) << gtruth.ftgtA << " "
156  << std::setw(11) << gtruth.ftgtPDG << " ("
157  << std::setw(11) << gtruth.fHitNucPDG << " "
158  << std::setw(11) << gtruth.fHitQrkPDG << ") "
159  << " IsSeaQuark " << std::setw(4) << ((gtruth.fIsSeaQuark)?"yes":"no") << std::endl
160  << " HitNucP4 " << gtruthaux::stringifyTLorentzVector(gtruth.fHitNucP4) << " "
161  << " HitNucPos " << std::setw(11) << gtruth.fHitNucPos << std::endl
162 
163  << " Gscatter " << std::setw(11) << gtruth.fGscatter << " "
164  << " Gint " << std::setw(11) << gtruth.fGint << std::endl
165 
166  << " Q2 q2 " << std::setw(11) << gtruth.fgQ2 << " "
167  << std::setw(11) << gtruth.fgq2 << std::endl
168  << " W T " << std::setw(11) << gtruth.fgW << " "
169  << std::setw(11) << gtruth.fgT << std::endl
170  << " X Y " << std::setw(11) << gtruth.fgX << " "
171  << std::setw(11) << gtruth.fgY << std::endl
172  << " FSlepton " << gtruthaux::stringifyTLorentzVector(gtruth.fFSleptonP4) << std::endl
173  << " FShadSyst " << gtruthaux::stringifyTLorentzVector(gtruth.fFShadSystP4) << std::endl
174 
175  << " IsCharm " << std::setw(4) << ((gtruth.fIsCharm)?"yes":"no") << " "
176  << " CharmPDG " << std::setw(6) << gtruth.fCharmHadronPdg << " "
177  << " IsStrange " << std::setw(4) << ((gtruth.fIsStrange)?"yes":"no") << " "
178  << " StrangePDG " << std::setw(6) << gtruth.fStrangeHadronPdg << std::endl
179  << " Np Nn " << std::setw(4) << gtruth.fNumProton << " "
180  << std::setw(4) << gtruth.fNumNeutron << " "
181  << " Npi(0,+,-) " << std::setw(4) << gtruth.fNumPi0 << " "
182  << std::setw(4) << gtruth.fNumPiPlus << " "
183  << std::setw(4) << gtruth.fNumPiMinus << std::endl
184  << " ResNum " << std::setw(4) << gtruth.fResNum << " "
185  << " DecayMode " << std::setw(4) << gtruth.fDecayMode << std::endl
186 
187  << std::endl ;
188 
189  return output;
190  }
191 
192  //ClassImp(GTruth)
bool fIsCharm
did the interaction produce a charmed hadron?
Definition: GTruth.h:69
double fgq2
Definition: GTruth.h:60
TLorentzVector fTgtP4
Definition: GTruth.h:41
int fCharmHadronPdg
Definition: GTruth.h:70
int fStrangeHadronPdg
Definition: GTruth.h:72
std::string string
Definition: nybbler.cc:12
int fNumPiMinus
number of pi minuses after reaction, before FSI
Definition: GTruth.h:77
double fweight
event interaction weight (genie internal)
Definition: GTruth.h:32
static constexpr double kUndefinedValue
Definition: GTruth.h:83
int fNumProton
number of protons after reaction, before FSI
Definition: GTruth.h:73
int fGscatter
neutrino scattering code
Definition: GTruth.h:54
double fgY
Definition: GTruth.h:64
TLorentzVector fFSleptonP4
generated final state primary lepton (LAB frame) // added version 13
Definition: GTruth.h:65
double fgT
Definition: GTruth.h:62
friend std::ostream & operator<<(std::ostream &output, const garana::GTruth &gtruth)
Definition: GTruth.cxx:138
int fNumNeutron
number of neutrons after reaction, before FSI
Definition: GTruth.h:74
int fResNum
resonance number
Definition: GTruth.h:78
TLorentzVector fVertex
Definition: GTruth.h:31
bool IsFilled()
Definition: GTruth.cxx:68
double fprobability
interaction probability
Definition: GTruth.h:33
double fgX
Definition: GTruth.h:63
int ftgtPDG
PDG of Target Nucleus, nucleon only if free.
Definition: GTruth.h:46
std::string stringifyTLorentzVector(const TLorentzVector &tv4)
Definition: GTruth.cxx:78
double fXsec
cross section of interaction
Definition: GTruth.h:34
TLorentzVector fProbeP4
Definition: GTruth.h:40
TLorentzVector fHitNucP4
Definition: GTruth.h:50
int fNumPi0
number of pi0 after reaction, before FSI
Definition: GTruth.h:75
int fDecayMode
Definition: GTruth.h:79
double fHitNucPos
Definition: GTruth.h:51
int fGPhaseSpace
phase space system of DiffXSec
Definition: GTruth.h:36
int fProbePDG
Definition: GTruth.h:39
double fgW
Definition: GTruth.h:61
double fDiffXsec
differential cross section of interaction
Definition: GTruth.h:35
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
int fNumPiPlus
number of pi pluses after reaction, before FSI
Definition: GTruth.h:76
int fHitNucPDG
hit nucleon PDG code
Definition: GTruth.h:47
int fGint
interaction code
Definition: GTruth.h:55
bool fIsSeaQuark
Definition: GTruth.h:49
int fHitQrkPDG
hit quark PDG code
Definition: GTruth.h:48
bool fIsStrange
strange production // added version 13
Definition: GTruth.h:71
TLorentzVector fFShadSystP4
generated final state hadronic system (LAB frame)
Definition: GTruth.h:66
std::string stringifyTLorentzVector(const TLorentzVector &tv4)
Definition: GTruth.cxx:127
double fgQ2
< these are for the internal (on shell) genie kinematics
Definition: GTruth.h:59
static QCString * s
Definition: config.cpp:1042
QTextStream & endl(QTextStream &s)