XclsTag.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2020, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5 
6  Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
7  University of Liverpool & STFC Rutherford Appleton Laboratory
8 */
9 //____________________________________________________________________________
10 
11 #include <sstream>
12 
18 
19 using std::endl;
20 using std::ostringstream;
21 
22 using namespace genie;
23 using namespace genie::utils;
24 
26 
27 //____________________________________________________________________________
28 namespace genie {
29  ostream & operator << (ostream & stream, const XclsTag & xcls)
30  {
31  xcls.Print(stream);
32  return stream;
33  }
34 }
35 //___________________________________________________________________________
37 TObject()
38 {
39  this->Reset();
40 }
41 //___________________________________________________________________________
42 XclsTag::XclsTag(const XclsTag & xcls) :
43 TObject()
44 {
45  this->Reset();
46  this->Copy(xcls);
47 }
48 //___________________________________________________________________________
50 {
51 
52 }
53 //___________________________________________________________________________
54 bool XclsTag::IsInclusiveCharm(void) const
55 {
56  return ( this->IsCharmEvent() && (this->CharmHadronPdg() == 0) );
57 }
58 //___________________________________________________________________________
59 void XclsTag::SetCharm(int charm_pdgc)
60 {
61  fIsCharmEvent = true;
62  fCharmedHadronPdg = charm_pdgc; // leave as 0 (default) for inclusive charm
63 }
64 //___________________________________________________________________________
66 {
67  fIsCharmEvent = false;
69 }
70 //___________________________________________________________________________
72 {
73  return ( this->IsStrangeEvent() && (this->StrangeHadronPdg() == 0) );
74 }
75 //___________________________________________________________________________
76 void XclsTag::SetStrange(int strange_pdgc)
77 {
78  fIsStrangeEvent = true;
79  fStrangeHadronPdg = strange_pdgc; // leave as 0 (default) for inclusive strange
80 }
81 //___________________________________________________________________________
83 {
84  fIsStrangeEvent = false;
86 }
87 //___________________________________________________________________________
88 void XclsTag::SetNPions(int npi_plus, int npi_0, int npi_minus)
89 {
90  fNPiPlus = npi_plus;
91  fNPi0 = npi_0;
92  fNPiMinus = npi_minus;
93 }
94 //___________________________________________________________________________
95 void XclsTag::SetNNucleons(int np, int nn)
96 {
97  fNProtons = np;
98  fNNeutrons = nn;
99 }
100 //___________________________________________________________________________
101 void XclsTag::SetNRhos(int nrho_plus, int nrho_0, int nrho_minus)
102 {
103  fNRhoPlus = nrho_plus;
104  fNRho0 = nrho_0;
105  fNRhoMinus = nrho_minus;
106 }
107 //___________________________________________________________________________
109 {
110  fNPi0 = 0;
111  fNPiPlus = 0;
112  fNPiMinus = 0;
113 }
114 //___________________________________________________________________________
116 {
117  fNProtons = 0;
118  fNNeutrons = 0;
119 }
120 //___________________________________________________________________________
122 {
123  fNRho0 = 0;
124  fNRhoPlus = 0;
125  fNRhoMinus = 0;
126 }
127 //___________________________________________________________________________
129 {
130  fResonance = res;
131 }
132 //___________________________________________________________________________
133 void XclsTag::SetDecayMode(int decay_mode)
134 {
135  fDecayMode = decay_mode;
136 }
137 //___________________________________________________________________________
138 void XclsTag::SetFinalQuark(int finalquark_pdgc)
139 {
140  fIsFinalQuarkEvent = true;
141  fFinalQuarkPdg = finalquark_pdgc; // leave as 0 (default) for inclusive charm
142 }
143 //___________________________________________________________________________
144 void XclsTag::SetFinalLepton(int finallepton_pdgc)
145 {
146  fIsFinalLeptonEvent = true;
147  fFinalLeptonPdg = finallepton_pdgc; // leave as 0 (default) for inclusive charm
148 }
149 //___________________________________________________________________________
150 void XclsTag::Reset(void)
151 {
152  fIsStrangeEvent = false ;
153  fIsCharmEvent = false ;
154  fStrangeHadronPdg = 0 ;
155  fCharmedHadronPdg = 0 ;
156  fNProtons = 0 ;
157  fNNeutrons = 0 ;
158  fNPi0 = 0 ;
159  fNPiPlus = 0 ;
160  fNPiMinus = 0 ;
161  fNSingleGammas = 0 ;
162  fNRho0 = 0 ;
163  fNRhoPlus = 0 ;
164  fNRhoMinus = 0 ;
166  fDecayMode = -1 ;
167  fIsFinalQuarkEvent = false;
168  fFinalQuarkPdg = 0;
169  fIsFinalLeptonEvent = false;
170  fFinalLeptonPdg = 0;
171 }
172 //___________________________________________________________________________
173 void XclsTag::Copy(const XclsTag & xcls)
174 {
179  fNProtons = xcls.fNProtons;
180  fNNeutrons = xcls.fNNeutrons;
181  fNPi0 = xcls.fNPi0;
182  fNPiPlus = xcls.fNPiPlus;
183  fNPiMinus = xcls.fNPiMinus;
185  fNRho0 = xcls.fNRho0;
186  fNRhoPlus = xcls.fNRhoPlus;
187  fNRhoMinus = xcls.fNRhoMinus;
188  fResonance = xcls.fResonance;
189  fDecayMode = xcls.fDecayMode;
194 }
195 //___________________________________________________________________________
196 /*
197 bool XclsTag::Compare(const XclsTag & xcls) const
198 {
199  return (
200  fIsCharmEvent == xcls.fIsCharmEvent &&
201  fCharmedHadronPdg == xcls.fCharmedHadronPdg &&
202  fNProtons == xcls.fNProtons &&
203  fNNeutrons == xcls.fNNeutrons &&
204  fNPi0 == xcls.fNPi0 &&
205  fNPiPlus == xcls.fNPiPlus &&
206  fNPiMinus == xcls.fNPiMinus &&
207  fResonance == xcls.fResonance &&
208  fResonance == xcls.fResonance &&
209  );
210 }*/
211 //___________________________________________________________________________
212 string XclsTag::AsString(void) const
213 {
214 // codifies XclsTag state into a compact string
215 
216  ostringstream tag;
217 
218  bool need_separator = false;
219 
220  if(fIsCharmEvent) {
221  tag << "charm:";
223  else tag << "incl";
224  need_separator = true;
225  }
226 
227  if(fIsStrangeEvent) {
228  tag << "strange:";
230  else tag << "incl";
231  need_separator = true;
232  }
233 
234  bool multset =
235  fNProtons>0 || fNNeutrons>0 ||
236  fNPiPlus>0 || fNPiMinus>0 || fNPi0>0 ||
237  fNSingleGammas>0 ||
238  fNRho0>0 || fNRhoPlus>0 || fNRhoMinus>0 ;
239  if(multset) {
240  if(need_separator) tag << ";";
241  tag << "hmult:"
242  << "(p=" << fNProtons << ",n=" << fNNeutrons
243  << ",pi+=" << fNPiPlus << ",pi-=" << fNPiMinus << ",pi0=" << fNPi0
244  << ",gamma=" << fNSingleGammas
245  << ",rho+=" << fNRhoPlus << ",rho-=" << fNRhoMinus << ",rho0=" << fNRho0
246  << ")";
247  }
248 
249  if(this->KnownResonance()) {
250  if(need_separator) tag << ";";
251  tag << "res:" << fResonance;
252  }
253 
254  if(fDecayMode != -1) {
255  tag << "dec:" << fDecayMode;
256  }
257 
258  if(fIsFinalQuarkEvent) {
259  tag << "finalquark:" << fFinalQuarkPdg;
260  }
261 
262  if(fIsFinalLeptonEvent) {
263  tag << "finallepton:" << fFinalLeptonPdg;
264  }
265 
266  return tag.str();
267 }
268 //___________________________________________________________________________
269 void XclsTag::Print(ostream & stream) const
270 {
271  stream << "[-] [Exclusive Process Info] " << endl;
272 
273  stream << " |--> charm prod. : "
275  if(fIsCharmEvent) {
276  if(!fCharmedHadronPdg) stream << " [inclusive]";
277  else {
278  stream << " - Charm hadron PDG-code = " << fCharmedHadronPdg;
279 
280  TParticlePDG * chadr = PDGLibrary::Instance()->Find( fCharmedHadronPdg );
281  if(chadr)
282  stream << " (" << chadr->GetName() << ")";
283  }
284  }
285 
286  stream << " |--> strange prod. : "
288  if(fIsStrangeEvent) {
289  if(!fStrangeHadronPdg) stream << " [inclusive]";
290  else {
291  stream << " - Strange hadron PDG-code = " << fStrangeHadronPdg;
292 
293  TParticlePDG * chadr = PDGLibrary::Instance()->Find( fStrangeHadronPdg );
294  if(chadr)
295  stream << " (" << chadr->GetName() << ")";
296  }
297  }
298 
299  stream << endl;
300 
301  stream << " |--> f/s nucleons :"
302  << " N(p) = " << fNProtons
303  << " N(n) = " << fNNeutrons
304  << endl;
305 
306  stream << " |--> f/s pions :"
307  << " N(pi^0) = " << fNPi0
308  << " N(pi^+) = " << fNPiPlus
309  << " N(pi^-) = " << fNPiMinus
310  << endl;
311 
312  stream << " |--> f/s Other :"
313  << " N(gamma) = " << fNSingleGammas
314  << " N(Rho^0) = " << fNRho0
315  << " N(Rho^+) = " << fNRhoPlus
316  << " N(Rho^-) = " << fNRhoMinus
317  << endl;
318 
319  stream << " |--> resonance : ";
320  if(this->KnownResonance()) {
321  stream << res::AsString(fResonance);
322  } else {
323  stream << "[not set]";
324  }
325 
326  stream << endl;
327 
328  stream << " |--> final quark prod. : "
330  if(fIsFinalQuarkEvent) {
331  stream << " - Final Quark PDG-code = " << fFinalQuarkPdg;
332  TParticlePDG * chadr = PDGLibrary::Instance()->Find( fFinalQuarkPdg );
333  if(chadr) stream << " (" << chadr->GetName() << ")";
334  }
335 
336  stream << endl;
337 
338  stream << " |--> final lepton prod. : "
340  if(fIsFinalLeptonEvent) {
341  stream << " - Final Lepton PDG-code = " << fFinalLeptonPdg;
342  TParticlePDG * chadr = PDGLibrary::Instance()->Find( fFinalLeptonPdg );
343  if(chadr) stream << " (" << chadr->GetName() << ")";
344  }
345 
346  stream << endl;
347 }
348 //___________________________________________________________________________
349 //bool XclsTag::operator == (const XclsTag & xcls) const
350 //{
351 // return this->Compare(xcls);
352 //}
353 //___________________________________________________________________________
355 {
356  this->Copy(xcls);
357  return (*this);
358 }
359 //___________________________________________________________________________
void SetNPions(int npi_plus, int npi_0, int npi_minus)
Definition: XclsTag.cxx:88
int fNPiPlus
of pi^+&#39;s in the hadronic system after this Xcls reaction (before FSI)
Definition: XclsTag.h:115
void ResetNNucleons(void)
Definition: XclsTag.cxx:115
void ResetNRhos(void)
Definition: XclsTag.cxx:121
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
int fNSingleGammas
of single gammas in the hadronic system after this Xcls reaction (before FSI)
Definition: XclsTag.h:117
int fCharmedHadronPdg
charmed hadron pdg-code
Definition: XclsTag.h:111
int fFinalQuarkPdg
final quark pdg-code
Definition: XclsTag.h:124
int fNNeutrons
of n&#39;s in the hadronic system after this Xcls reaction (before FSI)
Definition: XclsTag.h:113
bool fIsCharmEvent
true if we have charm production
Definition: XclsTag.h:109
bool KnownResonance(void) const
Definition: XclsTag.h:68
void UnsetStrange(void)
Definition: XclsTag.cxx:82
int CharmHadronPdg(void) const
Definition: XclsTag.h:52
bool IsStrangeEvent(void) const
Definition: XclsTag.h:53
bool fIsStrangeEvent
true if we have strange production
Definition: XclsTag.h:108
void Copy(const XclsTag &xcls)
copy input XclsTag object
Definition: XclsTag.cxx:173
int fStrangeHadronPdg
strange hadron pdg-code
Definition: XclsTag.h:110
XclsTag & operator=(const XclsTag &xcls)
copy
Definition: XclsTag.cxx:354
enum genie::EResonance Resonance_t
ostream & operator<<(ostream &stream, const T2KEvGenMetaData &md)
void SetResonance(Resonance_t res)
Definition: XclsTag.cxx:128
void Print(ostream &stream) const
print
Definition: XclsTag.cxx:269
Contains minimal information for tagging exclusive processes.
Definition: XclsTag.h:39
void SetCharm(int charm_pdgc=0)
Definition: XclsTag.cxx:59
bool IsCharmEvent(void) const
Definition: XclsTag.h:50
bool fIsFinalLeptonEvent
true if we have define final lepton
Definition: XclsTag.h:125
void Reset(void)
reset object
Definition: XclsTag.cxx:150
int StrangeHadronPdg(void) const
Definition: XclsTag.h:55
int fNRhoPlus
of rho^+&#39;s in the hadronic system after this Xcls reaction (before FSI)
Definition: XclsTag.h:119
int fDecayMode
Definition: XclsTag.h:122
int fNPi0
of pi^0&#39;s in the hadronic system after this Xcls reaction (before FSI)
Definition: XclsTag.h:114
string BoolAsString(bool b)
Definition: PrintUtils.cxx:91
string AsString(void) const
pack into a string code
Definition: XclsTag.cxx:212
void SetStrange(int strange_pdgc=0)
Definition: XclsTag.cxx:76
void SetFinalLepton(int finallepton_pdgc=0)
Definition: XclsTag.cxx:144
int fNRho0
of rho^0&#39;s in the hadronic system after this Xcls reaction (before FSI)
Definition: XclsTag.h:118
bool fIsFinalQuarkEvent
true if we have define final quark
Definition: XclsTag.h:123
int fNProtons
of p&#39;s in the hadronic system after this Xcls reaction (before FSI)
Definition: XclsTag.h:112
void SetDecayMode(int decay_mode)
Definition: XclsTag.cxx:133
ClassImp(XclsTag) namespace genie
Definition: XclsTag.cxx:25
bool IsInclusiveStrange(void) const
Definition: XclsTag.cxx:71
int fNRhoMinus
of rho^-&#39;s in the hadronic system after this Xcls reaction (before FSI)
Definition: XclsTag.h:120
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:57
void SetNNucleons(int np, int nn)
Definition: XclsTag.cxx:95
int fFinalLeptonPdg
final lepton pdg-code
Definition: XclsTag.h:126
void ResetNPions(void)
Definition: XclsTag.cxx:108
void SetNRhos(int nrho_plus, int nrho_0, int nrho_minus)
Definition: XclsTag.cxx:101
bool IsInclusiveCharm(void) const
Definition: XclsTag.cxx:54
void UnsetCharm(void)
Definition: XclsTag.cxx:65
const char * AsString(Resonance_t res)
resonance id -> string
TParticlePDG * Find(int pdgc, bool must_exist=true)
Definition: PDGLibrary.cxx:75
void SetFinalQuark(int finalquark_pdgc=0)
Definition: XclsTag.cxx:138
Resonance_t fResonance
baryon resonance excited by probe
Definition: XclsTag.h:121
int fNPiMinus
of pi^-&#39;s in the hadronic system after this Xcls reaction (before FSI)
Definition: XclsTag.h:116
Root of GENIE utility namespaces.
QTextStream & endl(QTextStream &s)