63 StatusCode
sc(StatusCode::SUCCESS);
67 ATH_MSG_WARNING(
"You need to specify the input PDF file name before you "
68 "call initialize() with "
69 "setPDFFileName('your/file/name.root') ");
70 sc = StatusCode::FAILURE;
73 unsigned int number_of_expected_bin_combinedLH;
78 unsigned int number_of_expected_bin_combinedOther =
82 ATH_MSG_ERROR(
"Configuration issue : cutLikelihood expected size "
83 << number_of_expected_bin_combinedLH <<
" input size "
85 sc = StatusCode::FAILURE;
90 number_of_expected_bin_combinedLH) {
92 "Configuration issue : DiscHardCutForPileupTransform expected size "
93 << number_of_expected_bin_combinedLH <<
" input size "
95 sc = StatusCode::FAILURE;
100 number_of_expected_bin_combinedLH) {
102 "DiscHardCutSlopeForPileupTransform expected size "
103 << number_of_expected_bin_combinedLH <<
" input size "
105 sc = StatusCode::FAILURE;
110 number_of_expected_bin_combinedLH) {
112 "Configuration issue : DiscLooseForPileupTransform expected size "
113 << number_of_expected_bin_combinedLH <<
" input size "
115 sc = StatusCode::FAILURE;
121 if (
m_cutA0.size() != number_of_expected_bin_combinedOther) {
123 << number_of_expected_bin_combinedOther <<
" input size "
125 sc = StatusCode::FAILURE;
131 if (
m_cutDeltaEta.size() != number_of_expected_bin_combinedOther) {
132 ATH_MSG_ERROR(
"Configuration issue : CutDeltaEta expected size "
133 << number_of_expected_bin_combinedOther <<
" input size "
135 sc = StatusCode::FAILURE;
142 ATH_MSG_ERROR(
"Configuration issue : CutDeltaPhiRes expected size "
143 << number_of_expected_bin_combinedOther <<
" input size "
145 sc = StatusCode::FAILURE;
148 if (
sc == StatusCode::FAILURE) {
150 "Could NOT initialize! Please fix the errors mentioned above...");
160 sc = StatusCode::FAILURE;
166 sc = StatusCode::FAILURE;
172 sc = StatusCode::FAILURE;
178 sc = StatusCode::FAILURE;
184 sc = StatusCode::FAILURE;
190 sc = StatusCode::FAILURE;
195 m_acceptInfo.addCut(
"TrackA0",
"A0 (aka d0) wrt beam spot < Cut");
197 sc = StatusCode::FAILURE;
202 "TrackMatchEta",
"Track match deta in 1st sampling < Cut");
204 sc = StatusCode::FAILURE;
209 "TrackMatchPhiRes",
"Track match dphi in 2nd sampling, rescaled < Cut");
211 sc = StatusCode::FAILURE;
216 "WstotAtHighET",
"Above HighETBinThreshold, Wstot < Cut");
218 sc = StatusCode::FAILURE;
223 "EoverPAtHighET",
"Above HighETBinThreshold, EoverP < Cut");
225 sc = StatusCode::FAILURE;
229 if (
sc == StatusCode::FAILURE) {
231 "! Something went wrong with the setup of the decision objects...");
242 gSystem->ExpandPathName(tmpString);
243 std::string fname(tmpString.Data());
244 auto pdfFile = std::unique_ptr<TFile>(TFile::Open(fname.c_str(),
"READ"));
248 return StatusCode::FAILURE;
252 for (
unsigned int varIndex = 0; varIndex <
s_fnVariables; varIndex++) {
268 ATH_MSG_DEBUG(
"Initialization complete for a LH tool with these specs:"
269 <<
"\n - pdfFileName : "
271 <<
"\n - Variable bitmask : "
276 <<
"\n - (bool)CutBL (yes/no) : "
277 << (!
m_cutBL.empty() ?
"yes" :
"no")
278 <<
"\n - (bool)CutPi (yes/no) : "
279 << (!
m_cutPi.empty() ?
"yes" :
"no")
280 <<
"\n - (bool)CutSi (yes/no) : "
281 << (!
m_cutSi.empty() ?
"yes" :
"no")
282 <<
"\n - (bool)CutAmbiguity (yes/no) : "
284 <<
"\n - (bool)doRemoveF3AtHighEt (yes/no) : "
286 <<
"\n - (bool)doRemoveTRTPIDAtHighEt (yes/no) : "
288 <<
"\n - (bool)doSmoothBinInterpolation (yes/no) : "
290 <<
"\n - (bool)useOneExtraHighETLHBin(yes/no) : "
292 <<
"\n - (double)HighETBinThreshold : "
294 <<
"\n - (bool)doPileupTransform (yes/no) : "
296 <<
"\n - (bool)doCentralityTransform (yes/no) : "
298 <<
"\n - (bool)CutLikelihood (yes/no) : "
300 <<
"\n - (bool)CutLikelihoodPileupCorrection (yes/no) : "
302 <<
"\n - (bool)CutA0 (yes/no) : "
303 << (!
m_cutA0.empty() ?
"yes" :
"no")
304 <<
"\n - (bool)CutDeltaEta (yes/no) : "
306 <<
"\n - (bool)CutDeltaPhiRes (yes/no) : "
308 <<
"\n - (bool)CutWstotAtHighET (yes/no) : "
310 <<
"\n - (bool)CutEoverPAtHighET (yes/no) : "
318 unsigned int varIndex)
320 for (
unsigned int s_or_b = 0; s_or_b < 2; ++s_or_b) {
321 for (
unsigned int ip = 0; ip < IP_BINS; ++ip) {
325 std::string sig_bkg = (s_or_b == 0) ?
"sig" :
"bkg";
329 unsigned int eta_tmp = (
eta > 0) ?
eta - 1 :
eta;
332 unsigned int et_tmp =
et;
335 if (((std::string(binname).
find(
"2.37") != std::string::npos)) &&
336 (vstr.find(
"el_f3") != std::string::npos)) {
340 if (((std::string(binname).
find(
"2.01") != std::string::npos) ||
341 (std::string(binname).
find(
"2.37") != std::string::npos)) &&
342 (vstr.find(
"TRT") != std::string::npos)) {
346 const std::string pdfdir = std::format(
"{}/{}", vstr, sig_bkg);
348 std::string pdf = std::format(
"{}_{}_smoothed_hist_from_KDE_{}",
349 vstr, sig_bkg, binname);
351 std::string pdf_newname = std::format(
"{}_{}_{}_LHtool_copy_{}",
352 m_name, vstr, sig_bkg, binname);
354 if (!pdfFile->GetListOfKeys()->Contains(vstr.c_str())) {
356 << vstr <<
" because the folder does not exist.");
359 if (!((TDirectory*)pdfFile->Get(vstr.c_str()))
361 ->Contains(sig_bkg.c_str())) {
363 << vstr <<
" because the folder does not exist.");
370 if (
et == 0 && !((TDirectory*)pdfFile->Get(pdfdir.c_str()))
372 ->Contains(pdf.c_str())) {
375 pdf = std::format(
"{}_{}_smoothed_hist_from_KDE_{}",
376 vstr, sig_bkg, binname);
378 pdf_newname = std::format(
"{}_{}_{}_LHtool_copy4GeV_{}",
379 m_name, vstr, sig_bkg, binname);
381 if (((TDirectory*)pdfFile->Get(pdfdir.c_str()))
383 ->Contains(pdf.c_str())) {
384 TH1F* hist = (TH1F*)(((TDirectory*)pdfFile->Get(pdfdir.c_str()))->Get(pdf.c_str()));
386 std::make_unique<EGSelectors::SafeTH1>(hist);
388 ATH_MSG_INFO(
"Warning: Object " << pdf <<
" does not exist.");
389 ATH_MSG_INFO(
"Skipping all other histograms with this variable.");
403 int nSiHitsPlusDeadSensors,
404 int nPixHitsPlusDeadSensors,
405 bool passBLayerRequirement,
406 uint8_t ambiguityBit,
443 bool passNSilicon(
true);
444 bool passNPixel(
true);
445 bool passNBlayer(
true);
446 bool passAmbiguity(
true);
448 bool passTrackA0(
true);
449 bool passDeltaEta(
true);
450 bool passDeltaPhiRes(
true);
451 bool passWstotAtHighET(
true);
452 bool passEoverPAtHighET(
true);
454 if (std::abs(vars_struct.
eta) > 2.47) {
455 ATH_MSG_DEBUG(
"This electron is std::abs(eta)>2.47 Returning False.");
466 << vars_struct.
eT <<
". Returning false..");
472 << vars_struct.
eT <<
". Returning false..");
488 passAmbiguity =
false;
510 passNSilicon =
false;
514 double cutDiscriminant;
515 unsigned int ibin_combinedLH =
518 unsigned int ibin_combinedOther =
528 <<
" is outside of the range specified by the input"
563 if (vars_struct.
likelihood < cutDiscriminant) {
571 if (std::abs(vars_struct.
d0) >
m_cutA0[ibin_combinedOther]) {
581 passDeltaEta =
false;
590 passDeltaPhiRes =
false;
600 passWstotAtHighET =
false;
608 passEoverPAtHighET =
false;
680 if (etabin == 3 || etabin == 4) {
681 rhad_corr = vars_struct.
rHad;
683 rhad_corr = vars_struct.
rHad1;
685 double d0significance = vars_struct.
d0sigma == 0
687 : std::abs(vars_struct.
d0) / vars_struct.
d0sigma;
689 std::vector<double>
vec = {
691 vars_struct.
f1, vars_struct.
f3, vars_struct.
Reta,
692 rhad_corr, vars_struct.
rphi, vars_struct.
d0,
698 vec, vars_struct.
eT, vars_struct.
eta, vars_struct.
ip);
705 const std::vector<float>& varVector,
710 std::vector<double>
vec;
712 vec.push_back(varVector[var]);
719 const std::vector<double>& varVector,
725 const double GeV = 1000;
731 <<
" etabin: " << etabin);
743 ATH_MSG_WARNING(
"Error! Variable vector size mismatch! Check your vector!");
750 const std::string TRT_string =
"TRT";
751 const std::string el_f3_string =
"el_f3";
752 const std::string el_TRT_PID_string =
"el_TRT_PID";
763 if (((etabin == 8) || (etabin == 9)) &&
764 (varstr.find(TRT_string) != std::string::npos)) {
768 if ((etabin == 9) && (varstr.find(el_f3_string) != std::string::npos)) {
773 (varstr.find(el_f3_string) != std::string::npos)) {
778 (varstr.find(el_TRT_PID_string) != std::string::npos)) {
781 for (
unsigned int s_or_b = 0; s_or_b < 2; s_or_b++) {
784 m_fPDFbins[s_or_b][ipbin][etbin][etabin][var]->FindBin(varVector[var]);
791 double(
m_fPDFbins[s_or_b][ipbin][etbin][etabin][var]->Integral());
799 m_fPDFbins[s_or_b][ipbin][etbin][etabin][var]->GetBinContent(
bin)) /
805 }
else if (s_or_b == 1) {
824 double fEpsilon = 1e-99;
830 double disc = ps / double(ps + pb);
834 }
else if (disc <= 0.0) {
839 disc = -std::log(1.0 / disc - 1.0) * (1. / double(tau));
862 "Vectors needed for pileup-dependent transform not correctly filled! "
863 "Skipping the transform.");
869 ATH_MSG_WARNING(
"Vectors needed for centrality-dependent transform not "
871 "Skipping the transform.");
877 double disc_hard_cut_ref = 0;
878 double disc_hard_cut_ref_slope = 0;
879 double disc_hard_cut_ref_quad =
881 double disc_loose_ref = 0;
890 disc_hard_cut_ref_slope =
896 disc_hard_cut_ref_quad =
909 unsigned int ibin_combined = etfinebinLH *
s_fnEtaBins + etabin;
911 disc_hard_cut_ref_slope =
914 disc_hard_cut_ref_quad =
922 "correctly filled for 4-7 GeV "
923 "bin! Skipping the transform.");
929 "not correctly filled for 4-7 "
930 "GeV bin! Skipping the transform.");
934 disc_hard_cut_ref_slope =
937 disc_hard_cut_ref_quad =
944 std::min(ip, pileup_max);
945 double disc_hard_cut_ref_prime =
946 disc_hard_cut_ref + disc_hard_cut_ref_slope * ip_for_corr +
947 disc_hard_cut_ref_quad * ip_for_corr * ip_for_corr;
949 if (disc <= disc_loose_ref) {
951 }
else if (disc <= disc_hard_cut_ref_prime) {
953 double denom = double(disc_hard_cut_ref_prime - disc_loose_ref);
956 disc = disc_loose_ref + (disc - disc_loose_ref) *
957 (disc_hard_cut_ref - disc_loose_ref) / denom;
958 }
else if (disc_hard_cut_ref_prime < disc && disc <= disc_max) {
960 double denom = double(disc_max - disc_hard_cut_ref_prime);
963 disc = disc_hard_cut_ref + (disc - disc_hard_cut_ref_prime) *
964 (disc_max - disc_hard_cut_ref) / denom;
977 for (
unsigned int ipBin = 0; ipBin < IP_BINS; ++ipBin) {
990 const double etaBins[nEtaBins] = { 0.1, 0.6, 0.8, 1.15, 1.37,
991 1.52, 1.81, 2.01, 2.37, 2.47 };
993 for (
unsigned int etaBin = 0; etaBin < nEtaBins; ++etaBin) {
994 if (std::abs(
eta) < etaBins[etaBin])
1005 const double GeV = 1000;
1008 const double eTBins[nEtBins] = { 7 *
GeV, 10 *
GeV, 15 *
GeV, 20 *
GeV,
1011 for (
unsigned int eTBin = 0; eTBin < nEtBins; ++eTBin) {
1012 if (eT < eTBins[eTBin]) {
1025 const bool isLHbinning)
const
1027 const double GeV = 1000;
1031 const double eTBins[nEtBins] = {
1038 for (
unsigned int eTBin = 0; eTBin < nEtBins; ++eTBin) {
1039 if (eT < eTBins[eTBin])
1047 const double eTBins[nEtBins] = { 10 *
GeV, 15 *
GeV, 20 *
GeV,
1051 for (
unsigned int eTBin = 0; eTBin < nEtBins; ++eTBin) {
1052 if (eT < eTBins[eTBin])
1065 const std::string& iptype)
1067 const double eta_bounds[9] = { 0.0, 0.6, 0.8, 1.15, 1.37, 1.52, 1.81, 2.01, 2.37 };
1068 const int et_bounds[
s_fnEtBinsHist] = { 4, 7, 10, 15, 20, 30, 40 };
1069 if (!iptype.empty()) {
1070 return std::format(
"{}{}et{:02}eta{:.2f}",
1072 et_bounds[etbin], eta_bounds[etabin]);
1074 return std::format(
"et{}eta{:.2f}",
1075 et_bounds[etbin], eta_bounds[etabin]);
1081 const std::string& vars)
const
1083 unsigned int mask = 0x0;
1086 if (vars.find(
s_fVariables[var]) != std::string::npos) {
1088 mask = mask | 0x1 << var;
1100 const std::vector<double>& cuts,
1101 const std::vector<double>& cuts_4gev,
1110 unsigned int ibin_combinedLH = etbinLH *
s_fnEtaBins + etabin;
1111 double cut = cuts.at(ibin_combinedLH);
1114 if (!cuts_4gev.empty()) {
1116 cut = cuts_4gev.at(etabin);
1134 double bin_width = 5000.;
1135 if (7000. <
et &&
et < 10000.) {
1141 const double GeV = 1000;
1145 double bin_center = eTBins[etbinLH];
1146 if (
et > bin_center) {
1147 double cut_next = cut;
1148 if (etbinLH + 1 <= 8)
1149 cut_next = cuts.at((etbinLH + 1) *
s_fnEtaBins + etabin);
1150 return cut + (cut_next - cut) * (
et - bin_center) / (bin_width);
1153 double cut_before = cut;
1155 cut_before = cuts.at((etbinLH - 1) *
s_fnEtaBins + etabin);
1156 }
else if (etbinLH == 0 && !cuts_4gev.empty()) {
1157 cut_before = cuts_4gev.at(etabin);
1160 return cut - (cut - cut_before) * (bin_center -
et) / (bin_width);
1172 unsigned int var)
const
1180 double(
m_fPDFbins[s_or_b][ipbin][etbin][etabin][var]->Integral());
1182 double(
m_fPDFbins[s_or_b][ipbin][etbin][etabin][var]->GetBinContent(
bin)) /
1185 int Nbins =
m_fPDFbins[s_or_b][ipbin][etbin][etabin][var]->GetNbinsX();
1192 if (22500. <
et &&
et < 27500.) {
1195 if (32500. <
et &&
et < 37500.) {
1198 double bin_width = 5000.;
1199 if (7000. <
et &&
et < 10000.) {
1205 const double GeV = 1000;
1210 double bin_center = eTHistBins[etbin];
1211 if (etbin == 4 &&
et >= 27500.) {
1212 bin_center = 27500.;
1214 if (etbin == 5 &&
et >= 37500.) {
1215 bin_center = 37500.;
1217 if (
et > bin_center) {
1218 double prob_next = prob;
1219 if (etbin + 1 <= 6) {
1222 m_fPDFbins[s_or_b][ipbin][etbin + 1][etabin][var]->GetNbinsX();
1224 if (Nbins < NbinsPlus) {
1225 binplus = int(round(
bin * (Nbins / NbinsPlus)));
1226 }
else if (Nbins > NbinsPlus) {
1227 binplus = int(round(
bin * (NbinsPlus / Nbins)));
1230 double integral_next =
1231 double(
m_fPDFbins[s_or_b][ipbin][etbin + 1][etabin][var]->Integral());
1233 double(
m_fPDFbins[s_or_b][ipbin][etbin + 1][etabin][var]->GetBinContent(
1236 return prob + (prob_next - prob) * (
et - bin_center) / (bin_width);
1240 double prob_before = prob;
1241 if (etbin - 1 >= 0) {
1244 m_fPDFbins[s_or_b][ipbin][etbin - 1][etabin][var]->GetNbinsX();
1246 if (Nbins < NbinsMinus) {
1247 binminus = int(round(
bin * (Nbins / NbinsMinus)));
1248 }
else if (Nbins > NbinsMinus) {
1249 binminus = int(round(
bin * (NbinsMinus / Nbins)));
1251 double integral_before =
1252 double(
m_fPDFbins[s_or_b][ipbin][etbin - 1][etabin][var]->Integral());
1254 double(
m_fPDFbins[s_or_b][ipbin][etbin - 1][etabin][var]->GetBinContent(
1258 return prob - (prob - prob_before) * (bin_center -
et) / (bin_width);
1265 "el_d0significance",
1273 "el_trackd0pvunbiased",
1276 "el_deltaphiRescaled",
Scalar eta() const
pseudorapidity method
#define ATH_MSG_WARNING(x)
std::vector< size_t > vec
void setCutResult(const std::string &cutName, bool cutResult)
Set the result of a cut, based on the cut name (safer)
AsgMessaging(const std::string &name)
Constructor with a name.
std::string find(const std::string &s)
return a remapped string
bool passAmbiguity(xAOD::AmbiguityTool::AmbiguityType type, const uint16_t criterion)
return true if the ambiguity type is one of several that are stored in a bitmask
bool passBLayerRequirement
int nSiHitsPlusDeadSensors
int nPixHitsPlusDeadSensors
Extra patterns decribing particle interation process.