InteractionData.cpp
Go to the documentation of this file.
1 
2 #include "InteractionData.h"
3 #include <iostream>
4 #include <iomanip>
5 
6 namespace NeutrinoFluxReweight{
7 
9 
10  particle = TDatabasePDG::Instance();
11 
12  gen = 0;
13  Inc_pdg = 0;
14  Prod_pdg= 0;
15 
16  Inc_P = -1000.;
17  Prod_P = -1000.;
18  Inc_Mass = -1000.;
19  Prod_Mass = -1000.;
20 
21  for(int i=0; i<4; i++){
22  Inc_P4[i]=0;
23  Prod_P4[i]=0;
24  if(i<3) Vtx[i]=0;
25  }
26 
27  xF = -1000.;
28  Pz = -1000.;
29  Theta = -1000.;
30  Pt = -1000.;
31 
32  Ecm = -1000.;
33  Betacm = -1000.;
34  Gammacm = -1000.;
35 
36  Vol = "NoDefinied";
37 
38  }
39 
40  InteractionData::InteractionData(int genid, double incMom[], int incPdg, double prodMom[], int prodPdg, std::string volname, std::string procname, double vtx[]){
41 
42  particle = TDatabasePDG::Instance();
43  // Z direction along the direction of the incident particle
44  // Cos between incMom and prodMom:
45  // The units are in GeV
46 
47  InteractionData::gen = genid;
48 
49  InteractionData::Inc_pdg = incPdg;
50  InteractionData::Prod_pdg = prodPdg;
51 
52  InteractionData::Inc_P = std::sqrt(incMom[0]*incMom[0] + incMom[1]*incMom[1] +incMom[2]*incMom[2]);
53  InteractionData::Prod_P = std::sqrt(prodMom[0]*prodMom[0] + prodMom[1]*prodMom[1] +prodMom[2]*prodMom[2]);
54 
55  double cos_theta = (incMom[0]*prodMom[0]+incMom[1]*prodMom[1]+incMom[2]*prodMom[2])/(Inc_P*Prod_P);
56  double sin_theta = std::sqrt(1.-pow(cos_theta,2.0));
57 
58  //Theta in rads:
59  InteractionData::Theta = std::acos(cos_theta);
60 
61  InteractionData::Pt = Prod_P*sin_theta;
62  InteractionData::Pz = Prod_P*cos_theta;
63 
64  if(Inc_pdg != 1000010020)Inc_Mass = particle->GetParticle(Inc_pdg)->Mass();
65  else {Inc_Mass = 1.875;}
66 
67  if(Prod_pdg != 1000010020)Prod_Mass = particle->GetParticle(Prod_pdg)->Mass();
68  else{Prod_Mass = 1.875;}
69 
70  InteractionData::Inc_Mass = particle->GetParticle(Inc_pdg)->Mass();
71  InteractionData::Prod_Mass = particle->GetParticle(Prod_pdg)->Mass();
72 
73 
74  //Ecm, gamma:
75  double inc_E_lab = std::sqrt(Inc_P*Inc_P + pow(Inc_Mass,2));
76  InteractionData::Ecm = std::sqrt(2.*pow(Inc_Mass,2)+2.*inc_E_lab*Inc_Mass);
77  InteractionData::Betacm = std::sqrt(pow(inc_E_lab,2)-pow(Inc_Mass,2.0))/(inc_E_lab + Inc_Mass);
78  InteractionData::Gammacm = 1./std::sqrt(1.-pow(Betacm,2.0));
79 
80  //xF:
81  double prod_E_lab = std::sqrt(Prod_P*Prod_P + pow(Prod_Mass,2));
82  double PL = Gammacm*(Pz-Betacm*prod_E_lab); // PL is measured in CM frame
83  InteractionData::xF = PL*2./Ecm;
84 
85  //4 momenta:
86  Inc_P4[3]=inc_E_lab;
87  Prod_P4[3]=prod_E_lab;
88  for(int i=0; i<3; i++) {Inc_P4[i]=incMom[i]; Prod_P4[i]=prodMom[i];}
89 
90 
91  //Volume:
92  InteractionData::Vol = volname;
93 
94  //Process:
95  InteractionData::Proc = procname;
96 
97  //Vertex:
98  for(int i=0; i<3; i++) Vtx[i]=vtx[i];
99 
100  }
101 
102  //----------------------------------------------------------------------
104 
105  }
106 
107  std::ostream& InteractionData::print(std::ostream& os) const {
108  using namespace std;
109  os<<"in:"<<setw(5)<<Inc_pdg
110  <<"|p3:";
111  for(int i=0; i<3; i++) {
112  os<<setiosflags(ios::fixed) << setprecision(2)<<setw(6)<<Inc_P4[i]<<" ";
113  }
114  os<<"||out:"<<setw(5)<<Prod_pdg
115  <<"|p3:"<<setiosflags(ios::fixed) << setprecision(2);
116  for(int i=0; i<3; i++) {
117  os<<setiosflags(ios::fixed) << setprecision(2)<<setw(6)<<Prod_P4[i]<<" ";
118  }
119  os <<"|v3:";
120  for(int i=0; i<3; i++) {
121  os<<setiosflags(ios::fixed) << setprecision(2)<<setw(5)<<Vtx[i]<<" ";
122  }
123  os<<"xF,pT:"<<xF<<","<<Pt;
124  os<<endl;
125  return os;
126  }
127 
128 }
double Ecm
Center of mass energy of the collision indident particle - nuclear proton.
std::string string
Definition: nybbler.cc:12
constexpr T pow(T x)
Definition: pow.h:72
int Prod_pdg
pdg code of the produced particle
double Pt
Transversal momentum (GeV/c) of the produced particle.
double Vtx[3]
Location of the interaction.
double Pz
Longitudinal momentum (GeV/c) of the produced particle.
std::ostream & print(std::ostream &os) const
STL namespace.
double Inc_P4[4]
Momentum 4 vector of the incident particle, E=p[3].
double Prod_P
Momentum magnitude of the produced particle.
Q_EXPORT QTSManip setprecision(int p)
Definition: qtextstream.h:343
double xF
Feynmann-x of the produced particle: .
double Prod_P4[4]
Momentum 4 vector of the produced particle, E=p[3].
std::string Proc
Interaction process.
double Inc_P
Momentum magnitude of the incident particle.
std::string Vol
Interaction volume.
double Theta
Angle (rad) of the produced particle.
double Inc_Mass
Mass of the incident particle.
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
InteractionData()
Default Constructor.
int Inc_pdg
pdg code of the incident particle
QTextStream & endl(QTextStream &s)
double Prod_Mass
Mass of the produced particle.