er  dev
ERDecayLi9DetoLi10_Li9n_p.cxx
1 #include "ERDecayLi9DetoLi10_Li9n_p.h"
2 
3 #include "TVirtualMC.h"
4 #include "TLorentzVector.h"
5 #include "TVector3.h"
6 #include "TMCProcess.h"
7 #include "TMath.h"
8 
9 #include "FairRunSim.h"
10 #include<iostream>
11 
12 using namespace std;
13 
14 //#include "ERTarget.h"
15 #include "ERLi10MCEventHeader.h" //for ERMCEventHeader
16 
17 ERDecayLi9DetoLi10_Li9n_p::ERDecayLi9DetoLi10_Li9n_p():
18  ERDecay("Li9DetoLi10_Li9n_p"),
19  fTargetReactionFinish(kFALSE),
20  fTargetReactZ(0.),
21  fLi9(NULL),
22  fLi10(NULL),
23  fH2(NULL),
24  fn(NULL),
25  fp(NULL)
26 {
27  fRnd = new TRandom3();
28  FairRunSim* run = FairRunSim::Instance();
29  FairIon* Li10Ion = new FairIon("Li10",3,10,3);
30  run->AddNewIon(Li10Ion);
31  FairIon* Li9Ion = new FairIon("Li9",3,9,3);
32  run->AddNewIon(Li9Ion);
33 }
34 
35 Bool_t ERDecayLi9DetoLi10_Li9n_p::Init(){
36 
37  fLi10 = TDatabasePDG::Instance()->GetParticle("Li10");
38  if ( ! fLi10 ) {
39  std::cerr << "-W- ERDecayLi9DetoLi10_Li9n_p: Ion Li10 not found in database!" << endl;
40  return kFALSE;
41  }
42 
43  fLi9 = TDatabasePDG::Instance()->GetParticle("Li9");
44  if ( ! fLi9 ) {
45  std::cerr << "-W- ERDecayLi9DetoLi10_Li9n_p: Ion Li9 not found in database!" << endl;
46  return kFALSE;
47  }
48 
49  fH2 = TDatabasePDG::Instance()->GetParticle("Deuteron");
50  if ( ! fH2 ) {
51  std::cerr << "-W- ERDecayLi9DetoLi10_Li9n_p: Ion Deuteron not found in database!" << endl;
52  return kFALSE;
53  }
54 
55  fn = TDatabasePDG::Instance()->GetParticle("neutron");
56  if ( ! fn ) {
57  std::cerr << "-W- ERDecayLi9DetoLi10_Li9n_p: Particle neutron not found in database!" << endl;
58  return kFALSE;
59  }
60 
61  fp = TDatabasePDG::Instance()->GetParticle("proton");
62  if ( ! fp ) {
63  std::cerr << "-W- ERDecayLi9DetoLi10_Li9n_p: Particle proton not found in database!" << endl;
64  return kFALSE;
65  }
66 
67  return kTRUE;
68 }
69 
70 
71 ERDecayLi9DetoLi10_Li9n_p::~ERDecayLi9DetoLi10_Li9n_p(){
72 
73 }
74 
76  //Определяемся с текущим положением.
77  if (gMC->TrackPid() == 1000030090 && !fTargetReactionFinish && TString(gMC->CurrentVolName()).Contains("target")){
78  gMC->SetMaxStep(0.001);
79  TLorentzVector curPos;
80  gMC->TrackPosition(curPos);
81  //std::cerr << curPos.Z() << " "<< fTargetReactZ << std::endl;
82  if (curPos.Z() > fTargetReactZ){
83  std::cout << "Start reation in target. Defined pos: " << fTargetReactZ << ", current pos: " << curPos.Z() << endl;
84  FairRunSim* run = FairRunSim::Instance();
85  ERLi10MCEventHeader* header = (ERLi10MCEventHeader*)run->GetMCEventHeader();
86  header->SetReactionTime(gMC->TrackTime() * 1.0e09);
87 
88  const double E10Li=600*10e-6; //600 KeV
89  const double mass9Li=fLi9->Mass();
90  const double mass1H=fp->Mass();
91  const double mass2H=fH2->Mass();
92  const double massn=fn->Mass();
93  const double mass10Li=fLi10->Mass();
94  double beam_total_energy = gMC->Etot();
95  double beam_T=beam_total_energy - mass9Li;
96  const double pin9Li = sqrt(beam_T*beam_T+2*mass9Li*beam_T);
97  double amu=931.494;
98  TLorentzVector Vin9Li(0,0,pin9Li,beam_T+mass9Li);
99  TLorentzVector V2H (0,0,0,mass2H);
100  TLorentzVector Vofcm = Vin9Li+V2H;
101  TVector3 boost_vector = Vofcm.BoostVector();
102  Vin9Li.Boost(-boost_vector);
103  V2H.Boost(-boost_vector);
104  double Ecm = Vin9Li.E()+V2H.E();
105  double theta_cm = TMath::ACos(fRnd->Uniform(0.99,1.));
106  double phi_cm = fRnd->Uniform(0.0,2*TMath::Pi());
107 
108  const double Ecm10Li=0.5*(Ecm*Ecm + mass10Li*mass10Li-mass1H*mass1H)/Ecm;
109  const double Ecmp=0.5*(Ecm*Ecm-mass10Li*mass10Li+mass1H*mass1H)/Ecm;
110  const double pcm10Li = sqrt(Ecm10Li*Ecm10Li-mass10Li*mass10Li);
111  TVector3 pcm = Vin9Li.Vect();
112  //pcm.rotate(0.,theta_cm,0);
113  //pcm.rotate(phi_cm,0,0);
114  pcm.SetTheta(theta_cm);
115  pcm.SetPhi(phi_cm);
116  pcm.SetMag(pcm10Li);
117  TLorentzVector V10Li=TLorentzVector(pcm,Ecm10Li);
118  TLorentzVector V1H=TLorentzVector(-pcm,Ecmp);
119  V10Li.Boost(boost_vector);
120  V1H.Boost(boost_vector);
121 
122  //10Li decay
123  double theta_p1 = TMath::ACos(fRnd->Uniform(-1.00,1.00));
124  double phi_p1 = fRnd->Uniform(0.0,2*TMath::Pi());
125 
126  TVector3 boost_vector1 = V10Li.BoostVector();
127 
128 
129  double ecm1 = mass10Li;
130 
131  const double Ecm9Li= 0.5*(ecm1*ecm1+mass9Li*mass9Li-massn*massn)/ecm1;
132 
133  const double pcm9Li = sqrt(Ecm9Li*Ecm9Li-mass9Li*mass9Li);
134 
135  TVector3 pcm1(pcm9Li*TMath::Sin(theta_p1)*TMath::Cos(phi_p1),
136  pcm9Li*TMath::Sin(theta_p1)*TMath::Sin(phi_p1),
137  pcm9Li*TMath::Cos(theta_p1));
138 
139  TLorentzVector V9Li(pcm1,mass9Li);
140 
141  V9Li.Boost(boost_vector1);
142 
143  TLorentzVector Vn(-pcm1,massn);
144  Vn.Boost(boost_vector1);
145 
146  Int_t newTrackNb;
147  gMC->GetStack()->PushTrack(1, 0, 2212,
148  V1H.Px(),V1H.Py(),V1H.Pz(),
149  V1H.E(), curPos.X(), curPos.Y(), curPos.Z(),
150  gMC->TrackTime(), 0., 0., 0.,
151  kPDecay, newTrackNb,mass1H, 0);
152 
153  gMC->GetStack()->PushTrack(1, 0, 2112,
154  Vn.Px(),Vn.Py(),Vn.Pz(),
155  Vn.E(), curPos.X(), curPos.Y(), curPos.Z(),
156  gMC->TrackTime(), 0., 0., 0.,
157  kPDecay, newTrackNb, massn, 0);
158 /*
159  gMC->GetStack()->PushTrack(1, 0, fLi9->PdgCode(),
160  V9Li.Px(),V9Li.Py(),V9Li.Pz(),
161  V9Li.E(), curPos.X(), curPos.Y(), curPos.Z(),
162  gMC->TrackTime(), 0., 0., 0.,
163  kPDecay, newTrackNb, massn, 0);
164 */
165  gMC->StopTrack();
166 
167 
168 
169  fTargetReactionFinish = kTRUE;
170  gMC->SetMaxStep(100.);
171  }
172  }
173  return kTRUE;
174 }
175 
176 void ERDecayLi9DetoLi10_Li9n_p::BeginEvent(){
177  fTargetReactionFinish = kFALSE;
178  //Double_t targetThickness = ERTarget::Thickness();
179  fTargetReactZ = fRnd->Uniform()*(.025+0.006);
180  FairRunSim* run = FairRunSim::Instance();
181  ERLi10MCEventHeader* header = (ERLi10MCEventHeader*)run->GetMCEventHeader();
182  header->SetReactionPos(fTargetReactZ);
183  fSecondaryIonPDG = -1;
184 }
185 
186 void ERDecayLi9DetoLi10_Li9n_p::FinishEvent(){
187 
188 }
189