FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairBaseMCGenerator.cxx
Go to the documentation of this file.
1 /*
2  * FairSimpleMCGenerator.cxx
3  *
4  * Created on: 16 mar 2020
5  * Author: Daniel Wielanek
6  * E-mail: daniel.wielanek@gmail.com
7  * Warsaw University of Technology, Faculty of Physics
8  */
9 #include "FairBaseMCGenerator.h"
10 
11 #include "FairLogger.h"
12 
13 #include <TDatabasePDG.h>
14 #include <TParticlePDG.h>
15 #include <TRandom.h>
16 
18  : FairGenerator()
19  , fX(0)
20  , fY(0)
21  , fZ(0)
22  , fPDGType(0)
23  , fMult(0)
24  , fVertexSmear(kBox)
25  , fPDGMass(0.0)
26  , fVx(0.0)
27  , fVy(0.0)
28  , fVz(0.0)
29  , fVex(0.0)
30  , fVey(0.0)
31  , fVez(0.0)
32 {}
33 
35  Double_t vy,
36  Double_t vz,
37  Double_t evx,
38  Double_t evy,
39  Double_t evz,
40  eVertexSmear VertexSmear)
41 {
42  fX = fVx = vx;
43  fY = fVy = vy;
44  fZ = fVz = vz;
45  fVex = evx;
46  fVey = evy;
47  fVez = evz;
48  fVertexSmear = VertexSmear;
49 }
50 
52 {
53  // TODO Auto-generated destructor stub
54 }
55 
57 {
58  if (fMult <= 0)
59  return kFALSE;
60  TDatabasePDG *pid = TDatabasePDG::Instance();
61  TParticlePDG *p = pid->GetParticle(fPDGType);
62  if (p != nullptr) {
63  LOG(info) << this->ClassName() << ": particle with PDG =" << GetPDGType() << " Found";
64  fPDGMass = p->Mass();
65  }
66  return kTRUE;
67 }
68 
69 void FairBaseMCGenerator::SetPDGType(Int_t pdg) { fPDGType = pdg; }
70 
72 {
73  switch (fVertexSmear) {
74  case kGauss: {
75  fX = gRandom->Gaus(fVx, fVex);
76  fY = gRandom->Gaus(fVy, fVey);
77  fZ = gRandom->Gaus(fVz, fVez);
78  } break;
79  case kBox: {
80  fX = gRandom->Uniform(fVx - fVex, fVx + fVex);
81  fY = gRandom->Uniform(fVy - fVey, fVy + fVey);
82  fZ = gRandom->Uniform(fVz - fVez, fVz + fVez);
83  } break;
84  case kExp: {
85  if (gRandom->Uniform() < 0.5) {
86  fX = fVx + gRandom->Exp(fVex);
87  } else {
88  fX = fVx - gRandom->Exp(fVex);
89  }
90  if (gRandom->Uniform() < 0.5) {
91  fY = fVy + gRandom->Exp(fVey);
92  } else {
93  fY = fVy - gRandom->Exp(fVey);
94  }
95  if (gRandom->Uniform() < 0.5) {
96  fZ = fVz + gRandom->Exp(fVez);
97  } else {
98  fZ = fVz - gRandom->Exp(fVez);
99  }
100  } break;
101  }
102  LOG(info) << this->ClassName() << ": Event, vertex = (" << fX << "," << fY << "," << fZ << ") cm, multiplicity "
103  << fMult;
104 }
Double_t fZ
Int_t GetPDGType() const
void SetPDGType(Int_t pdg)
Double_t fY
Double_t fX
virtual void GenerateEventParameters()
void SetVertex(Double_t vx, Double_t vy, Double_t vz, Double_t evx=0, Double_t evy=0, Double_t evz=0, eVertexSmear sm=kBox)