20 enum PhotonBDTIsEMBits :
unsigned int {
22 FailOutOfRange = 1u << 0,
25 FailPreselectionF1 = 1u << 1,
26 FailPreselectionE277 = 1u << 2,
29 FailBDTScore = 1u << 3,
32 FailMissingScore = 1u << 4
64 return StatusCode::FAILURE;
69 return StatusCode::SUCCESS;
86 return StatusCode::FAILURE;
92 return StatusCode::FAILURE;
117 if (nEta == 0 || nEt == 0) {
118 ATH_MSG_ERROR(
"Need at least 2 edges for eta and Et binning.");
119 return StatusCode::FAILURE;
122 const unsigned nExpected = nEta * nEt;
124 ATH_MSG_ERROR(
"Size mismatch between eta and Et binning and BDT cut maps: expected " << nExpected
125 <<
" (= " << nEta <<
"*" << nEt <<
")"
126 <<
" got BDTCutConv=" <<
m_cutConv.size()
128 return StatusCode::FAILURE;
131 return StatusCode::SUCCESS;
155 return accept(Gaudi::Hive::currentContext(), part);
163 if (
const auto* ph =
dynamic_cast<const xAOD::Photon*
>(part)) {
166 if (
const auto* eg =
dynamic_cast<const xAOD::Egamma*
>(part)) {
200 unsigned int& isEM)
const
203 if (!eg)
return StatusCode::SUCCESS;
208 return StatusCode::SUCCESS;
212 return StatusCode::SUCCESS;
224 size_t& iEta,
size_t& iEt)
const {
241 const size_t nEta =
m_etaBins.size() - 1;
242 const size_t idx = iEt * nEta + iEta;
249 for (
unsigned i = 0; i < info.getNCuts(); ++i) acc.setCutResult(i,
false);
256 ATH_MSG_ERROR(
"AsgPhotonBDTSelector: missing shower shape variable '" << name);
258 throw std::runtime_error(std::string(
"AsgPhotonBDTSelector: missing shower shape ") + name);
268 auto setBit = [&](
unsigned int bit) {
269 if (isEM) *isEM |= bit;
279 bool hasScore = accScore.isAvailable(ph);
282 if (
m_bdtTool->decorate(ph).isSuccess()) {
283 hasScore = accScore.isAvailable(ph);
288 else if (!hasScore) {
300 const float score = accScore(ph);
304 const float absEta = std::abs(ph.
eta());
305 const float etGeV = ph.
pt() * 1e-3f;
307 size_t iEta=0, iEt=0;
308 if (!
findBin(absEta, etGeV, iEta, iEt)) {
319 bool passF1 =
false, passE277 =
false, passPre =
false;
326 if (!hasF1 || !hasE277) {
329 if (accIsEM.isAvailable(ph)) {
330 const int previousIsEM = accIsEM(ph);
331 passF1 = !(previousIsEM & FailPreselectionF1);
332 passE277 = !(previousIsEM & FailPreselectionE277);
333 passPre = passF1 && passE277;
336 ATH_MSG_ERROR(
"Missing f1 and e277 shower shapes and isEM decoration, cannot reapply WP. Rejecting photon.");
340 setBit(FailPreselectionF1);
341 setBit(FailPreselectionE277);
348 float f1 = 0.f, e277 = 0.f;
354 passF1 = (f1 > cutF1);
355 passE277 = (e277 > cutE277);
356 passPre = passF1 && passE277;
365 if (!passF1)
setBit(FailPreselectionF1);
366 if (!passE277)
setBit(FailPreselectionE277);
368 if (!passPre)
return acc;
371 const float cut =
getCut(conv, iEta, iEt);
372 const bool passBDT = (score > cut);
374 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
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
asg::AcceptData makeReject(const asg::AcceptInfo &info) const
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 override final
The transverse momentum ( ) of the particle.
bool showerShapeValue(float &value, const EgammaParameters::ShowerShapeType information) const
Accessor for ShowerShape values.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
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...
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".