29 fEventPlaneSet(kFALSE)
31 std::cout <<
"-I MpdUnigenGenerator: Opening input file " << fileName.Data() << std::endl;
33 fInFile =
new TFile(fileName,
"read");
35 Fatal(
"MpdUnigenGenerator",
"Cannot open input file.");
39 fInTree = (TTree*) fInFile->Get(
"events");
40 fNEntries = fInTree->GetEntries();
41 fRun =
dynamic_cast<URun*
>(fInFile->Get(
"run"));
42 Double_t mProt = 0.938272;
46 Double_t eProj = TMath::Sqrt(pTarg * pTarg + mProt * mProt);
47 fBetaCM = pProj / eProj;
48 fGammaCM = 1. / TMath::Sqrt(1. - fBetaCM * fBetaCM);
49 Double_t pBeam = fGammaCM * (pProj - fBetaCM * eProj);
50 LOG(info) << GetName() <<
": sqrt(s_NN) = " << fRun->
GetNNSqrtS() <<
" GeV, p_beam = " << pBeam <<
" GeV/u";
51 LOG(info) << GetName() <<
": Lorentz transformation to lab system: " <<
" beta " << fBetaCM <<
", gamma " << fGammaCM;
55 Fatal(
"MpdUnigenGenerator",
"Cannot open TTree from the file.");
59 fSpectatorsON = isSpectator;
61 std::cout <<
"-I MpdUnigenGenerator: Spectators ON" << std::endl;
63 Long64_t nEntries = fInTree->GetEntries();
64 std::cout <<
"-I MpdUnigenGenerator: Number of entries in tree: " << nEntries << std::endl;
65 fInTree->SetBranchAddress(
"event", &fEvent);
76 cout <<
"-E- MpdUnigenGenerator: Input file not open! " << endl;
82 cout <<
"-E- MpdUnigenGenerator::ReadEvent: "
83 <<
"No PrimaryGenerator!" << endl;
88 if ( fEventNumber >= fNEntries ) {
89 cout <<
"-E- MpdUnigenGenerator::ReadEvent: "
90 <<
"Reached the of the tree" << endl;
94 fInTree->GetEntry(fEventNumber);
95 std::cout <<
"-I- MpdUnigenGenerator: Event " << fEventNumber << std::endl;
97 Double_t phi = fEvent->
GetPhi();
100 std::cout <<
"Rotation of EP will be performed " << fEventPlaneSet << std::endl;
101 if (fEventPlaneSet) {
104 dphi = uniform_real_distribution_(random_engine_);
106 std::cout <<
"EP is rotated to " << dphi << std::endl;
110 FairMCEventHeader* header = primGen->GetEvent();
111 if (header && (!header->IsSet())) {
113 header->SetB(fEvent->
GetB());
114 header->MarkSet(kTRUE);
115 header->SetRotZ(phi);
118 UInt_t nTracks = fEvent->
GetNpa();
120 for (UInt_t iTrack = 0; iTrack < nTracks; iTrack++){
125 Double_t px = fParticle->
Px();
126 Double_t py = fParticle->
Py();
127 Double_t pz = fParticle->
Pz();
130 Double_t e =
sqrt(mass * mass + px * px + py * py + pz * pz);
132 pz = fGammaCM * (pz + fBetaCM * e);
134 if (fEventPlaneSet) {
135 Double_t pt = TMath::Sqrt(px * px + py * py);
136 Double_t azim = TMath::ATan2(py, px);
138 px = pt * TMath::Cos(azim);
139 py = pt * TMath::Sin(azim);
142 if (fParticle->
GetPdg() < 1e9) {
143 primGen->AddTrack(fParticle->
GetPdg(), px, py, pz, 0., 0., 0.);
147 ionPdg = fParticle->
GetPdg();
148 if (GetIonLambdas(fParticle->
GetPdg())) {
149 ionPdg = fParticle->
GetPdg() - GetIonLambdas(fParticle->
GetPdg()) * kPdgLambda;
150 std::cout <<
"-W- MpdUnigenGenerator: Replacing hypernucleus (PDG " << fParticle->
GetPdg() <<
") by PDG " << ionPdg << std::endl;
153 if (GetIonCharge(ionPdg) > 0) {
154 primGen->AddTrack(ionPdg, px, py, pz, 0., 0., 0.);
158 Int_t neutralFragmentMass = GetIonMass(ionPdg);
159 for (Int_t iNeutron = 0; iNeutron < neutralFragmentMass; iNeutron++) {
160 Double_t pxNeutron = px/(Double_t)neutralFragmentMass;
161 Double_t pyNeutron = py/(Double_t)neutralFragmentMass;
162 Double_t pzNeutron = pz/(Double_t)neutralFragmentMass;
165 primGen->AddTrack(2112, pxNeutron, pyNeutron, pzNeutron, 0., 0., 0.);
167 std::cout <<
"-W- MpdUnigenGenerator: Neutral fragment (PDG " << ionPdg <<
") is split into " << neutralFragmentMass <<
" neutrons." << std::endl;
176 std::cout <<
"-I- MpdUnigenGenerator: Registering ions..." << std::endl;
181 for (Int_t iEvent=0; iEvent<fInTree->GetEntries(); iEvent++) {
182 fInTree->GetEntry(iEvent);
184 for (Int_t iParticle=0; iParticle<fEvent->
GetNpa(); iParticle++) {
187 Int_t pdgCode = particle->
GetPdg();
192 const Int_t nLambda = GetIonLambdas(pdgCode);
193 const Int_t chrg = GetIonCharge(pdgCode);
194 const Int_t mass = GetIonMass(pdgCode);
197 if (chrg == 0)
continue;
200 TString ionName = Form(
"Ion_%d_%d_%d", mass, chrg, nLambda);
201 if (fIonMap.find(ionName) == fIonMap.end()) {
202 fIonMap[ionName] =
new FairIon(ionName, chrg, mass, chrg);
204 std::cout <<
"-I- MpdUnigenGenerator: Added new ion with PDG " << pdgCode
205 <<
" (Charge " << chrg <<
", Mass " << mass <<
", nLambda " << nLambda
206 <<
") from event " << iEvent <<
" at index " << iParticle << std::endl;
215 for (
const auto& entry : fIonMap) {
216 FairRunSim::Instance()->AddNewIon(entry.second);
219 return fIonMap.size();
TLorentzVector GetMomentum() const