FairRoot/PandaRoot
PndCorrDistGenerator.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndCorrDistGenerator source file -----
3 // ----- Created 23/05/07 by Galoyan Aida -----
4 // -------------------------------------------------------------------------
5 
6 
7 #include <iostream>
8 #include "TClonesArray.h"
9 #include "TFile.h"
10 #include "TLorentzVector.h"
11 #include "TRandom.h"
12 #include "TMath.h"
13 #include "TH2F.h"
14 #include "TF1.h"
15 #include "TVector3.h"
16 //#include "THParticle.h"
17 #include "PndCorrDistGenerator.h"
18 #include "FairPrimaryGenerator.h"
19 
20 
21 using namespace std;
22 
23 // ----- Default constructor ------------------------------------------
25  iEvent = 0;
26  fInputFile = NULL;
27  fInputHist = NULL;
28  fPdgType = 0;
29  fParam = kFALSE;
30  fTheLow =0.;
31  fTheHigh =0.;
32 }
33 // ------------------------------------------------------------------------
34 
35 
36 //
37 // ----- Standard constructor -----------------------------------------
39  iEvent = 0;
40  fFileName = fileName;
41  fInputFile = new TFile(fFileName);
42  if(fParam){cout<<"choosing parametrization modell"<<endl;}
43  else{
44  cout<<" Random events gerated from a TH2D P(th) dist-->GiBUU Modell"<<endl;
45  fInputHist = (TH2F*) fInputFile->Get("source");
46  }
47 
48 }
49 // ------------------------------------------------------------------------
50 
51 
52 // ----- Destructor ---------------------------------------------------
54  CloseInput();
55 }
56 // ------------------------------------------------------------------------
57 
58 
59 // ----- Public method ReadEvent --------------------------------------
61 
62  // Check for input file
63  if ( ! fInputFile ) {
64  cout << "-E PndCorrDistGenerator: Input file nor open!" << endl;
65  return kFALSE;
66  }
67 
68  //defining kinematics variables, angle is expressed in degrees.
69 
70  Double_t phi, p=0.0,theta=0.0;
71  Double_t pz=0.,py=0.,px=0.;
72 
73 
74  phi = gRandom->Uniform(0,360)* TMath::DegToRad();
75 
76  TF1 *lan;//Landau
77  TF1 *exp; // exponential
78  TF1 *MBol;
79  // relativistic Maxwell Boltzmann dist <v> (Maxwell-Juettner dist), mean velocity
80  // For more INFO see, http://en.wikipedia.org/wiki/Maxwell–Jüttner_distribution
81 
82  Double_t mean_p=0.;
83 
84  if(fParam){
85 
86  //--> Landau, dsigma/dtheta dist
87 
88  //Constant 1.03980e+03 //Peak height (kFALSE-->0), no integral,
89  //MPV 1.10093e+01
90  //Sigma 4.65284e+00
91 
92  lan = new TF1("lan","1.03980e+03*TMath::Landau(x,[0],[1],0)",fTheLow,fTheHigh);
93  lan->SetParameters(1.10093e+01,4.65284e+00);
94 
95  // getting theta
96  theta = lan->GetRandom();
97 
98  // <p> --- > Max. Boltzmann dist --> p
99 
100  //more or less -->exponential <P>(theta)
101  //Constant 4.93964e-01
102  // Slope -1.41427e-02
103 
104 
105  mean_p = MeanMomentum(theta);// getting <p>
106  p = MaxBoltDistP(mean_p);
107 
108  pz = p*TMath::Cos(theta* TMath::DegToRad());
109  py = p*TMath::Sin(theta* TMath::DegToRad())*TMath::Sin(phi);
110  px = p*TMath::Sin(theta* TMath::DegToRad())*TMath::Cos(phi);
111 
112  }else{
113  //getting p and theta randomly from a TH2F object
114  //both variables are correlated to each other
115  //phi is independtly generated over the full angular range.
116 
117  fInputHist->GetRandom2(theta,p);
118 
119 
120 
121  pz = p*TMath::Cos(theta* TMath::DegToRad());
122  py = p*TMath::Sin(theta* TMath::DegToRad())*TMath::Sin(phi);
123  px = p*TMath::Sin(theta* TMath::DegToRad())*TMath::Cos(phi);
124  }
125  // vertex coordinates given during generation via prim generator
126 
127  // Give track to PrimaryGenerator
128  // multiplocity equal to 1
129  // pdg is -3312, corresponding to a Xi minus
130 
131  fPdgType==3312;
132 
133  //cout<<" generating Xi minus "<<px<<" "<<py<<" "<<pz<<endl;
134 
135  primGen->AddTrack(3312, px, py, pz, 0., 0., 0.);
136 
137 
138 
139  return kTRUE;
140 
141 }
142 // ------------------------------------------------------------------------
143 
144 
145 // ----- Private method CloseInput ------------------------------------
147  if ( fInputFile ) {
148  cout << "-I PndCorrDistGenerator: Closing input file " << fFileName
149  << endl;
150  fInputFile->Close();
151  delete fInputFile;
152  }
153  fInputFile = NULL;
154 }
155 // ------------------------------------------------------------------------
156 // ----- Private method MeanMomentum ------------------------------------
158 
159  cout << "-I PndCorrDistGenerator: Calculating Mean Momentum as function of theta" << endl;
160  //f(x) = exp(p0+p1*x)
161  Double_t fitval = TMath::Exp((4.93964e-01)-(thet*1.41427e-02));
162  return fitval;
163 
164 }
165 // ----- Private method MeanMomentum ------------------------------------
167 
168  Double_t Et=0.,EK=0.,v=0.,gamma=0.,zet=0.,sigma=0.;
169 
170  Et = TMath::Sqrt((MeanP*MeanP)+ (1.321*1.321)); // rel. energy, speed of light c = 1.
171  v = MeanP/Et; // v = beta*c/Etotal
172  gamma = 1./TMath::Sqrt(1.-(v*v)); // gamma factor
173  EK = gamma*1.321 - 1.321; //rel. kinetic energy, mass of Xi_minus = 1.321 GeV/c2
174  zet = EK/1.321;
175 
176 
177  sigma = TMath::Sqrt(3*zet);
178  Double_t limLow,limHigh;
179  limLow = MeanP*0.882;
180  limHigh = MeanP*1.085;
181  //Double_t beta =
182 
183  TF1* MBol = new TF1("mb","TMath::Gaus(x,[0],[1])",limLow,limHigh);
184  // TF1* MBol = new TF1("mb","TMath::Exp(-TMath::Sqrt(1.+ (TMath::Power(x/[0],2))))/(4*TMath::Power([0],3)*TMath::Pi()*[1]*TMath::BesselK(2,1/[1]))",-2.,3);
185  //TF1* MBol = new TF1("mb","x*x*[1]*TMath::Exp(-x/[0])/([0]*TMath::BesselK(2,1/[0]))",0.,3);
186  //MBol->SetParameter(0,1.321);
187  //MBol->SetParameter(1,zet);
188  // MBol->SetParameter(0,zet);
189  //MBol->SetParameter(1,v);
190  MBol->SetParameter(0,MeanP);
191  MBol->SetParameter(1,sigma);
192 
193  cout << "-I PndCorrDistGenerator: Calculating Momentum distribution via MB <v >" << endl;
194  Double_t fitval = MBol->GetRandom();
195 
196  return fitval;
197 
198 }
199 
Double_t p
Definition: anasim.C:58
friend F32vec4 exp(const F32vec4 &a)
Definition: P4_F32vec4.h:109
Double_t MeanMomentum(Double_t thet)
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)
static T Sin(const T &x)
Definition: PndCAMath.h:42
Double_t sigma[nsteps]
Definition: dedx_bands.C:65
static T Cos(const T &x)
Definition: PndCAMath.h:43
__m128 v
Definition: P4_F32vec4.h:4
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
Double_t
ClassImp(PndAnaContFact)
Double_t MaxBoltDistP(Double_t MeanP)
double pz[39]
Definition: pipisigmas.h:14