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