7 #include <FairLogger.h>
8 #include <FairPrimaryGenerator.h>
9 #include <FairRunSim.h>
11 #include <TDatabasePDG.h>
14 #include <TParticlePDG.h>
16 #include <TVirtualMC.h>
17 #include <TVirtualMCStack.h>
21 void AtTPCFissionGeneratorV3::loadIonList(TString ionList)
23 std::ifstream fileIn(ionList.Data());
25 if (!fileIn.is_open())
26 LOG(fatal) <<
"Failed to open file: " << ionList;
35 auto *ion =
new FairIon(TString::Format(
"Ion_%d_%d", Z, A), Z, A, Z);
36 FairRunSim::Instance()->AddNewIon(ion);
40 void AtTPCFissionGeneratorV3::loadFissionFragmentTree(TString fissionDistro)
43 fEventFile =
new TFile(fissionDistro,
"READ");
45 if (fEventFile->IsZombie())
46 LOG(fatal) <<
"Could not open file with decay fragments: " << fissionDistro;
48 fEventTree =
dynamic_cast<TTree *
>(fEventFile->Get(
"fragments"));
50 LOG(fatal) <<
"Failed to find the tree fragments";
52 fEventTree->SetBranchAddress(
"decayFragments", &fDecayFrags);
53 fEventTree->SetBranchAddress(
"A", &fA);
54 fEventTree->SetBranchAddress(
"Z", &fZ);
56 fNumEvents = fEventTree->GetEntries();
64 : fDecayFrags(new std::vector<
VecPE>()), fA(new std::vector<Int_t>()), fZ(new std::vector<Int_t>())
67 loadFissionFragmentTree(fissionDistro);
81 LOG(debug) <<
"AtTPCFissionGeneratorV3: Skipping beam-like event";
83 LOG(debug) <<
"AtTPCFissionGeneratorV3: Runing reaction-like event";
91 void AtTPCFissionGeneratorV3::generateEvent()
94 fEventTree->GetEntry(fCurrEvent);
96 for (
int i = 0; i < fDecayFrags->size(); ++i)
97 generateFragment(fDecayFrags->at(i), fA->at(i), fZ->at(i));
99 LOG(debug) <<
"Wrote tracks for fission root event: " << fCurrEvent;
104 VecPE AtTPCFissionGeneratorV3::getBeam4Vec()
112 beam.SetPxPyPzE(fVPx, fVPy, fVPz, fVEn);
122 void AtTPCFissionGeneratorV3::setBeamParameters()
124 fVertex = getVertex();
125 fBeamBoost = ROOT::Math::Boost(getBeam4Vec().BoostToCM());
129 void AtTPCFissionGeneratorV3::generateFragment(
VecPE &P, Int_t A, Int_t Z)
131 TString particleName = TString::Format(
"Ion_%d_%d", Z, A);
132 auto particle = TDatabasePDG::Instance()->GetParticle(particleName);
134 LOG(fatal) <<
"Couldn't find particle " << particleName <<
" in database!";
136 auto labP = fBeamBoost(P);
137 auto kinE = labP.E() - labP.mass();
138 auto angle = labP.Theta();
140 std::cout << std::endl;
141 LOG(debug) << TString::Format(
142 "AtTPCFissionGeneratorV3: Generating ion of type %s with CoM momentum (%f, %f, %f) MeV/c", particleName.Data(),
143 P.Px(), P.Py(), P.Pz());
144 LOG(debug) << TString::Format(
"Lab momentum (%f, %f, %f) MeV/c at (%f, %f, %f) cm with E = %f and angle = %f",
145 labP.Px(), labP.Py(), labP.Pz(), fVertex.X(), fVertex.Y(), fVertex.Z(), kinE, angle);
147 auto nextTrackID = gMC->GetStack()->GetNtrack();
153 fPrimeGen->AddTrack(particle->PdgCode(), labP.Px() / 1000, labP.Py() / 1000, labP.Pz() / 1000, fVertex.X(),
154 fVertex.Y(), fVertex.Z());