 |
ATLAS Offline Software
|
Go to the documentation of this file.
25 #include <unordered_map>
98 declareProperty(
"WorkingPoint", m_workingPoint=
"",
"The Working Point");
99 declareProperty(
"ConfigFile", m_configFile=
"",
"The config file to use");
102 declareProperty(
"inputModelFileName", m_modelFileName=
"",
"The input file name that holds the model" );
104 declareProperty(
"quantileFileName", m_quantileFileName=
"",
"The input file name that holds the QuantileTransformer");
106 declareProperty(
"skipDeltaPoverP",m_skipDeltaPoverP =
false,
"If true, it will skip the check of deltaPoverP");
108 declareProperty(
"skipAmbiguityCut",m_skipAmbiguityCut =
false,
"If true, it will skip the ambiguity cut");
131 return StatusCode::FAILURE;
137 return StatusCode::FAILURE;
145 std::string modelFilename(
"");
146 std::string quantileFilename(
"");
156 modelFilename =
env.GetValue(
"inputModelFileName",
"ElectronPhotonSelectorTools/offline/mc16_20210204/ElectronDNNNetwork.json");
157 ATH_MSG_DEBUG(
"Getting the input Model from: " << modelFilename );
161 ATH_MSG_ERROR(
"Could not find model file " << modelFilename);
162 return StatusCode::FAILURE;
173 quantileFilename =
env.GetValue(
"inputQuantileFileName",
"ElectronPhotonSelectorTools/offline/mc16_20210204/ElectronDNNQuantileTransformer.root");
174 ATH_MSG_DEBUG(
"Getting the input QuantileTransformer from: " << quantileFilename);
177 if (qfilename.empty()){
178 ATH_MSG_ERROR(
"Could not find QuantileTransformer file " << quantileFilename);
179 return StatusCode::FAILURE;
183 std::stringstream vars(
env.GetValue(
"Variables",
""));
187 std::getline(vars, substr,
',');
190 ATH_MSG_ERROR(
"Unsupported variable " << substr <<
" found in the config.");
191 return StatusCode::FAILURE;
220 unsigned int numberOfExpectedBinCombinedMVA ;
225 ATH_MSG_ERROR(
"Configuration issue : cutSelector expected size " << numberOfExpectedBinCombinedMVA <<
227 return StatusCode::FAILURE;
233 ATH_MSG_ERROR(
"Configuration issue : cutSelectorCF expected size " << numberOfExpectedBinCombinedMVA <<
235 return StatusCode::FAILURE;
238 ATH_MSG_ERROR(
"Configuration issue : CF rejection is only defined "
239 "for multiClass: TRUE");
240 return StatusCode::FAILURE;
252 if (
m_fractions.size() != numberOfExpectedEtaBins * 5){
254 return StatusCode::FAILURE;
259 if (
m_cutSCT.size() != numberOfExpectedEtaBins){
260 ATH_MSG_ERROR(
"Configuration issue : cutSCT expected size " << numberOfExpectedEtaBins <<
262 return StatusCode::FAILURE;
267 if (
m_cutPi.size() != numberOfExpectedEtaBins){
268 ATH_MSG_ERROR(
"Configuration issue : cutPi expected size " << numberOfExpectedEtaBins <<
269 " input size " <<
m_cutPi.size());
270 return StatusCode::FAILURE;
275 if (
m_cutBL.size() != numberOfExpectedEtaBins){
276 ATH_MSG_ERROR(
"Configuration issue : cutBL expected size " << numberOfExpectedEtaBins <<
277 " input size " <<
m_cutBL.size());
278 return StatusCode::FAILURE;
284 ATH_MSG_ERROR(
"Configuration issue : cutAmbiguity expected size " << numberOfExpectedEtaBins <<
286 return StatusCode::FAILURE;
323 ATH_MSG_ERROR(
"ERROR: Something went wrong with the setup of the decision objects...");
324 return StatusCode::FAILURE;
338 return StatusCode::SUCCESS;
356 ATH_MSG_VERBOSE(
"\t AsgElectronSelectorTool::accept( &ctx, *eg, mu= "<<(&ctx)<<
", "<<
eg<<
", "<<
mu<<
" )");
362 throw std::runtime_error(
"AsgElectronSelectorTool: Failed, no electron object was passed");
367 ATH_MSG_DEBUG(
"exiting because cluster is NULL " << cluster);
372 ATH_MSG_DEBUG(
"Failed, cluster is missing samplings EMB2 and EME2");
376 const double energy = cluster->e();
377 const float eta = cluster->etaBE(2);
380 ATH_MSG_DEBUG(
"Failed, this is a forward electron! The AsgElectronSelectorTool is only suitable for central electrons!");
394 uint8_t nSiHitsPlusDeadSensors(0);
399 bool allFound =
true;
400 std::string notFoundList =
"";
406 ambiguityBit = ambiguityTypeAcc(*
eg);
410 notFoundList +=
"ambiguityType ";
422 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",
427 double mvaScoreCF = 0;
430 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",
438 throw std::runtime_error(
"AsgElectronSelectorTool: Not all variables needed for the decision are found. The following variables are missing: " + notFoundList );
443 bool passNSilicon(
true);
444 bool passNPixel(
true);
445 bool passNBlayer(
true);
449 if (std::abs(
eta) > 2.47){
450 ATH_MSG_DEBUG(
"This electron is fabs(eta)>2.47 Returning False.");
459 ATH_MSG_DEBUG(
"Cannot evaluate model for Et " <<
et <<
". Returning false..");
465 if (!passKine){
return acceptData;}
493 passNSilicon =
false;
502 double cutDiscriminantCF;
505 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." );
515 if (mvaScoreCF < cutDiscriminantCF){
523 double cutDiscriminant;
526 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." );
536 if (mvaScore < cutDiscriminant){
573 const float eta = cluster->etaBE(2);
584 ATH_MSG_VERBOSE(
"\t AsgElectronSelectorTool::calculateMultipleOutputs( &ctx, *eg, mu= "<<(&ctx)<<
", "<<
eg<<
", "<<
mu<<
" )");
586 throw std::runtime_error(
"AsgElectronSelectorTool: Failed, no electron object was passed" );
597 ATH_MSG_DEBUG(
"Failed, cluster is missing samplings EMB2 and EME2.");
602 const double energy = cluster->e();
603 const float eta = cluster->etaBE(2);
606 ATH_MSG_DEBUG(
"Failed, this is a forward electron! The AsgElectronSelectorTool is only suitable for central electrons!");
627 float trackqoverp(0.0);
638 bool allFound =
true;
639 std::string notFoundList =
"";
642 trackqoverp =
track->qOverP();
645 float vard0 =
track->definingParametersCovMatrix()(0, 0);
647 d0sigma = std::sqrt(vard0);
657 notFoundList +=
"eProbabilityHT ";
661 const double tau = 15.0;
662 const double fEpsilon = 1.0e-30;
663 double pid_tmp = TRT_PID;
665 pid_tmp = 1.0 - 1.0e-15;
666 else if (pid_tmp <= fEpsilon)
689 dPOverP = 1 - trackqoverp / (refittedTrack_LMqoverp);
693 notFoundList +=
"deltaPoverP ";
703 for (
unsigned TPit = 0; TPit <
eg->nTrackParticles(); TPit++) {
705 if (
eg->trackParticle(TPit)) {
707 SCT += temp_NSCTHits;
708 charge += temp_NSCTHits*(
eg->trackParticle(TPit)->charge());
714 ATH_MSG_WARNING(
"No SCT hit for any track associated to electron ! nTP = " <<
eg->nTrackParticles());
721 notFoundList +=
"Reta ";
726 notFoundList +=
"Rphi ";
731 notFoundList +=
"Rhad1 ";
736 notFoundList +=
"Rhad ";
741 notFoundList +=
"weta2 ";
746 notFoundList +=
"f1 ";
751 notFoundList +=
"Eratio ";
756 notFoundList +=
"f3 ";
760 if (std::abs(
eta) > 2.01) {
767 notFoundList +=
"wtots1 ";
774 notFoundList +=
"deltaEta1 ";
779 notFoundList +=
"deltaPhiRescaled2 ";
783 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",
794 throw std::runtime_error(
"AsgElectronSelectorTool: Not all variables needed for MVA calculation are found. The following variables are missing: " + notFoundList );
797 std::vector<double> variableValues;
803 variableValues.push_back(std::abs(
eta));
break;
805 variableValues.push_back(
et);
break;
807 variableValues.push_back(
f3);
break;
809 variableValues.push_back(
Rhad);
break;
811 variableValues.push_back(
Rhad1);
break;
813 variableValues.push_back(
Reta);
break;
815 variableValues.push_back(w2);
break;
817 variableValues.push_back(
f1);
break;
819 variableValues.push_back(
Eratio);
break;
821 variableValues.push_back(
deltaEta1);
break;
823 variableValues.push_back(
d0);
break;
825 variableValues.push_back(
qd0);
break;
829 variableValues.push_back(
Rphi);
break;
831 variableValues.push_back(
dPOverP);
break;
837 variableValues.push_back(
wtots1);
break;
839 variableValues.push_back(
EoverP);
break;
848 throw std::runtime_error(
"AsgElectronSelectorTool: unknown variable "
849 "index, something went wrong in initialization!" );
857 std::vector<float> mvaOutputs;
858 mvaOutputs.reserve(mvaScores.rows());
859 for (
int i = 0;
i < mvaScores.rows();
i++) {
860 mvaOutputs.push_back(mvaScores(
i, 0));
877 return accept(Gaudi::Hive::currentContext(),
part);
881 ATH_MSG_VERBOSE(
"\t AsgElectronSelectorTool::accept( &ctx, *part= "<<(&ctx)<<
", "<<
part<<
" )");
887 ATH_MSG_DEBUG(
"AsgElectronSelectorTool::could not cast to const Electron");
901 ATH_MSG_VERBOSE(
"\t AsgElectronSelectorTool::calculate( &ctx, *part"<<(&ctx)<<
", "<<
part<<
" )");
907 ATH_MSG_DEBUG(
"AsgElectronSelectorTool::could not cast to const Electron");
915 ATH_MSG_VERBOSE(
"\t AsgElectronSelectorTool::accept( &ctx, *eg, mu= "<<(&ctx)<<
", "<<
eg<<
", "<<
mu<<
" )");
921 ATH_MSG_DEBUG(
"AsgElectronSelectorTool::could not cast to const Electron");
930 ATH_MSG_VERBOSE(
"\t AsgElectronSelectorTool::calculate( &ctx, *eg, mu= "<<(&ctx)<<
", "<<
eg<<
", "<<
mu<<
" )");
936 ATH_MSG_DEBUG(
"AsgElectronSelectorTool::could not cast to const Electron");
949 ATH_MSG_DEBUG(
"Failed, this is a forward electron! The AsgElectronSelectorTool is only suitable for central electrons!");
955 if (std::abs(
eta) > 2.5){
956 ATH_MSG_DEBUG(
"Failed, cluster->etaBE(2) range due to " <<
eta <<
" seems like a fwd electron" );
968 constexpr
double oneOverTau = 1. / 10;
969 constexpr
double fEpsilon = 1.0e-30;
995 disc = mvaScores.at(0) /
1010 disc = mvaScores.at(0) / mvaScores.at(1);
1020 const double etaBins[
nEtaBins] = {0.1, 0.6, 0.8, 1.15, 1.37, 1.52, 1.81, 2.01, 2.37, 2.47};
1030 static const double GeV = 1000;
1033 for (
unsigned int etBin = 0; etBin < nEtBins; ++etBin){
1034 if (
et < etBins[etBin])
return etBin;
1047 double cut =
cuts.at(ibin_combinedML);
1048 const double GeV = 1000;
1051 if (
et >= eTBins[9])
return cut;
1052 if (
et <= eTBins[0])
return cut;
1060 double etLow = eTBins[
bin-1];
1061 double etUp = eTBins[
bin];
1065 double gradient = ( discUp - discLow ) / ( etUp - etLow );
1067 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
Helper class to provide type-safe access to aux data.
Scalar eta() const
pseudorapidity method
@ nSCTHitsPlusDeadSensors
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
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.
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
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)
#define ATH_MSG_WARNING(x)
@ nPixHitsPlusDeadSensors
@ eProbabilityHT
Electron probability from High Threshold (HT) information [float].
const std::unordered_map< std::string, int > variableMap
@ 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...
constexpr int pow(int base, int exp) noexcept
std::vector< double > HelperDouble(const std::string &input, TEnv &env)
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