Skip to content

Commit 053cdd8

Browse files
committed
MC: allow single signal histogram instead of prompt+fd
1 parent fc40964 commit 053cdd8

1 file changed

Lines changed: 37 additions & 6 deletions

File tree

PWGHF/D2H/Macros/runMassFitter.C

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,11 @@ void runMassFitter(const std::string& configFileName)
9797
std::vector<std::string> inputHistoName;
9898
std::vector<std::string> promptHistoName;
9999
std::vector<std::string> fdHistoName;
100+
std::vector<std::string> signalHistoName;
100101
std::vector<std::string> reflHistoName;
101102
std::vector<std::string> promptSecPeakHistoName;
102103
std::vector<std::string> fdSecPeakHistoName;
104+
std::vector<std::string> signalSecPeakHistoName;
103105
std::vector<double> sliceVarMin;
104106
std::vector<double> sliceVarMax;
105107
std::vector<double> massMin;
@@ -127,9 +129,11 @@ void runMassFitter(const std::string& configFileName)
127129
readJsonVector(inputHistoName, config, "InputHistoName", true);
128130
readJsonVector(promptHistoName, config, "PromptHistoName");
129131
readJsonVector(fdHistoName, config, "FDHistoName");
132+
readJsonVector(signalHistoName, config, "SignalHistoName");
130133
readJsonVector(reflHistoName, config, "ReflHistoName");
131134
readJsonVector(promptSecPeakHistoName, config, "PromptSecPeakHistoName");
132135
readJsonVector(fdSecPeakHistoName, config, "FDSecPeakHistoName");
136+
readJsonVector(signalSecPeakHistoName, config, "SignalSecPeakHistoName");
133137

134138
const bool fixMean = readJsonField<bool>(config, "FixMean", false);
135139
const std::string meanFile = readJsonField<std::string>(config, "MeanFile", "");
@@ -211,9 +215,11 @@ void runMassFitter(const std::string& configFileName)
211215
checkVectorSize(inputHistoName, "inputHistoName", true);
212216
checkVectorSize(promptHistoName, "promptHistoName", true);
213217
checkVectorSize(fdHistoName, "fdHistoName", true);
218+
checkVectorSize(signalHistoName, "signalHistoName", true);
214219
checkVectorSize(reflHistoName, "reflHistoName", true);
215220
checkVectorSize(promptSecPeakHistoName, "promptSecPeakHistoName", true);
216221
checkVectorSize(fdSecPeakHistoName, "fdSecPeakHistoName", true);
222+
checkVectorSize(signalSecPeakHistoName, "signalSecPeakHistoName", true);
217223
checkVectorSize(sliceVarMin, "sliceVarMin");
218224
checkVectorSize(sliceVarMax, "sliceVarMax");
219225
checkVectorSize(massMin, "massMin");
@@ -238,6 +244,15 @@ void runMassFitter(const std::string& configFileName)
238244
checkVectorSize(dscbNRLower, "dscbNRLower", true);
239245
checkVectorSize(dscbNRUpper, "dscbNRUpper", true);
240246

247+
auto checkVectorSizeMcHistograms = [](const auto& vecSignal, const auto& vecPrompt, const auto& vecFd) {
248+
const auto signalSize = vecSignal.size();
249+
const auto promptSize = vecPrompt.size();
250+
const auto fdSize = vecFd.size();
251+
if (!((signalSize > 0 && promptSize == 0 && fdSize == 0) || (signalSize == 0 && promptSize > 0 && fdSize > 0))) {
252+
throw std::runtime_error("ERROR: either signal histogram must be provided or both prompt and fd, but not all three. Exit");
253+
}
254+
};
255+
241256
for (int iSliceVar = 0; iSliceVar < nSliceVarBins; iSliceVar++) {
242257
sliceVarLimits[iSliceVar] = sliceVarMin[iSliceVar];
243258

@@ -290,15 +305,31 @@ void runMassFitter(const std::string& configFileName)
290305
hMass[iSliceVar] = getObjectWithNullPtrCheck<TH1>(inputFile, inputHistoName[iSliceVar]);
291306
if (enableRefl) {
292307
hMassRefl[iSliceVar] = getObjectWithNullPtrCheck<TH1>(inputFileRefl, reflHistoName[iSliceVar]);
293-
hMassSgn[iSliceVar] = getObjectWithNullPtrCheck<TH1>(inputFileRefl, fdHistoName[iSliceVar]);
294-
hMassSgn[iSliceVar]->Add(getObjectWithNullPtrCheck<TH1>(inputFileRefl, promptHistoName[iSliceVar]));
308+
309+
checkVectorSizeMcHistograms(signalHistoName, promptHistoName, fdHistoName);
310+
if (!signalHistoName.empty()) {
311+
hMassSgn[iSliceVar] = getObjectWithNullPtrCheck<TH1>(inputFileRefl, signalHistoName[iSliceVar]);
312+
} else {
313+
hMassSgn[iSliceVar] = getObjectWithNullPtrCheck<TH1>(inputFileRefl, fdHistoName[iSliceVar]);
314+
hMassSgn[iSliceVar]->Add(getObjectWithNullPtrCheck<TH1>(inputFileRefl, promptHistoName[iSliceVar]));
315+
}
295316
}
296317
} else {
297-
hMass[iSliceVar] = getObjectWithNullPtrCheck<TH1>(inputFile, promptHistoName[iSliceVar]);
298-
hMass[iSliceVar]->Add(getObjectWithNullPtrCheck<TH1>(inputFile, fdHistoName[iSliceVar]));
318+
checkVectorSizeMcHistograms(signalHistoName, promptHistoName, fdHistoName);
319+
if (!signalHistoName.empty()) {
320+
hMass[iSliceVar] = getObjectWithNullPtrCheck<TH1>(inputFile, signalHistoName[iSliceVar]);
321+
} else {
322+
hMass[iSliceVar] = getObjectWithNullPtrCheck<TH1>(inputFile, promptHistoName[iSliceVar]);
323+
hMass[iSliceVar]->Add(getObjectWithNullPtrCheck<TH1>(inputFile, fdHistoName[iSliceVar]));
324+
}
299325
if (includeSecPeak) {
300-
hMass[iSliceVar]->Add(getObjectWithNullPtrCheck<TH1>(inputFile, promptSecPeakHistoName[iSliceVar]));
301-
hMass[iSliceVar]->Add(getObjectWithNullPtrCheck<TH1>(inputFile, fdSecPeakHistoName[iSliceVar]));
326+
checkVectorSizeMcHistograms(signalSecPeakHistoName, promptSecPeakHistoName, fdSecPeakHistoName);
327+
if (!signalHistoName.empty()) {
328+
hMass[iSliceVar]->Add(getObjectWithNullPtrCheck<TH1>(inputFile, signalSecPeakHistoName[iSliceVar]));
329+
} else {
330+
hMass[iSliceVar]->Add(getObjectWithNullPtrCheck<TH1>(inputFile, promptSecPeakHistoName[iSliceVar]));
331+
hMass[iSliceVar]->Add(getObjectWithNullPtrCheck<TH1>(inputFile, fdSecPeakHistoName[iSliceVar]));
332+
}
302333
}
303334
}
304335
hMass[iSliceVar]->SetDirectory(nullptr);

0 commit comments

Comments
 (0)