1 #include "ERDecay31Arto30Ar.h" 3 #include "TVirtualMC.h" 4 #include "TLorentzVector.h" 5 #include "TMCProcess.h" 7 #include "FairRunSim.h" 13 #include "ERMCEventHeader.h" 15 ERDecay31Arto30Ar::ERDecay31Arto30Ar():
17 fTargetReactionFinish(kFALSE),
21 fRnd =
new TRandom3();
22 FairRunSim* run = FairRunSim::Instance();
23 FairIon* SecondIon =
new FairIon(
"ExpertSecondIon",18,30, 18);
24 run->AddNewIon(SecondIon);
27 Bool_t ERDecay31Arto30Ar::Init(){
29 fSecondIon = TDatabasePDG::Instance()->GetParticle(
"ExpertSecondIon");
31 std::cerr <<
"-W- ERDecay31Arto30Ar: Ion ExpertSecondIon not found in database!" << endl;
38 ERDecay31Arto30Ar::~ERDecay31Arto30Ar(){
42 Bool_t ERDecay31Arto30Ar::Stepping(){
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();
52 TLorentzVector curMomentum;
53 gMC->TrackMomentum(curMomentum);
56 Double_t momentum = TMath::Sqrt(curMomentum.X()*curMomentum.X() + curMomentum.Y()*curMomentum.Y() + curMomentum.Z()*curMomentum.Z());
58 momentum *= fSecondIon->Mass()/gMC->TrackMass();
60 Double_t fullEnergy = TMath::Sqrt(fSecondIon->Mass()*fSecondIon->Mass() + momentum*momentum);
62 Double_t betaCM = (fullEnergy-fSecondIon->Mass())/fullEnergy;
63 Double_t gammaCM = TMath::Sqrt( 1. / ( 1. - betaCM*betaCM) );
65 TParticlePDG* thisPart =
66 TDatabasePDG::Instance()->GetParticle(fSecondIon->GetName());
68 fSecondaryIonPDG = fSecondIon->PdgCode();
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;
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);
85 fTargetReactionFinish = kTRUE;
91 void ERDecay31Arto30Ar::BeginEvent(){
92 fTargetReactionFinish = kFALSE;
94 fTargetReactZ = fRnd->Uniform()*2.;
95 FairRunSim* run = FairRunSim::Instance();
97 header->SetTargetReactionPos(fTargetReactZ);
98 fSecondaryIonPDG = -1;
101 void ERDecay31Arto30Ar::FinishEvent(){