6 #include <FairPrimaryGenerator.h>
7 #include <FairRunSim.h>
9 #include <TDatabasePDG.h>
12 #include <TParticlePDG.h>
22 constexpr
auto cRED =
"\033[1;31m";
25 constexpr
auto cGREEN =
"\033[1;32m";
27 Int_t AtTPCFissionGeneratorV2::fgNIon = 0;
30 : fP1x(0.), fP1y(0.), fP1z(0.), fP2x(0.), fP2y(0.), fP2z(0.), fVx(0.), fVy(0.), fVz(0.)
38 : fP1x(0.), fP1y(0.), fP1z(0.), fP2x(0.), fP2y(0.), fP2z(0.), fVx(0.), fVy(0.), fVz(0.)
41 TString dir = getenv(
"VMCWORKDIR");
42 TString fFileNamebase;
43 std::map<TString, FairIon *> fIonMap;
45 fFileNamebase = dir +
"/macro/Simulation/database/ionlist.txt";
46 std::cout <<
" AtTPCFissionGenerator: Opening input file " << fFileNamebase << std::endl;
48 std::ifstream fInputFilebase(fFileNamebase);
49 if (!fInputFilebase.is_open())
50 Fatal(
"AtTPCFissionGenerator",
"Cannot open input file.");
52 std::cout <<
"AtTPCFissionGenerator: Looking for ions..." << std::endl;
64 fInputFilebase >> Z >> A;
66 while (!fInputFilebase.eof()) {
68 if (fInputFilebase.eof())
72 sprintf(buffer,
"Ion_%d_%d", A, Z);
73 TString ionName(buffer);
75 auto *ion =
new FairIon(ionName, Z, A, qq);
76 fIonMap[ionName] = ion;
79 fInputFilebase >> Z >> A;
83 FairRunSim *run = FairRunSim::Instance();
84 std::map<TString, FairIon *>::iterator mapIt;
85 for (mapIt = fIonMap.begin(); mapIt != fIonMap.end(); mapIt++) {
86 FairIon *ion = (*mapIt).second;
90 std::cout <<
cYELLOW <<
"AtTPCFissionGenerator: " << nIons <<
" ions registered." <<
cNORMAL << std::endl;
92 TString simfilepath = dir +
"/macro/Simulation/data/" + simfile;
93 auto *
f =
new TFile(simfilepath.Data());
95 std::cout <<
cRED <<
" AtTPCFissionGenerator: No simulation file found! Check VMCWORKDIR variable. Exiting... "
99 std::cout <<
cGREEN <<
" AtTPCFissionGenerator : Prototype geometry found in : " << simfilepath.Data() <<
cNORMAL
102 auto *fTree =
dynamic_cast<TTree *
>(
f->Get(
"tree101"));
103 Int_t nEvents = fTree->GetEntriesFast();
104 std::cout <<
" Number of events : " << nEvents << std::endl;
105 fTree->SetBranchAddress(
"Evnt", &Evnt);
106 fTree->SetBranchAddress(
"Ntrack", &Ntrack);
107 fTree->SetBranchAddress(
"Aout", Aout);
108 fTree->SetBranchAddress(
"Zout", Zout);
109 fTree->SetBranchAddress(
"fOutPx", fOutPx);
110 fTree->SetBranchAddress(
"fOutPy", fOutPy);
111 fTree->SetBranchAddress(
"fOutPz", fOutPz);
112 pTree.push_back(fTree);
121 fVx = 0., fVy = 0., fVz = 0.;
122 Double_t uma = 931.494028, mp = 938.272013,
c = 29.972458;
125 TDatabasePDG *fPDG = TDatabasePDG::Instance();
127 pTree.at(0)->GetEntry(event);
161 for (Int_t j = 0; j < Ntrack; j++) {
166 if (ia1 > 2 && iz1 > 2) {
169 sprintf(ionName,
"Ion_%d_%d", ia1, iz1);
170 TParticlePDG *part = fPDG->GetParticle(ionName);
172 std::cout <<
"AtTPCFissionGenerator::ReadEvent: Cannot find " << ionName <<
" in database!" << std::endl;
176 pdgType = part->PdgCode();
184 primGen->AddTrack(pdgType, px, py, pz, fVx, fVy, fVz);
190 std::cout <<
cRED <<
" Fission event : " <<
event <<
cNORMAL << std::endl;