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