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 fPDFbins[s_or_b][
ip][
et][eta][varIndex] =
182 ATH_MSG_INFO(
"Skipping all other histograms with this variable.");
218 bool passKineEta(
true);
219 bool passKineEt(
true);
222 if (fabs(vars_struct.
eta) < 2.5) {
225 <<
", which is fabs(eta)<2.5 Returning False.");
229 acceptData.
setCutResult(m_cutPosition_kinematicEta, passKineEta);
234 unsigned int etbin = getLikelihoodEtHistBin(vars_struct.
eT);
235 unsigned int etabin = getLikelihoodEtaBin(vars_struct.
eta);
237 if (etbin >= s_fnDiscEtBins) {
239 << vars_struct.
eT <<
". Returning false..");
244 acceptData.
setCutResult(m_cutPosition_kinematicEt, passKineEt);
249 double cutDiscriminant = -999.;
250 unsigned int ibin_combined = etbin * s_fnEtaBins + etabin;
252 if (!m_cutLikelihood.empty()) {
254 cutDiscriminant = m_cutLikelihood[ibin_combined];
257 if (m_doPileupCorrection) {
259 vars_struct.
ip * m_cutLikelihoodPileupCorrectionA[ibin_combined] +
260 m_cutLikelihoodPileupCorrectionB[ibin_combined];
266 if (vars_struct.
likelihood < cutDiscriminant) {
284 double secondDensity,
290 vars.secondLambda = secondLambda;
291 vars.lateral = lateral;
292 vars.longitudinal = longitudinal;
293 vars.centerLambda = centerLambda;
294 vars.fracMax = fracMax;
295 vars.secondR = secondR;
296 vars.significance = significance;
297 vars.secondDensity = secondDensity;
313 std::vector<double>
vec(arr, arr +
sizeof(arr) /
sizeof(
double));
316 result = this->evaluateLikelihood(
317 vec, vars_struct.
eT, vars_struct.
eta, vars_struct.
ip);
323 std::vector<float>& varVector,
328 std::vector<double>
vec;
329 for (
unsigned int var = 0;
var < s_fnVariables;
var++) {
330 vec.push_back(varVector[
var]);
332 return evaluateLikelihood(
vec,
et, eta,
ip);
337 std::vector<double>& varVector,
343 unsigned int etbin = getLikelihoodEtHistBin(
et);
344 unsigned int etabin = getLikelihoodEtaBin(eta);
345 unsigned int ipbin = getIpBin(
ip);
347 if (etbin >= s_fnEtBinsHist) {
351 if (etabin >= s_fnEtaBins) {
356 if (varVector.size() != s_fnVariables) {
357 ATH_MSG_WARNING(
"Error! Variable vector size mismatch! Check your vector!");
364 for (
unsigned int var = 0;
var < s_fnVariables;
var++) {
366 std::string varstr = fVariables[
var];
369 if (!(m_variableBitMask & (0
x1 <<
var))) {
373 for (
unsigned int s_or_b = 0; s_or_b < 2; s_or_b++) {
376 fPDFbins[s_or_b][ipbin][etbin][etabin][
var]->FindBin(varVector[
var]);
380 double(fPDFbins[s_or_b][ipbin][etbin][etabin][
var]->Integral());
383 "Error! PDF integral == 0!");
389 prob =
double(fPDFbins[s_or_b][ipbin][etbin][etabin][
var]->GetBinContent(
395 else if (s_or_b == 1)
400 return TransformLikelihoodOutput(SigmaS, SigmaB);
410 double fEpsilon = 1
e-99;
420 else if (disc <= 0.0)
424 disc = -
log(1.0 / disc - 1.0) * (1. /
double(tau));
434 for (
unsigned int ipBin = 0; ipBin < IP_FBINS; ++ipBin) {
435 if (
ip < fIpBounds[ipBin + 1])
445 const unsigned int nEtaBins = s_fnEtaBins;
447 3.1, 3.16, 3.35, 3.6, 4.9 };
458 const double GeV = 1000;
459 const unsigned int nEtBins = s_fnDiscEtBins;
460 const double eTBins[nEtBins] = {
463 for (
unsigned int eTBin = 0; eTBin < nEtBins; ++eTBin) {
464 if (
eT < eTBins[eTBin]) {
468 return (nEtBins - 1);
478 const std::string& iptype)
480 double eta_bounds[s_fnEtaBins] = { 2.5, 2.6, 2.7, 2.8, 2.9,
481 3.0, 3.1, 3.16, 3.35, 3.6 };
482 int et_bounds[s_fnEtBinsHist] = { 20, 30, 40, 50 };
483 if (!iptype.empty()) {
485 iptype,
int(fIpBounds[ipbin]),
486 et_bounds[etbin], eta_bounds[etabin]);
489 et_bounds[etbin], eta_bounds[etabin]);
495 const std::string& vars)
const
497 unsigned int mask = 0x0;
499 for (
unsigned int var = 0;
var < s_fnVariables;
var++) {
500 if (vars.find(fVariables[
var]) != std::string::npos) {