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