er  dev
ERDecay26Oto24O2n.cxx
1 #include "ERDecay26Oto24O2n.h"
2 
3 #include "TVirtualMC.h"
4 #include "TLorentzVector.h"
5 #include "TMCProcess.h"
6 
7 #include "FairRunSim.h"
8 #include<iostream>
9 
10 using namespace std;
11 
12 //#include "ERTarget.h"
13 #include "ERMCEventHeader.h" //for ERMCEventHeader
14 
15 ERDecay26Oto24O2n::ERDecay26Oto24O2n():
16  ERDecay("26Oto24O2n"),
17  fDirectReactionFinish(kFALSE),
18  fTauCM(100.)
19 {
20  fRnd = new TRandom3();
21  fPHSpace = new TGenPhaseSpace();
22  FairRunSim* run = FairRunSim::Instance();
23  FairIon* ThirdIon = new FairIon("ExpertThirdIon",8,24, 8); //24O
24  run->AddNewIon(ThirdIon);
25 }
26 
27 ERDecay26Oto24O2n::~ERDecay26Oto24O2n(){
28 
29 }
30 
31 Bool_t ERDecay26Oto24O2n::Init(){
32 
33  fSecondIon = TDatabasePDG::Instance()->GetParticle("ExpertSecondIon");
34  if ( ! fSecondIon ) {
35  std::cerr << "-W- ERDecay26Oto24O2n: Ion ExpertSecondIon not found in database!" << endl;
36  return kFALSE;
37  }
38  fThirdIon = TDatabasePDG::Instance()->GetParticle("ExpertThirdIon");
39  if ( ! fThirdIon ) {
40  std::cerr << "-W- ERDecay26Oto24O2n: Ion not ExpertThirdIon found in database!" << endl;
41  return kFALSE;
42  }
43 }
44 
45 Bool_t ERDecay26Oto24O2n::Stepping(){
46  if(!fDirectReactionFinish && gMC->TrackPid() == 1000080260){
47 
48  gMC->SetMaxStep(0.01);
49  Int_t newTrackNb;
50  //Разыгрование позиции развала нестабильного иона
51 
52  Bool_t destroied = kFALSE; //развалился/не развалился
53 
54  TLorentzVector curMomentum;
55  gMC->TrackMomentum(curMomentum);
56  TLorentzVector curPos;
57  gMC->TrackPosition(curPos);
58 
59  Double_t momentum = TMath::Sqrt(curMomentum.X()*curMomentum.X() + curMomentum.Y()*curMomentum.Y() + curMomentum.Z()*curMomentum.Z());
60  Double_t fullEnergy = TMath::Sqrt(fSecondIon->Mass()*fSecondIon->Mass() + momentum*momentum);
61 
62  //Расчет гамма фактора
63  Double_t betaCM = (fullEnergy-fSecondIon->Mass())/fullEnergy;
64  Double_t gammaCM = TMath::Sqrt( 1. / ( 1. - betaCM*betaCM) );
65 
66  Double_t tau = fTauCM*gammaCM;
67 
68  //вероятность того, что произошел развал
69  if (fRnd->Uniform() > TMath::Exp(-(gMC->TrackTime())*(1.0e09)/tau)){
70  FairRunSim* run = FairRunSim::Instance();
71  ERMCEventHeader* header = (ERMCEventHeader*)run->GetMCEventHeader();
72  std::cout << "Start direct reaction. Current pos: " << curPos.Z() << " [cm] " << endl;
73  header->SetDirectReactionPos(curPos.Z());
74  //Результирующий импульс второго иона
75  TLorentzVector pSecIon(curMomentum.X(),curMomentum.Y(),curMomentum.Z(),fullEnergy);
76  //Чтение из файла треков продуктов развала нестабильного иона.
77  //Пока замена на ROOT класс с правильным обсчетом кинематики.
78  //Массив масс продуктов распада
79  Double_t masses[3];
80  masses[0] = fThirdIon->Mass();
81  masses[1] = 0.939; //neutron mass
82  masses[2] = 0.939; //neutron mass
83  if (!fPHSpace->SetDecay(pSecIon,3,masses)){
84  std::cerr << "ERDecay: the decay is forbidden by kinematics" <<endl;
85  fDirectReactionFinish = kTRUE;
86  return kFALSE;
87  }
88  fPHSpace->Generate();
89 
90  //Испускание третьего иона
91  TLorentzVector* pThirdIon = fPHSpace->GetDecay(0);
92 
93  Int_t thirdIonPDG = fThirdIon->PdgCode();
94 
95  std::cout << "-I- ERDecay: Generating ion of type "
96  << fThirdIon->GetName() << " (PDG code " << thirdIonPDG << ")" << endl;
97  std::cout << " Momentum (" << pThirdIon->Px() << ", " << pThirdIon->Py() << ", " << pThirdIon->Pz()
98  << ") Gev from vertex (" << curPos.X() << ", " << curPos.Y() << ", " << curPos.Z() << ") cm" << endl;
99 
100  gMC->GetStack()->PushTrack(1, 1, thirdIonPDG,
101  pThirdIon->Px(),pThirdIon->Py(),pThirdIon->Pz(),
102  pThirdIon->E(), curPos.X(), curPos.Y(), curPos.Z(),
103  gMC->TrackTime(), 0., 0., 0.,
104  kPDecay, newTrackNb, fThirdIon->Mass(), 0);
105  //Испускание нейтронов
106  TLorentzVector* pNeutron1 = fPHSpace->GetDecay(1);
107  TLorentzVector* pNeutron2 = fPHSpace->GetDecay(2);
108 
109  std::cout << "-I- ERGenerator: Generating neutron " << endl
110  << " Momentum (" << pNeutron1->Px() << ", " << pNeutron1->Py() << ", " << pNeutron1->Pz()
111  << ") Gev from vertex (" << curPos.X() << ", " << curPos.Y() << ", " << curPos.Z() << ") cm" << endl;
112  std::cout << "-I- ERGenerator: Generating neutron " << endl
113  << " Momentum (" << pNeutron2->Px() << ", " << pNeutron2->Py() << ", " << pNeutron2->Pz()
114  << ") Gev from vertex (" << curPos.X() << ", " << curPos.Y() << ", " << curPos.Z() << ") cm" << endl;
115 
116  gMC->GetStack()->PushTrack(1, 1, 2112,
117  pNeutron1->Px(),pNeutron1->Py(),pNeutron1->Pz(),
118  pNeutron1->E(), curPos.X(), curPos.Y(), curPos.Z(),
119  gMC->TrackTime(), 0., 0., 0.,
120  kPDecay, newTrackNb, 0.939, 0);
121  gMC->GetStack()->PushTrack(1, 1, 2112,
122  pNeutron2->Px(),pNeutron2->Py(),pNeutron2->Pz(),
123  pNeutron2->E(), curPos.X(), curPos.Y(), curPos.Z(),
124  gMC->TrackTime(), 0., 0., 0.,
125  kPDecay, newTrackNb, 0.939, 0);
126  //Испускание гаммы.
127  fDirectReactionFinish = kTRUE;
128  //Stop second ion
129  gMC->StopTrack();
130  }
131  }
132  return kTRUE;
133 }
134 
135 void ERDecay26Oto24O2n::BeginEvent(){
136  fDirectReactionFinish = kFALSE;
137 }
138 
139 void ERDecay26Oto24O2n::FinishEvent(){
140 
141 }
142 
143 ClassImp(ERDecay26Oto24O2n)