1 #include "ERDecay27Fto26O.h" 3 #include "TVirtualMC.h" 4 #include "TLorentzVector.h" 5 #include "TMCProcess.h" 7 #include "FairRunSim.h" 13 #include "ERMCEventHeader.h" 15 ERDecay27Fto26O::ERDecay27Fto26O():
17 fTargetReactionFinish(kFALSE),
21 fRnd =
new TRandom3();
22 FairRunSim* run = FairRunSim::Instance();
23 FairIon* SecondIon =
new FairIon(
"ExpertSecondIon",8,26, 8);
24 run->AddNewIon(SecondIon);
27 ERDecay27Fto26O::~ERDecay27Fto26O(){
31 Bool_t ERDecay27Fto26O::Init(){
33 fSecondIon = TDatabasePDG::Instance()->GetParticle(
"ExpertSecondIon");
35 std::cerr <<
"-W- ERDecay27Fto26O: Ion ExpertSecondIon not found in database!" << endl;
41 Bool_t ERDecay27Fto26O::Stepping(){
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();
51 TLorentzVector curMomentum;
52 gMC->TrackMomentum(curMomentum);
55 Double_t momentum = TMath::Sqrt(curMomentum.X()*curMomentum.X() + curMomentum.Y()*curMomentum.Y() + curMomentum.Z()*curMomentum.Z());
57 momentum *= fSecondIon->Mass()/gMC->TrackMass();
59 Double_t fullEnergy = TMath::Sqrt(fSecondIon->Mass()*fSecondIon->Mass() + momentum*momentum);
61 Double_t betaCM = (fullEnergy-fSecondIon->Mass())/fullEnergy;
62 Double_t gammaCM = TMath::Sqrt( 1. / ( 1. - betaCM*betaCM) );
64 TParticlePDG* thisPart =
65 TDatabasePDG::Instance()->GetParticle(fSecondIon->GetName());
67 fSecondaryIonPDG = fSecondIon->PdgCode();
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;
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);
84 fTargetReactionFinish = kTRUE;
90 void ERDecay27Fto26O::BeginEvent(){
91 fTargetReactionFinish = kFALSE;
93 fTargetReactZ = fRnd->Uniform()*2.;
94 FairRunSim* run = FairRunSim::Instance();
96 header->SetTargetReactionPos(fTargetReactZ);
97 fSecondaryIonPDG = -1;
100 void ERDecay27Fto26O::FinishEvent(){