ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
AtTPC20MgDecay-Rnalpha.cxx
Go to the documentation of this file.
1 
2 
3 #include "AtTPC20MgDecay.h"
4 
5 #include "FairLogger.h"
6 #include "FairMCEventHeader.h"
7 #include "FairPrimaryGenerator.h"
8 #include "FairRootManager.h"
9 #include "FairRunAna.h"
10 #include "FairRunSim.h"
11 #include "TDatabasePDG.h"
12 #include "TF1.h"
13 #include "TGraph.h"
14 #include "TH1.h"
15 #include "TMath.h"
16 #include "TParticlePDG.h"
17 #include "TRandom.h"
18 
19 // ----- Default constructor ------------------------------------------
21  : fOnlyAPBranch(0), fBoxVtxIsSet(0), fNuclearDecayChainIsSet(0), fParticlesDefinedInNuclearDecay(0), fX(0), fY(0),
22  fZ(0), fX1(0), fY1(0), fZ1(0), fX2(0), fY2(0), fZ2(0)
23 {
24 }
25 
26 // ----- Destructor ---------------------------------------------------
28 
30 {
31  // Initialize generator
32 }
33 
34 // ----- Public method ReadEvent --------------------------------------
35 Bool_t AtTPC20MgDecay::ReadEvent(FairPrimaryGenerator *primGen)
36 {
37 
38  if (fBoxVtxIsSet) {
39  fX = gRandom->Uniform(fX1, fX2);
40  fY = gRandom->Uniform(fY1, fY2);
41  fZ = gRandom->Uniform(fZ1, fZ2);
42  }
43 
44  // Bool_t
45 
46  if (!fOnlyAPBranch) {
47  // all gammas!!!! calculating branching ratios and prob of emission
48  }
49 
50  // Proton of 1210keV and alpha of 506keV
51  Int_t protonPDGID = 2212;
52  Int_t alphaPDGID = 1000020040;
53  Int_t gammaPDGID = 22;
54  Int_t betaPDGID = 11;
55  // Check for particle type
56  TDatabasePDG *pdgBase = TDatabasePDG::Instance();
57  TParticlePDG *protonParticle = pdgBase->GetParticle(protonPDGID);
58  TParticlePDG *alphaParticle = pdgBase->GetParticle(alphaPDGID);
59  TParticlePDG *gammaParticle = pdgBase->GetParticle(gammaPDGID);
60  TParticlePDG *betaParticle = pdgBase->GetParticle(betaPDGID);
61  if (!protonParticle)
62  LOG(fatal) << "AtTPC20MgDecay: PDG code " << protonPDGID << " (proton) not defined.";
63  Double32_t protonMass = protonParticle->Mass();
64  if (!gammaParticle)
65  LOG(fatal) << "AtTPC20MgDecay: PDG code" << gammaPDGID << " (gamma) not defined.";
66  Double32_t gammaMass = gammaParticle->Mass();
67  if (!alphaParticle)
68  LOG(fatal) << "AtTPC20MgDecay: PDG code " << alphaPDGID << " (alpha) not defined.";
69  Double32_t alphaMass = alphaParticle->Mass();
70 
71  std::cout << " protonMass: " << protonMass << std::endl;
72  std::cout << " gammaMass: " << gammaMass << std::endl;
73  std::cout << "alphaMass: " << alphaMass << std::endl;
74 
75  Double32_t ptProton = 0, pxProton = 0, pyProton = 0, pzProton = 0;
76  Double32_t pabsProton = 0.0470; // GeV/c
77  // Double32_t pabsProton = 0.05169;
78  Double32_t thetaProton = acos(gRandom->Uniform(-1, 1));
79  Double32_t brp = 0;
80  Double32_t phiProton = gRandom->Uniform(0, 360) * TMath::DegToRad();
81  pzProton = pabsProton * TMath::Cos(thetaProton);
82  ptProton = pabsProton * TMath::Sin(thetaProton);
83  pxProton = ptProton * TMath::Cos(phiProton);
84  pyProton = ptProton * TMath::Sin(phiProton);
85 
86  Double32_t ptAlpha = 0, pxAlpha = 0, pyAlpha = 0, pzAlpha = 0;
87  Double32_t bra = 0;
88  // Double32_t pabsAlpha = 0.06162; // GeV/c
89  Double32_t pabsAlpha = 0.2165; // GeV/c
90  Double32_t thetaAlpha = acos(gRandom->Uniform(-1, 1));
91  Double32_t phiAlpha = gRandom->Uniform(0, 360) * TMath::DegToRad();
92  pzAlpha = pabsAlpha * TMath::Cos(thetaAlpha);
93  ptAlpha = pabsAlpha * TMath::Sin(thetaAlpha);
94  pxAlpha = ptAlpha * TMath::Cos(phiAlpha);
95  pyAlpha = ptAlpha * TMath::Sin(phiAlpha);
96 
97  Double32_t ptGamma = 0, pxGamma = 0, pyGamma = 0, pzGamma = 0;
98  Double32_t pabsGamma = 0.004033; // GeV/c
99  // Double32_t brg=0;
100  Double32_t thetaGamma = acos(gRandom->Uniform(0, 1));
101  Double32_t phiGamma = gRandom->Uniform(0, 360) * TMath::DegToRad();
102  pzGamma = pabsGamma * TMath::Cos(thetaGamma);
103  ptGamma = pabsGamma * TMath::Sin(thetaGamma);
104  pxGamma = ptGamma * TMath::Cos(phiGamma);
105  pyGamma = ptGamma * TMath::Sin(phiGamma);
106 
107  if (fNuclearDecayChainIsSet) {
108 
109  if (!protonPDGID == 2212)
110  LOG(fatal) << "AtTPC20MgDecayGenerator:PDG code" << protonPDGID << "is not a proton!";
111  // if(protonPDGID == 2212)
112  brp = gRandom->Uniform(0, 1);
113  bra = gRandom->Uniform(0, 1);
114  // brb =gRandom->Uniform(0,1);
115  for (Int_t i = 0; i < fParticlesDefinedInNuclearDecay; i++) {
116 
117  /*if(brp<=1){{
118  Double32_t ProtonMomentum = TMath::Sqrt(pxProton*pxProton+pyProton*pyProton+pzProton*pzProton);
119  pxProton=pxProton*fParticleEnergies[i]/ProtonMomentum;
120  pyProton=pyProton*fParticleEnergies[i]/ProtonMomentum;
121  pzProton=pzProton*fParticleEnergies[i]/ProtonMomentum;}*/
122 
123  // if(bra<=0.716){
124  if (bra <= 1) {
125  Double32_t AlphaMomentum = TMath::Sqrt(pxAlpha * pxAlpha + pyAlpha * pyAlpha + pzAlpha * pzAlpha);
126  pxAlpha = pxAlpha * fParticleEnergies[i] / AlphaMomentum;
127  pyAlpha = pyAlpha * fParticleEnergies[i] / AlphaMomentum;
128  pzAlpha = pzAlpha * fParticleEnergies[i] / AlphaMomentum;
129  }
130  /*else if(0.716<bra<=1){
131  //else if(0.96<bra<=1){
132  Double32_t GammaMomentum = TMath::Sqrt(pxGamma*pxGamma+pyGamma*pyGamma+pzGamma*pzGamma);
133  pxGamma=pxGamma*fParticleEnergies[i]/GammaMomentum;
134  pyGamma=pyGamma*fParticleEnergies[i]/GammaMomentum;
135  pzGamma=pzGamma*fParticleEnergies[i]/GammaMomentum;}}*/
136  }
137 
138  primGen->AddTrack(22, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // dummy photon for track ID 0
139  /*if(brp<=1){{
140  primGen->AddTrack(protonPDGID, pxProton,pyProton,pzProton,fX,fY,fZ);}*/
141  // if(bra<=0.716){
142  if (bra <= 1) {
143  primGen->AddTrack(alphaPDGID, pxAlpha, pyAlpha, pzAlpha, fX, fY, fZ);
144  }
145  // else if(0.716<bra<=1){
146  // else if(0.96<bra<=1){
147  // primGen->AddTrack(gammaPDGID, pxGamma, pyGamma, pzGamma, fX, fY, fZ);}
148  }
149 
150  return kTRUE;
151 }
152 void AtTPC20MgDecay::SetDecayChainPoint(Double32_t ParticleEnergy, Double32_t ParticleBranchingRatio)
153 {
154 
155  for (Int_t i = 0; i < fParticlesDefinedInNuclearDecay; i++) {
156  fParticleEnergies[i] = ParticleEnergy;
157  fParticleBranchingRatios[i] = ParticleBranchingRatio;
158  }
159 }
160 
AtTPC20MgDecay::ReadEvent
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)
Definition: AtTPC20MgDecay-Rnalpha.cxx:35
ClassImp
ClassImp(AtFindVertex)
AtTPC20MgDecay::AtTPC20MgDecay
AtTPC20MgDecay()=default
Definition: AtTPC20MgDecay-Rnalpha.cxx:20
AtTPC20MgDecay::Init
virtual Bool_t Init()
Definition: AtTPC20MgDecay-Rnalpha.cxx:29
AtTPC20MgDecay.h
AtTPC20MgDecay::SetDecayChainPoint
void SetDecayChainPoint(Double32_t ParticleEnergy=0, Double32_t ParticleBranchingRatio=0)
Definition: AtTPC20MgDecay-Rnalpha.cxx:152
AtTPC20MgDecay::~AtTPC20MgDecay
virtual ~AtTPC20MgDecay()=default
Definition: AtTPC20MgDecay-Rnalpha.cxx:27
AtTPC20MgDecay
Definition: AtTPC20MgDecay.h:14