FairRoot/PandaRoot
PndDpmDirect.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndDpmDirect source file -----
3 // ----- -----
4 // -------------------------------------------------------------------------
5 
6 
7 #include <iostream>
8 #include "TClonesArray.h"
9 #include "TFile.h"
10 #include "TLorentzVector.h"
11 #include "TTree.h"
12 #include "TVector3.h"
13 #include "TParticle.h"
14 #include "PndDpmDirect.h"
15 #include "FairPrimaryGenerator.h"
16 #include "TRandom.h"
17 
18 using namespace std;
19 
20 #include "cfortran.h"
21 extern "C" {
22 // COMMON /LUJETS/ N,K(1000,2),P(1000,5)
23 // n - number of produced particles,
24 // k[] - Pythia particle identifiers
25 // p[] - kinematical characteristics of particles
26 
27 
28  typedef struct {
29  int n, k[2000];
30  double p[5000];
31  } lujets;
32 
33  #define LUJETS COMMON_BLOCK(LUJETS,lujets)
35 
36 }
37 
38 extern "C" int init1_(double* Plab, double* seed, double* Elastic, double* tetmin );//install DPM
39 extern "C" int dpm_gen_(double* Generator, double* seed ); //to generate events
40 extern "C" int chstatus_(int* iPDG, int* iStatus); //to change Particle status
41 
43 
44 // ----- Default constructor ------------------------------------------
46 
47 }
48 // ------------------------------------------------------------------------
49 
50 // ----- Standard constructor -----------------------------------------
51 
52 PndDpmDirect::PndDpmDirect(Double_t Mom, Int_t Mode, Long_t Seed) {
53 
54 //
55 // Calculate ThtMin first. For this we make a cut-off on the value of -t of 1e-2 GeV^2 (~100 MeV/c momentum)
56 // This estimated from a parametrization found in thesis of Thomas Wuerschig (figure 6.4, page 121):
57 // Roughly: 0.4 deg at 15 GeV/c and 4 deg at 1.5 GeV/c, lineair interpolation in double log-scale.
58 //
59 
60  Double_t logangle = TMath::Log(0.4)+(TMath::Log(15.)-TMath::Log(Mom))*(TMath::Log(4)-TMath::Log(0.4))/(TMath::Log(15)-TMath::Log(1.5));
61  Double_t ThtMin = TMath::Exp(logangle);
62 
63  PndDpmDirect(Mom, Mode, Seed, ThtMin) ;
64 }
65 
66 PndDpmDirect::PndDpmDirect(Double_t Mom, Int_t Mode, Long_t Seed, Double_t ThtMin) {
67  fMom = Mom;
68  fMode = Mode;
69  fSeed = Seed;
70  fThtMin = ThtMin;
71 
72  if (fSeed < 0)
73  {
74  Long_t iSeed = gRandom->GetSeed();
75  int a = iSeed/100000;
76  fSeed=iSeed - a*100000 + a/100000.;
77  }
78 
79  fGasmode = 0;
80  fRsigma = 0.;
81  fDensityFunction = new TF1();
82 
83  cout << "<I> PndDpmDirect initialization" << endl;
84  cout << "<I> Momentum = " << fMom << endl;
85  cout << "<I> Seed = " << fSeed << endl;
86  cout << "<I> Mode = " << fMode << endl;
87  cout << "<I> Theta min = " << fThtMin<<endl;
88 
89  init1_(&fMom,&fSeed,&fMode, &fThtMin); // init the DPM generator
90 }
91 // ------------------------------------------------------------------------
92 
93 // ----- Gas mode constructor -----------------------------------------
94 PndDpmDirect::PndDpmDirect(Double_t Mom, Int_t Mode, Double_t Rsigma, TF1* DensityFunction, Long_t Seed, Double_t ThtMin) {
95  fMom = Mom;
96  fMode = Mode;
97  fSeed = Seed;
98  fThtMin = ThtMin;
99 
100  if (fSeed < 0)
101  {
102  Long_t iSeed = gRandom->GetSeed();
103  int a = iSeed/100000;
104  fSeed=iSeed - a*100000 + a/100000.;
105  }
106 
107  fGasmode = 1;
108  fRsigma = Rsigma;
109  fDensityFunction = DensityFunction;
110 
111  cout << "<I> PndDpmDirect initialization" << endl;
112  cout << "<I> Momentum = " << fMom << endl;
113  cout << "<I> Seed = " << fSeed << endl;
114  cout << "<I> Mode = " << fMode << endl;
115  cout << "<I> Gasmode = " << fGasmode << endl;
116  cout << "<I> Theta min = " << fThtMin<<endl;
117 
118  init1_(&fMom,&fSeed,&fMode, &fThtMin); // init the DPM generator
119 }
120 // ------------------------------------------------------------------------
121 
122 // ----- Destructor ---------------------------------------------------
124 
125 }
126 // -----Set particle type stable ------------------------------------------
128 {
129  int status=1;
130  chstatus_(&pdg, &status);
131 }
132 
133 // -----Set particle type unstable ----------------------------------------
135 {
136  int status=0;
137  chstatus_(&pdg, &status);
138 }
139 // ------------------------------------------------------------------------
140 
141 
142 // ----- Public method ReadEvent --------------------------------------
143 Bool_t PndDpmDirect::ReadEvent(FairPrimaryGenerator* primGen) {
144 
145  int npart, i;
146  Double_t fX, fY, fZ, radius;
147  double Px[1000],Py[1000],Pz[1000]; //,E[1000],Pm[1000],Wh[1000]; //[R.K. 01/2017] unused variables
148  int Id[1000];
149 
150  double Generator=0.; // Format in which events are produced (0=pythia, 1=pluto)
151 
152  //Double_t weight = 1.0; //[R.K. 01/2017] unused variable?
153  //Int_t activeCnt=0; //[R.K. 01/2017] unused variable?
154 
155  // run generator
156  dpm_gen_(&Generator, &fSeed);
157 
158  // Loop over all produced particles
159  npart = lujets_.n;
160 
161  for (i= 0; i< npart; ++i) {
162 
163  Id[i]=lujets_.k[i+1000];
164  Px[i]=lujets_.p[i];
165  Py[i]=lujets_.p[i+1000];
166  Pz[i]=lujets_.p[i+2000];
167  //Pm[i]=lujets_.p[i+4000];
168  //E[i]=lujets_.p[i+3000];
169  //Wh[i]=1.0;
170 
171  /* Check if fGasmode is set */
172  fX = 0.;
173  fY = 0.;
174  fZ = 0.;
175  if (fGasmode == 1) {
176 
177  // define position of track start
178  // Random 2D point in a circle of radius r (simple beamprofile)
179  radius = gRandom->Gaus(0,fRsigma);
180  gRandom->Circle(fX, fY, radius);
181 
182  // calculate fZ according to some (probability) density function of the gas
183  fZ=fDensityFunction->GetRandom();
184 
185  }
186 
187  // add track
188  //printf("- I -: new particle at: %f, %f, %f ...\n", fX, fY, fZ);
189  primGen->AddTrack(Id[i], Px[i], Py[i], Pz[i], fX, fY, fZ);
190 
191  }
192 
193  return kTRUE;
194 
195 }
196 // ------------------------------------------------------------------------
197 
199 
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)
Double_t p
Definition: anasim.C:58
COMMON_BLOCK_DEF(lujets, LUJETS)
Int_t i
Definition: run_full.C:25
#define LUJETS
Double_t fX
Definition: PndCaloDraw.cxx:34
UInt_t fSeed
Definition: run_full.C:15
Double_t fZ
Definition: PndCaloDraw.cxx:34
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
TF1 * fDensityFunction
void SetUnstable(int pdg)
void SetStable(int pdg)
Int_t a
Definition: anaLmdDigi.C:126
Double_t
unsigned int seed
virtual ~PndDpmDirect()
int chstatus_(int *iPDG, int *iStatus)
int init1_(double *Plab, double *seed, double *Elastic, double *tetmin)
Double_t fY
Definition: PndCaloDraw.cxx:34
static T Log(const T &x)
Definition: PndCAMath.h:40
ClassImp(PndAnaContFact)
int dpm_gen_(double *Generator, double *seed)
int status[10]
Definition: f_Init.h:28