GENIEGenerator
Loading...
Searching...
No Matches
Kinematics.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, The GENIE Collaboration
4 For the full text of the license visit http://copyright.genie-mc.org
5
6 Costas Andreopoulos <c.andreopoulos \at cern.ch>
7 University of Liverpool
8*/
9//____________________________________________________________________________
10
11#include <TMath.h>
12#include <TLorentzVector.h>
13#include <TRootIOCtor.h>
14
17
18using std::endl;
19
20using namespace genie;
21
23
24//____________________________________________________________________________
25namespace genie {
26 ostream & operator << (ostream & stream, const Kinematics & kinematics)
27 {
28 kinematics.Print(stream);
29 return stream;
30 }
31}
32//___________________________________________________________________________
34TObject()
35{
36 this->Init();
37}
38//____________________________________________________________________________
40TObject()
41{
42 this->Init();
43 this->Copy(kinematics);
44}
45//____________________________________________________________________________
47TObject(),
48fP4Fsl(0),
50{
51
52}
53//____________________________________________________________________________
55{
56 this->CleanUp();
57}
58//____________________________________________________________________________
60{
61 fKV.clear();
62
63 fP4Fsl = new TLorentzVector;
64 fP4HadSyst = new TLorentzVector;
65}
66//____________________________________________________________________________
68{
69 fKV.clear();
70
71 delete fP4Fsl;
72 delete fP4HadSyst;
73}
74//____________________________________________________________________________
76{
77 fKV.clear();
78
79 this->SetFSLeptonP4 (0,0,0,0);
80 this->SetHadSystP4 (0,0,0,0);
81}
82//____________________________________________________________________________
83void Kinematics::Copy(const Kinematics & kinematics)
84{
85 this->Reset();
86
87 map<KineVar_t, double>::const_iterator iter;
88
89 for(iter = kinematics.fKV.begin(); iter != kinematics.fKV.end(); ++iter) {
90 KineVar_t kv = iter->first;
91 double val = iter->second;
92 this->SetKV(kv,val);
93 }
94
95 this->SetFSLeptonP4 (*kinematics.fP4Fsl);
96 this->SetHadSystP4 (*kinematics.fP4HadSyst);
97}
98//____________________________________________________________________________
99double Kinematics::x(bool selected) const
100{
101// returns the running or selected value of Bjorken scaling variable x
102
103 KineVar_t kvar = (selected) ? kKVSelx : kKVx;
104
105 if(this->KVSet(kvar)) { return this->GetKV(kvar); }
106 else {
107 LOG("Interaction", pWARN) << "Kinematic variable x was not set";
108 }
109 return -99999;
110}
111//____________________________________________________________________________
112double Kinematics::y(bool selected) const
113{
114// returns the running or selected value of inelasticity y
115
116 KineVar_t kvar = (selected) ? kKVSely : kKVy;
117
118 if(this->KVSet(kvar)) { return this->GetKV(kvar); }
119 else {
120 LOG("Interaction", pWARN) << "Kinematic variable y was not set";
121 }
122 return -99999;
123}
124//____________________________________________________________________________
125double Kinematics::Q2(bool selected) const
126{
127// returns the running or selected value of momentum transfer Q2 (>0)
128
129 if(selected) {
130 if (this->KVSet(kKVSelQ2) ) { return this->GetKV(kKVSelQ2); }
131 else if (this->KVSet(kKVSelq2) ) { return -1* this->GetKV(kKVSelq2); }
132 } else {
133 if (this->KVSet(kKVQ2) ) { return this->GetKV(kKVQ2); }
134 else if (this->KVSet(kKVq2) ) { return -1* this->GetKV(kKVq2); }
135 }
136
137 LOG("Interaction", pWARN) << "Kinematic variable Q2 was not set";
138 return -99999;
139}
140//____________________________________________________________________________
141double Kinematics::q2(bool selected) const
142{
143// returns the running or selected value of momentum transfer q2 (<0)
144
145 if(selected) {
146 if (this->KVSet(kKVSelQ2) ) { return -1* this->GetKV(kKVSelQ2); }
147 else if (this->KVSet(kKVSelq2) ) { return this->GetKV(kKVSelq2); }
148 } else {
149 if (this->KVSet(kKVQ2) ) { return -1* this->GetKV(kKVQ2); }
150 else if (this->KVSet(kKVq2) ) { return this->GetKV(kKVq2); }
151 }
152
153 LOG("Interaction", pWARN) << "Kinematic variable q2 was not set";
154 return -99999;
155}
156//____________________________________________________________________________
157double Kinematics::W(bool selected) const
158{
159// returns the running or selected value of invariant hadronic mass W
160
161 KineVar_t kvar = (selected) ? kKVSelW : kKVW;
162
163 if(this->KVSet(kvar)) { return this->GetKV(kvar); }
164 else {
165 LOG("Interaction", pWARN) << "Kinematic variable W was not set";
166 }
167 return -99999;
168}
169//____________________________________________________________________________
170double Kinematics::t(bool selected) const
171{
172// returns the running or selected value of invariant hadronic mass W
173
174 KineVar_t kvar = (selected) ? kKVSelt : kKVt;
175
176 if(this->KVSet(kvar)) { return this->GetKV(kvar); }
177 else {
178 LOG("Interaction", pWARN) << "Kinematic variable t was not set";
179 }
180 return -99999;
181}
182//____________________________________________________________________________
183double Kinematics::Logx(bool selected) const
184{
185 double xs = this->x(selected);
186 return (xs>0) ? TMath::Log(xs) : -99999;
187}
188//____________________________________________________________________________
189double Kinematics::Logy(bool selected) const
190{
191 double ys = this->y(selected);
192 return (ys>0) ? TMath::Log(ys) : -99999;
193}
194//____________________________________________________________________________
195double Kinematics::LogQ2(bool selected) const
196{
197 double Q2s = this->Q2(selected);
198 return (Q2s>0) ? TMath::Log(Q2s) : -99999;
199}
200//____________________________________________________________________________
201double Kinematics::LogW(bool selected) const
202{
203 double Ws = this->W(selected);
204 return (Ws>0) ? TMath::Log(Ws) : -99999;
205}
206//____________________________________________________________________________
207double Kinematics::Log10x(bool selected) const
208{
209 double xs = this->x(selected);
210 return (xs>0) ? TMath::Log10(xs) : -99999;
211}
212//____________________________________________________________________________
213double Kinematics::Log10y(bool selected) const
214{
215 double ys = this->y(selected);
216 return (ys>0) ? TMath::Log10(ys) : -99999;
217}
218//____________________________________________________________________________
219double Kinematics::Log10Q2(bool selected) const
220{
221 double Q2s = this->Q2(selected);
222 return (Q2s>0) ? TMath::Log10(Q2s) : -99999;
223}
224//____________________________________________________________________________
225double Kinematics::Log10W(bool selected) const
226{
227 double Ws = this->W(selected);
228 return (Ws>0) ? TMath::Log10(Ws) : -99999;
229}
230//____________________________________________________________________________
231void Kinematics::Setx(double xbj, bool selected)
232{
233// sets the running or selected value of Bjorken scaling variable x
234
235 if(xbj<0 || xbj>1) {
236 LOG("Interaction", pWARN)
237 << "Setting unphysical value for x (x = " << xbj << ")";
238 }
239 KineVar_t kvar = (selected) ? kKVSelx : kKVx;
240 this->SetKV(kvar, xbj);
241}
242//____________________________________________________________________________
243void Kinematics::Sety(double inel_y, bool selected)
244{
245// sets the running or selected value of inelasticity y
246
247 if(inel_y<0 || inel_y>1) {
248 LOG("Interaction", pWARN)
249 << "Setting unphysical value for y (y = " << inel_y << ")";
250 }
251 KineVar_t kvar = (selected) ? kKVSely : kKVy;
252 this->SetKV(kvar, inel_y);
253}
254//____________________________________________________________________________
255void Kinematics::SetQ2(double Qsqrd, bool selected)
256{
257// sets the running or selected value of momentum transfer Q2 (>0)
258
259 if(Qsqrd<0) {
260 LOG("Interaction", pWARN)
261 << "Setting unphysical value for Q2 (Q2 = " << Qsqrd << ")";
262 }
263 KineVar_t kvar = (selected) ? kKVSelQ2 : kKVQ2;
264 this->SetKV(kvar, Qsqrd);
265}
266//____________________________________________________________________________
267void Kinematics::Setq2(double qsqrd, bool selected)
268{
269// sets the running or selected value of momentum transfer q2 (<0)
270
271 if(qsqrd>0) {
272 LOG("Interaction", pWARN)
273 << "Setting unphysical value for q2 (q2 = " << qsqrd << ")";
274 }
275 KineVar_t kvar = (selected) ? kKVSelq2 : kKVq2;
276 this->SetKV(kvar, qsqrd);
277}
278//____________________________________________________________________________
279void Kinematics::SetW(double hadr_mass_W, bool selected)
280{
281// sets the running or selected value of invariant hadronic mass W
282
283 if(hadr_mass_W<0) {
284 LOG("Interaction", pWARN)
285 << "Setting unphysical value for W (W = " << hadr_mass_W << ")";
286 }
287 KineVar_t kvar = (selected) ? kKVSelW : kKVW;
288 this->SetKV(kvar, hadr_mass_W);
289}
290//____________________________________________________________________________
291void Kinematics::Sett(double tval, bool selected)
292{
293 KineVar_t kvar = (selected) ? kKVSelt : kKVt;
294 this->SetKV(kvar, tval);
295}
296//____________________________________________________________________________
297void Kinematics::SetFSLeptonP4(const TLorentzVector & p4)
298{
299 fP4Fsl->SetPxPyPzE(p4.Px(), p4.Py(), p4.Pz(), p4.E());
300}
301//____________________________________________________________________________
302void Kinematics::SetFSLeptonP4(double px, double py, double pz, double E)
303{
304 fP4Fsl->SetPxPyPzE(px,py,pz,E);
305}
306//____________________________________________________________________________
307void Kinematics::SetHadSystP4(const TLorentzVector & p4)
308{
309 fP4HadSyst->SetPxPyPzE(p4.Px(), p4.Py(), p4.Pz(), p4.E());
310}
311//____________________________________________________________________________
312void Kinematics::SetHadSystP4(double px, double py, double pz, double E)
313{
314 fP4HadSyst->SetPxPyPzE(px,py,pz,E);
315}
316//____________________________________________________________________________
318{
319 if(fKV.count(kv) == 1) return true;
320 else return false;
321}
322//____________________________________________________________________________
324{
325 if(this->KVSet(kv)) {
326 map<KineVar_t, double>::const_iterator iter = fKV.find(kv);
327 return iter->second;
328 } else {
329 LOG("Interaction", pWARN)
330 << "Kinematic variable: " << KineVar::AsString(kv) << " was not set";
331 }
332 return -99999;
333}
334//____________________________________________________________________________
335void Kinematics::SetKV(KineVar_t kv, double value)
336{
337 LOG("Interaction", pDEBUG)
338 << "Setting " << KineVar::AsString(kv) << " to " << value;
339
340 if(this->KVSet(kv)) {
341 fKV[kv] = value;
342 } else {
343 fKV.insert( map<KineVar_t, double>::value_type(kv,value) );
344 }
345}
346//____________________________________________________________________________
348{
349// clear the running values (leave the selected ones)
350//
351 fKV.erase( kKVx );
352 fKV.erase( kKVy );
353 fKV.erase( kKVQ2 );
354 fKV.erase( kKVq2 );
355 fKV.erase( kKVW );
356 fKV.erase( kKVt );
357}
358//____________________________________________________________________________
360{
361// copy the selected kinematics into the running ones
362//
363 map<KineVar_t, double>::const_iterator iter;
364 iter = fKV.find(kKVSelx);
365 if(iter != fKV.end()) this->Setx(iter->second);
366 iter = fKV.find(kKVSely);
367 if(iter != fKV.end()) this->Sety(iter->second);
368 iter = fKV.find(kKVSelQ2);
369 if(iter != fKV.end()) this->SetQ2(iter->second);
370 iter = fKV.find(kKVSelq2);
371 if(iter != fKV.end()) this->Setq2(iter->second);
372 iter = fKV.find(kKVSelW);
373 if(iter != fKV.end()) this->SetW(iter->second);
374 iter = fKV.find(kKVSelt);
375 if(iter != fKV.end()) this->Sett(iter->second);
376}
377//____________________________________________________________________________
378void Kinematics::Print(ostream & stream) const
379{
380 stream << "[-] [Kinematics]" << endl;
381
382 map<KineVar_t, double>::const_iterator iter;
383
384 for(iter = fKV.begin(); iter != fKV.end(); ++iter) {
385 KineVar_t kv = iter->first;
386 double val = iter->second;
387 stream << " |--> " << KineVar::AsString(kv) << " = " << val << endl;
388 }
389}
390//____________________________________________________________________________
392{
393 this->Copy(kinematics);
394 return (*this);
395}
396//___________________________________________________________________________
ClassImp(Kinematics) namespace genie
#define pDEBUG
Definition Messenger.h:63
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
#define pWARN
Definition Messenger.h:60
static string AsString(KineVar_t kv)
Definition KineVar.h:77
Generated/set kinematical variables for an event.
Definition Kinematics.h:39
void SetHadSystP4(const TLorentzVector &p4)
map< KineVar_t, double > fKV
selected kinematics
Definition Kinematics.h:102
double Logy(bool selected=false) const
void Setx(double x, bool selected=false)
double LogW(bool selected=false) const
void SetQ2(double Q2, bool selected=false)
bool KVSet(KineVar_t kv) const
TLorentzVector * fP4Fsl
generated final state primary lepton 4-p (LAB)
Definition Kinematics.h:103
double Q2(bool selected=false) const
double t(bool selected=false) const
void Sett(double t, bool selected=false)
void Copy(const Kinematics &kine)
double y(bool selected=false) const
double Log10y(bool selected=false) const
double GetKV(KineVar_t kv) const
double Log10x(bool selected=false) const
double Log10W(bool selected=false) const
double Logx(bool selected=false) const
double W(bool selected=false) const
double LogQ2(bool selected=false) const
TLorentzVector * fP4HadSyst
generated final state hadronic system 4-p (LAB)
Definition Kinematics.h:104
double q2(bool selected=false) const
void Setq2(double q2, bool selected=false)
void Init(void)
initialize
double Log10Q2(bool selected=false) const
void ClearRunningValues(void)
void Print(ostream &stream) const
void SetKV(KineVar_t kv, double value)
void Sety(double y, bool selected=false)
void SetW(double W, bool selected=false)
void SetFSLeptonP4(const TLorentzVector &p4)
Kinematics & operator=(const Kinematics &kine)
void CleanUp(void)
clean-up
void UseSelectedKinematics(void)
double x(bool selected=false) const
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
@ kKVQ2
Definition KineVar.h:33
@ kKVSelt
Definition KineVar.h:46
@ kKVSely
Definition KineVar.h:42
@ kKVSelW
Definition KineVar.h:45
@ kKVSelx
Definition KineVar.h:41
@ kKVx
Definition KineVar.h:31
@ kKVy
Definition KineVar.h:32
@ kKVW
Definition KineVar.h:35
@ kKVSelq2
Definition KineVar.h:44
@ kKVq2
Definition KineVar.h:34
@ kKVt
Definition KineVar.h:36
@ kKVSelQ2
Definition KineVar.h:43
enum genie::EKineVar KineVar_t
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)