21 enum PhotonBDTIsEMBits :
unsigned int {
23 FailOutOfRange = 1u << 0,
26 FailPreselectionF1 = 1u << 1,
27 FailPreselectionE277 = 1u << 2,
30 FailBDTScore = 1u << 3,
33 FailMissingScore = 1u << 4
65 return StatusCode::FAILURE;
70 return StatusCode::SUCCESS;
87 return StatusCode::FAILURE;
93 return StatusCode::FAILURE;
118 if (nEta == 0 || nEt == 0) {
119 ATH_MSG_ERROR(
"Need at least 2 edges for eta and Et binning.");
120 return StatusCode::FAILURE;
123 const unsigned nExpected = nEta * nEt;
125 ATH_MSG_ERROR(
"Size mismatch between eta and Et binning and BDT cut maps: expected " << nExpected
126 <<
" (= " << nEta <<
"*" << nEt <<
")"
127 <<
" got BDTCutConv=" <<
m_cutConv.size()
129 return StatusCode::FAILURE;
132 return StatusCode::SUCCESS;
156 return accept(Gaudi::Hive::currentContext(), part);
164 if (
const auto* ph =
dynamic_cast<const xAOD::Photon*
>(part)) {
167 if (
const auto* eg =
dynamic_cast<const xAOD::Egamma*
>(part)) {
201 unsigned int& isEM)
const
204 if (!eg)
return StatusCode::SUCCESS;
209 return StatusCode::SUCCESS;
213 return StatusCode::SUCCESS;
225 size_t& iEta,
size_t& iEt)
const {
242 const size_t nEta =
m_etaBins.size() - 1;
243 const size_t idx = iEt * nEta + iEta;
250 for (
unsigned i = 0; i < info.getNCuts(); ++i) acc.setCutResult(i,
false);
257 ATH_MSG_ERROR(
"AsgPhotonBDTSelector: missing shower shape variable '" << name);
259 throw std::runtime_error(std::string(
"AsgPhotonBDTSelector: missing shower shape ") + name);
269 auto setBit = [&](
unsigned int bit) {
270 if (isEM) *isEM |= bit;
280 bool hasScore = accScore.isAvailable(ph);
283 if (
m_bdtTool->decorate(ph).isSuccess()) {
284 hasScore = accScore.isAvailable(ph);
289 else if (!hasScore) {
301 const float score = accScore(ph);
310 const float absEta = std::abs(cluster->
eta());
311 const float etGeV = cluster->
pt() * 1e-3f;
313 size_t iEta=0, iEt=0;
314 if (!
findBin(absEta, etGeV, iEta, iEt)) {
325 bool passF1 =
false, passE277 =
false, passPre =
false;
332 if (!hasF1 || !hasE277) {
335 if (accIsEM.isAvailable(ph)) {
336 const int previousIsEM = accIsEM(ph);
337 passF1 = !(previousIsEM & FailPreselectionF1);
338 passE277 = !(previousIsEM & FailPreselectionE277);
339 passPre = passF1 && passE277;
342 ATH_MSG_ERROR(
"Missing f1 and e277 shower shapes and isEM decoration, cannot reapply WP. Rejecting photon.");
346 setBit(FailPreselectionF1);
347 setBit(FailPreselectionE277);
354 float f1 = 0.f, e277 = 0.f;
360 passF1 = (f1 > cutF1);
361 passE277 = (e277 > cutE277);
362 passPre = passF1 && passE277;
371 if (!passF1)
setBit(FailPreselectionF1);
372 if (!passE277)
setBit(FailPreselectionE277);
374 if (!passPre)
return acc;
377 const float cut =
getCut(conv, iEta, iEt);
378 const bool passBDT = (score > cut);
380 if (!passBDT)
setBit(FailBDTScore);
#define ATH_CHECK
Evaluate an expression and check for errors.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
static void setBit(unsigned char &field, unsigned num, bool val)
Gaudi::Property< std::string > m_workingPoint
float getShowerShape(const xAOD::Photon &ph, xAOD::EgammaParameters::ShowerShapeType t, const char *name="") const
std::vector< float > m_cutF1Unconv
std::vector< float > m_cutE277Conv
virtual std::string getOperatingPointName() const override
Report the current operating point.
Gaudi::Property< bool > m_reapplyWPIfNoShowerShapes
static asg::AcceptData makeReject(const asg::AcceptInfo &info)
bool isConverted(const xAOD::Photon &ph) const
std::vector< float > m_etaBins
std::vector< float > m_etBinsGeV
AsgPhotonBDTSelector(const std::string &name)
virtual const asg::AcceptInfo & getAcceptInfo() const override
Declare the interface ID for this pure-virtual interface class to the Athena framework.
std::vector< float > m_cutConv
ToolHandle< PhotonBDTCalculator > m_bdtTool
asg::AcceptData acceptBDT(const EventContext &ctx, const xAOD::Photon &ph, unsigned int *isEM=nullptr) const
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Gaudi::Property< std::string > m_scoreDecoration
Gaudi::Property< bool > m_excludeTRT
float getCut(const bool converted, const size_t iEta, const size_t iEt) const
int m_cutPosPassPreselection
std::vector< float > m_cutE277Unconv
virtual asg::AcceptData accept(const xAOD::IParticle *part) const override
accept with pointer to IParticle so as to not hide the IAsgSelectionTool one
Gaudi::Property< bool > m_computeIfMissing
virtual StatusCode execute(const EventContext &ctx, const xAOD::Egamma *eg, unsigned int &isEM) const override
Add a legacy execute method - return isEM value.
std::vector< float > m_cutF1Conv
asg::AcceptInfo m_acceptInfo
Gaudi::Property< std::string > m_isEMDecoration
bool findBin(const float absEta, const float etGeV, size_t &iEta, size_t &iEt) const
std::vector< float > m_cutUnconv
virtual double pt() const
The transverse momentum ( ) of the particle (negative for negative-energy clusters).
virtual double eta() const
The pseudorapidity ( ) of the particle.
bool showerShapeValue(float &value, const EgammaParameters::ShowerShapeType information) const
Accessor for ShowerShape values.
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
Class providing the definition of the 4-vector interface.
std::string findConfigFile(const std::string &input, const std::map< std::string, std::string > &configmap)
std::vector< float > HelperFloat(const std::string &input, TEnv &env)
const std::map< std::string, std::string > PhotonBDTPointToConfFile
bool isConvertedPhoton(const xAOD::Egamma *eg, bool excludeTRT=false)
is the object a converted photon
@ e277
uncalibrated energy (sum of cells) of the middle sampling in a rectangle of size 7x7
@ f1
E1/E = fraction of energy reconstructed in the first sampling, where E1 is energy in all strips belon...
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Egamma_v1 Egamma
Definition of the current "egamma version".
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".