17 "el_secondLambda",
"el_lateral",
"el_longitudinal",
"el_centerLambda",
18 "el_fracMax",
"el_secondR",
"el_significance",
"el_secondDensity"
23 :
asg::AsgMessaging(std::string(
name))
24 , m_doPileupCorrection(false)
27 , m_variableBitMask(0x0)
28 , m_cutPosition_kinematicEta(-9)
29 , m_cutPosition_kinematicEt(-9)
30 , m_cutPosition_LH(-9)
32 for (
unsigned int varIndex = 0; varIndex <
s_fnVariables; varIndex++) {
34 for (
auto &
ip : fPDFbin) {
36 for (
unsigned int eta = 0; eta <
s_fnEtaBins; eta++) {
37 ip[
et][eta][varIndex] =
nullptr;
50 for (
unsigned int varIndex = 0; varIndex < s_fnVariables; varIndex++) {
51 for (
auto & fPDFbin : fPDFbins) {
52 for (
auto &
ip : fPDFbin) {
53 for (
unsigned int et = 0;
et < s_fnEtBinsHist;
et++) {
54 for (
unsigned int eta = 0; eta < s_fnEtaBins; eta++) {
55 delete ip[
et][eta][varIndex];
56 ip[
et][eta][varIndex] =
nullptr;
72 if (m_pdfFileName.empty()) {
74 "You need to specify the input PDF file name before you call "
75 "initialize() with setPDFFileName('your/file/name.root') ");
76 sc = StatusCode::FAILURE;
79 unsigned int number_of_expected_bin = s_fnDiscEtBins * s_fnEtaBins;
80 if (m_cutLikelihood.size() != number_of_expected_bin) {
81 ATH_MSG_ERROR(
"Configuration issue : CutLikelihood expected size "
82 << number_of_expected_bin <<
" input size "
83 << m_cutLikelihood.size());
85 "Could NOT initialize! Please fix the errors mentioned above...");
86 sc = StatusCode::FAILURE;
94 m_cutPosition_kinematicEta =
95 m_acceptInfo.addCut(
"kinematicEta",
"pass kinematic eta");
96 if (m_cutPosition_kinematicEta < 0)
97 sc = StatusCode::FAILURE;
98 m_cutPosition_kinematicEt =
99 m_acceptInfo.addCut(
"kinematicEt",
"pass kinematic Et ");
100 if (m_cutPosition_kinematicEt < 0)
101 sc = StatusCode::FAILURE;
104 m_cutPosition_LH = m_acceptInfo.addCut(
"passLH",
"pass Likelihood");
105 if (m_cutPosition_LH < 0) {
106 sc = StatusCode::FAILURE;
110 if (
sc == StatusCode::FAILURE) {
112 "! Something went wrong with the setup of the return objects...");
117 m_variableBitMask = getLikelihoodBitmask(m_variableNames);
121 TString tmpString(m_pdfFileName);
122 gSystem->ExpandPathName(tmpString);
123 std::string
fname(tmpString.Data());
124 m_pdfFile = TFile::Open(
fname.c_str(),
"READ");
127 ATH_MSG_ERROR(
" No ROOT file found here: " << m_pdfFileName);
128 return StatusCode::FAILURE;
132 for (
unsigned int varIndex = 0; varIndex < s_fnVariables; varIndex++) {
133 const std::string& vstr = fVariables[varIndex];
137 if (m_variableNames.find(vstr) == std::string::npos &&
138 !m_variableNames.empty()) {
141 loadVarHistograms(vstr, varIndex);
150 ATH_MSG_DEBUG(
"Initialization complete for a LH tool with these specs:"
151 <<
"\n - PdfFileName : "
153 <<
"\n - Variable bitmask : "
155 <<
"\n - VariableNames : "
162 unsigned int varIndex)
164 for (
unsigned int s_or_b = 0; s_or_b < 2; ++s_or_b) {
165 for (
unsigned int ip = 0;
ip < IP_FBINS; ++
ip) {
166 for (
unsigned int et = 0;
et < s_fnEtBinsHist; ++
et) {
167 for (
unsigned int eta = 0; eta < s_fnEtaBins; ++eta) {
169 std::string sig_bkg = (s_or_b == 0) ?
"sig" :
"bkg";
172 unsigned int eta_tmp = eta;
173 unsigned int et_tmp =
et;
175 getBinName(binname, et_tmp, eta_tmp,
ip, m_ipBinning);
178 snprintf(pdfdir, 500,
"%s/%s", vstr.c_str(), sig_bkg.c_str());
182 "%s_%s_smoothed_hist_from_KDE_%s",
187 if (!m_pdfFile->GetListOfKeys()->Contains(vstr.c_str())) {
189 << vstr <<
" because the folder does not exist.");
192 if (!((TDirectory*)m_pdfFile->Get(vstr.c_str()))
194 ->Contains(sig_bkg.c_str())) {
196 << vstr <<
" because the folder does not exist.");
200 if (
et == 0 && !((TDirectory*)m_pdfFile->Get(pdfdir))
203 ATH_MSG_INFO(
"using lowest GeV bin in place of all below.");
204 getBinName(binname, et_tmp + 1, eta_tmp,
ip, m_ipBinning);
207 "%s_%s_smoothed_hist_from_KDE_%s",
212 if (((TDirectory*)m_pdfFile->Get(pdfdir))
216 (
TH1F*)(((TDirectory*)m_pdfFile->Get(pdfdir))->Get(
pdf));
217 fPDFbins[s_or_b][
ip][
et][eta][varIndex] =
222 ATH_MSG_INFO(
"Skipping all other histograms with this variable.");
258 bool passKineEta(
true);
259 bool passKineEt(
true);
262 if (fabs(vars_struct.
eta) < 2.5) {
265 <<
", which is fabs(eta)<2.5 Returning False.");
269 acceptData.
setCutResult(m_cutPosition_kinematicEta, passKineEta);
274 unsigned int etbin = getLikelihoodEtHistBin(vars_struct.
eT);
275 unsigned int etabin = getLikelihoodEtaBin(vars_struct.
eta);
277 if (etbin >= s_fnDiscEtBins) {
279 << vars_struct.
eT <<
". Returning false..");
284 acceptData.
setCutResult(m_cutPosition_kinematicEt, passKineEt);
289 double cutDiscriminant = -999.;
290 unsigned int ibin_combined = etbin * s_fnEtaBins + etabin;
292 if (!m_cutLikelihood.empty()) {
294 cutDiscriminant = m_cutLikelihood[ibin_combined];
297 if (m_doPileupCorrection) {
299 vars_struct.
ip * m_cutLikelihoodPileupCorrectionA[ibin_combined] +
300 m_cutLikelihoodPileupCorrectionB[ibin_combined];
306 if (vars_struct.
likelihood < cutDiscriminant) {
324 double secondDensity,
330 vars.secondLambda = secondLambda;
331 vars.lateral = lateral;
332 vars.longitudinal = longitudinal;
333 vars.centerLambda = centerLambda;
334 vars.fracMax = fracMax;
335 vars.secondR = secondR;
336 vars.significance = significance;
337 vars.secondDensity = secondDensity;
353 std::vector<double>
vec(arr, arr +
sizeof(arr) /
sizeof(
double));
356 result = this->evaluateLikelihood(
357 vec, vars_struct.
eT, vars_struct.
eta, vars_struct.
ip);
363 std::vector<float>& varVector,
368 std::vector<double>
vec;
369 for (
unsigned int var = 0;
var < s_fnVariables;
var++) {
370 vec.push_back(varVector[
var]);
372 return evaluateLikelihood(
vec,
et, eta,
ip);
377 std::vector<double>& varVector,
383 unsigned int etbin = getLikelihoodEtHistBin(
et);
384 unsigned int etabin = getLikelihoodEtaBin(eta);
385 unsigned int ipbin = getIpBin(
ip);
387 if (etbin >= s_fnEtBinsHist) {
391 if (etabin >= s_fnEtaBins) {
396 if (varVector.size() != s_fnVariables) {
397 ATH_MSG_WARNING(
"Error! Variable vector size mismatch! Check your vector!");
404 for (
unsigned int var = 0;
var < s_fnVariables;
var++) {
406 std::string varstr = fVariables[
var];
409 if (!(m_variableBitMask & (0
x1 <<
var))) {
413 for (
unsigned int s_or_b = 0; s_or_b < 2; s_or_b++) {
416 fPDFbins[s_or_b][ipbin][etbin][etabin][
var]->FindBin(varVector[
var]);
420 double(fPDFbins[s_or_b][ipbin][etbin][etabin][
var]->Integral());
423 "Error! PDF integral == 0!");
429 prob =
double(fPDFbins[s_or_b][ipbin][etbin][etabin][
var]->GetBinContent(
435 else if (s_or_b == 1)
440 return TransformLikelihoodOutput(SigmaS, SigmaB);
450 double fEpsilon = 1
e-99;
460 else if (disc <= 0.0)
464 disc = -
log(1.0 / disc - 1.0) * (1. /
double(tau));
474 for (
unsigned int ipBin = 0; ipBin < IP_FBINS; ++ipBin) {
475 if (
ip < fIpBounds[ipBin + 1])
485 const unsigned int nEtaBins = s_fnEtaBins;
487 3.1, 3.16, 3.35, 3.6, 4.9 };
498 const double GeV = 1000;
499 const unsigned int nEtBins = s_fnDiscEtBins;
500 const double eTBins[nEtBins] = {
503 for (
unsigned int eTBin = 0; eTBin < nEtBins; ++eTBin) {
504 if (
eT < eTBins[eTBin]) {
508 return (nEtBins - 1);
519 const std::string& iptype)
521 double eta_bounds[s_fnEtaBins] = { 2.5, 2.6, 2.7, 2.8, 2.9,
522 3.0, 3.1, 3.16, 3.35, 3.6 };
523 int et_bounds[s_fnEtBinsHist] = { 20, 30, 40, 50 };
524 if (!iptype.empty()) {
527 "%s%det%02deta%0.2f",
529 int(fIpBounds[ipbin]),
533 snprintf(
buffer, 200,
"et%deta%0.2f", et_bounds[etbin], eta_bounds[etabin]);
539 const std::string& vars)
const
541 unsigned int mask = 0x0;
543 for (
unsigned int var = 0;
var < s_fnVariables;
var++) {
544 if (vars.find(fVariables[
var]) != std::string::npos) {