47 const string& taskIdStr,
int nofFilesToMix)
55 int taskId = std::stoi(taskIdStr);
57 LOG(info) <<
"LmvmEventMix::DoEventMix: Energy string = " <<
fEnergy
58 <<
". Mind this for calculation of weighting values!" << endl;
59 fHMean.FillH1(
"hmx_nofJobs", 0.5);
65 int iSig = taskId %
fHMean.fNofSignals;
67 LOG(info) <<
"taskId = " << taskId <<
", iSig = " << iSig <<
", fSignal = " <<
fSignal;
70 string folder = (iSig == 0) ?
"inmed/"
71 : (iSig == 1) ?
"qgp/"
72 : (iSig == 2) ?
"omegaepem/"
73 : (iSig == 3) ?
"phi/"
74 : (iSig == 4) ?
"omegadalitz/"
76 if (folder ==
"") LOG(error) <<
"LmvmEventMix::DoEventMix(): No folder name specified. Check!";
80 for (
int iF = 1; iF <= 1000; iF++) {
82 string filename =
fDataDir + folder +
"lmvmcand." + iFString +
".root";
83 TFile* file(TFile::Open(filename.c_str()));
84 if (file) iFileMax = iF;
86 LOG(info) <<
"iFileMax = " << iFileMax;
91 vector<LmvmCand> candsSame;
93 for (
const string name : {
"inmed",
"omegaepem",
"omegadalitz",
"phi",
"qgp"}) {
95 string filename =
fDataDir + name +
"/lmvmcand." + taskIdStr +
".root";
96 TFile* file(TFile::Open(filename.c_str()));
98 LOG(info) <<
"file " << filename <<
" cannot be opened.";
101 vector<LmvmCand>* cands(file->Get<vector<LmvmCand>>(
"fCandsTotal"));
102 if (cands !=
nullptr) {
103 LOG(info) <<
"File taken for same events: " << filename;
104 candsSame.insert(candsSame.end(), cands->begin(), cands->end());
105 string filenameAna =
fDataDir + name +
"/analysis." + taskIdStr +
".root";
106 TFile* anafile(TFile::Open(filenameAna.c_str()));
108 TH1D*
h(anafile->Get<TH1D>(
"hEventNumber"));
112 LOG(warning) <<
"LmvmEventMix (loop 'same'): anafile " << filenameAna
113 <<
" could not be opened or does not exist.";
116 LOG(warning) <<
"LmvmEventMix::DoEventMix(): Loop 'same' with filename = " << filename
117 <<
": candsSame = nullptr!";
128 fHMean.FillH1(
"hmx_EventNumber", 0.5);
131 fHMean.FillH1(
"hmx_NofFilesToMix", 0.5);
135 vector<LmvmCand> candsMix;
142 LOG(error) <<
"LmvmEventMix::DoEventMix(): iter = " << iter <<
". Is too large. Check!";
145 int iFile = (taskId + iter == iFileMax) ? taskId + iter : (taskId + iter) % iFileMax;
147 string filename =
fDataDir + folder +
"lmvmcand." + iFileString +
".root";
148 TFile* file(TFile::Open(filename.c_str()));
150 vector<LmvmCand>* cands(file->Get<vector<LmvmCand>>(
"fCandsTotal"));
151 if (cands !=
nullptr) {
152 LOG(info) <<
"File taken for mixing: " << filename;
153 candsMix.insert(candsMix.end(), cands->begin(), cands->end());
157 LOG(warning) <<
"LmvmEventMix::DoEventMix(): Loop 'mix': filename = " << filename <<
", candsMix = nullptr!";
159 if (nMixedFiles <
fNofFilesToMix) LOG(warn) <<
"nMixedFiles < fNofFilesToMix. Check cause!";
163 double bW =
fHMean.H1(
"hmx_MinvPM_sameEv_elid")->GetBinWidth(1);
164 fHMean.fHM.ScaleByPattern(
"hmx_Minv.*", 1. / bW);
166 int nCandsMix = candsMix.size();
167 int nCandsSame = candsSame.size();
169 LOG(info) <<
"nCandsSame = " << nCandsSame <<
", nCandsMix = " << nCandsMix;
172 LOG(info) <<
"Real time " << timer.RealTime() <<
" s, CPU time " << timer.CpuTime() <<
" s.";
173 fHMean.FillH1(
"hmx_time", timer.RealTime());
181 if (mode !=
"same" && mode !=
"mix")
182 LOG(error) <<
"LmvmEventMix::FillMinvHistos: event mode must be 'same' or 'mix'!";
183 int nCands = cands.size();
184 for (
int iC1 = 0; iC1 < nCands - 1; iC1++) {
185 const auto& cand1 = cands[iC1];
186 if (cand1.fCharge == 0) LOG(error) <<
"LmvmEventMix::FillMinvHistos: Charge of cand1 is 0. Check!";
187 for (
int iC2 = iC1 + 1; iC2 < nCands; iC2++) {
188 const auto& cand2 = cands[iC2];
189 if (cand2.fCharge == 0) LOG(error) <<
"LmvmEventMix::FillMinvHistos: Charge of cand2 is 0. Check!";
190 if (cand1.fTaskId ==
"" || cand2.fTaskId ==
"")
191 LOG(error) <<
"LmvmEventMix::FillMinvHistos: String 'fTaskId' of at least one candidate is empty. Check!";
193 (cand1.fEventNumber == cand2.fEventNumber && cand1.fTaskId == cand2.fTaskId && cand1.fName == cand2.fName);
194 if ((mode ==
"same" && !isSameEvent) || (mode ==
"mix" && isSameEvent))
continue;
196 if (mode ==
"same" && isSameEvent) evmode =
"_sameEv";
197 if (mode ==
"mix" && !isSameEvent) evmode =
"_mixedEv";
199 LOG(error) <<
"LmvmEventMix::FillMinvHistos: string 'evmode' is not defined. Check!";
202 string comb = (cand1.fCharge * cand2.fCharge < 0) ?
"PM"
203 : (cand1.fCharge < 0 && cand2.fCharge < 0) ?
"MM"
204 : (cand1.fCharge > 0 && cand2.fCharge > 0) ?
"PP"
208 <<
"LmvmEventMix::FillMinvHistos: 'comb' is empty. Check!";
212 for (
auto step :
fHMean.fAnaSteps) {
214 if (!(cand1.IsCutTill(step) && cand2.IsCutTill(step)))
continue;
215 fHMean.FillH1(
"hmx_Minv" + comb + evmode, step, pRec.
fMinv, w);
216 if (std::abs(cand1.fMcPdg) == 11 && std::abs(cand2.fMcPdg) == 11)
217 fHMean.FillH1(
"hmx_Minv" + comb +
"_trueEl" + evmode, step, pRec.
fMinv, w);
218 if (!cand1.IsMcSignal() && !cand2.IsMcSignal())
219 fHMean.FillH1(
"hmx_Minv" + comb +
"_urqmdAll" + evmode, step, pRec.
fMinv, w);
220 if (!cand1.IsMcSignal() && !cand2.IsMcSignal() && std::abs(cand1.fMcPdg) == 11 && std::abs(cand2.fMcPdg) == 11)
221 fHMean.FillH1(
"hmx_Minv" + comb +
"_urqmdEl" + evmode, step, pRec.
fMinv, w);