18 "el_secondLambda",
"el_lateral",
"el_longitudinal",
"el_centerLambda",
19 "el_fracMax",
"el_secondR",
"el_significance",
"el_secondDensity"
24 :
asg::AsgMessaging(std::string(
name))
25 , m_doPileupCorrection(false)
28 , m_variableBitMask(0x0)
29 , m_cutPosition_kinematicEta(-9)
30 , m_cutPosition_kinematicEt(-9)
31 , m_cutPosition_LH(-9)
43 if (m_pdfFileName.empty()) {
45 "You need to specify the input PDF file name before you call "
46 "initialize() with setPDFFileName('your/file/name.root') ");
47 sc = StatusCode::FAILURE;
50 unsigned int number_of_expected_bin = s_fnDiscEtBins * s_fnEtaBins;
51 if (m_cutLikelihood.size() != number_of_expected_bin) {
52 ATH_MSG_ERROR(
"Configuration issue : CutLikelihood expected size "
53 << number_of_expected_bin <<
" input size "
54 << m_cutLikelihood.size());
56 "Could NOT initialize! Please fix the errors mentioned above...");
57 sc = StatusCode::FAILURE;
65 m_cutPosition_kinematicEta =
66 m_acceptInfo.addCut(
"kinematicEta",
"pass kinematic eta");
67 if (m_cutPosition_kinematicEta < 0)
68 sc = StatusCode::FAILURE;
69 m_cutPosition_kinematicEt =
70 m_acceptInfo.addCut(
"kinematicEt",
"pass kinematic Et ");
71 if (m_cutPosition_kinematicEt < 0)
72 sc = StatusCode::FAILURE;
75 m_cutPosition_LH = m_acceptInfo.addCut(
"passLH",
"pass Likelihood");
76 if (m_cutPosition_LH < 0) {
77 sc = StatusCode::FAILURE;
81 if (
sc == StatusCode::FAILURE) {
83 "! Something went wrong with the setup of the return objects...");
88 m_variableBitMask = getLikelihoodBitmask(m_variableNames);
92 TString tmpString(m_pdfFileName);
93 gSystem->ExpandPathName(tmpString);
94 std::string
fname(tmpString.Data());
95 m_pdfFile = TFile::Open(
fname.c_str(),
"READ");
99 return StatusCode::FAILURE;
103 for (
unsigned int varIndex = 0; varIndex < s_fnVariables; varIndex++) {
104 const std::string& vstr = fVariables[varIndex];
108 if (m_variableNames.find(vstr) == std::string::npos &&
109 !m_variableNames.empty()) {
112 loadVarHistograms(vstr, varIndex);
121 ATH_MSG_DEBUG(
"Initialization complete for a LH tool with these specs:"
122 <<
"\n - PdfFileName : "
124 <<
"\n - Variable bitmask : "
126 <<
"\n - VariableNames : "
133 unsigned int varIndex)
135 for (
unsigned int s_or_b = 0; s_or_b < 2; ++s_or_b) {
136 for (
unsigned int ip = 0;
ip < IP_FBINS; ++
ip) {
137 for (
unsigned int et = 0;
et < s_fnEtBinsHist; ++
et) {
138 for (
unsigned int eta = 0; eta < s_fnEtaBins; ++eta) {
140 std::string sig_bkg = (s_or_b == 0) ?
"sig" :
"bkg";
143 unsigned int eta_tmp = eta;
144 unsigned int et_tmp =
et;
145 std::string binname = getBinName(et_tmp, eta_tmp,
ip, m_ipBinning);
147 const std::string pdfdir =
std::format(
"{}/{}", vstr, sig_bkg);
149 vstr, sig_bkg, binname);
151 if (!m_pdfFile->GetListOfKeys()->Contains(vstr.c_str())) {
153 << vstr <<
" because the folder does not exist.");
156 if (!((TDirectory*)m_pdfFile->Get(vstr.c_str()))
158 ->Contains(sig_bkg.c_str())) {
160 << vstr <<
" because the folder does not exist.");
164 if (
et == 0 && !((TDirectory*)m_pdfFile->Get(pdfdir.c_str()))
166 ->Contains(
pdf.c_str())) {
167 ATH_MSG_INFO(
"using lowest GeV bin in place of all below.");
168 binname = getBinName(et_tmp + 1, eta_tmp,
ip, m_ipBinning);
170 vstr, sig_bkg, binname);
172 if (((TDirectory*)m_pdfFile->Get(pdfdir.c_str()))
174 ->Contains(
pdf.c_str())) {
176 (
TH1F*)(((TDirectory*)m_pdfFile->Get(pdfdir.c_str()))->Get(
pdf.c_str()));
177 m_fPDFbins[s_or_b][
ip][
et][eta][varIndex] =
178 std::make_unique<EGSelectors::SafeTH1>(
hist);
181 ATH_MSG_INFO(
"Skipping all other histograms with this variable.");
217 bool passKineEta(
true);
218 bool passKineEt(
true);
221 if (std::fabs(vars_struct.
eta) < 2.5) {
224 <<
", which is fabs(eta)<2.5 Returning False.");
228 acceptData.
setCutResult(m_cutPosition_kinematicEta, passKineEta);
233 unsigned int etbin = getLikelihoodEtHistBin(vars_struct.
eT);
234 unsigned int etabin = getLikelihoodEtaBin(vars_struct.
eta);
236 if (etbin >= s_fnDiscEtBins) {
238 << vars_struct.
eT <<
". Returning false..");
243 acceptData.
setCutResult(m_cutPosition_kinematicEt, passKineEt);
248 double cutDiscriminant = -999.;
249 unsigned int ibin_combined = etbin * s_fnEtaBins + etabin;
251 if (!m_cutLikelihood.empty()) {
253 cutDiscriminant = m_cutLikelihood[ibin_combined];
256 if (m_doPileupCorrection) {
258 vars_struct.
ip * m_cutLikelihoodPileupCorrectionA[ibin_combined] +
259 m_cutLikelihoodPileupCorrectionB[ibin_combined];
265 if (vars_struct.
likelihood < cutDiscriminant) {
283 double secondDensity,
289 vars.secondLambda = secondLambda;
290 vars.lateral = lateral;
291 vars.longitudinal = longitudinal;
292 vars.centerLambda = centerLambda;
293 vars.fracMax = fracMax;
294 vars.secondR = secondR;
295 vars.significance = significance;
296 vars.secondDensity = secondDensity;
312 std::vector<double>
vec(arr, arr +
sizeof(arr) /
sizeof(
double));
315 result = this->evaluateLikelihood(
316 vec, vars_struct.
eT, vars_struct.
eta, vars_struct.
ip);
322 const std::vector<float>& varVector,
327 std::vector<double>
vec;
328 for (
unsigned int var = 0;
var < s_fnVariables;
var++) {
329 vec.push_back(varVector[
var]);
331 return evaluateLikelihood(
vec,
et, eta,
ip);
336 const std::vector<double>& varVector,
342 unsigned int etbin = getLikelihoodEtHistBin(
et);
343 unsigned int etabin = getLikelihoodEtaBin(eta);
344 unsigned int ipbin = getIpBin(
ip);
346 if (etbin >= s_fnEtBinsHist) {
350 if (etabin >= s_fnEtaBins) {
355 if (varVector.size() != s_fnVariables) {
356 ATH_MSG_WARNING(
"Error! Variable vector size mismatch! Check your vector!");
363 for (
unsigned int var = 0;
var < s_fnVariables;
var++) {
365 std::string varstr = fVariables[
var];
368 if (!(m_variableBitMask & (0
x1 <<
var))) {
372 for (
unsigned int s_or_b = 0; s_or_b < 2; s_or_b++) {
375 m_fPDFbins[s_or_b][ipbin][etbin][etabin][
var]->FindBin(varVector[
var]);
379 double(m_fPDFbins[s_or_b][ipbin][etbin][etabin][
var]->Integral());
382 "Error! PDF integral == 0!");
388 prob =
double(m_fPDFbins[s_or_b][ipbin][etbin][etabin][
var]->GetBinContent(
394 else if (s_or_b == 1)
399 return TransformLikelihoodOutput(SigmaS, SigmaB);
409 double fEpsilon = 1
e-99;
419 else if (disc <= 0.0)
433 for (
unsigned int ipBin = 0; ipBin < IP_FBINS; ++ipBin) {
434 if (
ip < fIpBounds[ipBin + 1])
444 const unsigned int nEtaBins = s_fnEtaBins;
446 3.1, 3.16, 3.35, 3.6, 4.9 };
457 const double GeV = 1000;
458 const unsigned int nEtBins = s_fnDiscEtBins;
459 const double eTBins[nEtBins] = {
462 for (
unsigned int eTBin = 0; eTBin < nEtBins; ++eTBin) {
463 if (
eT < eTBins[eTBin]) {
467 return (nEtBins - 1);
477 const std::string& iptype)
479 double eta_bounds[s_fnEtaBins] = { 2.5, 2.6, 2.7, 2.8, 2.9,
480 3.0, 3.1, 3.16, 3.35, 3.6 };
481 int et_bounds[s_fnEtBinsHist] = { 20, 30, 40, 50 };
482 if (!iptype.empty()) {
484 iptype,
int(fIpBounds[ipbin]),
485 et_bounds[etbin], eta_bounds[etabin]);
488 et_bounds[etbin], eta_bounds[etabin]);
494 const std::string& vars)
const
496 unsigned int mask = 0x0;
498 for (
unsigned int var = 0;
var < s_fnVariables;
var++) {
499 if (vars.find(fVariables[
var]) != std::string::npos) {