er  dev
ERDecay27Fto26O.cxx
1 #include "ERDecay27Fto26O.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 ERDecay27Fto26O::ERDecay27Fto26O():
16  ERDecay("27Fto26O"),
17  fTargetReactionFinish(kFALSE),
18  fTargetReactZ(0.),
19  fSecondaryIonPDG(-1)
20 {
21  fRnd = new TRandom3();
22  FairRunSim* run = FairRunSim::Instance();
23  FairIon* SecondIon = new FairIon("ExpertSecondIon",8,26, 8); //26O
24  run->AddNewIon(SecondIon);
25 }
26 
27 ERDecay27Fto26O::~ERDecay27Fto26O(){
28 
29 }
30 
31 Bool_t ERDecay27Fto26O::Init(){
32 
33  fSecondIon = TDatabasePDG::Instance()->GetParticle("ExpertSecondIon");
34  if ( ! fSecondIon ) {
35  std::cerr << "-W- ERDecay27Fto26O: Ion ExpertSecondIon not found in database!" << endl;
36  return kFALSE;
37  }
38  return kTRUE;
39 }
40 
41 Bool_t ERDecay27Fto26O::Stepping(){
42  //Определяемся с текущим положением.
43  if (gMC->TrackPid() == 1000090270 && !fTargetReactionFinish && TString(gMC->CurrentVolName()).Contains("target")){
44  gMC->SetMaxStep(0.01);
45  TLorentzVector curPos;
46  gMC->TrackPosition(curPos);
47  if (curPos.Z() > fTargetReactZ){
48  std::cout << "Start reation in target. Defined pos: " << fTargetReactZ << ", current pos: " << curPos.Z() << endl;
49  FairRunSim* run = FairRunSim::Instance();
50  //Create new ion
51  TLorentzVector curMomentum;
52  gMC->TrackMomentum(curMomentum);
53 
54  //Импульс первого иона в момент распада
55  Double_t momentum = TMath::Sqrt(curMomentum.X()*curMomentum.X() + curMomentum.Y()*curMomentum.Y() + curMomentum.Z()*curMomentum.Z());
56  //Импульс второго иона
57  momentum *= fSecondIon->Mass()/gMC->TrackMass();
58 
59  Double_t fullEnergy = TMath::Sqrt(fSecondIon->Mass()*fSecondIon->Mass() + momentum*momentum);
60  //Расчет гамма фактора
61  Double_t betaCM = (fullEnergy-fSecondIon->Mass())/fullEnergy;
62  Double_t gammaCM = TMath::Sqrt( 1. / ( 1. - betaCM*betaCM) );
63 
64  TParticlePDG* thisPart =
65  TDatabasePDG::Instance()->GetParticle(fSecondIon->GetName());
66 
67  fSecondaryIonPDG = fSecondIon->PdgCode();
68 
69  std::cout << "-I- ERDecay27Fto26O: Generating ion of type "
70  << fSecondIon->GetName() << " (PDG code " << fSecondaryIonPDG << ")" << endl;
71  std::cout << " Momentum (" << curMomentum.X() << ", " << curMomentum.Y() << ", " << curMomentum.Z()
72  << ") Gev from vertex (" << curPos.X() << ", " << curPos.Y()
73  << ", " << curPos.Z() << ") cm" << endl;
74 
75  Int_t newTrackNb;
76 
77  gMC->GetStack()->PushTrack(1, 0, fSecondaryIonPDG,
78  curMomentum.X(),curMomentum.Y(), curMomentum.Z(),
79  fullEnergy, curPos.X(), curPos.Y(), curPos.Z(),
80  gMC->TrackTime(), 0., 0., 0.,
81  kPDecay, newTrackNb, fSecondIon->Mass(), 0);
82  //Stop first ion
83  gMC->StopTrack();
84  fTargetReactionFinish = kTRUE;
85  }
86  }
87  return kTRUE;
88 }
89 
90 void ERDecay27Fto26O::BeginEvent(){
91  fTargetReactionFinish = kFALSE;
92  //Double_t targetThickness = ERTarget::Thickness();
93  fTargetReactZ = fRnd->Uniform()*2.;
94  FairRunSim* run = FairRunSim::Instance();
95  ERMCEventHeader* header = (ERMCEventHeader*)run->GetMCEventHeader();
96  header->SetTargetReactionPos(fTargetReactZ);
97  fSecondaryIonPDG = -1;
98 }
99 
100 void ERDecay27Fto26O::FinishEvent(){
101 
102 }
103 
104 ClassImp(ERDecay27Fto26O)