diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h index 09b86500901ee33fd527edd92fead1d2ed82a602..b7279e7fbddc7f68e78cc824836f14573979fd82 100644 --- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h +++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // Dear emacs, this is -*-c++-*- @@ -7,35 +7,36 @@ #ifndef __ASGELECTRONLIKELIHOODTOOL__ #define __ASGELECTRONLIKELIHOODTOOL__ - // Atlas includes +#include "AsgDataHandles/ReadHandleKey.h" #include "AsgTools/AsgTool.h" #include "EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h" -#include "xAODEgamma/ElectronFwd.h" #include "PATCore/AcceptData.h" -#include "AsgDataHandles/ReadHandleKey.h" -#include "xAODTracking/VertexContainer.h" +#include "xAODEgamma/ElectronFwd.h" #include "xAODHIEvent/HIEventShapeContainer.h" +#include "xAODTracking/VertexContainer.h" class EventContext; -namespace Root{ - class TElectronLikelihoodTool; +namespace Root { +class TElectronLikelihoodTool; } - -class AsgElectronLikelihoodTool : public asg::AsgTool, - virtual public IAsgElectronLikelihoodTool +class AsgElectronLikelihoodTool + : public asg::AsgTool + , virtual public IAsgElectronLikelihoodTool { - ASG_TOOL_CLASS2(AsgElectronLikelihoodTool, IAsgElectronLikelihoodTool, IAsgSelectionTool) + ASG_TOOL_CLASS2(AsgElectronLikelihoodTool, + IAsgElectronLikelihoodTool, + IAsgSelectionTool) public: /** Standard constructor */ - AsgElectronLikelihoodTool( const std::string& myname); - + AsgElectronLikelihoodTool(const std::string& myname); /** Standard destructor */ virtual ~AsgElectronLikelihoodTool(); + public: /** Gaudi Service Interface method implementations */ virtual StatusCode initialize() override; @@ -43,84 +44,92 @@ public: // Main methods for IAsgSelectorTool interface /** Method to get the plain AcceptInfo. - This is needed so that one can already get the AcceptInfo - and query what cuts are defined before the first object + This is needed so that one can already get the AcceptInfo + and query what cuts are defined before the first object is passed to the tool. */ virtual const asg::AcceptInfo& getAcceptInfo() const override; /** The main accept method: using the generic interface */ - asg::AcceptData accept( const xAOD::IParticle* part ) const override; - asg::AcceptData accept( const EventContext& ctx, const xAOD::IParticle* part ) const override; + virtual asg::AcceptData accept( + const xAOD::IParticle* part) const override final; + + virtual asg::AcceptData accept( + const EventContext& ctx, + const xAOD::IParticle* part) const override final; /** The main accept method: the actual cuts are applied here */ - asg::AcceptData accept( const xAOD::Electron* eg ) const { - return accept (eg, -99); // mu = -99 as input will force accept to grab the pileup variable from the xAOD object - } - asg::AcceptData accept( const EventContext& ctx, const xAOD::Electron* eg ) const override { - return accept (ctx, eg, -99); // mu = -99 as input will force accept to grab the pileup variable from the xAOD object + virtual asg::AcceptData accept(const EventContext& ctx, + const xAOD::Electron* eg) const override final + { + return accept(ctx, eg, -99); // mu = -99 as input will force accept to grab + // the pileup variable from the xAOD object } /** The main accept method: the actual cuts are applied here */ - asg::AcceptData accept( const xAOD::Egamma* eg ) const { - return accept (eg, -99); // mu = -99 as input will force accept to grab the pileup variable from the xAOD object - } - asg::AcceptData accept(const EventContext& ctx, const xAOD::Egamma* eg ) const override { - return accept (ctx, eg, -99); // mu = -99 as input will force accept to grab the pileup variable from the xAOD object + virtual asg::AcceptData accept(const EventContext& ctx, + const xAOD::Egamma* eg) const override final + { + return accept(ctx, eg, -99); // mu = -99 as input will force accept to grab + // the pileup variable from the xAOD object } /** The main accept method: in case mu not in EventInfo online */ - asg::AcceptData accept( const xAOD::Electron* eg, double mu ) const; - asg::AcceptData accept( const EventContext& ctx, const xAOD::Electron* eg, double mu ) const override; + virtual asg::AcceptData accept(const EventContext& ctx, + const xAOD::Electron* eg, + double mu) const override final; /** The main accept method: in case mu not in EventInfo online */ - asg::AcceptData accept( const xAOD::Egamma* eg, double mu ) const; - asg::AcceptData accept( const EventContext& ctx, const xAOD::Egamma* eg, double mu ) const override; + virtual asg::AcceptData accept(const EventContext& ctx, + const xAOD::Egamma* eg, + double mu) const override final; // Main methods for IAsgCalculatorTool interface public: /** The main result method: the actual likelihood is calculated here */ - double calculate( const xAOD::IParticle* part ) const; - double calculate( const EventContext &ctx, const xAOD::IParticle* part ) const override; + double calculate(const xAOD::IParticle* part) const; + virtual double calculate(const EventContext& ctx, + const xAOD::IParticle* part) const override final; /** The main result method: the actual likelihood is calculated here */ - double calculate( const xAOD::Electron* eg ) const { - return calculate (eg, -99); // mu = -99 as input will force accept to grab the pileup variable from the xAOD object + virtual double calculate(const EventContext& ctx, + const xAOD::Electron* eg) const override final + { + return calculate( + ctx, eg, -99); // mu = -99 as input will force accept to grab the pileup + // variable from the xAOD object } - double calculate( const EventContext &ctx, const xAOD::Electron* eg ) const override { - return calculate (ctx, eg, -99); // mu = -99 as input will force accept to grab the pileup variable from the xAOD object - } - /** The main result method: the actual likelihood is calculated here */ - double calculate( const xAOD::Egamma* eg ) const { - return calculate (eg, -99); // mu = -99 as input will force accept to grab the pileup variable from the xAOD object - } - double calculate( const EventContext &ctx, const xAOD::Egamma* eg ) const override { - return calculate (ctx, eg, -99); // mu = -99 as input will force accept to grab the pileup variable from the xAOD object + virtual double calculate(const EventContext& ctx, + const xAOD::Egamma* eg) const override final + { + return calculate( + ctx, eg, -99); // mu = -99 as input will force accept to grab the pileup + // variable from the xAOD object } /** The main result method: the actual likelihood is calculated here */ - double calculate( const xAOD::Electron* eg, double mu ) const; - double calculate( const EventContext &ctx, const xAOD::Electron* eg, double mu ) const override; + virtual double calculate(const EventContext& ctx, + const xAOD::Electron* eg, + double mu) const override final; /** The main result method: the actual likelihood is calculated here */ - double calculate( const xAOD::Egamma* eg, double mu ) const; - double calculate( const EventContext &ctx, const xAOD::Egamma* eg, double mu ) const override; + virtual double calculate(const EventContext& ctx, + const xAOD::Egamma* eg, + double mu) const override final; - virtual std::string getOperatingPointName( ) const override; + /// Get the name of the current operating point + virtual std::string getOperatingPointName() const override final; // Private methods private: /// Get the number of primary vertices - unsigned int getNPrimVertices(const EventContext &ctx) const; + unsigned int getNPrimVertices(const EventContext& ctx) const; /// Get the FCal ET for centrality determination (for HI collisions) - double getFcalEt(const EventContext &ctx) const; - - /// Get the name of the current operating point + double getFcalEt(const EventContext& ctx) const; /// check for FwdElectron - bool isForwardElectron( const xAOD::Egamma* eg, const float eta ) const; - + bool isForwardElectron(const xAOD::Egamma* eg, const float eta) const; // Private member variables private: @@ -132,7 +141,7 @@ private: /** Pointer to the underlying ROOT based tool */ Root::TElectronLikelihoodTool* m_rootTool; - + /// Whether to use the PV (not available for trigger) bool m_usePVCont; @@ -155,21 +164,22 @@ private: bool m_skipDeltaPoverP; /// read handle key to heavy ion container - SG::ReadHandleKey<xAOD::HIEventShapeContainer> m_HIESContKey { - this, "CaloSumsContainer", "CaloSums", - "The CaloSums container name"}; - + SG::ReadHandleKey<xAOD::HIEventShapeContainer> m_HIESContKey{ + this, + "CaloSumsContainer", + "CaloSums", + "The CaloSums container name" + }; + /// read handle key to primary vertex container - SG::ReadHandleKey<xAOD::VertexContainer> m_primVtxContKey { - this, "primaryVertexContainer", "PrimaryVertices", - "The primary vertex container name"}; - + SG::ReadHandleKey<xAOD::VertexContainer> m_primVtxContKey{ + this, + "primaryVertexContainer", + "PrimaryVertices", + "The primary vertex container name" + }; }; // End: class definition - - - - #endif diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgElectronLikelihoodTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgElectronLikelihoodTool.cxx index 65bd255b1ba0c4a9c9446cf931a1433852aae18e..3e65087984a03d0c12fb54e26e8560d21df53814 100644 --- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgElectronLikelihoodTool.cxx +++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgElectronLikelihoodTool.cxx @@ -1,134 +1,199 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ /** @class AsgElectronLikelihoodTool - @brief Electron selector tool to select objects in Athena using an underlying pure ROOT tool. - - @author Karsten Koeneke + @brief Electron selector tool to select objects in Athena using an underlying + pure ROOT tool. + @author Karsten Koeneke , Jovan Mitrevski @date October 2012 @update April 2014, converted to ASGTool by Jovan Mitrevski - */ -// Include this class's header #include "ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h" -#include "ElectronPhotonSelectorTools/ElectronSelectorHelpers.h" #include "AsgElectronPhotonIsEMSelectorConfigHelper.h" -#include "TElectronLikelihoodTool.h" #include "EGSelectorConfigurationMapping.h" +#include "ElectronPhotonSelectorTools/ElectronSelectorHelpers.h" +#include "TElectronLikelihoodTool.h" // STL includes -#include <string> -#include <cstdint> #include <cmath> - -//EDM includes +#include <cstdint> +#include <string> +// EDM includes +#include "xAODCaloEvent/CaloCluster.h" #include "xAODEgamma/Electron.h" #include "xAODTracking/Vertex.h" -#include "xAODCaloEvent/CaloCluster.h" -#include "TEnv.h" - +// Framework includes #include "AsgDataHandles/ReadHandle.h" #include "AsgTools/CurrentContext.h" #include "PathResolver/PathResolver.h" +#include "TEnv.h" - -//============================================================================= // Standard constructor -//============================================================================= -AsgElectronLikelihoodTool::AsgElectronLikelihoodTool(const std::string& myname) : - AsgTool(myname), - m_configFile{""}, - m_rootTool{nullptr} +AsgElectronLikelihoodTool::AsgElectronLikelihoodTool(const std::string& myname) + : AsgTool(myname) + , m_configFile{ "" } + , m_rootTool{ nullptr } { // Create an instance of the underlying ROOT tool - m_rootTool = new Root::TElectronLikelihoodTool( ("T"+myname).c_str() ); + m_rootTool = new Root::TElectronLikelihoodTool(("T" + myname).c_str()); // Declare the needed properties - declareProperty("WorkingPoint",m_WorkingPoint="","The Working Point"); - declareProperty("ConfigFile",m_configFile="","The config file to use"); - declareProperty("usePVContainer", m_usePVCont=true, "Whether to use the PV container"); - declareProperty("nPVdefault", m_nPVdefault = 0, "The default number of PVs if not counted"); - declareProperty("useCaloSumsContainer", m_useCaloSumsCont=true, "Whether to use the CaloSums container"); - declareProperty("fcalEtDefault", m_fcalEtDefault = 0, "The default FCal sum ET"); - declareProperty("skipDeltaPoverP", m_skipDeltaPoverP=false, "If true, it wil skip the check of deltaPoverP" ); - - + declareProperty("WorkingPoint", m_WorkingPoint = "", "The Working Point"); + declareProperty("ConfigFile", m_configFile = "", "The config file to use"); + declareProperty( + "usePVContainer", m_usePVCont = true, "Whether to use the PV container"); + declareProperty( + "nPVdefault", m_nPVdefault = 0, "The default number of PVs if not counted"); + declareProperty("useCaloSumsContainer", + m_useCaloSumsCont = true, + "Whether to use the CaloSums container"); + declareProperty( + "fcalEtDefault", m_fcalEtDefault = 0, "The default FCal sum ET"); + declareProperty("skipDeltaPoverP", + m_skipDeltaPoverP = false, + "If true, it wil skip the check of deltaPoverP"); // // Configurables in the root tool // // pdf file name. Managed in the Asg tool. - declareProperty("inputPDFFileName", m_pdfFileName="", "The input ROOT file name that holds the PDFs" ); + declareProperty("inputPDFFileName", + m_pdfFileName = "", + "The input ROOT file name that holds the PDFs"); // the variable names, if non-standard - nope, it's done above! - declareProperty("VariableNames",m_rootTool->m_variableNames,"Variable names input to the LH"); + declareProperty("VariableNames", + m_rootTool->m_variableNames, + "Variable names input to the LH"); // The likelihood cut values - declareProperty("CutLikelihood",m_rootTool->m_cutLikelihood,"Cut on likelihood discriminant"); + declareProperty("CutLikelihood", + m_rootTool->m_cutLikelihood, + "Cut on likelihood discriminant"); // The pileup-correction part of the likelihood cut values - declareProperty("CutLikelihoodPileupCorrection",m_rootTool->m_cutLikelihoodPileupCorrection,"Pileup correction for LH discriminant"); + declareProperty("CutLikelihoodPileupCorrection", + m_rootTool->m_cutLikelihoodPileupCorrection, + "Pileup correction for LH discriminant"); // The likelihood cut values - 4 GeV - declareProperty("CutLikelihood4GeV",m_rootTool->m_cutLikelihood4GeV,"Cut on likelihood discriminant, 4 GeV special bin"); + declareProperty("CutLikelihood4GeV", + m_rootTool->m_cutLikelihood4GeV, + "Cut on likelihood discriminant, 4 GeV special bin"); // The pileup-correction part of the likelihood cut values - 4 GeV - declareProperty("CutLikelihoodPileupCorrection4GeV",m_rootTool->m_cutLikelihoodPileupCorrection4GeV,"Pileup correction for LH discriminant, 4 GeV special bin"); + declareProperty("CutLikelihoodPileupCorrection4GeV", + m_rootTool->m_cutLikelihoodPileupCorrection4GeV, + "Pileup correction for LH discriminant, 4 GeV special bin"); // do the ambiguity cut - declareProperty("CutAmbiguity" ,m_rootTool->m_cutAmbiguity ,"Apply a cut on the ambiguity bit"); + declareProperty("CutAmbiguity", + m_rootTool->m_cutAmbiguity, + "Apply a cut on the ambiguity bit"); // cut on b-layer - declareProperty("CutBL",m_rootTool->m_cutBL,"Cut on b-layer"); + declareProperty("CutBL", m_rootTool->m_cutBL, "Cut on b-layer"); // cut on pixel hits - declareProperty("CutPi",m_rootTool->m_cutPi,"Cut on pixel hits"); + declareProperty("CutPi", m_rootTool->m_cutPi, "Cut on pixel hits"); // cut on d0 - declareProperty("CutA0",m_rootTool->m_cutA0,"Cut on d0"); + declareProperty("CutA0", m_rootTool->m_cutA0, "Cut on d0"); // cut on deltaEta - declareProperty("CutDeltaEta",m_rootTool->m_cutDeltaEta,"Cut on deltaEta"); + declareProperty("CutDeltaEta", m_rootTool->m_cutDeltaEta, "Cut on deltaEta"); // cut on deltaPhiRes - declareProperty("CutDeltaPhiRes",m_rootTool->m_cutDeltaPhiRes,"Cut on deltaPhiRes"); + declareProperty( + "CutDeltaPhiRes", m_rootTool->m_cutDeltaPhiRes, "Cut on deltaPhiRes"); // cut on precision hits - declareProperty("CutSi",m_rootTool->m_cutSi,"Cut on precision hits"); + declareProperty("CutSi", m_rootTool->m_cutSi, "Cut on precision hits"); // turn off f3 at high Et - declareProperty("doRemoveF3AtHighEt",m_rootTool->m_doRemoveF3AtHighEt,"Turn off f3 at high Et"); + declareProperty("doRemoveF3AtHighEt", + m_rootTool->m_doRemoveF3AtHighEt, + "Turn off f3 at high Et"); // turn off TRTPID at high Et - declareProperty("doRemoveTRTPIDAtHighEt",m_rootTool->m_doRemoveTRTPIDAtHighEt,"Turn off TRTPID at high Et"); + declareProperty("doRemoveTRTPIDAtHighEt", + m_rootTool->m_doRemoveTRTPIDAtHighEt, + "Turn off TRTPID at high Et"); // use smooth interpolation between LH bins - declareProperty("doSmoothBinInterpolation",m_rootTool->m_doSmoothBinInterpolation,"use smooth interpolation between LH bins"); + declareProperty("doSmoothBinInterpolation", + m_rootTool->m_doSmoothBinInterpolation, + "use smooth interpolation between LH bins"); // use one extra bin for high ET LH - declareProperty("useOneExtraHighETLHBin",m_rootTool->m_useOneExtraHighETLHBin,"Use one extra bin for high ET LH"); + declareProperty("useOneExtraHighETLHBin", + m_rootTool->m_useOneExtraHighETLHBin, + "Use one extra bin for high ET LH"); // cut on Wstot above HighETBinThreshold - declareProperty("CutWstotAtHighET",m_rootTool->m_cutWstotAtHighET,"Cut on Wstot above HighETBinThreshold"); + declareProperty("CutWstotAtHighET", + m_rootTool->m_cutWstotAtHighET, + "Cut on Wstot above HighETBinThreshold"); // cut on EoverP above HighETBinThreshold - declareProperty("CutEoverPAtHighET",m_rootTool->m_cutEoverPAtHighET,"Cut on EoverP above HighETBinThreshold"); + declareProperty("CutEoverPAtHighET", + m_rootTool->m_cutEoverPAtHighET, + "Cut on EoverP above HighETBinThreshold"); // ET threshold for using high ET cuts and bin - declareProperty("HighETBinThreshold",m_rootTool->m_highETBinThreshold,"ET threshold for using high ET cuts and bin"); + declareProperty("HighETBinThreshold", + m_rootTool->m_highETBinThreshold, + "ET threshold for using high ET cuts and bin"); // do pileup-dependent transform on discriminant value - declareProperty("doPileupTransform",m_rootTool->m_doPileupTransform,"Do pileup-dependent transform on discriminant value"); + declareProperty("doPileupTransform", + m_rootTool->m_doPileupTransform, + "Do pileup-dependent transform on discriminant value"); // do centrality-dependent transform on discriminant value - declareProperty("doCentralityTransform",m_rootTool->m_doCentralityTransform,"Do centrality-dependent transform on discriminant value"); + declareProperty("doCentralityTransform", + m_rootTool->m_doCentralityTransform, + "Do centrality-dependent transform on discriminant value"); // reference disc for very hard cut; used by pileup transform - declareProperty("DiscHardCutForPileupTransform",m_rootTool->m_discHardCutForPileupTransform,"Reference disc for very hard cut; used by pileup transform"); + declareProperty("DiscHardCutForPileupTransform", + m_rootTool->m_discHardCutForPileupTransform, + "Reference disc for very hard cut; used by pileup transform"); // reference slope on disc for very hard cut; used by pileup transform - declareProperty("DiscHardCutSlopeForPileupTransform",m_rootTool->m_discHardCutSlopeForPileupTransform,"Reference slope on disc for very hard cut; used by pileup transform"); - // reference quadratic par on disc for very hard cut; used by centrality transform - declareProperty("DiscHardCutQuadForPileupTransform",m_rootTool->m_discHardCutQuadForPileupTransform,"Reference quadratic par on disc for very hard cut; used by centrality transform"); - // reference disc for a pileup independent loose menu; used by pileup transform - declareProperty("DiscLooseForPileupTransform",m_rootTool->m_discLooseForPileupTransform,"Reference disc for pileup indepdendent loose menu; used by pileup transform"); + declareProperty( + "DiscHardCutSlopeForPileupTransform", + m_rootTool->m_discHardCutSlopeForPileupTransform, + "Reference slope on disc for very hard cut; used by pileup transform"); + // reference quadratic par on disc for very hard cut; used by centrality + // transform + declareProperty("DiscHardCutQuadForPileupTransform", + m_rootTool->m_discHardCutQuadForPileupTransform, + "Reference quadratic par on disc for very hard cut; used by " + "centrality transform"); + // reference disc for a pileup independent loose menu; used by pileup + // transform + declareProperty("DiscLooseForPileupTransform", + m_rootTool->m_discLooseForPileupTransform, + "Reference disc for pileup indepdendent loose menu; used by " + "pileup transform"); // reference disc for very hard cut; used by pileup transform - 4-7 GeV bin - declareProperty("DiscHardCutForPileupTransform4GeV",m_rootTool->m_discHardCutForPileupTransform4GeV,"Reference disc for very hard cut; used by pileup transform. 4-7 GeV bin"); - // reference slope on disc for very hard cut; used by pileup transform - 4-7 GeV bin - declareProperty("DiscHardCutSlopeForPileupTransform4GeV",m_rootTool->m_discHardCutSlopeForPileupTransform4GeV,"Reference slope on disc for very hard cut; used by pileup transform. 4-7 GeV bin"); - // reference quadratic par on disc for very hard cut; used by centrality transform in 4-7 GeV bin - declareProperty("DiscHardCutQuadForPileupTransform4GeV",m_rootTool->m_discHardCutQuadForPileupTransform4GeV,"Reference quadratic par on disc for very hard cut; used by centrality transform in 4-7 GeV bin"); - // reference disc for a pileup independent loose menu; used by pileup transform - 4-7 GeV bin - declareProperty("DiscLooseForPileupTransform4GeV",m_rootTool->m_discLooseForPileupTransform4GeV,"Reference disc for pileup indepdendent loose menu; used by pileup transform. 4-7 GeV bin"); + declareProperty( + "DiscHardCutForPileupTransform4GeV", + m_rootTool->m_discHardCutForPileupTransform4GeV, + "Reference disc for very hard cut; used by pileup transform. 4-7 GeV bin"); + // reference slope on disc for very hard cut; used by pileup transform - 4-7 + // GeV bin + declareProperty("DiscHardCutSlopeForPileupTransform4GeV", + m_rootTool->m_discHardCutSlopeForPileupTransform4GeV, + "Reference slope on disc for very hard cut; used by pileup " + "transform. 4-7 GeV bin"); + // reference quadratic par on disc for very hard cut; used by centrality + // transform in 4-7 GeV bin + declareProperty("DiscHardCutQuadForPileupTransform4GeV", + m_rootTool->m_discHardCutQuadForPileupTransform4GeV, + "Reference quadratic par on disc for very hard cut; used by " + "centrality transform in 4-7 GeV bin"); + // reference disc for a pileup independent loose menu; used by pileup + // transform - 4-7 GeV bin + declareProperty("DiscLooseForPileupTransform4GeV", + m_rootTool->m_discLooseForPileupTransform4GeV, + "Reference disc for pileup indepdendent loose menu; used by " + "pileup transform. 4-7 GeV bin"); // max discriminant for which pileup transform is to be used - declareProperty("DiscMaxForPileupTransform",m_rootTool->m_discMaxForPileupTransform,"Max discriminant for which pileup transform is to be used"); + declareProperty("DiscMaxForPileupTransform", + m_rootTool->m_discMaxForPileupTransform, + "Max discriminant for which pileup transform is to be used"); // max nvtx or mu to be used in pileup transform - declareProperty("PileupMaxForPileupTransform",m_rootTool->m_pileupMaxForPileupTransform,"Max nvtx or mu to be used in pileup transform"); + declareProperty("PileupMaxForPileupTransform", + m_rootTool->m_pileupMaxForPileupTransform, + "Max nvtx or mu to be used in pileup transform"); // Flag to tell the tool if it is a calo-only LH - declareProperty("caloOnly", m_caloOnly=false, "Flag to tell the tool if it is a calo-only LH"); + declareProperty("caloOnly", + m_caloOnly = false, + "Flag to tell the tool if it is a calo-only LH"); } - //============================================================================= // Standard destructor //============================================================================= @@ -137,67 +202,78 @@ AsgElectronLikelihoodTool::~AsgElectronLikelihoodTool() delete m_rootTool; } - //============================================================================= // Asgena initialize method //============================================================================= -StatusCode AsgElectronLikelihoodTool::initialize() +StatusCode +AsgElectronLikelihoodTool::initialize() { - ATH_MSG_INFO("initialize : WP " << m_WorkingPoint.size() << " " << m_configFile.size()); + ATH_MSG_INFO("initialize : WP " << m_WorkingPoint.size() << " " + << m_configFile.size()); - std::string PDFfilename(""); //Default + std::string PDFfilename(""); // Default - if(!m_WorkingPoint.empty()){ - m_configFile=AsgConfigHelper::findConfigFile(m_WorkingPoint,EgammaSelectors::LHPointToConfFile); + if (!m_WorkingPoint.empty()) { + m_configFile = AsgConfigHelper::findConfigFile( + m_WorkingPoint, EgammaSelectors::LHPointToConfFile); ATH_MSG_INFO("operating point : " << this->getOperatingPointName()); } - if(!m_configFile.empty()){ - std::string configFile = PathResolverFindCalibFile( m_configFile); - if(configFile.empty()){ - ATH_MSG_ERROR("Could not locate " << m_configFile ); + if (!m_configFile.empty()) { + std::string configFile = PathResolverFindCalibFile(m_configFile); + if (configFile.empty()) { + ATH_MSG_ERROR("Could not locate " << m_configFile); return StatusCode::FAILURE; } - ATH_MSG_DEBUG("Configfile to use " << m_configFile ); + ATH_MSG_DEBUG("Configfile to use " << m_configFile); TEnv env(configFile.c_str()); // Get the input PDFs in the tool. ATH_MSG_DEBUG("Get the input PDFs in the tool "); - if(!m_pdfFileName.empty()) - { //If the property was set by the user, take that. - ATH_MSG_INFO("Setting user specified PDF file " << m_pdfFileName); - PDFfilename = m_pdfFileName; - } else { + if (!m_pdfFileName + .empty()) { // If the property was set by the user, take that. + ATH_MSG_INFO("Setting user specified PDF file " << m_pdfFileName); + PDFfilename = m_pdfFileName; + } else { if (m_configFile.find("dev/") != std::string::npos) { - std::string PDFdevval = env.GetValue("inputPDFFileName", "ElectronPhotonSelectorTools/v1/ElectronLikelihoodPdfs.root"); - PDFfilename = ("dev/"+PDFdevval); - ATH_MSG_DEBUG ( "Getting the input PDFs from: " << PDFfilename ); + std::string PDFdevval = env.GetValue( + "inputPDFFileName", + "ElectronPhotonSelectorTools/v1/ElectronLikelihoodPdfs.root"); + PDFfilename = ("dev/" + PDFdevval); + ATH_MSG_DEBUG("Getting the input PDFs from: " << PDFfilename); } else { - PDFfilename = env.GetValue("inputPDFFileName", "ElectronPhotonSelectorTools/v1/ElectronLikelihoodPdfs.root"); - ATH_MSG_DEBUG ( "Getting the input PDFs from: " << PDFfilename ); + PDFfilename = env.GetValue( + "inputPDFFileName", + "ElectronPhotonSelectorTools/v1/ElectronLikelihoodPdfs.root"); + ATH_MSG_DEBUG("Getting the input PDFs from: " << PDFfilename); } } - std::string filename = PathResolverFindCalibFile( PDFfilename ); - if (!filename.empty()){ - m_rootTool->setPDFFileName( filename.c_str() ); - }else{ - ATH_MSG_ERROR ("Could not find PDF file"); + std::string filename = PathResolverFindCalibFile(PDFfilename); + if (!filename.empty()) { + m_rootTool->setPDFFileName(filename.c_str()); + } else { + ATH_MSG_ERROR("Could not find PDF file"); return StatusCode::FAILURE; } - m_rootTool->m_variableNames = env.GetValue("VariableNames",""); - m_rootTool->m_cutLikelihood = AsgConfigHelper::HelperDouble("CutLikelihood",env); - m_rootTool->m_cutLikelihoodPileupCorrection = AsgConfigHelper::HelperDouble("CutLikelihoodPileupCorrection", env); - m_rootTool->m_cutLikelihood4GeV = AsgConfigHelper::HelperDouble("CutLikelihood4GeV",env); - m_rootTool->m_cutLikelihoodPileupCorrection4GeV = AsgConfigHelper::HelperDouble("CutLikelihoodPileupCorrection4GeV", env); + m_rootTool->m_variableNames = env.GetValue("VariableNames", ""); + m_rootTool->m_cutLikelihood = + AsgConfigHelper::HelperDouble("CutLikelihood", env); + m_rootTool->m_cutLikelihoodPileupCorrection = + AsgConfigHelper::HelperDouble("CutLikelihoodPileupCorrection", env); + m_rootTool->m_cutLikelihood4GeV = + AsgConfigHelper::HelperDouble("CutLikelihood4GeV", env); + m_rootTool->m_cutLikelihoodPileupCorrection4GeV = + AsgConfigHelper::HelperDouble("CutLikelihoodPileupCorrection4GeV", env); // do the ambiguity cut - m_rootTool->m_cutAmbiguity = AsgConfigHelper::HelperInt("CutAmbiguity", env); + m_rootTool->m_cutAmbiguity = + AsgConfigHelper::HelperInt("CutAmbiguity", env); // cut on b-layer - m_rootTool->m_cutBL = AsgConfigHelper::HelperInt("CutBL",env); + m_rootTool->m_cutBL = AsgConfigHelper::HelperInt("CutBL", env); // cut on pixel hits m_rootTool->m_cutPi = AsgConfigHelper::HelperInt("CutPi", env); // cut on precision hits @@ -205,121 +281,144 @@ StatusCode AsgElectronLikelihoodTool::initialize() // cut on d0 m_rootTool->m_cutA0 = AsgConfigHelper::HelperDouble("CutA0", env); // cut on deltaEta - m_rootTool->m_cutDeltaEta = AsgConfigHelper::HelperDouble("CutDeltaEta", env); + m_rootTool->m_cutDeltaEta = + AsgConfigHelper::HelperDouble("CutDeltaEta", env); // cut on deltaPhiRes - m_rootTool->m_cutDeltaPhiRes = AsgConfigHelper::HelperDouble("CutDeltaPhiRes", env); + m_rootTool->m_cutDeltaPhiRes = + AsgConfigHelper::HelperDouble("CutDeltaPhiRes", env); // turn off f3 at high Et - m_rootTool->m_doRemoveF3AtHighEt = env.GetValue("doRemoveF3AtHighEt", false); + m_rootTool->m_doRemoveF3AtHighEt = + env.GetValue("doRemoveF3AtHighEt", false); // turn off TRTPID at high Et - m_rootTool->m_doRemoveTRTPIDAtHighEt = env.GetValue("doRemoveTRTPIDAtHighEt", false); + m_rootTool->m_doRemoveTRTPIDAtHighEt = + env.GetValue("doRemoveTRTPIDAtHighEt", false); // do smooth interpolation between bins - m_rootTool->m_doSmoothBinInterpolation = env.GetValue("doSmoothBinInterpolation", false); + m_rootTool->m_doSmoothBinInterpolation = + env.GetValue("doSmoothBinInterpolation", false); m_caloOnly = env.GetValue("caloOnly", false); - m_rootTool->m_useOneExtraHighETLHBin = env.GetValue("useOneExtraHighETLHBin", false); + m_rootTool->m_useOneExtraHighETLHBin = + env.GetValue("useOneExtraHighETLHBin", false); // cut on Wstot above HighETBinThreshold - m_rootTool->m_cutWstotAtHighET = AsgConfigHelper::HelperDouble("CutWstotAtHighET", env); + m_rootTool->m_cutWstotAtHighET = + AsgConfigHelper::HelperDouble("CutWstotAtHighET", env); // cut on EoverP above HighETBinThreshold - m_rootTool->m_cutEoverPAtHighET = AsgConfigHelper::HelperDouble("CutEoverPAtHighET", env); + m_rootTool->m_cutEoverPAtHighET = + AsgConfigHelper::HelperDouble("CutEoverPAtHighET", env); m_rootTool->m_highETBinThreshold = env.GetValue("HighETBinThreshold", 125); m_rootTool->m_doPileupTransform = env.GetValue("doPileupTransform", false); - m_rootTool->m_doCentralityTransform = env.GetValue("doCentralityTransform", false); - m_rootTool->m_discHardCutForPileupTransform = AsgConfigHelper::HelperDouble("DiscHardCutForPileupTransform",env); - m_rootTool->m_discHardCutSlopeForPileupTransform = AsgConfigHelper::HelperDouble("DiscHardCutSlopeForPileupTransform",env); - m_rootTool->m_discHardCutQuadForPileupTransform = AsgConfigHelper::HelperDouble("DiscHardCutQuadForPileupTransform",env); - m_rootTool->m_discLooseForPileupTransform = AsgConfigHelper::HelperDouble("DiscLooseForPileupTransform",env); - m_rootTool->m_discHardCutForPileupTransform4GeV = AsgConfigHelper::HelperDouble("DiscHardCutForPileupTransform4GeV",env); - m_rootTool->m_discHardCutSlopeForPileupTransform4GeV = AsgConfigHelper::HelperDouble("DiscHardCutSlopeForPileupTransform4GeV",env); - m_rootTool->m_discHardCutQuadForPileupTransform4GeV = AsgConfigHelper::HelperDouble("DiscHardCutQuadForPileupTransform4GeV",env); - m_rootTool->m_discLooseForPileupTransform4GeV = AsgConfigHelper::HelperDouble("DiscLooseForPileupTransform4GeV",env); - m_rootTool->m_discMaxForPileupTransform = env.GetValue("DiscMaxForPileupTransform", 2.0); - m_rootTool->m_pileupMaxForPileupTransform = env.GetValue("PileupMaxForPileupTransform", 50); - - } else{ //Error if it cant find the conf - ATH_MSG_ERROR("Could not find configuration file"); - return StatusCode::FAILURE; + m_rootTool->m_doCentralityTransform = + env.GetValue("doCentralityTransform", false); + m_rootTool->m_discHardCutForPileupTransform = + AsgConfigHelper::HelperDouble("DiscHardCutForPileupTransform", env); + m_rootTool->m_discHardCutSlopeForPileupTransform = + AsgConfigHelper::HelperDouble("DiscHardCutSlopeForPileupTransform", env); + m_rootTool->m_discHardCutQuadForPileupTransform = + AsgConfigHelper::HelperDouble("DiscHardCutQuadForPileupTransform", env); + m_rootTool->m_discLooseForPileupTransform = + AsgConfigHelper::HelperDouble("DiscLooseForPileupTransform", env); + m_rootTool->m_discHardCutForPileupTransform4GeV = + AsgConfigHelper::HelperDouble("DiscHardCutForPileupTransform4GeV", env); + m_rootTool->m_discHardCutSlopeForPileupTransform4GeV = + AsgConfigHelper::HelperDouble("DiscHardCutSlopeForPileupTransform4GeV", + env); + m_rootTool->m_discHardCutQuadForPileupTransform4GeV = + AsgConfigHelper::HelperDouble("DiscHardCutQuadForPileupTransform4GeV", + env); + m_rootTool->m_discLooseForPileupTransform4GeV = + AsgConfigHelper::HelperDouble("DiscLooseForPileupTransform4GeV", env); + m_rootTool->m_discMaxForPileupTransform = + env.GetValue("DiscMaxForPileupTransform", 2.0); + m_rootTool->m_pileupMaxForPileupTransform = + env.GetValue("PileupMaxForPileupTransform", 50); + + } else { // Error if it cant find the conf + ATH_MSG_ERROR("Could not find configuration file"); + return StatusCode::FAILURE; } ///-----------End of text config---------------------------- // Setup primary vertex key handle - ATH_CHECK( m_primVtxContKey.initialize(m_usePVCont) ); + ATH_CHECK(m_primVtxContKey.initialize(m_usePVCont)); // Setup HI container key handle (must come after init from env) bool doCentralityTransform = m_rootTool->m_doCentralityTransform; - ATH_CHECK(m_HIESContKey.initialize(doCentralityTransform&&m_useCaloSumsCont)); - + ATH_CHECK( + m_HIESContKey.initialize(doCentralityTransform && m_useCaloSumsCont)); - // Get the name of the current operating point, and massage the other strings accordingly - ATH_MSG_VERBOSE( "Going to massage the labels based on the provided operating point..." ); - // Get the message level and set the underlying ROOT tool message level accordingly + // Get the name of the current operating point, and massage the other strings + // accordingly + ATH_MSG_VERBOSE( + "Going to massage the labels based on the provided operating point..."); + // Get the message level and set the underlying ROOT tool message level + // accordingly m_rootTool->msg().setLevel(this->msg().level()); // We need to initialize the underlying ROOT TSelectorTool - if ( m_rootTool->initialize().isFailure() ){ - ATH_MSG_ERROR ( "ERROR! Could not initialize the TElectronLikelihoodTool!" ); + if (m_rootTool->initialize().isFailure()) { + ATH_MSG_ERROR("ERROR! Could not initialize the TElectronLikelihoodTool!"); return StatusCode::FAILURE; } - return StatusCode::SUCCESS ; + return StatusCode::SUCCESS; } -//============================================================================= // return the accept info object -//============================================================================= - -const asg::AcceptInfo& AsgElectronLikelihoodTool::getAcceptInfo() const +const asg::AcceptInfo& +AsgElectronLikelihoodTool::getAcceptInfo() const { - return m_rootTool->getAcceptInfo(); + return m_rootTool->getAcceptInfo(); } -//============================================================================= // The main accept method: the actual cuts are applied here -//============================================================================= -asg::AcceptData AsgElectronLikelihoodTool::accept(const xAOD::Electron* el, double mu ) const +asg::AcceptData +AsgElectronLikelihoodTool::accept(const EventContext& ctx, + const xAOD::Electron* el, + double mu) const { - //Backwards compatibility - return accept(Gaudi::Hive::currentContext(), el, mu ); -} -asg::AcceptData AsgElectronLikelihoodTool::accept(const EventContext& ctx, const xAOD::Electron* el, double mu ) const -{ - if ( !el ){ - ATH_MSG_ERROR ("Failed, no electron object."); + if (!el) { + ATH_MSG_ERROR("Failed, no electron object."); return m_rootTool->accept(); } - const xAOD::CaloCluster* cluster = el->caloCluster(); - if ( !cluster ){ + const xAOD::CaloCluster* cluster = el->caloCluster(); + if (!cluster) { ATH_MSG_ERROR("exiting because cluster is NULL " << cluster); return m_rootTool->accept(); } - if( !cluster->hasSampling(CaloSampling::CaloSample::EMB2) && !cluster->hasSampling(CaloSampling::CaloSample::EME2) ){ + if (!cluster->hasSampling(CaloSampling::CaloSample::EMB2) && + !cluster->hasSampling(CaloSampling::CaloSample::EME2)) { ATH_MSG_ERROR("Failed, cluster is missing samplings EMB2 and EME2"); return m_rootTool->accept(); } const double energy = cluster->e(); - const float eta = (cluster->etaBE(2)); + const float eta = (cluster->etaBE(2)); - if( isForwardElectron(el,eta) ){ - ATH_MSG_WARNING("Failed, this is a forward electron! The AsgElectronLikelihoodTool is only suitable for central electrons!"); + if (isForwardElectron(el, eta)) { + ATH_MSG_WARNING( + "Failed, this is a forward electron! The AsgElectronLikelihoodTool is " + "only suitable for central electrons!"); return m_rootTool->accept(); } double et = 0.; - if(el->trackParticle() && !m_caloOnly) { - et = ( cosh(el->trackParticle()->eta()) != 0.) ? energy/cosh(el->trackParticle()->eta()) : 0.; + if (el->trackParticle() && !m_caloOnly) { + et = (cosh(el->trackParticle()->eta()) != 0.) + ? energy / cosh(el->trackParticle()->eta()) + : 0.; } else - et = ( cosh(eta) != 0.) ? energy/cosh(eta) : 0.; + et = (cosh(eta) != 0.) ? energy / cosh(eta) : 0.; // number of track hits uint8_t nSiHitsPlusDeadSensors(0); uint8_t nPixHitsPlusDeadSensors(0); bool passBLayerRequirement(false); float d0(0.0); - float deltaEta=0; - float deltaPhiRescaled2=0; - float wstot=0; - float EoverP=0; + float deltaEta = 0; + float deltaPhiRescaled2 = 0; + float wstot = 0; + float EoverP = 0; uint8_t ambiguityBit(0); double ip(0); @@ -327,14 +426,14 @@ asg::AcceptData AsgElectronLikelihoodTool::accept(const EventContext& ctx, const std::string notFoundList = ""; // Wstot for use when CutWstotAtHighET vector is filled - if( !el->showerShapeValue(wstot, xAOD::EgammaParameters::wtots1) ){ + if (!el->showerShapeValue(wstot, xAOD::EgammaParameters::wtots1)) { allFound = false; notFoundList += "wtots1 "; } // get the ambiguity type from the decoration - if ( !m_rootTool->m_cutAmbiguity.empty() ) { - if ( el->isAvailable<uint8_t>("ambiguityType") ) { + if (!m_rootTool->m_cutAmbiguity.empty()) { + if (el->isAvailable<uint8_t>("ambiguityType")) { static const SG::AuxElement::Accessor<uint8_t> acc("ambiguityType"); ambiguityBit = acc(*el); } else { @@ -343,39 +442,44 @@ asg::AcceptData AsgElectronLikelihoodTool::accept(const EventContext& ctx, const } } - if(!m_caloOnly) { - // retrieve associated track - const xAOD::TrackParticle* t = el->trackParticle(); - if (t) { - nSiHitsPlusDeadSensors = ElectronSelectorHelpers::numberOfSiliconHitsAndDeadSensors(t); - nPixHitsPlusDeadSensors = ElectronSelectorHelpers::numberOfPixelHitsAndDeadSensors(t); - passBLayerRequirement = ElectronSelectorHelpers::passBLayerRequirement(t); - d0 = t->d0(); - EoverP = fabs(t->qOverP()) * energy; - } - else { - ATH_MSG_ERROR( "Failed, no track particle. et= " << et << "eta= " << eta ); - return m_rootTool->accept(); - } + if (!m_caloOnly) { + // retrieve associated track + const xAOD::TrackParticle* t = el->trackParticle(); + if (t) { + nSiHitsPlusDeadSensors = + ElectronSelectorHelpers::numberOfSiliconHitsAndDeadSensors(t); + nPixHitsPlusDeadSensors = + ElectronSelectorHelpers::numberOfPixelHitsAndDeadSensors(t); + passBLayerRequirement = ElectronSelectorHelpers::passBLayerRequirement(t); + d0 = t->d0(); + EoverP = fabs(t->qOverP()) * energy; + } else { + ATH_MSG_ERROR("Failed, no track particle. et= " << et << "eta= " << eta); + return m_rootTool->accept(); + } - if( !el->trackCaloMatchValue(deltaEta, xAOD::EgammaParameters::deltaEta1) ){ - allFound = false; - notFoundList += "deltaEta1 "; - } - if( !el->trackCaloMatchValue(deltaPhiRescaled2, xAOD::EgammaParameters::deltaPhiRescaled2) ){ - allFound = false; - notFoundList += "deltaPhiRescaled2 "; - } + if (!el->trackCaloMatchValue(deltaEta, xAOD::EgammaParameters::deltaEta1)) { + allFound = false; + notFoundList += "deltaEta1 "; + } + if (!el->trackCaloMatchValue(deltaPhiRescaled2, + xAOD::EgammaParameters::deltaPhiRescaled2)) { + allFound = false; + notFoundList += "deltaPhiRescaled2 "; + } - } //if not calo ONly + } // if not calo ONly // Get the number of primary vertices or FCal ET in this event bool doCentralityTransform = m_rootTool->m_doCentralityTransform; - if( mu < 0 ){ // use npv if mu is negative (not given) - if (doCentralityTransform) ip = static_cast<double>(m_useCaloSumsCont ? this->getFcalEt(ctx) : m_fcalEtDefault); - else ip = static_cast<double>(m_usePVCont ? this->getNPrimVertices(ctx) : m_nPVdefault); - } - else { + if (mu < 0) { // use npv if mu is negative (not given) + if (doCentralityTransform) + ip = static_cast<double>(m_useCaloSumsCont ? this->getFcalEt(ctx) + : m_fcalEtDefault); + else + ip = static_cast<double>(m_usePVCont ? this->getNPrimVertices(ctx) + : m_nPVdefault); + } else { ip = mu; } @@ -383,82 +487,89 @@ asg::AcceptData AsgElectronLikelihoodTool::accept(const EventContext& ctx, const double likelihood = calculate(ctx, el, ip); ATH_MSG_VERBOSE(Form( - "PassVars: LH=%8.5f, eta=%8.5f, et=%8.5f, nSiHitsPlusDeadSensors=%i, " - "nHitsPlusPixDeadSensors=%i, passBLayerRequirement=%i, ambiguityBit=%i, " - "d0=%8.5f, deltaEta=%8.5f, deltaphires=%5.8f, wstot=%8.5f, EoverP=%8.5f, " - "ip=%8.5f", - likelihood, eta, et, nSiHitsPlusDeadSensors, nPixHitsPlusDeadSensors, - passBLayerRequirement, ambiguityBit, d0, deltaEta, deltaPhiRescaled2, - wstot, EoverP, ip)); + "PassVars: LH=%8.5f, eta=%8.5f, et=%8.5f, nSiHitsPlusDeadSensors=%i, " + "nHitsPlusPixDeadSensors=%i, passBLayerRequirement=%i, ambiguityBit=%i, " + "d0=%8.5f, deltaEta=%8.5f, deltaphires=%5.8f, wstot=%8.5f, EoverP=%8.5f, " + "ip=%8.5f", + likelihood, + eta, + et, + nSiHitsPlusDeadSensors, + nPixHitsPlusDeadSensors, + passBLayerRequirement, + ambiguityBit, + d0, + deltaEta, + deltaPhiRescaled2, + wstot, + EoverP, + ip)); if (!allFound) { - ATH_MSG_ERROR("Skipping LH rectangular cuts! The following variables are missing: " << notFoundList); + ATH_MSG_ERROR( + "Skipping LH rectangular cuts! The following variables are missing: " + << notFoundList); return m_rootTool->accept(); } // Get the answer from the underlying ROOT tool - return m_rootTool->accept( likelihood, - eta, - et, - nSiHitsPlusDeadSensors, - nPixHitsPlusDeadSensors, - passBLayerRequirement, - ambiguityBit, - d0, - deltaEta, - deltaPhiRescaled2, - wstot, - EoverP, - ip - ); + return m_rootTool->accept(likelihood, + eta, + et, + nSiHitsPlusDeadSensors, + nPixHitsPlusDeadSensors, + passBLayerRequirement, + ambiguityBit, + d0, + deltaEta, + deltaPhiRescaled2, + wstot, + EoverP, + ip); } -//============================================================================= // Accept method for EFCaloLH in the trigger; do full LH if !CaloCutsOnly -//============================================================================= -asg::AcceptData AsgElectronLikelihoodTool::accept( const xAOD::Egamma* eg, double mu) const -{ - //Backwards compatbility - return accept(Gaudi::Hive::currentContext(), eg, mu); -} -asg::AcceptData AsgElectronLikelihoodTool::accept(const EventContext& ctx, const xAOD::Egamma* eg, double mu) const +asg::AcceptData +AsgElectronLikelihoodTool::accept(const EventContext& ctx, + const xAOD::Egamma* eg, + double mu) const { - if ( !eg ){ - ATH_MSG_ERROR ("Failed, no egamma object."); + if (!eg) { + ATH_MSG_ERROR("Failed, no egamma object."); return m_rootTool->accept(); } // Call the main accept if this is not a calo-only LH if (!m_caloOnly) { - if(eg->type() == xAOD::Type::Electron){ - const xAOD::Electron* el = static_cast<const xAOD::Electron*>(eg); - return accept(ctx,el, mu); + if (eg->type() == xAOD::Type::Electron) { + const xAOD::Electron* el = static_cast<const xAOD::Electron*>(eg); + return accept(ctx, el, mu); } - ATH_MSG_ERROR("Input is not an electron and not caloOnly is set"); - return m_rootTool->accept(); - + ATH_MSG_ERROR("Input is not an electron and not caloOnly is set"); + return m_rootTool->accept(); } - //Calo only LH + // Calo only LH const xAOD::CaloCluster* cluster = eg->caloCluster(); - if ( !cluster ){ - ATH_MSG_ERROR ("Failed, no cluster."); + if (!cluster) { + ATH_MSG_ERROR("Failed, no cluster."); return m_rootTool->accept(); } - if( !cluster->hasSampling(CaloSampling::CaloSample::EMB2) && !cluster->hasSampling(CaloSampling::CaloSample::EME2) ){ + if (!cluster->hasSampling(CaloSampling::CaloSample::EMB2) && + !cluster->hasSampling(CaloSampling::CaloSample::EME2)) { ATH_MSG_ERROR("Failed, cluster is missing samplings EMB2 and EME2"); return m_rootTool->accept(); } - const double energy = cluster->e(); + const double energy = cluster->e(); const float eta = (cluster->etaBE(2)); - if( isForwardElectron(eg,eta) ){ + if (isForwardElectron(eg, eta)) { ATH_MSG_WARNING( - "Failed, this is a forward electron! The AsgElectronLikelihoodTool is " - "only suitable for central electrons!"); + "Failed, this is a forward electron! The AsgElectronLikelihoodTool is " + "only suitable for central electrons!"); return m_rootTool->accept(); } - const double et = ( cosh(eta) != 0.) ? energy/cosh(eta) : 0.; + const double et = (cosh(eta) != 0.) ? energy / cosh(eta) : 0.; // Variables the EFCaloLH ignores uint8_t nSiHitsPlusDeadSensors(0); @@ -470,98 +581,110 @@ asg::AcceptData AsgElectronLikelihoodTool::accept(const EventContext& ctx, const double ip(0); bool doCentralityTransform = m_rootTool->m_doCentralityTransform; - if( mu < 0 ){ // use npv if mu is negative (not given) - if (doCentralityTransform) ip = static_cast<double>(m_useCaloSumsCont ? this->getFcalEt(ctx) : m_fcalEtDefault); - else ip = static_cast<double>(m_usePVCont ? this->getNPrimVertices(ctx) : m_nPVdefault); + if (mu < 0) { // use npv if mu is negative (not given) + if (doCentralityTransform) + ip = static_cast<double>(m_useCaloSumsCont ? this->getFcalEt(ctx) + : m_fcalEtDefault); + else + ip = static_cast<double>(m_usePVCont ? this->getNPrimVertices(ctx) + : m_nPVdefault); - } - else { + } else { ip = mu; } // for now don't cache. double likelihood = calculate(ctx, eg, ip); - double deltaEta=0; - double deltaPhiRescaled2=0; - double d0=0; - float wstot=0; - float EoverP=0; + double deltaEta = 0; + double deltaPhiRescaled2 = 0; + double d0 = 0; + float wstot = 0; + float EoverP = 0; bool allFound = true; std::string notFoundList = ""; // Wstot for use when CutWstotAtHighET vector is filled - if( !eg->showerShapeValue(wstot, xAOD::EgammaParameters::wtots1) ){ + if (!eg->showerShapeValue(wstot, xAOD::EgammaParameters::wtots1)) { allFound = false; notFoundList += "wtots1 "; } ATH_MSG_VERBOSE( - Form("PassVars: LH=%8.5f, eta=%8.5f, et=%8.5f, " - "nSiHitsPlusDeadSensors=%i, nPixHitsPlusDeadSensors=%i, " - "passBLayerRequirement=%i, ambiguityBit=%i, ip=%8.5f, wstot=%8.5f", - likelihood, eta, et, nSiHitsPlusDeadSensors, nPixHitsPlusDeadSensors, - passBLayerRequirement, ambiguityBit, ip, wstot)); + Form("PassVars: LH=%8.5f, eta=%8.5f, et=%8.5f, " + "nSiHitsPlusDeadSensors=%i, nPixHitsPlusDeadSensors=%i, " + "passBLayerRequirement=%i, ambiguityBit=%i, ip=%8.5f, wstot=%8.5f", + likelihood, + eta, + et, + nSiHitsPlusDeadSensors, + nPixHitsPlusDeadSensors, + passBLayerRequirement, + ambiguityBit, + ip, + wstot)); if (!allFound) { - ATH_MSG_ERROR("Skipping LH rectangular cuts! The following variables are missing: " << notFoundList); + ATH_MSG_ERROR( + "Skipping LH rectangular cuts! The following variables are missing: " + << notFoundList); return m_rootTool->accept(); } // Get the answer from the underlying ROOT tool - return m_rootTool->accept( likelihood, - eta, - et, - nSiHitsPlusDeadSensors, - nPixHitsPlusDeadSensors, - passBLayerRequirement, - ambiguityBit, - d0, - deltaEta, - deltaPhiRescaled2, - wstot, - EoverP, - ip - ); + return m_rootTool->accept(likelihood, + eta, + et, + nSiHitsPlusDeadSensors, + nPixHitsPlusDeadSensors, + passBLayerRequirement, + ambiguityBit, + d0, + deltaEta, + deltaPhiRescaled2, + wstot, + EoverP, + ip); } -//============================================================================= // The main result method: the actual likelihood is calculated here -//============================================================================= -double AsgElectronLikelihoodTool::calculate( const xAOD::Electron* el, double mu ) const +double +AsgElectronLikelihoodTool::calculate(const EventContext& ctx, + const xAOD::Electron* el, + double mu) const { - //Backward compatbility - return calculate(Gaudi::Hive::currentContext(), el, mu); -} -double AsgElectronLikelihoodTool::calculate( const EventContext& ctx, const xAOD::Electron* el, double mu ) const -{ - if ( !el){ - ATH_MSG_ERROR ("Failed, no egamma object."); + if (!el) { + ATH_MSG_ERROR("Failed, no egamma object."); return -999; } - const xAOD::CaloCluster* cluster = el->caloCluster(); - if ( !cluster ){ - ATH_MSG_ERROR ("Failed, no cluster."); + const xAOD::CaloCluster* cluster = el->caloCluster(); + if (!cluster) { + ATH_MSG_ERROR("Failed, no cluster."); return -999; } - if( !cluster->hasSampling(CaloSampling::CaloSample::EMB2) && !cluster->hasSampling(CaloSampling::CaloSample::EME2) ){ + if (!cluster->hasSampling(CaloSampling::CaloSample::EMB2) && + !cluster->hasSampling(CaloSampling::CaloSample::EME2)) { ATH_MSG_ERROR("Failed, cluster is missing samplings EMB2 and EME2"); return -999; } - const double energy = cluster->e(); + const double energy = cluster->e(); const float eta = cluster->etaBE(2); - if( isForwardElectron(el,eta) ){ - ATH_MSG_WARNING("Failed, this is a forward electron! The AsgElectronLikelihoodTool is only suitable for central electrons!"); + if (isForwardElectron(el, eta)) { + ATH_MSG_WARNING( + "Failed, this is a forward electron! The AsgElectronLikelihoodTool is " + "only suitable for central electrons!"); return -999; } double et = 0.; - if(el->trackParticle() && !m_caloOnly) { - et = ( cosh(el->trackParticle()->eta()) != 0.) ? energy/cosh(el->trackParticle()->eta()) : 0.; + if (el->trackParticle() && !m_caloOnly) { + et = (cosh(el->trackParticle()->eta()) != 0.) + ? energy / cosh(el->trackParticle()->eta()) + : 0.; } else { - et = ( cosh(eta) != 0.) ? energy/cosh(eta) : 0.; + et = (cosh(eta) != 0.) ? energy / cosh(eta) : 0.; } // number of track hits and other track quantities @@ -571,59 +694,56 @@ double AsgElectronLikelihoodTool::calculate( const EventContext& ctx, const xAOD double dpOverp(0.0); float TRT_PID(0.0); double trans_TRT_PID(0.0); - float deltaEta=0; - float deltaPhiRescaled2=0; + float deltaEta = 0; + float deltaPhiRescaled2 = 0; bool allFound = true; std::string notFoundList = ""; - if (!m_caloOnly){ - // retrieve associated TrackParticle + if (!m_caloOnly) { + // retrieve associated TrackParticle const xAOD::TrackParticle* t = el->trackParticle(); - if (t) - { - trackqoverp = t->qOverP(); - d0 = t->d0(); - float vard0 = t->definingParametersCovMatrix()(0,0); - if (vard0 > 0) { - d0sigma=sqrtf(vard0); - } - if( !t->summaryValue(TRT_PID, xAOD::eProbabilityHT) ){ - allFound = false; - notFoundList += "eProbabilityHT "; - } - - //Transform the TRT PID output for use in the LH tool. - double tau = 15.0; - double fEpsilon = 1.0e-30; // to avoid zero division - double pid_tmp = TRT_PID; - if (pid_tmp >= 1.0) pid_tmp = 1.0 - 1.0e-15; //this number comes from TMVA - else if (pid_tmp <= fEpsilon) pid_tmp = fEpsilon; - trans_TRT_PID = - log(1.0/pid_tmp - 1.0)*(1./double(tau)); - - unsigned int index; - if( t->indexOfParameterAtPosition(index, xAOD::LastMeasurement) ) { - - double refittedTrack_LMqoverp = - t->charge() / sqrt(std::pow(t->parameterPX(index), 2) + - std::pow(t->parameterPY(index), 2) + - std::pow(t->parameterPZ(index), 2)); - - dpOverp = 1 - trackqoverp/(refittedTrack_LMqoverp); - } - else if (!m_skipDeltaPoverP){ - allFound = false; - notFoundList += "deltaPoverP "; - } - - + if (t) { + trackqoverp = t->qOverP(); + d0 = t->d0(); + float vard0 = t->definingParametersCovMatrix()(0, 0); + if (vard0 > 0) { + d0sigma = sqrtf(vard0); } - else - { - ATH_MSG_ERROR( "Failed, no track particle. et= " << et << "eta= " << eta ); - return -999; + if (!t->summaryValue(TRT_PID, xAOD::eProbabilityHT)) { + allFound = false; + notFoundList += "eProbabilityHT "; } - } // if not calo Only + + // Transform the TRT PID output for use in the LH tool. + double tau = 15.0; + double fEpsilon = 1.0e-30; // to avoid zero division + double pid_tmp = TRT_PID; + if (pid_tmp >= 1.0) + pid_tmp = 1.0 - 1.0e-15; // this number comes from TMVA + else if (pid_tmp <= fEpsilon) + pid_tmp = fEpsilon; + trans_TRT_PID = -log(1.0 / pid_tmp - 1.0) * (1. / double(tau)); + + unsigned int index; + if (t->indexOfParameterAtPosition(index, xAOD::LastMeasurement)) { + + double refittedTrack_LMqoverp = + t->charge() / sqrt(std::pow(t->parameterPX(index), 2) + + std::pow(t->parameterPY(index), 2) + + std::pow(t->parameterPZ(index), 2)); + + dpOverp = 1 - trackqoverp / (refittedTrack_LMqoverp); + } else if (!m_skipDeltaPoverP) { + allFound = false; + notFoundList += "deltaPoverP "; + } + + } else { + ATH_MSG_ERROR("Failed, no track particle. et= " << et << "eta= " << eta); + return -999; + } + } // if not calo Only float Reta(0); float Rphi(0); @@ -635,162 +755,179 @@ double AsgElectronLikelihoodTool::calculate( const EventContext& ctx, const xAOD float f3(0); // reta = e237/e277 - if( !el->showerShapeValue(Reta, xAOD::EgammaParameters::Reta) ){ + if (!el->showerShapeValue(Reta, xAOD::EgammaParameters::Reta)) { allFound = false; notFoundList += "Reta "; } // rphi e233/e237 - if( !el->showerShapeValue(Rphi, xAOD::EgammaParameters::Rphi) ){ + if (!el->showerShapeValue(Rphi, xAOD::EgammaParameters::Rphi)) { allFound = false; notFoundList += "Rphi "; } // rhad1 = ethad1/et - if( !el->showerShapeValue(Rhad1, xAOD::EgammaParameters::Rhad1) ){ + if (!el->showerShapeValue(Rhad1, xAOD::EgammaParameters::Rhad1)) { allFound = false; notFoundList += "Rhad1 "; } // rhad = ethad/et - if( !el->showerShapeValue(Rhad, xAOD::EgammaParameters::Rhad) ){ + if (!el->showerShapeValue(Rhad, xAOD::EgammaParameters::Rhad)) { allFound = false; notFoundList += "Rhad "; } // shower width in 2nd sampling - if( !el->showerShapeValue(w2, xAOD::EgammaParameters::weta2) ){ + if (!el->showerShapeValue(w2, xAOD::EgammaParameters::weta2)) { allFound = false; notFoundList += "weta2 "; } // fraction of energy reconstructed in the 1st sampling - if( !el->showerShapeValue(f1, xAOD::EgammaParameters::f1) ){ + if (!el->showerShapeValue(f1, xAOD::EgammaParameters::f1)) { allFound = false; notFoundList += "f1 "; } // E of 2nd max between max and min in strips - if( !el->showerShapeValue(Eratio, xAOD::EgammaParameters::Eratio) ){ + if (!el->showerShapeValue(Eratio, xAOD::EgammaParameters::Eratio)) { allFound = false; notFoundList += "Eratio "; } // fraction of energy reconstructed in the 3rd sampling - if( !el->showerShapeValue(f3, xAOD::EgammaParameters::f3) ){ + if (!el->showerShapeValue(f3, xAOD::EgammaParameters::f3)) { allFound = false; notFoundList += "f3 "; } - if( !m_caloOnly){ + if (!m_caloOnly) { // deltaEta1 - if( !el->trackCaloMatchValue(deltaEta, xAOD::EgammaParameters::deltaEta1) ){ + if (!el->trackCaloMatchValue(deltaEta, xAOD::EgammaParameters::deltaEta1)) { allFound = false; notFoundList += "deltaEta1 "; } - // difference between the cluster phi (sampling 2) and the eta of the track extrapolated from the last measurement point. - if( !el->trackCaloMatchValue(deltaPhiRescaled2, xAOD::EgammaParameters::deltaPhiRescaled2) ){ + // difference between the cluster phi (sampling 2) and the eta of the track + // extrapolated from the last measurement point. + if (!el->trackCaloMatchValue(deltaPhiRescaled2, + xAOD::EgammaParameters::deltaPhiRescaled2)) { allFound = false; notFoundList += "deltaPhiRescaled2 "; } - } // Get the number of primary vertices or FCal ET in this event double ip = static_cast<double>(m_nPVdefault); bool doCentralityTransform = m_rootTool->m_doCentralityTransform; - if( mu < 0 ){ // use npv if mu is negative (not given) - if (doCentralityTransform) ip = static_cast<double>(m_useCaloSumsCont ? this->getFcalEt(ctx) : m_fcalEtDefault); - else ip = static_cast<double>(m_usePVCont ? this->getNPrimVertices(ctx) : m_nPVdefault); - } - else{ + if (mu < 0) { // use npv if mu is negative (not given) + if (doCentralityTransform) + ip = static_cast<double>(m_useCaloSumsCont ? this->getFcalEt(ctx) + : m_fcalEtDefault); + else + ip = static_cast<double>(m_usePVCont ? this->getNPrimVertices(ctx) + : m_nPVdefault); + } else { ip = mu; } - ATH_MSG_VERBOSE( Form("Vars: eta=5%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, deltaEta=%8.5f, d0=%8.5f, d0sigma=%8.5f, Rphi=%8.5f, dpOverp=%8.5f, deltaPhiRescaled2=%8.5f, TRT_PID=%8.5f, trans_TRT_PID=%8.5f, ip=%8.5f", - eta, et, f3, Rhad, Rhad1, Reta, - w2, f1, Eratio, - deltaEta, d0, - d0sigma, - Rphi, dpOverp, deltaPhiRescaled2, - TRT_PID, trans_TRT_PID, - ip ) ); + ATH_MSG_VERBOSE(Form( + "Vars: eta=5%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, deltaEta=%8.5f, d0=%8.5f, " + "d0sigma=%8.5f, Rphi=%8.5f, dpOverp=%8.5f, deltaPhiRescaled2=%8.5f, " + "TRT_PID=%8.5f, trans_TRT_PID=%8.5f, ip=%8.5f", + eta, + et, + f3, + Rhad, + Rhad1, + Reta, + w2, + f1, + Eratio, + deltaEta, + d0, + d0sigma, + Rphi, + dpOverp, + deltaPhiRescaled2, + TRT_PID, + trans_TRT_PID, + ip)); if (!allFound) { - ATH_MSG_ERROR("Skipping LH calculation! The following variables are missing: " << notFoundList); + ATH_MSG_ERROR( + "Skipping LH calculation! The following variables are missing: " + << notFoundList); return -999; } // Get the answer from the underlying ROOT tool - return m_rootTool->calculate( eta, - et, - f3, - Rhad, - Rhad1, - Reta, - w2, - f1, - Eratio, - deltaEta, - d0, - d0sigma, - Rphi, - dpOverp, - deltaPhiRescaled2, - trans_TRT_PID, - ip - ); + return m_rootTool->calculate(eta, + et, + f3, + Rhad, + Rhad1, + Reta, + w2, + f1, + Eratio, + deltaEta, + d0, + d0sigma, + Rphi, + dpOverp, + deltaPhiRescaled2, + trans_TRT_PID, + ip); } -//============================================================================= // Calculate method for EFCaloLH in the trigger; do full LH if !CaloCutsOnly -//============================================================================= -double AsgElectronLikelihoodTool::calculate( const xAOD::Egamma* eg, double mu ) const -{ - //Backward compatibility - return calculate(Gaudi::Hive::currentContext(), eg, mu); - -} -double AsgElectronLikelihoodTool::calculate( const EventContext& ctx, const xAOD::Egamma* eg, double mu ) const +double +AsgElectronLikelihoodTool::calculate(const EventContext& ctx, + const xAOD::Egamma* eg, + double mu) const { - if ( !eg ){ - ATH_MSG_ERROR ("Failed, no egamma object."); + if (!eg) { + ATH_MSG_ERROR("Failed, no egamma object."); return -999; } - if( !m_caloOnly ){ - if(eg->type() == xAOD::Type::Electron){ - const xAOD::Electron* el = static_cast<const xAOD::Electron*>(eg); - return calculate(ctx, el); - } - - ATH_MSG_ERROR("Input is not an electron and not Calo Only is required"); - return -999; + if (!m_caloOnly) { + if (eg->type() == xAOD::Type::Electron) { + const xAOD::Electron* el = static_cast<const xAOD::Electron*>(eg); + return calculate(ctx, el); + } + ATH_MSG_ERROR("Input is not an electron and not Calo Only is required"); + return -999; } - const xAOD::CaloCluster* cluster = eg->caloCluster(); - if ( !cluster ){ - ATH_MSG_ERROR ("Failed, no cluster."); + const xAOD::CaloCluster* cluster = eg->caloCluster(); + if (!cluster) { + ATH_MSG_ERROR("Failed, no cluster."); return -999; } - if( !cluster->hasSampling(CaloSampling::CaloSample::EMB2) && !cluster->hasSampling(CaloSampling::CaloSample::EME2) ){ + if (!cluster->hasSampling(CaloSampling::CaloSample::EMB2) && + !cluster->hasSampling(CaloSampling::CaloSample::EME2)) { ATH_MSG_ERROR("Failed, cluster is missing samplings EMB2 and EME2"); return -999; } - const double energy = cluster->e(); + const double energy = cluster->e(); const float eta = cluster->etaBE(2); - if( isForwardElectron(eg,eta) ){ - ATH_MSG_WARNING("Failed, this is a forward electron! The AsgElectronLikelihoodTool is only suitable for central electrons!"); + if (isForwardElectron(eg, eta)) { + ATH_MSG_WARNING( + "Failed, this is a forward electron! The AsgElectronLikelihoodTool is " + "only suitable for central electrons!"); return -999; } - const double et = ( cosh(eta) != 0.) ? energy/cosh(eta) : 0.; + const double et = (cosh(eta) != 0.) ? energy / cosh(eta) : 0.; // Track variables that the EFCaloLH will not use float d0(0.0); float d0sigma(0.0); double dpOverp(0.0); - float deltaEta=0; - float deltaPhiRescaled2=0; + float deltaEta = 0; + float deltaPhiRescaled2 = 0; float TRT_PID(0.0); // Calo Variables @@ -807,42 +944,42 @@ double AsgElectronLikelihoodTool::calculate( const EventContext& ctx, const xAOD std::string notFoundList = ""; // reta = e237/e277 - if( !eg->showerShapeValue(Reta, xAOD::EgammaParameters::Reta) ){ + if (!eg->showerShapeValue(Reta, xAOD::EgammaParameters::Reta)) { allFound = false; notFoundList += "Reta "; } // rphi e233/e237 - if( !eg->showerShapeValue(Rphi, xAOD::EgammaParameters::Rphi) ){ + if (!eg->showerShapeValue(Rphi, xAOD::EgammaParameters::Rphi)) { allFound = false; notFoundList += "Rphi "; } // rhad1 = ethad1/et - if( !eg->showerShapeValue(Rhad1, xAOD::EgammaParameters::Rhad1) ){ + if (!eg->showerShapeValue(Rhad1, xAOD::EgammaParameters::Rhad1)) { allFound = false; notFoundList += "Rhad1 "; } // rhad = ethad/et - if( !eg->showerShapeValue(Rhad, xAOD::EgammaParameters::Rhad) ){ + if (!eg->showerShapeValue(Rhad, xAOD::EgammaParameters::Rhad)) { allFound = false; notFoundList += "Rhad "; } // shower width in 2nd sampling - if( !eg->showerShapeValue(w2, xAOD::EgammaParameters::weta2) ){ + if (!eg->showerShapeValue(w2, xAOD::EgammaParameters::weta2)) { allFound = false; notFoundList += "weta2 "; } // fraction of energy reconstructed in the 1st sampling - if( !eg->showerShapeValue(f1, xAOD::EgammaParameters::f1) ){ + if (!eg->showerShapeValue(f1, xAOD::EgammaParameters::f1)) { allFound = false; notFoundList += "f1 "; } // E of 2nd max between max and min in strips - if( !eg->showerShapeValue(Eratio, xAOD::EgammaParameters::Eratio) ){ + if (!eg->showerShapeValue(Eratio, xAOD::EgammaParameters::Eratio)) { allFound = false; notFoundList += "Eratio "; } // fraction of energy reconstructed in the 3rd sampling - if( !eg->showerShapeValue(f3, xAOD::EgammaParameters::f3) ){ + if (!eg->showerShapeValue(f3, xAOD::EgammaParameters::f3)) { allFound = false; notFoundList += "f3 "; } @@ -851,142 +988,168 @@ double AsgElectronLikelihoodTool::calculate( const EventContext& ctx, const xAOD double ip(0); bool doCentralityTransform = m_rootTool->m_doCentralityTransform; - if( mu < 0 ){ // use npv if mu is negative (not given) - if (doCentralityTransform) ip = static_cast<double>(m_useCaloSumsCont ? this->getFcalEt(ctx) : m_fcalEtDefault); - else ip = static_cast<double>(m_usePVCont ? this->getNPrimVertices(ctx) : m_nPVdefault); - } - else { + if (mu < 0) { // use npv if mu is negative (not given) + if (doCentralityTransform) + ip = static_cast<double>(m_useCaloSumsCont ? this->getFcalEt(ctx) + : m_fcalEtDefault); + else + ip = static_cast<double>(m_usePVCont ? this->getNPrimVertices(ctx) + : m_nPVdefault); + } else { ip = mu; } 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, deltaEta=%8.5f, " - "d0=%8.5f, d0sigma=%8.5f, Rphi=%8.5f, dpOverp=%8.5f, " - "deltaPhiRescaled2=%8.5f, TRT_PID=%8.5f, ip=%8.5f", - eta, et, f3, Rhad, Rhad1, Reta, w2, f1, Eratio, deltaEta, d0, - d0sigma, Rphi, dpOverp, deltaPhiRescaled2, TRT_PID, ip)); + 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, deltaEta=%8.5f, " + "d0=%8.5f, d0sigma=%8.5f, Rphi=%8.5f, dpOverp=%8.5f, " + "deltaPhiRescaled2=%8.5f, TRT_PID=%8.5f, ip=%8.5f", + eta, + et, + f3, + Rhad, + Rhad1, + Reta, + w2, + f1, + Eratio, + deltaEta, + d0, + d0sigma, + Rphi, + dpOverp, + deltaPhiRescaled2, + TRT_PID, + ip)); if (!allFound) { - ATH_MSG_ERROR("Skipping LH calculation! The following variables are missing: " << notFoundList); + ATH_MSG_ERROR( + "Skipping LH calculation! The following variables are missing: " + << notFoundList); return -999; } // Get the answer from the underlying ROOT tool - return m_rootTool->calculate( eta, - et, - f3, - Rhad, - Rhad1, - Reta, - w2, - f1, - Eratio, - deltaEta, - d0, - d0sigma, - Rphi, - dpOverp, - deltaPhiRescaled2, - TRT_PID, - ip - ); + return m_rootTool->calculate(eta, + et, + f3, + Rhad, + Rhad1, + Reta, + w2, + f1, + Eratio, + deltaEta, + d0, + d0sigma, + Rphi, + dpOverp, + deltaPhiRescaled2, + TRT_PID, + ip); } - -//============================================================================= -/// Get the name of the current operating point -//============================================================================= -std::string AsgElectronLikelihoodTool::getOperatingPointName() const +// Get the name of the current operating point +std::string +AsgElectronLikelihoodTool::getOperatingPointName() const { return m_WorkingPoint; } -//============================================================================= -asg::AcceptData AsgElectronLikelihoodTool::accept(const xAOD::IParticle* part) const + +// aceept with IParticle and no EventContext, backwards compatibility +asg::AcceptData +AsgElectronLikelihoodTool::accept(const xAOD::IParticle* part) const { - //Backwards compatibility + // Backwards compatibility return accept(Gaudi::Hive::currentContext(), part); } -asg::AcceptData AsgElectronLikelihoodTool::accept(const EventContext& ctx, const xAOD::IParticle* part) const +asg::AcceptData +AsgElectronLikelihoodTool::accept(const EventContext& ctx, + const xAOD::IParticle* part) const { - if(part->type() == xAOD::Type::Electron){ + if (part->type() == xAOD::Type::Electron) { const xAOD::Electron* el = static_cast<const xAOD::Electron*>(part); return accept(ctx, el); } - - ATH_MSG_ERROR("Input is not an electron"); - return m_rootTool->accept(); - + ATH_MSG_ERROR("Input is not an electron"); + return m_rootTool->accept(); } -double AsgElectronLikelihoodTool::calculate(const xAOD::IParticle* part) const +// Calculate with IParticle and no EventContext, backwards compatibility +double +AsgElectronLikelihoodTool::calculate(const xAOD::IParticle* part) const { - //Backwards compatibily + // Backward compatibility return calculate(Gaudi::Hive::currentContext(), part); } - -double AsgElectronLikelihoodTool::calculate(const EventContext& ctx, const xAOD::IParticle* part) const +double +AsgElectronLikelihoodTool::calculate(const EventContext& ctx, + const xAOD::IParticle* part) const { - if(part->type() == xAOD::Type::Electron){ + if (part->type() == xAOD::Type::Electron) { const xAOD::Electron* el = static_cast<const xAOD::Electron*>(part); return calculate(ctx, el); } - ATH_MSG_ERROR ( "Input is not an electron" ); - return -999; - + ATH_MSG_ERROR("Input is not an electron"); + return -999; } -//============================================================================= // Helper method to get the number of primary vertices // We don't want to iterate over all vertices in the event for each electron!!! -//============================================================================= -unsigned int AsgElectronLikelihoodTool::getNPrimVertices(const EventContext& ctx) const +unsigned int +AsgElectronLikelihoodTool::getNPrimVertices(const EventContext& ctx) const { unsigned int nVtx(0); - SG::ReadHandle<xAOD::VertexContainer> vtxCont (m_primVtxContKey, ctx); - for ( unsigned int i = 0; i < vtxCont->size(); i++ ) { - const xAOD::Vertex* vxcand = vtxCont->at(i); - if ( vxcand->nTrackParticles() >= 2 ) nVtx++; + SG::ReadHandle<xAOD::VertexContainer> vtxCont(m_primVtxContKey, ctx); + for (unsigned int i = 0; i < vtxCont->size(); i++) { + const xAOD::Vertex* vxcand = vtxCont->at(i); + if (vxcand->nTrackParticles() >= 2) + nVtx++; } return nVtx; } -//============================================================================= // Helper method to get FCal ET for centrality determination -//============================================================================= -double AsgElectronLikelihoodTool::getFcalEt(const EventContext& ctx) const +double +AsgElectronLikelihoodTool::getFcalEt(const EventContext& ctx) const { double fcalEt(0.); - SG::ReadHandle<xAOD::HIEventShapeContainer> HIESCont (m_HIESContKey,ctx); + SG::ReadHandle<xAOD::HIEventShapeContainer> HIESCont(m_HIESContKey, ctx); xAOD::HIEventShapeContainer::const_iterator es_itr = HIESCont->begin(); xAOD::HIEventShapeContainer::const_iterator es_end = HIESCont->end(); - for (; es_itr != es_end; es_itr++){ - double et = (*es_itr)->et(); - const std::string name = (*es_itr)->auxdataConst<std::string>("Summary"); - if (name == "FCal") fcalEt = et*1.e-6; + for (; es_itr != es_end; es_itr++) { + double et = (*es_itr)->et(); + const std::string name = (*es_itr)->auxdataConst<std::string>("Summary"); + if (name == "FCal") + fcalEt = et * 1.e-6; } return fcalEt; } -bool AsgElectronLikelihoodTool::isForwardElectron( const xAOD::Egamma* eg, const float eta ) const{ +bool +AsgElectronLikelihoodTool::isForwardElectron(const xAOD::Egamma* eg, + const float eta) const +{ - static const SG::AuxElement::ConstAccessor< uint16_t > accAuthor( "author" ); + static const SG::AuxElement::ConstAccessor<uint16_t> accAuthor("author"); - if( accAuthor.isAvailable(*eg) ){ + if (accAuthor.isAvailable(*eg)) { // cannot just do eg->author() because it isn't always filled // at trigger level - if( accAuthor(*eg) == xAOD::EgammaParameters::AuthorFwdElectron ){ - ATH_MSG_WARNING("Failed, this is a forward electron! The AsgElectronLikelihoodTool is only suitable for central electrons!"); + if (accAuthor(*eg) == xAOD::EgammaParameters::AuthorFwdElectron) { + ATH_MSG_WARNING( + "Failed, this is a forward electron! The AsgElectronLikelihoodTool is " + "only suitable for central electrons!"); return true; } - } - else{ - //Check for fwd via eta range the old logic - if ( fabs(eta) > 2.5 ) { - ATH_MSG_WARNING("Failed, cluster->etaBE(2) range due to " << eta << " seems like a fwd electron" ); + } else { + // Check for fwd via eta range the old logic + if (fabs(eta) > 2.5) { + ATH_MSG_WARNING("Failed, cluster->etaBE(2) range due to " + << eta << " seems like a fwd electron"); return true; } } diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgForwardElectronLikelihoodTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgForwardElectronLikelihoodTool.cxx index 2717d06377a2fe030743a9d8b44ffa483d74d187..6137d1128db9456a5669659f43892ffdfe182b90 100644 --- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgForwardElectronLikelihoodTool.cxx +++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgForwardElectronLikelihoodTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ /** @@ -89,7 +89,7 @@ StatusCode AsgForwardElectronLikelihoodTool::initialize() if (!m_configFile.empty()) { std::string configFile = PathResolverFindCalibFile(m_configFile); - if (configFile == "") + if (configFile.empty()) { ATH_MSG_ERROR("Could not locate " << m_configFile); return StatusCode::FAILURE; diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/TElectronLikelihoodTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/TElectronLikelihoodTool.cxx index 719eaac1fa41c5c854d437cd0d05a9d756a77b38..b5e99555a584708434f141dd72a9864b3a0d1774 100644 --- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/TElectronLikelihoodTool.cxx +++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/TElectronLikelihoodTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "TElectronLikelihoodTool.h" @@ -109,24 +109,29 @@ Root::TElectronLikelihoodTool::initialize() number_of_expected_bin_combinedLH = s_fnDiscEtBinsOneExtra * s_fnEtaBins; else number_of_expected_bin_combinedLH = s_fnDiscEtBins * s_fnEtaBins; - unsigned int number_of_expected_bin_combinedOther = s_fnDiscEtBins * s_fnEtaBins; + unsigned int number_of_expected_bin_combinedOther = + s_fnDiscEtBins * s_fnEtaBins; if (m_cutLikelihood.size() != number_of_expected_bin_combinedLH) { ATH_MSG_ERROR("Configuration issue : cutLikelihood expected size " - << number_of_expected_bin_combinedLH << " input size " << m_cutLikelihood.size()); + << number_of_expected_bin_combinedLH << " input size " + << m_cutLikelihood.size()); sc = StatusCode::FAILURE; } if (!m_discHardCutForPileupTransform.empty()) { - if (m_discHardCutForPileupTransform.size() != number_of_expected_bin_combinedLH) { - ATH_MSG_ERROR("Configuration issue : DiscHardCutForPileupTransform expected size " - << number_of_expected_bin_combinedLH << " input size " - << m_discHardCutForPileupTransform.size()); + if (m_discHardCutForPileupTransform.size() != + number_of_expected_bin_combinedLH) { + ATH_MSG_ERROR( + "Configuration issue : DiscHardCutForPileupTransform expected size " + << number_of_expected_bin_combinedLH << " input size " + << m_discHardCutForPileupTransform.size()); sc = StatusCode::FAILURE; } } if (!m_discHardCutSlopeForPileupTransform.empty()) { - if (m_discHardCutSlopeForPileupTransform.size() != number_of_expected_bin_combinedLH) { + if (m_discHardCutSlopeForPileupTransform.size() != + number_of_expected_bin_combinedLH) { ATH_MSG_ERROR("Configuration issue : " "DiscHardCutSlopeForPileupTransform expected size " << number_of_expected_bin_combinedLH << " input size " @@ -135,10 +140,12 @@ Root::TElectronLikelihoodTool::initialize() } } if (!m_discLooseForPileupTransform.empty()) { - if (m_discLooseForPileupTransform.size() != number_of_expected_bin_combinedLH) { - ATH_MSG_ERROR("Configuration issue : DiscLooseForPileupTransform expected size " - << number_of_expected_bin_combinedLH << " input size " - << m_discLooseForPileupTransform.size()); + if (m_discLooseForPileupTransform.size() != + number_of_expected_bin_combinedLH) { + ATH_MSG_ERROR( + "Configuration issue : DiscLooseForPileupTransform expected size " + << number_of_expected_bin_combinedLH << " input size " + << m_discLooseForPileupTransform.size()); sc = StatusCode::FAILURE; } } @@ -147,7 +154,8 @@ Root::TElectronLikelihoodTool::initialize() if (!m_cutA0.empty()) { if (m_cutA0.size() != number_of_expected_bin_combinedOther) { ATH_MSG_ERROR("Configuration issue : CutA0 expected size " - << number_of_expected_bin_combinedOther << " input size " << m_cutA0.size()); + << number_of_expected_bin_combinedOther << " input size " + << m_cutA0.size()); sc = StatusCode::FAILURE; } } @@ -172,7 +180,8 @@ Root::TElectronLikelihoodTool::initialize() } } if (sc == StatusCode::FAILURE) { - ATH_MSG_ERROR("Could NOT initialize! Please fix the errors mentioned above..."); + ATH_MSG_ERROR( + "Could NOT initialize! Please fix the errors mentioned above..."); return sc; } @@ -216,42 +225,44 @@ Root::TElectronLikelihoodTool::initialize() } // D0 - m_cutPositionTrackA0 = m_acceptInfo.addCut("TrackA0", "A0 (aka d0) wrt beam spot < Cut"); + m_cutPositionTrackA0 = + m_acceptInfo.addCut("TrackA0", "A0 (aka d0) wrt beam spot < Cut"); if (m_cutPositionTrackA0 < 0) { sc = StatusCode::FAILURE; } // deltaeta - m_cutPositionTrackMatchEta = - m_acceptInfo.addCut("TrackMatchEta", "Track match deta in 1st sampling < Cut"); + m_cutPositionTrackMatchEta = m_acceptInfo.addCut( + "TrackMatchEta", "Track match deta in 1st sampling < Cut"); if (m_cutPositionTrackMatchEta < 0) { sc = StatusCode::FAILURE; } // deltaphi - m_cutPositionTrackMatchPhiRes = - m_acceptInfo.addCut("TrackMatchPhiRes", "Track match dphi in 2nd sampling, rescaled < Cut"); + m_cutPositionTrackMatchPhiRes = m_acceptInfo.addCut( + "TrackMatchPhiRes", "Track match dphi in 2nd sampling, rescaled < Cut"); if (m_cutPositionTrackMatchPhiRes < 0) { sc = StatusCode::FAILURE; } // Wstot - m_cutPositionWstotAtHighET = - m_acceptInfo.addCut("WstotAtHighET", "Above HighETBinThreshold, Wstot < Cut"); + m_cutPositionWstotAtHighET = m_acceptInfo.addCut( + "WstotAtHighET", "Above HighETBinThreshold, Wstot < Cut"); if (m_cutPositionWstotAtHighET < 0) { sc = StatusCode::FAILURE; } // EoverP - m_cutPositionEoverPAtHighET = - m_acceptInfo.addCut("EoverPAtHighET", "Above HighETBinThreshold, EoverP < Cut"); + m_cutPositionEoverPAtHighET = m_acceptInfo.addCut( + "EoverPAtHighET", "Above HighETBinThreshold, EoverP < Cut"); if (m_cutPositionEoverPAtHighET < 0) { sc = StatusCode::FAILURE; } // Check that we got everything OK if (sc == StatusCode::FAILURE) { - ATH_MSG_ERROR("! Something went wrong with the setup of the decision objects..."); + ATH_MSG_ERROR( + "! Something went wrong with the setup of the decision objects..."); return sc; } @@ -277,7 +288,8 @@ Root::TElectronLikelihoodTool::initialize() // Skip the loading of PDFs for variables we don't care about for this // operating point. If the string is empty (which is true in the default // 2012 case), load all of them. - if (m_variableNames.find(vstr) == std::string::npos && !m_variableNames.empty()) { + if (m_variableNames.find(vstr) == std::string::npos && + !m_variableNames.empty()) { continue; } loadVarHistograms(vstr, varIndex); @@ -290,48 +302,55 @@ Root::TElectronLikelihoodTool::initialize() //----------End File/Histo operation------------------------------------ ATH_MSG_DEBUG("Initialization complete for a LH tool with these specs:" - << "\n - pdfFileName : " << m_pdfFileName - << "\n - Variable bitmask : " << m_variableBitMask); - - ATH_MSG_DEBUG( - "\n - VariableNames : " - << m_variableNames - << "\n - (bool)CutBL (yes/no) : " << (!m_cutBL.empty() ? "yes" : "no") - << "\n - (bool)CutPi (yes/no) : " << (!m_cutPi.empty() ? "yes" : "no") - << "\n - (bool)CutSi (yes/no) : " << (!m_cutSi.empty() ? "yes" : "no") - << "\n - (bool)CutAmbiguity (yes/no) : " - << (!m_cutAmbiguity.empty() ? "yes" : "no") - << "\n - (bool)doRemoveF3AtHighEt (yes/no) : " - << (m_doRemoveF3AtHighEt ? "yes" : "no") - << "\n - (bool)doRemoveTRTPIDAtHighEt (yes/no) : " - << (m_doRemoveTRTPIDAtHighEt ? "yes" : "no") - << "\n - (bool)doSmoothBinInterpolation (yes/no) : " - << (m_doSmoothBinInterpolation ? "yes" : "no") - << "\n - (bool)useOneExtraHighETLHBin(yes/no) : " - << (m_useOneExtraHighETLHBin ? "yes" : "no") - << "\n - (double)HighETBinThreshold : " << m_highETBinThreshold - << "\n - (bool)doPileupTransform (yes/no) : " - << (m_doPileupTransform ? "yes" : "no") - << "\n - (bool)doCentralityTransform (yes/no) : " - << (m_doCentralityTransform ? "yes" : "no") - << "\n - (bool)CutLikelihood (yes/no) : " - << (!m_cutLikelihood.empty() ? "yes" : "no") - << "\n - (bool)CutLikelihoodPileupCorrection (yes/no) : " - << (!m_cutLikelihoodPileupCorrection.empty() ? "yes" : "no") - << "\n - (bool)CutA0 (yes/no) : " << (!m_cutA0.empty() ? "yes" : "no") - << "\n - (bool)CutDeltaEta (yes/no) : " - << (!m_cutDeltaEta.empty() ? "yes" : "no") - << "\n - (bool)CutDeltaPhiRes (yes/no) : " - << (!m_cutDeltaPhiRes.empty() ? "yes" : "no") - << "\n - (bool)CutWstotAtHighET (yes/no) : " - << (!m_cutWstotAtHighET.empty() ? "yes" : "no") - << "\n - (bool)CutEoverPAtHighET (yes/no) : " - << (!m_cutEoverPAtHighET.empty() ? "yes" : "no")); + << "\n - pdfFileName : " + << m_pdfFileName + << "\n - Variable bitmask : " + << m_variableBitMask); + + ATH_MSG_DEBUG("\n - VariableNames : " + << m_variableNames + << "\n - (bool)CutBL (yes/no) : " + << (!m_cutBL.empty() ? "yes" : "no") + << "\n - (bool)CutPi (yes/no) : " + << (!m_cutPi.empty() ? "yes" : "no") + << "\n - (bool)CutSi (yes/no) : " + << (!m_cutSi.empty() ? "yes" : "no") + << "\n - (bool)CutAmbiguity (yes/no) : " + << (!m_cutAmbiguity.empty() ? "yes" : "no") + << "\n - (bool)doRemoveF3AtHighEt (yes/no) : " + << (m_doRemoveF3AtHighEt ? "yes" : "no") + << "\n - (bool)doRemoveTRTPIDAtHighEt (yes/no) : " + << (m_doRemoveTRTPIDAtHighEt ? "yes" : "no") + << "\n - (bool)doSmoothBinInterpolation (yes/no) : " + << (m_doSmoothBinInterpolation ? "yes" : "no") + << "\n - (bool)useOneExtraHighETLHBin(yes/no) : " + << (m_useOneExtraHighETLHBin ? "yes" : "no") + << "\n - (double)HighETBinThreshold : " + << m_highETBinThreshold + << "\n - (bool)doPileupTransform (yes/no) : " + << (m_doPileupTransform ? "yes" : "no") + << "\n - (bool)doCentralityTransform (yes/no) : " + << (m_doCentralityTransform ? "yes" : "no") + << "\n - (bool)CutLikelihood (yes/no) : " + << (!m_cutLikelihood.empty() ? "yes" : "no") + << "\n - (bool)CutLikelihoodPileupCorrection (yes/no) : " + << (!m_cutLikelihoodPileupCorrection.empty() ? "yes" : "no") + << "\n - (bool)CutA0 (yes/no) : " + << (!m_cutA0.empty() ? "yes" : "no") + << "\n - (bool)CutDeltaEta (yes/no) : " + << (!m_cutDeltaEta.empty() ? "yes" : "no") + << "\n - (bool)CutDeltaPhiRes (yes/no) : " + << (!m_cutDeltaPhiRes.empty() ? "yes" : "no") + << "\n - (bool)CutWstotAtHighET (yes/no) : " + << (!m_cutWstotAtHighET.empty() ? "yes" : "no") + << "\n - (bool)CutEoverPAtHighET (yes/no) : " + << (!m_cutEoverPAtHighET.empty() ? "yes" : "no")); return sc; } int -Root::TElectronLikelihoodTool::loadVarHistograms(const std::string& vstr, unsigned int varIndex) +Root::TElectronLikelihoodTool::loadVarHistograms(const std::string& vstr, + unsigned int varIndex) { for (unsigned int s_or_b = 0; s_or_b < 2; s_or_b++) { for (unsigned int ip = 0; ip < IP_BINS; ip++) { @@ -361,8 +380,12 @@ Root::TElectronLikelihoodTool::loadVarHistograms(const std::string& vstr, unsign char pdfdir[500]; snprintf(pdfdir, 500, "%s/%s", vstr.c_str(), sig_bkg.c_str()); char pdf[500]; - snprintf( - pdf, 500, "%s_%s_smoothed_hist_from_KDE_%s", vstr.c_str(), sig_bkg.c_str(), binname); + snprintf(pdf, + 500, + "%s_%s_smoothed_hist_from_KDE_%s", + vstr.c_str(), + sig_bkg.c_str(), + binname); char pdf_newname[500]; snprintf(pdf_newname, 500, @@ -373,15 +396,15 @@ Root::TElectronLikelihoodTool::loadVarHistograms(const std::string& vstr, unsign binname); if (!m_pdfFile->GetListOfKeys()->Contains(vstr.c_str())) { - ATH_MSG_INFO("Warning: skipping variable " << vstr - << " because the folder does not exist."); + ATH_MSG_INFO("Warning: skipping variable " + << vstr << " because the folder does not exist."); return 1; } if (!((TDirectory*)m_pdfFile->Get(vstr.c_str())) ->GetListOfKeys() ->Contains(sig_bkg.c_str())) { - ATH_MSG_INFO("Warning: skipping variable " << vstr - << " because the folder does not exist."); + ATH_MSG_INFO("Warning: skipping variable " + << vstr << " because the folder does not exist."); return 1; } @@ -394,10 +417,16 @@ Root::TElectronLikelihoodTool::loadVarHistograms(const std::string& vstr, unsign // If the 0th et bin (4-7 GeV) histogram does not exist in the root // file, then just use the 7-10 GeV bin histogram. This should // preserve backward compatibility - if (et == 0 && !((TDirectory*)m_pdfFile->Get(pdfdir))->GetListOfKeys()->Contains(pdf)) { + if (et == 0 && !((TDirectory*)m_pdfFile->Get(pdfdir)) + ->GetListOfKeys() + ->Contains(pdf)) { getBinName(binname, et_tmp + 1, eta_tmp, ip, m_ipBinning); - snprintf( - pdf, 500, "%s_%s_smoothed_hist_from_KDE_%s", vstr.c_str(), sig_bkg.c_str(), binname); + snprintf(pdf, + 500, + "%s_%s_smoothed_hist_from_KDE_%s", + vstr.c_str(), + sig_bkg.c_str(), + binname); snprintf(pdf_newname, 500, "%s_%s_%s_LHtool_copy4GeV_%s", @@ -406,9 +435,13 @@ Root::TElectronLikelihoodTool::loadVarHistograms(const std::string& vstr, unsign sig_bkg.c_str(), binname); } - if (((TDirectory*)m_pdfFile->Get(pdfdir))->GetListOfKeys()->Contains(pdf)) { - TH1F* hist = (TH1F*)(((TDirectory*)m_pdfFile->Get(pdfdir))->Get(pdf)); - fPDFbins[s_or_b][ip][et][eta][varIndex] = new EGSelectors::SafeTH1(hist); + if (((TDirectory*)m_pdfFile->Get(pdfdir)) + ->GetListOfKeys() + ->Contains(pdf)) { + TH1F* hist = + (TH1F*)(((TDirectory*)m_pdfFile->Get(pdfdir))->Get(pdf)); + fPDFbins[s_or_b][ip][et][eta][varIndex] = + new EGSelectors::SafeTH1(hist); delete hist; } else { ATH_MSG_INFO("Warning: Object " << pdf << " does not exist."); @@ -458,7 +491,8 @@ Root::TElectronLikelihoodTool::accept(double likelihood, // This method calculates if the current electron passes the requested // likelihood cut asg::AcceptData -Root::TElectronLikelihoodTool::accept(LikeEnum::LHAcceptVars_t& vars_struct) const +Root::TElectronLikelihoodTool::accept( + LikeEnum::LHAcceptVars_t& vars_struct) const { // Setup return accept with AcceptInfo asg::AcceptData acceptData(&m_acceptInfo); @@ -487,14 +521,14 @@ Root::TElectronLikelihoodTool::accept(LikeEnum::LHAcceptVars_t& vars_struct) con // sanity if (etbinLH >= s_fnDiscEtBinsOneExtra) { - ATH_MSG_WARNING("Cannot evaluate likelihood for Et " << vars_struct.eT - << ". Returning false.."); + ATH_MSG_WARNING("Cannot evaluate likelihood for Et " + << vars_struct.eT << ". Returning false.."); passKine = false; } // sanity if (etbinOther >= s_fnDiscEtBins) { - ATH_MSG_WARNING("Cannot evaluate likelihood for Et " << vars_struct.eT - << ". Returning false.."); + ATH_MSG_WARNING("Cannot evaluate likelihood for Et " + << vars_struct.eT << ". Returning false.."); passKine = false; } @@ -507,7 +541,8 @@ Root::TElectronLikelihoodTool::accept(LikeEnum::LHAcceptVars_t& vars_struct) con // ambiguity bit if (!m_cutAmbiguity.empty()) { if (!ElectronSelectorHelpers::passAmbiguity( - (xAOD::AmbiguityTool::AmbiguityType)vars_struct.ambiguityBit, m_cutAmbiguity[etabin])) { + (xAOD::AmbiguityTool::AmbiguityType)vars_struct.ambiguityBit, + m_cutAmbiguity[etabin])) { ATH_MSG_DEBUG("Likelihood macro: ambiguity Bit Failed."); passAmbiguity = false; } @@ -540,39 +575,45 @@ Root::TElectronLikelihoodTool::accept(LikeEnum::LHAcceptVars_t& vars_struct) con etbinLH * s_fnEtaBins + etabin; // Must change if number of eta bins // changes!. Also starts from 7-10 GeV bin. unsigned int ibin_combinedOther = - etbinOther * s_fnEtaBins + etabin; // Must change if number of eta bins changes!. Also - // starts from 7-10 GeV bin. + etbinOther * s_fnEtaBins + + etabin; // Must change if number of eta bins changes!. Also + // starts from 7-10 GeV bin. if (!m_cutLikelihood.empty()) { // To protect against a binning mismatch, which should never happen if (ibin_combinedLH >= m_cutLikelihood.size()) { ATH_MSG_ERROR("The desired eta/pt bin " - << ibin_combinedLH << " is outside of the range specified by the input" + << ibin_combinedLH + << " is outside of the range specified by the input" << m_cutLikelihood.size() << "This should never happen!"); return acceptData; } if (m_doSmoothBinInterpolation) { - cutDiscriminant = - InterpolateCuts(m_cutLikelihood, m_cutLikelihood4GeV, vars_struct.eT, vars_struct.eta); + cutDiscriminant = InterpolateCuts( + m_cutLikelihood, m_cutLikelihood4GeV, vars_struct.eT, vars_struct.eta); if (!m_doPileupTransform && !m_cutLikelihoodPileupCorrection.empty() && !m_cutLikelihoodPileupCorrection4GeV.empty()) - cutDiscriminant += vars_struct.ip * InterpolateCuts(m_cutLikelihoodPileupCorrection, - m_cutLikelihoodPileupCorrection4GeV, - vars_struct.eT, - vars_struct.eta); + cutDiscriminant += + vars_struct.ip * InterpolateCuts(m_cutLikelihoodPileupCorrection, + m_cutLikelihoodPileupCorrection4GeV, + vars_struct.eT, + vars_struct.eta); } else { if (vars_struct.eT > 7000. || m_cutLikelihood4GeV.empty()) { cutDiscriminant = m_cutLikelihood[ibin_combinedLH]; // If doPileupTransform, then correct the discriminant itself instead of // the cut value if (!m_doPileupTransform && !m_cutLikelihoodPileupCorrection.empty()) { - cutDiscriminant += vars_struct.ip * m_cutLikelihoodPileupCorrection[ibin_combinedLH]; + cutDiscriminant += + vars_struct.ip * m_cutLikelihoodPileupCorrection[ibin_combinedLH]; } } else { cutDiscriminant = m_cutLikelihood4GeV[etabin]; - if (!m_doPileupTransform && !m_cutLikelihoodPileupCorrection4GeV.empty()) - cutDiscriminant += vars_struct.ip * m_cutLikelihoodPileupCorrection4GeV[etabin]; + if (!m_doPileupTransform && + !m_cutLikelihoodPileupCorrection4GeV.empty()) + cutDiscriminant += + vars_struct.ip * m_cutLikelihoodPileupCorrection4GeV[etabin]; } } @@ -602,7 +643,8 @@ Root::TElectronLikelihoodTool::accept(LikeEnum::LHAcceptVars_t& vars_struct) con // deltaPhiRes cut if (!m_cutDeltaPhiRes.empty()) { - if (std::abs(vars_struct.deltaphires) > m_cutDeltaPhiRes[ibin_combinedOther]) { + if (std::abs(vars_struct.deltaphires) > + m_cutDeltaPhiRes[ibin_combinedOther]) { ATH_MSG_DEBUG("Likelihood macro: deltaphires Failed."); passDeltaPhiRes = false; } @@ -686,7 +728,8 @@ Root::TElectronLikelihoodTool::calculate(double eta, // The main public method to actually calculate the likelihood value double -Root::TElectronLikelihoodTool::calculate(LikeEnum::LHCalcVars_t& vars_struct) const +Root::TElectronLikelihoodTool::calculate( + LikeEnum::LHCalcVars_t& vars_struct) const { // Reset the results to defaul values double result = -999; @@ -698,25 +741,30 @@ Root::TElectronLikelihoodTool::calculate(LikeEnum::LHCalcVars_t& vars_struct) co } else { rhad_corr = vars_struct.rHad1; } - double d0significance = - vars_struct.d0sigma == 0 ? 0. : std::abs(vars_struct.d0) / vars_struct.d0sigma; - - std::vector<double> vec = { d0significance, vars_struct.eratio, vars_struct.deltaEta, - vars_struct.f1, vars_struct.f3, vars_struct.Reta, - rhad_corr, vars_struct.rphi, vars_struct.d0, - vars_struct.w2, vars_struct.deltaPoverP, vars_struct.deltaphires, - vars_struct.TRT_PID }; + double d0significance = vars_struct.d0sigma == 0 + ? 0. + : std::abs(vars_struct.d0) / vars_struct.d0sigma; + + std::vector<double> vec = { + d0significance, vars_struct.eratio, vars_struct.deltaEta, + vars_struct.f1, vars_struct.f3, vars_struct.Reta, + rhad_corr, vars_struct.rphi, vars_struct.d0, + vars_struct.w2, vars_struct.deltaPoverP, vars_struct.deltaphires, + vars_struct.TRT_PID + }; // Calculate the actual likelihood value and fill the return object - result = this->evaluateLikelihood(vec, vars_struct.eT, vars_struct.eta, vars_struct.ip); + result = this->evaluateLikelihood( + vec, vars_struct.eT, vars_struct.eta, vars_struct.ip); return result; } double -Root::TElectronLikelihoodTool::evaluateLikelihood(const std::vector<float>& varVector, - double et, - double eta, - double ip) const +Root::TElectronLikelihoodTool::evaluateLikelihood( + const std::vector<float>& varVector, + double et, + double eta, + double ip) const { std::vector<double> vec; for (unsigned int var = 0; var < s_fnVariables; var++) { @@ -726,10 +774,11 @@ Root::TElectronLikelihoodTool::evaluateLikelihood(const std::vector<float>& varV } double -Root::TElectronLikelihoodTool::evaluateLikelihood(const std::vector<double>& varVector, - double et, - double eta, - double ip) const +Root::TElectronLikelihoodTool::evaluateLikelihood( + const std::vector<double>& varVector, + double et, + double eta, + double ip) const { const double GeV = 1000; @@ -737,7 +786,8 @@ Root::TElectronLikelihoodTool::evaluateLikelihood(const std::vector<double>& var unsigned int etabin = getLikelihoodEtaBin(eta); unsigned int ipbin = getIpBin(ip); - ATH_MSG_DEBUG("et: " << et << " eta: " << eta << " etbin: " << etbin << " etabin: " << etabin); + ATH_MSG_DEBUG("et: " << et << " eta: " << eta << " etbin: " << etbin + << " etabin: " << etabin); if (etbin >= s_fnEtBinsHist) { ATH_MSG_WARNING("skipping etbin " << etbin << ", et " << et); @@ -769,7 +819,8 @@ Root::TElectronLikelihoodTool::evaluateLikelihood(const std::vector<double>& var continue; } // Don't use TRT for outer eta bins (2.01,2.37) - if (((etabin == 8) || (etabin == 9)) && (varstr.find(TRT_string) != std::string::npos)) { + if (((etabin == 8) || (etabin == 9)) && + (varstr.find(TRT_string) != std::string::npos)) { continue; } // Don't use f3 for outer eta bin (2.37) @@ -788,19 +839,24 @@ Root::TElectronLikelihoodTool::evaluateLikelihood(const std::vector<double>& var } for (unsigned int s_or_b = 0; s_or_b < 2; s_or_b++) { - int bin = fPDFbins[s_or_b][ipbin][etbin][etabin][var]->FindBin(varVector[var]); + int bin = + fPDFbins[s_or_b][ipbin][etbin][etabin][var]->FindBin(varVector[var]); double prob = 0; if (m_doSmoothBinInterpolation) { prob = InterpolatePdfs(s_or_b, ipbin, et, eta, bin, var); } else { - double integral = double(fPDFbins[s_or_b][ipbin][etbin][etabin][var]->Integral()); + double integral = + double(fPDFbins[s_or_b][ipbin][etbin][etabin][var]->Integral()); if (integral == 0) { ATH_MSG_WARNING("Error! PDF integral == 0!"); return -1.35; } - prob = double(fPDFbins[s_or_b][ipbin][etbin][etabin][var]->GetBinContent(bin)) / integral; + prob = + double( + fPDFbins[s_or_b][ipbin][etbin][etabin][var]->GetBinContent(bin)) / + integral; } if (s_or_b == 0) { @@ -858,14 +914,17 @@ Root::TElectronLikelihoodTool::TransformLikelihoodOutput(double ps, // - pileup_max = max nvtx or mu for calculating the transform. Any larger // pileup values will use this maximum value in the transform. - if (m_discHardCutForPileupTransform.empty() || m_discHardCutSlopeForPileupTransform.empty() || + if (m_discHardCutForPileupTransform.empty() || + m_discHardCutSlopeForPileupTransform.empty() || m_discLooseForPileupTransform.empty()) { - ATH_MSG_WARNING("Vectors needed for pileup-dependent transform not correctly filled! " - "Skipping the transform."); + ATH_MSG_WARNING( + "Vectors needed for pileup-dependent transform not correctly filled! " + "Skipping the transform."); return disc; } - if (m_doCentralityTransform && m_discHardCutQuadForPileupTransform.empty()) { + if (m_doCentralityTransform && + m_discHardCutQuadForPileupTransform.empty()) { ATH_MSG_WARNING("Vectors needed for centrality-dependent transform not " "correctly filled! " "Skipping the transform."); @@ -876,30 +935,43 @@ Root::TElectronLikelihoodTool::TransformLikelihoodOutput(double ps, double disc_hard_cut_ref = 0; double disc_hard_cut_ref_slope = 0; - double disc_hard_cut_ref_quad = 0; // only used for heavy ion implementation of the LH + double disc_hard_cut_ref_quad = + 0; // only used for heavy ion implementation of the LH double disc_loose_ref = 0; double disc_max = m_discMaxForPileupTransform; double pileup_max = m_pileupMaxForPileupTransform; if (m_doSmoothBinInterpolation) { - disc_hard_cut_ref = InterpolateCuts( - m_discHardCutForPileupTransform, m_discHardCutForPileupTransform4GeV, et, eta); - disc_hard_cut_ref_slope = InterpolateCuts( - m_discHardCutSlopeForPileupTransform, m_discHardCutSlopeForPileupTransform4GeV, et, eta); + disc_hard_cut_ref = InterpolateCuts(m_discHardCutForPileupTransform, + m_discHardCutForPileupTransform4GeV, + et, + eta); + disc_hard_cut_ref_slope = + InterpolateCuts(m_discHardCutSlopeForPileupTransform, + m_discHardCutSlopeForPileupTransform4GeV, + et, + eta); if (m_doCentralityTransform) - disc_hard_cut_ref_quad = InterpolateCuts( - m_discHardCutQuadForPileupTransform, m_discHardCutQuadForPileupTransform4GeV, et, eta); - disc_loose_ref = - InterpolateCuts(m_discLooseForPileupTransform, m_discLooseForPileupTransform4GeV, et, eta); + disc_hard_cut_ref_quad = + InterpolateCuts(m_discHardCutQuadForPileupTransform, + m_discHardCutQuadForPileupTransform4GeV, + et, + eta); + disc_loose_ref = InterpolateCuts(m_discLooseForPileupTransform, + m_discLooseForPileupTransform4GeV, + et, + eta); } else { // default situation, in the case where 4-7 GeV bin is not defined if (et > 7000. || m_discHardCutForPileupTransform4GeV.empty()) { unsigned int etfinebinLH = getLikelihoodEtDiscBin(et, true); unsigned int ibin_combined = etfinebinLH * s_fnEtaBins + etabin; disc_hard_cut_ref = m_discHardCutForPileupTransform[ibin_combined]; - disc_hard_cut_ref_slope = m_discHardCutSlopeForPileupTransform[ibin_combined]; + disc_hard_cut_ref_slope = + m_discHardCutSlopeForPileupTransform[ibin_combined]; if (m_doCentralityTransform) - disc_hard_cut_ref_quad = m_discHardCutQuadForPileupTransform[ibin_combined]; + disc_hard_cut_ref_quad = + m_discHardCutQuadForPileupTransform[ibin_combined]; disc_loose_ref = m_discLooseForPileupTransform[ibin_combined]; } else { if (m_discHardCutForPileupTransform4GeV.empty() || @@ -910,23 +982,28 @@ Root::TElectronLikelihoodTool::TransformLikelihoodOutput(double ps, "bin! Skipping the transform."); return disc; } - if (m_doCentralityTransform && m_discHardCutQuadForPileupTransform4GeV.empty()) { + if (m_doCentralityTransform && + m_discHardCutQuadForPileupTransform4GeV.empty()) { ATH_MSG_WARNING("Vectors needed for centrality-dependent transform " "not correctly filled for 4-7 " "GeV bin! Skipping the transform."); return disc; } disc_hard_cut_ref = m_discHardCutForPileupTransform4GeV[etabin]; - disc_hard_cut_ref_slope = m_discHardCutSlopeForPileupTransform4GeV[etabin]; + disc_hard_cut_ref_slope = + m_discHardCutSlopeForPileupTransform4GeV[etabin]; if (m_doCentralityTransform) - disc_hard_cut_ref_quad = m_discHardCutQuadForPileupTransform4GeV[etabin]; + disc_hard_cut_ref_quad = + m_discHardCutQuadForPileupTransform4GeV[etabin]; disc_loose_ref = m_discLooseForPileupTransform4GeV[etabin]; } } - double ip_for_corr = std::min(ip, pileup_max); // turn off correction for values > pileup_max - double disc_hard_cut_ref_prime = disc_hard_cut_ref + disc_hard_cut_ref_slope * ip_for_corr + - disc_hard_cut_ref_quad * ip_for_corr * ip_for_corr; + double ip_for_corr = + std::min(ip, pileup_max); // turn off correction for values > pileup_max + double disc_hard_cut_ref_prime = + disc_hard_cut_ref + disc_hard_cut_ref_slope * ip_for_corr + + disc_hard_cut_ref_quad * ip_for_corr * ip_for_corr; if (disc <= disc_loose_ref) { // Below threshold for applying pileup correction @@ -935,15 +1012,15 @@ Root::TElectronLikelihoodTool::TransformLikelihoodOutput(double ps, double denom = double(disc_hard_cut_ref_prime - disc_loose_ref); if (denom < 0.001) denom = 0.001; - disc = - disc_loose_ref + (disc - disc_loose_ref) * (disc_hard_cut_ref - disc_loose_ref) / denom; + disc = disc_loose_ref + (disc - disc_loose_ref) * + (disc_hard_cut_ref - disc_loose_ref) / denom; } else if (disc_hard_cut_ref_prime < disc && disc <= disc_max) { // Between the hard cut and max reference points for pileup correction double denom = double(disc_max - disc_hard_cut_ref_prime); if (denom < 0.001) denom = 0.001; - disc = disc_hard_cut_ref + - (disc - disc_hard_cut_ref_prime) * (disc_max - disc_hard_cut_ref) / denom; + disc = disc_hard_cut_ref + (disc - disc_hard_cut_ref_prime) * + (disc_max - disc_hard_cut_ref) / denom; } } @@ -951,7 +1028,8 @@ Root::TElectronLikelihoodTool::TransformLikelihoodOutput(double ps, return disc; } -const double Root::TElectronLikelihoodTool::fIpBounds[IP_BINS + 1] = { 0., 500. }; +const double Root::TElectronLikelihoodTool::fIpBounds[IP_BINS + 1] = { 0., + 500. }; //--------------------------------------------------------------------------------------- // Gets the IP bin @@ -971,7 +1049,8 @@ unsigned int Root::TElectronLikelihoodTool::getLikelihoodEtaBin(double eta) const { const unsigned int nEtaBins = s_fnEtaBins; - const double etaBins[nEtaBins] = { 0.1, 0.6, 0.8, 1.15, 1.37, 1.52, 1.81, 2.01, 2.37, 2.47 }; + const double etaBins[nEtaBins] = { 0.1, 0.6, 0.8, 1.15, 1.37, + 1.52, 1.81, 2.01, 2.37, 2.47 }; for (unsigned int etaBin = 0; etaBin < nEtaBins; ++etaBin) { if (std::abs(eta) < etaBins[etaBin]) @@ -1003,16 +1082,20 @@ Root::TElectronLikelihoodTool::getLikelihoodEtHistBin(double eT) const //--------------------------------------------------------------------------------------- // Gets the Et bin [0-10] given the et (MeV) unsigned int -Root::TElectronLikelihoodTool::getLikelihoodEtDiscBin(double eT, const bool isLHbinning) const +Root::TElectronLikelihoodTool::getLikelihoodEtDiscBin( + double eT, + const bool isLHbinning) const { const double GeV = 1000; if (m_useOneExtraHighETLHBin && isLHbinning) { const unsigned int nEtBins = s_fnDiscEtBinsOneExtra; - const double eTBins[nEtBins] = { 10 * GeV, 15 * GeV, 20 * GeV, - 25 * GeV, 30 * GeV, 35 * GeV, - 40 * GeV, 45 * GeV, m_highETBinThreshold * GeV, - 6000 * GeV }; + const double eTBins[nEtBins] = { + 10 * GeV, 15 * GeV, 20 * GeV, + 25 * GeV, 30 * GeV, 35 * GeV, + 40 * GeV, 45 * GeV, m_highETBinThreshold * GeV, + 6000 * GeV + }; for (unsigned int eTBin = 0; eTBin < nEtBins; ++eTBin) { if (eT < eTBins[eTBin]) @@ -1023,8 +1106,9 @@ Root::TElectronLikelihoodTool::getLikelihoodEtDiscBin(double eT, const bool isLH } const unsigned int nEtBins = s_fnDiscEtBins; - const double eTBins[nEtBins] = { 10 * GeV, 15 * GeV, 20 * GeV, 25 * GeV, 30 * GeV, - 35 * GeV, 40 * GeV, 45 * GeV, 50 * GeV }; + const double eTBins[nEtBins] = { 10 * GeV, 15 * GeV, 20 * GeV, + 25 * GeV, 30 * GeV, 35 * GeV, + 40 * GeV, 45 * GeV, 50 * GeV }; for (unsigned int eTBin = 0; eTBin < nEtBins; ++eTBin) { if (eT < eTBins[eTBin]) @@ -1059,7 +1143,8 @@ Root::TElectronLikelihoodTool::getBinName(char* buffer, } //---------------------------------------------------------------------------------------- unsigned int -Root::TElectronLikelihoodTool::getLikelihoodBitmask(const std::string& vars) const +Root::TElectronLikelihoodTool::getLikelihoodBitmask( + const std::string& vars) const { unsigned int mask = 0x0; ATH_MSG_DEBUG("Variables to be used: "); @@ -1077,10 +1162,11 @@ Root::TElectronLikelihoodTool::getLikelihoodBitmask(const std::string& vars) con // Note that this will only perform the cut interpolation up to ~45 GeV, so // no smoothing is done above this for the high ET LH binning yet double -Root::TElectronLikelihoodTool::InterpolateCuts(const std::vector<double>& cuts, - const std::vector<double>& cuts_4gev, - double et, - double eta) const +Root::TElectronLikelihoodTool::InterpolateCuts( + const std::vector<double>& cuts, + const std::vector<double>& cuts_4gev, + double et, + double eta) const { int etbinLH = getLikelihoodEtDiscBin(et, true); int etabin = getLikelihoodEtaBin(eta); @@ -1106,8 +1192,9 @@ Root::TElectronLikelihoodTool::InterpolateCuts(const std::vector<double>& cuts, bin_width = 2000.; } const double GeV = 1000; - const double eTBins[9] = { 8.5 * GeV, 12.5 * GeV, 17.5 * GeV, 22.5 * GeV, 27.5 * GeV, - 32.5 * GeV, 37.5 * GeV, 42.5 * GeV, 47.5 * GeV }; + const double eTBins[9] = { 8.5 * GeV, 12.5 * GeV, 17.5 * GeV, + 22.5 * GeV, 27.5 * GeV, 32.5 * GeV, + 37.5 * GeV, 42.5 * GeV, 47.5 * GeV }; double bin_center = eTBins[etbinLH]; if (et > bin_center) { double cut_next = cut; @@ -1142,8 +1229,11 @@ Root::TElectronLikelihoodTool::InterpolatePdfs(unsigned int s_or_b, // interpolation scheme between cuts - so be careful! int etbin = getLikelihoodEtHistBin(et); // hist binning int etabin = getLikelihoodEtaBin(eta); - double integral = double(fPDFbins[s_or_b][ipbin][etbin][etabin][var]->Integral()); - double prob = double(fPDFbins[s_or_b][ipbin][etbin][etabin][var]->GetBinContent(bin)) / integral; + double integral = + double(fPDFbins[s_or_b][ipbin][etbin][etabin][var]->Integral()); + double prob = + double(fPDFbins[s_or_b][ipbin][etbin][etabin][var]->GetBinContent(bin)) / + integral; int Nbins = fPDFbins[s_or_b][ipbin][etbin][etabin][var]->GetNbinsX(); if (et > 42500.) { @@ -1179,7 +1269,8 @@ Root::TElectronLikelihoodTool::InterpolatePdfs(unsigned int s_or_b, double prob_next = prob; if (etbin + 1 <= 6) { // account for potential histogram bin inequalities - int NbinsPlus = fPDFbins[s_or_b][ipbin][etbin + 1][etabin][var]->GetNbinsX(); + int NbinsPlus = + fPDFbins[s_or_b][ipbin][etbin + 1][etabin][var]->GetNbinsX(); int binplus = bin; if (Nbins < NbinsPlus) { binplus = int(round(bin * (Nbins / NbinsPlus))); @@ -1187,9 +1278,12 @@ Root::TElectronLikelihoodTool::InterpolatePdfs(unsigned int s_or_b, binplus = int(round(bin * (NbinsPlus / Nbins))); } // do interpolation - double integral_next = double(fPDFbins[s_or_b][ipbin][etbin + 1][etabin][var]->Integral()); - prob_next = double(fPDFbins[s_or_b][ipbin][etbin + 1][etabin][var]->GetBinContent(binplus)) / - integral_next; + double integral_next = + double(fPDFbins[s_or_b][ipbin][etbin + 1][etabin][var]->Integral()); + prob_next = + double(fPDFbins[s_or_b][ipbin][etbin + 1][etabin][var]->GetBinContent( + binplus)) / + integral_next; return prob + (prob_next - prob) * (et - bin_center) / (bin_width); } } @@ -1197,16 +1291,20 @@ Root::TElectronLikelihoodTool::InterpolatePdfs(unsigned int s_or_b, double prob_before = prob; if (etbin - 1 >= 0) { // account for potential histogram bin inequalities - int NbinsMinus = fPDFbins[s_or_b][ipbin][etbin - 1][etabin][var]->GetNbinsX(); + int NbinsMinus = + fPDFbins[s_or_b][ipbin][etbin - 1][etabin][var]->GetNbinsX(); int binminus = bin; if (Nbins < NbinsMinus) { binminus = int(round(bin * (Nbins / NbinsMinus))); } else if (Nbins > NbinsMinus) { binminus = int(round(bin * (NbinsMinus / Nbins))); } - double integral_before = double(fPDFbins[s_or_b][ipbin][etbin - 1][etabin][var]->Integral()); - prob_before = double(fPDFbins[s_or_b][ipbin][etbin - 1][etabin][var]->GetBinContent(binminus)) / - integral_before; + double integral_before = + double(fPDFbins[s_or_b][ipbin][etbin - 1][etabin][var]->Integral()); + prob_before = + double(fPDFbins[s_or_b][ipbin][etbin - 1][etabin][var]->GetBinContent( + binminus)) / + integral_before; } return prob - (prob - prob_before) * (bin_center - et) / (bin_width); } diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/TElectronLikelihoodTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/TElectronLikelihoodTool.h index cc7a6066388d2717a7336f185973b7921672d702..e7006e8f5e877c2f794d66c6a6fe5378b56ac46b 100644 --- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/TElectronLikelihoodTool.h +++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/TElectronLikelihoodTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // Dear emacs, this is -*-c++-*- @@ -336,7 +336,8 @@ private: static const unsigned int s_fnEtaBins = 10; static const unsigned int s_fnVariables = 13; // 5D array of ptr to SafeTH1 // [sig(0)/bkg(1)][ip][et][eta][variable] - EGSelectors::SafeTH1* fPDFbins[2][IP_BINS][s_fnEtBinsHist][s_fnEtaBins][s_fnVariables]; + EGSelectors::SafeTH1* fPDFbins[2][IP_BINS][s_fnEtBinsHist][s_fnEtaBins] + [s_fnVariables]; static const std::string fVariables[s_fnVariables]; unsigned int getIpBin(double ip) const;