diff --git a/Reconstruction/PanTau/PanTauAlgs/CMakeLists.txt b/Reconstruction/PanTau/PanTauAlgs/CMakeLists.txt index 42ab5dc4284c01ccd9f4403ba79220a034ce6189..34d053bcb24adfbbe37ebf8bec2b1f5ee9575f68 100644 --- a/Reconstruction/PanTau/PanTauAlgs/CMakeLists.txt +++ b/Reconstruction/PanTau/PanTauAlgs/CMakeLists.txt @@ -1,6 +1,4 @@ -################################################################################ -# Package: PanTauAlgs -################################################################################ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration # Declare the package name: atlas_subdir( PanTauAlgs ) @@ -10,7 +8,7 @@ if( NOT XAOD_ANALYSIS ) find_package( CLHEP ) endif() find_package( Eigen ) -find_package( ROOT COMPONENTS MathMore Matrix Core Tree Hist RIO pthread Minuit Minuit2 Physics HistPainter Rint ) +find_package( ROOT COMPONENTS MathMore Matrix Core Tree Hist RIO pthread Rint ) atlas_add_root_dictionary( PanTauAlgs PanTauAlgsCintDict ROOT_HEADERS @@ -44,8 +42,8 @@ if( NOT XAOD_STANDALONE ) Root/*.cxx src/components/*.cxx ${PanTauAlgsCintDict} INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps NavFourMom xAODPFlow xAODTau xAODParticleEvent GaudiKernel CaloEvent AthenaKernel StoreGateLib SGtests GeoPrimitives FourMom FourMomUtils xAODTracking Particle eflowEvent MVAUtils tauEvent tauRecToolsLib PathResolver VxVertex TrkVertexFitterInterfaces ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps xAODPFlow xAODTau xAODParticleEvent GaudiKernel AthenaKernel StoreGateLib FourMom xAODTracking Particle eflowEvent MVAUtils tauRecToolsLib PathResolver ) endif() # Install files from the package: -atlas_install_python_modules( python/*.py ) +atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/HelperFunctions.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/HelperFunctions.h index 5626bf8d5b90c37dcaa40704d69aace3d9bf3895..ed2e8a9dd1383a469de76ef7565852d8c874187d 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/HelperFunctions.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/HelperFunctions.h @@ -7,18 +7,16 @@ #include <string> #include <iostream> +#include <vector> #include "AsgMessaging/AsgMessaging.h" #include "AsgTools/ToolHandle.h" -#include "xAODTau/TauJet.h" -#include "xAODPFlow/PFO.h" - class TLorentzVector; class TVector3; namespace PanTau { - class TauConstituent2; + class TauConstituent; } class TVector3; @@ -37,12 +35,8 @@ namespace PanTau { virtual ~HelperFunctions () {}; - - virtual void dumpFourMomentum(TLorentzVector FourMom) const; - virtual void dumpTauConstituent2(PanTau::TauConstituent2* tauConstituent) const; - - TauConstituent2* getNeutralConstWithLargestAngle(TLorentzVector charged, - std::vector<PanTau::TauConstituent2*> neutral); + TauConstituent* getNeutralConstWithLargestAngle(TLorentzVector charged, + std::vector<PanTau::TauConstituent*> neutral); virtual std::string convertNumberToString(double x) const; diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_DetailsArranger.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_DetailsArranger.h index 4e3a746a3457294c115082bf7b94a679d5b4baac..a484f75992469b7ad3e50eb91969aa202e4c3ebf 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_DetailsArranger.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_DetailsArranger.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef PANTAUALGS_ITOOL_DETAILSARRANGER_H @@ -9,12 +9,10 @@ #include "xAODParticleEvent/ParticleContainer.h" -//class Jet; namespace PanTau { - class PanTauSeed2; + class PanTauSeed; } - namespace PanTau { /** @class ITool_DetailsArranger @@ -30,9 +28,10 @@ namespace PanTau { public: virtual bool isInitialized() = 0; - virtual StatusCode execute(PanTau::PanTauSeed2* inSeed, xAOD::ParticleContainer& pi0Container) = 0; + virtual StatusCode execute(PanTau::PanTauSeed* inSeed, xAOD::ParticleContainer& pi0Container) = 0; }; } + #endif // PANTAUALGS_ITAUDISCRIMINANTTOOL_H diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_InputConverter.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_InputConverter.h index ad85559cfda032a6e746887c9a15263e71412f40..0f776a16b740a11d99946bc1381be7336752edca 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_InputConverter.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_InputConverter.h @@ -5,27 +5,21 @@ #ifndef PANTAUALGS_ITOOL_INPUTCONVERTER_H #define PANTAUALGS_ITOOL_INPUTCONVERTER_H -// Gaudi #include "AsgTools/IAsgTool.h" #include <string> - -//! xAOD EDM #include "xAODPFlow/PFO.h" #include "xAODTau/TauJet.h" namespace PanTau{ - class TauConstituent2; + class TauConstituent; } namespace Rec { class TrackParticle; } - - - namespace PanTau { /** @class ITool_InputConverter @@ -43,8 +37,8 @@ namespace PanTau { virtual bool isInitialized() = 0; //PFO Converter (r19+) - virtual StatusCode ConvertToTauConstituent2(xAOD::PFO* pfo, - PanTau::TauConstituent2* &tauConstituent, + virtual StatusCode ConvertToTauConstituent(xAOD::PFO* pfo, + PanTau::TauConstituent* &tauConstituent, const xAOD::TauJet* tauJet) const = 0; }; diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_ModeDiscriminator.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_ModeDiscriminator.h index 49f23f34fb898dd8c912f938f87ebf9d7d6c01d2..27767b1a0bd704018e8373fb40872b9a12954b96 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_ModeDiscriminator.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_ModeDiscriminator.h @@ -7,13 +7,10 @@ #include "AsgTools/IAsgTool.h" - -//class Jet; namespace PanTau { - class PanTauSeed2; + class PanTauSeed; } - namespace PanTau { /** @class ITool_ModeDiscriminator @@ -29,7 +26,7 @@ namespace PanTau { public: virtual bool isInitialized() = 0; - virtual double getResponse(PanTau::PanTauSeed2* inSeed, bool& isOK) = 0; + virtual double getResponse(PanTau::PanTauSeed* inSeed, bool& isOK) = 0; }; } diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_PanTauTools.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_PanTauTools.h index 6bc4b67a71baf92271a3eaaa3160e807e5369570..b192d2f28a6668bdf8195740b239c999172a11b9 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_PanTauTools.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_PanTauTools.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef PANTAUALGS_ITOOL_PANTAUTOOLS_H @@ -17,9 +17,9 @@ namespace PanTau { - class TauFeature2; - class PanTauSeed2; - class TauConstituent2; + class TauFeature; + class PanTauSeed; + class TauConstituent; } @@ -44,7 +44,7 @@ namespace PanTau { virtual bool isInitialized() = 0; // used in Tool_FeatureExtractor, Tool_DecayModeDeterminator and Tool_DetailsArranger: - virtual StatusCode execute(PanTau::PanTauSeed2* inSeed) = 0; + virtual StatusCode execute(PanTau::PanTauSeed* inSeed) = 0; }; diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_TauConstituentGetter.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_TauConstituentGetter.h index 7fc2f70ed1fd3b2e667fb1d56dee1ba17acb46d2..ba2077f5d2f486e1f0bc142373cd7df72061d6fa 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_TauConstituentGetter.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_TauConstituentGetter.h @@ -5,13 +5,12 @@ #ifndef PANTAUALGS_ITOOL_TAUCONSTITUENTGETTER_H #define PANTAUALGS_ITOOL_TAUCONSTITUENTGETTER_H -// Gaudi #include "AsgTools/IAsgTool.h" #include <string> namespace PanTau{ - class TauConstituent2; + class TauConstituent; } #include "xAODTau/TauJet.h" @@ -33,7 +32,7 @@ namespace PanTau { virtual bool isInitialized() = 0; virtual StatusCode GetTauConstituents(const xAOD::TauJet* tauJet, - std::vector<TauConstituent2*>& outputList, + std::vector<TauConstituent*>& outputList, std::string algName) const = 0; }; diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_TauConstituentSelector.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_TauConstituentSelector.h index c6a932cc2df770feae07b38455005de3ba5e684f..1a8ca7aa712369d6286f8603e608ce79ab46c54e 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_TauConstituentSelector.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_TauConstituentSelector.h @@ -5,7 +5,6 @@ #ifndef PANTAUALGS_ITOOL_TAUCONSTITUENTSELECTOR_H #define PANTAUALGS_ITOOL_TAUCONSTITUENTSELECTOR_H -// Gaudi #include "AsgTools/IAsgTool.h" #include <vector> @@ -26,8 +25,8 @@ namespace PanTau { public: virtual bool isInitialized() = 0; - virtual StatusCode SelectTauConstituents(std::vector<TauConstituent2*> inputList, - std::vector<TauConstituent2*>& outputList) const = 0; + virtual StatusCode SelectTauConstituents(std::vector<TauConstituent*> inputList, + std::vector<TauConstituent*>& outputList) const = 0; }; } diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/PanTauSeed.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/PanTauSeed.h index 1af8f302d5e4edde0bda5e3b0524a891db15d1aa..3f8798d9a79332d430256ed6724da122e1f6fe8f 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/PanTauSeed.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/PanTauSeed.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef PANTAUALGS_PANTAUSEED_H @@ -21,7 +21,7 @@ namespace PanTau { - class PanTauSeed2 : public xAOD::IParticle { + class PanTauSeed : public xAOD::IParticle { // IParticle implementation as in // http://acode-browser.usatlas.bnl.gov/lxr/source/atlas/Event/xAOD/xAODEgamma/xAODEgamma/versions/Egamma_v1.h // http://acode-browser.usatlas.bnl.gov/lxr/source/atlas/Event/xAOD/xAODEgamma/Root/Egamma_v1.cxx @@ -58,10 +58,10 @@ namespace PanTau { static int getDecayMode(int nCharged, int nNeutral); static std::string getDecayModeName(int decayMode); - PanTauSeed2(); - ~PanTauSeed2(); - PanTauSeed2(const PanTauSeed2& seed); - PanTauSeed2& operator=(const PanTauSeed2& seed); + PanTauSeed(); + ~PanTauSeed(); + PanTauSeed(const PanTauSeed& seed); + PanTauSeed& operator=(const PanTauSeed& seed); /// @name xAOD::IParticle functions @@ -114,35 +114,35 @@ namespace PanTau { /** Main constructor to be used */ - PanTauSeed2( std::string nameInputAlgorithm, - const xAOD::TauJet* tauJet, - std::vector<PanTau::TauConstituent2*> tauConstituents, - std::vector<PanTau::TauConstituent2*> tauConstituentsWithUnselected, - std::vector<int> pantauSeed_TechnicalQuality - ); + PanTauSeed( std::string nameInputAlgorithm, + const xAOD::TauJet* tauJet, + std::vector<PanTau::TauConstituent*> tauConstituents, + std::vector<PanTau::TauConstituent*> tauConstituentsWithUnselected, + std::vector<int> pantauSeed_TechnicalQuality + ); /** Constructor for invalid seeds */ - PanTauSeed2( std::string nameInputAlgorithm, + PanTauSeed( std::string nameInputAlgorithm, const xAOD::TauJet* tauJet, std::vector<int> pantauSeed_TechnicalQuality ); std::string getNameInputAlgorithm() const; const xAOD::TauJet* getTauJet() const; - PanTau::TauFeature2* getFeatures() const; + PanTau::TauFeature* getFeatures() const; TLorentzVector getProtoMomentumCore() const; TLorentzVector getProtoMomentumWide() const; bool getIsValidSeed() const; std::vector<int> getTechnicalQuality() const; bool isOfTechnicalQuality(int pantauSeed_TechnicalQuality) const; - std::vector< std::vector<PanTau::TauConstituent2*> > getConstituents() const; - std::vector<PanTau::TauConstituent2*> getConstituentsAsList_Core() const; - std::vector<PanTau::TauConstituent2*> getConstituentsAsList_Wide() const; - std::vector<PanTau::TauConstituent2*> getConstituentsAsList_All() const; + std::vector< std::vector<PanTau::TauConstituent*> > getConstituents() const; + std::vector<PanTau::TauConstituent*> getConstituentsAsList_Core() const; + std::vector<PanTau::TauConstituent*> getConstituentsAsList_Wide() const; + std::vector<PanTau::TauConstituent*> getConstituentsAsList_All() const; - std::vector<PanTau::TauConstituent2*> getConstituentsOfType(int tauConstituent_Type, bool& foundit); + std::vector<PanTau::TauConstituent*> getConstituentsOfType(int tauConstituent_Type, bool& foundit); int getNumberOfConstituentsOfType(int tauConstituent_Type); TLorentzVector getSubsystemHLV(int tauConstituent_Type, bool& foundit); @@ -177,12 +177,12 @@ namespace PanTau { //place to store which input alg created this pantauseed: eflowRec, CellBased, ClusterBased.. std::string m_NameInputAlgorithm; - //pointer to the TauJet this PanTauSeed2 was build from (pointer not owned by PanTauSeed) + //pointer to the TauJet this PanTauSeed was build from (pointer not owned by PanTauSeed) const xAOD::TauJet* m_TauJet; //for each type of tauConstituent, a list of constituents (of that type) - // the TauConstituent2 objects are owned by PanTauSeed2 (this class), so they need to be deleted in the destructor - std::vector< std::vector<PanTau::TauConstituent2*> > m_Constituents; + // the TauConstituent objects are owned by PanTauSeed (this class), so they need to be deleted in the destructor + std::vector< std::vector<PanTau::TauConstituent*> > m_Constituents; //the momentum as calculated by using all constituents added to this seed TLorentzVector m_ProtoMomentum_Wide; @@ -197,13 +197,13 @@ namespace PanTau { std::vector< TLorentzVector > m_TypeHLVs; //also store constituents as flat list for easier access later on - std::vector<PanTau::TauConstituent2*> m_ConstituentsList_Core; //only objects in core region - std::vector<PanTau::TauConstituent2*> m_ConstituentsList_Wide; //objects out of core region up to 0.4 - std::vector<PanTau::TauConstituent2*> m_ConstituentsList_AllSelected; //all selected objects for this seed + std::vector<PanTau::TauConstituent*> m_ConstituentsList_Core; //only objects in core region + std::vector<PanTau::TauConstituent*> m_ConstituentsList_Wide; //objects out of core region up to 0.4 + std::vector<PanTau::TauConstituent*> m_ConstituentsList_AllSelected; //all selected objects for this seed //for memory reasons: // pass list of selected AND unselected pfos to seed, which will take ownership - std::vector<PanTau::TauConstituent2*> m_ConstituentsList_All; //all objects for this seed, selected and unselected + std::vector<PanTau::TauConstituent*> m_ConstituentsList_All; //all objects for this seed, selected and unselected //the decay mode int m_DecayMode_BySubAlg; @@ -214,7 +214,7 @@ namespace PanTau { //! is set) //the features of this pantauseed - PanTau::TauFeature2* m_Features; + PanTau::TauFeature* m_Features; }; @@ -226,23 +226,23 @@ namespace PanTau { } //end name space pantau -inline std::string PanTau::PanTauSeed2::getNameInputAlgorithm() const {return m_NameInputAlgorithm;} -inline const xAOD::TauJet* PanTau::PanTauSeed2::getTauJet() const {return m_TauJet;} -inline PanTau::TauFeature2* PanTau::PanTauSeed2::getFeatures() const {return m_Features;} -inline TLorentzVector PanTau::PanTauSeed2::getProtoMomentumWide() const {return m_ProtoMomentum_Wide;} -inline TLorentzVector PanTau::PanTauSeed2::getProtoMomentumCore() const {return m_ProtoMomentum_Core;} -inline std::vector< std::vector<PanTau::TauConstituent2*> > PanTau::PanTauSeed2::getConstituents() const {return m_Constituents;} -inline std::vector<PanTau::TauConstituent2*> PanTau::PanTauSeed2::getConstituentsAsList_Core() const {return m_ConstituentsList_Core;} -inline std::vector<PanTau::TauConstituent2*> PanTau::PanTauSeed2::getConstituentsAsList_Wide() const {return m_ConstituentsList_Wide;} -inline std::vector<PanTau::TauConstituent2*> PanTau::PanTauSeed2::getConstituentsAsList_All() const {return m_ConstituentsList_All;} -inline TLorentzVector PanTau::PanTauSeed2::getFinalMomentum() const {return m_FinalMomentum;} -inline int PanTau::PanTauSeed2::getDecayModeBySubAlg() const {return m_DecayMode_BySubAlg;} -inline int PanTau::PanTauSeed2::getDecayModeByPanTau() const {return m_DecayMode_ByPanTau;} -inline bool PanTau::PanTauSeed2::getIsValidSeed() const {return m_IsValidSeed;} -inline std::vector<int> PanTau::PanTauSeed2::getTechnicalQuality() const {return m_TechnicalQuality;} - -inline void PanTau::PanTauSeed2::setFinalMomentum(TLorentzVector finalMom) {m_FinalMomentum = finalMom;} -inline void PanTau::PanTauSeed2::setDecayModeByPanTau(int decayModePanTau) {m_DecayMode_ByPanTau = decayModePanTau;} +inline std::string PanTau::PanTauSeed::getNameInputAlgorithm() const {return m_NameInputAlgorithm;} +inline const xAOD::TauJet* PanTau::PanTauSeed::getTauJet() const {return m_TauJet;} +inline PanTau::TauFeature* PanTau::PanTauSeed::getFeatures() const {return m_Features;} +inline TLorentzVector PanTau::PanTauSeed::getProtoMomentumWide() const {return m_ProtoMomentum_Wide;} +inline TLorentzVector PanTau::PanTauSeed::getProtoMomentumCore() const {return m_ProtoMomentum_Core;} +inline std::vector< std::vector<PanTau::TauConstituent*> > PanTau::PanTauSeed::getConstituents() const {return m_Constituents;} +inline std::vector<PanTau::TauConstituent*> PanTau::PanTauSeed::getConstituentsAsList_Core() const {return m_ConstituentsList_Core;} +inline std::vector<PanTau::TauConstituent*> PanTau::PanTauSeed::getConstituentsAsList_Wide() const {return m_ConstituentsList_Wide;} +inline std::vector<PanTau::TauConstituent*> PanTau::PanTauSeed::getConstituentsAsList_All() const {return m_ConstituentsList_All;} +inline TLorentzVector PanTau::PanTauSeed::getFinalMomentum() const {return m_FinalMomentum;} +inline int PanTau::PanTauSeed::getDecayModeBySubAlg() const {return m_DecayMode_BySubAlg;} +inline int PanTau::PanTauSeed::getDecayModeByPanTau() const {return m_DecayMode_ByPanTau;} +inline bool PanTau::PanTauSeed::getIsValidSeed() const {return m_IsValidSeed;} +inline std::vector<int> PanTau::PanTauSeed::getTechnicalQuality() const {return m_TechnicalQuality;} + +inline void PanTau::PanTauSeed::setFinalMomentum(TLorentzVector finalMom) {m_FinalMomentum = finalMom;} +inline void PanTau::PanTauSeed::setDecayModeByPanTau(int decayModePanTau) {m_DecayMode_ByPanTau = decayModePanTau;} inline static void PanTau::SetP4EEtaPhiM(TLorentzVector& hlv, double e, double eta, double phi, double m ){ diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauConstituent.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauConstituent.h index 3748de965a13f4fe48ddfec2b56ebad85d568d8a..bff44eddea1ccd7a86e9a26db23476c2b80ef3cf 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauConstituent.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauConstituent.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -27,7 +27,7 @@ namespace PanTau { */ - class TauConstituent2 : public xAOD::IParticle { + class TauConstituent : public xAOD::IParticle { public: @@ -60,7 +60,7 @@ namespace PanTau { static double DefaultCharge() {return -47111337;} static std::string AllConstituentsName() {return "All";} - static std::string getTypeName(PanTau::TauConstituent2::Type aType); + static std::string getTypeName(PanTau::TauConstituent::Type aType); static bool isNeutralType(int tauConstituentType); static bool isCoreType(int tauConstituentType); @@ -68,14 +68,14 @@ namespace PanTau { /** Default Constructor for POOL. Do not use! */ - TauConstituent2(); + TauConstituent(); /** * @param itsMomentum The P4EEtaPhiM of this particle * @param itsType The type of this particle using this class' enumeration * @param itsBDTValue If a BDT was used ot ID this particle, provide the BDT response */ - TauConstituent2(TLorentzVector itsMomentum, + TauConstituent(TLorentzVector itsMomentum, int itsCharge, std::vector<int> itsType, double itsBDTValue, @@ -83,14 +83,14 @@ namespace PanTau { /** Destructor */ - virtual ~TauConstituent2(); + virtual ~TauConstituent(); /** Copy Constructor */ - TauConstituent2(const TauConstituent2& tauConst); + TauConstituent(const TauConstituent& tauConst); /** Assignment operator */ - TauConstituent2& operator=(const TauConstituent2& tauConst); + TauConstituent& operator=(const TauConstituent& tauConst); /// @name xAOD::IParticle functions /// These are already virtual due to IParticle @@ -141,19 +141,19 @@ namespace PanTau { //no setter functions needed as all properties are set in constructor - void removeTypeFlag(TauConstituent2::Type aType); + void removeTypeFlag(TauConstituent::Type aType); //Getter functions std::vector<std::string> getTypeName() const; std::string getTypeNameString() const; std::vector<int> getTypeFlags() const; - bool isOfType(TauConstituent2::Type aType) const; + bool isOfType(TauConstituent::Type aType) const; double getBDTValue() const; int getCharge() const; xAOD::PFO* getPFO() const; - void addShot(TauConstituent2* shot); - std::vector<TauConstituent2*> getShots(); + void addShot(TauConstituent* shot); + std::vector<TauConstituent*> getShots(); unsigned int getNShots(); void setNPhotonsInShot(int nPhotons); @@ -179,7 +179,7 @@ namespace PanTau { xAOD::PFO* m_PFOLink; // the constituents in there are owned by this! delete them! - std::vector<TauConstituent2*> m_Shots; + std::vector<TauConstituent*> m_Shots; int m_nPhotonsInShot; diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauFeature.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauFeature.h index 31d06e93cb2c4bd4ce35e3a9e64a4c59ef94c010..96464d7d7097d2acce370475997faaab2cec83c2 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauFeature.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauFeature.h @@ -17,7 +17,7 @@ namespace PanTau { @author Sebastian.Fleischmann@cern.ch */ -class TauFeature2 { +class TauFeature { typedef std::map<std::string, double> FeatureMap; typedef FeatureMap::iterator FeatureMapIter; @@ -28,10 +28,10 @@ typedef VectorFeatureMap::const_iterator VectorFeatureMapConstIter; public: /** Default constructor */ - TauFeature2(); + TauFeature(); /** Destructor */ - virtual ~TauFeature2(); + virtual ~TauFeature(); /** returns the value of the feature given by its name*/ double value(const std::string& ItsName, bool& isValid) const; @@ -56,7 +56,7 @@ public: int nVecValues() const; - void add(PanTau::TauFeature2* otherFeatures); + void add(PanTau::TauFeature* otherFeatures); void addFeaturesFromMap(std::map<std::string, double>, std::string prefix); @@ -69,7 +69,6 @@ protected: }; - } #endif // PANTAUALGSTAUFEATURE_H diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_DecayModeDeterminator.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_DecayModeDeterminator.h index 482753e2932d7fa7b634a0255065f6c8e8df881a..61e6325f7b775b41859249a82399defa34d33ae3 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_DecayModeDeterminator.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_DecayModeDeterminator.h @@ -5,21 +5,17 @@ #ifndef PANTAUALGS_TOOL_DECAYMODEDETERMINATOR_H #define PANTAUALGS_TOOL_DECAYMODEDETERMINATOR_H -//! C++ -#include <vector> #include <string> -//! Gaudi #include "AsgTools/AsgTool.h" #include "AsgTools/ToolHandle.h" -//! PanTau #include "PanTauAlgs/ITool_PanTauTools.h" #include "PanTauAlgs/ITool_ModeDiscriminator.h" #include "PanTauAlgs/ITool_InformationStore.h" namespace PanTau { - class PanTauSeed2; + class PanTauSeed; } @@ -48,24 +44,21 @@ namespace PanTau { virtual StatusCode initialize(); - virtual StatusCode execute(PanTau::PanTauSeed2* inSeed); + virtual StatusCode execute(PanTau::PanTauSeed* inSeed); private: - ToolHandle<PanTau::ITool_InformationStore> m_Tool_InformationStore; - + ToolHandle<PanTau::ITool_InformationStore> m_Tool_InformationStore; ToolHandle<PanTau::ITool_ModeDiscriminator> m_Tool_ModeDiscriminator_1p0n_vs_1p1n; ToolHandle<PanTau::ITool_ModeDiscriminator> m_Tool_ModeDiscriminator_1p1n_vs_1pXn; ToolHandle<PanTau::ITool_ModeDiscriminator> m_Tool_ModeDiscriminator_3p0n_vs_3pXn; - std::string m_Tool_InformationStoreName; std::string m_Tool_ModeDiscriminator_1p0n_vs_1p1nName; std::string m_Tool_ModeDiscriminator_1p1n_vs_1pXnName; std::string m_Tool_ModeDiscriminator_3p0n_vs_3pXnName; - - + //configurables to be retrieved from information store //variable prefix for the decay mode diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_DetailsArranger.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_DetailsArranger.h index 7357391431d6c4596346541e7f1a12a23a1952a5..0a46d074769479b43154b0a6f419758e08ee2483 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_DetailsArranger.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_DetailsArranger.h @@ -8,23 +8,18 @@ #include <string> #include <vector> -//! ASG #include "AsgTools/AsgTool.h" #include "AsgTools/ToolHandle.h" -//! xAOD EDM #include "xAODTau/TauJet.h" +#include "xAODParticleEvent/ParticleContainer.h" -//! PanTau #include "PanTauAlgs/ITool_DetailsArranger.h" #include "PanTauAlgs/ITool_InformationStore.h" - #include "PanTauAlgs/TauConstituent.h" -#include "xAODParticleEvent/ParticleContainer.h" - namespace PanTau { - class PanTauSeed2; + class PanTauSeed; class PanTauDetails; } @@ -52,21 +47,21 @@ namespace PanTau { virtual StatusCode initialize(); - virtual StatusCode execute(PanTau::PanTauSeed2* inSeed, xAOD::ParticleContainer& pi0Container); + virtual StatusCode execute(PanTau::PanTauSeed* inSeed, xAOD::ParticleContainer& pi0Container); protected: ToolHandle<PanTau::ITool_InformationStore> m_Tool_InformationStore; std::string m_Tool_InformationStoreName; - void addPanTauDetailToTauJet(PanTauSeed2* inSeed, + void addPanTauDetailToTauJet(PanTauSeed* inSeed, std::string featName, xAOD::TauJetParameters::PanTauDetails detailEnum, PanTauDetailsType detailType) const; - StatusCode arrangePFOLinks(PanTau::PanTauSeed2* inSeed, xAOD::TauJet* tauJet, xAOD::ParticleContainer& pi0Container); + StatusCode arrangePFOLinks(PanTau::PanTauSeed* inSeed, xAOD::TauJet* tauJet, xAOD::ParticleContainer& pi0Container); - void SetHLVTau(PanTau::PanTauSeed2* inSeed, xAOD::TauJet* tauJet, std::string inputAlg, std::string varTypeName_Basic); + void SetHLVTau(PanTau::PanTauSeed* inSeed, xAOD::TauJet* tauJet, std::string inputAlg, std::string varTypeName_Basic); std::vector< ElementLink< xAOD::PFOContainer > > PreselectNeutralLinks(std::vector< ElementLink<xAOD::PFOContainer> > neutralPFOLinks, xAOD::TauJet* tauJet); @@ -78,7 +73,7 @@ namespace PanTau { void SetNeutralConstituentVectorMasses(std::vector< ElementLink<xAOD::PFOContainer> > neutralPFOLinks, double mass); - std::vector< ElementLink< xAOD::PFOContainer > > CollectConstituentsAsPFOLinks( PanTau::PanTauSeed2* inSeed, std::vector< ElementLink< xAOD::PFOContainer > > cellbased_neutralPFOLinks, PanTau::TauConstituent2::Type type ); + std::vector< ElementLink< xAOD::PFOContainer > > CollectConstituentsAsPFOLinks( PanTau::PanTauSeed* inSeed, std::vector< ElementLink< xAOD::PFOContainer > > cellbased_neutralPFOLinks, PanTau::TauConstituent::Type type ); void createPi0Vectors(xAOD::TauJet* tauJet, std::vector<TLorentzVector>& vPi0s, std::vector< std::vector< ElementLink<xAOD::PFOContainer> > > &vec_pi0pfos); diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_FeatureExtractor.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_FeatureExtractor.h index d56a46f922e2d95dbaa4715cbdb6af5ec9640b7d..6e668c25aebfd1031051f8624d23312a22e61a20 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_FeatureExtractor.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_FeatureExtractor.h @@ -37,7 +37,7 @@ namespace PanTau { virtual StatusCode initialize(); //get the features for an input seed - virtual StatusCode execute(PanTau::PanTauSeed2* inSeed); + virtual StatusCode execute(PanTau::PanTauSeed* inSeed); void Log10(); protected: @@ -51,27 +51,27 @@ namespace PanTau { std::map<std::string, double> m_Variants_SeedEt; //Function to calculate basic features - StatusCode calculateBasicFeatures(PanTau::PanTauSeed2* inSeed); + StatusCode calculateBasicFeatures(PanTau::PanTauSeed* inSeed); //Function to calculate features for one set of constituents - StatusCode calculateFeatures(PanTau::PanTauSeed2* inSeed, + StatusCode calculateFeatures(PanTau::PanTauSeed* inSeed, int tauConstituentType); //Function to add the 4 momenta of the tau constituents to the features - StatusCode addConstituentMomenta(PanTau::PanTauSeed2* inSeed); + StatusCode addConstituentMomenta(PanTau::PanTauSeed* inSeed); //Function to calculate features based on two sets of constituents - StatusCode addCombinedFeatures(PanTau::PanTauSeed2* inSeed); + StatusCode addCombinedFeatures(PanTau::PanTauSeed* inSeed); //Function to add impact parameter features - StatusCode addImpactParameterFeatures(PanTau::PanTauSeed2* inSeed) const; + StatusCode addImpactParameterFeatures(PanTau::PanTauSeed* inSeed) const; //Function to fill the m_Variants_SeedEt member - void fillVariantsSeedEt(std::vector<PanTau::TauConstituent2*> tauConstituents); + void fillVariantsSeedEt(std::vector<PanTau::TauConstituent*> tauConstituents); //helper function to fill the m_Variants_SeedEt map - void addFeatureWrtSeedEnergy(PanTau::TauFeature2* targetMap, + void addFeatureWrtSeedEnergy(PanTau::TauFeature* targetMap, std::string featName, double numerator, std::map<std::string, double>* denominatorMap) const; diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_InputConverter.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_InputConverter.h index 8de6c56ef1c95d27af832176d043f11dd69d316d..15cca23223d0f8413d95c1da66c679403f125487 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_InputConverter.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_InputConverter.h @@ -9,14 +9,12 @@ #include <vector> #include <string> -//! ASG #include "AsgTools/AsgTool.h" #include "AsgTools/ToolHandle.h" #include "PanTauAlgs/ITool_InformationStore.h" #include "PanTauAlgs/ITool_InputConverter.h" -//! xAOD EDM #include "xAODPFlow/PFO.h" #include "xAODTau/TauJet.h" #include "xAODPFlow/PFODefs.h" @@ -26,7 +24,7 @@ namespace Rec { } namespace PanTau { - class TauConstituent2; + class TauConstituent; } @@ -43,8 +41,8 @@ namespace PanTau { virtual StatusCode initialize(); - virtual StatusCode ConvertToTauConstituent2(xAOD::PFO* pfo, - PanTau::TauConstituent2* &tauConstituent, + virtual StatusCode ConvertToTauConstituent(xAOD::PFO* pfo, + PanTau::TauConstituent* &tauConstituent, const xAOD::TauJet* tauJet) const; protected: @@ -75,6 +73,4 @@ namespace PanTau { }//end namespace PanTau - - #endif // PANTAUALGS_TOOL_INPUTCONVERTER diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_ModeDiscriminator.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_ModeDiscriminator.h index 4260c7f62a7042721fe15ca8538f039895117c6e..3cbf9e353beac066d9e91ca03374403b14b93239 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_ModeDiscriminator.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_ModeDiscriminator.h @@ -21,7 +21,7 @@ #include "MVAUtils/BDT.h" namespace PanTau { - class PanTauSeed2; + class PanTauSeed; } @@ -46,11 +46,11 @@ namespace PanTau { virtual StatusCode finalize (); - virtual double getResponse(PanTau::PanTauSeed2* inSeed, bool& isOK); + virtual double getResponse(PanTau::PanTauSeed* inSeed, bool& isOK); private: - void updateReaderVariables(PanTau::PanTauSeed2* inSeed); + void updateReaderVariables(PanTau::PanTauSeed* inSeed); std::string m_calib_path; //<! cvmfs folder for data files std::string m_Name_InputAlg; diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_TauConstituentGetter.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_TauConstituentGetter.h index 9907d1f3e6b683488b5f996577f1e26e39aa949d..6ef75862a64f7f31172a5b83f42d2beb99fc70f7 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_TauConstituentGetter.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_TauConstituentGetter.h @@ -9,7 +9,6 @@ #include <vector> #include <string> -//! ASG #include "AsgTools/AsgTool.h" #include "AsgTools/ToolHandle.h" @@ -18,17 +17,13 @@ #include "PanTauAlgs/ITool_TauConstituentGetter.h" #include "PanTauAlgs/ITool_InputConverter.h" -//! xAOD EDM #include "xAODTau/TauJet.h" namespace PanTau { - class TauConstituent2; + class TauConstituent; } - - - namespace PanTau { class Tool_TauConstituentGetter : public asg::AsgTool, virtual public PanTau::ITool_TauConstituentGetter { @@ -43,7 +38,7 @@ class Tool_TauConstituentGetter : public asg::AsgTool, virtual public PanTau::IT virtual StatusCode initialize(); virtual StatusCode GetTauConstituents(const xAOD::TauJet* tauJet, - std::vector<TauConstituent2*>& outputList, + std::vector<TauConstituent*>& outputList, std::string algName) const; @@ -64,10 +59,7 @@ class Tool_TauConstituentGetter : public asg::AsgTool, virtual public PanTau::IT }; //end class ConstituentGetter - }//end namespace PanTau - - #endif // PANTAUALGS_TOOL_TAUCONSTITUENTGETTER diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_TauConstituentSelector.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_TauConstituentSelector.h index 12ea31b764b292d0a71e61c7a4b836f1e11dcd46..a95cdd555c2cf00fec69abcea94ae011772aa967 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_TauConstituentSelector.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_TauConstituentSelector.h @@ -33,21 +33,21 @@ class Tool_TauConstituentSelector : public asg::AsgTool, virtual public PanTau:: virtual StatusCode initialize(); - virtual StatusCode SelectTauConstituents( std::vector<TauConstituent2*> inputList, - std::vector<TauConstituent2*>& outputList) const; + virtual StatusCode SelectTauConstituents( std::vector<TauConstituent*> inputList, + std::vector<TauConstituent*>& outputList) const; protected: - virtual bool passesSelection_NeutralConstituent(TauConstituent2* tauConstituent) const; - virtual bool passesSelection_Pi0NeutConstituent(TauConstituent2* tauConstituent) const; - virtual bool passesSelection_ChargedConstituent(TauConstituent2* tauConstituent) const; - virtual bool passesSelection_OutNeutConstituent(TauConstituent2* TauConstituent) const; - virtual bool passesSelection_OutChrgConstituent(TauConstituent2* TauConstituent) const; - virtual bool passesSelection_NeutLowAConstituent(TauConstituent2* TauConstituent) const; - virtual bool passesSelection_NeutLowBConstituent(TauConstituent2* TauConstituent) const; + virtual bool passesSelection_NeutralConstituent(TauConstituent* tauConstituent) const; + virtual bool passesSelection_Pi0NeutConstituent(TauConstituent* tauConstituent) const; + virtual bool passesSelection_ChargedConstituent(TauConstituent* tauConstituent) const; + virtual bool passesSelection_OutNeutConstituent(TauConstituent* TauConstituent) const; + virtual bool passesSelection_OutChrgConstituent(TauConstituent* TauConstituent) const; + virtual bool passesSelection_NeutLowAConstituent(TauConstituent* TauConstituent) const; + virtual bool passesSelection_NeutLowBConstituent(TauConstituent* TauConstituent) const; - virtual double getEtCut(double eta, PanTau::TauConstituent2::Type constituentType) const; + virtual double getEtCut(double eta, PanTau::TauConstituent::Type constituentType) const; //member variables diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx index 4639241b16b2b7679d94073e502440cd758d3ed0..a19de062e8d61221ad29b136f33806c74f039088 100644 --- a/Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx @@ -2,149 +2,112 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ - -//! PanTau includes #include "PanTauAlgs/HelperFunctions.h" #include "PanTauAlgs/TauConstituent.h" -#include "xAODPFlow/PFO.h" -#include "xAODTau/TauJet.h" -#include "xAODTracking/Vertex.h" -#include "xAODTracking/VertexContainer.h" - -//! ROOT includes #include "Math/SpecFuncMathMore.h" #include "TMath.h" -#include "TRandom.h" #include "TLorentzVector.h" #include "TVector3.h" -#include "TMatrixDSym.h" -#include "TVectorD.h" -#include "TMatrixDSymEigen.h" #include <vector> - #include <sstream> -#include <vector> #include <cmath> - - - -void PanTau::HelperFunctions::dumpFourMomentum(TLorentzVector FourMom) const { - ATH_MSG_DEBUG("\t\tFourMomentum: Pt, Eta, Phi, M: " << FourMom.Pt() << " / " << FourMom.Eta() << " / " << FourMom.Phi() << " / " << FourMom.M()); - return; -} -void PanTau::HelperFunctions::dumpTauConstituent2(PanTau::TauConstituent2* tauConstituent) const { - TLorentzVector tlv_TauConst = tauConstituent->p4(); - ATH_MSG_DEBUG("\t\tTauConstituent2 has charge " << tauConstituent->getCharge() << " and types " << tauConstituent->getTypeNameString() << " with BDT Value " << tauConstituent->getBDTValue()); - ATH_MSG_DEBUG("\t\tTauConstituent2 has pT, Eta, Phi, m: " << tlv_TauConst.Perp() << " / " << tlv_TauConst.Eta() << " / " << tlv_TauConst.Phi() << " / " << tlv_TauConst.M()); - - return; -} - - -PanTau::TauConstituent2* PanTau::HelperFunctions::getNeutralConstWithLargestAngle( TLorentzVector charged, - std::vector<PanTau::TauConstituent2*> neutral) { - ATH_MSG_DEBUG("getNeutralConstWithLargestAngle"); - if(neutral.size() == 0) return 0; - //loop through neutrals to find the one with largest angle - unsigned int idx_Neutral = -1; - double angle_Neutral = -1.; - for(unsigned int iNeut=0; iNeut<neutral.size(); iNeut++) { - TLorentzVector tlv_CurNeut = neutral[iNeut]->p4(); - double angle = charged.Angle(tlv_CurNeut.Vect()); - if(angle > angle_Neutral) { - angle_Neutral = angle; - idx_Neutral = iNeut; - } - }//end loop neutrals ()); +PanTau::TauConstituent* PanTau::HelperFunctions::getNeutralConstWithLargestAngle(TLorentzVector charged, + std::vector<PanTau::TauConstituent*> neutral) { + if(neutral.size() == 0) return 0; + //loop through neutrals to find the one with largest angle + unsigned int idx_Neutral = -1; + double angle_Neutral = -1.; + for(unsigned int iNeut=0; iNeut<neutral.size(); iNeut++) { + TLorentzVector tlv_CurNeut = neutral[iNeut]->p4(); + double angle = charged.Angle(tlv_CurNeut.Vect()); + if(angle > angle_Neutral) { + angle_Neutral = angle; + idx_Neutral = iNeut; + } + }//end loop neutrals - return neutral[idx_Neutral]; + return neutral[idx_Neutral]; } - std::string PanTau::HelperFunctions::convertNumberToString(double x) const { - std::stringstream tmpStream; - tmpStream << x; - return tmpStream.str(); + std::stringstream tmpStream; + tmpStream << x; + return tmpStream.str(); } int PanTau::HelperFunctions::getBinIndex(std::vector<double> binEdges, double value) const { - int resBin = -1; - for(unsigned int i=0; i<binEdges.size()-1; i++) { - double lowerEdge = binEdges[i]; - double upperEdge = binEdges[i+1]; - if(lowerEdge <= value && value < upperEdge) resBin = i; - } - if(resBin == -1) { - ATH_MSG_WARNING("Could not find matching bin for value " << value << " in these bin edges:"); - for(unsigned int i=0; i<binEdges.size(); i++) ATH_MSG_WARNING("\tbin edge " << i << ": " << binEdges[i]); - } - return resBin; + int resBin = -1; + for(unsigned int i=0; i<binEdges.size()-1; i++) { + double lowerEdge = binEdges[i]; + double upperEdge = binEdges[i+1]; + if(lowerEdge <= value && value < upperEdge) resBin = i; + } + if(resBin == -1) { + ATH_MSG_WARNING("Could not find matching bin for value " << value << " in these bin edges:"); + for(unsigned int i=0; i<binEdges.size(); i++) ATH_MSG_WARNING("\tbin edge " << i << ": " << binEdges[i]); + } + return resBin; } - double PanTau::HelperFunctions::stddev(double sumOfSquares, double sumOfValues, int numConsts) const { - // calculate standard deviations according to: - // sigma^2 = (sum_i x_i^2) / N - ((sum_i x_i)/N)^2 (biased maximum-likelihood estimate) - // directly set sigma^2 to 0 in case of N=1, otherwise numerical effects may yield very small negative sigma^2 - if(numConsts == 1) return 0; - double a = sumOfSquares / ((double)numConsts); - double b = sumOfValues / ((double)numConsts); - double stdDev = a - b*b; - if(stdDev < 0.) stdDev = 0; - return sqrt(stdDev); + // calculate standard deviations according to: + // sigma^2 = (sum_i x_i^2) / N - ((sum_i x_i)/N)^2 (biased maximum-likelihood estimate) + // directly set sigma^2 to 0 in case of N=1, otherwise numerical effects may yield very small negative sigma^2 + if(numConsts == 1) return 0; + double a = sumOfSquares / ((double)numConsts); + double b = sumOfValues / ((double)numConsts); + double stdDev = a - b*b; + if(stdDev < 0.) stdDev = 0; + return std::sqrt(stdDev); } - double PanTau::HelperFunctions::deltaRprime(const TVector3& vec1, const TVector3& vec2) const { - const double a = vec1.DeltaPhi(vec2); - const double b = vec1.Theta() - vec2.Theta(); - double dRprime = sqrt(a*a + b*b); - return dRprime; + const double a = vec1.DeltaPhi(vec2); + const double b = vec1.Theta() - vec2.Theta(); + double dRprime = std::sqrt(a*a + b*b); + return dRprime; } - int PanTau::HelperFunctions::iPow(int man, int exp) const { - int ans = 1; - for (int k = 0; k < exp; k++) { - ans = ans * man; - } - return ans; + int ans = 1; + for (int k = 0; k < exp; k++) { + ans = ans * man; + } + return ans; } - double PanTau::HelperFunctions::ulAngle(double x, double y) const { - Double_t ulangl = 0; - Double_t r = TMath::Sqrt(x * x + y * y); - if (r < 1.0E-20) { - return ulangl; - } - if (TMath::Abs(x) / r < 0.8) { - ulangl = sign(TMath::ACos(x / r), y); - } else { - ulangl = TMath::ASin(y / r); - if (x < 0. && ulangl >= 0.) { - ulangl = TMath::Pi() - ulangl; - } else if (x < 0.) { - ulangl = -TMath::Pi() - ulangl; - } - } + Double_t ulangl = 0; + Double_t r = std::sqrt(x * x + y * y); + if (r < 1.0E-20) { return ulangl; + } + if (TMath::Abs(x) / r < 0.8) { + ulangl = sign(TMath::ACos(x / r), y); + } else { + ulangl = TMath::ASin(y / r); + if (x < 0. && ulangl >= 0.) { + ulangl = TMath::Pi() - ulangl; + } else if (x < 0.) { + ulangl = -TMath::Pi() - ulangl; + } + } + return ulangl; } - double PanTau::HelperFunctions::sign(double a, double b) const { - if (b < 0) { - return -TMath::Abs(a); - } else { - return TMath::Abs(a); - } + if (b < 0) { + return -std::abs(a); + } else { + return std::abs(a); + } } diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/PanTauProcessor.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/PanTauProcessor.cxx index d63345115f9e66399d2c9f4e664737b962228ccb..893a539c95fd796b0257ace2cbc007484cbbda0a 100644 --- a/Reconstruction/PanTau/PanTauAlgs/Root/PanTauProcessor.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/PanTauProcessor.cxx @@ -2,29 +2,19 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -//! C++ includes -#include <string> - #include "PanTauAlgs/PanTauProcessor.h" - -//! xAOD physics objects includes -#include "xAODTau/TauJet.h" -#include "xAODParticleEvent/Particle.h" -#include "xAODParticleEvent/ParticleContainer.h" -#include "xAODParticleEvent/ParticleAuxContainer.h" - -//! PanTau includes #include "PanTauAlgs/Tool_InformationStore.h" - #include "PanTauAlgs/TauConstituent.h" #include "PanTauAlgs/HelperFunctions.h" #include "PanTauAlgs/PanTauSeed.h" +#include "xAODTau/TauJet.h" +#include "xAODParticleEvent/Particle.h" +#include "xAODParticleEvent/ParticleContainer.h" + +#include <string> -/// ////////////////////////////////////////////////////////// -/// Constructor -/// ////////////////////////////////////////////////////////// PanTau::PanTauProcessor::PanTauProcessor(const std::string& name) : TauRecToolBase(name), m_Name_InputAlg(""), @@ -38,195 +28,173 @@ PanTau::PanTauProcessor::PanTauProcessor(const std::string& name) m_Tool_DetailsArranger("PanTau::Tool_DetailsArranger/Tool_DetailsArranger", this) { - //Connect python variables to member functions... - declareProperty("Name_InputAlg", m_Name_InputAlg, "Name of input algorithm for this instance"); - declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Tool handle to Tool_InformationStore"); - declareProperty("Tool_TauConstituentGetter", m_Tool_TauConstituentGetter, "Tool handle to Tool_TauConstituentGetter"); - declareProperty("Tool_TauConstituentSelector", m_Tool_TauConstituentSelector, "Tool handle to Tool_TauConstituentSelector"); - declareProperty("Tool_FeatureExtractor", m_Tool_FeatureExtractor, "Tool handle to Tool_FeatureExtractor"); - declareProperty("Tool_DecayModeDeterminator", m_Tool_DecayModeDeterminator, "Tool handle to Tool_DecayModeDeterminator"); - declareProperty("Tool_DetailsArranger", m_Tool_DetailsArranger, "Tool handle to Tool_DetailsArranger"); - - declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName="", "Tool handle to Tool_InformationStore"); - declareProperty("Tool_TauConstituentGetterName", m_Tool_TauConstituentGetterName="", "Tool handle to Tool_TauConstituentGetter"); - declareProperty("Tool_TauConstituentSelectorName", m_Tool_TauConstituentSelectorName="", "Tool handle to Tool_TauConstituentSelector"); - declareProperty("Tool_FeatureExtractorName", m_Tool_FeatureExtractorName="", "Tool handle to Tool_FeatureExtractor"); - declareProperty("Tool_DecayModeDeterminatorName", m_Tool_DecayModeDeterminatorName="", "Tool handle to Tool_DecayModeDeterminator"); - declareProperty("Tool_DetailsArrangerName", m_Tool_DetailsArrangerName="", "Tool handle to Tool_DetailsArranger"); - + //Connect python variables to member functions... + declareProperty("Name_InputAlg", m_Name_InputAlg, "Name of input algorithm for this instance"); + declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Tool handle to Tool_InformationStore"); + declareProperty("Tool_TauConstituentGetter", m_Tool_TauConstituentGetter, "Tool handle to Tool_TauConstituentGetter"); + declareProperty("Tool_TauConstituentSelector", m_Tool_TauConstituentSelector, "Tool handle to Tool_TauConstituentSelector"); + declareProperty("Tool_FeatureExtractor", m_Tool_FeatureExtractor, "Tool handle to Tool_FeatureExtractor"); + declareProperty("Tool_DecayModeDeterminator", m_Tool_DecayModeDeterminator, "Tool handle to Tool_DecayModeDeterminator"); + declareProperty("Tool_DetailsArranger", m_Tool_DetailsArranger, "Tool handle to Tool_DetailsArranger"); + + declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName="", "Tool handle to Tool_InformationStore"); + declareProperty("Tool_TauConstituentGetterName", m_Tool_TauConstituentGetterName="", "Tool handle to Tool_TauConstituentGetter"); + declareProperty("Tool_TauConstituentSelectorName", m_Tool_TauConstituentSelectorName="", "Tool handle to Tool_TauConstituentSelector"); + declareProperty("Tool_FeatureExtractorName", m_Tool_FeatureExtractorName="", "Tool handle to Tool_FeatureExtractor"); + declareProperty("Tool_DecayModeDeterminatorName", m_Tool_DecayModeDeterminatorName="", "Tool handle to Tool_DecayModeDeterminator"); + declareProperty("Tool_DetailsArrangerName", m_Tool_DetailsArrangerName="", "Tool handle to Tool_DetailsArranger"); } - -/// ////////////////////////////////////////////////////////// -/// Destructor -/// ////////////////////////////////////////////////////////// PanTau::PanTauProcessor::~PanTauProcessor() { } - -/// ////////////////////////////////////////////////////////// -/// Initialize -/// ////////////////////////////////////////////////////////// StatusCode PanTau::PanTauProcessor::initialize() { - ATH_MSG_INFO(name() << " initialize()"); - - // retrieve StoreGate Service and the tools - ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) ); - ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_TauConstituentGetter, m_Tool_TauConstituentGetterName ) ); - ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_TauConstituentSelector, m_Tool_TauConstituentSelectorName ) ); - ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_FeatureExtractor, m_Tool_FeatureExtractorName ) ); - ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_DecayModeDeterminator, m_Tool_DecayModeDeterminatorName ) ); - ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_DetailsArranger, m_Tool_DetailsArrangerName ) ); - - - // retrieve StoreGate Service and the tools - ATH_CHECK( m_Tool_InformationStore.retrieve() ); - ATH_CHECK( m_Tool_TauConstituentGetter.retrieve() ); - ATH_CHECK( m_Tool_TauConstituentSelector.retrieve() ); - ATH_CHECK( m_Tool_FeatureExtractor.retrieve() ); - ATH_CHECK( m_Tool_DecayModeDeterminator.retrieve() ); - ATH_CHECK( m_Tool_DetailsArranger.retrieve() ); - - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("ModeDiscriminator_BinEdges_Pt", m_Config_PtBins) ); - m_Config_MinPt = m_Config_PtBins.front(); - m_Config_MaxPt = m_Config_PtBins.back(); - - return StatusCode::SUCCESS; -}//end of initialize - + ATH_MSG_INFO(name() << " initialize()"); + + // retrieve StoreGate Service and the tools + ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) ); + ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_TauConstituentGetter, m_Tool_TauConstituentGetterName ) ); + ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_TauConstituentSelector, m_Tool_TauConstituentSelectorName ) ); + ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_FeatureExtractor, m_Tool_FeatureExtractorName ) ); + ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_DecayModeDeterminator, m_Tool_DecayModeDeterminatorName ) ); + ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_DetailsArranger, m_Tool_DetailsArrangerName ) ); + + // retrieve StoreGate Service and the tools + ATH_CHECK( m_Tool_InformationStore.retrieve() ); + ATH_CHECK( m_Tool_TauConstituentGetter.retrieve() ); + ATH_CHECK( m_Tool_TauConstituentSelector.retrieve() ); + ATH_CHECK( m_Tool_FeatureExtractor.retrieve() ); + ATH_CHECK( m_Tool_DecayModeDeterminator.retrieve() ); + ATH_CHECK( m_Tool_DetailsArranger.retrieve() ); + + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("ModeDiscriminator_BinEdges_Pt", m_Config_PtBins) ); + m_Config_MinPt = m_Config_PtBins.front(); + m_Config_MaxPt = m_Config_PtBins.back(); + + return StatusCode::SUCCESS; +} -/// ////////////////////////////////////////////////////////// -/// Finalize -/// ////////////////////////////////////////////////////////// StatusCode PanTau::PanTauProcessor::finalize() { - return StatusCode::SUCCESS; -}//end finalize + return StatusCode::SUCCESS; +} -/// ////////////////////////////////////////////////////////// -/// Execute -/// ////////////////////////////////////////////////////////// -StatusCode PanTau::PanTauProcessor::executePanTau(xAOD::TauJet& pTau, xAOD::ParticleContainer& pi0Container) { + +StatusCode PanTau::PanTauProcessor::executePanTau(xAOD::TauJet& pTau, xAOD::ParticleContainer& pi0Container) { - //get the current TauJet - xAOD::TauJet* curTauJet = &pTau; - ATH_MSG_DEBUG("===> Tau: "); - - //check for null pointer - if(curTauJet == 0) { - ATH_MSG_WARNING("Pointer to xAOD::TauJet is 0!"); - return StatusCode::FAILURE; - } + //get the current TauJet + xAOD::TauJet* curTauJet = &pTau; - fillDefaultValuesToTau(curTauJet); + //check for null pointer + if(curTauJet == 0) { + ATH_MSG_WARNING("Pointer to xAOD::TauJet is 0!"); + return StatusCode::FAILURE; + } + fillDefaultValuesToTau(curTauJet); - //keep track of the technical quality of the pantau seed to be created - std::vector<int> pantauSeed_TechnicalQuality = std::vector<int>((unsigned int)PanTau::PanTauSeed2::t_nTechnicalQualities, 0); - - //Only process taus with 1 <= ntracks <= 5: - int numTrack = curTauJet->nTracks(); - if(numTrack == 0 || numTrack > 5) { - ATH_MSG_DEBUG("Flagging tau for algorithm " << m_Name_InputAlg << " as invalid, because numTrack is " << numTrack); - pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed2::t_NoValidInputTau) = 1; - } - + //keep track of the technical quality of the pantau seed to be created + std::vector<int> pantauSeed_TechnicalQuality = std::vector<int>((unsigned int)PanTau::PanTauSeed::t_nTechnicalQualities, 0); - // if there is substructure info available, get constituents, perform selection and recombination - //these vectors will be owned by the PanTauSeed2 object. - std::vector<TauConstituent2*> l_List_TauConstituents = std::vector<TauConstituent2*>(0); - std::vector<TauConstituent2*> l_List_SelectedTauConstituents = std::vector<TauConstituent2*>(0); + //Only process taus with 1 <= ntracks <= 5: + int numTrack = curTauJet->nTracks(); + if(numTrack == 0 || numTrack > 5) { + ATH_MSG_DEBUG("Flagging tau for algorithm " << m_Name_InputAlg << " as invalid, because numTrack is " << numTrack); + pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed::t_NoValidInputTau) = 1; + } + // if there is substructure info available, get constituents, perform selection and recombination + //these vectors will be owned by the PanTauSeed object. + std::vector<TauConstituent*> l_List_TauConstituents = std::vector<TauConstituent*>(0); + std::vector<TauConstituent*> l_List_SelectedTauConstituents = std::vector<TauConstituent*>(0); - if(pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed2::t_NoValidInputTau) == 0) { - // Get the constituents for the current tau - ATH_CHECK( m_Tool_TauConstituentGetter->GetTauConstituents(curTauJet, l_List_TauConstituents, m_Name_InputAlg) ); - if(l_List_TauConstituents.size() == 0) { - pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed2::t_NoConstituentsAtAll) = 1; - ATH_MSG_DEBUG("Seed has no associated constituents!"); - } - - // Call the TauConstituentSelector tool to throw out bad constituents - ATH_CHECK(m_Tool_TauConstituentSelector->SelectTauConstituents(l_List_TauConstituents, l_List_SelectedTauConstituents) ); - if(l_List_SelectedTauConstituents.size() == 0) { - pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed2::t_NoSelectedConstituents) = 1; - ATH_MSG_DEBUG("Seed has no associated constituents that pass selection!"); - } - - //check if there are core objects in the selected constituents - bool hasCoreConstituents = false; - for(unsigned int iConst=0; iConst<l_List_SelectedTauConstituents.size(); iConst++) { - PanTau::TauConstituent2* curConst = l_List_SelectedTauConstituents.at(iConst); - if(curConst->isOfType(PanTau::TauConstituent2::t_Charged) == true) {hasCoreConstituents = true; break;}; - if(curConst->isOfType(PanTau::TauConstituent2::t_Neutral) == true) {hasCoreConstituents = true; break;}; - if(curConst->isOfType(PanTau::TauConstituent2::t_Pi0Neut) == true) {hasCoreConstituents = true; break;}; - } + if(pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed::t_NoValidInputTau) == 0) { + // Get the constituents for the current tau + ATH_CHECK( m_Tool_TauConstituentGetter->GetTauConstituents(curTauJet, l_List_TauConstituents, m_Name_InputAlg) ); + if(l_List_TauConstituents.size() == 0) { + pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed::t_NoConstituentsAtAll) = 1; + ATH_MSG_DEBUG("Seed has no associated constituents!"); + } - if(hasCoreConstituents == false) { - pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed2::t_NoSelectedConstituents) = 1; //use this flag at the moment as a quick hack - } + // Call the TauConstituentSelector tool to throw out bad constituents + ATH_CHECK(m_Tool_TauConstituentSelector->SelectTauConstituents(l_List_TauConstituents, l_List_SelectedTauConstituents) ); + if(l_List_SelectedTauConstituents.size() == 0) { + pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed::t_NoSelectedConstituents) = 1; + ATH_MSG_DEBUG("Seed has no associated constituents that pass selection!"); + } + //check if there are core objects in the selected constituents + bool hasCoreConstituents = false; + for(unsigned int iConst=0; iConst<l_List_SelectedTauConstituents.size(); iConst++) { + PanTau::TauConstituent* curConst = l_List_SelectedTauConstituents.at(iConst); + if(curConst->isOfType(PanTau::TauConstituent::t_Charged) == true) {hasCoreConstituents = true; break;}; + if(curConst->isOfType(PanTau::TauConstituent::t_Neutral) == true) {hasCoreConstituents = true; break;}; + if(curConst->isOfType(PanTau::TauConstituent::t_Pi0Neut) == true) {hasCoreConstituents = true; break;}; } + + if(hasCoreConstituents == false) { + pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed::t_NoSelectedConstituents) = 1; //use this flag at the moment as a quick hack + } + } - //to be consistent, taus without substructure algs run on them also have no constituents - if(pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed2::t_NoValidInputTau) == 1) { - pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed2::t_NoConstituentsAtAll) = 1; - pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed2::t_NoSelectedConstituents) = 1; - } - - //check for the pT flag - double tauJet_pT = curTauJet->ptIntermediateAxis(); - if(tauJet_pT < m_Config_MinPt || tauJet_pT > m_Config_MaxPt) { - pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed2::t_BadPtValue) = 1; - } - - - // Now build the PanTauSeed2 with the new Constituents - PanTau::PanTauSeed2* curPanTauSeed = new PanTau::PanTauSeed2(m_Name_InputAlg, + //to be consistent, taus without substructure algs run on them also have no constituents + if(pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed::t_NoValidInputTau) == 1) { + pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed::t_NoConstituentsAtAll) = 1; + pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed::t_NoSelectedConstituents) = 1; + } + + //check for the pT flag + double tauJet_pT = curTauJet->ptIntermediateAxis(); + if(tauJet_pT < m_Config_MinPt || tauJet_pT > m_Config_MaxPt) { + pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed::t_BadPtValue) = 1; + } + + // Now build the PanTauSeed with the new Constituents + PanTau::PanTauSeed* curPanTauSeed = new PanTau::PanTauSeed(m_Name_InputAlg, curTauJet, l_List_SelectedTauConstituents, - l_List_TauConstituents, pantauSeed_TechnicalQuality); - - curPanTauSeed->makePrivateStore(); - - // Get the features for this PanTauSeed - ATH_CHECK(m_Tool_FeatureExtractor->execute(curPanTauSeed) ); - - // Seed finalizing: - // 1. Pass the seed to the decay mode determination tool - // 2. Pass the seed to the DetailsArranger tool to calculate the four momentum and add the details to tauJet - - // 1. call decay mode determinator for this seed - ATH_CHECK( m_Tool_DecayModeDeterminator->execute(curPanTauSeed) ); - - // 2. calculate the four momentum and link the details to the tauJet - ATH_CHECK( m_Tool_DetailsArranger->execute(curPanTauSeed, pi0Container) ); - - delete curPanTauSeed; - return StatusCode::SUCCESS; -}//end of execute - + l_List_TauConstituents, + pantauSeed_TechnicalQuality); + + curPanTauSeed->makePrivateStore(); + + // Get the features for this PanTauSeed + ATH_CHECK(m_Tool_FeatureExtractor->execute(curPanTauSeed) ); + + // Seed finalizing: + // 1. Pass the seed to the decay mode determination tool + // 2. Pass the seed to the DetailsArranger tool to calculate the four momentum and add the details to tauJet + + // 1. call decay mode determinator for this seed + ATH_CHECK( m_Tool_DecayModeDeterminator->execute(curPanTauSeed) ); + + // 2. calculate the four momentum and link the details to the tauJet + ATH_CHECK( m_Tool_DetailsArranger->execute(curPanTauSeed, pi0Container) ); + + delete curPanTauSeed; + return StatusCode::SUCCESS; +} void PanTau::PanTauProcessor::fillDefaultValuesToTau(xAOD::TauJet* tauJet) { - //default four momentum set to previous calibration state: TauEnergyScale - TLorentzVector defaultP4 = tauJet->p4(); - tauJet->setP4(xAOD::TauJetParameters::PanTauCellBased, defaultP4.Pt(), defaultP4.Eta(), defaultP4.Phi(), defaultP4.M()); + //default four momentum set to previous calibration state: TauEnergyScale + TLorentzVector defaultP4 = tauJet->p4(); + tauJet->setP4(xAOD::TauJetParameters::PanTauCellBased, defaultP4.Pt(), defaultP4.Eta(), defaultP4.Phi(), defaultP4.M()); - //charged - std::vector< ElementLink< xAOD::PFOContainer > > chrgPFOLinks = tauJet->protoChargedPFOLinks(); - tauJet->setChargedPFOLinks(chrgPFOLinks); + //charged + std::vector< ElementLink< xAOD::PFOContainer > > chrgPFOLinks = tauJet->protoChargedPFOLinks(); + tauJet->setChargedPFOLinks(chrgPFOLinks); - //pi0 - std::vector< ElementLink< xAOD::PFOContainer > > pi0PFOLinks = tauJet->protoPi0PFOLinks(); - tauJet->setPi0PFOLinks(pi0PFOLinks); + //pi0 + std::vector< ElementLink< xAOD::PFOContainer > > pi0PFOLinks = tauJet->protoPi0PFOLinks(); + tauJet->setPi0PFOLinks(pi0PFOLinks); - //neutrals - std::vector< ElementLink< xAOD::PFOContainer > > neutralPFOLinks = tauJet->protoNeutralPFOLinks(); - tauJet->setNeutralPFOLinks(neutralPFOLinks); + //neutrals + std::vector< ElementLink< xAOD::PFOContainer > > neutralPFOLinks = tauJet->protoNeutralPFOLinks(); + tauJet->setNeutralPFOLinks(neutralPFOLinks); - return; + return; } diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/PanTauSeed.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/PanTauSeed.cxx index b8217ea860dfc53a73040c84ee6fd1d06f2d34da..ebd447010941ac6106b4404f9343996c55a4001b 100644 --- a/Reconstruction/PanTau/PanTauAlgs/Root/PanTauSeed.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/PanTauSeed.cxx @@ -3,15 +3,11 @@ */ #include "PanTauAlgs/PanTauSeed.h" - #include "PanTauAlgs/TauConstituent.h" - -#include <iostream> - #include "xAODTau/TauJet.h" // default constructor -PanTau::PanTauSeed2::PanTauSeed2() +PanTau::PanTauSeed::PanTauSeed() : IParticle(), m_p4(), m_p4Cached( false ), @@ -33,15 +29,14 @@ PanTau::PanTauSeed2::PanTauSeed2() } - // destructor -PanTau::PanTauSeed2::~PanTauSeed2() +PanTau::PanTauSeed::~PanTauSeed() { if(m_Features != 0) delete m_Features; //delete the constituents for(unsigned int iConst=0; iConst<m_ConstituentsList_All.size(); iConst++) { - PanTau::TauConstituent2* curConst = m_ConstituentsList_All[iConst]; + PanTau::TauConstituent* curConst = m_ConstituentsList_All[iConst]; if(curConst != 0) delete curConst; } m_ConstituentsList_All.clear(); @@ -49,19 +44,18 @@ PanTau::PanTauSeed2::~PanTauSeed2() m_ConstituentsList_Core.clear(); m_ConstituentsList_Wide.clear(); - //also clear the constituent matrix - //dont delete the entries as they point to the (at this point already deleted) constituents in m_ConstituentsList + // also clear the constituent matrix + // dont delete the entries as they point to the (at this point already deleted) constituents in m_ConstituentsList for(unsigned int iType=0; iType<m_Constituents.size(); iType++) { - std::vector<PanTau::TauConstituent2*> curConsts = m_Constituents[iType]; + std::vector<PanTau::TauConstituent*> curConsts = m_Constituents[iType]; curConsts.clear(); } m_Constituents.clear(); - } //copy constructor -PanTau::PanTauSeed2::PanTauSeed2(const PanTau::PanTauSeed2& rhs) +PanTau::PanTauSeed::PanTauSeed(const PanTau::PanTauSeed& rhs) : IParticle(rhs), m_p4(rhs.m_p4), m_p4Cached(rhs.m_p4Cached), @@ -79,13 +73,12 @@ PanTau::PanTauSeed2::PanTauSeed2(const PanTau::PanTauSeed2& rhs) m_DecayMode_ByPanTau(rhs.m_DecayMode_ByPanTau), m_decayModeHack_CellBasedShots(rhs.m_decayModeHack_CellBasedShots), - m_Features( (rhs.m_Features ? new PanTau::TauFeature2(*rhs.m_Features) : 0) ) + m_Features( (rhs.m_Features ? new PanTau::TauFeature(*rhs.m_Features) : 0) ) { } - -PanTau::PanTauSeed2& PanTau::PanTauSeed2::operator=(const PanTau::PanTauSeed2& seed) +PanTau::PanTauSeed& PanTau::PanTauSeed::operator=(const PanTau::PanTauSeed& seed) { if (this != &seed){ @@ -108,46 +101,45 @@ PanTau::PanTauSeed2& PanTau::PanTauSeed2::operator=(const PanTau::PanTauSeed2& s m_decayModeHack_CellBasedShots = seed.m_decayModeHack_CellBasedShots; if(m_Features) delete m_Features; - m_Features = (seed.m_Features ? new PanTau::TauFeature2(*seed.m_Features) : 0); + m_Features = (seed.m_Features ? new PanTau::TauFeature(*seed.m_Features) : 0); } return *this; } - -double PanTau::PanTauSeed2::pt() const { +double PanTau::PanTauSeed::pt() const { // static Accessor< float > acc( "pt" ); // return acc( *this ); return p4().Pt(); } -double PanTau::PanTauSeed2::eta() const { +double PanTau::PanTauSeed::eta() const { // static Accessor<float > acc( "eta" ); // return acc( *this ); return p4().Eta(); } -double PanTau::PanTauSeed2::phi() const { +double PanTau::PanTauSeed::phi() const { // static Accessor< float > acc( "phi" ); // return acc( *this ); return p4().Phi(); } -double PanTau::PanTauSeed2::m() const { +double PanTau::PanTauSeed::m() const { // static Accessor< float> acc( "m" ); // return acc( *this ); return p4().M(); } -double PanTau::PanTauSeed2::e() const{ +double PanTau::PanTauSeed::e() const{ return p4().E(); } -double PanTau::PanTauSeed2::rapidity() const { +double PanTau::PanTauSeed::rapidity() const { return p4().Rapidity(); } -PanTau::PanTauSeed2::FourMom_t PanTau::PanTauSeed2::p4() const { +PanTau::PanTauSeed::FourMom_t PanTau::PanTauSeed::p4() const { if( ! m_p4Cached ) { m_p4.SetPtEtaPhiM( pt(), eta(), phi(),m()); m_p4Cached=true; @@ -155,7 +147,7 @@ PanTau::PanTauSeed2::FourMom_t PanTau::PanTauSeed2::p4() const { return m_p4; } -void PanTau::PanTauSeed2::setP4(float pt, float eta, float phi, float m){ +void PanTau::PanTauSeed::setP4(float pt, float eta, float phi, float m){ static Accessor< float > acc1( "pt" ); acc1( *this ) = pt; static Accessor< float > acc2( "eta" ); @@ -169,28 +161,28 @@ void PanTau::PanTauSeed2::setP4(float pt, float eta, float phi, float m){ } -void PanTau::PanTauSeed2::setPt(float pt){ +void PanTau::PanTauSeed::setPt(float pt){ static Accessor< float > acc( "pt" ); acc( *this ) = pt; //Need to recalculate m_p4 if requested after update - m_p4Cached=false; + m_p4Cached=false; } -void PanTau::PanTauSeed2::setEta(float eta){ +void PanTau::PanTauSeed::setEta(float eta){ static Accessor< float > acc( "eta" ); acc( *this ) = eta; //Need to recalculate m_p4 if requested after update m_p4Cached=false; } -void PanTau::PanTauSeed2::setPhi(float phi){ +void PanTau::PanTauSeed::setPhi(float phi){ static Accessor< float > acc( "phi" ); acc( *this ) = phi; //Need to recalculate m_p4 if requested after update m_p4Cached=false; } -void PanTau::PanTauSeed2::setM(float m){ +void PanTau::PanTauSeed::setM(float m){ static Accessor< float > acc( "m" ); acc( *this ) = m; //Need to recalculate m_p4 if requested after update @@ -198,25 +190,25 @@ void PanTau::PanTauSeed2::setM(float m){ } -xAOD::Type::ObjectType PanTau::PanTauSeed2::type() const { +xAOD::Type::ObjectType PanTau::PanTauSeed::type() const { return xAOD::Type::Tau; } /** Main constructor to be used */ -PanTau::PanTauSeed2::PanTauSeed2( std::string nameInputAlgorithm, - const xAOD::TauJet* tauJet, - std::vector<PanTau::TauConstituent2*> tauConstituents, - std::vector<PanTau::TauConstituent2*> tauConstituentsAll, - std::vector<int> pantauSeed_TechnicalQuality +PanTau::PanTauSeed::PanTauSeed( std::string nameInputAlgorithm, + const xAOD::TauJet* tauJet, + std::vector<PanTau::TauConstituent*> tauConstituents, + std::vector<PanTau::TauConstituent*> tauConstituentsAll, + std::vector<int> pantauSeed_TechnicalQuality ) - : + : IParticle() { // *This may be a bug!!! change to Set*Pt*EtaPhiM?? *** -// PanTau::SetP4EEtaPhiM( m_p4, tauJet->ptIntermediateAxis() * cosh( tauJet->etaIntermediateAxis() ), tauJet->etaIntermediateAxis(), tauJet->phiIntermediateAxis(), tauJet->mIntermediateAxis() ); + // PanTau::SetP4EEtaPhiM( m_p4, tauJet->ptIntermediateAxis() * cosh( tauJet->etaIntermediateAxis() ), tauJet->etaIntermediateAxis(), tauJet->phiIntermediateAxis(), tauJet->mIntermediateAxis() ); m_p4.SetPtEtaPhiM(tauJet->ptIntermediateAxis(), tauJet->etaIntermediateAxis(), tauJet->phiIntermediateAxis(), tauJet->mIntermediateAxis() ); m_p4Cached=true; m_IsValidSeed = true; @@ -224,26 +216,26 @@ PanTau::PanTauSeed2::PanTauSeed2( std::string nameIn m_NameInputAlgorithm = nameInputAlgorithm; m_TauJet = tauJet; m_decayModeHack_CellBasedShots = false; - m_Features = new PanTau::TauFeature2; + m_Features = new PanTau::TauFeature; //save a copy of the flat constituents list and also split into core/wide constituents m_ConstituentsList_All = tauConstituentsAll; m_ConstituentsList_AllSelected = tauConstituents; //all types are in here, this is the complete list for(unsigned int iConst=0; iConst<tauConstituents.size(); iConst++) { - bool isCoreChrg = tauConstituents[iConst]->isOfType(PanTau::TauConstituent2::t_Charged); - bool isCoreNeut = tauConstituents[iConst]->isOfType(PanTau::TauConstituent2::t_Neutral); - bool isCorePi0 = tauConstituents[iConst]->isOfType(PanTau::TauConstituent2::t_Pi0Neut); + bool isCoreChrg = tauConstituents[iConst]->isOfType(PanTau::TauConstituent::t_Charged); + bool isCoreNeut = tauConstituents[iConst]->isOfType(PanTau::TauConstituent::t_Neutral); + bool isCorePi0 = tauConstituents[iConst]->isOfType(PanTau::TauConstituent::t_Pi0Neut); if(isCoreChrg == true || isCoreNeut == true || isCorePi0 == true) m_ConstituentsList_Core.push_back(tauConstituents[iConst]); // Core only contains the currently used objects - bool isWideChrg = tauConstituents[iConst]->isOfType(PanTau::TauConstituent2::t_OutChrg); - bool isWideNeut = tauConstituents[iConst]->isOfType(PanTau::TauConstituent2::t_OutNeut); + bool isWideChrg = tauConstituents[iConst]->isOfType(PanTau::TauConstituent::t_OutChrg); + bool isWideNeut = tauConstituents[iConst]->isOfType(PanTau::TauConstituent::t_OutNeut); if(isWideChrg == true || isWideNeut == true) m_ConstituentsList_Wide.push_back(tauConstituents[iConst]); // Wide contains objectsin 0.2-0.4 } //create the constituents lists - for(int iType=0; iType<PanTau::TauConstituent2::t_nTypes; iType++) { - m_Constituents.push_back( std::vector<PanTau::TauConstituent2*>(0) ); + for(int iType=0; iType<PanTau::TauConstituent::t_nTypes; iType++) { + m_Constituents.push_back( std::vector<PanTau::TauConstituent*>(0) ); m_TypeHLVs.push_back( TLorentzVector(0,0,0,0) ); } @@ -255,14 +247,14 @@ PanTau::PanTauSeed2::PanTauSeed2( std::string nameIn int nPi0Neut = 0; for(unsigned int iConst=0; iConst<tauConstituents.size(); iConst++) { - PanTau::TauConstituent2* curConst = tauConstituents.at(iConst); + PanTau::TauConstituent* curConst = tauConstituents.at(iConst); std::vector<int> curTypes = curConst->getTypeFlags(); for(unsigned int curType=0; curType<curTypes.size(); curType++) { if(curTypes.at(curType) == 0) continue; - if(curType == (int)PanTau::TauConstituent2::t_Charged) nCharged++; - if(curType == (int)PanTau::TauConstituent2::t_Pi0Neut) nPi0Neut++; + if(curType == (int)PanTau::TauConstituent::t_Charged) nCharged++; + if(curType == (int)PanTau::TauConstituent::t_Pi0Neut) nPi0Neut++; if((unsigned int)curType >= m_Constituents.size()) { continue; @@ -278,8 +270,8 @@ PanTau::PanTauSeed2::PanTauSeed2( std::string nameIn hlv_SumConstituents_Wide += curConst->p4(); //add all charged and neutral constituents (i.e. from core region) to core proto momentum - if(curConst->isOfType(PanTau::TauConstituent2::t_Charged)) {hlv_SumConstituents_Core += curConst->p4(); continue;} - if(curConst->isOfType(PanTau::TauConstituent2::t_Pi0Neut)) {hlv_SumConstituents_Core += curConst->p4(); continue;} + if(curConst->isOfType(PanTau::TauConstituent::t_Charged)) {hlv_SumConstituents_Core += curConst->p4(); continue;} + if(curConst->isOfType(PanTau::TauConstituent::t_Pi0Neut)) {hlv_SumConstituents_Core += curConst->p4(); continue;} }//end loop over constituents @@ -287,10 +279,10 @@ PanTau::PanTauSeed2::PanTauSeed2( std::string nameIn m_ProtoMomentum_Core = hlv_SumConstituents_Core; //set mode as obtained from subalg - m_DecayMode_BySubAlg = PanTau::PanTauSeed2::getDecayMode(nCharged, nPi0Neut); + m_DecayMode_BySubAlg = PanTau::PanTauSeed::getDecayMode(nCharged, nPi0Neut); m_DecayMode_ByPanTau = xAOD::TauJetParameters::Mode_Error; - if(isOfTechnicalQuality(PanTau::PanTauSeed2::t_NoValidInputTau) == true) { + if(isOfTechnicalQuality(PanTau::PanTauSeed::t_NoValidInputTau) == true) { m_DecayMode_ByPanTau = xAOD::TauJetParameters::Mode_NotSet; } @@ -298,11 +290,10 @@ PanTau::PanTauSeed2::PanTauSeed2( std::string nameIn /** Constructor for invalid seeds */ -PanTau::PanTauSeed2::PanTauSeed2( std::string nameInputAlgorithm, - const xAOD::TauJet* tauJet, - std::vector<int> pantauSeed_TechnicalQuality - ) - : +PanTau::PanTauSeed::PanTauSeed(std::string nameInputAlgorithm, + const xAOD::TauJet* tauJet, + std::vector<int> pantauSeed_TechnicalQuality) + : IParticle(), m_Constituents(), m_TypeHLVs(), @@ -313,45 +304,41 @@ PanTau::PanTauSeed2::PanTauSeed2( std::string nameInput m_decayModeHack_CellBasedShots(false) { // *This may be a bug!!! change to Set*Pt*EtaPhiM?? *** -// PanTau::SetP4EEtaPhiM( m_p4, tauJet->ptIntermediateAxis() * cosh( tauJet->etaIntermediateAxis() ), tauJet->etaIntermediateAxis(), tauJet->phiIntermediateAxis(), tauJet->mIntermediateAxis() ); + // PanTau::SetP4EEtaPhiM( m_p4, tauJet->ptIntermediateAxis() * cosh( tauJet->etaIntermediateAxis() ), tauJet->etaIntermediateAxis(), tauJet->phiIntermediateAxis(), tauJet->mIntermediateAxis() ); m_p4.SetPtEtaPhiM(tauJet->ptIntermediateAxis(), tauJet->etaIntermediateAxis(), tauJet->phiIntermediateAxis(), tauJet->mIntermediateAxis() ); m_p4Cached=true; m_IsValidSeed = false; m_TechnicalQuality = pantauSeed_TechnicalQuality; m_NameInputAlgorithm = nameInputAlgorithm; m_TauJet = tauJet; - m_Features = new PanTau::TauFeature2; + m_Features = new PanTau::TauFeature; } - -int PanTau::PanTauSeed2::getDecayMode(int nCharged, int nNeutral) { +int PanTau::PanTauSeed::getDecayMode(int nCharged, int nNeutral) { int decayMode; - // 1 Prong modes + + // 1 Prong modes if(nCharged == 1 && nNeutral == 0) decayMode = (int)xAOD::TauJetParameters::Mode_1p0n; else if(nCharged == 1 && nNeutral == 1) decayMode = (int)xAOD::TauJetParameters::Mode_1p1n; else if(nCharged == 1 && nNeutral > 1) decayMode = (int)xAOD::TauJetParameters::Mode_1pXn; - - // 3 prong modes + // 3 prong modes else if(nCharged == 3 && nNeutral == 0) decayMode = (int)xAOD::TauJetParameters::Mode_3p0n; else if(nCharged == 3 && nNeutral > 0) decayMode = (int)xAOD::TauJetParameters::Mode_3pXn; - - // other mode + // other mode else if(nCharged == 2) decayMode = (int)xAOD::TauJetParameters::Mode_Other; else if(nCharged == 4) decayMode = (int)xAOD::TauJetParameters::Mode_Other; else if(nCharged == 5) decayMode = (int)xAOD::TauJetParameters::Mode_Other; - else if(nCharged == 0) decayMode = (int)xAOD::TauJetParameters::Mode_NotSet; else if(nCharged >= 6) decayMode = (int)xAOD::TauJetParameters::Mode_NotSet; - else decayMode = (int)xAOD::TauJetParameters::Mode_Error; return decayMode; } -std::string PanTau::PanTauSeed2::getDecayModeName(int decayMode) { +std::string PanTau::PanTauSeed::getDecayModeName(int decayMode) { xAOD::TauJetParameters::DecayMode mode = (xAOD::TauJetParameters::DecayMode)decayMode; @@ -367,9 +354,8 @@ std::string PanTau::PanTauSeed2::getDecayModeName(int decayMode) { } - -bool PanTau::PanTauSeed2::isOfTechnicalQuality(int pantauSeed_TechnicalQuality) const { - if(pantauSeed_TechnicalQuality > PanTau::PanTauSeed2::t_nTechnicalQualities) { +bool PanTau::PanTauSeed::isOfTechnicalQuality(int pantauSeed_TechnicalQuality) const { + if(pantauSeed_TechnicalQuality > PanTau::PanTauSeed::t_nTechnicalQualities) { return false; } if(m_TechnicalQuality[pantauSeed_TechnicalQuality] == 1) return true; @@ -377,39 +363,32 @@ bool PanTau::PanTauSeed2::isOfTec } - - -std::vector<PanTau::TauConstituent2*> PanTau::PanTauSeed2::getConstituentsOfType(int tauConstituent_Type, bool& foundit) { - if(tauConstituent_Type > PanTau::TauConstituent2::t_nTypes) { - foundit = false; - return std::vector<TauConstituent2*>(0); - } - foundit = true; - if(tauConstituent_Type == (int)PanTau::TauConstituent2::t_NoType) return m_ConstituentsList_AllSelected; - return m_Constituents.at(tauConstituent_Type); +std::vector<PanTau::TauConstituent*> PanTau::PanTauSeed::getConstituentsOfType(int tauConstituent_Type, bool& foundit) { + if(tauConstituent_Type > PanTau::TauConstituent::t_nTypes) { + foundit = false; + return std::vector<TauConstituent*>(0); + } + foundit = true; + if(tauConstituent_Type == (int)PanTau::TauConstituent::t_NoType) return m_ConstituentsList_AllSelected; + return m_Constituents.at(tauConstituent_Type); } - -int PanTau::PanTauSeed2::getNumberOfConstituentsOfType(int tauConstituent_Type) { - bool isOK = false; - std::vector<PanTau::TauConstituent2*> consts = this->getConstituentsOfType(tauConstituent_Type, isOK); - if(isOK) { - return (int)consts.size(); - } - return -1; +int PanTau::PanTauSeed::getNumberOfConstituentsOfType(int tauConstituent_Type) { + bool isOK = false; + std::vector<PanTau::TauConstituent*> consts = this->getConstituentsOfType(tauConstituent_Type, isOK); + if(isOK) { + return (int)consts.size(); + } + return -1; } -TLorentzVector PanTau::PanTauSeed2::getSubsystemHLV(int tauConstituent_Type, bool& foundit) { - if(tauConstituent_Type > PanTau::TauConstituent2::t_nTypes) { - foundit = false; - return TLorentzVector(0,0,0,0); - } - foundit = true; - return m_TypeHLVs.at(tauConstituent_Type); +TLorentzVector PanTau::PanTauSeed::getSubsystemHLV(int tauConstituent_Type, bool& foundit) { + if(tauConstituent_Type > PanTau::TauConstituent::t_nTypes) { + foundit = false; + return TLorentzVector(0,0,0,0); + } + foundit = true; + return m_TypeHLVs.at(tauConstituent_Type); } - - - - diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/TauConstituent.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/TauConstituent.cxx index 0f38863d86079cc1ab6a100da8b6a0183e078f30..77c5a6d8e665ef08e0992e8816a3b09988cc394a 100644 --- a/Reconstruction/PanTau/PanTauAlgs/Root/TauConstituent.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/TauConstituent.cxx @@ -1,18 +1,15 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "PanTauAlgs/TauConstituent.h" -#include <iostream> - -PanTau::TauConstituent2::TauConstituent2() - : +PanTau::TauConstituent::TauConstituent() : IParticle(), m_p4(), m_p4Cached( false ), m_TypeFlags(), - m_BDTValue(PanTau::TauConstituent2::DefaultBDTValue()), - m_Charge(PanTau::TauConstituent2::DefaultCharge()), + m_BDTValue(PanTau::TauConstituent::DefaultBDTValue()), + m_Charge(PanTau::TauConstituent::DefaultCharge()), m_PFOLink(0), m_Shots(), m_nPhotonsInShot(0) @@ -20,14 +17,11 @@ PanTau::TauConstituent2::TauConstituent2() } - -PanTau::TauConstituent2::TauConstituent2(TLorentzVector itsMomentum, - int itsCharge, - std::vector<int> itsType, - double itsBDTValue, - xAOD::PFO* itsPFO - ) - : +PanTau::TauConstituent::TauConstituent(TLorentzVector itsMomentum, + int itsCharge, + std::vector<int> itsType, + double itsBDTValue, + xAOD::PFO* itsPFO) : IParticle(), m_p4(itsMomentum), m_p4Cached(true), m_TypeFlags(itsType), @@ -40,10 +34,7 @@ PanTau::TauConstituent2::TauConstituent2(TLorentzVector itsMomentum, } - -PanTau::TauConstituent2::TauConstituent2( - const PanTau::TauConstituent2& rhs - ): +PanTau::TauConstituent::TauConstituent(const PanTau::TauConstituent& rhs) : IParticle(rhs), m_p4(rhs.m_p4), m_p4Cached(rhs.m_p4Cached), m_TypeFlags(rhs.m_TypeFlags), @@ -56,24 +47,22 @@ PanTau::TauConstituent2::TauConstituent2( } - -PanTau::TauConstituent2::~TauConstituent2() +PanTau::TauConstituent::~TauConstituent() { //delete the shot constituents for(unsigned int iShot=0; iShot<m_Shots.size(); iShot++) { - PanTau::TauConstituent2* curConst = m_Shots[iShot]; + PanTau::TauConstituent* curConst = m_Shots[iShot]; delete curConst; } } - -PanTau::TauConstituent2& PanTau::TauConstituent2::operator=(const PanTau::TauConstituent2& tauConst) +PanTau::TauConstituent& PanTau::TauConstituent::operator=(const PanTau::TauConstituent& tauConst) { if (this!=&tauConst){ if (!this->container() && !this->hasStore() ) { - makePrivateStore(); + makePrivateStore(); } this->IParticle::operator=( tauConst ); this->m_p4 = tauConst.m_p4; @@ -89,35 +78,35 @@ PanTau::TauConstituent2& PanTau::TauConstituent2::operator=(const PanTau::TauCon } -double PanTau::TauConstituent2::pt() const { +double PanTau::TauConstituent::pt() const { static Accessor< float > acc( "pt" ); return acc( *this ); } -double PanTau::TauConstituent2::eta() const { +double PanTau::TauConstituent::eta() const { static Accessor<float > acc( "eta" ); return acc( *this ); } -double PanTau::TauConstituent2::phi() const { +double PanTau::TauConstituent::phi() const { static Accessor< float > acc( "phi" ); return acc( *this ); } -double PanTau::TauConstituent2::m() const { +double PanTau::TauConstituent::m() const { static Accessor< float> acc( "m" ); return acc( *this ); } -double PanTau::TauConstituent2::e() const{ +double PanTau::TauConstituent::e() const{ return p4().E(); } -double PanTau::TauConstituent2::rapidity() const { +double PanTau::TauConstituent::rapidity() const { return p4().Rapidity(); } -PanTau::TauConstituent2::FourMom_t PanTau::TauConstituent2::p4() const { +PanTau::TauConstituent::FourMom_t PanTau::TauConstituent::p4() const { if( ! m_p4Cached ) { m_p4.SetPtEtaPhiM( pt(), eta(), phi(),m()); m_p4Cached=true; @@ -125,7 +114,7 @@ PanTau::TauConstituent2::FourMom_t PanTau::TauConstituent2::p4() const { return m_p4; } -void PanTau::TauConstituent2::setP4(float pt, float eta, float phi, float m){ +void PanTau::TauConstituent::setP4(float pt, float eta, float phi, float m){ static Accessor< float > acc1( "pt" ); acc1( *this ) = pt; static Accessor< float > acc2( "eta" ); @@ -138,28 +127,28 @@ void PanTau::TauConstituent2::setP4(float pt, float eta, float phi, float m){ m_p4Cached=false; } -void PanTau::TauConstituent2::setPt(float pt){ +void PanTau::TauConstituent::setPt(float pt){ static Accessor< float > acc( "pt" ); acc( *this ) = pt; //Need to recalculate m_p4 if requested after update m_p4Cached=false; } -void PanTau::TauConstituent2::setEta(float eta){ +void PanTau::TauConstituent::setEta(float eta){ static Accessor< float > acc( "eta" ); acc( *this ) = eta; //Need to recalculate m_p4 if requested after update m_p4Cached=false; } -void PanTau::TauConstituent2::setPhi(float phi){ +void PanTau::TauConstituent::setPhi(float phi){ static Accessor< float > acc( "phi" ); acc( *this ) = phi; //Need to recalculate m_p4 if requested after update m_p4Cached=false; } -void PanTau::TauConstituent2::setM(float m){ +void PanTau::TauConstituent::setM(float m){ static Accessor< float > acc( "m" ); acc( *this ) = m; //Need to recalculate m_p4 if requested after update @@ -167,14 +156,12 @@ void PanTau::TauConstituent2::setM(float m){ } -xAOD::Type::ObjectType PanTau::TauConstituent2::type() const { +xAOD::Type::ObjectType PanTau::TauConstituent::type() const { return xAOD::Type::ParticleFlow; } - - -void PanTau::TauConstituent2::removeTypeFlag(TauConstituent2::Type aType) { +void PanTau::TauConstituent::removeTypeFlag(TauConstituent::Type aType) { unsigned int typeIndex = (unsigned int)aType; m_TypeFlags.at(typeIndex) = 0; return; @@ -182,94 +169,88 @@ void PanTau::TauConstituent2::removeTypeFlag(TauConstituent2::Type a //the static getTypeName which does a translation -std::string PanTau::TauConstituent2::getTypeName(PanTau::TauConstituent2::Type aType) { +std::string PanTau::TauConstituent::getTypeName(PanTau::TauConstituent::Type aType) { switch(aType) { - case PanTau::TauConstituent2::t_Charged: return "Charged"; - case PanTau::TauConstituent2::t_Neutral: return "Neutral"; - case PanTau::TauConstituent2::t_Pi0Neut: return "Pi0Neut"; - case PanTau::TauConstituent2::t_OutChrg: return "OuterChrg"; - case PanTau::TauConstituent2::t_OutNeut: return "OuterNeut"; - case PanTau::TauConstituent2::t_NeutLowA: return "NeutLowA"; - case PanTau::TauConstituent2::t_NeutLowB: return "NeutLowB"; - case PanTau::TauConstituent2::t_NoType: return "All"; + case PanTau::TauConstituent::t_Charged: return "Charged"; + case PanTau::TauConstituent::t_Neutral: return "Neutral"; + case PanTau::TauConstituent::t_Pi0Neut: return "Pi0Neut"; + case PanTau::TauConstituent::t_OutChrg: return "OuterChrg"; + case PanTau::TauConstituent::t_OutNeut: return "OuterNeut"; + case PanTau::TauConstituent::t_NeutLowA: return "NeutLowA"; + case PanTau::TauConstituent::t_NeutLowB: return "NeutLowB"; + case PanTau::TauConstituent::t_NoType: return "All"; default: return "UnkownType"; } } - -bool PanTau::TauConstituent2::isNeutralType(int tauConstituentType) { - PanTau::TauConstituent2::Type type = (PanTau::TauConstituent2::Type)tauConstituentType; +bool PanTau::TauConstituent::isNeutralType(int tauConstituentType) { + PanTau::TauConstituent::Type type = (PanTau::TauConstituent::Type)tauConstituentType; switch(type) { - case PanTau::TauConstituent2::t_Neutral: return true; - case PanTau::TauConstituent2::t_Pi0Neut: return true; - case PanTau::TauConstituent2::t_OutNeut: return true; - case PanTau::TauConstituent2::t_NeutLowA: return true; - case PanTau::TauConstituent2::t_NeutLowB: return true; + case PanTau::TauConstituent::t_Neutral: return true; + case PanTau::TauConstituent::t_Pi0Neut: return true; + case PanTau::TauConstituent::t_OutNeut: return true; + case PanTau::TauConstituent::t_NeutLowA: return true; + case PanTau::TauConstituent::t_NeutLowB: return true; default: return false; } return false; } - -bool PanTau::TauConstituent2::isCoreType(int tauConstituentType) { - PanTau::TauConstituent2::Type type = (PanTau::TauConstituent2::Type)tauConstituentType; +bool PanTau::TauConstituent::isCoreType(int tauConstituentType) { + PanTau::TauConstituent::Type type = (PanTau::TauConstituent::Type)tauConstituentType; switch(type) { - case PanTau::TauConstituent2::t_Charged: return true; - case PanTau::TauConstituent2::t_Neutral: return true; - case PanTau::TauConstituent2::t_Pi0Neut: return true; - case PanTau::TauConstituent2::t_OutNeut: return false; - case PanTau::TauConstituent2::t_OutChrg: return false; - case PanTau::TauConstituent2::t_NeutLowA: return true; - case PanTau::TauConstituent2::t_NeutLowB: return true; + case PanTau::TauConstituent::t_Charged: return true; + case PanTau::TauConstituent::t_Neutral: return true; + case PanTau::TauConstituent::t_Pi0Neut: return true; + case PanTau::TauConstituent::t_OutNeut: return false; + case PanTau::TauConstituent::t_OutChrg: return false; + case PanTau::TauConstituent::t_NeutLowA: return true; + case PanTau::TauConstituent::t_NeutLowB: return true; default: return false; } return false; } - //the non static getType name, which returns -std::vector<std::string> PanTau::TauConstituent2::getTypeName() const { +std::vector<std::string> PanTau::TauConstituent::getTypeName() const { std::vector<std::string> res; - for(unsigned int iType=0; iType<TauConstituent2::t_nTypes; iType++) { + for(unsigned int iType=0; iType<TauConstituent::t_nTypes; iType++) { if(m_TypeFlags[iType] == 1) { - PanTau::TauConstituent2::Type curType = (PanTau::TauConstituent2::Type)iType; - res.push_back( TauConstituent2::getTypeName(curType) ); + PanTau::TauConstituent::Type curType = (PanTau::TauConstituent::Type)iType; + res.push_back( TauConstituent::getTypeName(curType) ); } } return res; } - -std::string PanTau::TauConstituent2::getTypeNameString() const { +std::string PanTau::TauConstituent::getTypeNameString() const { std::string res; for(unsigned int iType=0; iType<m_TypeFlags.size(); iType++) { if(m_TypeFlags[iType] == 1) { - res += PanTau::TauConstituent2::getTypeName((PanTau::TauConstituent2::Type)(iType)) + ","; + res += PanTau::TauConstituent::getTypeName((PanTau::TauConstituent::Type)(iType)) + ","; } } return res; } - -double PanTau::TauConstituent2::getBDTValue() const { +double PanTau::TauConstituent::getBDTValue() const { return m_BDTValue; } - -std::vector<int> PanTau::TauConstituent2::getTypeFlags() const { +std::vector<int> PanTau::TauConstituent::getTypeFlags() const { return m_TypeFlags; } -bool PanTau::TauConstituent2::isOfType(PanTau::TauConstituent2::Type theType) const { +bool PanTau::TauConstituent::isOfType(PanTau::TauConstituent::Type theType) const { int typeIndex = (int)theType; - if(theType >= (int)TauConstituent2::t_nTypes) { + if(theType >= (int)TauConstituent::t_nTypes) { return false; } if(m_TypeFlags.at(typeIndex) == 1) return true; @@ -277,35 +258,36 @@ bool PanTau::TauConstituent2::isOfType(PanT } -int PanTau::TauConstituent2::getCharge() const { +int PanTau::TauConstituent::getCharge() const { return m_Charge; } - -xAOD::PFO* PanTau::TauConstituent2::getPFO() const { +xAOD::PFO* PanTau::TauConstituent::getPFO() const { return m_PFOLink; } - -void PanTau::TauConstituent2::addShot(TauConstituent2* shot) { +void PanTau::TauConstituent::addShot(TauConstituent* shot) { if(shot != 0) m_Shots.push_back(shot); } -std::vector<PanTau::TauConstituent2*> PanTau::TauConstituent2::getShots() { +std::vector<PanTau::TauConstituent*> PanTau::TauConstituent::getShots() { return m_Shots; } -unsigned int PanTau::TauConstituent2::getNShots() { + +unsigned int PanTau::TauConstituent::getNShots() { return m_Shots.size(); } -void PanTau::TauConstituent2::setNPhotonsInShot(int nPhotons) { + +void PanTau::TauConstituent::setNPhotonsInShot(int nPhotons) { m_nPhotonsInShot = nPhotons; } -int PanTau::TauConstituent2::getNPhotonsInShot() { + + +int PanTau::TauConstituent::getNPhotonsInShot() { return m_nPhotonsInShot; } - diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/TauFeature.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/TauFeature.cxx index e20077ab507134cb532dc3bc66cb135eeba4ed9d..f128b59d9bc4b45d0d5da15b8af6a44c2020a37f 100644 --- a/Reconstruction/PanTau/PanTauAlgs/Root/TauFeature.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/TauFeature.cxx @@ -6,121 +6,112 @@ #include <cmath> #include <stdexcept> -#include <iostream> - - static const std::vector<double> s_defaultVec(0); -PanTau::TauFeature2::TauFeature2() - : - m_featureMap(), - m_vecFeatureMap() - +PanTau::TauFeature::TauFeature(): + m_featureMap(), + m_vecFeatureMap() { } - -PanTau::TauFeature2::~TauFeature2() +PanTau::TauFeature::~TauFeature() { } -double PanTau::TauFeature2::value(const std::string& ItsName, bool& isValid) const -{ - FeatureMapConstIter iter = m_featureMap.find(ItsName); -if(m_featureMap.end() == iter) +double PanTau::TauFeature::value(const std::string& ItsName, bool& isValid) const { - // not found - isValid=false; - return -999999.; -} -// entry found, return value -isValid=true; -return (*iter).second; + FeatureMapConstIter iter = m_featureMap.find(ItsName); + if(m_featureMap.end() == iter) + { + isValid=false; + return -999999.; + } + // entry found, return value + isValid=true; + return (*iter).second; } -const std::vector<double>& PanTau::TauFeature2::vecValue(const std::string& name) const { - VectorFeatureMapConstIter iter = m_vecFeatureMap.find(name); - if(m_vecFeatureMap.end() == iter) + +const std::vector<double>& PanTau::TauFeature::vecValue(const std::string& name) const { + VectorFeatureMapConstIter iter = m_vecFeatureMap.find(name); + if(m_vecFeatureMap.end() == iter) { - return s_defaultVec; + return s_defaultVec; } - return (*iter).second; + return (*iter).second; } -bool PanTau::TauFeature2::addFeature( - const std::string& name, - const double& value) { - if (std::isnan(value)) { - throw std::runtime_error("TauFeature2::addFeature: Given " + name + " value is NaN!"); - } - if (std::isinf(value)){ - throw std::runtime_error("TauFeature2::addFeature: Given " + name + " value is inf!"); - } - std::pair<FeatureMapConstIter, bool> result = m_featureMap.insert(make_pair(name, value)); - return result.second; +bool PanTau::TauFeature::addFeature(const std::string& name, + const double& value) { + + if (std::isnan(value)) { + throw std::runtime_error("TauFeature::addFeature: Given " + name + " value is NaN!"); + } + if (std::isinf(value)){ + throw std::runtime_error("TauFeature::addFeature: Given " + name + " value is inf!"); + } + std::pair<FeatureMapConstIter, bool> result = m_featureMap.insert(make_pair(name, value)); + return result.second; } -bool PanTau::TauFeature2::addVecFeature( - const std::string& name, - const std::vector<double>& value) { - std::pair<VectorFeatureMapConstIter, bool> result = m_vecFeatureMap.insert(make_pair(name, value)); - return result.second; + +bool PanTau::TauFeature::addVecFeature(const std::string& name, + const std::vector<double>& value) { + std::pair<VectorFeatureMapConstIter, bool> result = m_vecFeatureMap.insert(make_pair(name, value)); + return result.second; } -int PanTau::TauFeature2::nValues() const { - return m_featureMap.size(); +int PanTau::TauFeature::nValues() const { + return m_featureMap.size(); } -int PanTau::TauFeature2::nVecValues() const { - return m_vecFeatureMap.size(); +int PanTau::TauFeature::nVecValues() const { + return m_vecFeatureMap.size(); } -void PanTau::TauFeature2::add(PanTau::TauFeature2* otherFeatures) { +void PanTau::TauFeature::add(PanTau::TauFeature* otherFeatures) { - //add the scalar features - FeatureMapIter itScalar = otherFeatures->m_featureMap.begin(); - for(; itScalar != otherFeatures->m_featureMap.end(); itScalar++) { - std::string key = itScalar->first; - double val = itScalar->second; - bool isOK = this->addFeature(key, val); - if(isOK == false) { - throw std::runtime_error("PanTau::TauFeature2::add( PanTau::TauFeature2* ): Error when adding scalar feature " + key); - } - }//end loop over scalar features to be added - - //add the vector features - VectorFeatureMapIter itVector = otherFeatures->m_vecFeatureMap.begin(); - for(; itVector != otherFeatures->m_vecFeatureMap.end(); itVector++) { - std::string key = itVector->first; - std::vector<double> val = itVector->second; - bool isOK = this->addVecFeature(key, val); - if(isOK == false) { - throw std::runtime_error("PanTau::TauFeature2::add( PanTau::TauFeature2* ): Error when adding vector feature " + key); - } - }//end loop over vector features to be added + //add the scalar features + FeatureMapIter itScalar = otherFeatures->m_featureMap.begin(); + for(; itScalar != otherFeatures->m_featureMap.end(); itScalar++) { + std::string key = itScalar->first; + double val = itScalar->second; + bool isOK = this->addFeature(key, val); + if(isOK == false) { + throw std::runtime_error("PanTau::TauFeature::add( PanTau::TauFeature* ): Error when adding scalar feature " + key); + } + } + //add the vector features + VectorFeatureMapIter itVector = otherFeatures->m_vecFeatureMap.begin(); + for(; itVector != otherFeatures->m_vecFeatureMap.end(); itVector++) { + std::string key = itVector->first; + std::vector<double> val = itVector->second; + bool isOK = this->addVecFeature(key, val); + if(isOK == false) { + throw std::runtime_error("PanTau::TauFeature::add( PanTau::TauFeature* ): Error when adding vector feature " + key); + } + } } - -void PanTau::TauFeature2::addFeaturesFromMap(std::map<std::string, double> otherMap, std::string prefix = "") { +void PanTau::TauFeature::addFeaturesFromMap(std::map<std::string, double> otherMap, std::string prefix = "") { - FeatureMapConstIter iter = otherMap.begin(); - FeatureMapConstIter iterEnd = otherMap.end(); + FeatureMapConstIter iter = otherMap.begin(); + FeatureMapConstIter iterEnd = otherMap.end(); - for(; iter != iterEnd; iter++) { - std::string oKey = prefix + iter->first; - double oVal = iter->second; - addFeature(oKey, oVal); - } + for(; iter != iterEnd; iter++) { + std::string oKey = prefix + iter->first; + double oVal = iter->second; + addFeature(oKey, oVal); + } - return; + return; } - diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_DecayModeDeterminator.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_DecayModeDeterminator.cxx index 84624acb99b25b683e963b30169c4298d54b1684..62a90fdbaa90acaa01a57e6b4f73bde8e5d9be26 100644 --- a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_DecayModeDeterminator.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_DecayModeDeterminator.cxx @@ -2,368 +2,322 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ - -//! PanTau includes #include "PanTauAlgs/Tool_DecayModeDeterminator.h" - #include "PanTauAlgs/PanTauSeed.h" #include "PanTauAlgs/HelperFunctions.h" #include "PanTauAlgs/TauClassificationTypes.h" - #include "xAODTau/TauDefs.h" +PanTau::Tool_DecayModeDeterminator::Tool_DecayModeDeterminator(const std::string& name) : + asg::AsgTool(name), + m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore"), + m_Tool_ModeDiscriminator_1p0n_vs_1p1n("PanTau::Tool_ModeDiscriminator/Tool_ModeDiscriminator"), + m_Tool_ModeDiscriminator_1p1n_vs_1pXn("PanTau::Tool_ModeDiscriminator/Tool_ModeDiscriminator"), + m_Tool_ModeDiscriminator_3p0n_vs_3pXn("PanTau::Tool_ModeDiscriminator/Tool_ModeDiscriminator") +{ -PanTau::Tool_DecayModeDeterminator::Tool_DecayModeDeterminator( - const std::string& name ) : - asg::AsgTool(name), - m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore"), - m_Tool_ModeDiscriminator_1p0n_vs_1p1n("PanTau::Tool_ModeDiscriminator/Tool_ModeDiscriminator"), - m_Tool_ModeDiscriminator_1p1n_vs_1pXn("PanTau::Tool_ModeDiscriminator/Tool_ModeDiscriminator"), - m_Tool_ModeDiscriminator_3p0n_vs_3pXn("PanTau::Tool_ModeDiscriminator/Tool_ModeDiscriminator") - { + declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Tool handle to the information store tool"); + declareProperty("Tool_ModeDiscriminator_1p0n_vs_1p1n", m_Tool_ModeDiscriminator_1p0n_vs_1p1n, "Handle to the ModeDiscriminator tool for 1p0n_vs_1p1n"); + declareProperty("Tool_ModeDiscriminator_1p1n_vs_1pXn", m_Tool_ModeDiscriminator_1p1n_vs_1pXn, "Handle to the ModeDiscriminator tool for 1p1n_vs_1pXn"); + declareProperty("Tool_ModeDiscriminator_3p0n_vs_3pXn", m_Tool_ModeDiscriminator_3p0n_vs_3pXn, "Handle to the ModeDiscriminator tool for 3p0n_vs_3pXn"); - declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Tool handle to the information store tool"); - declareProperty("Tool_ModeDiscriminator_1p0n_vs_1p1n", m_Tool_ModeDiscriminator_1p0n_vs_1p1n, "Handle to the ModeDiscriminator tool for 1p0n_vs_1p1n"); - declareProperty("Tool_ModeDiscriminator_1p1n_vs_1pXn", m_Tool_ModeDiscriminator_1p1n_vs_1pXn, "Handle to the ModeDiscriminator tool for 1p1n_vs_1pXn"); - declareProperty("Tool_ModeDiscriminator_3p0n_vs_3pXn", m_Tool_ModeDiscriminator_3p0n_vs_3pXn, "Handle to the ModeDiscriminator tool for 3p0n_vs_3pXn"); - - declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName="", "Tool handle to the information store tool"); - declareProperty("Tool_ModeDiscriminator_1p0n_vs_1p1nName", m_Tool_ModeDiscriminator_1p0n_vs_1p1nName="", "Handle to the ModeDiscriminator tool for 1p0n_vs_1p1n"); - declareProperty("Tool_ModeDiscriminator_1p1n_vs_1pXnName", m_Tool_ModeDiscriminator_1p1n_vs_1pXnName="", "Handle to the ModeDiscriminator tool for 1p1n_vs_1pXn"); - declareProperty("Tool_ModeDiscriminator_3p0n_vs_3pXnName", m_Tool_ModeDiscriminator_3p0n_vs_3pXnName="", "Handle to the ModeDiscriminator tool for 3p0n_vs_3pXn"); + declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName="", "Tool handle to the information store tool"); + declareProperty("Tool_ModeDiscriminator_1p0n_vs_1p1nName", m_Tool_ModeDiscriminator_1p0n_vs_1p1nName="", "Handle to the ModeDiscriminator tool for 1p0n_vs_1p1n"); + declareProperty("Tool_ModeDiscriminator_1p1n_vs_1pXnName", m_Tool_ModeDiscriminator_1p1n_vs_1pXnName="", "Handle to the ModeDiscriminator tool for 1p1n_vs_1pXn"); + declareProperty("Tool_ModeDiscriminator_3p0n_vs_3pXnName", m_Tool_ModeDiscriminator_3p0n_vs_3pXnName="", "Handle to the ModeDiscriminator tool for 3p0n_vs_3pXn"); } - PanTau::Tool_DecayModeDeterminator::~Tool_DecayModeDeterminator() { } - StatusCode PanTau::Tool_DecayModeDeterminator::initialize() { - m_init=true; + m_init=true; - ATH_CHECK( HelperFunctions::bindToolHandle(m_Tool_InformationStore, m_Tool_InformationStoreName) ); - ATH_CHECK( HelperFunctions::bindToolHandle(m_Tool_ModeDiscriminator_1p0n_vs_1p1n, m_Tool_ModeDiscriminator_1p0n_vs_1p1nName) ); - ATH_CHECK( HelperFunctions::bindToolHandle(m_Tool_ModeDiscriminator_1p1n_vs_1pXn, m_Tool_ModeDiscriminator_1p1n_vs_1pXnName) ); - ATH_CHECK( HelperFunctions::bindToolHandle(m_Tool_ModeDiscriminator_3p0n_vs_3pXn, m_Tool_ModeDiscriminator_3p0n_vs_3pXnName) ); + ATH_CHECK( HelperFunctions::bindToolHandle(m_Tool_InformationStore, m_Tool_InformationStoreName) ); + ATH_CHECK( HelperFunctions::bindToolHandle(m_Tool_ModeDiscriminator_1p0n_vs_1p1n, m_Tool_ModeDiscriminator_1p0n_vs_1p1nName) ); + ATH_CHECK( HelperFunctions::bindToolHandle(m_Tool_ModeDiscriminator_1p1n_vs_1pXn, m_Tool_ModeDiscriminator_1p1n_vs_1pXnName) ); + ATH_CHECK( HelperFunctions::bindToolHandle(m_Tool_ModeDiscriminator_3p0n_vs_3pXn, m_Tool_ModeDiscriminator_3p0n_vs_3pXnName) ); - //get the discri tools - ATH_CHECK(m_Tool_ModeDiscriminator_1p0n_vs_1p1n.retrieve()); - ATH_CHECK(m_Tool_ModeDiscriminator_1p1n_vs_1pXn.retrieve()); - ATH_CHECK(m_Tool_ModeDiscriminator_3p0n_vs_3pXn.retrieve()); + //get the discri tools + ATH_CHECK(m_Tool_ModeDiscriminator_1p0n_vs_1p1n.retrieve()); + ATH_CHECK(m_Tool_ModeDiscriminator_1p1n_vs_1pXn.retrieve()); + ATH_CHECK(m_Tool_ModeDiscriminator_3p0n_vs_3pXn.retrieve()); - //get the variable prefix - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Basic", m_varTypeName_Prefix_Basic) ); - - //get the BDT cut values - ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R10X_CellBased", m_BDTCutValue_R10X_CellBased) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R11X_CellBased", m_BDTCutValue_R11X_CellBased) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R110_CellBased", m_BDTCutValue_R110_CellBased) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R1XX_CellBased", m_BDTCutValue_R1XX_CellBased) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R30X_CellBased", m_BDTCutValue_R30X_CellBased) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R3XX_CellBased", m_BDTCutValue_R3XX_CellBased) ); - - return StatusCode::SUCCESS; + //get the variable prefix + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Basic", m_varTypeName_Prefix_Basic) ); + + //get the BDT cut values + ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R10X_CellBased", m_BDTCutValue_R10X_CellBased) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R11X_CellBased", m_BDTCutValue_R11X_CellBased) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R110_CellBased", m_BDTCutValue_R110_CellBased) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R1XX_CellBased", m_BDTCutValue_R1XX_CellBased) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R30X_CellBased", m_BDTCutValue_R30X_CellBased) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R3XX_CellBased", m_BDTCutValue_R3XX_CellBased) ); + + return StatusCode::SUCCESS; } - -StatusCode PanTau::Tool_DecayModeDeterminator::execute(PanTau::PanTauSeed2* inSeed) { - - std::string inAlgName = inSeed->getNameInputAlgorithm(); - PanTau::TauFeature2* features = inSeed->getFeatures(); +StatusCode PanTau::Tool_DecayModeDeterminator::execute(PanTau::PanTauSeed* inSeed) { - //check for invalid input seed - bool noValidInput = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed2::t_NoValidInputTau); - bool noAnyConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed2::t_NoConstituentsAtAll); - bool noSelConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed2::t_NoSelectedConstituents); - bool badPt = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed2::t_BadPtValue); - bool invalidForDecayMode = (noValidInput || noAnyConstituents || noSelConstituents || badPt); - if(invalidForDecayMode) { - ATH_MSG_DEBUG("Seed has no constituents assigned and/or input seed has no substructure info - use NotSet mode for this"); - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_RecoMode_PanTau", xAOD::TauJetParameters::Mode_NotSet); - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_RecoMode_PanTauExtended", PanTau::PanTauSeed2::t_ExtModeNotSet); - return StatusCode::SUCCESS; - } + std::string inAlgName = inSeed->getNameInputAlgorithm(); + PanTau::TauFeature* features = inSeed->getFeatures(); + //check for invalid input seed + bool noValidInput = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_NoValidInputTau); + bool noAnyConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_NoConstituentsAtAll); + bool noSelConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_NoSelectedConstituents); + bool badPt = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_BadPtValue); + bool invalidForDecayMode = (noValidInput || noAnyConstituents || noSelConstituents || badPt); + if(invalidForDecayMode) { + ATH_MSG_DEBUG("Seed has no constituents assigned and/or input seed has no substructure info - use NotSet mode for this"); + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_RecoMode_PanTau", xAOD::TauJetParameters::Mode_NotSet); + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_RecoMode_PanTauExtended", PanTau::PanTauSeed::t_ExtModeNotSet); + return StatusCode::SUCCESS; + } - //get the mode as it was determined by the subalgorithm - int decayMode_SubAlg = inSeed->getDecayModeBySubAlg(); - int decayMode_PanTau = xAOD::TauJetParameters::Mode_NotSet; - int decayMode_PanTauExtended = PanTau::PanTauSeed2::t_ExtModeNotSet; + //get the mode as it was determined by the subalgorithm + int decayMode_SubAlg = inSeed->getDecayModeBySubAlg(); + int decayMode_PanTau = xAOD::TauJetParameters::Mode_NotSet; + int decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtModeNotSet; - //and calc the number of additional neutrals, not tagged as pi0 - int nCharged_SubAlg = inSeed->getNumberOfConstituentsOfType(PanTau::TauConstituent2::t_Charged); - int nPi0Neut_SubAlg = inSeed->getNumberOfConstituentsOfType(PanTau::TauConstituent2::t_Pi0Neut); - int nNeutrals_SubAlg = inSeed->getNumberOfConstituentsOfType(PanTau::TauConstituent2::t_Neutral); - int AdditionalNeutrals = nNeutrals_SubAlg - nPi0Neut_SubAlg; - - double BDTCutValue_R10X = 0.; - double BDTCutValue_R110 = 0.; - double BDTCutValue_R11X = 0.; - double BDTCutValue_R1XX = 0.; - double BDTCutValue_R30X = 0.; - double BDTCutValue_R3XX = 0.; - - BDTCutValue_R10X = m_BDTCutValue_R10X_CellBased; - BDTCutValue_R110 = m_BDTCutValue_R110_CellBased; - BDTCutValue_R11X = m_BDTCutValue_R11X_CellBased; - BDTCutValue_R1XX = m_BDTCutValue_R1XX_CellBased; - BDTCutValue_R30X = m_BDTCutValue_R30X_CellBased; - BDTCutValue_R3XX = m_BDTCutValue_R3XX_CellBased; - - //based on the subAlg decay mode, pass to corresponding PanTau BDT... - double bdtResponse = -5; - DecayModeTest bdtTest = t_UnknownTest; - // 1p0n mode - if(decayMode_SubAlg == xAOD::TauJetParameters::Mode_1p0n) { - - - //1 prong, and no other objects at all -> use 1p0n - if(AdditionalNeutrals == 0) { - decayMode_PanTau = xAOD::TauJetParameters::Mode_1p0n; - decayMode_PanTauExtended = PanTau::PanTauSeed2::t_ExtMode100; - bdtResponse = -3.; - - //if there are neutrals which are not pi0-tagged, check BDT to maybe set 1p1n - } else { - - bool isOK = false; - bdtResponse = m_Tool_ModeDiscriminator_1p0n_vs_1p1n->getResponse(inSeed, isOK); - bdtTest = t_1p0n_vs_1p1n; - decayMode_PanTauExtended = PanTau::PanTauSeed2::t_ExtMode10X; - if(isOK == false) { - ATH_MSG_WARNING("WARNING: problems getting bdt response for 1p0n + X-neutrals. use subAlg mode"); - decayMode_PanTau = decayMode_SubAlg; - } else { - if(bdtResponse > BDTCutValue_R10X) { - decayMode_PanTau = xAOD::TauJetParameters::Mode_1p0n; - } - if(bdtResponse <= BDTCutValue_R10X) { - decayMode_PanTau = xAOD::TauJetParameters::Mode_1p1n; - } - ATH_MSG_DEBUG("R10X: Response is: " << bdtResponse << " Use 1p0n if > " << BDTCutValue_R10X << " -- decision: " << PanTau::PanTauSeed2::getDecayModeName(decayMode_PanTau) ); - } - } - - }//end 1p0n - - - //1p1n mode - else if (decayMode_SubAlg == xAOD::TauJetParameters::Mode_1p1n) { - - - //1prong, 1pi0 and no other neutrals. check 1p0n-vs-1p1n - if(AdditionalNeutrals == 0) { - bool isOK = false; - bdtResponse = m_Tool_ModeDiscriminator_1p0n_vs_1p1n->getResponse(inSeed, isOK); - bdtTest = t_1p0n_vs_1p1n; - decayMode_PanTauExtended = PanTau::PanTauSeed2::t_ExtMode110; - if(isOK == false) { - ATH_MSG_WARNING("WARNING problems getting bdt response for 1p1n + 0-neutrals. use subAlg mode"); - decayMode_PanTau = decayMode_SubAlg; - } else { - if(bdtResponse <= BDTCutValue_R110) { - decayMode_PanTau = xAOD::TauJetParameters::Mode_1p1n; - } - if(bdtResponse > BDTCutValue_R110) { - decayMode_PanTau = xAOD::TauJetParameters::Mode_1p0n; - } - } - - - //1prong, 1pi0 and additional neutrals. check 1p1n vs 1pXn - } else { - //NOTE: May investigate chain of decisions here: first check 1p0n-1p1n, and then (in case of 1p1n) 1p1n-1pXn - bool isOK = false; - bdtResponse = m_Tool_ModeDiscriminator_1p1n_vs_1pXn->getResponse(inSeed, isOK); - bdtTest = t_1p1n_vs_1pXn; - decayMode_PanTauExtended = PanTau::PanTauSeed2::t_ExtMode11X; - if(isOK == false) { - ATH_MSG_WARNING("WARNING problems getting bdt response for 1p1n + X-neutrals. use subAlg mode"); - decayMode_PanTau = decayMode_SubAlg; - } else { - if(bdtResponse > BDTCutValue_R11X) { - decayMode_PanTau = xAOD::TauJetParameters::Mode_1p1n; - } - if(bdtResponse <= BDTCutValue_R11X) { - decayMode_PanTau = xAOD::TauJetParameters::Mode_1pXn; - } - } - } - - }//end 1p1n - - - - //1pXn mode - else if (decayMode_SubAlg == xAOD::TauJetParameters::Mode_1pXn) { - - //1prong, Xpi0. check 1p1n-vs-1pXn - bool isOK = false; - bdtResponse = m_Tool_ModeDiscriminator_1p1n_vs_1pXn->getResponse(inSeed, isOK); - bdtTest = t_1p1n_vs_1pXn; - decayMode_PanTauExtended = PanTau::PanTauSeed2::t_ExtMode1XX; - if(isOK == false) { - ATH_MSG_WARNING("WARNING problems getting bdt response for 1p1n + X-neutrals. use subAlg mode"); - decayMode_PanTau = decayMode_SubAlg; - } else { - if(bdtResponse > BDTCutValue_R1XX) { - decayMode_PanTau = xAOD::TauJetParameters::Mode_1p1n; - } - if(bdtResponse <= BDTCutValue_R1XX) { - decayMode_PanTau = xAOD::TauJetParameters::Mode_1pXn; - } - } - - }//end 1pXn + //and calc the number of additional neutrals, not tagged as pi0 + int nCharged_SubAlg = inSeed->getNumberOfConstituentsOfType(PanTau::TauConstituent::t_Charged); + int nPi0Neut_SubAlg = inSeed->getNumberOfConstituentsOfType(PanTau::TauConstituent::t_Pi0Neut); + int nNeutrals_SubAlg = inSeed->getNumberOfConstituentsOfType(PanTau::TauConstituent::t_Neutral); + int AdditionalNeutrals = nNeutrals_SubAlg - nPi0Neut_SubAlg; + double BDTCutValue_R10X = m_BDTCutValue_R10X_CellBased; + double BDTCutValue_R110 = m_BDTCutValue_R110_CellBased; + double BDTCutValue_R11X = m_BDTCutValue_R11X_CellBased; + double BDTCutValue_R1XX = m_BDTCutValue_R1XX_CellBased; + double BDTCutValue_R30X = m_BDTCutValue_R30X_CellBased; + double BDTCutValue_R3XX = m_BDTCutValue_R3XX_CellBased; - - //3p0n mode - else if (decayMode_SubAlg == xAOD::TauJetParameters::Mode_3p0n) { - - //no additional neutrals. - if(AdditionalNeutrals == 0) { - decayMode_PanTau = xAOD::TauJetParameters::Mode_3p0n; - decayMode_PanTauExtended = PanTau::PanTauSeed2::t_ExtMode300; - bdtResponse = -2.5; - - //additional neutrals - } else { + //based on the subAlg decay mode, pass to corresponding PanTau BDT... + double bdtResponse = -5; + DecayModeTest bdtTest = t_UnknownTest; + // 1p0n mode + if(decayMode_SubAlg == xAOD::TauJetParameters::Mode_1p0n) { + + //1 prong, and no other objects at all -> use 1p0n + if(AdditionalNeutrals == 0) { + decayMode_PanTau = xAOD::TauJetParameters::Mode_1p0n; + decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode100; + bdtResponse = -3.; - bool isOK = false; - bdtResponse = m_Tool_ModeDiscriminator_3p0n_vs_3pXn->getResponse(inSeed, isOK); - bdtTest = t_3p0n_vs_3pXn; - decayMode_PanTauExtended = PanTau::PanTauSeed2::t_ExtMode30X; - if(isOK == false) { - ATH_MSG_WARNING("WARNING problems getting bdt response for 3p0n + X-neutrals. use subAlg mode"); - decayMode_PanTau = decayMode_SubAlg; - } else { - if(bdtResponse > BDTCutValue_R30X) { - decayMode_PanTau = xAOD::TauJetParameters::Mode_3p0n; - } - if(bdtResponse <= BDTCutValue_R30X) { - decayMode_PanTau = xAOD::TauJetParameters::Mode_3pXn; - } - ATH_MSG_DEBUG("R30X: Response is: " << bdtResponse << " Use 3p0n if > " << BDTCutValue_R30X << " -- decision: " << PanTau::PanTauSeed2::getDecayModeName(decayMode_PanTau) ); - } - - } - - ATH_MSG_DEBUG("SubAlgMode " << decayMode_SubAlg << ". Chrg/Neut: " << nCharged_SubAlg << " / " << nPi0Neut_SubAlg << ". Mode set to: " << decayMode_PanTau << " - " << PanTau::PanTauSeed2::getDecayModeName(decayMode_PanTau)); - }//end 3p0n - - + //if there are neutrals which are not pi0-tagged, check BDT to maybe set 1p1n + } + else { + bool isOK = false; + bdtResponse = m_Tool_ModeDiscriminator_1p0n_vs_1p1n->getResponse(inSeed, isOK); + bdtTest = t_1p0n_vs_1p1n; + decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode10X; + if(isOK == false) { + ATH_MSG_WARNING("WARNING: problems getting bdt response for 1p0n + X-neutrals. use subAlg mode"); + decayMode_PanTau = decayMode_SubAlg; + } + else { + if(bdtResponse > BDTCutValue_R10X) { + decayMode_PanTau = xAOD::TauJetParameters::Mode_1p0n; + } + if(bdtResponse <= BDTCutValue_R10X) { + decayMode_PanTau = xAOD::TauJetParameters::Mode_1p1n; + } + } + } + }//end 1p0n - //3pXn mode - else if (decayMode_SubAlg == xAOD::TauJetParameters::Mode_3pXn) { - - //3prong, Xpi0. check 3p0n-vs-3pXn - bool isOK = false; - bdtResponse = m_Tool_ModeDiscriminator_3p0n_vs_3pXn->getResponse(inSeed, isOK); - bdtTest = t_3p0n_vs_3pXn; - decayMode_PanTauExtended = PanTau::PanTauSeed2::t_ExtMode3XX; - if(isOK == false) { - ATH_MSG_WARNING("WARNING problems getting bdt response for 3p0n + X-neutrals. use subAlg mode"); - decayMode_PanTau = decayMode_SubAlg; - } else { - if(bdtResponse > BDTCutValue_R3XX) { - decayMode_PanTau = xAOD::TauJetParameters::Mode_3p0n; - } - if(bdtResponse <= BDTCutValue_R3XX) { - decayMode_PanTau = xAOD::TauJetParameters::Mode_3pXn; - } - } + //1p1n mode + else if (decayMode_SubAlg == xAOD::TauJetParameters::Mode_1p1n) { + //1prong, 1pi0 and no other neutrals. check 1p0n-vs-1p1n + if(AdditionalNeutrals == 0) { + bool isOK = false; + bdtResponse = m_Tool_ModeDiscriminator_1p0n_vs_1p1n->getResponse(inSeed, isOK); + bdtTest = t_1p0n_vs_1p1n; + decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode110; + if(isOK == false) { + ATH_MSG_WARNING("WARNING problems getting bdt response for 1p1n + 0-neutrals. use subAlg mode"); + decayMode_PanTau = decayMode_SubAlg; + } + else { + if(bdtResponse <= BDTCutValue_R110) { + decayMode_PanTau = xAOD::TauJetParameters::Mode_1p1n; + } + if(bdtResponse > BDTCutValue_R110) { + decayMode_PanTau = xAOD::TauJetParameters::Mode_1p0n; + } + } + //1prong, 1pi0 and additional neutrals. check 1p1n vs 1pXn + } + else { + //NOTE: May investigate chain of decisions here: first check 1p0n-1p1n, and then (in case of 1p1n) 1p1n-1pXn + bool isOK = false; + bdtResponse = m_Tool_ModeDiscriminator_1p1n_vs_1pXn->getResponse(inSeed, isOK); + bdtTest = t_1p1n_vs_1pXn; + decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode11X; + if(isOK == false) { + ATH_MSG_WARNING("WARNING problems getting bdt response for 1p1n + X-neutrals. use subAlg mode"); + decayMode_PanTau = decayMode_SubAlg; + } + else { + if(bdtResponse > BDTCutValue_R11X) { + decayMode_PanTau = xAOD::TauJetParameters::Mode_1p1n; + } + if(bdtResponse <= BDTCutValue_R11X) { + decayMode_PanTau = xAOD::TauJetParameters::Mode_1pXn; + } + } + } + }//end 1p1n - } //end 3pXn - - + //1pXn mode + else if (decayMode_SubAlg == xAOD::TauJetParameters::Mode_1pXn) { + //1prong, Xpi0. check 1p1n-vs-1pXn + bool isOK = false; + bdtResponse = m_Tool_ModeDiscriminator_1p1n_vs_1pXn->getResponse(inSeed, isOK); + bdtTest = t_1p1n_vs_1pXn; + decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode1XX; + if(isOK == false) { + ATH_MSG_WARNING("WARNING problems getting bdt response for 1p1n + X-neutrals. use subAlg mode"); + decayMode_PanTau = decayMode_SubAlg; + } else { + if(bdtResponse > BDTCutValue_R1XX) { + decayMode_PanTau = xAOD::TauJetParameters::Mode_1p1n; + } + if(bdtResponse <= BDTCutValue_R1XX) { + decayMode_PanTau = xAOD::TauJetParameters::Mode_1pXn; + } + } + }//end 1pXn - //it's none of 1p0n, 1p1n, 1pXn, 3p0n, 3pXn -> set other mode - else { - decayMode_PanTau = xAOD::TauJetParameters::Mode_Other; - decayMode_PanTauExtended = PanTau::PanTauSeed2::t_ExtModeOther; - bdtResponse = -4; - bdtTest = t_UnknownTest; + //3p0n mode + else if (decayMode_SubAlg == xAOD::TauJetParameters::Mode_3p0n) { + //no additional neutrals. + if(AdditionalNeutrals == 0) { + decayMode_PanTau = xAOD::TauJetParameters::Mode_3p0n; + decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode300; + bdtResponse = -2.5; + //additional neutrals + } + else { + bool isOK = false; + bdtResponse = m_Tool_ModeDiscriminator_3p0n_vs_3pXn->getResponse(inSeed, isOK); + bdtTest = t_3p0n_vs_3pXn; + decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode30X; + if(isOK == false) { + ATH_MSG_WARNING("WARNING problems getting bdt response for 3p0n + X-neutrals. use subAlg mode"); + decayMode_PanTau = decayMode_SubAlg; + } + else { + if(bdtResponse > BDTCutValue_R30X) { + decayMode_PanTau = xAOD::TauJetParameters::Mode_3p0n; + } + if(bdtResponse <= BDTCutValue_R30X) { + decayMode_PanTau = xAOD::TauJetParameters::Mode_3pXn; + } + } + } + }//end 3p0n + + //3pXn mode + else if (decayMode_SubAlg == xAOD::TauJetParameters::Mode_3pXn) { + //3prong, Xpi0. check 3p0n-vs-3pXn + bool isOK = false; + bdtResponse = m_Tool_ModeDiscriminator_3p0n_vs_3pXn->getResponse(inSeed, isOK); + bdtTest = t_3p0n_vs_3pXn; + decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode3XX; + if(isOK == false) { + ATH_MSG_WARNING("WARNING problems getting bdt response for 3p0n + X-neutrals. use subAlg mode"); + decayMode_PanTau = decayMode_SubAlg; } - - if(inAlgName != "CellBased") { - ATH_MSG_WARNING("Name of input algorithm not known - use mode from sub alg!"); - decayMode_PanTau = decayMode_SubAlg; - bdtResponse = -5; - bdtTest = t_UnknownTest; + else { + if(bdtResponse > BDTCutValue_R3XX) { + decayMode_PanTau = xAOD::TauJetParameters::Mode_3p0n; + } + if(bdtResponse <= BDTCutValue_R3XX) { + decayMode_PanTau = xAOD::TauJetParameters::Mode_3pXn; + } } + } //end 3pXn - // this overrides Pantau BDT 1p1n decision in the following case: - // if cell based counted 1 charged, 1 pi0neut, and number of hits in EM1 for the pi0neut is 3 or larger, set 1pXn; - if(nCharged_SubAlg == 1 && nPi0Neut_SubAlg == 1) { - //check for shots in EM1 - bool isOK = false; - PanTau::TauConstituent2* pi0Neut = inSeed->getConstituentsOfType(PanTau::TauConstituent2::t_Pi0Neut, isOK).at(0); - if(isOK == true) { - double nPhotons = 0; - std::vector<PanTau::TauConstituent2*> shots = pi0Neut->getShots(); - - for(unsigned int iShot=0; iShot<shots.size(); iShot++) { - nPhotons = nPhotons + (double)(shots.at(iShot)->getNPhotonsInShot()); - } - - if(nPhotons > 2) { - decayMode_SubAlg = xAOD::TauJetParameters::Mode_1pXn; - decayMode_PanTau = xAOD::TauJetParameters::Mode_1pXn; - decayMode_PanTauExtended = PanTau::PanTauSeed2::t_ExtMode11shots; - inSeed->setModeHackedByCellBased(true); - bdtResponse = -2.; - } - - //end check for pi0 neutrals were found - } else { - ATH_MSG_WARNING("Could not find expected CellBased neutral -> don't check for photons in cluster"); - } - } //end hack check for 1p1n - - //update mode of seed and store in features - inSeed->setDecayModeByPanTau(decayMode_PanTau); - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_RecoMode", (double)decayMode_SubAlg); - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_RecoMode_PanTau", (double)decayMode_PanTau); - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_RecoMode_PanTauExtended", (double)decayMode_PanTauExtended); - - xAOD::TauJet* tauJet = const_cast<xAOD::TauJet*>(inSeed->getTauJet()); - // tauJet->auxdecor<size_t>("PanTau_DecayModeExtended") = decayMode_PanTauExtended; - tauJet->setPanTauDetail(xAOD::TauJetParameters::PanTauDetails::PanTau_DecayModeExtended, decayMode_PanTauExtended); + //it's none of 1p0n, 1p1n, 1pXn, 3p0n, 3pXn -> set other mode + else { + decayMode_PanTau = xAOD::TauJetParameters::Mode_Other; + decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtModeOther; + bdtResponse = -4; + bdtTest = t_UnknownTest; + } + + if(inAlgName != "CellBased") { + ATH_MSG_WARNING("Name of input algorithm not known - use mode from sub alg!"); + decayMode_PanTau = decayMode_SubAlg; + bdtResponse = -5; + bdtTest = t_UnknownTest; + } - if(bdtTest == t_1p0n_vs_1p1n) { - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p0n_vs_1p1n", bdtResponse); - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p1n_vs_1pXn", -5.); - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_3p0n_vs_3pXn", -5.); + // this overrides Pantau BDT 1p1n decision in the following case: + // if cell based counted 1 charged, 1 pi0neut, and number of hits in EM1 for the pi0neut is 3 or larger, set 1pXn; + if(nCharged_SubAlg == 1 && nPi0Neut_SubAlg == 1) { + //check for shots in EM1 + bool isOK = false; + PanTau::TauConstituent* pi0Neut = inSeed->getConstituentsOfType(PanTau::TauConstituent::t_Pi0Neut, isOK).at(0); + if(isOK == true) { + double nPhotons = 0; + std::vector<PanTau::TauConstituent*> shots = pi0Neut->getShots(); + + for(unsigned int iShot=0; iShot<shots.size(); iShot++) { + nPhotons = nPhotons + (double)(shots.at(iShot)->getNPhotonsInShot()); + } + + if(nPhotons > 2) { + decayMode_SubAlg = xAOD::TauJetParameters::Mode_1pXn; + decayMode_PanTau = xAOD::TauJetParameters::Mode_1pXn; + decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode11shots; + inSeed->setModeHackedByCellBased(true); + bdtResponse = -2.; + } + //end check for pi0 neutrals were found } - if(bdtTest == t_1p1n_vs_1pXn) { - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p0n_vs_1p1n", -5.); - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p1n_vs_1pXn", bdtResponse); - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_3p0n_vs_3pXn", -5.); - } - if(bdtTest == t_3p0n_vs_3pXn) { - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p0n_vs_1p1n", -5.); - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p1n_vs_1pXn", -5.); - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_3p0n_vs_3pXn", bdtResponse); - } - if(bdtTest == t_UnknownTest) { - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p0n_vs_1p1n", -5.); - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p1n_vs_1pXn", -5.); - features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_3p0n_vs_3pXn", -5.); + else { + ATH_MSG_WARNING("Could not find expected CellBased neutral -> don't check for photons in cluster"); } - - return StatusCode::SUCCESS; + } //end hack check for 1p1n + + //update mode of seed and store in features + inSeed->setDecayModeByPanTau(decayMode_PanTau); + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_RecoMode", (double)decayMode_SubAlg); + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_RecoMode_PanTau", (double)decayMode_PanTau); + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_RecoMode_PanTauExtended", (double)decayMode_PanTauExtended); + + xAOD::TauJet* tauJet = const_cast<xAOD::TauJet*>(inSeed->getTauJet()); + tauJet->setPanTauDetail(xAOD::TauJetParameters::PanTauDetails::PanTau_DecayModeExtended, decayMode_PanTauExtended); + + if(bdtTest == t_1p0n_vs_1p1n) { + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p0n_vs_1p1n", bdtResponse); + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p1n_vs_1pXn", -5.); + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_3p0n_vs_3pXn", -5.); + } + if(bdtTest == t_1p1n_vs_1pXn) { + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p0n_vs_1p1n", -5.); + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p1n_vs_1pXn", bdtResponse); + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_3p0n_vs_3pXn", -5.); + } + if(bdtTest == t_3p0n_vs_3pXn) { + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p0n_vs_1p1n", -5.); + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p1n_vs_1pXn", -5.); + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_3p0n_vs_3pXn", bdtResponse); + } + if(bdtTest == t_UnknownTest) { + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p0n_vs_1p1n", -5.); + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p1n_vs_1pXn", -5.); + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_BDTValue_3p0n_vs_3pXn", -5.); + } + + return StatusCode::SUCCESS; } - - - - - - - diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_DetailsArranger.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_DetailsArranger.cxx index 8186e9f4dac4c96a36a620000bb15f650ffe9e77..a7e97812bce524b84ee3cc3d520ea7436fc40527 100644 --- a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_DetailsArranger.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_DetailsArranger.cxx @@ -2,17 +2,14 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -//! C++ #include <string> #include <vector> -//! xAOD EDM #include "xAODTau/TauJet.h" #include "xAODPFlow/PFOContainer.h" #include "xAODParticleEvent/Particle.h" #include "xAODParticleEvent/ParticleContainer.h" -//! PanTau includes #include "PanTauAlgs/Tool_DetailsArranger.h" #include "PanTauAlgs/PanTauSeed.h" #include "PanTauAlgs/HelperFunctions.h" @@ -21,365 +18,346 @@ bool sortBDTscore(ElementLink< xAOD::PFOContainer > i, ElementLink< xAOD::PFOContainer > j){ return ( i.cachedElement()->bdtPi0Score() > j.cachedElement()->bdtPi0Score() ); - } -PanTau::Tool_DetailsArranger::Tool_DetailsArranger( - const std::string& name ) : - asg::AsgTool(name), - m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore") +PanTau::Tool_DetailsArranger::Tool_DetailsArranger(const std::string& name) : + asg::AsgTool(name), + m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore") { - declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Tool handle to the information store tool"); - declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName, "Tool handle to the information store tool"); + declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Tool handle to the information store tool"); + declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName, "Tool handle to the information store tool"); } - PanTau::Tool_DetailsArranger::~Tool_DetailsArranger() { } - StatusCode PanTau::Tool_DetailsArranger::initialize() { - m_init=true; + m_init=true; - ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) ); + ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_Types_DeltaRCore", m_CoreCone) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_BinEdges_Eta", m_EtaBinEdges) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_Neutral_EtaBinned_EtCut", m_EtaBinnedEtCuts) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Sum", m_varTypeName_Sum) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Ratio", m_varTypeName_Ratio) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_EtInRing", m_varTypeName_EtInRing) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Isolation", m_varTypeName_Isolation) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Num", m_varTypeName_Num) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Mean", m_varTypeName_Mean) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_StdDev", m_varTypeName_StdDev) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_HLV", m_varTypeName_HLV) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Angle", m_varTypeName_Angle) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_DeltaR", m_varTypeName_DeltaR) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_JetMoment", m_varTypeName_JetMoment) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Combined", m_varTypeName_Combined) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_JetShape", m_varTypeName_JetShape) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_ImpactParams", m_varTypeName_ImpactParams) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Basic", m_varTypeName_Basic) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_PID", m_varTypeName_PID) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Shots", m_varTypeName_Shots) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_Types_DeltaRCore", m_CoreCone) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_BinEdges_Eta", m_EtaBinEdges) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_Neutral_EtaBinned_EtCut", m_EtaBinnedEtCuts) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Sum", m_varTypeName_Sum) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Ratio", m_varTypeName_Ratio) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_EtInRing", m_varTypeName_EtInRing) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Isolation", m_varTypeName_Isolation) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Num", m_varTypeName_Num) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Mean", m_varTypeName_Mean) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_StdDev", m_varTypeName_StdDev) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_HLV", m_varTypeName_HLV) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Angle", m_varTypeName_Angle) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_DeltaR", m_varTypeName_DeltaR) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_JetMoment", m_varTypeName_JetMoment) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Combined", m_varTypeName_Combined) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_JetShape", m_varTypeName_JetShape) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_ImpactParams", m_varTypeName_ImpactParams) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Basic", m_varTypeName_Basic) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_PID", m_varTypeName_PID) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Shots", m_varTypeName_Shots) ); - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } -StatusCode PanTau::Tool_DetailsArranger::execute(PanTau::PanTauSeed2* inSeed, xAOD::ParticleContainer& pi0Container) { +StatusCode PanTau::Tool_DetailsArranger::execute(PanTau::PanTauSeed* inSeed, xAOD::ParticleContainer& pi0Container) { - std::string inputAlg = inSeed->getNameInputAlgorithm(); + std::string inputAlg = inSeed->getNameInputAlgorithm(); - bool noAnyConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed2::t_NoConstituentsAtAll); - bool noSelConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed2::t_NoSelectedConstituents); - bool noValidInputTau = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed2::t_NoValidInputTau); - bool isBadSeed = (noAnyConstituents || noSelConstituents || noValidInputTau); - m_expectInvalidFeatures = isBadSeed; - + bool noAnyConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_NoConstituentsAtAll); + bool noSelConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_NoSelectedConstituents); + bool noValidInputTau = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_NoValidInputTau); + bool isBadSeed = (noAnyConstituents || noSelConstituents || noValidInputTau); + m_expectInvalidFeatures = isBadSeed; - //set the PFO link vector and pantau 4-vector to default values for every tau first (xAOD technicality) - //if the tau is valid, overwrite with non-default values - xAOD::TauJet* tauJet = const_cast<xAOD::TauJet*>(inSeed->getTauJet()); + //set the PFO link vector and pantau 4-vector to default values for every tau first (xAOD technicality) + //if the tau is valid, overwrite with non-default values + xAOD::TauJet* tauJet = const_cast<xAOD::TauJet*>(inSeed->getTauJet()); - if(isBadSeed == true) { - ATH_MSG_DEBUG("This seed is not useable for detail arranging (other than validity flag)"); - tauJet->setPanTauDetail(xAOD::TauJetParameters::PanTau_isPanTauCandidate, 0); - return StatusCode::SUCCESS; - } + if(isBadSeed == true) { + ATH_MSG_DEBUG("This seed is not useable for detail arranging (other than validity flag)"); + tauJet->setPanTauDetail(xAOD::TauJetParameters::PanTau_isPanTauCandidate, 0); + return StatusCode::SUCCESS; + } - ATH_CHECK(arrangePFOLinks(inSeed, tauJet, pi0Container)); - - //Basic variables - addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_isPanTauCandidate", xAOD::TauJetParameters::PanTau_isPanTauCandidate, PanTau::Tool_DetailsArranger::t_Int); - addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_RecoMode_PanTau", xAOD::TauJetParameters::PanTau_DecayMode, PanTau::Tool_DetailsArranger::t_Int); - addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_BDTValue_1p0n_vs_1p1n", xAOD::TauJetParameters::PanTau_BDTValue_1p0n_vs_1p1n, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_BDTValue_1p1n_vs_1pXn", xAOD::TauJetParameters::PanTau_BDTValue_1p1n_vs_1pXn, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_BDTValue_3p0n_vs_3pXn", xAOD::TauJetParameters::PanTau_BDTValue_3p0n_vs_3pXn, PanTau::Tool_DetailsArranger::t_Float); + ATH_CHECK(arrangePFOLinks(inSeed, tauJet, pi0Container)); + + //Basic variables + addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_isPanTauCandidate", xAOD::TauJetParameters::PanTau_isPanTauCandidate, PanTau::Tool_DetailsArranger::t_Int); + addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_RecoMode_PanTau", xAOD::TauJetParameters::PanTau_DecayMode, PanTau::Tool_DetailsArranger::t_Int); + addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_BDTValue_1p0n_vs_1p1n", xAOD::TauJetParameters::PanTau_BDTValue_1p0n_vs_1p1n, PanTau::Tool_DetailsArranger::t_Float); + addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_BDTValue_1p1n_vs_1pXn", xAOD::TauJetParameters::PanTau_BDTValue_1p1n_vs_1pXn, PanTau::Tool_DetailsArranger::t_Float); + addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_BDTValue_3p0n_vs_3pXn", xAOD::TauJetParameters::PanTau_BDTValue_3p0n_vs_3pXn, PanTau::Tool_DetailsArranger::t_Float); - //Final 4-vector - tauJet->setP4(xAOD::TauJetParameters::PanTauCellBased, inSeed->getFinalMomentum().Pt(), inSeed->getFinalMomentum().Eta(), inSeed->getFinalMomentum().Phi(), inSeed->getFinalMomentum().M()); - - //BDT variables - addPanTauDetailToTauJet(inSeed, "Basic_NNeutralConsts", - xAOD::TauJetParameters::PanTau_BDTVar_Basic_NNeutralConsts, PanTau::Tool_DetailsArranger::t_Int); - addPanTauDetailToTauJet(inSeed, "Charged_JetMoment_EtDRxTotalEt", - xAOD::TauJetParameters::PanTau_BDTVar_Charged_JetMoment_EtDRxTotalEt, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Charged_StdDev_Et_WrtEtAllConsts", - xAOD::TauJetParameters::PanTau_BDTVar_Charged_StdDev_Et_WrtEtAllConsts, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_HLV_SumM", - xAOD::TauJetParameters::PanTau_BDTVar_Neutral_HLV_SumM, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_PID_BDTValues_BDTSort_1", - xAOD::TauJetParameters::PanTau_BDTVar_Neutral_PID_BDTValues_BDTSort_1, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_PID_BDTValues_BDTSort_2", - xAOD::TauJetParameters::PanTau_BDTVar_Neutral_PID_BDTValues_BDTSort_2, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_Ratio_1stBDTEtOverEtAllConsts", - xAOD::TauJetParameters::PanTau_BDTVar_Neutral_Ratio_1stBDTEtOverEtAllConsts, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_Ratio_EtOverEtAllConsts", - xAOD::TauJetParameters::PanTau_BDTVar_Neutral_Ratio_EtOverEtAllConsts, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_Shots_NPhotonsInSeed", - xAOD::TauJetParameters::PanTau_BDTVar_Neutral_Shots_NPhotonsInSeed, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Combined_DeltaR1stNeutralTo1stCharged", - xAOD::TauJetParameters::PanTau_BDTVar_Combined_DeltaR1stNeutralTo1stCharged, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Charged_HLV_SumM", - xAOD::TauJetParameters::PanTau_BDTVar_Charged_HLV_SumM, PanTau::Tool_DetailsArranger::t_Float); - + //Final 4-vector + tauJet->setP4(xAOD::TauJetParameters::PanTauCellBased, inSeed->getFinalMomentum().Pt(), inSeed->getFinalMomentum().Eta(), inSeed->getFinalMomentum().Phi(), inSeed->getFinalMomentum().M()); + + //BDT variables + addPanTauDetailToTauJet(inSeed, "Basic_NNeutralConsts", + xAOD::TauJetParameters::PanTau_BDTVar_Basic_NNeutralConsts, PanTau::Tool_DetailsArranger::t_Int); + addPanTauDetailToTauJet(inSeed, "Charged_JetMoment_EtDRxTotalEt", + xAOD::TauJetParameters::PanTau_BDTVar_Charged_JetMoment_EtDRxTotalEt, PanTau::Tool_DetailsArranger::t_Float); + addPanTauDetailToTauJet(inSeed, "Charged_StdDev_Et_WrtEtAllConsts", + xAOD::TauJetParameters::PanTau_BDTVar_Charged_StdDev_Et_WrtEtAllConsts, PanTau::Tool_DetailsArranger::t_Float); + addPanTauDetailToTauJet(inSeed, "Neutral_HLV_SumM", + xAOD::TauJetParameters::PanTau_BDTVar_Neutral_HLV_SumM, PanTau::Tool_DetailsArranger::t_Float); + addPanTauDetailToTauJet(inSeed, "Neutral_PID_BDTValues_BDTSort_1", + xAOD::TauJetParameters::PanTau_BDTVar_Neutral_PID_BDTValues_BDTSort_1, PanTau::Tool_DetailsArranger::t_Float); + addPanTauDetailToTauJet(inSeed, "Neutral_PID_BDTValues_BDTSort_2", + xAOD::TauJetParameters::PanTau_BDTVar_Neutral_PID_BDTValues_BDTSort_2, PanTau::Tool_DetailsArranger::t_Float); + addPanTauDetailToTauJet(inSeed, "Neutral_Ratio_1stBDTEtOverEtAllConsts", + xAOD::TauJetParameters::PanTau_BDTVar_Neutral_Ratio_1stBDTEtOverEtAllConsts, PanTau::Tool_DetailsArranger::t_Float); + addPanTauDetailToTauJet(inSeed, "Neutral_Ratio_EtOverEtAllConsts", + xAOD::TauJetParameters::PanTau_BDTVar_Neutral_Ratio_EtOverEtAllConsts, PanTau::Tool_DetailsArranger::t_Float); + addPanTauDetailToTauJet(inSeed, "Neutral_Shots_NPhotonsInSeed", + xAOD::TauJetParameters::PanTau_BDTVar_Neutral_Shots_NPhotonsInSeed, PanTau::Tool_DetailsArranger::t_Float); + addPanTauDetailToTauJet(inSeed, "Combined_DeltaR1stNeutralTo1stCharged", + xAOD::TauJetParameters::PanTau_BDTVar_Combined_DeltaR1stNeutralTo1stCharged, PanTau::Tool_DetailsArranger::t_Float); + addPanTauDetailToTauJet(inSeed, "Charged_HLV_SumM", + xAOD::TauJetParameters::PanTau_BDTVar_Charged_HLV_SumM, PanTau::Tool_DetailsArranger::t_Float); - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } - -void PanTau::Tool_DetailsArranger::addPanTauDetailToTauJet(PanTauSeed2* inSeed, +void PanTau::Tool_DetailsArranger::addPanTauDetailToTauJet(PanTauSeed* inSeed, std::string featName, xAOD::TauJetParameters::PanTauDetails detailEnum, PanTauDetailsType detailType) const { - bool isValid; - PanTau::TauFeature2* features = inSeed->getFeatures(); - std::string fullFeatName = inSeed->getNameInputAlgorithm() + "_" + featName; + bool isValid; + PanTau::TauFeature* features = inSeed->getFeatures(); + std::string fullFeatName = inSeed->getNameInputAlgorithm() + "_" + featName; - double theValue; - theValue = features->value(fullFeatName, isValid); - if(isValid == false) { + double theValue = features->value(fullFeatName, isValid); + if(isValid == false) { - if(m_expectInvalidFeatures == false) { - ATH_MSG_DEBUG("WARNING --- Problems getting value for feature " << fullFeatName << " from map! This should not happen for this seed!"); - ATH_MSG_DEBUG("WARNING --- Did the ModeDiscriminator set features used in BDTs that were not found to their default values?"); - ATH_MSG_DEBUG("NOTE --- This can also happen for seeds with (for example) 0 neutrals when trying to get Neutral_SumM - check seed"); - } - theValue = -1111; + if(m_expectInvalidFeatures == false) { + ATH_MSG_DEBUG("WARNING --- Problems getting value for feature " << fullFeatName << " from map! This should not happen for this seed!"); + ATH_MSG_DEBUG("WARNING --- Did the ModeDiscriminator set features used in BDTs that were not found to their default values?"); + ATH_MSG_DEBUG("NOTE --- This can also happen for seeds with (for example) 0 neutrals when trying to get Neutral_SumM - check seed"); } + theValue = -1111; + } - xAOD::TauJet* tauJet = const_cast<xAOD::TauJet*>(inSeed->getTauJet()); - int valueToAddInt = -1; - float valueToAddFloat = -1.1; - - switch(detailType) { - case PanTau::Tool_DetailsArranger::t_Int: - valueToAddInt = (int)theValue; - tauJet->setPanTauDetail(detailEnum, valueToAddInt); - break; - case PanTau::Tool_DetailsArranger::t_Float: - valueToAddFloat = (float)theValue; - tauJet->setPanTauDetail(detailEnum, valueToAddFloat); - break; - default: - ATH_MSG_WARNING("Unknown PanTauDetailType! Please use enum PanTauDetailsType from PanTauAlgs/Tool_DetailsArranger.h."); - ATH_MSG_WARNING("!NOT! adding detail named " << featName); - break; - } + xAOD::TauJet* tauJet = const_cast<xAOD::TauJet*>(inSeed->getTauJet()); + int valueToAddInt = -1; + float valueToAddFloat = -1.1; + + switch(detailType) { + case PanTau::Tool_DetailsArranger::t_Int: + valueToAddInt = (int)theValue; + tauJet->setPanTauDetail(detailEnum, valueToAddInt); + break; + case PanTau::Tool_DetailsArranger::t_Float: + valueToAddFloat = (float)theValue; + tauJet->setPanTauDetail(detailEnum, valueToAddFloat); + break; + default: + ATH_MSG_WARNING("Unknown PanTauDetailType! Please use enum PanTauDetailsType from PanTauAlgs/Tool_DetailsArranger.h."); + ATH_MSG_WARNING("!NOT! adding detail named " << featName); + break; + } - return; + return; } +StatusCode PanTau::Tool_DetailsArranger::arrangePFOLinks(PanTau::PanTauSeed* inSeed, xAOD::TauJet* tauJet, xAOD::ParticleContainer& pi0Container) { -StatusCode PanTau::Tool_DetailsArranger::arrangePFOLinks(PanTau::PanTauSeed2* inSeed, xAOD::TauJet* tauJet, xAOD::ParticleContainer& pi0Container) { - - std::string inputAlg = inSeed->getNameInputAlgorithm(); + std::string inputAlg = inSeed->getNameInputAlgorithm(); - //get the PFO links - std::vector< ElementLink< xAOD::PFOContainer > > chrgPFOLinks = tauJet->protoChargedPFOLinks(); - std::vector< ElementLink< xAOD::PFOContainer > > neutralPFOLinks = tauJet->protoNeutralPFOLinks(); - - std::vector< ElementLink< xAOD::PFOContainer > > pi0PFOLinks = CollectConstituentsAsPFOLinks( inSeed, tauJet->protoNeutralPFOLinks(), PanTau::TauConstituent2::t_Pi0Neut ); - std::vector< ElementLink< xAOD::PFOContainer > > preSelected_neutralPFOLinks = CollectConstituentsAsPFOLinks( inSeed, tauJet->protoNeutralPFOLinks(), PanTau::TauConstituent2::t_Neutral ); - - - //clear the default links, just to be safe - tauJet->clearChargedPFOLinks(); - tauJet->clearNeutralPFOLinks(); - tauJet->clearPi0PFOLinks(); + //get the PFO links + std::vector< ElementLink< xAOD::PFOContainer > > chrgPFOLinks = tauJet->protoChargedPFOLinks(); + std::vector< ElementLink< xAOD::PFOContainer > > neutralPFOLinks = tauJet->protoNeutralPFOLinks(); + std::vector< ElementLink< xAOD::PFOContainer > > pi0PFOLinks = CollectConstituentsAsPFOLinks( inSeed, tauJet->protoNeutralPFOLinks(), PanTau::TauConstituent::t_Pi0Neut ); + std::vector< ElementLink< xAOD::PFOContainer > > preSelected_neutralPFOLinks = CollectConstituentsAsPFOLinks( inSeed, tauJet->protoNeutralPFOLinks(), PanTau::TauConstituent::t_Neutral ); + + //clear the default links, just to be safe + tauJet->clearChargedPFOLinks(); + tauJet->clearNeutralPFOLinks(); + tauJet->clearPi0PFOLinks(); - std::vector< ElementLink< xAOD::PFOContainer > > preLinkPi0PFOLinks = tauJet->pi0PFOLinks(); + std::vector< ElementLink< xAOD::PFOContainer > > preLinkPi0PFOLinks = tauJet->pi0PFOLinks(); - // sort PFO links according to pi0 BDT score: - std::sort (pi0PFOLinks.begin(), pi0PFOLinks.end(), sortBDTscore); - std::sort (preSelected_neutralPFOLinks.begin(), preSelected_neutralPFOLinks.end(), sortBDTscore); - std::sort (neutralPFOLinks.begin(), neutralPFOLinks.end(), sortBDTscore); + // sort PFO links according to pi0 BDT score: + std::sort (pi0PFOLinks.begin(), pi0PFOLinks.end(), sortBDTscore); + std::sort (preSelected_neutralPFOLinks.begin(), preSelected_neutralPFOLinks.end(), sortBDTscore); + std::sort (neutralPFOLinks.begin(), neutralPFOLinks.end(), sortBDTscore); - // set the masses of all neutrals *and pi0 neutrals* to 0: - SetNeutralConstituentVectorMasses(neutralPFOLinks, 0.); + // set the masses of all neutrals *and pi0 neutrals* to 0: + SetNeutralConstituentVectorMasses(neutralPFOLinks, 0.); - // arrange charged & neutral PFOs: they are not changed -> copy from cellbased - tauJet->setChargedPFOLinks(chrgPFOLinks); - tauJet->setNeutralPFOLinks(neutralPFOLinks); + // arrange charged & neutral PFOs: they are not changed -> copy from cellbased + tauJet->setChargedPFOLinks(chrgPFOLinks); + tauJet->setNeutralPFOLinks(neutralPFOLinks); - tauJet->setDetail(xAOD::TauJetParameters::nCharged, (int)chrgPFOLinks.size()); + tauJet->setDetail(xAOD::TauJetParameters::nCharged, (int)chrgPFOLinks.size()); - //arrange pi0 pfos: depends on decay mode classification - int decayModeProto = inSeed->getDecayModeBySubAlg(); - int decayModeFinal = inSeed->getDecayModeByPanTau(); + //arrange pi0 pfos: depends on decay mode classification + int decayModeProto = inSeed->getDecayModeBySubAlg(); + int decayModeFinal = inSeed->getDecayModeByPanTau(); - if(decayModeFinal == xAOD::TauJetParameters::Mode_Other) { - tauJet->setPi0PFOLinks(pi0PFOLinks); - SetHLVTau(inSeed, tauJet, inputAlg, m_varTypeName_Basic); + if(decayModeFinal == xAOD::TauJetParameters::Mode_Other) { + tauJet->setPi0PFOLinks(pi0PFOLinks); + SetHLVTau(inSeed, tauJet, inputAlg, m_varTypeName_Basic); - return StatusCode::SUCCESS; - } + return StatusCode::SUCCESS; + } - //if pantau sets the same decay mode as the substructure algorithm, just copy the links - if(decayModeProto == decayModeFinal) { + //if pantau sets the same decay mode as the substructure algorithm, just copy the links + if(decayModeProto == decayModeFinal) { - if( decayModeFinal == xAOD::TauJetParameters::Mode_3pXn && pi0PFOLinks.size() > 1 ){ + if( decayModeFinal == xAOD::TauJetParameters::Mode_3pXn && pi0PFOLinks.size() > 1 ){ - // assign all neutrals but only one pi0 neutral to Pantau: - preLinkPi0PFOLinks.push_back( pi0PFOLinks.at(0) ); + // assign all neutrals but only one pi0 neutral to Pantau: + preLinkPi0PFOLinks.push_back( pi0PFOLinks.at(0) ); - // set all masses correctly: - SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); + // set all masses correctly: + SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); - } else { + } else { - // assign the same constituents to Pantau: - preLinkPi0PFOLinks=pi0PFOLinks; + // assign the same constituents to Pantau: + preLinkPi0PFOLinks=pi0PFOLinks; - // set all masses correctly: - SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); - - } - - - } else { + // set all masses correctly: + SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); + } - if( decayModeFinal == xAOD::TauJetParameters::Mode_1p1n && decayModeProto == xAOD::TauJetParameters::Mode_1p0n ){ + } else { - // add the highest BDT-score neutral from the sub-alg: - if(preSelected_neutralPFOLinks.size() > 0) preLinkPi0PFOLinks.push_back( preSelected_neutralPFOLinks.at(0) ); - else ATH_MSG_WARNING("No neutral PFO Links although there should be!!"); + if( decayModeFinal == xAOD::TauJetParameters::Mode_1p1n && decayModeProto == xAOD::TauJetParameters::Mode_1p0n ){ + // add the highest BDT-score neutral from the sub-alg: + if(preSelected_neutralPFOLinks.size() > 0) preLinkPi0PFOLinks.push_back( preSelected_neutralPFOLinks.at(0) ); + else ATH_MSG_WARNING("No neutral PFO Links although there should be!!"); - // set the mass: - SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); + // set the mass: + SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); - } else if( decayModeFinal == xAOD::TauJetParameters::Mode_1p0n && decayModeProto == xAOD::TauJetParameters::Mode_1p1n ){ + } else if( decayModeFinal == xAOD::TauJetParameters::Mode_1p0n && decayModeProto == xAOD::TauJetParameters::Mode_1p1n ){ - // do nothing (leave the pi0 neutrals list empty) + // do nothing (leave the pi0 neutrals list empty) - } else if( decayModeFinal == xAOD::TauJetParameters::Mode_1pXn && decayModeProto == xAOD::TauJetParameters::Mode_1p1n ){ + } else if( decayModeFinal == xAOD::TauJetParameters::Mode_1pXn && decayModeProto == xAOD::TauJetParameters::Mode_1p1n ){ - if( pi0PFOLinks.size() == 1 && HasMultPi0sInOneCluster(pi0PFOLinks.at(0).cachedElement(), decayModeProto, inputAlg) ){ + if( pi0PFOLinks.size() == 1 && HasMultPi0sInOneCluster(pi0PFOLinks.at(0).cachedElement(), decayModeProto, inputAlg) ){ - // assign twice the pi0 mass to the one pi0 PFO: - SetNeutralConstituentVectorMasses(pi0PFOLinks, 2*MASS_PI0); + // assign twice the pi0 mass to the one pi0 PFO: + SetNeutralConstituentVectorMasses(pi0PFOLinks, 2*MASS_PI0); - // assign the same constituents to Pantau: - preLinkPi0PFOLinks=pi0PFOLinks; + // assign the same constituents to Pantau: + preLinkPi0PFOLinks=pi0PFOLinks; - } else { + } else { - // copy all (really only one) pi0s from the sub-alg and add - // the highest BDT-score neutral: - preLinkPi0PFOLinks=pi0PFOLinks; - if(preSelected_neutralPFOLinks.size() > 0) preLinkPi0PFOLinks.push_back( preSelected_neutralPFOLinks.at(0) ); - else ATH_MSG_WARNING("No neutral PFO Links although there should be!!"); + // copy all (really only one) pi0s from the sub-alg and add + // the highest BDT-score neutral: + preLinkPi0PFOLinks=pi0PFOLinks; + if(preSelected_neutralPFOLinks.size() > 0) preLinkPi0PFOLinks.push_back( preSelected_neutralPFOLinks.at(0) ); + else ATH_MSG_WARNING("No neutral PFO Links although there should be!!"); - // set the mass: - SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); - - } + // set the mass: + SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); + } - } else if( decayModeFinal == xAOD::TauJetParameters::Mode_1p1n && decayModeProto == xAOD::TauJetParameters::Mode_1pXn ){ + } else if( decayModeFinal == xAOD::TauJetParameters::Mode_1p1n && decayModeProto == xAOD::TauJetParameters::Mode_1pXn ){ - // copy all (two) pi0s from the sub-alg: - preLinkPi0PFOLinks.push_back( pi0PFOLinks.at(0) ); - preLinkPi0PFOLinks.push_back( pi0PFOLinks.at(1) ); + // copy all (two) pi0s from the sub-alg: + preLinkPi0PFOLinks.push_back( pi0PFOLinks.at(0) ); + preLinkPi0PFOLinks.push_back( pi0PFOLinks.at(1) ); - // set both pi0neutrals to mass 0 (photon mass): - SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, 0.); + // set both pi0neutrals to mass 0 (photon mass): + SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, 0.); - } else if( decayModeFinal == xAOD::TauJetParameters::Mode_3pXn && decayModeProto == xAOD::TauJetParameters::Mode_3p0n ){ + } else if( decayModeFinal == xAOD::TauJetParameters::Mode_3pXn && decayModeProto == xAOD::TauJetParameters::Mode_3p0n ){ - // add the highest BDT-score neutral from the sub-alg: - if(preSelected_neutralPFOLinks.size() > 0) preLinkPi0PFOLinks.push_back( preSelected_neutralPFOLinks.at(0) ); - else ATH_MSG_WARNING("No neutral PFO Links although there should be!!"); + // add the highest BDT-score neutral from the sub-alg: + if(preSelected_neutralPFOLinks.size() > 0) preLinkPi0PFOLinks.push_back( preSelected_neutralPFOLinks.at(0) ); + else ATH_MSG_WARNING("No neutral PFO Links although there should be!!"); - // set the mass: - SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); + // set the mass: + SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); - } else if( decayModeFinal == xAOD::TauJetParameters::Mode_3p0n && decayModeProto == xAOD::TauJetParameters::Mode_3pXn ){ - - // do nothing (leave the pi0 neutrals list empty) - - } + } else if( decayModeFinal == xAOD::TauJetParameters::Mode_3p0n && decayModeProto == xAOD::TauJetParameters::Mode_3pXn ){ + // do nothing (leave the pi0 neutrals list empty) } + } - tauJet->setPi0PFOLinks(preLinkPi0PFOLinks); - - SetHLVTau(inSeed, tauJet, inputAlg, m_varTypeName_Basic); + tauJet->setPi0PFOLinks(preLinkPi0PFOLinks); - std::vector< ElementLink< xAOD::PFOContainer > > finalChrgPFOLinks = tauJet->chargedPFOLinks(); - std::vector< ElementLink< xAOD::PFOContainer > > finalPi0PFOLinks = tauJet->pi0PFOLinks(); - std::vector< ElementLink< xAOD::PFOContainer > > finalNeutralPFOLinks = tauJet->neutralPFOLinks(); - - - // vector of 4-vectors of actual pi0s and a vector with pointers to PFOs: - std::vector< TLorentzVector > vec_pi04vec; - std::vector< std::vector< ElementLink<xAOD::PFOContainer> > > vec_pi0pfos; - createPi0Vectors(tauJet, vec_pi04vec, vec_pi0pfos); - - for(unsigned int itlv=0; itlv!=vec_pi04vec.size(); ++itlv) { - xAOD::Particle* p = new xAOD::Particle(); - pi0Container.push_back(p); - p->setPxPyPzE(vec_pi04vec.at(itlv).Px(), vec_pi04vec.at(itlv).Py(), vec_pi04vec.at(itlv).Pz(), vec_pi04vec.at(itlv).E()); - std::vector< ElementLink< xAOD::PFOContainer > > pfo_link_vector; - for( uint ipfo = 0; ipfo != vec_pi0pfos.at(itlv).size(); ++ipfo) { - pfo_link_vector.push_back(vec_pi0pfos.at(itlv).at(ipfo)); - } + SetHLVTau(inSeed, tauJet, inputAlg, m_varTypeName_Basic); - static SG::AuxElement::Accessor<std::vector< ElementLink< xAOD::PFOContainer > > > accPi0PFOLinks("pi0PFOLinks"); - accPi0PFOLinks(*p) = pfo_link_vector; + std::vector< ElementLink< xAOD::PFOContainer > > finalChrgPFOLinks = tauJet->chargedPFOLinks(); + std::vector< ElementLink< xAOD::PFOContainer > > finalPi0PFOLinks = tauJet->pi0PFOLinks(); + std::vector< ElementLink< xAOD::PFOContainer > > finalNeutralPFOLinks = tauJet->neutralPFOLinks(); - ElementLink< xAOD::IParticleContainer > linkToPi0; - linkToPi0.toContainedElement(pi0Container, dynamic_cast<xAOD::IParticle*> (p)); + // vector of 4-vectors of actual pi0s and a vector with pointers to PFOs: + std::vector< TLorentzVector > vec_pi04vec; + std::vector< std::vector< ElementLink<xAOD::PFOContainer> > > vec_pi0pfos; + createPi0Vectors(tauJet, vec_pi04vec, vec_pi0pfos); - tauJet->addPi0Link(linkToPi0); + for(unsigned int itlv=0; itlv!=vec_pi04vec.size(); ++itlv) { + xAOD::Particle* p = new xAOD::Particle(); + pi0Container.push_back(p); + p->setPxPyPzE(vec_pi04vec.at(itlv).Px(), vec_pi04vec.at(itlv).Py(), vec_pi04vec.at(itlv).Pz(), vec_pi04vec.at(itlv).E()); + std::vector< ElementLink< xAOD::PFOContainer > > pfo_link_vector; + for( uint ipfo = 0; ipfo != vec_pi0pfos.at(itlv).size(); ++ipfo) { + pfo_link_vector.push_back(vec_pi0pfos.at(itlv).at(ipfo)); } + + static SG::AuxElement::Accessor<std::vector< ElementLink< xAOD::PFOContainer > > > accPi0PFOLinks("pi0PFOLinks"); + accPi0PFOLinks(*p) = pfo_link_vector; + + ElementLink< xAOD::IParticleContainer > linkToPi0; + linkToPi0.toContainedElement(pi0Container, dynamic_cast<xAOD::IParticle*> (p)); + + tauJet->addPi0Link(linkToPi0); + } - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } // Calculate final 4-vector: -void PanTau::Tool_DetailsArranger::SetHLVTau( PanTau::PanTauSeed2* inSeed, xAOD::TauJet* tauJet, std::string inputAlg, std::string varTypeName_Basic){ +void PanTau::Tool_DetailsArranger::SetHLVTau( PanTau::PanTauSeed* inSeed, xAOD::TauJet* tauJet, std::string inputAlg, std::string varTypeName_Basic){ - std::vector< ElementLink< xAOD::PFOContainer > > finalChrgPFOLinks = tauJet->chargedPFOLinks(); - std::vector< ElementLink< xAOD::PFOContainer > > finalPi0PFOLinks = tauJet->pi0PFOLinks(); - std::vector< ElementLink< xAOD::PFOContainer > > finalNeutralPFOLinks = tauJet->neutralPFOLinks(); + std::vector< ElementLink< xAOD::PFOContainer > > finalChrgPFOLinks = tauJet->chargedPFOLinks(); + std::vector< ElementLink< xAOD::PFOContainer > > finalPi0PFOLinks = tauJet->pi0PFOLinks(); + std::vector< ElementLink< xAOD::PFOContainer > > finalNeutralPFOLinks = tauJet->neutralPFOLinks(); - unsigned int NCharged = finalChrgPFOLinks.size(); - unsigned int NPi0Neut = finalPi0PFOLinks.size(); + unsigned int NCharged = finalChrgPFOLinks.size(); + unsigned int NPi0Neut = finalPi0PFOLinks.size(); - TLorentzVector tlv_PanTau_Final; - for(unsigned int iPFO=0; iPFO<NCharged; iPFO++) { - const xAOD::PFO* pfo = finalChrgPFOLinks.at(iPFO).cachedElement(); - tlv_PanTau_Final += pfo->p4(); - } - for(unsigned int iPFO=0; iPFO<NPi0Neut; iPFO++) { - const xAOD::PFO* pfo = finalPi0PFOLinks.at(iPFO).cachedElement(); - tlv_PanTau_Final += pfo->p4(); - } + TLorentzVector tlv_PanTau_Final; + for(unsigned int iPFO=0; iPFO<NCharged; iPFO++) { + const xAOD::PFO* pfo = finalChrgPFOLinks.at(iPFO).cachedElement(); + tlv_PanTau_Final += pfo->p4(); + } + for(unsigned int iPFO=0; iPFO<NPi0Neut; iPFO++) { + const xAOD::PFO* pfo = finalPi0PFOLinks.at(iPFO).cachedElement(); + tlv_PanTau_Final += pfo->p4(); + } - inSeed->setFinalMomentum(tlv_PanTau_Final); + inSeed->setFinalMomentum(tlv_PanTau_Final); - PanTau::TauFeature2* featureMap = inSeed->getFeatures(); - featureMap->addFeature(inputAlg + "_" + varTypeName_Basic + "_FinalMomentumCore_pt", tlv_PanTau_Final.Pt() ); - featureMap->addFeature(inputAlg + "_" + varTypeName_Basic + "_FinalMomentumCore_eta", tlv_PanTau_Final.Eta() ); - featureMap->addFeature(inputAlg + "_" + varTypeName_Basic + "_FinalMomentumCore_phi", tlv_PanTau_Final.Phi() ); - featureMap->addFeature(inputAlg + "_" + varTypeName_Basic + "_FinalMomentumCore_m", tlv_PanTau_Final.M() ); + PanTau::TauFeature* featureMap = inSeed->getFeatures(); + featureMap->addFeature(inputAlg + "_" + varTypeName_Basic + "_FinalMomentumCore_pt", tlv_PanTau_Final.Pt() ); + featureMap->addFeature(inputAlg + "_" + varTypeName_Basic + "_FinalMomentumCore_eta", tlv_PanTau_Final.Eta() ); + featureMap->addFeature(inputAlg + "_" + varTypeName_Basic + "_FinalMomentumCore_phi", tlv_PanTau_Final.Phi() ); + featureMap->addFeature(inputAlg + "_" + varTypeName_Basic + "_FinalMomentumCore_m", tlv_PanTau_Final.M() ); - return; + return; } - bool PanTau::Tool_DetailsArranger::HasMultPi0sInOneCluster(const xAOD::PFO* pfo, int decayModeProto, TString inputAlg){ @@ -403,7 +381,6 @@ bool PanTau::Tool_DetailsArranger::HasMultPi0sInOneCluster(const xAOD::PFO* pfo, } - void PanTau::Tool_DetailsArranger::SetNeutralConstituentMass(xAOD::PFO* neutral_pfo, double mass){ TLorentzVector momentum; @@ -420,15 +397,14 @@ void PanTau::Tool_DetailsArranger::SetNeutralConstituentVectorMasses(std::vector ElementLink<xAOD::PFOContainer> curNeutralPFOLink = neutralPFOLinks.at(iNeutral); xAOD::PFO* curNeutralPFO = const_cast<xAOD::PFO*>(curNeutralPFOLink.cachedElement()); - SetNeutralConstituentMass(curNeutralPFO, mass); - + SetNeutralConstituentMass(curNeutralPFO, mass); } return; } -std::vector< ElementLink< xAOD::PFOContainer > > PanTau::Tool_DetailsArranger::CollectConstituentsAsPFOLinks( PanTau::PanTauSeed2* inSeed, std::vector< ElementLink< xAOD::PFOContainer > > cellbased_neutralPFOLinks, PanTau::TauConstituent2::Type type ){ +std::vector< ElementLink< xAOD::PFOContainer > > PanTau::Tool_DetailsArranger::CollectConstituentsAsPFOLinks( PanTau::PanTauSeed* inSeed, std::vector< ElementLink< xAOD::PFOContainer > > cellbased_neutralPFOLinks, PanTau::TauConstituent::Type type ){ // collect element links from tau constituents in the Pantau // seed of type "type". cellbased_neutralPFOLinks is only used // to obtain the ElementLinks. @@ -437,9 +413,9 @@ std::vector< ElementLink< xAOD::PFOContainer > > PanTau::Tool_DetailsArranger::C unsigned int nConstsOfType=0; bool foundIt=false; - std::vector<PanTau::TauConstituent2*> tauConstituents=inSeed->getConstituentsOfType(type,foundIt); + std::vector<PanTau::TauConstituent*> tauConstituents=inSeed->getConstituentsOfType(type,foundIt); - if( (type != PanTau::TauConstituent2::t_Neutral && type != PanTau::TauConstituent2::t_Pi0Neut) || !foundIt){ + if( (type != PanTau::TauConstituent::t_Neutral && type != PanTau::TauConstituent::t_Pi0Neut) || !foundIt){ ATH_MSG_WARNING("CollectConstituentsAsPFOLinks: Function was called with type = " << type << " , however it was only designed for types t_Pi0Neut and t_Neutral! Returning..."); return new_links; } @@ -451,7 +427,7 @@ std::vector< ElementLink< xAOD::PFOContainer > > PanTau::Tool_DetailsArranger::C // if the requested type is t_Neutral then exclude any t_Pi0Neut // from the list (note: tau constituents that are t_Pi0Neut are // also t_Neutral at the same time): - if(type==PanTau::TauConstituent2::t_Neutral && tauConstituents[iConst]->isOfType(PanTau::TauConstituent2::t_Pi0Neut) ) continue; + if(type==PanTau::TauConstituent::t_Neutral && tauConstituents[iConst]->isOfType(PanTau::TauConstituent::t_Pi0Neut) ) continue; ++nConstsOfType; for(unsigned int iPFO=0; iPFO<cellbased_neutralPFOLinks.size(); iPFO++) { @@ -460,31 +436,11 @@ std::vector< ElementLink< xAOD::PFOContainer > > PanTau::Tool_DetailsArranger::C if( tauConstituents[iConst]->getPFO() != pfo ) continue; new_links.push_back( cellbased_neutralPFOLinks.at(iPFO) ); - } - } - if( nConstsOfType != new_links.size() ){ ATH_MSG_WARNING("CollectConstituentsAsPFOLinks: Couldn't find PFOLinks " << new_links.size() << " for all tau constituents (" << tauConstituents.size() << ")!"); - - for(unsigned int iConst=0; iConst<tauConstituents.size(); iConst++) { - const xAOD::PFO* pfo = tauConstituents[iConst]->getPFO(); - int nPi0 = -1; - bool getOK = pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0); - if(getOK == false) ATH_MSG_DEBUG("problems reading pi0Proto attribute"); - ATH_MSG_DEBUG("pfo " << iConst << " pt, eta, phi, m: " << pfo->pt() << ", " << pfo->eta() << ", " << pfo->phi() << ", " << pfo->m() << " isPi0: " << nPi0 << " , BDTscore: " << pfo->bdtPi0Score() ); - } - - ATH_MSG_DEBUG("Dumping all cellbased neutral pfo links"); - for(unsigned int iPFO=0; iPFO<cellbased_neutralPFOLinks.size(); iPFO++) { - const xAOD::PFO* pfo = cellbased_neutralPFOLinks.at(iPFO).cachedElement(); - int nPi0 = -1; - bool getOK = pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0); - if(getOK == false) ATH_MSG_DEBUG("problems reading pi0Proto attribute"); - ATH_MSG_DEBUG("pfo " << iPFO << " pt, eta, phi, m: " << pfo->pt() << ", " << pfo->eta() << ", " << pfo->phi() << ", " << pfo->m() << " isPi0: " << nPi0 << " , BDTscore: " << pfo->bdtPi0Score() ); - } } return new_links; @@ -494,12 +450,10 @@ std::vector< ElementLink< xAOD::PFOContainer > > PanTau::Tool_DetailsArranger::C //______________________________________________________________________________ void PanTau::Tool_DetailsArranger::createPi0Vectors(xAOD::TauJet* tauJet, std::vector<TLorentzVector>& vPi0s, std::vector< std::vector< ElementLink< xAOD::PFOContainer > > > &vec_pi0pfos) { - // reset the pi0s vPi0s.clear(); vec_pi0pfos.clear(); - // Since the PFO links as they come out of reconstruction, only correspond to // calorimeter clusters, whereas we want the consts_pi0 vectors to correspond // to real pi0s, we need to be careful to collect the PFOs correctly to pi0s diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_FeatureExtractor.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_FeatureExtractor.cxx index 46b4636cfd02a05d79db39d41bc256a9992f47a6..99891029b8b1de4bf7e2ab19d4432539b37127e3 100644 --- a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_FeatureExtractor.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_FeatureExtractor.cxx @@ -2,22 +2,18 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -//! Helper classes #include "xAODTau/TauJet.h" #include "xAODTracking/Vertex.h" #include "xAODTracking/TrackParticle.h" -//! ROOT includes #include "TMath.h" #include "TLorentzVector.h" #include "TVector3.h" -//! C++ includes #include <vector> #include <map> #include <math.h> -//! PanTau includes #include "PanTauAlgs/Tool_FeatureExtractor.h" #include "PanTauAlgs/Tool_InformationStore.h" #include "PanTauAlgs/TauConstituent.h" @@ -26,1126 +22,1084 @@ #include "PanTauAlgs/HelperFunctions.h" - - -bool sortTauConstituentMVA(const PanTau::TauConstituent2* u, const PanTau::TauConstituent2* v) { - double uBDT = u->getBDTValue(); - double vBDT = v->getBDTValue(); - return uBDT > vBDT; +bool sortTauConstituentMVA(const PanTau::TauConstituent* u, const PanTau::TauConstituent* v) { + double uBDT = u->getBDTValue(); + double vBDT = v->getBDTValue(); + return uBDT > vBDT; } - -bool sortTauConstituentEt(const PanTau::TauConstituent2* u, const PanTau::TauConstituent2* v) { - double uEt = u->p4().Et(); - double vEt = v->p4().Et(); - return uEt > vEt; +bool sortTauConstituentEt(const PanTau::TauConstituent* u, const PanTau::TauConstituent* v) { + double uEt = u->p4().Et(); + double vEt = v->p4().Et(); + return uEt > vEt; } +PanTau::Tool_FeatureExtractor::Tool_FeatureExtractor(const std::string& name) : + asg::AsgTool(name), + m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore"){ - - -PanTau::Tool_FeatureExtractor::Tool_FeatureExtractor( - const std::string& name ) : - asg::AsgTool(name), - m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore"){ - - declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Tool handle to the information store tool"); - declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName, "Tool handle to the information store tool"); + declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Tool handle to the information store tool"); + declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName, "Tool handle to the information store tool"); } - StatusCode PanTau::Tool_FeatureExtractor::initialize() { - ATH_MSG_INFO(" initialize()"); - m_init=true; - - ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) ); - ATH_CHECK( m_Tool_InformationStore.retrieve() ); - - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Sum", m_varTypeName_Sum) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Ratio", m_varTypeName_Ratio) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_EtInRing", m_varTypeName_EtInRing) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Isolation", m_varTypeName_Isolation) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Num", m_varTypeName_Num) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Mean", m_varTypeName_Mean) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_StdDev", m_varTypeName_StdDev) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_HLV", m_varTypeName_HLV) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Angle", m_varTypeName_Angle) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_DeltaR", m_varTypeName_DeltaR) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_JetMoment", m_varTypeName_JetMoment) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Combined", m_varTypeName_Combined) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_JetShape", m_varTypeName_JetShape) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_ImpactParams", m_varTypeName_ImpactParams) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Basic", m_varTypeName_Basic) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_PID", m_varTypeName_PID) ); - - ATH_CHECK( m_Tool_InformationStore->getInfo_Int("FeatureExtractor_UseEmptySeeds", m_Config_UseEmptySeeds) ); - - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_BinEdges_Eta", m_Config_CellBased_BinEdges_Eta) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_EtaBinned_Pi0MVACut_1prong", m_Config_CellBased_EtaBinned_Pi0MVACut_1prong) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_EtaBinned_Pi0MVACut_3prong", m_Config_CellBased_EtaBinned_Pi0MVACut_3prong) ); - - return StatusCode::SUCCESS; + ATH_MSG_INFO(" initialize()"); + m_init=true; + + ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) ); + ATH_CHECK( m_Tool_InformationStore.retrieve() ); + + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Sum", m_varTypeName_Sum) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Ratio", m_varTypeName_Ratio) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_EtInRing", m_varTypeName_EtInRing) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Isolation", m_varTypeName_Isolation) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Num", m_varTypeName_Num) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Mean", m_varTypeName_Mean) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_StdDev", m_varTypeName_StdDev) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_HLV", m_varTypeName_HLV) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Angle", m_varTypeName_Angle) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_DeltaR", m_varTypeName_DeltaR) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_JetMoment", m_varTypeName_JetMoment) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Combined", m_varTypeName_Combined) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_JetShape", m_varTypeName_JetShape) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_ImpactParams", m_varTypeName_ImpactParams) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Basic", m_varTypeName_Basic) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_PID", m_varTypeName_PID) ); + + ATH_CHECK( m_Tool_InformationStore->getInfo_Int("FeatureExtractor_UseEmptySeeds", m_Config_UseEmptySeeds) ); + + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_BinEdges_Eta", m_Config_CellBased_BinEdges_Eta) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_EtaBinned_Pi0MVACut_1prong", m_Config_CellBased_EtaBinned_Pi0MVACut_1prong) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_EtaBinned_Pi0MVACut_3prong", m_Config_CellBased_EtaBinned_Pi0MVACut_3prong) ); + + return StatusCode::SUCCESS; } +void PanTau::Tool_FeatureExtractor::fillVariantsSeedEt(std::vector<PanTau::TauConstituent*> tauConstituents) { -void PanTau::Tool_FeatureExtractor::fillVariantsSeedEt(std::vector<PanTau::TauConstituent2*> tauConstituents) { - - //use different approaches to calculate total energy of seed: - m_Variants_SeedEt["EtAllConsts"] = 0.0; - m_Variants_SeedEt["EtNeutLowA"] = 0.0; - m_Variants_SeedEt["EtNeutLowB"] = 0.0; + //use different approaches to calculate total energy of seed: + m_Variants_SeedEt["EtAllConsts"] = 0.0; + m_Variants_SeedEt["EtNeutLowA"] = 0.0; + m_Variants_SeedEt["EtNeutLowB"] = 0.0; - //loop over all constituents in seed - for(unsigned int iConst = 0; iConst < tauConstituents.size(); iConst++) { + //loop over all constituents in seed + for(unsigned int iConst = 0; iConst < tauConstituents.size(); iConst++) { - //get current constituents - PanTau::TauConstituent2* curConstituent = tauConstituents.at(iConst); - double curEt = curConstituent->p4().Et(); + //get current constituents + PanTau::TauConstituent* curConstituent = tauConstituents.at(iConst); + double curEt = curConstituent->p4().Et(); - //update the different Et definitions - if(curConstituent->isOfType(PanTau::TauConstituent2::t_Charged) == true) { - m_Variants_SeedEt["EtAllConsts"] += curEt; - m_Variants_SeedEt["EtNeutLowA"] += curEt; - m_Variants_SeedEt["EtNeutLowB"] += curEt; - } - if(curConstituent->isOfType(PanTau::TauConstituent2::t_Neutral) == true) { - m_Variants_SeedEt["EtAllConsts"] += curEt; - } + //update the different Et definitions + if(curConstituent->isOfType(PanTau::TauConstituent::t_Charged) == true) { + m_Variants_SeedEt["EtAllConsts"] += curEt; + m_Variants_SeedEt["EtNeutLowA"] += curEt; + m_Variants_SeedEt["EtNeutLowB"] += curEt; + } + if(curConstituent->isOfType(PanTau::TauConstituent::t_Neutral) == true) { + m_Variants_SeedEt["EtAllConsts"] += curEt; + } - if(curConstituent->isOfType(PanTau::TauConstituent2::t_NeutLowA) == true) { - m_Variants_SeedEt["EtNeutLowA"] += curEt; - } - if(curConstituent->isOfType(PanTau::TauConstituent2::t_NeutLowB) == true) { - m_Variants_SeedEt["EtNeutLowB"] += curEt; - } + if(curConstituent->isOfType(PanTau::TauConstituent::t_NeutLowA) == true) { + m_Variants_SeedEt["EtNeutLowA"] += curEt; + } + if(curConstituent->isOfType(PanTau::TauConstituent::t_NeutLowB) == true) { + m_Variants_SeedEt["EtNeutLowB"] += curEt; + } - }//end loop over constituents in seed + }//end loop over constituents in seed - return; + return; } - -void PanTau::Tool_FeatureExtractor::addFeatureWrtSeedEnergy( PanTau::TauFeature2* targetMap, - std::string featName, - double numerator, - std::map<std::string, double>* denominatorMap) const { - std::map<std::string, double>::iterator it = denominatorMap->begin(); - for(; it!=denominatorMap->end(); it++) { - std::string FullName = featName + it->first; - float value = (float)it->second; - if(value <= 0. || isnan(value) || isinf(value) ) continue; - targetMap->addFeature(FullName, numerator / it->second); - } +void PanTau::Tool_FeatureExtractor::addFeatureWrtSeedEnergy(PanTau::TauFeature* targetMap, + std::string featName, + double numerator, + std::map<std::string, double>* denominatorMap) const { + std::map<std::string, double>::iterator it = denominatorMap->begin(); + for(; it!=denominatorMap->end(); it++) { + std::string FullName = featName + it->first; + float value = (float)it->second; + if(value <= 0. || isnan(value) || isinf(value) ) continue; + targetMap->addFeature(FullName, numerator / it->second); + } } - -StatusCode PanTau::Tool_FeatureExtractor::execute(PanTau::PanTauSeed2* inSeed) { - - bool noAnyConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed2::t_NoConstituentsAtAll); - bool noSelConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed2::t_NoSelectedConstituents); - bool noValidInputTau = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed2::t_NoValidInputTau); - bool isBadSeed = (noAnyConstituents || noSelConstituents || noValidInputTau); - if(m_Config_UseEmptySeeds == true) isBadSeed = noValidInputTau; - - if(isBadSeed == true) { - ATH_MSG_DEBUG("Seed is not valid for feature extraction (no constituents or no valid input tau) - just fill isPanTauCandidate feature"); - inSeed->getFeatures()->addFeature(inSeed->getNameInputAlgorithm() + "_" + m_varTypeName_Basic + "_isPanTauCandidate", 0); - return StatusCode::SUCCESS; - } - inSeed->getFeatures()->addFeature(inSeed->getNameInputAlgorithm() + "_" + m_varTypeName_Basic + "_isPanTauCandidate", 1); +StatusCode PanTau::Tool_FeatureExtractor::execute(PanTau::PanTauSeed* inSeed) { + bool noAnyConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_NoConstituentsAtAll); + bool noSelConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_NoSelectedConstituents); + bool noValidInputTau = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_NoValidInputTau); + bool isBadSeed = (noAnyConstituents || noSelConstituents || noValidInputTau); + if(m_Config_UseEmptySeeds == true) isBadSeed = noValidInputTau; - ATH_CHECK( calculateBasicFeatures(inSeed) ); + if(isBadSeed == true) { + ATH_MSG_DEBUG("Seed is not valid for feature extraction (no constituents or no valid input tau) - just fill isPanTauCandidate feature"); + inSeed->getFeatures()->addFeature(inSeed->getNameInputAlgorithm() + "_" + m_varTypeName_Basic + "_isPanTauCandidate", 0); + return StatusCode::SUCCESS; + } + inSeed->getFeatures()->addFeature(inSeed->getNameInputAlgorithm() + "_" + m_varTypeName_Basic + "_isPanTauCandidate", 1); - ATH_CHECK( addConstituentMomenta(inSeed) ); - //first, calculate the Et variants for the seed - fillVariantsSeedEt(inSeed->getConstituentsAsList_All()); + ATH_CHECK( calculateBasicFeatures(inSeed) ); - //loop through all types of Constituents in tau and calculate type features for them - //baseline - ATH_CHECK( calculateFeatures(inSeed, PanTau::TauConstituent2::t_NoType) ); //=> all constituents - ATH_CHECK( calculateFeatures(inSeed, PanTau::TauConstituent2::t_Charged) ); //=> charged ones in core - ATH_CHECK( calculateFeatures(inSeed, PanTau::TauConstituent2::t_Neutral) ); //=> neutral ones in core - ATH_CHECK( calculateFeatures(inSeed, PanTau::TauConstituent2::t_Pi0Neut) ); //=> pi0 tagged ones in core - //for testing - ATH_CHECK( calculateFeatures(inSeed, PanTau::TauConstituent2::t_NeutLowA) ); //=> same as neutral but with lower Et - ATH_CHECK( calculateFeatures(inSeed, PanTau::TauConstituent2::t_NeutLowB) ); //=> same as neutral but with even lower et + ATH_CHECK( addConstituentMomenta(inSeed) ); + //first, calculate the Et variants for the seed + fillVariantsSeedEt(inSeed->getConstituentsAsList_All()); - //fill the combined features - ATH_CHECK( addCombinedFeatures(inSeed) ); + //loop through all types of Constituents in tau and calculate type features for them + //baseline + ATH_CHECK( calculateFeatures(inSeed, PanTau::TauConstituent::t_NoType) ); //=> all constituents + ATH_CHECK( calculateFeatures(inSeed, PanTau::TauConstituent::t_Charged) ); //=> charged ones in core + ATH_CHECK( calculateFeatures(inSeed, PanTau::TauConstituent::t_Neutral) ); //=> neutral ones in core + ATH_CHECK( calculateFeatures(inSeed, PanTau::TauConstituent::t_Pi0Neut) ); //=> pi0 tagged ones in core + //for testing + ATH_CHECK( calculateFeatures(inSeed, PanTau::TauConstituent::t_NeutLowA) ); //=> same as neutral but with lower Et + ATH_CHECK( calculateFeatures(inSeed, PanTau::TauConstituent::t_NeutLowB) ); //=> same as neutral but with even lower et - //fill the impact paramter features - ATH_CHECK( addImpactParameterFeatures(inSeed) ); + //fill the combined features + ATH_CHECK( addCombinedFeatures(inSeed) ); - return StatusCode::SUCCESS; + //fill the impact paramter features + ATH_CHECK( addImpactParameterFeatures(inSeed) ); + + return StatusCode::SUCCESS; } - -StatusCode PanTau::Tool_FeatureExtractor::calculateBasicFeatures(PanTau::PanTauSeed2* inSeed) { - - ATH_MSG_DEBUG("calculating basic features"); - PanTau::TauFeature2* featureMap = inSeed->getFeatures(); +StatusCode PanTau::Tool_FeatureExtractor::calculateBasicFeatures(PanTau::PanTauSeed* inSeed) { - std::string featureAlg = inSeed->getNameInputAlgorithm(); - std::string featurePrefix = m_varTypeName_Basic; + PanTau::TauFeature* featureMap = inSeed->getFeatures(); + std::string featureAlg = inSeed->getNameInputAlgorithm(); + std::string featurePrefix = m_varTypeName_Basic; + double SumCharge = 0; + double AbsCharge = 0; - double SumCharge = 0; - double AbsCharge = 0; - - //! Loop over types to fill - //! - multiplicity of that type - //! - sum charge and abs charge - for(int iType=0; iType<PanTau::TauConstituent2::t_nTypes; iType++) { - - bool foundIt = false; - std::vector<TauConstituent2*> curList = inSeed->getConstituentsOfType(iType, foundIt); - if(foundIt == false) continue; + //! Loop over types to fill + //! - multiplicity of that type + //! - sum charge and abs charge + for(int iType=0; iType<PanTau::TauConstituent::t_nTypes; iType++) { - //store multiplicity of current type - std::string typeName = PanTau::TauConstituent2::getTypeName((PanTau::TauConstituent2::Type)iType); - unsigned int nConstituents = curList.size(); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_N" + typeName + "Consts", nConstituents); + bool foundIt = false; + std::vector<TauConstituent*> curList = inSeed->getConstituentsOfType(iType, foundIt); + if(foundIt == false) continue; + //store multiplicity of current type + std::string typeName = PanTau::TauConstituent::getTypeName((PanTau::TauConstituent::Type)iType); + unsigned int nConstituents = curList.size(); + featureMap->addFeature(featureAlg + "_" + featurePrefix + "_N" + typeName + "Consts", nConstituents); - //count charge, i.e. skip if not charged - if(iType != (int)PanTau::TauConstituent2::t_Charged) continue; - for(unsigned int iConst=0; iConst<nConstituents; iConst++) { - PanTau::TauConstituent2* curConstituent = curList[iConst]; - SumCharge += curConstituent->getCharge(); - AbsCharge += fabs((double)curConstituent->getCharge()); - } + //count charge, i.e. skip if not charged + if(iType != (int)PanTau::TauConstituent::t_Charged) continue; + for(unsigned int iConst=0; iConst<nConstituents; iConst++) { + PanTau::TauConstituent* curConstituent = curList[iConst]; + SumCharge += curConstituent->getCharge(); + AbsCharge += fabs((double)curConstituent->getCharge()); } - - //store charge - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_SumCharge", SumCharge); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_AbsCharge", AbsCharge); - - //! Fill multiplicity for any constituents - //all constituents - std::string typeNameAll = PanTau::TauConstituent2::AllConstituentsName(); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_N" + typeNameAll + "Consts", inSeed->getConstituentsAsList_Core().size() + inSeed->getConstituentsAsList_Wide().size()); - - //! Fill the proto vector (i.e. sum momentum of constituents) - //proto 4-vector (just the sum of all constituents) - // will have better four momentum after mode ID - TLorentzVector tlv_ProtoMomentumCore = inSeed->getProtoMomentumCore(); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumCore_pt", tlv_ProtoMomentumCore.Perp()); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumCore_eta", tlv_ProtoMomentumCore.Eta()); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumCore_phi", tlv_ProtoMomentumCore.Phi()); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumCore_m", tlv_ProtoMomentumCore.M()); - - TLorentzVector tlv_ProtoMomentumWide = inSeed->getProtoMomentumWide(); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumWide_pt", tlv_ProtoMomentumWide.Perp()); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumWide_eta", tlv_ProtoMomentumWide.Eta()); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumWide_phi", tlv_ProtoMomentumWide.Phi()); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumWide_m", tlv_ProtoMomentumWide.M()); - - - return StatusCode::SUCCESS; + } + + //store charge + featureMap->addFeature(featureAlg + "_" + featurePrefix + "_SumCharge", SumCharge); + featureMap->addFeature(featureAlg + "_" + featurePrefix + "_AbsCharge", AbsCharge); + + //! Fill multiplicity for any constituents + //all constituents + std::string typeNameAll = PanTau::TauConstituent::AllConstituentsName(); + featureMap->addFeature(featureAlg + "_" + featurePrefix + "_N" + typeNameAll + "Consts", inSeed->getConstituentsAsList_Core().size() + inSeed->getConstituentsAsList_Wide().size()); + + //! Fill the proto vector (i.e. sum momentum of constituents) + //proto 4-vector (just the sum of all constituents) + // will have better four momentum after mode ID + TLorentzVector tlv_ProtoMomentumCore = inSeed->getProtoMomentumCore(); + featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumCore_pt", tlv_ProtoMomentumCore.Perp()); + featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumCore_eta", tlv_ProtoMomentumCore.Eta()); + featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumCore_phi", tlv_ProtoMomentumCore.Phi()); + featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumCore_m", tlv_ProtoMomentumCore.M()); + + TLorentzVector tlv_ProtoMomentumWide = inSeed->getProtoMomentumWide(); + featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumWide_pt", tlv_ProtoMomentumWide.Perp()); + featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumWide_eta", tlv_ProtoMomentumWide.Eta()); + featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumWide_phi", tlv_ProtoMomentumWide.Phi()); + featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumWide_m", tlv_ProtoMomentumWide.M()); + + return StatusCode::SUCCESS; } - - -StatusCode PanTau::Tool_FeatureExtractor::addConstituentMomenta(PanTau::PanTauSeed2* inSeed) { - std::string inputAlgName = inSeed->getNameInputAlgorithm(); - TauFeature2* tauFeatureMap = inSeed->getFeatures(); - std::string prefixVARType = m_varTypeName_HLV; - for(int iType=0; iType<(int)PanTau::TauConstituent2::t_nTypes; iType++) { - bool isOK; - std::vector<PanTau::TauConstituent2*> list_TypeConstituents = inSeed->getConstituentsOfType(iType, isOK); // list of constituents of current type - unsigned int n_Constituents_Type = list_TypeConstituents.size(); // number of objects of current type - TLorentzVector tlv_TypeConstituents = inSeed->getSubsystemHLV(iType, isOK); // summed hlv of objects of current type - std::string curTypeName = PanTau::TauConstituent2::getTypeName((PanTau::TauConstituent2::Type)iType); - - std::vector<PanTau::TauConstituent2*> list_TypeConstituents_SortBDT = inSeed->getConstituentsOfType(iType, isOK); - std::sort(list_TypeConstituents_SortBDT.begin(), list_TypeConstituents_SortBDT.end(), sortTauConstituentMVA); +StatusCode PanTau::Tool_FeatureExtractor::addConstituentMomenta(PanTau::PanTauSeed* inSeed) { + std::string inputAlgName = inSeed->getNameInputAlgorithm(); + TauFeature* tauFeatureMap = inSeed->getFeatures(); + std::string prefixVARType = m_varTypeName_HLV; + for(int iType=0; iType<(int)PanTau::TauConstituent::t_nTypes; iType++) { + bool isOK; + std::vector<PanTau::TauConstituent*> list_TypeConstituents = inSeed->getConstituentsOfType(iType, isOK); // list of constituents of current type + unsigned int n_Constituents_Type = list_TypeConstituents.size(); // number of objects of current type + TLorentzVector tlv_TypeConstituents = inSeed->getSubsystemHLV(iType, isOK); // summed hlv of objects of current type + std::string curTypeName = PanTau::TauConstituent::getTypeName((PanTau::TauConstituent::Type)iType); - if(list_TypeConstituents.size() > 0) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumPt", tlv_TypeConstituents.Perp()); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumEta", tlv_TypeConstituents.Eta()); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumPhi", tlv_TypeConstituents.Phi()); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumM", tlv_TypeConstituents.M()); - } + std::vector<PanTau::TauConstituent*> list_TypeConstituents_SortBDT = inSeed->getConstituentsOfType(iType, isOK); + std::sort(list_TypeConstituents_SortBDT.begin(), list_TypeConstituents_SortBDT.end(), sortTauConstituentMVA); - //store 4-vectors of current type (et sort); - std::vector<double> curConsts_pt = std::vector<double>(0); - std::vector<double> curConsts_eta = std::vector<double>(0); - std::vector<double> curConsts_phi = std::vector<double>(0); - std::vector<double> curConsts_m = std::vector<double>(0); - for(unsigned int iConst=0; iConst<n_Constituents_Type; iConst++) { - TLorentzVector tlv_curConst = list_TypeConstituents[iConst]->p4(); - curConsts_pt.push_back(tlv_curConst.Perp()); - curConsts_eta.push_back(tlv_curConst.Eta()); - curConsts_phi.push_back(tlv_curConst.Phi()); - curConsts_m.push_back(tlv_curConst.M()); - } - tauFeatureMap->addVecFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtSort_Constituents_pt", curConsts_pt); - tauFeatureMap->addVecFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtSort_Constituents_eta", curConsts_eta); - tauFeatureMap->addVecFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtSort_Constituents_phi", curConsts_phi); - tauFeatureMap->addVecFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtSort_Constituents_m", curConsts_m); + if(list_TypeConstituents.size() > 0) { + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumPt", tlv_TypeConstituents.Perp()); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumEta", tlv_TypeConstituents.Eta()); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumPhi", tlv_TypeConstituents.Phi()); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumM", tlv_TypeConstituents.M()); + } - - //store 4-vectors of current type (bdt sort) - std::vector<double> curConstsBDT_pt = std::vector<double>(0); - std::vector<double> curConstsBDT_eta = std::vector<double>(0); - std::vector<double> curConstsBDT_phi = std::vector<double>(0); - std::vector<double> curConstsBDT_m = std::vector<double>(0); - for(unsigned int iConst=0; iConst<n_Constituents_Type; iConst++) { - TLorentzVector tlv_curConstBDT = list_TypeConstituents_SortBDT[iConst]->p4(); - curConstsBDT_pt.push_back(tlv_curConstBDT.Perp()); - curConstsBDT_eta.push_back(tlv_curConstBDT.Eta()); - curConstsBDT_phi.push_back(tlv_curConstBDT.Phi()); - curConstsBDT_m.push_back(tlv_curConstBDT.M()); - } - tauFeatureMap->addVecFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTSort_Constituents_pt", curConstsBDT_pt); - tauFeatureMap->addVecFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTSort_Constituents_eta", curConstsBDT_eta); - tauFeatureMap->addVecFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTSort_Constituents_phi", curConstsBDT_phi); - tauFeatureMap->addVecFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTSort_Constituents_m", curConstsBDT_m); - - } //end loop over constituent types + //store 4-vectors of current type (et sort); + std::vector<double> curConsts_pt = std::vector<double>(0); + std::vector<double> curConsts_eta = std::vector<double>(0); + std::vector<double> curConsts_phi = std::vector<double>(0); + std::vector<double> curConsts_m = std::vector<double>(0); + for(unsigned int iConst=0; iConst<n_Constituents_Type; iConst++) { + TLorentzVector tlv_curConst = list_TypeConstituents[iConst]->p4(); + curConsts_pt.push_back(tlv_curConst.Perp()); + curConsts_eta.push_back(tlv_curConst.Eta()); + curConsts_phi.push_back(tlv_curConst.Phi()); + curConsts_m.push_back(tlv_curConst.M()); + } + tauFeatureMap->addVecFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtSort_Constituents_pt", curConsts_pt); + tauFeatureMap->addVecFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtSort_Constituents_eta", curConsts_eta); + tauFeatureMap->addVecFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtSort_Constituents_phi", curConsts_phi); + tauFeatureMap->addVecFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtSort_Constituents_m", curConsts_m); + + //store 4-vectors of current type (bdt sort) + std::vector<double> curConstsBDT_pt = std::vector<double>(0); + std::vector<double> curConstsBDT_eta = std::vector<double>(0); + std::vector<double> curConstsBDT_phi = std::vector<double>(0); + std::vector<double> curConstsBDT_m = std::vector<double>(0); + for(unsigned int iConst=0; iConst<n_Constituents_Type; iConst++) { + TLorentzVector tlv_curConstBDT = list_TypeConstituents_SortBDT[iConst]->p4(); + curConstsBDT_pt.push_back(tlv_curConstBDT.Perp()); + curConstsBDT_eta.push_back(tlv_curConstBDT.Eta()); + curConstsBDT_phi.push_back(tlv_curConstBDT.Phi()); + curConstsBDT_m.push_back(tlv_curConstBDT.M()); + } + tauFeatureMap->addVecFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTSort_Constituents_pt", curConstsBDT_pt); + tauFeatureMap->addVecFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTSort_Constituents_eta", curConstsBDT_eta); + tauFeatureMap->addVecFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTSort_Constituents_phi", curConstsBDT_phi); + tauFeatureMap->addVecFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTSort_Constituents_m", curConstsBDT_m); - return StatusCode::SUCCESS; + } //end loop over constituent types + + return StatusCode::SUCCESS; } - -StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed2* inSeed, - int tauConstituentType) { - - std::string curTypeName = PanTau::TauConstituent2::getTypeName( (PanTau::TauConstituent2::Type)tauConstituentType ); - std::string curTypeName_All = PanTau::TauConstituent2::AllConstituentsName(); - PanTau::TauFeature2* tauFeatureMap = inSeed->getFeatures(); - std::string inputAlgName = inSeed->getNameInputAlgorithm(); - TLorentzVector tlv_Reference = inSeed->getProtoMomentumCore(); - - std::vector<PanTau::TauConstituent2*> list_AllConstituents = inSeed->getConstituentsAsList_Core(); - - bool foundIt = false; - std::vector<PanTau::TauConstituent2*> list_TypeConstituents; - if(tauConstituentType != PanTau::TauConstituent2::t_NoType) list_TypeConstituents = inSeed->getConstituentsOfType(tauConstituentType, foundIt); - if(tauConstituentType == PanTau::TauConstituent2::t_NoType) list_TypeConstituents = list_AllConstituents; - if(foundIt == false) return StatusCode::SUCCESS; - - unsigned int n_Constituents_All = list_AllConstituents.size(); - unsigned int n_Constituents_Type = list_TypeConstituents.size(); - - ATH_MSG_DEBUG("Calculating features for " << list_TypeConstituents.size() << " constituents of type " << tauConstituentType << "(" << curTypeName << ")"); - - //sort the lists by Et - std::sort(list_AllConstituents.begin(), list_AllConstituents.end(), sortTauConstituentEt); - std::sort(list_TypeConstituents.begin(), list_TypeConstituents.end(), sortTauConstituentEt); +StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* inSeed, + int tauConstituentType) { - TLorentzVector tlv_1st_Et; - TLorentzVector tlv_2nd_Et; - TLorentzVector tlv_3rd_Et; + std::string curTypeName = PanTau::TauConstituent::getTypeName( (PanTau::TauConstituent::Type)tauConstituentType ); + std::string curTypeName_All = PanTau::TauConstituent::AllConstituentsName(); + PanTau::TauFeature* tauFeatureMap = inSeed->getFeatures(); + std::string inputAlgName = inSeed->getNameInputAlgorithm(); + TLorentzVector tlv_Reference = inSeed->getProtoMomentumCore(); - if(list_TypeConstituents.size() > 0) tlv_1st_Et = list_TypeConstituents[0]->p4(); - if(list_TypeConstituents.size() > 1) tlv_2nd_Et = list_TypeConstituents[1]->p4(); - if(list_TypeConstituents.size() > 2) tlv_3rd_Et = list_TypeConstituents[2]->p4(); + std::vector<PanTau::TauConstituent*> list_AllConstituents = inSeed->getConstituentsAsList_Core(); - - TLorentzVector tlv_Last_Et; - if(list_TypeConstituents.size() > 0) tlv_Last_Et = list_TypeConstituents.back()->p4(); - - //make an additional list of constituents, but now ordered by BDT value - std::vector<PanTau::TauConstituent2*> list_TypeConstituents_SortBDT = list_TypeConstituents; - std::sort(list_TypeConstituents_SortBDT.begin(), list_TypeConstituents_SortBDT.end(), sortTauConstituentMVA); - - TLorentzVector tlv_1st_BDT; - TLorentzVector tlv_2nd_BDT; - TLorentzVector tlv_3rd_BDT; - - if(list_TypeConstituents_SortBDT.size() > 0) tlv_1st_BDT = list_TypeConstituents_SortBDT[0]->p4(); - if(list_TypeConstituents_SortBDT.size() > 1) tlv_2nd_BDT = list_TypeConstituents_SortBDT[1]->p4(); - if(list_TypeConstituents_SortBDT.size() > 2) tlv_3rd_BDT = list_TypeConstituents_SortBDT[2]->p4(); - - //! ////////////////////////////////////////// - //! Prepare variables for information from eflow Objects - //! ////////////////////////////////////////// - - // ===> hlv for the leading EFOs and the summed HLV - TLorentzVector tlv_TypeConstituents; - // ===> Sum of DeltaR to jet axis - double sum_DRToReference = 0; - double sum_DR2ToReference = 0; - double sum_DRToLeading = 0; - double sum_DR2ToLeading = 0; - // ===> Sum of Et, Et^2, E and E^2 - double sum_Et = 0; - double sum_Et2 = 0; - double sum_E = 0; - double sum_E2 = 0; - // ===> Sum of Et (and E) times DeltaR, DeltaR', Angle - double sum_EtxDR = 0; - double sum_EtxDR2 = 0; - double sum_EtxDRprime = 0; - double sum_EtxAngle = 0; - double sum_ExDR = 0; - double sum_ExDR2 = 0; - double sum_ExDRprime = 0; - double sum_ExAngle = 0; - // ===> Isolation rings - double sum_EtInRing00To01 = 0; - double sum_EtInRing01To02 = 0; - double sum_EtInRing02To03 = 0; - double sum_EtInRing03To04 = 0; - double sum_EtInRing04To05 = 0; - // ===> Multiplicities - unsigned int num_EFOs = 0; - unsigned int num_ConstsIn00To01 = 0; - unsigned int num_ConstsIn01To02 = 0; - unsigned int num_ConstsIn02To03 = 0; - unsigned int num_ConstsIn03To04 = 0; - unsigned int num_ConstsIn04To05 = 0; - // ===> Maximal values - double max_DeltaR = 0; - - - //! ////////////////////////////////////////// - //! Loop over selected constituents and collect information - //! ////////////////////////////////////////// - for(unsigned int iTypeConst=0; iTypeConst<list_TypeConstituents.size(); iTypeConst++) { + bool foundIt = false; + std::vector<PanTau::TauConstituent*> list_TypeConstituents; + if(tauConstituentType != PanTau::TauConstituent::t_NoType) list_TypeConstituents = inSeed->getConstituentsOfType(tauConstituentType, foundIt); + if(tauConstituentType == PanTau::TauConstituent::t_NoType) list_TypeConstituents = list_AllConstituents; + if(foundIt == false) return StatusCode::SUCCESS; + + unsigned int n_Constituents_All = list_AllConstituents.size(); + unsigned int n_Constituents_Type = list_TypeConstituents.size(); - //get hep lorentz vector - TLorentzVector tlv_curConst = list_TypeConstituents.at(iTypeConst)->p4(); + //sort the lists by Et + std::sort(list_AllConstituents.begin(), list_AllConstituents.end(), sortTauConstituentEt); + std::sort(list_TypeConstituents.begin(), list_TypeConstituents.end(), sortTauConstituentEt); + + TLorentzVector tlv_1st_Et; + TLorentzVector tlv_2nd_Et; + TLorentzVector tlv_3rd_Et; + + if(list_TypeConstituents.size() > 0) tlv_1st_Et = list_TypeConstituents[0]->p4(); + if(list_TypeConstituents.size() > 1) tlv_2nd_Et = list_TypeConstituents[1]->p4(); + if(list_TypeConstituents.size() > 2) tlv_3rd_Et = list_TypeConstituents[2]->p4(); + + + TLorentzVector tlv_Last_Et; + if(list_TypeConstituents.size() > 0) tlv_Last_Et = list_TypeConstituents.back()->p4(); + + //make an additional list of constituents, but now ordered by BDT value + std::vector<PanTau::TauConstituent*> list_TypeConstituents_SortBDT = list_TypeConstituents; + std::sort(list_TypeConstituents_SortBDT.begin(), list_TypeConstituents_SortBDT.end(), sortTauConstituentMVA); + + TLorentzVector tlv_1st_BDT; + TLorentzVector tlv_2nd_BDT; + TLorentzVector tlv_3rd_BDT; + + if(list_TypeConstituents_SortBDT.size() > 0) tlv_1st_BDT = list_TypeConstituents_SortBDT[0]->p4(); + if(list_TypeConstituents_SortBDT.size() > 1) tlv_2nd_BDT = list_TypeConstituents_SortBDT[1]->p4(); + if(list_TypeConstituents_SortBDT.size() > 2) tlv_3rd_BDT = list_TypeConstituents_SortBDT[2]->p4(); + + //! ////////////////////////////////////////// + //! Prepare variables for information from eflow Objects + //! ////////////////////////////////////////// + + // ===> hlv for the leading EFOs and the summed HLV + TLorentzVector tlv_TypeConstituents; + // ===> Sum of DeltaR to jet axis + double sum_DRToReference = 0; + double sum_DR2ToReference = 0; + double sum_DRToLeading = 0; + double sum_DR2ToLeading = 0; + // ===> Sum of Et, Et^2, E and E^2 + double sum_Et = 0; + double sum_Et2 = 0; + double sum_E = 0; + double sum_E2 = 0; + // ===> Sum of Et (and E) times DeltaR, DeltaR', Angle + double sum_EtxDR = 0; + double sum_EtxDR2 = 0; + double sum_EtxDRprime = 0; + double sum_EtxAngle = 0; + double sum_ExDR = 0; + double sum_ExDR2 = 0; + double sum_ExDRprime = 0; + double sum_ExAngle = 0; + // ===> Isolation rings + double sum_EtInRing00To01 = 0; + double sum_EtInRing01To02 = 0; + double sum_EtInRing02To03 = 0; + double sum_EtInRing03To04 = 0; + double sum_EtInRing04To05 = 0; + // ===> Multiplicities + unsigned int num_EFOs = 0; + unsigned int num_ConstsIn00To01 = 0; + unsigned int num_ConstsIn01To02 = 0; + unsigned int num_ConstsIn02To03 = 0; + unsigned int num_ConstsIn03To04 = 0; + unsigned int num_ConstsIn04To05 = 0; + // ===> Maximal values + double max_DeltaR = 0; + + + //! ////////////////////////////////////////// + //! Loop over selected constituents and collect information + //! ////////////////////////////////////////// + for(unsigned int iTypeConst=0; iTypeConst<list_TypeConstituents.size(); iTypeConst++) { - //final check (nan & inf) - if (isnan(tlv_curConst.Pt()) || isinf(tlv_curConst.Pt())) continue; + //get hep lorentz vector + TLorentzVector tlv_curConst = list_TypeConstituents.at(iTypeConst)->p4(); - //ready to calc stuff - //basically update each of the prepared sum_* and num_* variables above, - // the sum HLV and the pointers to 1st, 2nd, 3rd leading constituents of current type - tlv_TypeConstituents += tlv_curConst; + //final check (nan & inf) + if (isnan(tlv_curConst.Pt()) || isinf(tlv_curConst.Pt())) continue; - //helpers to reduce function calls - double hlp_Et = tlv_curConst.Et(); - double hlp_Et2 = hlp_Et * hlp_Et; - double hlp_E = tlv_curConst.E(); - double hlp_E2 = hlp_E * hlp_E; - double hlp_DeltaR = tlv_Reference.DeltaR(tlv_curConst); - double hlp_DeltaR2 = hlp_DeltaR * hlp_DeltaR; - double hlp_DeltaRLeading = (tlv_1st_Et.Pt() == 0 ? 0 : tlv_1st_Et.DeltaR(tlv_curConst)); - double hlp_DeltaR2Leading = hlp_DeltaRLeading * hlp_DeltaRLeading; - double hlp_DeltaRprime = m_HelperFunctions.deltaRprime(tlv_Reference.Vect(), tlv_curConst.Vect()); - double hlp_Angle = tlv_Reference.Angle(tlv_curConst.Vect()); + //ready to calc stuff + //basically update each of the prepared sum_* and num_* variables above, + // the sum HLV and the pointers to 1st, 2nd, 3rd leading constituents of current type + tlv_TypeConstituents += tlv_curConst; - // update sum of DeltaR to jet axis - sum_DRToReference += hlp_DeltaR; - sum_DR2ToReference += hlp_DeltaR2; - sum_DRToLeading += hlp_DeltaRLeading; - sum_DR2ToLeading += hlp_DeltaR2Leading; - // update Sum of Et, Et^2, E and E^2 - sum_Et += hlp_Et; - sum_Et2 += hlp_Et2; - sum_E += hlp_E; - sum_E2 += hlp_E2; - // update Sum of Et (and E) times DeltaR, DeltaR', Angle - sum_EtxDR += hlp_Et * hlp_DeltaR; - sum_EtxDR2 += hlp_Et * hlp_DeltaR2; - sum_EtxDRprime += hlp_Et * hlp_DeltaRprime; - sum_EtxAngle += hlp_Et * hlp_Angle; - sum_ExDR += hlp_E * hlp_DeltaR; - sum_ExDR2 += hlp_E * hlp_DeltaR2; - sum_ExDRprime += hlp_E * hlp_DeltaRprime; - sum_ExAngle += hlp_E * hlp_Angle; - // update Isolation rings - if(hlp_DeltaR >= 0.0 && hlp_DeltaR < 0.1) sum_EtInRing00To01 += hlp_Et; - if(hlp_DeltaR >= 0.1 && hlp_DeltaR < 0.2) sum_EtInRing01To02 += hlp_Et; - if(hlp_DeltaR >= 0.2 && hlp_DeltaR < 0.3) sum_EtInRing02To03 += hlp_Et; - if(hlp_DeltaR >= 0.3 && hlp_DeltaR < 0.4) sum_EtInRing03To04 += hlp_Et; - if(hlp_DeltaR >= 0.4 && hlp_DeltaR < 0.5) sum_EtInRing04To05 += hlp_Et; - // update Multiplicities - num_EFOs++; - if(hlp_DeltaR >= 0.0 && hlp_DeltaR < 0.1) num_ConstsIn00To01++; - if(hlp_DeltaR >= 0.1 && hlp_DeltaR < 0.2) num_ConstsIn01To02++; - if(hlp_DeltaR >= 0.2 && hlp_DeltaR < 0.3) num_ConstsIn02To03++; - if(hlp_DeltaR >= 0.3 && hlp_DeltaR < 0.4) num_ConstsIn03To04++; - if(hlp_DeltaR >= 0.4 && hlp_DeltaR < 0.5) num_ConstsIn04To05++; - // update Max values - if(hlp_DeltaR > max_DeltaR) max_DeltaR = hlp_DeltaR; - }//end loop over selected EFOs - - - - //! ////////////////////////////////////////// - //! Calculate & fill features - //! ////////////////////////////////////////// - - // naming string - std::string prefixVARType = ""; - - //! Multiplicities /////////////////////////////////////////// - //if there are no EFOs of this type in the seed, all other variables cannot be calculated to have any reasonable value - if( num_EFOs == 0 ) { - return StatusCode::SUCCESS; - } - - prefixVARType = m_varTypeName_Num; - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_ConstsIn00To01", num_ConstsIn00To01); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_ConstsIn01To02", num_ConstsIn01To02); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_ConstsIn02To03", num_ConstsIn02To03); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_ConstsIn03To04", num_ConstsIn03To04); - + //helpers to reduce function calls + double hlp_Et = tlv_curConst.Et(); + double hlp_Et2 = hlp_Et * hlp_Et; + double hlp_E = tlv_curConst.E(); + double hlp_E2 = hlp_E * hlp_E; + double hlp_DeltaR = tlv_Reference.DeltaR(tlv_curConst); + double hlp_DeltaR2 = hlp_DeltaR * hlp_DeltaR; + double hlp_DeltaRLeading = (tlv_1st_Et.Pt() == 0 ? 0 : tlv_1st_Et.DeltaR(tlv_curConst)); + double hlp_DeltaR2Leading = hlp_DeltaRLeading * hlp_DeltaRLeading; + double hlp_DeltaRprime = m_HelperFunctions.deltaRprime(tlv_Reference.Vect(), tlv_curConst.Vect()); + double hlp_Angle = tlv_Reference.Angle(tlv_curConst.Vect()); + + // update sum of DeltaR to jet axis + sum_DRToReference += hlp_DeltaR; + sum_DR2ToReference += hlp_DeltaR2; + sum_DRToLeading += hlp_DeltaRLeading; + sum_DR2ToLeading += hlp_DeltaR2Leading; + // update Sum of Et, Et^2, E and E^2 + sum_Et += hlp_Et; + sum_Et2 += hlp_Et2; + sum_E += hlp_E; + sum_E2 += hlp_E2; + // update Sum of Et (and E) times DeltaR, DeltaR', Angle + sum_EtxDR += hlp_Et * hlp_DeltaR; + sum_EtxDR2 += hlp_Et * hlp_DeltaR2; + sum_EtxDRprime += hlp_Et * hlp_DeltaRprime; + sum_EtxAngle += hlp_Et * hlp_Angle; + sum_ExDR += hlp_E * hlp_DeltaR; + sum_ExDR2 += hlp_E * hlp_DeltaR2; + sum_ExDRprime += hlp_E * hlp_DeltaRprime; + sum_ExAngle += hlp_E * hlp_Angle; + // update Isolation rings + if(hlp_DeltaR >= 0.0 && hlp_DeltaR < 0.1) sum_EtInRing00To01 += hlp_Et; + if(hlp_DeltaR >= 0.1 && hlp_DeltaR < 0.2) sum_EtInRing01To02 += hlp_Et; + if(hlp_DeltaR >= 0.2 && hlp_DeltaR < 0.3) sum_EtInRing02To03 += hlp_Et; + if(hlp_DeltaR >= 0.3 && hlp_DeltaR < 0.4) sum_EtInRing03To04 += hlp_Et; + if(hlp_DeltaR >= 0.4 && hlp_DeltaR < 0.5) sum_EtInRing04To05 += hlp_Et; + // update Multiplicities + num_EFOs++; + if(hlp_DeltaR >= 0.0 && hlp_DeltaR < 0.1) num_ConstsIn00To01++; + if(hlp_DeltaR >= 0.1 && hlp_DeltaR < 0.2) num_ConstsIn01To02++; + if(hlp_DeltaR >= 0.2 && hlp_DeltaR < 0.3) num_ConstsIn02To03++; + if(hlp_DeltaR >= 0.3 && hlp_DeltaR < 0.4) num_ConstsIn03To04++; + if(hlp_DeltaR >= 0.4 && hlp_DeltaR < 0.5) num_ConstsIn04To05++; + // update Max values + if(hlp_DeltaR > max_DeltaR) max_DeltaR = hlp_DeltaR; + }//end loop over selected EFOs + + + + //! ////////////////////////////////////////// + //! Calculate & fill features + //! ////////////////////////////////////////// + + // naming string + std::string prefixVARType = ""; + + //! Multiplicities /////////////////////////////////////////// + //if there are no EFOs of this type in the seed, all other variables cannot be calculated to have any reasonable value + if( num_EFOs == 0 ) { + return StatusCode::SUCCESS; + } + prefixVARType = m_varTypeName_Num; + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_ConstsIn00To01", num_ConstsIn00To01); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_ConstsIn01To02", num_ConstsIn01To02); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_ConstsIn02To03", num_ConstsIn02To03); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_ConstsIn03To04", num_ConstsIn03To04); - //! Substructure particle ID features /////////////////////////////////////////// - prefixVARType = m_varTypeName_PID; + //! Substructure particle ID features /////////////////////////////////////////// + prefixVARType = m_varTypeName_PID; - // Sorted by highest BDT score - double value_sumBDT_BDTSort = 0; - for(unsigned int iTypeConst=0; iTypeConst<n_Constituents_Type; iTypeConst++) { - - double value_BDT = list_TypeConstituents_SortBDT[iTypeConst]->getBDTValue(); - if( isnan(value_BDT) || isinf(value_BDT) ) continue; + // Sorted by highest BDT score + double value_sumBDT_BDTSort = 0; + for(unsigned int iTypeConst=0; iTypeConst<n_Constituents_Type; iTypeConst++) { - //correct BDT value based on BDT cut - if(tauConstituentType != PanTau::TauConstituent2::t_Charged) { - double mvaCorrection = 0.0; - double etaCurConst = list_TypeConstituents_SortBDT[iTypeConst]->p4().Eta(); - int etaBinIndex = m_HelperFunctions.getBinIndex(m_Config_CellBased_BinEdges_Eta, fabs(etaCurConst)); - int numTrack = inSeed->getTauJet()->nTracks(); - if(numTrack == 1) { mvaCorrection = m_Config_CellBased_EtaBinned_Pi0MVACut_1prong.at(etaBinIndex); } - else { mvaCorrection = m_Config_CellBased_EtaBinned_Pi0MVACut_3prong.at(etaBinIndex); } - ATH_MSG_DEBUG("\t\tnumTrack = " << numTrack << " / value_BDT = " << value_BDT << " / mvaCorrection = " << mvaCorrection << " / etaCurConst = " << etaCurConst << " / etaBinIndex = " << etaBinIndex); - value_BDT = value_BDT - mvaCorrection; - } + double value_BDT = list_TypeConstituents_SortBDT[iTypeConst]->getBDTValue(); + if( isnan(value_BDT) || isinf(value_BDT) ) continue; - value_sumBDT_BDTSort += value_BDT; - std::string iConst = m_HelperFunctions.convertNumberToString((double)(iTypeConst+1)); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTValues_BDTSort_" + iConst, value_BDT); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTValuesSum_BDTSort_" + iConst, value_sumBDT_BDTSort); + //correct BDT value based on BDT cut + if(tauConstituentType != PanTau::TauConstituent::t_Charged) { + double mvaCorrection = 0.0; + double etaCurConst = list_TypeConstituents_SortBDT[iTypeConst]->p4().Eta(); + int etaBinIndex = m_HelperFunctions.getBinIndex(m_Config_CellBased_BinEdges_Eta, fabs(etaCurConst)); + int numTrack = inSeed->getTauJet()->nTracks(); + if(numTrack == 1) { mvaCorrection = m_Config_CellBased_EtaBinned_Pi0MVACut_1prong.at(etaBinIndex); } + else { mvaCorrection = m_Config_CellBased_EtaBinned_Pi0MVACut_3prong.at(etaBinIndex); } + + value_BDT = value_BDT - mvaCorrection; } - - //sorted by highest Et - double value_sumBDT_EtSort = 0; - for(unsigned int iTypeConst=0; iTypeConst<n_Constituents_Type; iTypeConst++) { - double value_BDT = list_TypeConstituents[iTypeConst]->getBDTValue(); - if( isnan(value_BDT) || isinf(value_BDT) ) continue; + value_sumBDT_BDTSort += value_BDT; + std::string iConst = m_HelperFunctions.convertNumberToString((double)(iTypeConst+1)); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTValues_BDTSort_" + iConst, value_BDT); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTValuesSum_BDTSort_" + iConst, value_sumBDT_BDTSort); + } + + //sorted by highest Et + double value_sumBDT_EtSort = 0; + for(unsigned int iTypeConst=0; iTypeConst<n_Constituents_Type; iTypeConst++) { - value_sumBDT_EtSort += value_BDT; - std::string iConst = m_HelperFunctions.convertNumberToString((double)(iTypeConst+1)); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTValues_EtSort_" + iConst, value_BDT); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTValuesSum_EtSort_" + iConst, value_sumBDT_EtSort); - } + double value_BDT = list_TypeConstituents[iTypeConst]->getBDTValue(); + if( isnan(value_BDT) || isinf(value_BDT) ) continue; + + value_sumBDT_EtSort += value_BDT; + std::string iConst = m_HelperFunctions.convertNumberToString((double)(iTypeConst+1)); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTValues_EtSort_" + iConst, value_BDT); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTValuesSum_EtSort_" + iConst, value_sumBDT_EtSort); + } - //! Shot information /////////////////////////////////////////// - prefixVARType = PanTau::Tool_FeatureExtractor::varTypeName_Shots(); - //only execute if the constituent type is neutral - if(PanTau::TauConstituent2::isNeutralType(tauConstituentType) == true) { + //! Shot information /////////////////////////////////////////// + prefixVARType = PanTau::Tool_FeatureExtractor::varTypeName_Shots(); + //only execute if the constituent type is neutral + if(PanTau::TauConstituent::isNeutralType(tauConstituentType) == true) { - TLorentzVector totalTLV_SumShots = TLorentzVector(0., 0., 0., 0.); - unsigned int totalPhotonsInSeed = 0; - unsigned int totalShotsInSeed = 0; - double maxDeltaRSumShotToConst = -999; - double minDeltaRSumShotToConst = 999; - double maxDeltaRSumShotToTau = -999; - double minDeltaRSumShotToTau = 999; + TLorentzVector totalTLV_SumShots = TLorentzVector(0., 0., 0., 0.); + unsigned int totalPhotonsInSeed = 0; + unsigned int totalShotsInSeed = 0; + double maxDeltaRSumShotToConst = -999; + double minDeltaRSumShotToConst = 999; + double maxDeltaRSumShotToTau = -999; + double minDeltaRSumShotToTau = 999; - std::vector<TLorentzVector> allShotTLVs = std::vector<TLorentzVector>(0); + std::vector<TLorentzVector> allShotTLVs = std::vector<TLorentzVector>(0); - for(unsigned int iConst=0; iConst<list_TypeConstituents_SortBDT.size(); iConst++) { + for(unsigned int iConst=0; iConst<list_TypeConstituents_SortBDT.size(); iConst++) { - PanTau::TauConstituent2* curConst = list_TypeConstituents_SortBDT.at(iConst); - TLorentzVector tlv_CurConst = curConst->p4(); - std::vector<PanTau::TauConstituent2*> shotConstituents = curConst->getShots(); - unsigned int nShots = shotConstituents.size(); + PanTau::TauConstituent* curConst = list_TypeConstituents_SortBDT.at(iConst); + TLorentzVector tlv_CurConst = curConst->p4(); + std::vector<PanTau::TauConstituent*> shotConstituents = curConst->getShots(); + unsigned int nShots = shotConstituents.size(); - unsigned int totalPhotonsInNeutral = 0; - TLorentzVector tlv_SumShots = TLorentzVector(0., 0., 0., 0.); + unsigned int totalPhotonsInNeutral = 0; + TLorentzVector tlv_SumShots = TLorentzVector(0., 0., 0., 0.); - for(unsigned int iShot=0; iShot<nShots; iShot++) { - PanTau::TauConstituent2* curShot = shotConstituents.at(iShot); - totalPhotonsInNeutral += curShot->getNPhotonsInShot(); - tlv_SumShots += curShot->p4(); - allShotTLVs.push_back(curShot->p4()); - }//end loop over shots - totalShotsInSeed += nShots; - totalTLV_SumShots += tlv_SumShots; - totalPhotonsInSeed += totalPhotonsInNeutral; + for(unsigned int iShot=0; iShot<nShots; iShot++) { + PanTau::TauConstituent* curShot = shotConstituents.at(iShot); + totalPhotonsInNeutral += curShot->getNPhotonsInShot(); + tlv_SumShots += curShot->p4(); + allShotTLVs.push_back(curShot->p4()); + }//end loop over shots + totalShotsInSeed += nShots; + totalTLV_SumShots += tlv_SumShots; + totalPhotonsInSeed += totalPhotonsInNeutral; - std::string iConstStr = m_HelperFunctions.convertNumberToString((double)(iConst+1)); + std::string iConstStr = m_HelperFunctions.convertNumberToString((double)(iConst+1)); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_nPhotons_BDTSort_" + iConstStr, totalPhotonsInNeutral); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_nShots_BDTSort_" + iConstStr, nShots); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_nPhotons_BDTSort_" + iConstStr, totalPhotonsInNeutral); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_nShots_BDTSort_" + iConstStr, nShots); - //the et/eta/phi/m of the hlv of all shots combined for this neutral-type constituent - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumShots_Et_BDTSort_" + iConstStr, tlv_SumShots.Et()); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumShots_Eta_BDTSort_" + iConstStr, tlv_SumShots.Eta()); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumShots_Phi_BDTSort_" + iConstStr, tlv_SumShots.Phi()); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumShots_M_BDTSort_" + iConstStr, tlv_SumShots.M()); + //the et/eta/phi/m of the hlv of all shots combined for this neutral-type constituent + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumShots_Et_BDTSort_" + iConstStr, tlv_SumShots.Et()); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumShots_Eta_BDTSort_" + iConstStr, tlv_SumShots.Eta()); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumShots_Phi_BDTSort_" + iConstStr, tlv_SumShots.Phi()); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumShots_M_BDTSort_" + iConstStr, tlv_SumShots.M()); - //energy ratio, deltaR of sumShots and constituent - double deltaRSumShotToConst = tlv_CurConst.DeltaR(tlv_SumShots); - if(deltaRSumShotToConst > maxDeltaRSumShotToConst) maxDeltaRSumShotToConst = deltaRSumShotToConst; - if(deltaRSumShotToConst < minDeltaRSumShotToConst) minDeltaRSumShotToConst = deltaRSumShotToConst; - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_ConstDeltaRToSumShots_BDTSort_" + iConstStr, deltaRSumShotToConst); - if(tlv_CurConst.Et() > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtSumShotsOverConstEt_BDTSort_" + iConstStr, tlv_SumShots.Et() / tlv_CurConst.Et()); + //energy ratio, deltaR of sumShots and constituent + double deltaRSumShotToConst = tlv_CurConst.DeltaR(tlv_SumShots); + if(deltaRSumShotToConst > maxDeltaRSumShotToConst) maxDeltaRSumShotToConst = deltaRSumShotToConst; + if(deltaRSumShotToConst < minDeltaRSumShotToConst) minDeltaRSumShotToConst = deltaRSumShotToConst; + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_ConstDeltaRToSumShots_BDTSort_" + iConstStr, deltaRSumShotToConst); + if(tlv_CurConst.Et() > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtSumShotsOverConstEt_BDTSort_" + iConstStr, tlv_SumShots.Et() / tlv_CurConst.Et()); - //energy ratio, deltaR of shots and tauSeed - double deltaRSumShotToTau = tlv_Reference.DeltaR(tlv_SumShots); - if(deltaRSumShotToTau > maxDeltaRSumShotToTau) maxDeltaRSumShotToTau = deltaRSumShotToTau; - if(deltaRSumShotToTau < minDeltaRSumShotToTau) minDeltaRSumShotToTau = deltaRSumShotToTau; - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_TauDeltaRToSumShots_BDTSort_" + iConstStr, deltaRSumShotToTau); - if(tlv_Reference.Et() > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtSumShotsOverTauEt_BDTSort_" + iConstStr, tlv_SumShots.Et() / tlv_Reference.Et()); + //energy ratio, deltaR of shots and tauSeed + double deltaRSumShotToTau = tlv_Reference.DeltaR(tlv_SumShots); + if(deltaRSumShotToTau > maxDeltaRSumShotToTau) maxDeltaRSumShotToTau = deltaRSumShotToTau; + if(deltaRSumShotToTau < minDeltaRSumShotToTau) minDeltaRSumShotToTau = deltaRSumShotToTau; + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_TauDeltaRToSumShots_BDTSort_" + iConstStr, deltaRSumShotToTau); + if(tlv_Reference.Et() > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtSumShotsOverTauEt_BDTSort_" + iConstStr, tlv_SumShots.Et() / tlv_Reference.Et()); - }//end loop over constituents in tau + }//end loop over constituents in tau - //delta R values - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MaxDeltaRSumShotToConst", maxDeltaRSumShotToConst); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MinDeltaRSumShotToConst", minDeltaRSumShotToConst); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MaxDeltaRSumShotToTau", maxDeltaRSumShotToTau); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MinDeltaRSumShotToTau", minDeltaRSumShotToTau); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_DeltaRAllShotsToTau", tlv_Reference.DeltaR(totalTLV_SumShots)); + //delta R values + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MaxDeltaRSumShotToConst", maxDeltaRSumShotToConst); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MinDeltaRSumShotToConst", minDeltaRSumShotToConst); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MaxDeltaRSumShotToTau", maxDeltaRSumShotToTau); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MinDeltaRSumShotToTau", minDeltaRSumShotToTau); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_DeltaRAllShotsToTau", tlv_Reference.DeltaR(totalTLV_SumShots)); - //et ratio - if(tlv_Reference.Et() > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtAllShotsOverEtTau", totalTLV_SumShots.Et() / tlv_Reference.Et()); + //et ratio + if(tlv_Reference.Et() > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtAllShotsOverEtTau", totalTLV_SumShots.Et() / tlv_Reference.Et()); - //number of shots in seed - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_NShotsInSeed", totalShotsInSeed); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_NPhotonsInSeed", totalPhotonsInSeed); - - //build di-Shot mass - double maxDiShotMass = -200; - double minDiShotMass = 99999; - double bestDiShotMass = -200; - double bestPi0Diff = 99999; - for(unsigned int iShot=0; iShot<allShotTLVs.size(); iShot++) { - TLorentzVector cur_iShot = allShotTLVs.at(iShot); + //number of shots in seed + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_NShotsInSeed", totalShotsInSeed); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_NPhotonsInSeed", totalPhotonsInSeed); + + //build di-Shot mass + double maxDiShotMass = -200; + double minDiShotMass = 99999; + double bestDiShotMass = -200; + double bestPi0Diff = 99999; + for(unsigned int iShot=0; iShot<allShotTLVs.size(); iShot++) { + TLorentzVector cur_iShot = allShotTLVs.at(iShot); - for(unsigned int jShot=iShot+1; jShot<allShotTLVs.size(); jShot++) { - TLorentzVector cur_jShot = allShotTLVs.at(jShot); + for(unsigned int jShot=iShot+1; jShot<allShotTLVs.size(); jShot++) { + TLorentzVector cur_jShot = allShotTLVs.at(jShot); - ATH_MSG_DEBUG("\t\tBuilding di-shot mass of shots " << iShot << " & " << jShot); - TLorentzVector tlv_DiShot = cur_iShot + cur_jShot; - double curDiShotMass = tlv_DiShot.M(); - double curpi0Diff = fabs(curDiShotMass - 134.98); - ATH_MSG_DEBUG("\t\tit is: " << curDiShotMass); - if(curpi0Diff < bestPi0Diff) bestDiShotMass = curDiShotMass; - if(curDiShotMass > maxDiShotMass) maxDiShotMass = curDiShotMass; - if(curDiShotMass < minDiShotMass) minDiShotMass = curDiShotMass; - } - } + ATH_MSG_DEBUG("\t\tBuilding di-shot mass of shots " << iShot << " & " << jShot); + TLorentzVector tlv_DiShot = cur_iShot + cur_jShot; + double curDiShotMass = tlv_DiShot.M(); + double curpi0Diff = fabs(curDiShotMass - 134.98); + ATH_MSG_DEBUG("\t\tit is: " << curDiShotMass); + if(curpi0Diff < bestPi0Diff) bestDiShotMass = curDiShotMass; + if(curDiShotMass > maxDiShotMass) maxDiShotMass = curDiShotMass; + if(curDiShotMass < minDiShotMass) minDiShotMass = curDiShotMass; + } + } - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BestDiShotMass", bestDiShotMass); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MaxDiShotMass", maxDiShotMass); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MinDiShotMass", minDiShotMass); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BestDiShotMass", bestDiShotMass); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MaxDiShotMass", maxDiShotMass); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MinDiShotMass", minDiShotMass); - }//end if check for shot info dumping + }//end if check for shot info dumping - //! Ratios /////////////////////////////////////////// - prefixVARType = m_varTypeName_Ratio; + //! Ratios /////////////////////////////////////////// + prefixVARType = m_varTypeName_Ratio; - if(curTypeName != curTypeName_All) addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtOver", sum_Et, &m_Variants_SeedEt); + if(curTypeName != curTypeName_All) addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtOver", sum_Et, &m_Variants_SeedEt); - if(tlv_1st_Et.Pt() != 0) addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stEtOver", tlv_1st_Et.Et(), &m_Variants_SeedEt); - if(tlv_1st_BDT.Pt() != 0) addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stBDTEtOver", tlv_1st_BDT.Et(), &m_Variants_SeedEt); + if(tlv_1st_Et.Pt() != 0) addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stEtOver", tlv_1st_Et.Et(), &m_Variants_SeedEt); + if(tlv_1st_BDT.Pt() != 0) addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stBDTEtOver", tlv_1st_BDT.Et(), &m_Variants_SeedEt); - if(tlv_Last_Et.Pt() != 0) addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SoftestEtOver", tlv_Last_Et.Et(), &m_Variants_SeedEt); + if(tlv_Last_Et.Pt() != 0) addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SoftestEtOver", tlv_Last_Et.Et(), &m_Variants_SeedEt); - if(tlv_1st_Et.Pt() != 0 && sum_Et > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stEtOverTypeEt", tlv_1st_Et.Et() / sum_Et); - if(tlv_1st_BDT.Pt() != 0 && sum_Et > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stBDTEtOverTypeEt", tlv_1st_BDT.Et() / sum_Et); + if(tlv_1st_Et.Pt() != 0 && sum_Et > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stEtOverTypeEt", tlv_1st_Et.Et() / sum_Et); + if(tlv_1st_BDT.Pt() != 0 && sum_Et > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stBDTEtOverTypeEt", tlv_1st_BDT.Et() / sum_Et); - - - if(n_Constituents_All != 0 && curTypeName != curTypeName_All) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EFOsOverTotalEFOs", (double)(((double)num_EFOs) / ((double)n_Constituents_All))); - if(tlv_1st_Et.Pt() != 0 && tlv_2nd_Et.Pt() != 0) { - if(tlv_1st_Et.Et() > 0. && tlv_2nd_Et.Et() > 0. ) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log1stEtOver2ndEt", TMath::Log10(tlv_1st_Et.Et() / tlv_2nd_Et.Et())); - } + if(n_Constituents_All != 0 && curTypeName != curTypeName_All) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EFOsOverTotalEFOs", (double)(((double)num_EFOs) / ((double)n_Constituents_All))); + if(tlv_1st_Et.Pt() != 0 && tlv_2nd_Et.Pt() != 0) { + if(tlv_1st_Et.Et() > 0. && tlv_2nd_Et.Et() > 0. ) { + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log1stEtOver2ndEt", TMath::Log10(tlv_1st_Et.Et() / tlv_2nd_Et.Et())); } - if(tlv_1st_Et.Pt() != 0 && tlv_3rd_Et.Pt() != 0) { - if(tlv_1st_Et.Et() > 0. && tlv_3rd_Et.Et() > 0.) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log1stEtOver3rdEt", TMath::Log10(tlv_1st_Et.Et() / tlv_3rd_Et.Et())); - } + } + if(tlv_1st_Et.Pt() != 0 && tlv_3rd_Et.Pt() != 0) { + if(tlv_1st_Et.Et() > 0. && tlv_3rd_Et.Et() > 0.) { + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log1stEtOver3rdEt", TMath::Log10(tlv_1st_Et.Et() / tlv_3rd_Et.Et())); } - if(tlv_2nd_Et.Pt() != 0 && tlv_3rd_Et.Pt() != 0) { - if(tlv_2nd_Et.Et() > 0. && tlv_3rd_Et.Et() > 0.) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log2ndEtOver3rdEt", TMath::Log10(tlv_2nd_Et.Et() / tlv_3rd_Et.Et())); - } + } + if(tlv_2nd_Et.Pt() != 0 && tlv_3rd_Et.Pt() != 0) { + if(tlv_2nd_Et.Et() > 0. && tlv_3rd_Et.Et() > 0.) { + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log2ndEtOver3rdEt", TMath::Log10(tlv_2nd_Et.Et() / tlv_3rd_Et.Et())); } + } - //and for the BDT score ordered EFOs - if(tlv_1st_BDT.Pt() != 0 && tlv_2nd_BDT.Pt() != 0) { - if(tlv_1st_BDT.Et() > 0. && tlv_2nd_BDT.Et() > 0. ) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log1stEtOver2ndEt_BDTSort", TMath::Log10(tlv_1st_BDT.Et() / tlv_2nd_BDT.Et())); - } + //and for the BDT score ordered EFOs + if(tlv_1st_BDT.Pt() != 0 && tlv_2nd_BDT.Pt() != 0) { + if(tlv_1st_BDT.Et() > 0. && tlv_2nd_BDT.Et() > 0. ) { + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log1stEtOver2ndEt_BDTSort", TMath::Log10(tlv_1st_BDT.Et() / tlv_2nd_BDT.Et())); } - if(tlv_1st_BDT.Pt() != 0 && tlv_3rd_BDT.Pt() != 0) { - if(tlv_1st_BDT.Et() > 0. && tlv_3rd_BDT.Et() > 0.) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log1stEtOver3rdEt_BDTSort", TMath::Log10(tlv_1st_BDT.Et() / tlv_3rd_BDT.Et())); - } + } + if(tlv_1st_BDT.Pt() != 0 && tlv_3rd_BDT.Pt() != 0) { + if(tlv_1st_BDT.Et() > 0. && tlv_3rd_BDT.Et() > 0.) { + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log1stEtOver3rdEt_BDTSort", TMath::Log10(tlv_1st_BDT.Et() / tlv_3rd_BDT.Et())); } - if(tlv_2nd_BDT.Pt() != 0 && tlv_3rd_BDT.Pt() != 0) { - if(tlv_2nd_BDT.Et() > 0. && tlv_3rd_BDT.Et() > 0.) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log2ndEtOver3rdEt_BDTSort", TMath::Log10(tlv_2nd_BDT.Et() / tlv_3rd_BDT.Et())); - } + } + if(tlv_2nd_BDT.Pt() != 0 && tlv_3rd_BDT.Pt() != 0) { + if(tlv_2nd_BDT.Et() > 0. && tlv_3rd_BDT.Et() > 0.) { + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log2ndEtOver3rdEt_BDTSort", TMath::Log10(tlv_2nd_BDT.Et() / tlv_3rd_BDT.Et())); } + } - //! EtRings /////////////////////////////////////////// - if(curTypeName == curTypeName_All) { - prefixVARType = m_varTypeName_EtInRing; + //! EtRings /////////////////////////////////////////// + if(curTypeName == curTypeName_All) { + prefixVARType = m_varTypeName_EtInRing; - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_00To01", sum_EtInRing00To01); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_01To02", sum_EtInRing01To02); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_02To03", sum_EtInRing02To03); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_03To04", sum_EtInRing03To04); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_04To05", sum_EtInRing04To05); - } + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_00To01", sum_EtInRing00To01); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_01To02", sum_EtInRing01To02); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_02To03", sum_EtInRing02To03); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_03To04", sum_EtInRing03To04); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_04To05", sum_EtInRing04To05); + } - //! Isolations /////////////////////////////////////////// - if(curTypeName == curTypeName_All) { - prefixVARType = m_varTypeName_Isolation; + //! Isolations /////////////////////////////////////////// + if(curTypeName == curTypeName_All) { + prefixVARType = m_varTypeName_Isolation; - double iso_EtIn01 = sum_EtInRing00To01; - double iso_EtIn02 = iso_EtIn01 + sum_EtInRing01To02; - double iso_EtIn03 = iso_EtIn02 + sum_EtInRing02To03; - double iso_EtIn04 = iso_EtIn03 + sum_EtInRing03To04; + double iso_EtIn01 = sum_EtInRing00To01; + double iso_EtIn02 = iso_EtIn01 + sum_EtInRing01To02; + double iso_EtIn03 = iso_EtIn02 + sum_EtInRing02To03; + double iso_EtIn04 = iso_EtIn03 + sum_EtInRing03To04; - addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtIn01Over", iso_EtIn01, &m_Variants_SeedEt); - addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtIn02Over", iso_EtIn02, &m_Variants_SeedEt); - addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtIn03Over", iso_EtIn03, &m_Variants_SeedEt); - addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtIn04Over", iso_EtIn04, &m_Variants_SeedEt); + addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtIn01Over", iso_EtIn01, &m_Variants_SeedEt); + addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtIn02Over", iso_EtIn02, &m_Variants_SeedEt); + addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtIn03Over", iso_EtIn03, &m_Variants_SeedEt); + addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtIn04Over", iso_EtIn04, &m_Variants_SeedEt); - addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtIn00To02Over", (sum_EtInRing00To01 + sum_EtInRing01To02), &m_Variants_SeedEt); - addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtIn02To04Over", (sum_EtInRing02To03 + sum_EtInRing03To04), &m_Variants_SeedEt); + addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtIn00To02Over", (sum_EtInRing00To01 + sum_EtInRing01To02), &m_Variants_SeedEt); + addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtIn02To04Over", (sum_EtInRing02To03 + sum_EtInRing03To04), &m_Variants_SeedEt); - if(iso_EtIn02>0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtIn01OverEtIn02", iso_EtIn01 / iso_EtIn02); - if(iso_EtIn04>0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtIn01OverEtIn04", iso_EtIn01 / iso_EtIn04); - } + if(iso_EtIn02>0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtIn01OverEtIn02", iso_EtIn01 / iso_EtIn02); + if(iso_EtIn04>0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtIn01OverEtIn04", iso_EtIn01 / iso_EtIn04); + } - //! Means /////////////////////////////////////////// - prefixVARType = m_varTypeName_Mean; + //! Means /////////////////////////////////////////// + prefixVARType = m_varTypeName_Mean; - if(num_EFOs > 0) { - addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Et_Wrt", (sum_Et / num_EFOs), &m_Variants_SeedEt); - addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_DRToJetAxis_Wrt", (sum_DRToReference / num_EFOs), &m_Variants_SeedEt); - addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_DRToLeading_Wrt", (sum_DRToLeading / num_EFOs), &m_Variants_SeedEt); - } + if(num_EFOs > 0) { + addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Et_Wrt", (sum_Et / num_EFOs), &m_Variants_SeedEt); + addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_DRToJetAxis_Wrt", (sum_DRToReference / num_EFOs), &m_Variants_SeedEt); + addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_DRToLeading_Wrt", (sum_DRToLeading / num_EFOs), &m_Variants_SeedEt); + } - //! Standard deviations /////////////////////////////////////////// - prefixVARType = m_varTypeName_StdDev; + //! Standard deviations /////////////////////////////////////////// + prefixVARType = m_varTypeName_StdDev; - double stddev_E = m_HelperFunctions.stddev(sum_E2, sum_E, num_EFOs); - double stddev_Et = m_HelperFunctions.stddev(sum_Et2, sum_Et, num_EFOs); - double stddev_DRToJetAxis = m_HelperFunctions.stddev(sum_DR2ToReference, sum_DRToReference, num_EFOs); - double stddev_DRToLeading = m_HelperFunctions.stddev(sum_DRToLeading, sum_DR2ToLeading, num_EFOs); - - if(stddev_E > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_E", stddev_E); - if(stddev_Et > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Et", stddev_Et); - if(stddev_Et > 0.) addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Et_Wrt", stddev_Et, &m_Variants_SeedEt); - if(stddev_DRToJetAxis > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_DRToJetAxis", stddev_DRToJetAxis); - if(stddev_DRToLeading > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_DRToLeading", stddev_DRToLeading); - + double stddev_E = m_HelperFunctions.stddev(sum_E2, sum_E, num_EFOs); + double stddev_Et = m_HelperFunctions.stddev(sum_Et2, sum_Et, num_EFOs); + double stddev_DRToJetAxis = m_HelperFunctions.stddev(sum_DR2ToReference, sum_DRToReference, num_EFOs); + double stddev_DRToLeading = m_HelperFunctions.stddev(sum_DRToLeading, sum_DR2ToLeading, num_EFOs); - //! Angles /////////////////////////////////////////// - prefixVARType = m_varTypeName_Angle; - - double angle_12 = 0; - double angle_13 = 0; - double angle_23 = 0; - - if(curTypeName != curTypeName_All) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_ToJetAxis", tlv_Reference.Angle(tlv_TypeConstituents.Vect())); - if(tlv_1st_Et.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stToJetAxis", tlv_Reference.Angle(tlv_1st_Et.Vect())); - if(tlv_2nd_Et.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndToJetAxis", tlv_Reference.Angle(tlv_2nd_Et.Vect())); - if(tlv_3rd_Et.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_3rdToJetAxis", tlv_Reference.Angle(tlv_3rd_Et.Vect())); - if(tlv_1st_Et.Pt() != 0) { - if(tlv_2nd_Et.Pt() != 0) { - angle_12 = tlv_1st_Et.Angle(tlv_2nd_Et.Vect()); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stTo2nd", angle_12); - } - if(tlv_3rd_Et.Pt() != 0) { - angle_13 = tlv_1st_Et.Angle(tlv_3rd_Et.Vect()); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stTo3rd", angle_13); - } - } - if(tlv_2nd_Et.Pt() != 0 && tlv_3rd_Et.Pt() != 0) { - angle_23 = tlv_2nd_Et.Angle(tlv_3rd_Et.Vect()); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndTo3rd", angle_23); - } - if(num_EFOs > 2 && tlv_1st_Et.Pt() != 0 && tlv_2nd_Et.Pt() != 0 && tlv_3rd_Et.Pt() != 0) { - double angle_Planes = ( tlv_1st_Et.Vect().Cross(tlv_2nd_Et.Vect()) ).Angle( tlv_1st_Et.Vect().Cross(tlv_3rd_Et.Vect()) ); - double angle_max = 0; - if(angle_12 > angle_13) { - if(angle_12 > angle_23) angle_max = angle_12; - else angle_max =angle_23; - } else { - if(angle_13 > angle_23) angle_max =angle_13; - else angle_max =angle_23; - } - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MaxToJetAxis", angle_max); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MeanValue123", (angle_12 + angle_13 + angle_23)/3.); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Btw1213Planes", angle_Planes); + if(stddev_E > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_E", stddev_E); + if(stddev_Et > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Et", stddev_Et); + if(stddev_Et > 0.) addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Et_Wrt", stddev_Et, &m_Variants_SeedEt); + if(stddev_DRToJetAxis > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_DRToJetAxis", stddev_DRToJetAxis); + if(stddev_DRToLeading > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_DRToLeading", stddev_DRToLeading); - } - - - //! DeltaR /////////////////////////////////////////// - prefixVARType = m_varTypeName_DeltaR; - - if(curTypeName != curTypeName_All) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_ToJetAxis", tlv_Reference.DeltaR(tlv_TypeConstituents)); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MaxToJetAxis_EtSort", max_DeltaR); - if(tlv_1st_Et.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stToJetAxis_EtSort", tlv_Reference.DeltaR(tlv_1st_Et)); - if(tlv_2nd_Et.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndToJetAxis_EtSort", tlv_Reference.DeltaR(tlv_2nd_Et)); - if(tlv_3rd_Et.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_3rdToJetAxis_EtSort", tlv_Reference.DeltaR(tlv_3rd_Et)); - if(tlv_1st_Et.Pt() != 0) { - if(tlv_2nd_Et.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stTo2nd_EtSort", tlv_1st_Et.DeltaR(tlv_2nd_Et)); - if(tlv_3rd_Et.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stTo3rd_EtSort", tlv_1st_Et.DeltaR(tlv_3rd_Et)); - } - if(tlv_2nd_Et.Pt() != 0 && tlv_3rd_Et.Pt() != 0) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndTo3rd_EtSort", tlv_2nd_Et.DeltaR(tlv_3rd_Et)); - } - if(tlv_1st_BDT.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stToJetAxis_BDTSort", tlv_Reference.DeltaR(tlv_1st_BDT)); - if(tlv_2nd_BDT.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndToJetAxis_BDTSort", tlv_Reference.DeltaR(tlv_2nd_BDT)); - if(tlv_3rd_BDT.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_3rdToJetAxis_BDTSort", tlv_Reference.DeltaR(tlv_3rd_BDT)); - if(tlv_1st_BDT.Pt() != 0) { - if(tlv_2nd_BDT.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stTo2nd_BDTSort", tlv_1st_BDT.DeltaR(tlv_2nd_BDT)); - if(tlv_3rd_BDT.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stTo3rd_BDTSort", tlv_1st_BDT.DeltaR(tlv_3rd_BDT)); + //! Angles /////////////////////////////////////////// + prefixVARType = m_varTypeName_Angle; + + double angle_12 = 0; + double angle_13 = 0; + double angle_23 = 0; + + if(curTypeName != curTypeName_All) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_ToJetAxis", tlv_Reference.Angle(tlv_TypeConstituents.Vect())); + if(tlv_1st_Et.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stToJetAxis", tlv_Reference.Angle(tlv_1st_Et.Vect())); + if(tlv_2nd_Et.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndToJetAxis", tlv_Reference.Angle(tlv_2nd_Et.Vect())); + if(tlv_3rd_Et.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_3rdToJetAxis", tlv_Reference.Angle(tlv_3rd_Et.Vect())); + if(tlv_1st_Et.Pt() != 0) { + if(tlv_2nd_Et.Pt() != 0) { + angle_12 = tlv_1st_Et.Angle(tlv_2nd_Et.Vect()); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stTo2nd", angle_12); } - if(tlv_2nd_BDT.Pt() != 0 && tlv_3rd_BDT.Pt() != 0) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndTo3rd_BDTSort", tlv_2nd_BDT.DeltaR(tlv_3rd_BDT)); + if(tlv_3rd_Et.Pt() != 0) { + angle_13 = tlv_1st_Et.Angle(tlv_3rd_Et.Vect()); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stTo3rd", angle_13); } - - - //! JetMoment /////////////////////////////////////////// - // Moment wrt X = Sum( Et * X ) / Sum(Et) - // ==> Named as Eflow_EFOType_JetMoment_EtX" when using Et as weight - // ==> Named as Eflow_EFOType_JetMoment_EX" when using E as weight - prefixVARType = m_varTypeName_JetMoment; - - if(sum_Et > 0.) { - //Using transverse energy - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtDR", sum_EtxDR / sum_Et); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtDRprime", sum_EtxDRprime / sum_Et); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtDR2", sum_EtxDR2 / sum_Et); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtAngle", sum_EtxAngle / sum_Et); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtDRxTotalEt", (sum_EtxDR / sum_Et) * m_Variants_SeedEt["EtAllConsts"]); + } + if(tlv_2nd_Et.Pt() != 0 && tlv_3rd_Et.Pt() != 0) { + angle_23 = tlv_2nd_Et.Angle(tlv_3rd_Et.Vect()); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndTo3rd", angle_23); + } + if(num_EFOs > 2 && tlv_1st_Et.Pt() != 0 && tlv_2nd_Et.Pt() != 0 && tlv_3rd_Et.Pt() != 0) { + double angle_Planes = ( tlv_1st_Et.Vect().Cross(tlv_2nd_Et.Vect()) ).Angle( tlv_1st_Et.Vect().Cross(tlv_3rd_Et.Vect()) ); + double angle_max = 0; + if(angle_12 > angle_13) { + if(angle_12 > angle_23) angle_max = angle_12; + else angle_max =angle_23; + } else { + if(angle_13 > angle_23) angle_max =angle_13; + else angle_max =angle_23; } - - - return StatusCode::SUCCESS; + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MaxToJetAxis", angle_max); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MeanValue123", (angle_12 + angle_13 + angle_23)/3.); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Btw1213Planes", angle_Planes); + + } + + + //! DeltaR /////////////////////////////////////////// + prefixVARType = m_varTypeName_DeltaR; + + if(curTypeName != curTypeName_All) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_ToJetAxis", tlv_Reference.DeltaR(tlv_TypeConstituents)); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_MaxToJetAxis_EtSort", max_DeltaR); + if(tlv_1st_Et.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stToJetAxis_EtSort", tlv_Reference.DeltaR(tlv_1st_Et)); + if(tlv_2nd_Et.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndToJetAxis_EtSort", tlv_Reference.DeltaR(tlv_2nd_Et)); + if(tlv_3rd_Et.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_3rdToJetAxis_EtSort", tlv_Reference.DeltaR(tlv_3rd_Et)); + if(tlv_1st_Et.Pt() != 0) { + if(tlv_2nd_Et.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stTo2nd_EtSort", tlv_1st_Et.DeltaR(tlv_2nd_Et)); + if(tlv_3rd_Et.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stTo3rd_EtSort", tlv_1st_Et.DeltaR(tlv_3rd_Et)); + } + if(tlv_2nd_Et.Pt() != 0 && tlv_3rd_Et.Pt() != 0) { + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndTo3rd_EtSort", tlv_2nd_Et.DeltaR(tlv_3rd_Et)); + } + + if(tlv_1st_BDT.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stToJetAxis_BDTSort", tlv_Reference.DeltaR(tlv_1st_BDT)); + if(tlv_2nd_BDT.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndToJetAxis_BDTSort", tlv_Reference.DeltaR(tlv_2nd_BDT)); + if(tlv_3rd_BDT.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_3rdToJetAxis_BDTSort", tlv_Reference.DeltaR(tlv_3rd_BDT)); + if(tlv_1st_BDT.Pt() != 0) { + if(tlv_2nd_BDT.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stTo2nd_BDTSort", tlv_1st_BDT.DeltaR(tlv_2nd_BDT)); + if(tlv_3rd_BDT.Pt() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stTo3rd_BDTSort", tlv_1st_BDT.DeltaR(tlv_3rd_BDT)); + } + if(tlv_2nd_BDT.Pt() != 0 && tlv_3rd_BDT.Pt() != 0) { + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndTo3rd_BDTSort", tlv_2nd_BDT.DeltaR(tlv_3rd_BDT)); + } + + + //! JetMoment /////////////////////////////////////////// + // Moment wrt X = Sum( Et * X ) / Sum(Et) + // ==> Named as Eflow_EFOType_JetMoment_EtX" when using Et as weight + // ==> Named as Eflow_EFOType_JetMoment_EX" when using E as weight + prefixVARType = m_varTypeName_JetMoment; + + if(sum_Et > 0.) { + //Using transverse energy + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtDR", sum_EtxDR / sum_Et); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtDRprime", sum_EtxDRprime / sum_Et); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtDR2", sum_EtxDR2 / sum_Et); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtAngle", sum_EtxAngle / sum_Et); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtDRxTotalEt", (sum_EtxDR / sum_Et) * m_Variants_SeedEt["EtAllConsts"]); + } + + return StatusCode::SUCCESS; } - -StatusCode PanTau::Tool_FeatureExtractor::addCombinedFeatures(PanTau::PanTauSeed2* inSeed) { - - //! ////////////////////////////////////////// - //! Prepare some short notations for variables - //! ////////////////////////////////////////// - PanTau::TauFeature2* tauFeatures = inSeed->getFeatures(); - std::string inputAlgName = inSeed->getNameInputAlgorithm(); - - - //et: EFO Type - int et_Charged = PanTau::TauConstituent2::t_Charged; - int et_Pi0Neut = PanTau::TauConstituent2::t_Pi0Neut; - int et_Neutral = PanTau::TauConstituent2::t_Neutral; - int et_All = PanTau::TauConstituent2::t_NoType; - - bool foundIt; - std::vector<PanTau::TauConstituent2*> list_NeutralConstituents = inSeed->getConstituentsOfType(et_Neutral, foundIt); - - //! ////////////////////////////////////////// - //! Prepare the list of names for EFO Types & - //! the 4 momenta of the different sub systems - //! (ie. charged, neutral subsystem, etc...) - //! ////////////////////////////////////////// - std::string name_EFOType[PanTau::TauConstituent2::t_nTypes]; - double num_EFOs[PanTau::TauConstituent2::t_nTypes]; - TLorentzVector tlv_System[PanTau::TauConstituent2::t_nTypes]; - TLorentzVector tlv_1stEFO[PanTau::TauConstituent2::t_nTypes]; - TLorentzVector tlv_2ndEFO[PanTau::TauConstituent2::t_nTypes]; - - //! ////////////////////////////////////////// - //! get input objects to calc combined features - //! ////////////////////////////////////////// - bool tlv_Sys_OK[PanTau::TauConstituent2::t_nTypes]; - bool tlv_1st_OK[PanTau::TauConstituent2::t_nTypes]; - bool tlv_2nd_OK[PanTau::TauConstituent2::t_nTypes]; - - - //initialize arrays with default values - for(unsigned int iType=0; iType<(unsigned int)PanTau::TauConstituent2::t_nTypes; iType++) { - name_EFOType[iType] = ""; - num_EFOs[iType] = 0.; - tlv_System[iType] = TLorentzVector(); - tlv_1stEFO[iType] = TLorentzVector(); - tlv_2ndEFO[iType] = TLorentzVector(); - tlv_Sys_OK[iType] = false; - tlv_1st_OK[iType] = false; - tlv_2nd_OK[iType] = false; - } +StatusCode PanTau::Tool_FeatureExtractor::addCombinedFeatures(PanTau::PanTauSeed* inSeed) { - for(int iType=0; iType<(int)PanTau::TauConstituent2::t_nTypes; iType++) { - name_EFOType[iType] = PanTau::TauConstituent2::getTypeName((PanTau::TauConstituent2::Type)iType); + //! ////////////////////////////////////////// + //! Prepare some short notations for variables + //! ////////////////////////////////////////// + PanTau::TauFeature* tauFeatures = inSeed->getFeatures(); + std::string inputAlgName = inSeed->getNameInputAlgorithm(); - tlv_System[iType] = inSeed->getSubsystemHLV(iType, tlv_Sys_OK[iType]); - if(tlv_Sys_OK[iType] == false) continue; + //et: EFO Type + int et_Charged = PanTau::TauConstituent::t_Charged; + int et_Pi0Neut = PanTau::TauConstituent::t_Pi0Neut; + int et_Neutral = PanTau::TauConstituent::t_Neutral; + int et_All = PanTau::TauConstituent::t_NoType; + + bool foundIt; + std::vector<PanTau::TauConstituent*> list_NeutralConstituents = inSeed->getConstituentsOfType(et_Neutral, foundIt); + + //! ////////////////////////////////////////// + //! Prepare the list of names for EFO Types & + //! the 4 momenta of the different sub systems + //! (ie. charged, neutral subsystem, etc...) + //! ////////////////////////////////////////// + std::string name_EFOType[PanTau::TauConstituent::t_nTypes]; + double num_EFOs[PanTau::TauConstituent::t_nTypes]; + TLorentzVector tlv_System[PanTau::TauConstituent::t_nTypes]; + TLorentzVector tlv_1stEFO[PanTau::TauConstituent::t_nTypes]; + TLorentzVector tlv_2ndEFO[PanTau::TauConstituent::t_nTypes]; + + //! ////////////////////////////////////////// + //! get input objects to calc combined features + //! ////////////////////////////////////////// + bool tlv_Sys_OK[PanTau::TauConstituent::t_nTypes]; + bool tlv_1st_OK[PanTau::TauConstituent::t_nTypes]; + bool tlv_2nd_OK[PanTau::TauConstituent::t_nTypes]; + + //initialize arrays with default values + for(unsigned int iType=0; iType<(unsigned int)PanTau::TauConstituent::t_nTypes; iType++) { + name_EFOType[iType] = ""; + num_EFOs[iType] = 0.; + tlv_System[iType] = TLorentzVector(); + tlv_1stEFO[iType] = TLorentzVector(); + tlv_2ndEFO[iType] = TLorentzVector(); + tlv_Sys_OK[iType] = false; + tlv_1st_OK[iType] = false; + tlv_2nd_OK[iType] = false; + } + + for(int iType=0; iType<(int)PanTau::TauConstituent::t_nTypes; iType++) { + name_EFOType[iType] = PanTau::TauConstituent::getTypeName((PanTau::TauConstituent::Type)iType); - std::vector<TauConstituent2*> typeConstituents = inSeed->getConstituentsOfType(iType, tlv_Sys_OK[iType]); - if(typeConstituents.size() == 0) tlv_Sys_OK[iType] = false; - if(tlv_Sys_OK[iType] == false) continue; + tlv_System[iType] = inSeed->getSubsystemHLV(iType, tlv_Sys_OK[iType]); + if(tlv_Sys_OK[iType] == false) continue; - num_EFOs[iType] = typeConstituents.size(); + std::vector<TauConstituent*> typeConstituents = inSeed->getConstituentsOfType(iType, tlv_Sys_OK[iType]); + if(typeConstituents.size() == 0) tlv_Sys_OK[iType] = false; + if(tlv_Sys_OK[iType] == false) continue; - if(typeConstituents.size() > 0) { - tlv_1stEFO[iType] = typeConstituents.at(0)->p4(); - tlv_1st_OK[iType] = true; - } else { - tlv_1st_OK[iType] = false; - } + num_EFOs[iType] = typeConstituents.size(); - if(typeConstituents.size() > 1) { - tlv_2ndEFO[iType] = typeConstituents.at(1)->p4(); - tlv_2nd_OK[iType] = true; - } else { - tlv_2nd_OK[iType] = false; - } - - } - - - //! ////////////////////////////////////////// - //! From the extracted input, calc combined features - //! ////////////////////////////////////////// - std::string prefixVARType = m_varTypeName_Combined; - - - //! Combined-Single Features //////////////////////////////////////// - // Ratios of numbers (heavily spiked, just keep them for validation) - if(tlv_Sys_OK[et_Charged] == true && tlv_Sys_OK[et_Neutral] && num_EFOs[et_Neutral] > 0.) { - tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_NumChargedOverNumNeutral", num_EFOs[et_Charged] / num_EFOs[et_Neutral]); + if(typeConstituents.size() > 0) { + tlv_1stEFO[iType] = typeConstituents.at(0)->p4(); + tlv_1st_OK[iType] = true; + } else { + tlv_1st_OK[iType] = false; } - if(tlv_Sys_OK[et_Charged] == true && tlv_Sys_OK[et_All] && num_EFOs[et_All] > 0.) { - tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_NumChargedOverNumTotal", num_EFOs[et_Charged] / num_EFOs[et_All]); + + if(typeConstituents.size() > 1) { + tlv_2ndEFO[iType] = typeConstituents.at(1)->p4(); + tlv_2nd_OK[iType] = true; + } else { + tlv_2nd_OK[iType] = false; } + + } - if(num_EFOs[et_Charged]>0. && num_EFOs[et_Neutral]>1.) { - if(tlv_1st_OK[et_Charged] && tlv_1st_OK[et_Neutral] && tlv_2nd_OK[et_Neutral]) { - TVector3 axis_Plane_cn1 = (tlv_1stEFO[et_Charged].Vect()).Cross( tlv_1stEFO[et_Neutral].Vect() ); - TVector3 axis_Plane_cn2 = (tlv_1stEFO[et_Charged].Vect()).Cross( tlv_2ndEFO[et_Neutral].Vect() ); - double anglePlanes = axis_Plane_cn1.Angle(axis_Plane_cn2); - tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_AnglePlane1stCharged1st2ndNeutral", anglePlanes); - } + // From the extracted input, calc combined features + std::string prefixVARType = m_varTypeName_Combined; + + // Combined-Single Features + // Ratios of numbers (heavily spiked, just keep them for validation) + if(tlv_Sys_OK[et_Charged] == true && tlv_Sys_OK[et_Neutral] && num_EFOs[et_Neutral] > 0.) { + tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_NumChargedOverNumNeutral", num_EFOs[et_Charged] / num_EFOs[et_Neutral]); + } + if(tlv_Sys_OK[et_Charged] == true && tlv_Sys_OK[et_All] && num_EFOs[et_All] > 0.) { + tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_NumChargedOverNumTotal", num_EFOs[et_Charged] / num_EFOs[et_All]); + } + + if(num_EFOs[et_Charged]>0. && num_EFOs[et_Neutral]>1.) { + if(tlv_1st_OK[et_Charged] && tlv_1st_OK[et_Neutral] && tlv_2nd_OK[et_Neutral]) { + TVector3 axis_Plane_cn1 = (tlv_1stEFO[et_Charged].Vect()).Cross( tlv_1stEFO[et_Neutral].Vect() ); + TVector3 axis_Plane_cn2 = (tlv_1stEFO[et_Charged].Vect()).Cross( tlv_2ndEFO[et_Neutral].Vect() ); + double anglePlanes = axis_Plane_cn1.Angle(axis_Plane_cn2); + tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_AnglePlane1stCharged1st2ndNeutral", anglePlanes); } + } - - PanTau::TauConstituent2* tauConst_NeutralLargestAngle = m_HelperFunctions.getNeutralConstWithLargestAngle(tlv_System[et_Charged], - list_NeutralConstituents); - if(tauConst_NeutralLargestAngle != 0) { - TLorentzVector tlv_NeutralLargestAngle = tauConst_NeutralLargestAngle->p4(); + PanTau::TauConstituent* tauConst_NeutralLargestAngle = m_HelperFunctions.getNeutralConstWithLargestAngle(tlv_System[et_Charged], + list_NeutralConstituents); + if(tauConst_NeutralLargestAngle != 0) { + TLorentzVector tlv_NeutralLargestAngle = tauConst_NeutralLargestAngle->p4(); - tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_FarthestNeutral_AngleToCharged", tlv_System[et_Charged].Angle(tlv_NeutralLargestAngle.Vect()) ); - tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_FarthestNeutral_BDTScore", tauConst_NeutralLargestAngle->getBDTValue()); - if(tlv_System[et_Charged].Et() > 0) tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_FarthestNeutral_EtOverChargedEt", tlv_NeutralLargestAngle.Et() / tlv_System[et_Charged].Et()); - } + tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_FarthestNeutral_AngleToCharged", tlv_System[et_Charged].Angle(tlv_NeutralLargestAngle.Vect()) ); + tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_FarthestNeutral_BDTScore", tauConst_NeutralLargestAngle->getBDTValue()); + if(tlv_System[et_Charged].Et() > 0) tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_FarthestNeutral_EtOverChargedEt", tlv_NeutralLargestAngle.Et() / tlv_System[et_Charged].Et()); + } - //! Combined Type-vs-Type Features //////////////////////////////////////// - //Loop over all EFO types... - // for every type, loop over all other types (but neglect permutations, i.e. A,B is the same as B,A) - // calculate ratios, angles etc... + // Combined Type-vs-Type Features + // Loop over all EFO types... + // for every type, loop over all other types (but neglect permutations, i.e. A,B is the same as B,A) + // calculate ratios, angles etc... - for(int iType=0; iType<PanTau::TauConstituent2::t_nTypes; iType++) { + for(int iType=0; iType<PanTau::TauConstituent::t_nTypes; iType++) { - if(iType == (int)PanTau::TauConstituent2::t_NoType) continue; - int type_Denom = iType; + if(iType == (int)PanTau::TauConstituent::t_NoType) continue; + int type_Denom = iType; - for(int jType=0; jType<PanTau::TauConstituent2::t_nTypes; jType++) { - - if(jType == (int)PanTau::TauConstituent2::t_NoType) continue; - int type_Nom = jType; + for(int jType=0; jType<PanTau::TauConstituent::t_nTypes; jType++) { - if(jType == iType) continue; + if(jType == (int)PanTau::TauConstituent::t_NoType) continue; + int type_Nom = jType; - std::string typeName_Nom = PanTau::TauConstituent2::getTypeName((PanTau::TauConstituent2::Type)type_Nom); - std::string typeName_Denom = PanTau::TauConstituent2::getTypeName((PanTau::TauConstituent2::Type)type_Denom); + if(jType == iType) continue; - double sum_Et_Nom = 0.0; - double sum_Et_Denom = 0.0; - if(tlv_Sys_OK[type_Nom] && tlv_Sys_OK[type_Denom]) { - sum_Et_Nom = tlv_System[type_Nom].Et(); - sum_Et_Denom = tlv_System[type_Denom].Et(); - } + std::string typeName_Nom = PanTau::TauConstituent::getTypeName((PanTau::TauConstituent::Type)type_Nom); + std::string typeName_Denom = PanTau::TauConstituent::getTypeName((PanTau::TauConstituent::Type)type_Denom); - //Fraction of leading EFO of system A wrt complete system B - // this is not symmetric wrt system A and B, hence do this for all combinations - if(tlv_1st_OK[type_Nom]) { - double LeadEFO_Et_Nom = tlv_1stEFO[type_Nom].Et(); - if(LeadEFO_Et_Nom > 0. && sum_Et_Denom > 0.) { - tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_Log1st" + typeName_Nom + "EtOver" + typeName_Denom + "Et", TMath::Log10(LeadEFO_Et_Nom / sum_Et_Denom) ); - } - } + double sum_Et_Nom = 0.0; + double sum_Et_Denom = 0.0; + if(tlv_Sys_OK[type_Nom] && tlv_Sys_OK[type_Denom]) { + sum_Et_Nom = tlv_System[type_Nom].Et(); + sum_Et_Denom = tlv_System[type_Denom].Et(); + } - //following features symmetric in system A-B, hence skip multi calculation - if(jType <= iType) continue; + // Fraction of leading EFO of system A wrt complete system B + // this is not symmetric wrt system A and B, hence do this for all combinations + if(tlv_1st_OK[type_Nom]) { + double LeadEFO_Et_Nom = tlv_1stEFO[type_Nom].Et(); + if(LeadEFO_Et_Nom > 0. && sum_Et_Denom > 0.) { + tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_Log1st" + typeName_Nom + "EtOver" + typeName_Denom + "Et", TMath::Log10(LeadEFO_Et_Nom / sum_Et_Denom) ); + } + } - //Energy ratios between systems - if(sum_Et_Denom > 0. && sum_Et_Nom > 0.) { - tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_Log" + typeName_Nom + "EtOver" + typeName_Denom + "Et", TMath::Log10(sum_Et_Nom / sum_Et_Denom) ); - }//end check for div by zero + //following features symmetric in system A-B, hence skip multi calculation + if(jType <= iType) continue; - //Angles between systems - if(tlv_Sys_OK[type_Nom] && tlv_Sys_OK[type_Denom]) { - double angle_system = tlv_System[type_Nom].Angle( tlv_System[type_Denom].Vect() ); - m_HelperFunctions.dumpFourMomentum(tlv_System[type_Nom]); - m_HelperFunctions.dumpFourMomentum(tlv_System[type_Denom]); - tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_Angle" + typeName_Nom + "To" + typeName_Denom, angle_system ); - }//end check for valid system pointer + //Energy ratios between systems + if(sum_Et_Denom > 0. && sum_Et_Nom > 0.) { + tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_Log" + typeName_Nom + "EtOver" + typeName_Denom + "Et", TMath::Log10(sum_Et_Nom / sum_Et_Denom) ); + }//end check for div by zero + //Angles between systems + if(tlv_Sys_OK[type_Nom] && tlv_Sys_OK[type_Denom]) { + double angle_system = tlv_System[type_Nom].Angle( tlv_System[type_Denom].Vect() ); + tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_Angle" + typeName_Nom + "To" + typeName_Denom, angle_system ); + }//end check for valid system pointer + + if(tlv_1st_OK[type_Nom] && tlv_1st_OK[type_Denom]) { + //Delta R between 1st and 1st EFO + double deltaR_1st1st = tlv_1stEFO[type_Nom].DeltaR( tlv_1stEFO[type_Denom] ); + tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_DeltaR1st" + typeName_Nom + "To1st" + typeName_Denom, deltaR_1st1st ); + + //Angles between 1st and 1st EFO + double angle_1st1st = tlv_1stEFO[type_Nom].Angle( tlv_1stEFO[type_Denom].Vect() ); + tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_Angle1st" + typeName_Nom + "To1st" + typeName_Denom, angle_1st1st ); + } //end check for valid leading efo - if(tlv_1st_OK[type_Nom] && tlv_1st_OK[type_Denom]) { - //Delta R between 1st and 1st EFO - double deltaR_1st1st = tlv_1stEFO[type_Nom].DeltaR( tlv_1stEFO[type_Denom] ); - tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_DeltaR1st" + typeName_Nom + "To1st" + typeName_Denom, deltaR_1st1st ); - - //Angles between 1st and 1st EFO - double angle_1st1st = tlv_1stEFO[type_Nom].Angle( tlv_1stEFO[type_Denom].Vect() ); - tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_Angle1st" + typeName_Nom + "To1st" + typeName_Denom, angle_1st1st ); - } //end check for valid leading efo - - }//end loop over system B - }//end loop over system A + }//end loop over system B + }//end loop over system A - //! Combined Selected-Type Features //////////////////////////////////////// + // Combined Selected-Type Features - //setup arrays for combination of selected charged and neutral combinations - const int cTypes = 1; - const int nTypes = 2; - int index_charged[cTypes] = {et_Charged}; - int index_neutral[nTypes] = {et_Pi0Neut, et_Neutral}; - - for(int cType=0; cType<cTypes; cType++) { - for(int nType=0; nType<nTypes; nType++) { + //setup arrays for combination of selected charged and neutral combinations + const int cTypes = 1; + const int nTypes = 2; + int index_charged[cTypes] = {et_Charged}; + int index_neutral[nTypes] = {et_Pi0Neut, et_Neutral}; + + for(int cType=0; cType<cTypes; cType++) { + for(int nType=0; nType<nTypes; nType++) { - int et_c = index_charged[cType]; - int et_n = index_neutral[nType]; + int et_c = index_charged[cType]; + int et_n = index_neutral[nType]; - std::string name_cType = PanTau::TauConstituent2::getTypeName((PanTau::TauConstituent2::Type)et_c); - std::string name_nType = PanTau::TauConstituent2::getTypeName((PanTau::TauConstituent2::Type)et_n); + std::string name_cType = PanTau::TauConstituent::getTypeName((PanTau::TauConstituent::Type)et_c); + std::string name_nType = PanTau::TauConstituent::getTypeName((PanTau::TauConstituent::Type)et_n); - if(tlv_Sys_OK[et_c]==false || tlv_Sys_OK[et_n]==false) continue; + if(tlv_Sys_OK[et_c]==false || tlv_Sys_OK[et_n]==false) continue; - //mean Et fraction of charged+neutral system wrt total ET - if(num_EFOs[et_c] + num_EFOs[et_n] > 0.) { - double mean_cTypenTypeEt = ( tlv_System[et_c].Et() + tlv_System[et_n].Et() ) / (num_EFOs[et_c] + num_EFOs[et_n]); - addFeatureWrtSeedEnergy(tauFeatures, inputAlgName + "_" + prefixVARType + "_Mean" + name_cType + name_nType + "Et_Wrt", mean_cTypenTypeEt, &m_Variants_SeedEt); - } + //mean Et fraction of charged+neutral system wrt total ET + if(num_EFOs[et_c] + num_EFOs[et_n] > 0.) { + double mean_cTypenTypeEt = ( tlv_System[et_c].Et() + tlv_System[et_n].Et() ) / (num_EFOs[et_c] + num_EFOs[et_n]); + addFeatureWrtSeedEnergy(tauFeatures, inputAlgName + "_" + prefixVARType + "_Mean" + name_cType + name_nType + "Et_Wrt", mean_cTypenTypeEt, &m_Variants_SeedEt); + } - //invariant masses - double mass_cTypenType = ( tlv_System[et_c] + tlv_System[et_n] ).M(); - tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_InvMass" + name_cType + name_nType, mass_cTypenType ); + //invariant masses + double mass_cTypenType = ( tlv_System[et_c] + tlv_System[et_n] ).M(); + tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_InvMass" + name_cType + name_nType, mass_cTypenType ); - //angle 1st charged to second neutral - if(tlv_2nd_OK[et_n]) { - //Angles between 1st and 2nd EFO - double angle_1st2nd = tlv_1stEFO[et_c].Angle( tlv_2ndEFO[et_n].Vect() ); - tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_Angle1st2nd" + name_cType + name_nType, angle_1st2nd ); - } //end check for valid 2nd EFOs + //angle 1st charged to second neutral + if(tlv_2nd_OK[et_n]) { + //Angles between 1st and 2nd EFO + double angle_1st2nd = tlv_1stEFO[et_c].Angle( tlv_2ndEFO[et_n].Vect() ); + tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_Angle1st2nd" + name_cType + name_nType, angle_1st2nd ); + } //end check for valid 2nd EFOs - }//end loop neutral types - }//end loop charged types - + }//end loop neutral types + }//end loop charged types - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } - -StatusCode PanTau::Tool_FeatureExtractor::addImpactParameterFeatures(PanTau::PanTauSeed2* inSeed) const { +StatusCode PanTau::Tool_FeatureExtractor::addImpactParameterFeatures(PanTau::PanTauSeed* inSeed) const { - const xAOD::TauJet* tauJet = inSeed->getTauJet(); + const xAOD::TauJet* tauJet = inSeed->getTauJet(); - const xAOD::Vertex* vtx_TauJet = tauJet->vertexLink().cachedElement(); - if(vtx_TauJet == 0) { - ATH_MSG_DEBUG("Trk::RecVertex of taujet (via origin()) points to 0! Not extracting impact parameters"); - return StatusCode::SUCCESS; - } - - PanTau::TauFeature2* tauFeatures = inSeed->getFeatures(); - std::string inputAlgName = inSeed->getNameInputAlgorithm(); - std::string featureNamePrefix = m_varTypeName_ImpactParams; - std::vector<double> impactParameters(0); - std::vector<double> impactParameterSignf(0); - - // get jet direction: - TLorentzVector tlv_Tau; - tlv_Tau.SetPtEtaPhiM(tauJet->ptIntermediateAxis(), tauJet->etaIntermediateAxis(), tauJet->phiIntermediateAxis(), tauJet->mIntermediateAxis()); - TVector3 vec_Tau = tlv_Tau.Vect(); - const TVector3 tauDirection = TVector3(vec_Tau.X(), vec_Tau.Y(), vec_Tau.Z()); - - // get a list of tracks from the inputseed - // NOTE: if we ever have more than one charged type, may want to generalize this part to automagically get IPs from all tracks - bool foundIt; - std::vector<PanTau::TauConstituent2*> list_ChargedConsts = inSeed->getConstituentsOfType(PanTau::TauConstituent2::t_Charged, foundIt); - if(foundIt == false || list_ChargedConsts.size() == 0) return StatusCode::SUCCESS; - std::sort(list_ChargedConsts.begin(), list_ChargedConsts.end(), sortTauConstituentEt); - - std::vector<const xAOD::TrackParticle*> list_Tracks; - for(unsigned int iChrg=0; iChrg<list_ChargedConsts.size(); iChrg++) list_Tracks.push_back( list_ChargedConsts[iChrg]->getPFO()->track(0) ); - - // calculate the transverse impact parameter for the 4 highest momentum tracks - for(unsigned int iTrk=0; iTrk<list_Tracks.size(); iTrk++) { - const xAOD::TrackParticle* curTrack = list_Tracks[iTrk]; + const xAOD::Vertex* vtx_TauJet = tauJet->vertex(); + if(!vtx_TauJet) { + ATH_MSG_DEBUG("Vertex of taujet points to 0! Not extracting impact parameters"); + return StatusCode::SUCCESS; + } + + PanTau::TauFeature* tauFeatures = inSeed->getFeatures(); + std::string inputAlgName = inSeed->getNameInputAlgorithm(); + std::string featureNamePrefix = m_varTypeName_ImpactParams; + std::vector<double> impactParameters(0); + std::vector<double> impactParameterSignf(0); + + // get jet direction: + TLorentzVector tlv_Tau; + tlv_Tau.SetPtEtaPhiM(tauJet->ptIntermediateAxis(), tauJet->etaIntermediateAxis(), tauJet->phiIntermediateAxis(), tauJet->mIntermediateAxis()); + TVector3 vec_Tau = tlv_Tau.Vect(); + TVector3 tauDirection = TVector3(vec_Tau.X(), vec_Tau.Y(), vec_Tau.Z()); + + // get a list of tracks from the inputseed + // NOTE: if we ever have more than one charged type, may want to generalize this part to automagically get IPs from all tracks + bool foundIt; + std::vector<PanTau::TauConstituent*> list_ChargedConsts = inSeed->getConstituentsOfType(PanTau::TauConstituent::t_Charged, foundIt); + if(foundIt == false || list_ChargedConsts.size() == 0) return StatusCode::SUCCESS; + std::sort(list_ChargedConsts.begin(), list_ChargedConsts.end(), sortTauConstituentEt); + + std::vector<const xAOD::TrackParticle*> list_Tracks; + for(unsigned int iChrg=0; iChrg<list_ChargedConsts.size(); iChrg++) list_Tracks.push_back( list_ChargedConsts[iChrg]->getPFO()->track(0) ); + + // calculate the transverse impact parameter for the 4 highest momentum tracks + for(unsigned int iTrk=0; iTrk<list_Tracks.size(); iTrk++) { + const xAOD::TrackParticle* curTrack = list_Tracks[iTrk]; - double recoD0 = curTrack->d0(); - double errD02 = curTrack->definingParametersCovMatrix()(0, 0); - double signfD0 = -999.; - if(errD02 > 0) signfD0 = curTrack->d0() / sqrtf( errD02 ); - - double recoZ0 = curTrack->z0(); - double errZ02 = curTrack->definingParametersCovMatrix()(1, 1); - double signfZ0 = -999.; - if(errZ02 > 0) signfZ0 = curTrack->z0() / sqrtf( errZ02 ); + double recoD0 = curTrack->d0(); + double errD02 = curTrack->definingParametersCovMatrix()(0, 0); + double signfD0 = -999.; + if(errD02 > 0) signfD0 = curTrack->d0() / sqrtf( errD02 ); + + double recoZ0 = curTrack->z0(); + double errZ02 = curTrack->definingParametersCovMatrix()(1, 1); + double signfZ0 = -999.; + if(errZ02 > 0) signfZ0 = curTrack->z0() / sqrtf( errZ02 ); - // add to features - if (iTrk < 4) { - std::string indexTrk = m_HelperFunctions.convertNumberToString(iTrk+1); - tauFeatures->addFeature(inputAlgName + "_" + featureNamePrefix + "_TransIPTrack" + indexTrk + "_SortByEt", recoD0 ); - tauFeatures->addFeature(inputAlgName + "_" + featureNamePrefix + "_LongIPTrack" + indexTrk + "_SortByEt", recoZ0 ); + // add to features + if (iTrk < 4) { + std::string indexTrk = m_HelperFunctions.convertNumberToString(iTrk+1); + tauFeatures->addFeature(inputAlgName + "_" + featureNamePrefix + "_TransIPTrack" + indexTrk + "_SortByEt", recoD0 ); + tauFeatures->addFeature(inputAlgName + "_" + featureNamePrefix + "_LongIPTrack" + indexTrk + "_SortByEt", recoZ0 ); - if(isnan(signfD0) == false) tauFeatures->addFeature(inputAlgName + "_" + featureNamePrefix + "_TransSignfIPTrack" + indexTrk + "_SortByEt", signfD0); - if(isnan(signfZ0) == false) tauFeatures->addFeature(inputAlgName + "_" + featureNamePrefix + "_LongSignfIPTrack" + indexTrk + "_SortByEt", signfZ0); + if(isnan(signfD0) == false) tauFeatures->addFeature(inputAlgName + "_" + featureNamePrefix + "_TransSignfIPTrack" + indexTrk + "_SortByEt", signfD0); + if(isnan(signfZ0) == false) tauFeatures->addFeature(inputAlgName + "_" + featureNamePrefix + "_LongSignfIPTrack" + indexTrk + "_SortByEt", signfZ0); - impactParameters.push_back(fabs(recoD0)); - impactParameterSignf.push_back(fabs(signfD0)); - } + impactParameters.push_back(fabs(recoD0)); + impactParameterSignf.push_back(fabs(signfD0)); + } - }//end loop over tracks + }//end loop over tracks - //sort impact parameters and also store sorted by value - std::sort( impactParameters.begin(), impactParameters.end(), std::greater<double>() ); - std::sort( impactParameterSignf.begin(), impactParameterSignf.end(), std::greater<double>() ); + //sort impact parameters and also store sorted by value + std::sort( impactParameters.begin(), impactParameters.end(), std::greater<double>() ); + std::sort( impactParameterSignf.begin(), impactParameterSignf.end(), std::greater<double>() ); - for(unsigned int iIP=0; iIP<impactParameters.size(); iIP++) { - std::string curNum = m_HelperFunctions.convertNumberToString(iIP+1); - tauFeatures->addFeature(inputAlgName + "_" + featureNamePrefix + "_TransIP" + curNum + "_SortByValue", impactParameters[iIP] ); - tauFeatures->addFeature(inputAlgName + "_" + featureNamePrefix + "_TransSignfIP" + curNum + "_SortByValue", impactParameterSignf[iIP] ); - } + for(unsigned int iIP=0; iIP<impactParameters.size(); iIP++) { + std::string curNum = m_HelperFunctions.convertNumberToString(iIP+1); + tauFeatures->addFeature(inputAlgName + "_" + featureNamePrefix + "_TransIP" + curNum + "_SortByValue", impactParameters[iIP] ); + tauFeatures->addFeature(inputAlgName + "_" + featureNamePrefix + "_TransSignfIP" + curNum + "_SortByValue", impactParameterSignf[iIP] ); + } - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_InformationStore.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_InformationStore.cxx index f2b003fdc950a29510f2480d4a961a4dcb5a8fea..dd85c32762d522006b6b0101072be364bc49d952 100644 --- a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_InformationStore.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_InformationStore.cxx @@ -2,16 +2,12 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -//! PanTau includes #include "PanTauAlgs/Tool_InformationStore.h" -// ROOT includes -#include "TVector2.h" - #define GeV 1000 void PanTau::Tool_InformationStore::ABRDefaultInit(){ - #ifdef XAOD_ANALYSIS +#ifdef XAOD_ANALYSIS // Boolean values MapInt m01 = { @@ -123,85 +119,82 @@ void PanTau::Tool_InformationStore::ABRDefaultInit(){ }; setMapVecString(m05); - #endif +#endif } - -PanTau::Tool_InformationStore::Tool_InformationStore( - const std::string& name ) : - asg::AsgTool(name) +PanTau::Tool_InformationStore::Tool_InformationStore(const std::string& name) : + asg::AsgTool(name) { - - declareProperty("Infos_String", m_Infos_String, "Map with string type infos"); - declareProperty("Infos_VecString", m_Infos_VecString, "Map with vector<string> type infos"); - declareProperty("Infos_Int", m_Infos_Int, "Map with int type infos"); - declareProperty("Infos_Double", m_Infos_Double, "Map with double type infos"); - declareProperty("Infos_VecDouble", m_Infos_VecDouble, "Map with double type infos"); + declareProperty("Infos_String", m_Infos_String, "Map with string type infos"); + declareProperty("Infos_VecString", m_Infos_VecString, "Map with vector<string> type infos"); + declareProperty("Infos_Int", m_Infos_Int, "Map with int type infos"); + declareProperty("Infos_Double", m_Infos_Double, "Map with double type infos"); + declareProperty("Infos_VecDouble", m_Infos_VecDouble, "Map with double type infos"); } PanTau::Tool_InformationStore::~Tool_InformationStore() { } StatusCode PanTau::Tool_InformationStore::initialize() { - ATH_MSG_INFO( name() << " initialize()" ); - m_init=true; + ATH_MSG_INFO( name() << " initialize()" ); + m_init=true; - //This function does nothing in athena - ABRDefaultInit(); + //This function does nothing in athena + ABRDefaultInit(); - ATH_CHECK( this->getInfo_String("Name_TauRecContainer", m_Name_Container_TauRec) ); - ATH_CHECK( this->getInfo_String("Name_TrackParticleContainer", m_Name_Container_Tracks) ); + ATH_CHECK( this->getInfo_String("Name_TauRecContainer", m_Name_Container_TauRec) ); + ATH_CHECK( this->getInfo_String("Name_TrackParticleContainer", m_Name_Container_Tracks) ); - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } -StatusCode PanTau::Tool_InformationStore::getInfo_Int(std::string varName, int& value) { - MapInt::const_iterator it = m_Infos_Int.find(varName); - if(it == m_Infos_Int.end()) { - ATH_MSG_ERROR("getInfo_Int: No integer information called " << varName << " present in InformationStore"); - return StatusCode::FAILURE; - } - value = it->second; - return StatusCode::SUCCESS; +StatusCode PanTau::Tool_InformationStore::getInfo_Int(std::string varName, int& value) { + MapInt::const_iterator it = m_Infos_Int.find(varName); + if(it == m_Infos_Int.end()) { + ATH_MSG_ERROR("getInfo_Int: No integer information called " << varName << " present in InformationStore"); + return StatusCode::FAILURE; + } + value = it->second; + return StatusCode::SUCCESS; } -StatusCode PanTau::Tool_InformationStore::getInfo_Double(std::string varName, double& value) { - MapDouble::const_iterator it = m_Infos_Double.find(varName); - if(it == m_Infos_Double.end()) { - ATH_MSG_ERROR("getInfo_Double: No double information called " << varName << " present in InformationStore"); - return StatusCode::FAILURE; - } - value = it->second; - return StatusCode::SUCCESS; +StatusCode PanTau::Tool_InformationStore::getInfo_Double(std::string varName, double& value) { + MapDouble::const_iterator it = m_Infos_Double.find(varName); + if(it == m_Infos_Double.end()) { + ATH_MSG_ERROR("getInfo_Double: No double information called " << varName << " present in InformationStore"); + return StatusCode::FAILURE; + } + value = it->second; + return StatusCode::SUCCESS; } -StatusCode PanTau::Tool_InformationStore::getInfo_VecDouble(std::string varName, std::vector<double>& value) { - MapVecDouble::const_iterator it = m_Infos_VecDouble.find(varName); - if(it == m_Infos_VecDouble.end()) { - ATH_MSG_ERROR("getInfo_VecDouble: No double information called " << varName << " present in InformationStore"); - return StatusCode::FAILURE; - } - value = it->second; - return StatusCode::SUCCESS; +StatusCode PanTau::Tool_InformationStore::getInfo_VecDouble(std::string varName, std::vector<double>& value) { + MapVecDouble::const_iterator it = m_Infos_VecDouble.find(varName); + if(it == m_Infos_VecDouble.end()) { + ATH_MSG_ERROR("getInfo_VecDouble: No double information called " << varName << " present in InformationStore"); + return StatusCode::FAILURE; + } + value = it->second; + return StatusCode::SUCCESS; } -StatusCode PanTau::Tool_InformationStore::getInfo_String(std::string varName, std::string& value) { - MapString::const_iterator it = m_Infos_String.find(varName); - if(it == m_Infos_String.end()) { - ATH_MSG_ERROR("getInfo_String: No string information called " << varName << " present in InformationStore"); - return StatusCode::FAILURE; - } - value = it->second; - return StatusCode::SUCCESS; +StatusCode PanTau::Tool_InformationStore::getInfo_String(std::string varName, std::string& value) { + MapString::const_iterator it = m_Infos_String.find(varName); + if(it == m_Infos_String.end()) { + ATH_MSG_ERROR("getInfo_String: No string information called " << varName << " present in InformationStore"); + return StatusCode::FAILURE; + } + value = it->second; + return StatusCode::SUCCESS; } -StatusCode PanTau::Tool_InformationStore::getInfo_VecString(std::string varName, std::vector<std::string>& value) { - MapVecString::const_iterator it = m_Infos_VecString.find(varName); - if(it == m_Infos_VecString.end()) { - ATH_MSG_ERROR("getInfo_VecString: No std::string information called " << varName << " present in InformationStore"); - return StatusCode::FAILURE; - } - value = it->second; - return StatusCode::SUCCESS; +StatusCode PanTau::Tool_InformationStore::getInfo_VecString(std::string varName, std::vector<std::string>& value) { + MapVecString::const_iterator it = m_Infos_VecString.find(varName); + if(it == m_Infos_VecString.end()) { + ATH_MSG_ERROR("getInfo_VecString: No std::string information called " << varName << " present in InformationStore"); + return StatusCode::FAILURE; + } + value = it->second; + return StatusCode::SUCCESS; } diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_InputConverter.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_InputConverter.cxx index feea749af5a7efceb54c48ad1c8fdea5eefe3656..0fc9ea228aead779c004eb24189be8d86168a387 100644 --- a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_InputConverter.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_InputConverter.cxx @@ -2,27 +2,22 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ - -//! PanTau includes #include "PanTauAlgs/Tool_InputConverter.h" #include "PanTauAlgs/Tool_InformationStore.h" #include "PanTauAlgs/TauConstituent.h" #include "PanTauAlgs/PanTauSeed.h" #include "PanTauAlgs/HelperFunctions.h" - -//! xAOD EDM #include "xAODTau/TauJet.h" #include "xAODPFlow/PFO.h" #include "xAODPFlow/PFODefs.h" -PanTau::Tool_InputConverter::Tool_InputConverter( - const std::string& name ) : - asg::AsgTool(name), - m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore") +PanTau::Tool_InputConverter::Tool_InputConverter( const std::string& name ) : + asg::AsgTool(name), + m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore") { - declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Link to tool with all information"); - declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName="", "Optional Name for InformationStore insance in ABR"); + declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Link to tool with all information"); + declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName="", "Optional Name for InformationStore insance in ABR"); } PanTau::Tool_InputConverter::~Tool_InputConverter() { @@ -30,182 +25,158 @@ PanTau::Tool_InputConverter::~Tool_InputConverter() { StatusCode PanTau::Tool_InputConverter::initialize() { - ATH_MSG_INFO(" initialize()"); - m_init=true; + ATH_MSG_INFO(" initialize()"); + m_init=true; - ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName) ); //ABR only + ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName) ); //ABR only - ATH_CHECK( m_Tool_InformationStore.retrieve() ); - - ATH_CHECK( m_Tool_InformationStore->getInfo_Int("TauConstituents_UsePionMass", m_Config_UsePionMass) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_Int("TauConstituents_UseShrinkingCone", m_Config_TauConstituents_UseShrinkingCone) ); - - - ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_Types_DeltaRCore", m_Config_TauConstituents_Types_DeltaRCore) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_PreselectionMinEnergy", m_Config_TauConstituents_PreselectionMinEnergy) ); + ATH_CHECK( m_Tool_InformationStore.retrieve() ); - - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_BinEdges_Eta", m_Config_CellBased_BinEdges_Eta) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_EtaBinned_Pi0MVACut_1prong", m_Config_CellBased_EtaBinned_Pi0MVACut_1prong) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_EtaBinned_Pi0MVACut_3prong", m_Config_CellBased_EtaBinned_Pi0MVACut_3prong) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_Int("TauConstituents_UsePionMass", m_Config_UsePionMass) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_Int("TauConstituents_UseShrinkingCone", m_Config_TauConstituents_UseShrinkingCone) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_Types_DeltaRCore", m_Config_TauConstituents_Types_DeltaRCore) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_PreselectionMinEnergy", m_Config_TauConstituents_PreselectionMinEnergy) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_BinEdges_Eta", m_Config_CellBased_BinEdges_Eta) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_EtaBinned_Pi0MVACut_1prong", m_Config_CellBased_EtaBinned_Pi0MVACut_1prong) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_EtaBinned_Pi0MVACut_3prong", m_Config_CellBased_EtaBinned_Pi0MVACut_3prong) ); - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } -bool PanTau::Tool_InputConverter::passesPreselectionEnergy(double itsEnergy) const { - if(itsEnergy < m_Config_TauConstituents_PreselectionMinEnergy) return false; - return true; +bool PanTau::Tool_InputConverter::passesPreselectionEnergy(double itsEnergy) const { + if(itsEnergy < m_Config_TauConstituents_PreselectionMinEnergy) return false; + return true; } - -//! ============================================ -//! PFO converter -//! ============================================ - - -StatusCode PanTau::Tool_InputConverter::ConvertToTauConstituent2(xAOD::PFO* pfo, - PanTau::TauConstituent2* &tauConstituent, - const xAOD::TauJet* tauJet) const { - // - - //! ================================================== - //! check for invalid eta, phi, e "NAN" values: - //! - if(pfo->eta() != pfo->eta()) { - ATH_MSG_WARNING("Will not convert PFO with eta value of " << pfo->eta() << " -> return to Tool_TauConstituentGetter"); - return StatusCode::SUCCESS; - } - if(pfo->phi() != pfo->phi()) { - ATH_MSG_WARNING("Will not convert PFO with phi value of " << pfo->phi() << " -> return to Tool_TauConstituentGetter"); - return StatusCode::SUCCESS; - } - if(pfo->e() != pfo->e()) { - ATH_MSG_WARNING("Will not convert PFO with e value of " << pfo->e() << " -> return to Tool_TauConstituentGetter"); - return StatusCode::SUCCESS; - } - - - //! ================================================== - //! Check whether neutral input pfo has pion mass (it may have if xAOD is being reprocessed) - //! If it does, make it massless again and use that - if(!pfo->isCharged() && pfo->m() != 0) { - TLorentzVector tlvUpdate; - PanTau::SetP4EEtaPhiM( tlvUpdate, pfo->e(), pfo->eta(), pfo->phi(), 0); - pfo->setP4(tlvUpdate.Pt(), pfo->eta(), pfo->phi(), 0); - } - - //! ================================================== - //! preselection to veto very low energetic PFOs: - int pfoCharge = (int)(pfo->charge()); - double constituentEnergy = pfo->e(); - if (passesPreselectionEnergy(constituentEnergy) == false) { - ATH_MSG_DEBUG("EFO of charge " << pfoCharge << " and energy " << constituentEnergy << " does not pass presel Energy cut of " << m_Config_TauConstituents_PreselectionMinEnergy); - return StatusCode::SUCCESS; - } +// PFO converter +StatusCode PanTau::Tool_InputConverter::ConvertToTauConstituent(xAOD::PFO* pfo, + PanTau::TauConstituent* &tauConstituent, + const xAOD::TauJet* tauJet) const { - - //! ================================================== - //! get the mass correct & build 4-vector - double constituentMass = pfo->m(); - if(m_Config_UsePionMass == true) { + // check for invalid eta, phi, e "NAN" values: + if(pfo->eta() != pfo->eta()) { + ATH_MSG_WARNING("Will not convert PFO with eta value of " << pfo->eta() << " -> return to Tool_TauConstituentGetter"); + return StatusCode::SUCCESS; + } + if(pfo->phi() != pfo->phi()) { + ATH_MSG_WARNING("Will not convert PFO with phi value of " << pfo->phi() << " -> return to Tool_TauConstituentGetter"); + return StatusCode::SUCCESS; + } + if(pfo->e() != pfo->e()) { + ATH_MSG_WARNING("Will not convert PFO with e value of " << pfo->e() << " -> return to Tool_TauConstituentGetter"); + return StatusCode::SUCCESS; + } + + // Check whether neutral input pfo has pion mass (it may have if xAOD is being reprocessed) + // If it does, make it massless again and use that + if(!pfo->isCharged() && pfo->m() != 0) { + TLorentzVector tlvUpdate; + PanTau::SetP4EEtaPhiM( tlvUpdate, pfo->e(), pfo->eta(), pfo->phi(), 0); + pfo->setP4(tlvUpdate.Pt(), pfo->eta(), pfo->phi(), 0); + } + + // preselection to veto very low energetic PFOs: + int pfoCharge = (int)(pfo->charge()); + double constituentEnergy = pfo->e(); + if (passesPreselectionEnergy(constituentEnergy) == false) { + ATH_MSG_DEBUG("EFO of charge " << pfoCharge << " and energy " << constituentEnergy << " does not pass presel Energy cut of " << m_Config_TauConstituents_PreselectionMinEnergy); + return StatusCode::SUCCESS; + } - //clusters: don't touch the measured energy. set mass to pion mass, so momentum will be altered - if(!pfo->isCharged()) { - constituentMass = 134.98; - } - } - + // get the mass correct & build 4-vector + double constituentMass = pfo->m(); + if(m_Config_UsePionMass == true) { + + //clusters: don't touch the measured energy. set mass to pion mass, so momentum will be altered + if(!pfo->isCharged()) { + constituentMass = 134.98; + } + } - TLorentzVector momentum; - PanTau::SetP4EEtaPhiM( momentum, constituentEnergy, pfo->eta(), pfo->phi(), constituentMass); + TLorentzVector momentum; + PanTau::SetP4EEtaPhiM( momentum, constituentEnergy, pfo->eta(), pfo->phi(), constituentMass); - //! ================================================== - //! get type (based on charge and DR to tau) - std::vector<int> itsTypeFlags = std::vector<int>((unsigned int)PanTau::TauConstituent2::t_nTypes, 0); - itsTypeFlags.at((int)PanTau::TauConstituent2::t_NoType) = 1; + // get type (based on charge and DR to tau) + std::vector<int> itsTypeFlags = std::vector<int>((unsigned int)PanTau::TauConstituent::t_nTypes, 0); + itsTypeFlags.at((int)PanTau::TauConstituent::t_NoType) = 1; - double mvaValue = PanTau::TauConstituent2::DefaultBDTValue(); + double mvaValue = PanTau::TauConstituent::DefaultBDTValue(); - TLorentzVector tlv_intAxis = tauJet->p4(xAOD::TauJetParameters::IntermediateAxis); - double deltaR_toTauJet = tlv_intAxis.DeltaR( pfo->p4() ); + TLorentzVector tlv_intAxis = tauJet->p4(xAOD::TauJetParameters::IntermediateAxis); + double deltaR_toTauJet = tlv_intAxis.DeltaR( pfo->p4() ); - if(deltaR_toTauJet > m_Config_TauConstituents_Types_DeltaRCore) { - if(pfo->isCharged()) { - itsTypeFlags.at((int)PanTau::TauConstituent2::t_Charged) = 1; - } - if(!pfo->isCharged()) { - itsTypeFlags.at((int)PanTau::TauConstituent2::t_OutNeut) = 1; - mvaValue = pfo->bdtPi0Score(); - } - }//end if pfo is not in core + if(deltaR_toTauJet > m_Config_TauConstituents_Types_DeltaRCore) { + if(pfo->isCharged()) { + itsTypeFlags.at((int)PanTau::TauConstituent::t_Charged) = 1; + } + if(!pfo->isCharged()) { + itsTypeFlags.at((int)PanTau::TauConstituent::t_OutNeut) = 1; + mvaValue = pfo->bdtPi0Score(); + } + }//end if pfo is not in core - if(deltaR_toTauJet <= m_Config_TauConstituents_Types_DeltaRCore) { + if(deltaR_toTauJet <= m_Config_TauConstituents_Types_DeltaRCore) { - if(pfo->isCharged()) { - itsTypeFlags.at((int)PanTau::TauConstituent2::t_Charged) = 1; - } - if(!pfo->isCharged()) { - itsTypeFlags.at((int)PanTau::TauConstituent2::t_Neutral) = 1; - itsTypeFlags.at((int)PanTau::TauConstituent2::t_NeutLowA) = 1; - itsTypeFlags.at((int)PanTau::TauConstituent2::t_NeutLowB) = 1; + if(pfo->isCharged()) { + itsTypeFlags.at((int)PanTau::TauConstituent::t_Charged) = 1; + } + if(!pfo->isCharged()) { + itsTypeFlags.at((int)PanTau::TauConstituent::t_Neutral) = 1; + itsTypeFlags.at((int)PanTau::TauConstituent::t_NeutLowA) = 1; + itsTypeFlags.at((int)PanTau::TauConstituent::t_NeutLowB) = 1; - //neutral PFO arranging --- check for pi0 tag - mvaValue = pfo->bdtPi0Score(); + //neutral PFO arranging --- check for pi0 tag + mvaValue = pfo->bdtPi0Score(); - int nPi0sPerCluster = 0; - if( !pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0sPerCluster) ) { - ATH_MSG_WARNING("WARNING: Could not retrieve nPi0Proto. Will set it to 1."); - nPi0sPerCluster = 1; - } - if(nPi0sPerCluster > 0) itsTypeFlags.at((int)PanTau::TauConstituent2::t_Pi0Neut) = 1; + int nPi0sPerCluster = 0; + if( !pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0sPerCluster) ) { + ATH_MSG_WARNING("WARNING: Could not retrieve nPi0Proto. Will set it to 1."); + nPi0sPerCluster = 1; + } + if(nPi0sPerCluster > 0) itsTypeFlags.at((int)PanTau::TauConstituent::t_Pi0Neut) = 1; - } - }//end if pfo is in core - + } + }//end if pfo is in core - //! ================================================== - //! create the tau constituent - tauConstituent = new PanTau::TauConstituent2(momentum, pfoCharge, itsTypeFlags, mvaValue, pfo); - tauConstituent->makePrivateStore(); + // create the tau constituent + tauConstituent = new PanTau::TauConstituent(momentum, pfoCharge, itsTypeFlags, mvaValue, pfo); + tauConstituent->makePrivateStore(); - //! ================================================== - //! Check if the pfo object has shots: - std::vector<const xAOD::IParticle*> list_TauShots = std::vector<const xAOD::IParticle*>(0); - bool shotsOK = pfo->associatedParticles(xAOD::PFODetails::TauShot, list_TauShots); - if(shotsOK == false) { - ATH_MSG_DEBUG("WARNING: Could not get shots from current pfo"); - } + // Check if the pfo object has shots: + std::vector<const xAOD::IParticle*> list_TauShots = std::vector<const xAOD::IParticle*>(0); + bool shotsOK = pfo->associatedParticles(xAOD::PFODetails::TauShot, list_TauShots); + if(shotsOK == false) { + ATH_MSG_DEBUG("WARNING: Could not get shots from current pfo"); + } - if(list_TauShots.size() > 0) { - for(unsigned int iShot=0; iShot<list_TauShots.size(); iShot++) { + if(list_TauShots.size() > 0) { + for(unsigned int iShot=0; iShot<list_TauShots.size(); iShot++) { - if(list_TauShots.at(iShot) == 0) { - ATH_MSG_WARNING("Shot number " << iShot << " points to 0! Skip it"); - continue; - } + if(list_TauShots.at(iShot) == 0) { + ATH_MSG_WARNING("Shot number " << iShot << " points to 0! Skip it"); + continue; + } - xAOD::PFO* curShot = const_cast<xAOD::PFO*>( dynamic_cast<const xAOD::PFO*>(list_TauShots.at(iShot)) ); - TLorentzVector shotMomentum; - PanTau::SetP4EEtaPhiM( shotMomentum, curShot->e(), curShot->eta(), curShot->phi(), curShot->m()); - std::vector<int> shotTypeFlags = std::vector<int>((unsigned int)PanTau::TauConstituent2::t_nTypes, 0); - double shotMVAValue = PanTau::TauConstituent2::DefaultBDTValue(); - PanTau::TauConstituent2* shotConstituent = new PanTau::TauConstituent2(shotMomentum, 0, itsTypeFlags, shotMVAValue, curShot); - shotConstituent->makePrivateStore(); + xAOD::PFO* curShot = const_cast<xAOD::PFO*>( dynamic_cast<const xAOD::PFO*>(list_TauShots.at(iShot)) ); + TLorentzVector shotMomentum; + PanTau::SetP4EEtaPhiM( shotMomentum, curShot->e(), curShot->eta(), curShot->phi(), curShot->m()); + std::vector<int> shotTypeFlags = std::vector<int>((unsigned int)PanTau::TauConstituent::t_nTypes, 0); + double shotMVAValue = PanTau::TauConstituent::DefaultBDTValue(); + PanTau::TauConstituent* shotConstituent = new PanTau::TauConstituent(shotMomentum, 0, itsTypeFlags, shotMVAValue, curShot); + shotConstituent->makePrivateStore(); - int nPhotons = 0; - if( curShot->attribute(xAOD::PFODetails::tauShots_nPhotons, nPhotons) == false) { - nPhotons = -1; - ATH_MSG_DEBUG("WARNING: Could not get nPhotons for this shot! Set to -1"); - } - shotConstituent->setNPhotonsInShot(nPhotons); - tauConstituent->addShot(shotConstituent); + int nPhotons = 0; + if( curShot->attribute(xAOD::PFODetails::tauShots_nPhotons, nPhotons) == false) { + nPhotons = -1; + ATH_MSG_DEBUG("WARNING: Could not get nPhotons for this shot! Set to -1"); + } + shotConstituent->setNPhotonsInShot(nPhotons); + tauConstituent->addShot(shotConstituent); - }//end loop over shots - } + }//end loop over shots + } - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } - - diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_ModeDiscriminator.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_ModeDiscriminator.cxx index 4842e65c5edcf94246eceaf618c6fa03d6ec05e3..66ab3bfa836afeff72bd6e85880b21ea4cd57170 100644 --- a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_ModeDiscriminator.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_ModeDiscriminator.cxx @@ -2,223 +2,199 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -//! C++ -#include <string> - -//! PanTau includes #include "PanTauAlgs/Tool_ModeDiscriminator.h" #include "PanTauAlgs/Tool_InformationStore.h" #include "PanTauAlgs/TauFeature.h" #include "PanTauAlgs/PanTauSeed.h" #include "PanTauAlgs/HelperFunctions.h" - -//! Root +#include "PathResolver/PathResolver.h" #include "TString.h" #include "TFile.h" #include "TTree.h" -#include "TH1F.h" - -//!Other -#include "PathResolver/PathResolver.h" +#include <string> -PanTau::Tool_ModeDiscriminator::Tool_ModeDiscriminator( - const std::string& name ) : - asg::AsgTool(name), - m_Name_InputAlg("InvalidInputAlg"), - m_Name_ModeCase("InvalidModeCase"), - m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore"), - m_MVABDT_List() +PanTau::Tool_ModeDiscriminator::Tool_ModeDiscriminator(const std::string& name) : + asg::AsgTool(name), + m_Name_InputAlg("InvalidInputAlg"), + m_Name_ModeCase("InvalidModeCase"), + m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore"), + m_MVABDT_List() { - declareProperty("calibFolder", m_calib_path, "Location of calib files in cvmfs");//sync'd with tauRecFlags.tauRecToolsCVMFSPath() - declareProperty("Name_InputAlg", m_Name_InputAlg, "Name of the input algorithm for this instance"); - declareProperty("Name_ModeCase", m_Name_ModeCase, "Name of the two modes to be distinguished for this instance"); - declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Handle to the information store tool"); - declareProperty("Tool_InformationStoreName",m_Tool_InformationStoreName,"Handle to the information store tool"); + declareProperty("calibFolder", m_calib_path, "Location of calib files in cvmfs");//sync'd with tauRecFlags.tauRecToolsCVMFSPath() + declareProperty("Name_InputAlg", m_Name_InputAlg, "Name of the input algorithm for this instance"); + declareProperty("Name_ModeCase", m_Name_ModeCase, "Name of the two modes to be distinguished for this instance"); + declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Handle to the information store tool"); + declareProperty("Tool_InformationStoreName",m_Tool_InformationStoreName,"Handle to the information store tool"); } - PanTau::Tool_ModeDiscriminator::~Tool_ModeDiscriminator() { } - StatusCode PanTau::Tool_ModeDiscriminator::initialize() { - ATH_MSG_DEBUG( name() << " initialize()" ); - m_init=true; + ATH_MSG_DEBUG( name() << " initialize()" ); + m_init=true; - ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) ); + ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) ); - ATH_CHECK(m_Tool_InformationStore.retrieve()); + ATH_CHECK(m_Tool_InformationStore.retrieve()); - //get the required information from the informationstore tool - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("ModeDiscriminator_BinEdges_Pt", m_BinEdges_Pt)); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("ModeDiscriminator_ReaderOption", m_ReaderOption) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_String("ModeDiscriminator_TMVAMethod", m_MethodName) ); + // get the required information from the informationstore tool + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("ModeDiscriminator_BinEdges_Pt", m_BinEdges_Pt)); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("ModeDiscriminator_ReaderOption", m_ReaderOption) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_String("ModeDiscriminator_TMVAMethod", m_MethodName) ); - //build the name of the variable that contains the variable list for this discri tool - std::string varNameList_Prefix = "ModeDiscriminator_BDTVariableNames_"; - std::string varNameList_Full = varNameList_Prefix + m_Name_InputAlg + "_" + m_Name_ModeCase; - ATH_CHECK( m_Tool_InformationStore->getInfo_VecString(varNameList_Full, m_List_BDTVariableNames) ); + // build the name of the variable that contains the variable list for this discri tool + std::string varNameList_Prefix = "ModeDiscriminator_BDTVariableNames_"; + std::string varNameList_Full = varNameList_Prefix + m_Name_InputAlg + "_" + m_Name_ModeCase; + ATH_CHECK( m_Tool_InformationStore->getInfo_VecString(varNameList_Full, m_List_BDTVariableNames) ); - std::string varDefaultValueList_Prefix = "ModeDiscriminator_BDTVariableDefaults_"; - std::string varDefaultValueList_Full = varDefaultValueList_Prefix + m_Name_InputAlg + "_" + m_Name_ModeCase; - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble(varDefaultValueList_Full, m_List_BDTVariableDefaultValues) ); + std::string varDefaultValueList_Prefix = "ModeDiscriminator_BDTVariableDefaults_"; + std::string varDefaultValueList_Full = varDefaultValueList_Prefix + m_Name_InputAlg + "_" + m_Name_ModeCase; + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble(varDefaultValueList_Full, m_List_BDTVariableDefaultValues) ); - //consistency check: - // Number of feature names and feature default values has to match - if( m_List_BDTVariableDefaultValues.size() != m_List_BDTVariableNames.size() ) { - ATH_MSG_ERROR("Number of variable names does not match number of default values! Check jobOptions!"); - return StatusCode::FAILURE; - } - - //! //////////////////////// - //! Create list of BDT variables to link to the reader - - m_List_BDTVariableValues = std::vector<float*>(0); - for(unsigned int iVar=0; iVar<m_List_BDTVariableNames.size(); iVar++) { - m_List_BDTVariableValues.push_back(new float(0)); - } - + // consistency check: + // Number of feature names and feature default values has to match + if( m_List_BDTVariableDefaultValues.size() != m_List_BDTVariableNames.size() ) { + ATH_MSG_ERROR("Number of variable names does not match number of default values! Check jobOptions!"); + return StatusCode::FAILURE; + } - //! //////////////////////// - //! Create reader for each pT Bin + // Create list of BDT variables to link to the reader + m_List_BDTVariableValues = std::vector<float*>(0); + for(unsigned int iVar=0; iVar<m_List_BDTVariableNames.size(); iVar++) { + m_List_BDTVariableValues.push_back(new float(0)); + } - unsigned int nPtBins = m_BinEdges_Pt.size() - 1; // nBins = Edges-1 - for(unsigned int iPtBin=0; iPtBin<nPtBins; iPtBin++) { - - double bin_lowerVal = m_BinEdges_Pt[iPtBin]; - double bin_upperVal = m_BinEdges_Pt[iPtBin+1]; - - std::string bin_lowerStr = m_HelperFunctions.convertNumberToString(bin_lowerVal/1000.); - std::string bin_upperStr = m_HelperFunctions.convertNumberToString(bin_upperVal/1000.); + // Create reader for each pT Bin + unsigned int nPtBins = m_BinEdges_Pt.size() - 1; // nBins = Edges-1 + for(unsigned int iPtBin=0; iPtBin<nPtBins; iPtBin++) { - std::string curPtBin = "ET_" + bin_lowerStr + "_" + bin_upperStr; - std::string curModeCase = m_Name_ModeCase; + double bin_lowerVal = m_BinEdges_Pt[iPtBin]; + double bin_upperVal = m_BinEdges_Pt[iPtBin+1]; + std::string bin_lowerStr = m_HelperFunctions.convertNumberToString(bin_lowerVal/1000.); + std::string bin_upperStr = m_HelperFunctions.convertNumberToString(bin_upperVal/1000.); - //! //////////////////////// - //! weight files - std::string curWeightFile = m_calib_path + (m_calib_path.length() ? "/" : ""); - curWeightFile += "TrainModes_"; - curWeightFile += m_Name_InputAlg + "_"; - curWeightFile += curPtBin + "_"; - curWeightFile += curModeCase + "_"; - curWeightFile += m_MethodName + ".weights.root"; - - std::string resolvedWeightFileName = PathResolverFindCalibFile(curWeightFile); - - if(resolvedWeightFileName == "") { - ATH_MSG_ERROR("Weight file " << curWeightFile << " not found!"); - return StatusCode::FAILURE; - } - - //! //////////////////////// - //! TMVA Readers - - //setup variables for reader - for(unsigned int iVar=0; iVar<m_List_BDTVariableNames.size(); iVar++) { - TString variableNameForReader = "tau_pantauFeature_" + m_Name_InputAlg + "_" + m_List_BDTVariableNames[iVar]; - }//end loop over variables + std::string curPtBin = "ET_" + bin_lowerStr + "_" + bin_upperStr; + std::string curModeCase = m_Name_ModeCase; + + // weight files + std::string curWeightFile = m_calib_path + (m_calib_path.length() ? "/" : ""); + curWeightFile += "TrainModes_"; + curWeightFile += m_Name_InputAlg + "_"; + curWeightFile += curPtBin + "_"; + curWeightFile += curModeCase + "_"; + curWeightFile += m_MethodName + ".weights.root"; + + std::string resolvedWeightFileName = PathResolverFindCalibFile(curWeightFile); + + if(resolvedWeightFileName == "") { + ATH_MSG_ERROR("Weight file " << curWeightFile << " not found!"); + return StatusCode::FAILURE; + } + + // TMVA Readers + //setup variables for reader + for(unsigned int iVar=0; iVar<m_List_BDTVariableNames.size(); iVar++) { + TString variableNameForReader = "tau_pantauFeature_" + m_Name_InputAlg + "_" + m_List_BDTVariableNames[iVar]; + }//end loop over variables - TFile* fBDT = TFile::Open(resolvedWeightFileName.c_str()); - TTree* tBDT = dynamic_cast<TTree*> (fBDT->Get("BDT")); - MVAUtils::BDT* curBDT = new MVAUtils::BDT(tBDT); - curBDT->SetPointers(m_List_BDTVariableValues); + TFile* fBDT = TFile::Open(resolvedWeightFileName.c_str()); + TTree* tBDT = dynamic_cast<TTree*> (fBDT->Get("BDT")); + MVAUtils::BDT* curBDT = new MVAUtils::BDT(tBDT); + curBDT->SetPointers(m_List_BDTVariableValues); - m_MVABDT_List.push_back(curBDT); + m_MVABDT_List.push_back(curBDT); - }//end loop over pt bins to get weight files, reference hists and MVAUtils::BDT objects + }//end loop over pt bins to get weight files, reference hists and MVAUtils::BDT objects - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } - StatusCode PanTau::Tool_ModeDiscriminator::finalize() { - //delete the readers - for(unsigned int iReader=0; iReader<m_MVABDT_List.size(); iReader++) { - MVAUtils::BDT* curBDT = m_MVABDT_List[iReader]; - if(curBDT != 0) delete curBDT; - } - m_MVABDT_List.clear(); - for( float* f : m_List_BDTVariableValues ) delete f; - m_List_BDTVariableValues.clear(); + //delete the readers + for(unsigned int iReader=0; iReader<m_MVABDT_List.size(); iReader++) { + MVAUtils::BDT* curBDT = m_MVABDT_List[iReader]; + if(curBDT != 0) delete curBDT; + } + m_MVABDT_List.clear(); + for( float* f : m_List_BDTVariableValues ) delete f; + m_List_BDTVariableValues.clear(); - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } - -void PanTau::Tool_ModeDiscriminator::updateReaderVariables(PanTau::PanTauSeed2* inSeed) { +void PanTau::Tool_ModeDiscriminator::updateReaderVariables(PanTau::PanTauSeed* inSeed) { - //update features used in MVA with values from current seed - // use default value for feature if it is not present in current seed - //NOTE! This has to be done (even if the seed pt is bad) otherwise problems with details storage - // [If this for loop is skipped, it is not guaranteed that all details are set to their proper default value] - PanTau::TauFeature2* seedFeatures = inSeed->getFeatures(); + //update features used in MVA with values from current seed + // use default value for feature if it is not present in current seed + //NOTE! This has to be done (even if the seed pt is bad) otherwise problems with details storage + // [If this for loop is skipped, it is not guaranteed that all details are set to their proper default value] + PanTau::TauFeature* seedFeatures = inSeed->getFeatures(); - for(unsigned int iVar=0; iVar<m_List_BDTVariableNames.size(); iVar++) { - std::string curVar = m_Name_InputAlg + "_" + m_List_BDTVariableNames[iVar]; + for(unsigned int iVar=0; iVar<m_List_BDTVariableNames.size(); iVar++) { + std::string curVar = m_Name_InputAlg + "_" + m_List_BDTVariableNames[iVar]; - bool isValid; - double newValue = seedFeatures->value(curVar, isValid); - if(isValid == false) { - ATH_MSG_DEBUG("\tUse default value as the feature (the one below this line) was not calculated"); - newValue = m_List_BDTVariableDefaultValues[iVar]; - //add this feature with its default value for the details later - seedFeatures->addFeature(curVar, newValue); - } + bool isValid; + double newValue = seedFeatures->value(curVar, isValid); + if(isValid == false) { + ATH_MSG_DEBUG("\tUse default value as the feature (the one below this line) was not calculated"); + newValue = m_List_BDTVariableDefaultValues[iVar]; + //add this feature with its default value for the details later + seedFeatures->addFeature(curVar, newValue); + } - *(m_List_BDTVariableValues[iVar]) = (float)newValue; - }//end loop over BDT vars for update + *(m_List_BDTVariableValues[iVar]) = (float)newValue; + }//end loop over BDT vars for update - return; + return; } - -double PanTau::Tool_ModeDiscriminator::getResponse(PanTau::PanTauSeed2* inSeed, bool& isOK) { +double PanTau::Tool_ModeDiscriminator::getResponse(PanTau::PanTauSeed* inSeed, bool& isOK) { - updateReaderVariables(inSeed); - - if(inSeed->isOfTechnicalQuality(PanTau::PanTauSeed2::t_BadPtValue) == true) { - ATH_MSG_DEBUG("WARNING Seed has bad pt value! " << inSeed->getTauJet()->pt() << " MeV"); - isOK = false; - return -2; - } + updateReaderVariables(inSeed); - //get the pt bin of input Seed - //NOTE: could be moved to decay mode determinator tool... - double seedPt = inSeed->p4().Pt(); - int ptBin = -1; - for(unsigned int iPtBin=0; iPtBin<m_BinEdges_Pt.size()-1; iPtBin++) { - if(seedPt > m_BinEdges_Pt[iPtBin] && seedPt < m_BinEdges_Pt[iPtBin+1]) { - ptBin = iPtBin; - break; - } - } - if(ptBin == -1) { - ATH_MSG_WARNING("Could not find ptBin for tau seed with pt " << seedPt); - isOK = false; - return -2.; - } + if(inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_BadPtValue) == true) { + ATH_MSG_DEBUG("WARNING Seed has bad pt value! " << inSeed->getTauJet()->pt() << " MeV"); + isOK = false; + return -2; + } - //get mva response - MVAUtils::BDT* curBDT = m_MVABDT_List[ptBin]; - if(curBDT == 0) { - ATH_MSG_ERROR("MVAUtils::BDT object for current tau seed points to 0"); - isOK = false; - return -2.; + //get the pt bin of input Seed + //NOTE: could be moved to decay mode determinator tool... + double seedPt = inSeed->p4().Pt(); + int ptBin = -1; + for(unsigned int iPtBin=0; iPtBin<m_BinEdges_Pt.size()-1; iPtBin++) { + if(seedPt > m_BinEdges_Pt[iPtBin] && seedPt < m_BinEdges_Pt[iPtBin+1]) { + ptBin = iPtBin; + break; } - - double mvaResponse = curBDT->GetGradBoostMVA(m_List_BDTVariableValues); - ATH_MSG_DEBUG("MVA response from " << m_MethodName << " in " << m_Name_ModeCase << " is " << mvaResponse); - - isOK = true; - return mvaResponse; + } + if(ptBin == -1) { + ATH_MSG_WARNING("Could not find ptBin for tau seed with pt " << seedPt); + isOK = false; + return -2.; + } + + //get mva response + MVAUtils::BDT* curBDT = m_MVABDT_List[ptBin]; + if(curBDT == 0) { + ATH_MSG_ERROR("MVAUtils::BDT object for current tau seed points to 0"); + isOK = false; + return -2.; + } + + double mvaResponse = curBDT->GetGradBoostMVA(m_List_BDTVariableValues); + + isOK = true; + return mvaResponse; } diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_TauConstituentGetter.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_TauConstituentGetter.cxx index 417d0c03b2e8b832f159c7241ca6247373c1bf35..66fe41ae02d74d8528e0d66b841f661d3b674b30 100644 --- a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_TauConstituentGetter.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_TauConstituentGetter.cxx @@ -2,32 +2,23 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ - -//! PanTau includes #include "PanTauAlgs/Tool_TauConstituentGetter.h" - #include "PanTauAlgs/TauConstituent.h" #include "PanTauAlgs/HelperFunctions.h" #include "PanTauAlgs/Tool_InformationStore.h" #include "PanTauAlgs/Tool_InputConverter.h" - -//! xAOD EDM #include "xAODTau/TauJet.h" #include "xAODPFlow/PFO.h" -#include "xAODTracking/Vertex.h" - - -PanTau::Tool_TauConstituentGetter::Tool_TauConstituentGetter( - const std::string& name ) : - asg::AsgTool(name), - m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore"), - m_Tool_InputConverter("PanTau::Tool_InputConverter/Tool_InputConverter", this) +PanTau::Tool_TauConstituentGetter::Tool_TauConstituentGetter(const std::string& name) : + asg::AsgTool(name), + m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore"), + m_Tool_InputConverter("PanTau::Tool_InputConverter/Tool_InputConverter", this) { - declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Link to tool with all information"); - declareProperty("Tool_InputConverter", m_Tool_InputConverter, "Link to tool to convert into TauConstituents"); - declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName, "Link to tool with all information"); - declareProperty("Tool_InputConverterName", m_Tool_InputConverterName, "Link to tool to convert into TauConstituents"); + declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Link to tool with all information"); + declareProperty("Tool_InputConverter", m_Tool_InputConverter, "Link to tool to convert into TauConstituents"); + declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName, "Link to tool with all information"); + declareProperty("Tool_InputConverterName", m_Tool_InputConverterName, "Link to tool to convert into TauConstituents"); } PanTau::Tool_TauConstituentGetter::~Tool_TauConstituentGetter() { @@ -35,96 +26,70 @@ PanTau::Tool_TauConstituentGetter::~Tool_TauConstituentGetter() { StatusCode PanTau::Tool_TauConstituentGetter::initialize() { - ATH_MSG_INFO(" initialize()"); - m_init=true; + ATH_MSG_INFO(" initialize()"); + m_init=true; - ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) ); - ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InputConverter, m_Tool_InputConverterName ) ); + ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) ); + ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InputConverter, m_Tool_InputConverterName ) ); - ATH_CHECK( m_Tool_InformationStore.retrieve() ); - ATH_CHECK( m_Tool_InputConverter.retrieve() ); + ATH_CHECK( m_Tool_InformationStore.retrieve() ); + ATH_CHECK( m_Tool_InputConverter.retrieve() ); - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } /** -* Function to get the PFOs for a given TauJet object (Shots in each PFO etc are collected in "ConvertToTauConstituent") -*/ + * Function to get the PFOs for a given TauJet object (Shots in each PFO etc are collected in "ConvertToTauConstituent") + */ StatusCode PanTau::Tool_TauConstituentGetter::GetTauConstituents(const xAOD::TauJet* tauJet, - std::vector<TauConstituent2*>& outputConstituents, + std::vector<TauConstituent*>& outputConstituents, std::string algName) const { - bool inputAlgIsValid = false; - // extend this if-statement once Pantau has been validated for other algs: - if(algName == "CellBased") inputAlgIsValid = true; - if(inputAlgIsValid == false) { - ATH_MSG_WARNING("Unknown input algorithm: " << algName << " -> Pantau BDT Training not done for this algorithm!"); - return StatusCode::FAILURE; - } + if(algName != "CellBased") { + ATH_MSG_WARNING("Unknown input algorithm: " << algName << " -> Pantau BDT Training not done for this algorithm!"); + return StatusCode::FAILURE; + } - //loop over charged PFOs - unsigned int nChargedPFO = 0; - nChargedPFO = tauJet->nProtoChargedPFOs(); - - for(unsigned int iChrgPFO=0; iChrgPFO<nChargedPFO; iChrgPFO++) { - xAOD::PFO* curChrgPFO = 0; - curChrgPFO = const_cast<xAOD::PFO*>(tauJet->protoChargedPFO( iChrgPFO )); - - //convert to tau constituent - PanTau::TauConstituent2* curConst = 0; - ATH_CHECK(m_Tool_InputConverter->ConvertToTauConstituent2(curChrgPFO, curConst, tauJet) ); - if(curConst == 0) { - ATH_MSG_DEBUG("Problems converting charged PFO into tau constituent -> skip PFO"); - continue; - } - - TLorentzVector v=curConst->p4(); + //loop over charged PFOs + unsigned int nChargedPFO = tauJet->nProtoChargedPFOs(); + + for(unsigned int iChrgPFO=0; iChrgPFO<nChargedPFO; iChrgPFO++) { + xAOD::PFO* curChrgPFO = const_cast<xAOD::PFO*>(tauJet->protoChargedPFO( iChrgPFO )); + + //convert to tau constituent + PanTau::TauConstituent* curConst = nullptr; + ATH_CHECK(m_Tool_InputConverter->ConvertToTauConstituent(curChrgPFO, curConst, tauJet) ); + if(curConst == 0) { + ATH_MSG_DEBUG("Problems converting charged PFO into tau constituent -> skip PFO"); + continue; + } - //add to list of tau constituents - m_HelperFunctions.dumpTauConstituent2(curConst); - outputConstituents.push_back(curConst); + //add to list of tau constituents + outputConstituents.push_back(curConst); - }//end loop over charged PFOs - + }//end loop over charged PFOs + + // Pi0 tagged PFOs are not collected! - // Pi0 tagged PFOs are not collected! + //loop over neutral PFOs + unsigned int nNeutPFO = tauJet->nProtoNeutralPFOs(); - //loop over neutral PFOs - unsigned int nNeutPFO = 0; - nNeutPFO = tauJet->nProtoNeutralPFOs(); - - for(unsigned int iNeutPFO=0; iNeutPFO<nNeutPFO; iNeutPFO++) { - xAOD::PFO* curNeutPFO = 0; - curNeutPFO = const_cast<xAOD::PFO*>(tauJet->protoNeutralPFO( iNeutPFO )); + for(unsigned int iNeutPFO=0; iNeutPFO<nNeutPFO; iNeutPFO++) { + xAOD::PFO* curNeutPFO = const_cast<xAOD::PFO*>(tauJet->protoNeutralPFO( iNeutPFO )); - //convert to tau constituent - PanTau::TauConstituent2* curConst = 0; - ATH_CHECK( m_Tool_InputConverter->ConvertToTauConstituent2(curNeutPFO, curConst, tauJet) ); - if(curConst == 0) { - ATH_MSG_DEBUG("Problems converting neutral PFO into tau constituent -> skip PFO"); - continue; - } + //convert to tau constituent + PanTau::TauConstituent* curConst = nullptr; + ATH_CHECK( m_Tool_InputConverter->ConvertToTauConstituent(curNeutPFO, curConst, tauJet) ); + if(curConst == 0) { + ATH_MSG_DEBUG("Problems converting neutral PFO into tau constituent -> skip PFO"); + continue; + } - //add to list of tau constituents - m_HelperFunctions.dumpTauConstituent2(curConst); - outputConstituents.push_back(curConst); + //add to list of tau constituents + outputConstituents.push_back(curConst); - }//end loop over charged PFOs - - - return StatusCode::SUCCESS; - -}//end PFO getter - - - - - - - - - - - - + }//end loop over charged PFOs + + return StatusCode::SUCCESS; +} diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_TauConstituentSelector.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_TauConstituentSelector.cxx index 1da2fdceff1db9b5b15f5911271bfec5acdc30e2..4486a4b7731bd8307bda24acd7db304784f7c3d0 100644 --- a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_TauConstituentSelector.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_TauConstituentSelector.cxx @@ -2,238 +2,219 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ - -//! PanTau includes #include "PanTauAlgs/Tool_TauConstituentSelector.h" - #include "PanTauAlgs/TauConstituent.h" #include "PanTauAlgs/HelperFunctions.h" #include "PanTauAlgs/Tool_InformationStore.h" -#include <math.h> - -PanTau::Tool_TauConstituentSelector::Tool_TauConstituentSelector( - const std::string& name ) : - asg::AsgTool(name), - m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore") +PanTau::Tool_TauConstituentSelector::Tool_TauConstituentSelector(const std::string& name) : + asg::AsgTool(name), + m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore") { - declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Link to tool with all information"); - declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName, "Link to tool with all information"); + declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Link to tool with all information"); + declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName, "Link to tool with all information"); } + PanTau::Tool_TauConstituentSelector::~Tool_TauConstituentSelector() { } + StatusCode PanTau::Tool_TauConstituentSelector::initialize() { - ATH_MSG_INFO(" initialize()"); - m_init=true; - - ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) ); - ATH_CHECK( m_Tool_InformationStore.retrieve() ); + ATH_MSG_INFO(" initialize()"); + m_init=true; - ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_MaxEta", m_MaxEta) ); + ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) ); + ATH_CHECK( m_Tool_InformationStore.retrieve() ); - //eta bin edges - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_BinEdges_Eta", m_BinEdges_Eta) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_MaxEta", m_MaxEta) ); - //et cuts for types used in mode reco - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_Neutral_EtaBinned_EtCut", m_Selection_Neutral_EtaBinned_EtCut) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_Pi0Neut_EtaBinned_EtCut", m_Selection_Pi0Neut_EtaBinned_EtCut) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_Charged_EtaBinned_EtCut", m_Selection_Charged_EtaBinned_EtCut) ); + //eta bin edges + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_BinEdges_Eta", m_BinEdges_Eta) ); - //et cuts for types interesting for jet rej. - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_OutNeut_EtaBinned_EtCut", m_Selection_OutNeut_EtaBinned_EtCut) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_OutChrg_EtaBinned_EtCut", m_Selection_OutChrg_EtaBinned_EtCut) ); + //et cuts for types used in mode reco + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_Neutral_EtaBinned_EtCut", m_Selection_Neutral_EtaBinned_EtCut) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_Pi0Neut_EtaBinned_EtCut", m_Selection_Pi0Neut_EtaBinned_EtCut) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_Charged_EtaBinned_EtCut", m_Selection_Charged_EtaBinned_EtCut) ); - //et cuts for neutral test types with lower et cuts - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_NeutLowA_EtaBinned_EtCut", m_Selection_NeutLowA_EtaBinned_EtCut) ); - ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_NeutLowB_EtaBinned_EtCut", m_Selection_NeutLowB_EtaBinned_EtCut) ); + //et cuts for types interesting for jet rej. + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_OutNeut_EtaBinned_EtCut", m_Selection_OutNeut_EtaBinned_EtCut) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_OutChrg_EtaBinned_EtCut", m_Selection_OutChrg_EtaBinned_EtCut) ); + //et cuts for neutral test types with lower et cuts + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_NeutLowA_EtaBinned_EtCut", m_Selection_NeutLowA_EtaBinned_EtCut) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_NeutLowB_EtaBinned_EtCut", m_Selection_NeutLowB_EtaBinned_EtCut) ); - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } -double PanTau::Tool_TauConstituentSelector::getEtCut(double eta, PanTau::TauConstituent2::Type constituentType) const { - - for(unsigned int iEtaBin=0; iEtaBin<m_BinEdges_Eta.size()-1; iEtaBin++) { - if(m_BinEdges_Eta[iEtaBin] <= eta && eta < m_BinEdges_Eta[iEtaBin+1]) { - switch(constituentType) { - case PanTau::TauConstituent2::t_Charged: return m_Selection_Charged_EtaBinned_EtCut[iEtaBin]; - case PanTau::TauConstituent2::t_Neutral: return m_Selection_Neutral_EtaBinned_EtCut[iEtaBin]; - case PanTau::TauConstituent2::t_Pi0Neut: return m_Selection_Pi0Neut_EtaBinned_EtCut[iEtaBin]; - case PanTau::TauConstituent2::t_OutNeut: return m_Selection_OutNeut_EtaBinned_EtCut[iEtaBin]; - case PanTau::TauConstituent2::t_OutChrg: return m_Selection_OutChrg_EtaBinned_EtCut[iEtaBin]; - case PanTau::TauConstituent2::t_NeutLowA: return m_Selection_NeutLowA_EtaBinned_EtCut[iEtaBin]; - case PanTau::TauConstituent2::t_NeutLowB: return m_Selection_NeutLowB_EtaBinned_EtCut[iEtaBin]; - default: - return 9999999.; - } - } +double PanTau::Tool_TauConstituentSelector::getEtCut(double eta, PanTau::TauConstituent::Type constituentType) const { + + for(unsigned int iEtaBin=0; iEtaBin<m_BinEdges_Eta.size()-1; iEtaBin++) { + if(m_BinEdges_Eta[iEtaBin] <= eta && eta < m_BinEdges_Eta[iEtaBin+1]) { + switch(constituentType) { + case PanTau::TauConstituent::t_Charged: return m_Selection_Charged_EtaBinned_EtCut[iEtaBin]; + case PanTau::TauConstituent::t_Neutral: return m_Selection_Neutral_EtaBinned_EtCut[iEtaBin]; + case PanTau::TauConstituent::t_Pi0Neut: return m_Selection_Pi0Neut_EtaBinned_EtCut[iEtaBin]; + case PanTau::TauConstituent::t_OutNeut: return m_Selection_OutNeut_EtaBinned_EtCut[iEtaBin]; + case PanTau::TauConstituent::t_OutChrg: return m_Selection_OutChrg_EtaBinned_EtCut[iEtaBin]; + case PanTau::TauConstituent::t_NeutLowA: return m_Selection_NeutLowA_EtaBinned_EtCut[iEtaBin]; + case PanTau::TauConstituent::t_NeutLowB: return m_Selection_NeutLowB_EtaBinned_EtCut[iEtaBin]; + default: + return 9999999.; + } } + } - ATH_MSG_WARNING("Eta value of " << eta << " could not be matched to any eta bin!"); - return 9999999.; + ATH_MSG_WARNING("Eta value of " << eta << " could not be matched to any eta bin!"); + return 9999999.; } - /** -* Function to further select PFOs of the various categories (basically apply additional ET cuts): -* -*/ -StatusCode PanTau::Tool_TauConstituentSelector::SelectTauConstituents( std::vector<TauConstituent2*> inputList, - std::vector<TauConstituent2*>& outputList) const { - - unsigned int nConst = inputList.size(); + * Function to further select PFOs of the various categories (basically apply additional ET cuts): + * + */ +StatusCode PanTau::Tool_TauConstituentSelector::SelectTauConstituents(std::vector<TauConstituent*> inputList, + std::vector<TauConstituent*>& outputList) const { + unsigned int nConst = inputList.size(); - for(unsigned int iConst=0; iConst<nConst; iConst++) { + for(unsigned int iConst=0; iConst<nConst; iConst++) { - PanTau::TauConstituent2* curConstituent = inputList[iConst]; + PanTau::TauConstituent* curConstituent = inputList[iConst]; - //general preselection: - double curEta = fabs( curConstituent->p4().Eta() ); - if(curEta > m_MaxEta) { - ATH_MSG_DEBUG("\tNot using constituent with eta of " << curEta); - continue; - } + //general preselection: + double curEta = std::abs( curConstituent->p4().Eta() ); + if(curEta > m_MaxEta) { + ATH_MSG_DEBUG("\tNot using constituent with eta of " << curEta); + continue; + } - bool passesSelection = false; + bool passesSelection = false; - // check if constituent is charged: - if(curConstituent->isOfType(PanTau::TauConstituent2::t_Charged) == true) { - passesSelection = passesSelection_ChargedConstituent(curConstituent); + // check if constituent is charged: + if(curConstituent->isOfType(PanTau::TauConstituent::t_Charged) == true) { + passesSelection = passesSelection_ChargedConstituent(curConstituent); - // check if constituent is neutral, assign correctly pi0neut and neut flags: - } else if(curConstituent->isOfType(PanTau::TauConstituent2::t_Neutral) == true) { - passesSelection = passesSelection_NeutralConstituent(curConstituent); + // check if constituent is neutral, assign correctly pi0neut and neut flags: + } else if(curConstituent->isOfType(PanTau::TauConstituent::t_Neutral) == true) { + passesSelection = passesSelection_NeutralConstituent(curConstituent); - //special treatment for the testing neutral flags - // a constituent can be a NeutLowA but not a neutral (because neutral Et cut is higher) - // => need that the constituent is in the seed for calculating test variables, but need it to NOT be tagged as neutral - // => remove the neutral-tag and check if it passes NeutLowA - //-> repeat those steps for NeutLowB - if(passesSelection == false) { - curConstituent->removeTypeFlag(PanTau::TauConstituent2::t_Neutral); - curConstituent->removeTypeFlag(PanTau::TauConstituent2::t_Pi0Neut); - passesSelection = passesSelection_NeutLowAConstituent(curConstituent); - if(passesSelection == false) { - curConstituent->removeTypeFlag(PanTau::TauConstituent2::t_NeutLowA); - passesSelection = passesSelection_NeutLowBConstituent(curConstituent); - } - } - - - // apply further selection to constituent in isolation cone: - } else if(curConstituent->isOfType(PanTau::TauConstituent2::t_OutChrg) == true) { - passesSelection = passesSelection_OutChrgConstituent(curConstituent); + //special treatment for the testing neutral flags + // a constituent can be a NeutLowA but not a neutral (because neutral Et cut is higher) + // => need that the constituent is in the seed for calculating test variables, but need it to NOT be tagged as neutral + // => remove the neutral-tag and check if it passes NeutLowA + //-> repeat those steps for NeutLowB + if(passesSelection == false) { + curConstituent->removeTypeFlag(PanTau::TauConstituent::t_Neutral); + curConstituent->removeTypeFlag(PanTau::TauConstituent::t_Pi0Neut); + passesSelection = passesSelection_NeutLowAConstituent(curConstituent); + if(passesSelection == false) { + curConstituent->removeTypeFlag(PanTau::TauConstituent::t_NeutLowA); + passesSelection = passesSelection_NeutLowBConstituent(curConstituent); + } + } + // apply further selection to constituent in isolation cone: + } else if(curConstituent->isOfType(PanTau::TauConstituent::t_OutChrg) == true) { + passesSelection = passesSelection_OutChrgConstituent(curConstituent); - } else if(curConstituent->isOfType(PanTau::TauConstituent2::t_OutNeut) == true) { - passesSelection = passesSelection_OutNeutConstituent(curConstituent); + } else if(curConstituent->isOfType(PanTau::TauConstituent::t_OutNeut) == true) { + passesSelection = passesSelection_OutNeutConstituent(curConstituent); - } else { - ATH_MSG_WARNING("Unhandled constituent type (" << curConstituent->getTypeNameString() << ") when trying to apply constituent selection - constituent will not be selected!"); - passesSelection = false; - } + } else { + ATH_MSG_WARNING("Unhandled constituent type (" << curConstituent->getTypeNameString() + << ") when trying to apply constituent selection - constituent will not be selected!"); + passesSelection = false; + } - if(passesSelection == false) continue; + if(passesSelection == false) continue; - outputList.push_back(inputList[iConst]); - } + outputList.push_back(inputList[iConst]); + } - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } +bool PanTau::Tool_TauConstituentSelector::passesSelection_NeutralConstituent(PanTau::TauConstituent* tauConstituent) const { -bool PanTau::Tool_TauConstituentSelector::passesSelection_NeutralConstituent(PanTau::TauConstituent2* tauConstituent) const { - - TLorentzVector tlv_Constituent = tauConstituent->p4(); + TLorentzVector tlv_Constituent = tauConstituent->p4(); - double curEta = tlv_Constituent.Eta(); - double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_Neutral); - double curEt = tlv_Constituent.Et(); + double curEta = tlv_Constituent.Eta(); + double cut_MinEt = getEtCut(std::abs(curEta), PanTau::TauConstituent::t_Neutral); + double curEt = tlv_Constituent.Et(); - if(curEt < cut_MinEt) { - ATH_MSG_DEBUG("\tNot using constituent at eta " << curEta << " with et of " << curEt); - return false; - } + if(curEt < cut_MinEt) { + ATH_MSG_DEBUG("\tNot using constituent at eta " << curEta << " with et of " << curEt); + return false; + } - return true; + return true; } +bool PanTau::Tool_TauConstituentSelector::passesSelection_Pi0NeutConstituent(PanTau::TauConstituent* tauConstituent) const { -bool PanTau::Tool_TauConstituentSelector::passesSelection_Pi0NeutConstituent(PanTau::TauConstituent2* tauConstituent) const { - - TLorentzVector tlv_Constituent = tauConstituent->p4(); + TLorentzVector tlv_Constituent = tauConstituent->p4(); - double curEta = tlv_Constituent.Eta(); - double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_Pi0Neut); - double curEt = tlv_Constituent.Et(); - if(curEt < cut_MinEt) { - ATH_MSG_DEBUG("\tNot using constituent at eta " << curEta << " with et of " << curEt); - return false; - } + double curEta = tlv_Constituent.Eta(); + double cut_MinEt = getEtCut(std::abs(curEta), PanTau::TauConstituent::t_Pi0Neut); + double curEt = tlv_Constituent.Et(); + if(curEt < cut_MinEt) { + ATH_MSG_DEBUG("\tNot using constituent at eta " << curEta << " with et of " << curEt); + return false; + } - return true; + return true; } - -bool PanTau::Tool_TauConstituentSelector::passesSelection_ChargedConstituent(PanTau::TauConstituent2* /*tauConstituent*/) const { - +bool PanTau::Tool_TauConstituentSelector::passesSelection_ChargedConstituent(PanTau::TauConstituent* /*tauConstituent*/) const { // we want to use all tracks return true; } - -bool PanTau::Tool_TauConstituentSelector::passesSelection_OutNeutConstituent(TauConstituent2* TauConstituent) const { - TLorentzVector tlv_Constituent = TauConstituent->p4(); +bool PanTau::Tool_TauConstituentSelector::passesSelection_OutNeutConstituent(TauConstituent* TauConstituent) const { + TLorentzVector tlv_Constituent = TauConstituent->p4(); - double curEta = tlv_Constituent.Eta(); - double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_OutNeut); - double curEt = tlv_Constituent.Et(); + double curEta = tlv_Constituent.Eta(); + double cut_MinEt = getEtCut(std::abs(curEta), PanTau::TauConstituent::t_OutNeut); + double curEt = tlv_Constituent.Et(); - if(curEt < cut_MinEt) return false; - return true; + if(curEt < cut_MinEt) return false; + return true; } -bool PanTau::Tool_TauConstituentSelector::passesSelection_OutChrgConstituent(TauConstituent2* /*TauConstituent*/) const { - +bool PanTau::Tool_TauConstituentSelector::passesSelection_OutChrgConstituent(TauConstituent* /*TauConstituent*/) const { // we want to use all tracks return true; } - -bool PanTau::Tool_TauConstituentSelector::passesSelection_NeutLowAConstituent(TauConstituent2* TauConstituent) const { - TLorentzVector tlv_Constituent = TauConstituent->p4(); +bool PanTau::Tool_TauConstituentSelector::passesSelection_NeutLowAConstituent(TauConstituent* TauConstituent) const { + TLorentzVector tlv_Constituent = TauConstituent->p4(); - double curEta = tlv_Constituent.Eta(); - double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_NeutLowA); - double curEt = tlv_Constituent.Pt(); + double curEta = tlv_Constituent.Eta(); + double cut_MinEt = getEtCut(std::abs(curEta), PanTau::TauConstituent::t_NeutLowA); + double curEt = tlv_Constituent.Pt(); - if(curEt < cut_MinEt) return false; - return true; + if(curEt < cut_MinEt) return false; + return true; } - -bool PanTau::Tool_TauConstituentSelector::passesSelection_NeutLowBConstituent(TauConstituent2* TauConstituent) const { - TLorentzVector tlv_Constituent = TauConstituent->p4(); +bool PanTau::Tool_TauConstituentSelector::passesSelection_NeutLowBConstituent(TauConstituent* TauConstituent) const { + TLorentzVector tlv_Constituent = TauConstituent->p4(); - double curEta = tlv_Constituent.Eta(); - double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_NeutLowB); - double curEt = tlv_Constituent.Pt(); + double curEta = tlv_Constituent.Eta(); + double cut_MinEt = getEtCut(std::abs(curEta), PanTau::TauConstituent::t_NeutLowB); + double curEt = tlv_Constituent.Pt(); - if(curEt < cut_MinEt) return false; - return true; + if(curEt < cut_MinEt) return false; + return true; } - - - diff --git a/Reconstruction/PanTau/PanTauAlgs/python/JobOptions_Main_PanTau.py b/Reconstruction/PanTau/PanTauAlgs/python/JobOptions_Main_PanTau.py index 48d22102e4dd8d43be222bb3d60bf9118204e118..06909a9de8d1afe9a6c3c36b1f919c6b9ecc3198 100644 --- a/Reconstruction/PanTau/PanTauAlgs/python/JobOptions_Main_PanTau.py +++ b/Reconstruction/PanTau/PanTauAlgs/python/JobOptions_Main_PanTau.py @@ -1,15 +1,11 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - - -from AthenaCommon.SystemOfUnits import * -from AthenaCommon.Constants import * +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration cached_instances = {} sPrefix = 'tauRec_' bAODmode = False -from tauRec.tauRecFlags import jobproperties as config_TauRec +#from tauRec.tauRecFlags import jobproperties as config_TauRec ######################################################################## # PanTau @@ -30,7 +26,7 @@ def getPanTau(): # copy the configuration from cellbased if requested - from PanTauAlgs.Config_PanTau import config_PanTau + #from PanTauAlgs.Config_PanTau import config_PanTau #if config_PanTau.UseDefaultCellBasedConfig == True: # pi0-BDT cuts @@ -62,46 +58,40 @@ def getPanTau(): Infos_VecDouble = infoHandler.m_Infos_VecDouble, Infos_String = infoHandler.m_Infos_String, Infos_VecString = infoHandler.m_Infos_VecString) - python_Tool_InformationStore.OutputLevel = INFO ToolSvc += python_Tool_InformationStore # ===> Input Converter python_Tool_InputConverter = PanTau__Tool_InputConverter("PanTau_InputConverter", Tool_InformationStore = python_Tool_InformationStore) - python_Tool_InputConverter.OutputLevel = INFO #ToolSvc += python_Tool_InputConverter # ===> Tau Constituent Getter python_Tool_TauConstituentGetter = PanTau__Tool_TauConstituentGetter( "PanTau_TauConstituentGetter", Tool_InformationStore = python_Tool_InformationStore, Tool_InputConverter = python_Tool_InputConverter) - python_Tool_TauConstituentGetter.OutputLevel = INFO #ToolSvc += python_Tool_TauConstituentGetter # ===> Tau Constituent Selector python_Tool_TauConstituentSelector = PanTau__Tool_TauConstituentSelector( "PanTau_TauConstituentSelector", Tool_InformationStore = python_Tool_InformationStore) - python_Tool_TauConstituentSelector.OutputLevel = INFO #ToolSvc += python_Tool_TauConstituentSelector # ===> Tau Feature Extractor python_Tool_FeatureExtractor = PanTau__Tool_FeatureExtractor( "PanTau_FeatureExtractor", Tool_InformationStore = python_Tool_InformationStore ) - python_Tool_FeatureExtractor.OutputLevel = INFO #ToolSvc += python_Tool_FeatureExtractor # ===> Details arranger tool python_Tool_DetailsArranger = PanTau__Tool_DetailsArranger( "PanTau_DetailsArranger", Tool_InformationStore = python_Tool_InformationStore) - python_Tool_DetailsArranger.OutputLevel = INFO #ToolSvc += python_Tool_DetailsArranger - from PanTauAlgs.Config_PanTau import config_PanTau - List_InputAlgs = config_PanTau.Names_InputAlgorithms() + #from PanTauAlgs.Config_PanTau import config_PanTau + #List_InputAlgs = config_PanTau.Names_InputAlgorithms() #for curInAlg in List_InputAlgs: curInAlg = 'CellBased' @@ -117,7 +107,6 @@ def getPanTau(): Name_InputAlg = curInAlg, Name_ModeCase = "1p0n_vs_1p1n", Tool_InformationStore = python_Tool_InformationStore) - python_Tool_ModeDiscri_1p0n_vs_1p1n.OutputLevel = INFO ToolSvc += python_Tool_ModeDiscri_1p0n_vs_1p1n python_Tool_ModeDiscri_1p1n_vs_1pXn = PanTau__Tool_ModeDiscriminator( "PanTau_ModeDiscri_1p1n_vs_1pXn_" + curInAlg, @@ -125,7 +114,6 @@ def getPanTau(): Name_InputAlg = curInAlg, Name_ModeCase = "1p1n_vs_1pXn", Tool_InformationStore = python_Tool_InformationStore) - python_Tool_ModeDiscri_1p1n_vs_1pXn.OutputLevel = INFO ToolSvc += python_Tool_ModeDiscri_1p1n_vs_1pXn python_Tool_ModeDiscri_3p0n_vs_3pXn = PanTau__Tool_ModeDiscriminator( "PanTau_ModeDiscri_3p0n_vs_3pXn_" + curInAlg, @@ -133,7 +121,6 @@ def getPanTau(): Name_InputAlg = curInAlg, Name_ModeCase = "3p0n_vs_3pXn", Tool_InformationStore = python_Tool_InformationStore) - python_Tool_ModeDiscri_3p0n_vs_3pXn.OutputLevel = INFO ToolSvc += python_Tool_ModeDiscri_3p0n_vs_3pXn @@ -144,13 +131,9 @@ def getPanTau(): Tool_ModeDiscriminator_1p0n_vs_1p1n = python_Tool_ModeDiscri_1p0n_vs_1p1n, Tool_ModeDiscriminator_1p1n_vs_1pXn = python_Tool_ModeDiscri_1p1n_vs_1pXn, Tool_ModeDiscriminator_3p0n_vs_3pXn = python_Tool_ModeDiscri_3p0n_vs_3pXn) - python_Tool_DecayModeDeterminator.OutputLevel = INFO ToolSvc += python_Tool_DecayModeDeterminator - - - from PanTauAlgs.PanTauAlgsConf import PanTau__PanTauProcessor PanTau__PanTauProcessor = PanTau__PanTauProcessor( name = _name, Name_InputAlg = curInAlg, Tool_InformationStore = python_Tool_InformationStore, @@ -159,20 +142,7 @@ def getPanTau(): Tool_FeatureExtractor = python_Tool_FeatureExtractor, Tool_DecayModeDeterminator = python_Tool_DecayModeDeterminator, Tool_DetailsArranger = python_Tool_DetailsArranger) - PanTau__PanTauProcessor.OutputLevel = INFO cached_instances[_name] = PanTau__PanTauProcessor return PanTau__PanTauProcessor - - - - - - - - - - - -