![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
Go to the documentation of this file.
45 declareProperty(
"WorkingPoint", m_workingPoint=
"",
"The Working Point");
46 declareProperty(
"ConfigFile", m_configFile=
"",
"The config file to use");
49 declareProperty(
"inputModelFileName", m_modelFileName=
"",
"The input file name that holds the model" );
51 declareProperty(
"quantileFileName", m_quantileFileName=
"",
"The input file name that holds the QuantileTransformer");
53 declareProperty(
"multiClass", m_multiClass,
"Whether the given model is multiclass or not");
55 declareProperty(
"CFReject", m_CFReject,
"Whether we use the DNN CF+ID approach or the regular DNN ID");
57 declareProperty(
"cfSignal", m_cfSignal,
"Whether to include the CF fraction in the numerator or denominator");
59 declareProperty(
"Fractions", m_fractions,
"Fractions to combine the single outputs into one discriminant");
61 declareProperty(
"Variables", m_variables,
"Variables used in the MVA tool");
63 declareProperty(
"CutSelector", m_cutSelector,
"Cut on prompt electrons MVA discriminant");
64 declareProperty(
"CutSelectorCF", m_cutSelectorCF,
"Cut on CF electrons MVA discriminant");
66 declareProperty(
"CutAmbiguity" , m_cutAmbiguity,
"Apply a cut on the ambiguity bit");
74 declareProperty(
"doSmoothBinInterpolation", m_doSmoothBinInterpolation,
"use smooth interpolation between discriminant bins");
76 declareProperty(
"skipDeltaPoverP",m_skipDeltaPoverP =
false,
"If true, it will skip the check of deltaPoverP");
78 declareProperty(
"skipAmbiguityCut",m_skipAmbiguityCut =
false,
"If true, it will skip the ambiguity cut");
103 return StatusCode::FAILURE;
111 std::string modelFilename(
"");
112 std::string quantileFilename(
"");
122 modelFilename =
env.GetValue(
"inputModelFileName",
"ElectronPhotonSelectorTools/offline/mc16_20210204/ElectronDNNNetwork.json");
123 ATH_MSG_DEBUG(
"Getting the input Model from: " << modelFilename );
127 ATH_MSG_ERROR(
"Could not find model file " << modelFilename);
128 return StatusCode::FAILURE;
139 quantileFilename =
env.GetValue(
"inputQuantileFileName",
"ElectronPhotonSelectorTools/offline/mc16_20210204/ElectronDNNQuantileTransformer.root");
140 ATH_MSG_DEBUG(
"Getting the input QuantileTransformer from: " << quantileFilename);
143 if (qfilename.empty()){
144 ATH_MSG_ERROR(
"Could not find QuantileTransformer file " << quantileFilename);
145 return StatusCode::FAILURE;
149 std::stringstream vars(
env.GetValue(
"Variables",
""));
153 std::getline(vars, substr,
',');
181 unsigned int numberOfExpectedBinCombinedMVA ;
186 ATH_MSG_ERROR(
"Configuration issue : cutSelector expected size " << numberOfExpectedBinCombinedMVA <<
188 return StatusCode::FAILURE;
194 ATH_MSG_ERROR(
"Configuration issue : cutSelectorCF expected size " << numberOfExpectedBinCombinedMVA <<
196 return StatusCode::FAILURE;
215 if (
m_fractions.size() != numberOfExpectedEtaBins * 5){
217 return StatusCode::FAILURE;
223 if (
m_cutSCT.size() != numberOfExpectedEtaBins){
224 ATH_MSG_ERROR(
"Configuration issue : cutSCT expected size " << numberOfExpectedEtaBins <<
226 return StatusCode::FAILURE;
231 if (
m_cutPi.size() != numberOfExpectedEtaBins){
232 ATH_MSG_ERROR(
"Configuration issue : cutPi expected size " << numberOfExpectedEtaBins <<
233 " input size " <<
m_cutPi.size());
234 return StatusCode::FAILURE;
239 if (
m_cutBL.size() != numberOfExpectedEtaBins){
240 ATH_MSG_ERROR(
"Configuration issue : cutBL expected size " << numberOfExpectedEtaBins <<
241 " input size " <<
m_cutBL.size());
242 return StatusCode::FAILURE;
248 ATH_MSG_ERROR(
"Configuration issue : cutAmbiguity expected size " << numberOfExpectedEtaBins <<
250 return StatusCode::FAILURE;
287 ATH_MSG_ERROR(
"ERROR: Something went wrong with the setup of the decision objects...");
288 return StatusCode::FAILURE;
294 return StatusCode::FAILURE;
307 return StatusCode::SUCCESS;
325 ATH_MSG_VERBOSE(
"\t AsgElectronSelectorTool::accept( &ctx, *eg, mu= "<<(&ctx)<<
", "<<
eg<<
", "<<
mu<<
" )");
331 throw std::runtime_error(
"AsgElectronSelectorTool: Failed, no electron object was passed");
336 ATH_MSG_DEBUG(
"exiting because cluster is NULL " << cluster);
341 ATH_MSG_DEBUG(
"Failed, cluster is missing samplings EMB2 and EME2");
345 const double energy = cluster->
e();
346 const float eta = cluster->
etaBE(2);
349 ATH_MSG_DEBUG(
"Failed, this is a forward electron! The AsgElectronSelectorTool is only suitable for central electrons!");
363 uint8_t nSiHitsPlusDeadSensors(0);
364 uint8_t nPixHitsPlusDeadSensors(0);
368 bool allFound =
true;
369 std::string notFoundList =
"";
375 ambiguityBit = ambiguityTypeAcc(*
eg);
379 notFoundList +=
"ambiguityType ";
389 ATH_MSG_VERBOSE(Form(
"PassVars: MVA=%8.5f, eta=%8.5f, et=%8.5f, nSiHitsPlusDeadSensors=%i, nHitsPlusPixDeadSensors=%i, passBLayerRequirement=%i, ambiguityBit=%i, mu=%8.5f",
391 nSiHitsPlusDeadSensors, nPixHitsPlusDeadSensors,
394 double mvaScoreCF = 0;
397 ATH_MSG_VERBOSE(Form(
"PassVars: MVA=%8.5f, eta=%8.5f, et=%8.5f, nSiHitsPlusDeadSensors=%i, nHitsPlusPixDeadSensors=%i, passBLayerRequirement=%i, ambiguityBit=%i, mu=%8.5f",
399 nSiHitsPlusDeadSensors, nPixHitsPlusDeadSensors,
405 throw std::runtime_error(
"AsgElectronSelectorTool: Not all variables needed for the decision are found. The following variables are missing: " + notFoundList );
410 bool passNSilicon(
true);
411 bool passNPixel(
true);
412 bool passNBlayer(
true);
416 if (std::abs(
eta) > 2.47){
417 ATH_MSG_DEBUG(
"This electron is fabs(eta)>2.47 Returning False.");
426 ATH_MSG_DEBUG(
"Cannot evaluate model for Et " <<
et <<
". Returning false..");
432 if (!passKine){
return acceptData;}
460 passNSilicon =
false;
469 double cutDiscriminantCF;
472 throw std::runtime_error(
"AsgElectronSelectorTool: The desired eta/pt bin is outside of the range specified by the input. This should never happen! This indicates a mismatch between the binning in the configuration file and the tool implementation." );
482 if (mvaScoreCF < cutDiscriminantCF){
490 double cutDiscriminant;
493 throw std::runtime_error(
"AsgElectronSelectorTool: The desired eta/pt bin is outside of the range specified by the input. This should never happen! This indicates a mismatch between the binning in the configuration file and the tool implementation." );
503 if (mvaScore < cutDiscriminant){
535 const float eta = cluster->
etaBE(2);
563 ATH_MSG_VERBOSE(
"\t AsgElectronSelectorTool::calculateMultipleOutputs( &ctx, *eg, mu= "<<(&ctx)<<
", "<<
eg<<
", "<<
mu<<
" )");
565 throw std::runtime_error(
"AsgElectronSelectorTool: Failed, no electron object was passed" );
576 ATH_MSG_DEBUG(
"Failed, cluster is missing samplings EMB2 and EME2.");
581 const double energy = cluster->
e();
582 const float eta = cluster->
etaBE(2);
585 ATH_MSG_DEBUG(
"Failed, this is a forward electron! The AsgElectronSelectorTool is only suitable for central electrons!");
602 double SCTWeightedCharge(0.0);
604 uint8_t nPixHitsPlusDeadSensors(0);
606 float trackqoverp(0.0);
609 double trans_TRTPID(0.0);
617 bool allFound =
true;
618 std::string notFoundList =
"";
621 trackqoverp =
track->qOverP();
623 qd0 = (
eg->charge())*
track->d0();
624 float vard0 =
track->definingParametersCovMatrix()(0, 0);
626 d0sigma = std::sqrt(vard0);
636 notFoundList +=
"eProbabilityHT ";
640 const double tau = 15.0;
641 const double fEpsilon = 1.0e-30;
642 double pid_tmp = TRT_PID;
644 pid_tmp = 1.0 - 1.0e-15;
645 else if (pid_tmp <= fEpsilon)
647 trans_TRTPID = -
std::log(1.0 / pid_tmp - 1.0) * (1. / tau);
654 trans_TRTPID = trans_TRT_PID_acc(*
eg);
658 if ((std::abs(trans_TRTPID) < 1.0
e-6) && (std::abs(
eta) > 2.01)){
668 dPOverP = 1 - trackqoverp / (refittedTrack_LMqoverp);
672 notFoundList +=
"deltaPoverP ";
682 for (
unsigned TPit = 0; TPit <
eg->nTrackParticles(); TPit++) {
684 if (
eg->trackParticle(TPit)) {
686 SCT += temp_NSCTHits;
687 charge += temp_NSCTHits*(
eg->trackParticle(TPit)->charge());
693 ATH_MSG_WARNING(
"No SCT hit for any track associated to electron ! nTP = " <<
eg->nTrackParticles());
700 notFoundList +=
"Reta ";
705 notFoundList +=
"Rphi ";
710 notFoundList +=
"Rhad1 ";
715 notFoundList +=
"Rhad ";
720 notFoundList +=
"weta2 ";
725 notFoundList +=
"f1 ";
730 notFoundList +=
"Eratio ";
735 notFoundList +=
"f3 ";
739 if (std::abs(
eta) > 2.01) {
746 notFoundList +=
"wtots1 ";
753 notFoundList +=
"deltaEta1 ";
758 notFoundList +=
"deltaPhiRescaled2 ";
762 ATH_MSG_VERBOSE(Form(
"Vars: eta=%8.5f, et=%8.5f, f3=%8.5f, rHad==%8.5f, rHad1=%8.5f, Reta=%8.5f, w2=%8.5f, f1=%8.5f, Emaxs1=%8.5f, deltaEta1=%8.5f, d0=%8.5f, qd0=%8.5f, d0significance=%8.5f, Rphi=%8.5f, dPOverP=%8.5f, deltaPhiRescaled2=%8.5f, TRT_PID=%8.5f, trans_TRTPID=%8.5f, mu=%8.5f, wtots1=%8.5f, EoverP=%8.5f, nPixHitsPlusDeadSensors=%2df, nSCTHitsPlusDeadSensors=%2df, SCTWeightedCharge=%8.5f",
768 TRT_PID, trans_TRTPID,
773 throw std::runtime_error(
"AsgElectronSelectorTool: Not all variables needed for MVA calculation are found. The following variables are missing: " + notFoundList );
790 vars.SCTWeightedCharge = SCTWeightedCharge;
797 vars.dPOverP = dPOverP;
799 vars.trans_TRTPID = trans_TRTPID;
802 vars.nPixHitsPlusDeadSensors = nPixHitsPlusDeadSensors;
808 std::vector<float> mvaOutputs;
809 mvaOutputs.reserve(mvaScores.rows());
810 for (
int i = 0;
i < mvaScores.rows();
i++) {
811 mvaOutputs.push_back(mvaScores(
i, 0));
828 return accept(Gaudi::Hive::currentContext(),
part);
832 ATH_MSG_VERBOSE(
"\t AsgElectronSelectorTool::accept( &ctx, *part= "<<(&ctx)<<
", "<<
part<<
" )");
838 ATH_MSG_DEBUG(
"AsgElectronSelectorTool::could not cast to const Electron");
852 ATH_MSG_VERBOSE(
"\t AsgElectronSelectorTool::calculate( &ctx, *part"<<(&ctx)<<
", "<<
part<<
" )");
858 ATH_MSG_DEBUG(
"AsgElectronSelectorTool::could not cast to const Electron");
866 ATH_MSG_VERBOSE(
"\t AsgElectronSelectorTool::accept( &ctx, *eg, mu= "<<(&ctx)<<
", "<<
eg<<
", "<<
mu<<
" )");
872 ATH_MSG_DEBUG(
"AsgElectronSelectorTool::could not cast to const Electron");
881 ATH_MSG_VERBOSE(
"\t AsgElectronSelectorTool::calculate( &ctx, *eg, mu= "<<(&ctx)<<
", "<<
eg<<
", "<<
mu<<
" )");
887 ATH_MSG_DEBUG(
"AsgElectronSelectorTool::could not cast to const Electron");
900 ATH_MSG_DEBUG(
"Failed, this is a forward electron! The AsgElectronSelectorTool is only suitable for central electrons!");
906 if (std::abs(
eta) > 2.5){
907 ATH_MSG_DEBUG(
"Failed, cluster->etaBE(2) range due to " <<
eta <<
" seems like a fwd electron" );
919 constexpr
double oneOverTau = 1. / 10;
920 constexpr
double fEpsilon = 1.0e-30;
946 disc = mvaScores.at(0) /
961 disc = mvaScores.at(0) / mvaScores.at(1);
971 const double etaBins[
nEtaBins] = {0.1, 0.6, 0.8, 1.15, 1.37, 1.52, 1.81, 2.01, 2.37, 2.47};
981 static const double GeV = 1000;
984 for (
unsigned int etBin = 0; etBin < nEtBins; ++etBin){
985 if (
et < etBins[etBin])
return etBin;
998 double cut =
cuts.at(ibin_combinedML);
999 const double GeV = 1000;
1002 if (
et >= eTBins[9])
return cut;
1003 if (
et <= eTBins[0])
return cut;
1011 double etLow = eTBins[
bin-1];
1012 double etUp = eTBins[
bin];
1016 double gradient = ( discUp - discLow ) / ( etUp - etLow );
1018 return discLow + (
et - etLow) * gradient;
std::size_t numberOfSCTHitsAndDeadSensors(const xAOD::TrackParticle &tp)
return the number of SCT hits plus dead sensors in the track particle
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
Extra patterns decribing particle interation process.
std::size_t numberOfSiliconHitsAndDeadSensors(const xAOD::TrackParticle &tp)
return the number of Silicon hits plus dead sensors in the track particle
constexpr unsigned nEtaBins
std::string find(const std::string &s)
return a remapped string
Helper class to provide type-safe access to aux data.
Scalar eta() const
pseudorapidity method
double d0significance(const xAOD::TrackParticle *tp, double d0_uncert_beam_spot_2)
Helper class to provide constant type-safe access to aux data.
const uint16_t AuthorFwdElectron
Electron reconstructed by the Forward cluster-based algorithm.
@ LastMeasurement
Parameter defined at the position of the last measurement.
#define ATH_MSG_VERBOSE(x)
Class providing the definition of the 4-vector interface.
bool passBLayerRequirement(const xAOD::TrackParticle &tp)
return true if effective number of BL hits + outliers is at least one
@ wtots1
shower width is determined in a window detaxdphi = 0,0625 ×~0,2, corresponding typically to 20 strips...
@ f3
fraction of energy reconstructed in 3rd sampling
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
Description of a calorimeter cluster.
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
@ f1
E1/E = fraction of energy reconstructed in the first sampling, where E1 is energy in all strips belon...
::StatusCode StatusCode
StatusCode definition for legacy code.
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
@ deltaPhiRescaled2
difference between the cluster phi (second sampling) and the phi of the track extrapolated to the sec...
std::vector< int > HelperInt(const std::string &input, TEnv &env)
double charge(const T &p)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
void setCutResult(const std::string &cutName, bool cutResult)
Set the result of a cut, based on the cut name (safer)
bool nSCTHitsPlusDeadSensors(const xAOD::TauJet &, const xAOD::TauTrack &track, double &out)
#define ATH_MSG_WARNING(x)
@ eProbabilityHT
Electron probability from High Threshold (HT) information [float].
@ numberOfSCTHits
number of hits in SCT [unit8_t].
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
const std::map< std::string, std::string > ElectronDNNPointToConfFile
@ Eratio
(emaxs1-e2tsts1)/(emaxs1+e2tsts1)
Class describing a TrackParticle.
@ deltaEta1
difference between the cluster eta (first sampling) and the eta of the track extrapolated to the firs...
bool hasSampling(const CaloSample s) const
Checks if certain smapling contributes to cluster.
std::vector< double > HelperDouble(const std::string &input, TEnv &env)
virtual double e() const
The total energy of the particle.
int addCut(const std::string &cutName, const std::string &cutDescription)
Add a cut; returning the cut position.
@ weta2
the lateral width is calculated with a window of 3x5 cells using the energy weighted sum over all cel...
std::string findConfigFile(const std::string &input, const std::map< std::string, std::string > &configmap)
std::size_t numberOfPixelHitsAndDeadSensors(const xAOD::TrackParticle &tp)
return the number of Pixel hits plus dead sensors in the track particle