diff --git a/Reconstruction/PanTau/PanTauAlgs/CMakeLists.txt b/Reconstruction/PanTau/PanTauAlgs/CMakeLists.txt index a16ae6dadc439f88e042653c6434dc788d298eaf..cee8ca41f7f42d89e2214265b3134e072440be13 100644 --- a/Reconstruction/PanTau/PanTauAlgs/CMakeLists.txt +++ b/Reconstruction/PanTau/PanTauAlgs/CMakeLists.txt @@ -1,7 +1,7 @@ ################################################################################ # Package: PanTauAlgs ################################################################################ - + # Declare the package name: atlas_subdir( PanTauAlgs ) @@ -11,9 +11,8 @@ atlas_depends_on_subdirs( PUBLIC Event/NavFourMom Event/xAOD/xAODPFlow Event/xAOD/xAODTau + Event/xAOD/xAODParticleEvent GaudiKernel - Reconstruction/PanTau/PanTauEvent - Reconstruction/PanTau/PanTauInterfaces PRIVATE Calorimeter/CaloEvent Control/AthenaKernel @@ -26,6 +25,7 @@ atlas_depends_on_subdirs( PUBLIC Reconstruction/Particle Reconstruction/eflowEvent Reconstruction/tauEvent + Reconstruction/tauRecTools Tools/PathResolver Tracking/TrkEvent/VxVertex Tracking/TrkVertexFitter/TrkVertexFitterInterfaces ) @@ -40,11 +40,13 @@ find_package( ROOT COMPONENTS MathCore MathMore Matrix TMVA Core Tree Hist RIO p # Component(s) in the package: atlas_add_component( PanTauAlgs src/*.cxx + Root/*.cxx src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps NavFourMom xAODPFlow xAODTau GaudiKernel PanTauEvent CaloEvent AthenaKernel DataModel StoreGateLib SGtests GeoPrimitives FourMom FourMomUtils xAODTracking Particle eflowEvent tauEvent PathResolver VxVertex TrkVertexFitterInterfaces ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps NavFourMom xAODPFlow xAODTau xAODParticleEvent GaudiKernel CaloEvent AthenaKernel DataModel StoreGateLib SGtests GeoPrimitives FourMom FourMomUtils xAODTracking Particle eflowEvent tauEvent tauRecToolsLib PathResolver VxVertex TrkVertexFitterInterfaces ) # Install files from the package: atlas_install_headers( PanTauAlgs ) atlas_install_runtime( data/weights/*.xml ) +atlas_install_python_modules( python/*.py ) diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Alg_SeedBuilder.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Alg_SeedBuilder.h deleted file mode 100644 index bd1b715091cd13286055513b4fba2938c16ada1e..0000000000000000000000000000000000000000 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Alg_SeedBuilder.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// Alg_SeedBuilder.h, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -#ifndef PANTAU_ALG_SEEDBUILDER_H -#define PANTAU_ALG_SEEDBUILDER_H - -// Gaudi includes -#include "AthenaBaseComps/AthAlgorithm.h" -#include "GaudiKernel/MsgStream.h" -#include "GaudiKernel/ToolHandle.h" - -// C++ includes -#include <string> -#include <map> -#include <vector> - -// PanTau includes -#include "PanTauAlgs/Tool_InformationStore.h" -#include "PanTauAlgs/Tool_TauConstituentGetter.h" -#include "PanTauAlgs/Tool_TauConstituentSelector.h" -#include "PanTauAlgs/Tool_FeatureExtractor.h" -#include "PanTauAlgs/Tool_DecayModeDeterminator.h" -#include "PanTauAlgs/Tool_FourMomentumCalculator.h" -#include "PanTauAlgs/Tool_DetailsArranger.h" - -#include "PanTauEvent/PanTauSeedContainer.h" - -class StoreGateSvc; - - - -namespace PanTau -{ - - /** @class Alg_SeedBuilder - - @author Peter Wienemann <peter.wienemann@cern.ch> - @author Sebastian Fleischmann <Sebastian.Fleischmann@cern.ch> - @author Robindra Prabhu <robindra.prabhu@cern.ch> - @author Christian Limbach <limbach@physik.uni-bonn.de> - */ - - class Alg_SeedBuilder : public AthAlgorithm - { - public: - - Alg_SeedBuilder(const std::string& name, ISvcLocator* pSvcLocator); - ~Alg_SeedBuilder(); - - StatusCode initialize(); - StatusCode execute(); - StatusCode finalize(); - - private: - - mutable MsgStream m_log; - StoreGateSvc* m_sgSvc; - - std::string m_Name_InputAlg; - - //Tools used in seed building - ToolHandle<PanTau::ITool_InformationStore> m_Tool_InformationStore; - ToolHandle<PanTau::ITool_TauConstituentGetter> m_Tool_TauConstituentGetter; - ToolHandle<PanTau::ITool_TauConstituentSelector> m_Tool_TauConstituentSelector; - ToolHandle<PanTau::ITool_FeatureExtractor> m_Tool_FeatureExtractor; - - //Tools used in seed finalizing - ToolHandle<PanTau::ITool_DecayModeDeterminator> m_Tool_DecayModeDeterminator; - ToolHandle<PanTau::ITool_FourMomentumCalculator> m_Tool_FourMomentumCalculator; - ToolHandle<PanTau::ITool_DetailsArranger> m_Tool_DetailsArranger; - - std::vector<double> m_Config_PtBins; - double m_Config_MinPt; - double m_Config_MaxPt; - - void fillDefaultValuesToTau(xAOD::TauJet* tauJet); - - - }; //end class -} // end of namespace - -#endif diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/HelperFunctions.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/HelperFunctions.h new file mode 100644 index 0000000000000000000000000000000000000000..b7921d36db0569d194405fad32709155221913af --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/HelperFunctions.h @@ -0,0 +1,86 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PANTAUALGS_TOOL_HELPERFUNCTIONS +#define PANTAUALGS_TOOL_HELPERFUNCTIONS + +//#include "NavFourMom/INavigable4MomentumCollection.h" + + +#include <string> +#include <iostream> + +#include "AsgTools/AsgMessaging.h" + +#include "xAODTau/TauJet.h" +#include "xAODPFlow/PFO.h" + +class TLorentzVector; +class TVector3; + +namespace PanTau { + class TauConstituent2; +} + +class TVector3; + +namespace PanTau { + + class HelperFunctions : public asg::AsgMessaging { + + public: + + // from PhysicsAnalysis/TauID/TauDiscriminant/TauDiscriminant/MethodBase.h + HelperFunctions(const std::string& _name = ""): + AsgMessaging(_name), + name(_name) + {} + + virtual ~HelperFunctions () {}; + + + virtual void dumpFourMomentum(TLorentzVector FourMom) const; + virtual void dumpTauConstituent2(PanTau::TauConstituent2* tauConstituent) const; + + TauConstituent2* getNeutralConstWithLargestAngle(TLorentzVector charged, + std::vector<PanTau::TauConstituent2*> neutral); + + virtual std::string convertNumberToString(double x) const; + + void vertexCorrection_PFOs(const xAOD::TauJet* tauJet, xAOD::PFO* efo) const; + + virtual int getBinIndex(std::vector<double> binEdges, double value) const; + + virtual double stddev(double sumOfSquares, double sumOfValues, int numConsts) const; + virtual double deltaRprime(const TVector3& vec1, const TVector3& vec2) const; + + virtual int iPow(int man, int exp) const; + virtual double ulAngle(double x, double y) const; + virtual double sign(double a, double b) const; + virtual std::vector<double> calcThrust(std::vector<TauConstituent2*>* tauConstituents, bool& calcIsValid) const; + virtual void ludbrb(TMatrix* mom, double the, double phi, double bx, double by, double bz) const; + virtual std::vector<double> calcFWMoments(std::vector<TauConstituent2*>* tauConstituents, bool& calcIsValid) const; + virtual std::vector<double> calcSphericity(std::vector<TauConstituent2*>* tauConstituents, bool& calcIsValid) const; + + + std::string getName() const + { + return name; + } + + + private: + + std::string name; + + + }; //end class Tool_HelperFunctions + + +}//end namespace PanTau + + + + +#endif // PANTAUALGS_TOOL_HELPERFUNCTIONS diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_InformationStore.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_InformationStore.h new file mode 100644 index 0000000000000000000000000000000000000000..731acc65dd83a9994afedac9dac621cf0c4b0538 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_InformationStore.h @@ -0,0 +1,58 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PANTAUALGS_ITOOL_INFORMATIONSTORE_H +#define PANTAUALGS_ITOOL_INFORMATIONSTORE_H +// Gaudi +#include "AsgTools/IAsgTool.h" + +#include <string> + +//class eflowObjectContainer; + +// namespace Analysis { +// class TauJetContainer; +// class TauDetailsContainer; +// } + +//! xAOD EDM +/* +#include "xAODTau/TauJetContainer.h" + +namespace Rec { + class TrackParticleContainer; +} +*/ + +namespace PanTau { + + + /** @class ITool_InformationStore + @brief Interface for Tool_InformationStore + @author Christian Limbach (limbach@physik.uni-bonn.de) + */ + + + class ITool_InformationStore : virtual public asg::IAsgTool { + ASG_TOOL_INTERFACE(ITool_InformationStore) + + public: + //virtual StatusCode updateInformation(std::string inputAlg) = 0; + virtual StatusCode getInfo_Int(std::string varName, int& value) = 0; + virtual StatusCode getInfo_Double(std::string varName, double& value) = 0; + virtual StatusCode getInfo_VecDouble(std::string varName, std::vector<double>& value) = 0; + virtual StatusCode getInfo_String(std::string varName, std::string& value) = 0; + virtual StatusCode getInfo_VecString(std::string varName, std::vector<std::string>& value) = 0; + + virtual StatusCode dumpMaps() const = 0; + + /* + virtual const xAOD::TauJetContainer* getContainer_TauRec() const = 0; + virtual const Rec::TrackParticleContainer* getContainer_TrackParticle() const = 0; + */ + }; + +} +#endif //PANTAUALGS_ITOOL_INFORMATIONSTORE_H + diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_InputConverter.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_InputConverter.h new file mode 100644 index 0000000000000000000000000000000000000000..98befb64d822421dbef2b3d7b6035dc412e62dfe --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_InputConverter.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#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 eflowObject; + +//namespace Analysis { +// class TauPi0Cluster; +// class TauJet; +//} + +namespace Rec { + class TrackParticle; +} + + + + +namespace PanTau { + + /** @class ITool_InputConverter + @brief Interface for Tool_InputConverter + @author Christian Limbach (limbach@physik.uni-bonn.de) + */ + + + class ITool_InputConverter : virtual public asg::IAsgTool { + + ASG_TOOL_INTERFACE(ITool_InputConverter) + + public: + + //PFO Converter (r19+) + virtual StatusCode ConvertToTauConstituent2(xAOD::PFO* pfo, + PanTau::TauConstituent2* &tauConstituent, + const xAOD::TauJet* tauJet) const = 0; + +// virtual bool passesPreselectionEnergy(double itsEnergy) const = 0; + + //cluster based converter +// virtual StatusCode ConvertToTauConstituent2(eflowObject* efo, TauConstituent2* &tauConstituent) const; + + }; + + +} +#endif //PANTAUALGS_ITOOL_INPUTCONVERTER_H diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_ModeDiscriminator.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_ModeDiscriminator.h new file mode 100644 index 0000000000000000000000000000000000000000..6ede28b9f1ed340404db0c8f404161f0e47fac74 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_ModeDiscriminator.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PANTAUALGS_ITOOL_MODEDISCRIMINATOR_H +#define PANTAUALGS_ITOOL_MODEDISCRIMINATOR_H + +#include "AsgTools/IAsgTool.h" + + +//class Jet; +namespace PanTau { + class PanTauSeed2; +} + + +namespace PanTau { + + /** @class ITool_ModeDiscriminator + @brief Interface for PID from tau seeds. + + @author Sebastian Fleischmann + @author Christian Limbach + */ + class ITool_ModeDiscriminator : virtual public asg::IAsgTool { + + ASG_TOOL_INTERFACE(ITool_ModeDiscriminator) + + public: + + //virtual double getModeLikeliness(PanTau::PanTauSeed2* inSeed, bool& wasSuccessful) = 0; + virtual double getResponse(PanTau::PanTauSeed2* inSeed, bool& isOK) = 0; + }; + +} +#endif // PANTAUALGS_ITAUDISCRIMINANTTOOL_H diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_PanTauTools.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_PanTauTools.h new file mode 100644 index 0000000000000000000000000000000000000000..7030ef6391297af7fb9caa2d53ce01087520a6d7 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_PanTauTools.h @@ -0,0 +1,51 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PANTAUALGS_ITOOL_PANTAUTOOLS_H +#define PANTAUALGS_ITOOL_PANTAUTOOLS_H + +#include "AsgTools/IAsgTool.h" + +#include <string> +#include <vector> + +//! xAOD EDM +#include "xAODPFlow/PFO.h" +#include "xAODTau/TauJet.h" +#include "PanTauAlgs/TauConstituent.h" + + +namespace PanTau { + class TauFeature2; + class PanTauSeed2; + class TauConstituent2; +} + + +namespace Rec { + class TrackParticle; +} + + +namespace PanTau { + + /** @class ITool_PanTauTools + @brief Interface for PID from tau seeds. + + @author Sebastian Fleischmann + @author Christian Limbach + */ + class ITool_PanTauTools : virtual public asg::IAsgTool { + + ASG_TOOL_INTERFACE(ITool_PanTauTools) + + public: + + // used in Tool_FeatureExtractor, Tool_DecayModeDeterminator and Tool_DetailsArranger: + virtual StatusCode execute(PanTau::PanTauSeed2* inSeed) = 0; + + }; + +} +#endif // PANTAUALGS_ITAUDISCRIMINANTTOOL_H diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_TauConstituentGetter.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_TauConstituentGetter.h new file mode 100644 index 0000000000000000000000000000000000000000..f7436c4ebad14d26d474630205f9d99405867094 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_TauConstituentGetter.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PANTAUALGS_ITOOL_TAUCONSTITUENTGETTER_H +#define PANTAUALGS_ITOOL_TAUCONSTITUENTGETTER_H + +// Gaudi +#include "AsgTools/IAsgTool.h" + +#include <string> + +namespace PanTau{ + class TauConstituent2; +} + +//namespace Analysis { +// class TauJet; +//} +#include "xAODTau/TauJet.h" + +namespace PanTau { + + + /** @class ITool_TauConstituentGetter + @brief Interface for Tool_TauConstituentGetter + @author Christian Limbach (limbach@physik.uni-bonn.de) + */ + + + class ITool_TauConstituentGetter : virtual public asg::IAsgTool { + + ASG_TOOL_INTERFACE(ITool_TauConstituentGetter) + + public: + + virtual StatusCode GetTauConstituents(//const Analysis::TauJet*, + const xAOD::TauJet* tauJet, + std::vector<TauConstituent2*>& outputList, + std::string algName) const = 0; + + }; + +} +#endif //PANTAUALGS_ITOOL_TAUCONSTITUENTGETTER_H diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_TauConstituentSelector.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_TauConstituentSelector.h new file mode 100644 index 0000000000000000000000000000000000000000..8af0aa872745c1ff237c18e11a1e0c2e433be5c0 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/ITool_TauConstituentSelector.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PANTAUALGS_ITOOL_TAUCONSTITUENTSELECTOR_H +#define PANTAUALGS_ITOOL_TAUCONSTITUENTSELECTOR_H + +// Gaudi +#include "AsgTools/IAsgTool.h" + +#include <vector> + +#include "PanTauAlgs/TauConstituent.h" + +namespace PanTau { + + /** @class ITool_TauConstituentSelector + @brief Interface for Tool_TauConstituentSelector + @author Christian Limbach (limbach@physik.uni-bonn.de) + */ + + + class ITool_TauConstituentSelector : virtual public asg::IAsgTool { + + ASG_TOOL_INTERFACE(ITool_TauConstituentSelector) + + public: + virtual StatusCode SelectTauConstituents(std::vector<TauConstituent2*> inputList, + std::vector<TauConstituent2*>& outputList) const = 0; + protected: +// virtual bool passesSelection_NeutralConstituent(TauConstituent2* tauConstituent) const = 0; +// virtual bool passesSelection_Pi0NeutConstituent(TauConstituent2* tauConstituent) const = 0; +// virtual bool passesSelection_ChargedConstituent(TauConstituent2* tauConstituent) const = 0; +// virtual bool passesSelection_OutNeutConstituent(TauConstituent2* TauConstituent) const = 0; +// virtual bool passesSelection_OutChrgConstituent(TauConstituent2* TauConstituent) const = 0; +// virtual bool passesSelection_NeutLowAConstituent(TauConstituent2* TauConstituent) const = 0; +// virtual bool passesSelection_NeutLowBConstituent(TauConstituent2* TauConstituent) const = 0; + +// virtual double getEtCut(double eta, PanTau::TauConstituent2::Type constituentType) const = 0; + }; + +} +#endif //PANTAUALGS_ITOOL_TAUCONSTITUENTSELECTOR_H diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/PanTauProcessor.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/PanTauProcessor.h new file mode 100644 index 0000000000000000000000000000000000000000..4eb206fcdb4cd53a092f39e41803fe2fff07461b --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/PanTauProcessor.h @@ -0,0 +1,93 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// PanTauProcessor.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef PANTAU_PANTAUPROCESSOR_H +#define PANTAU_PANTAUPROCESSOR_H + +// Gaudi includes +#include "AsgTools/AsgTool.h" +#include "AsgTools/ToolHandle.h" +#include "tauRecTools/TauRecToolBase.h" + +// C++ includes +#include <string> +#include <map> +#include <vector> + +// PanTau includes +#include "PanTauAlgs/ITool_InformationStore.h" +#include "PanTauAlgs/ITool_TauConstituentGetter.h" +#include "PanTauAlgs/ITool_TauConstituentSelector.h" +#include "PanTauAlgs/ITool_PanTauTools.h" + +//#include "PanTauAlgs/PanTauSeedContainer.h" + +//class StoreGateSvc; + + + +namespace PanTau +{ + + /** @class PanTauProcessor + + @author Peter Wienemann <peter.wienemann@cern.ch> + @author Sebastian Fleischmann <Sebastian.Fleischmann@cern.ch> + @author Robindra Prabhu <robindra.prabhu@cern.ch> + @author Christian Limbach <limbach@physik.uni-bonn.de> + @author Peter Wagner <peter.wagner@cern.ch> + @author Lara Schildgen <schildgen@physik.uni-bonn.de> + */ + + class PanTauProcessor : virtual public TauRecToolBase + { + public: + + // as in https://svnweb.cern.ch/trac/atlasoff/browser/Reconstruction/tauRecTools/trunk/tauRecTools/TauCalibrateLC.h + ASG_TOOL_CLASS2( PanTauProcessor, TauRecToolBase, ITauToolBase ) + + PanTauProcessor(const std::string& name); + ~PanTauProcessor(); + + virtual StatusCode initialize(); + virtual StatusCode finalize(); + virtual StatusCode execute(xAOD::TauJet& pTau); + + virtual StatusCode eventInitialize(); + virtual StatusCode eventFinalize() { return StatusCode::SUCCESS; } + + virtual void print() const { } + + private: + + //mutable MsgStream m_log; + //StoreGateSvc* m_sgSvc; + + std::string m_Name_InputAlg; + + //Tools used in seed building + ToolHandle<PanTau::ITool_InformationStore> m_Tool_InformationStore; + ToolHandle<PanTau::ITool_TauConstituentGetter> m_Tool_TauConstituentGetter; + ToolHandle<PanTau::ITool_TauConstituentSelector> m_Tool_TauConstituentSelector; + ToolHandle<PanTau::ITool_PanTauTools> m_Tool_FeatureExtractor; + + //Tools used in seed finalizing + ToolHandle<PanTau::ITool_PanTauTools> m_Tool_DecayModeDeterminator; + ToolHandle<PanTau::ITool_PanTauTools> m_Tool_DetailsArranger; + + std::vector<double> m_Config_PtBins; + double m_Config_MinPt; + double m_Config_MaxPt; + + void fillDefaultValuesToTau(xAOD::TauJet* tauJet); + + + }; //end class +} // end of namespace + +#endif diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/PanTauSeed.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/PanTauSeed.h new file mode 100644 index 0000000000000000000000000000000000000000..18780486547ac302b9d5c30aa283e121dc9173e8 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/PanTauSeed.h @@ -0,0 +1,246 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PANTAUALGS_PANTAUSEED_H +#define PANTAUALGS_PANTAUSEED_H + + +#include <vector> +#include <string> + +#include "xAODBase/IParticle.h" + +//CxxUtils for override final +#include "CxxUtils/final.h" +#include "CxxUtils/override.h" + +#include "PanTauAlgs/TauConstituent.h" +#include "PanTauAlgs/TauFeature.h" + + +#include "xAODTau/TauJet.h" + +namespace PanTau { + + + + class PanTauSeed2 : 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 + + public: + + //enumeration to describe technical status of the seed + // i.e. numTrack ok? pT ok? etc... + enum TechnicalQuality { + t_NoValidInputTau, //use this when there's no substructure info available + t_NoConstituentsAtAll, //use when no constituent was found + t_NoSelectedConstituents, //use when no constituent passes the cuts (all below pT, none in cone...) + t_BadPtValue, //for cases when pT is not in the range of any BDT PT bin + t_GoodSeed, + t_nTechnicalQualities + }; + + static int getDecayMode(int nCharged, int nNeutral); + static std::string getDecayModeName(int decayMode); + + PanTauSeed2(); + ~PanTauSeed2(); + PanTauSeed2(const PanTauSeed2& seed); + PanTauSeed2& operator=(const PanTauSeed2& seed); + + + /// @name xAOD::IParticle functions + /// These are already virtual due to IParticle + /// @{ + + /// @brief The transverse momentum (\f$p_T\f$) of the particle + virtual double pt() const; + + /// @brief The pseudorapidity (\f$\eta\f$) of the particle + virtual double eta() const; + + /// @brief The azimuthal angle (\f$\phi\f$) of the particle + virtual double phi() const; + + /// @brief The invariant mass of the particle + virtual double m() const; + + /// The total energy of the particle + virtual double e() const; + + /// @brief The true rapidity (y) of the particle + virtual double rapidity() const; + + /// @brief Definition of the 4-momentum type + typedef IParticle::FourMom_t FourMom_t; + + /// @brief The full 4-momentum of the particle as a TLoretzVector + virtual const FourMom_t& p4() const; + + /// @brief The type of the object as a simple enumeration, remains pure virtual in e/gamma. + virtual xAOD::Type::ObjectType type() const; + + + /// @brief set the 4-vec + void setP4(float pt, float eta, float phi, float m); + + /// @brief set the Pt + void setPt(float pt); + + /// @brief set the eta + void setEta(float eta); + + /// @brief set the phi + void setPhi(float phi); + + /// @brief set the Mass + void setM(float m); + + + + /** 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 + ); + + + /** Constructor for invalid seeds */ + PanTauSeed2( 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; + 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<PanTau::TauConstituent2*> getConstituentsOfType(int tauConstituent_Type, bool& foundit); + int getNumberOfConstituentsOfType(int tauConstituent_Type); + TLorentzVector getSubsystemHLV(int tauConstituent_Type, bool& foundit); + + TLorentzVector getFinalMomentum() const; + int getDecayModeBySubAlg() const; + int getDecayModeByPanTau() const; + + void setFinalMomentum(TLorentzVector finalMom); + void setDecayModeByPanTau(int decayModePanTau); + + void setModeHackedByCellBased(bool f) {m_decayModeHack_CellBasedShots = f;} + bool getModeHackedByCellBased() {return m_decayModeHack_CellBasedShots;} + + + + private: + + /// Cached 4-momentum object + mutable FourMom_t m_p4; + /// + + /// Cache state of the internal 4-momentum (reset from the streamer) + mutable bool m_p4Cached; + + protected: + + //flag that tells whether the seed is valid + bool m_IsValidSeed; + + std::vector<int> m_TechnicalQuality; + + //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) + 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 momentum as calculated by using all constituents added to this seed + TLorentzVector m_ProtoMomentum_Wide; + + //the momentum as calculated by using only core constituents + TLorentzVector m_ProtoMomentum_Core; + + //the momentum as calculated by using info about decay mode + TLorentzVector m_FinalMomentum; + + //a list of hlvs for the different subsystems (charged, neutral, pi0Neut...) + 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 + + //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 + + //the decay mode + int m_DecayMode_BySubAlg; + int m_DecayMode_ByPanTau; + + bool m_decayModeHack_CellBasedShots; //! flag to indicate whether the decay mode by cellbased was + //! 1p1n and hits in EM1 > 2 (because then 1p1n -> 1pX + //! is set) + + //the features of this pantauseed + PanTau::TauFeature2* m_Features; + + + }; + + + static void SetP4EEtaPhiM(TLorentzVector& hlv, double e, double eta, double phi, double m ); + + +} //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 static void PanTau::SetP4EEtaPhiM(TLorentzVector& hlv, double e, double eta, double phi, double m ){ + if( eta == 0. ) return; + double pt = std::sqrt( e*e - m*m) / std::cosh( eta ); // not really safe. + hlv.SetPtEtaPhiE(pt, eta, phi, e); + return; +} + + +#endif // PANTAUALGS_PANTAUSEED_H + + diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/RunTimeMonitoring.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/RunTimeMonitoring.h deleted file mode 100644 index 3af581f297889ebeaba27629a4c93671a93cd7d2..0000000000000000000000000000000000000000 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/RunTimeMonitoring.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef PANTAU_RUNTIMEMONITORING_H -#define PANTAU_RUNTIMEMONITORING_H - -#include <vector> -#include <string> -#include <map> -#include <iostream> -#include "TH1F.h" -#include "TString.h" - -#include "GaudiKernel/ITHistSvc.h" - - -namespace PanTau { - - typedef std::map<std::string, TH1F*> HistMap; - - class RunTimeMonitoring { - - private: - - bool m_IsActivated; //if this is false, functions may be called but not executed - //not ideal, but maybe better than have an if statement in SeedBuilder in front of every call to m_RTH... - ITHistSvc* m_THistSvc; //this is not owned by this class (externally created and passed) - HistMap m_HistMap; - - void CreateHist1D(std::string Name, std::string xTitle, int nBins, double MinBin, double MaxBin); - - public: - - RunTimeMonitoring( bool isActive); - RunTimeMonitoring( const RunTimeMonitoring& other ); - ~RunTimeMonitoring(); - - RunTimeMonitoring operator=( RunTimeMonitoring rhs ); - - void SetTHistSvcLink(ITHistSvc* histSvc); - void CreateHist1DMap( - std::vector<std::string> Names, - std::vector<std::string> xTitles, - std::vector<int> nBins, - std::vector<double> MinBins, - std::vector<double> MaxBins - ); - bool RegisterHistos(); - - //call this for variables that are not added via AddFooBarVariable(...) - void FillHisto(std::string itsName, double fillValue); - - - }; -} - -#endif \ No newline at end of file diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauClassificationTypes.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauClassificationTypes.h new file mode 100644 index 0000000000000000000000000000000000000000..a55c98ba93f856d534a9737593e2e20461084c38 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauClassificationTypes.h @@ -0,0 +1,83 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TauClassificationTypes.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef PANTAUALGS_TAUCLASSIFICATIONTYPES_H +#define PANTAUALGS_TAUCLASSIFICATIONTYPES_H + +namespace PanTau { + namespace TauClassificationTypes { + enum TruthTauType { + TruthOneProng=0, + TruthOneProngNeutrals=1, + TruthThreeProng=2, + TruthThreeProngNeutrals=3, + TruthKaon=4, + TruthElectron=5, + TruthMuon=6, + TruthFake=7, + TruthOther=8, + NumberOfTruthTauTypes=9 + }; + enum SeedTauType { + SeedOneProng=0, + SeedOneProngNeutrals=1, + SeedThreeProng=2, + SeedThreeProngNeutrals=3, + SeedThreeAndOneProng=4, + SeedThreeAndOneProngNeutrals=5, + SeedElectron=6, + SeedMuon=7, + SeedOther=8, + SeedMissing=9, + NumberOfSeedTauTypes=10, + TauRecBoth=0, + TauRecBothMissing=1, + TauRec=2, + Tau1p3p=3, + NumberOfTauRecTypes=4, + UnknownSeedType = 10 + }; + + enum PanTauRecoMode { + Reco_1prong_0neutrals = 0, + Reco_1prong_1neutral = 1, + Reco_1prong_Xneutrals = 2, + Reco_3prong_0neutrals = 3, + Reco_3prong_Xneutrals = 4, + Reco_BadPt = -2, + Reco_Error = -3, + Reco_InvalidInSeed = -4, + Reco_nModes = 8 + }; + +// enum CandTauType { +// TauRecBoth=0, +// TauRecBothMissing=1, +// TauRec=2, +// Tau1p3p=3, +// NumberOfCandTauTypes=4 +// }; + + inline std::string getRecoModeName(PanTauRecoMode recoMode) { + switch(recoMode) { + case Reco_1prong_0neutrals: return "1p0n"; + case Reco_1prong_1neutral: return "1p1n"; + case Reco_1prong_Xneutrals: return "1pXn"; + case Reco_3prong_0neutrals: return "3p0n"; + case Reco_3prong_Xneutrals: return "3pXn"; + case Reco_BadPt: return "BadPt"; + case Reco_Error: return "Error"; + default: return "Unkown"; + } + } + } +} // end of namespace + +#endif //PANTAUALGS_TAUCLASSIFICATIONTYPES_H + + diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauConstituent.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauConstituent.h new file mode 100644 index 0000000000000000000000000000000000000000..1c71d73da21d801eb34362703c992588c17c6a9b --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauConstituent.h @@ -0,0 +1,196 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TauSeed.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef PANTAUALGSTAUCONSTITUENT_H +#define PANTAUALGSTAUCONSTITUENT_H + +#include <string> +#include <vector> + +#include "xAODBase/IParticle.h" +#include "xAODPFlow/PFO.h" +#include <TLorentzVector.h> + +//CxxUtils for override final +#include "CxxUtils/final.h" +#include "CxxUtils/override.h" + + +namespace PanTau { + +/** @class TauConstituent + Input object for PanTau. + Mainly a 4-vector with additional information about its type (charged, neutral, pi0 tagged) + + @author limbach@physik.uni-bonn.de + */ + + + class TauConstituent2 : public xAOD::IParticle { + + public: + + /** + * Type enumeration to specify type of this tau constituent + * + * t_NoType: This is used in default constructors when no type is specified + * t_Charged: Used to represent objects considered as 'charged' by input substructure reco + * t_Neutral: Use for objects considered neutral by input substructure algorithm + * t_Pi0Neut: If a particle passes pi0 ID, use this flag + * t_OutChrg: Charged objects in 0.2 to 0.4 + * t_OutNeut: Neutral objects in 0.2 to 0.4 + * t_NeutLowA: (Core) Neutrals with lower Et cut + * t_NeutLowB: (Core) Neutrals with even lower Et cut + * t_nTypes: Dont use this, just tell number of types + */ + enum Type { + t_NoType = 0, + t_Charged = 1, + t_Neutral = 2, + t_Pi0Neut = 3, + t_OutChrg = 4, + t_OutNeut = 5, + t_NeutLowA = 6, + t_NeutLowB = 7, + t_nTypes = 8 + }; + + static double DefaultBDTValue() {return -4711.1337;} + static double DefaultCharge() {return -47111337;} + static std::string AllConstituentsName() {return "All";} + + static std::string getTypeName(PanTau::TauConstituent2::Type aType); + static bool isNeutralType(int tauConstituentType); + static bool isCoreType(int tauConstituentType); + + + + + /** Default Constructor for POOL. Do not use! */ + TauConstituent2(); + + /** + * @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, + int itsCharge, + std::vector<int> itsType, + double itsBDTValue, + xAOD::PFO* itsPFOLink); + + + /** Destructor */ + virtual ~TauConstituent2(); + + + /** Copy Constructor */ + TauConstituent2(const TauConstituent2& tauConst); + + /** Assignment operator */ + TauConstituent2& operator=(const TauConstituent2& tauConst); + + /// @name xAOD::IParticle functions + /// These are already virtual due to IParticle + /// @{ + + /// @brief The transverse momentum (\f$p_T\f$) of the particle + virtual double pt() const; + + /// @brief The pseudorapidity (\f$\eta\f$) of the particle + virtual double eta() const; + + /// @brief The azimuthal angle (\f$\phi\f$) of the particle + virtual double phi() const; + + /// @brief The invariant mass of the particle + virtual double m() const; + + /// The total energy of the particle + virtual double e() const; + + /// @brief The true rapidity (y) of the particle + virtual double rapidity() const; + + /// @brief Definition of the 4-momentum type + typedef IParticle::FourMom_t FourMom_t; + + /// @brief The full 4-momentum of the particle as a TLoretzVector + virtual const FourMom_t& p4() const; + + /// @brief The type of the object as a simple enumeration, remains pure virtual in e/gamma. + virtual xAOD::Type::ObjectType type() const; + + + /// @brief set the 4-vec + void setP4(float pt, float eta, float phi, float m); + + /// @brief set the Pt + void setPt(float pt); + + /// @brief set the eta + void setEta(float eta); + + /// @brief set the phi + void setPhi(float phi); + + /// @brief set the Mass + void setM(float m); + + + //no setter functions needed as all properties are set in constructor + void removeTypeFlag(TauConstituent2::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; + double getBDTValue() const; + int getCharge() const; + xAOD::PFO* getPFO() const; + + void addShot(TauConstituent2* shot); + std::vector<TauConstituent2*> getShots(); + unsigned int getNShots(); + + void setNPhotonsInShot(int nPhotons); + int getNPhotonsInShot(); + + private: + + /// Cached 4-momentum object + mutable FourMom_t m_p4; + /// + + /// Cache state of the internal 4-momentum (reset from the streamer) + mutable bool m_p4Cached; + + + + protected: + + std::vector<int> m_TypeFlags; + double m_BDTValue; + int m_Charge; + + xAOD::PFO* m_PFOLink; + + // the constituents in there are owned by this! delete them! + std::vector<TauConstituent2*> m_Shots; + int m_nPhotonsInShot; + + + }; + + + + +} //end namespace +#endif // PANTAUALGSTAUCONSTITUENT_H diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauFeature.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauFeature.h new file mode 100644 index 0000000000000000000000000000000000000000..3ee792e90598d255cf02e3b74af37bbfb8d42761 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/TauFeature.h @@ -0,0 +1,111 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TauFeature.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef PANTAUALGSTAUFEATURE_H +#define PANTAUALGSTAUFEATURE_H + + +#include <string> +#include <map> +#include <vector> + +namespace PanTau { + + +/** @class TauFeature + Class containing features of a tau seed. + @author Sebastian.Fleischmann@cern.ch + */ + +class TauFeature2 { + +//struct cmp_fn { +//bool operator()(const std::string& s1, const std::string& s2) const { +//return (s1 < s2); +//} +//}; +//typedef std::map<std::string, double, cmp_fn> FeatureMap; +typedef std::map<std::string, double> FeatureMap; +typedef FeatureMap::iterator FeatureMapIter; +typedef FeatureMap::const_iterator FeatureMapConstIter; +typedef std::map<std::string, const std::vector<double> > VectorFeatureMap; +typedef VectorFeatureMap::iterator VectorFeatureMapIter; +typedef VectorFeatureMap::const_iterator VectorFeatureMapConstIter; + +public: + /** Default constructor */ + TauFeature2(); + /** Copy Constructor */ + //TauFeature2(const TauFeature& feature); +// /** Assignment operator */ +// TauFeature& operator=(const TauFeature& seed); + +// /** +// * Full constructor. +// * +// * @param[in] name name of the feature +// * @param[in] value value of the feature +// */ +// TauFeature2( +// const std::string& name, +// const double& value +// ); + + /** Destructor */ + virtual ~TauFeature2(); + + /** returns the value of the feature given by its name*/ + double value(const std::string& ItsName, bool& isValid) const; + + /** returns the value of a vector feature given by its name*/ + const std::vector<double>& vecValue(const std::string& name) const; + + /** adds a new feature*/ + bool addFeature( + const std::string& name, + const double& value); + + /** adds a new vector feature*/ + bool addVecFeature( + const std::string& name, + const std::vector<double>& value); + + /** returns the size of the m_featureMap */ + int nValues() const; + + /** returns the size of the m_vecFeatureMap */ + int nVecValues() const; + + + void add(PanTau::TauFeature2* otherFeatures); + + void addFeaturesFromMap(std::map<std::string, double>, std::string prefix); + + /* + std::ostream& operator<< ( std::ostream& out, + xAOD::FileMetaData_v1::MetaDataType type ); + //MsgStream& dump( MsgStream& out, MSG::Level debugLevel ) const; + */ + +protected: + + /** The map containg all features */ + FeatureMap m_featureMap; + /** The map containg all features */ + VectorFeatureMap m_vecFeatureMap; + +}; + + +} + +/**Overload of << operator for MsgStream for debug output*/ +// inline MsgStream& operator << ( MsgStream& sl, const PanTau::TauFeature& feature) +// { return feature.dump(sl); } + +#endif // PANTAUALGSTAUFEATURE_H diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_DecayModeDeterminator.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_DecayModeDeterminator.h index 5d47366aba72eaae065633c5171d3115ab17badc..dc969aa54090c1267f931bcb7633ee23b1cf5b9c 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_DecayModeDeterminator.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_DecayModeDeterminator.h @@ -21,18 +21,18 @@ #include <string> //! Gaudi -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ToolHandle.h" +#include "AsgTools/AsgTool.h" +#include "AsgTools/ToolHandle.h" //! PanTau -#include "PanTauInterfaces/ITool_DecayModeDeterminator.h" -#include "PanTauInterfaces/ITool_ModeDiscriminator.h" -#include "PanTauInterfaces/ITool_InformationStore.h" +#include "PanTauAlgs/ITool_PanTauTools.h" +#include "PanTauAlgs/ITool_ModeDiscriminator.h" +#include "PanTauAlgs/ITool_InformationStore.h" class StoreGateSvc; namespace PanTau { - class PanTauSeed; + class PanTauSeed2; } @@ -42,9 +42,9 @@ namespace PanTau { Tool to store information needed in PanTau Algorithms @author Christian Limbach (limbach@physik.uni-bonn.de) */ -class Tool_DecayModeDeterminator : public AthAlgTool, virtual public PanTau::ITool_DecayModeDeterminator { - - + class Tool_DecayModeDeterminator : public asg::AsgTool, virtual public PanTau::ITool_PanTauTools { + + ASG_TOOL_CLASS1(Tool_DecayModeDeterminator, PanTau::ITool_PanTauTools) public: @@ -56,13 +56,13 @@ class Tool_DecayModeDeterminator : public AthAlgTool, virtual public PanTau::ITo t_nTests }; - Tool_DecayModeDeterminator(const std::string&,const std::string&,const IInterface*); + Tool_DecayModeDeterminator(const std::string &name); virtual ~Tool_DecayModeDeterminator (); virtual StatusCode initialize(); // virtual StatusCode finalize (); - virtual StatusCode determineDecayMode(PanTau::PanTauSeed* inSeed) const; + virtual StatusCode execute(PanTau::PanTauSeed2* inSeed); private: @@ -88,14 +88,6 @@ class Tool_DecayModeDeterminator : public AthAlgTool, virtual public PanTau::ITo double m_BDTCutValue_R30X_CellBased; double m_BDTCutValue_R3XX_CellBased; - //cut values for eflowRec - double m_BDTCutValue_R10X_eflowRec; - double m_BDTCutValue_R11X_eflowRec; - double m_BDTCutValue_R110_eflowRec; - double m_BDTCutValue_R1XX_eflowRec; - double m_BDTCutValue_R30X_eflowRec; - double m_BDTCutValue_R3XX_eflowRec; - }; diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_DetailsArranger.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_DetailsArranger.h index 05be53a0c6d88058f8058f42507e56f6ca069825..01f10f024a4143a55ef544c33a24d738df847f4c 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_DetailsArranger.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_DetailsArranger.h @@ -18,28 +18,28 @@ #include <string> #include <vector> -//! Gaudi -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ToolHandle.h" +//! ASG +#include "AsgTools/AsgTool.h" +#include "AsgTools/ToolHandle.h" //! xAOD EDM #include "xAODTau/TauJet.h" // #include "xAODTau/TauDefs.h" //! PanTau -#include "PanTauInterfaces/ITool_DetailsArranger.h" -#include "PanTauInterfaces/ITool_InformationStore.h" +#include "PanTauAlgs/ITool_PanTauTools.h" +#include "PanTauAlgs/ITool_InformationStore.h" -#include "PanTauEvent/TauConstituent.h" +#include "PanTauAlgs/TauConstituent.h" namespace PanTau { - class PanTauSeed; + class PanTauSeed2; class PanTauDetails; } -namespace Analysis { - class TauDetailsContainer; -} +//namespace Analysis { +// class TauDetailsContainer; +//} class StoreGateSvc; @@ -51,8 +51,9 @@ namespace PanTau { @author Sebastian Fleischmann @author Christian Limbach <limbach@physik.uni-bonn.de> */ - class Tool_DetailsArranger : public AthAlgTool, virtual public PanTau::ITool_DetailsArranger { + class Tool_DetailsArranger : public asg::AsgTool, virtual public PanTau::ITool_PanTauTools { + ASG_TOOL_CLASS1(Tool_DetailsArranger, PanTau::ITool_PanTauTools) public: @@ -62,13 +63,13 @@ namespace PanTau { t_NTypes }; - Tool_DetailsArranger(const std::string&,const std::string&,const IInterface*); + Tool_DetailsArranger(const std::string &name); virtual ~Tool_DetailsArranger (); virtual StatusCode initialize(); // virtual StatusCode finalize(); - virtual StatusCode arrangeDetails(PanTau::PanTauSeed* inSeed);//, Analysis::TauDetailsContainer* detailsCont); + virtual StatusCode execute(PanTau::PanTauSeed2* inSeed);//, Analysis::TauDetailsContainer* detailsCont); protected: @@ -76,13 +77,14 @@ namespace PanTau { ToolHandle<PanTau::ITool_InformationStore> m_Tool_InformationStore; - void addPanTauDetailToTauJet(PanTauSeed* inSeed, + void addPanTauDetailToTauJet(PanTauSeed2* inSeed, std::string featName, xAOD::TauJetParameters::PanTauDetails detailEnum, PanTauDetailsType detailType) const; - void arrangeScalarDetail(PanTau::PanTauDetails* targetDetails, std::string featName, int featEnumFromPanTauDetails) const; - void arrangeVectorDetail(PanTau::PanTauDetails* targetDetails, std::string featName, int featEnumFromPanTauDetails) const; - void arrangePFOLinks(PanTau::PanTauSeed* inSeed, xAOD::TauJet* tauJet); + + StatusCode arrangePFOLinks(PanTau::PanTauSeed2* inSeed, xAOD::TauJet* tauJet); + + void SetHLVTau(PanTau::PanTauSeed2* inSeed, xAOD::TauJet* tauJet, std::string inputAlg, std::string m_varTypeName_Basic); std::vector< ElementLink< xAOD::PFOContainer > > PreselectNeutralLinks(std::vector< ElementLink<xAOD::PFOContainer> > neutralPFOLinks, xAOD::TauJet* tauJet); @@ -94,7 +96,10 @@ namespace PanTau { void SetNeutralConstituentVectorMasses(std::vector< ElementLink<xAOD::PFOContainer> > neutralPFOLinks, double mass); - std::vector< ElementLink< xAOD::PFOContainer > > CollectConstituentsAsPFOLinks( PanTau::PanTauSeed* inSeed, std::vector< ElementLink< xAOD::PFOContainer > > cellbased_neutralPFOLinks, PanTau::TauConstituent::Type type ); + std::vector< ElementLink< xAOD::PFOContainer > > CollectConstituentsAsPFOLinks( PanTau::PanTauSeed2* inSeed, std::vector< ElementLink< xAOD::PFOContainer > > cellbased_neutralPFOLinks, PanTau::TauConstituent2::Type type ); + + void createPi0Vectors(xAOD::TauJet* tauJet, std::vector<TLorentzVector>& vPi0s, std::vector< std::vector< ElementLink<xAOD::PFOContainer> > > &vec_pi0pfos); + /* std::vector<unsigned int> helper_IndicesOfNeutralsToBePi0(xAOD::TauJet* tauJet, */ /* std::vector< ElementLink<xAOD::PFOContainer> > neutralPFOLinks, */ diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_FeatureExtractor.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_FeatureExtractor.h index e20d877127c87cb15dc86c23d12f84bf93942692..f92309d420a41b0d2807af7e871a3743e5075f78 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_FeatureExtractor.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_FeatureExtractor.h @@ -19,19 +19,19 @@ #include <map> #include <vector> -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ToolHandle.h" +//! ASG +#include "AsgTools/AsgTool.h" +#include "AsgTools/ToolHandle.h" // PanTau -#include "PanTauInterfaces/ITool_FeatureExtractor.h" -#include "PanTauInterfaces/ITool_HelperFunctions.h" -#include "PanTauInterfaces/ITool_InformationStore.h" -#include "PanTauEvent/TauConstituent.h" -#include "PanTauEvent/TauFeature.h" +#include "PanTauAlgs/HelperFunctions.h" +#include "PanTauAlgs/ITool_PanTauTools.h" +#include "PanTauAlgs/ITool_InformationStore.h" +#include "PanTauAlgs/TauConstituent.h" +#include "PanTauAlgs/TauFeature.h" + +//#include "ITrackToVertex/ITrackToVertex.h" -namespace Trk{ - class ITrackToVertexIPEstimator; -} namespace PanTau { @@ -40,56 +40,57 @@ namespace PanTau { @author Christian Limbach @author Sebastian Fleischmann */ -class Tool_FeatureExtractor : public AthAlgTool, virtual public PanTau::ITool_FeatureExtractor { - + class Tool_FeatureExtractor : public asg::AsgTool, virtual public PanTau::ITool_PanTauTools { + + ASG_TOOL_CLASS1(Tool_FeatureExtractor, PanTau::ITool_PanTauTools) public: - Tool_FeatureExtractor(const std::string&,const std::string&,const IInterface*); + Tool_FeatureExtractor(const std::string &name); // virtual ~Tool_FeatureExtractor (); virtual StatusCode initialize(); // virtual StatusCode finalize (); //get the features for an input seed - virtual StatusCode calculateFeatures(PanTau::PanTauSeed* inSeed); + virtual StatusCode execute(PanTau::PanTauSeed2* inSeed); void Log10(); protected: //handle to the helper function - ToolHandle<PanTau::ITool_HelperFunctions> m_Tool_HelperFunctions; + PanTau::HelperFunctions m_HelperFunctions; ToolHandle<PanTau::ITool_InformationStore> m_Tool_InformationStore; - ToolHandle<Trk::ITrackToVertexIPEstimator> m_Tool_TrackToVertexIPEstimator; + //ToolHandle<Reco::ITrackToVertex> m_trackToVertexTool; //map containing different methods to calc seed et std::map<std::string, double> m_Variants_SeedEt; //Function to calculate basic features - StatusCode calculateBasicFeatures(PanTau::PanTauSeed* inSeed); + StatusCode calculateBasicFeatures(PanTau::PanTauSeed2* inSeed); //Function to calculate features for one set of constituents - StatusCode calculateFeatures(PanTau::PanTauSeed* inSeed, + StatusCode calculateFeatures(PanTau::PanTauSeed2* inSeed, int tauConstituentType); //Function to add the 4 momenta of the tau constituents to the features - StatusCode addConstituentMomenta(PanTau::PanTauSeed* inSeed); + StatusCode addConstituentMomenta(PanTau::PanTauSeed2* inSeed); //Function to calculate features based on two sets of constituents - StatusCode addCombinedFeatures(PanTau::PanTauSeed* inSeed); + StatusCode addCombinedFeatures(PanTau::PanTauSeed2* inSeed); //Function to calculate generic jet features - StatusCode addGenericJetFeatures(PanTau::PanTauSeed* inSeed) const; + StatusCode addGenericJetFeatures(PanTau::PanTauSeed2* inSeed) const; //Function to add impact parameter features - StatusCode addImpactParameterFeatures(PanTau::PanTauSeed* inSeed) const; + StatusCode addImpactParameterFeatures(PanTau::PanTauSeed2* inSeed) const; //Function to fill the m_Variants_SeedEt member - void fillVariantsSeedEt(std::vector<PanTau::TauConstituent*> tauConstituents); + void fillVariantsSeedEt(std::vector<PanTau::TauConstituent2*> tauConstituents); //helper function to fill the m_Variants_SeedEt map - void addFeatureWrtSeedEnergy(PanTau::TauFeature* targetMap, + void addFeatureWrtSeedEnergy(PanTau::TauFeature2* targetMap, std::string featName, double numerator, std::map<std::string, double>* denominatorMap) const; diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_FourMomentumCalculator.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_FourMomentumCalculator.h deleted file mode 100644 index bf02a05ad264b83f2a5bdbf18b0884eef519c2ff..0000000000000000000000000000000000000000 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_FourMomentumCalculator.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// Header file for class TauImpactParameterExtractionTool -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// -// Tool to store information needed in PanTau Algorithms -/////////////////////////////////////////////////////////////////// -// limbach@physik.uni-bonn.de -/////////////////////////////////////////////////////////////////// - -#ifndef PANTAUALGS_TOOL_FOURMOMENTUMCALCULATOR_H -#define PANTAUALGS_TOOL_FOURMOMENTUMCALCULATOR_H - - -//! C++ -#include <map> -#include <string> - -//! Gaudi -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ToolHandle.h" - -//! PanTau -#include "PanTauInterfaces/ITool_FourMomentumCalculator.h" -#include "PanTauInterfaces/ITool_InformationStore.h" - - -class eflowObjectContainer; -class StoreGateSvc; - -namespace PanTau { - class PanTauSeed; -} - - -namespace PanTau { - -/** @class Tool_FourMomentumCalculator - Tool to store information needed in PanTau Algorithms - @author Christian Limbach (limbach@physik.uni-bonn.de) -*/ -class Tool_FourMomentumCalculator : public AthAlgTool, virtual public PanTau::ITool_FourMomentumCalculator { - - - - public: - - Tool_FourMomentumCalculator(const std::string&,const std::string&,const IInterface*); - virtual ~Tool_FourMomentumCalculator (); - - virtual StatusCode initialize(); -// virtual StatusCode finalize (); - - virtual StatusCode calculateFourMomentum(PanTau::PanTauSeed* inSeed) const; - - private: - ToolHandle<PanTau::ITool_InformationStore> m_Tool_InformationStore; - std::string m_varTypeName_Basic; - - -}; - - -} // end of namespace PanTau -#endif // PANTAUALGS_TAUIMPACTPARAMETEREXTRACTIONTOOL_H - diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_HelperFunctions.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_HelperFunctions.h deleted file mode 100644 index 672b0baa671d6f0f89a75584d02e7f995c4bf98c..0000000000000000000000000000000000000000 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_HelperFunctions.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef PANTAUALGS_TOOL_HELPERFUNCTIONS -#define PANTAUALGS_TOOL_HELPERFUNCTIONS - -#include "AthenaBaseComps/AthAlgTool.h" -#include "NavFourMom/INavigable4MomentumCollection.h" -#include "PanTauInterfaces/ITool_HelperFunctions.h" - -#include "xAODTau/TauJet.h" -#include "xAODPFlow/PFO.h" - -namespace CLHEP { - class HepLorentzVector; - class Hep3Vector; -} - -namespace PanTau { - class TauConstituent; -} - -// namespace xAOD { -// class PFO; -// class TauJet; -// } - -class TVector3; -class eflowObject; - -namespace PanTau { - -class Tool_HelperFunctions : public AthAlgTool, virtual public PanTau::ITool_HelperFunctions { - - public: - - Tool_HelperFunctions(const std::string&,const std::string&,const IInterface*); - virtual ~Tool_HelperFunctions (); - - - virtual void dumpFourMomentum(CLHEP::HepLorentzVector FourMom) const; - virtual void dumpTauConstituent(PanTau::TauConstituent* tauConstituent) const; - - TauConstituent* getNeutralConstWithLargestAngle(CLHEP::HepLorentzVector charged, - std::vector<PanTau::TauConstituent*> neutral); - - virtual std::string convertNumberToString(double x) const; - -// virtual void vertexCorrection_eflowObjects(TVector3 vertexToCorrectTo, eflowObject* efo); - virtual void vertexCorrection_PFOs(const xAOD::TauJet* tauJet, xAOD::PFO* efo); - - virtual int getBinIndex(std::vector<double> binEdges, double value) const; - - virtual double stddev(double sumOfSquares, double sumOfValues, int numConsts) const; - virtual double deltaRprime(const CLHEP::Hep3Vector& vec1, const CLHEP::Hep3Vector& vec2) const; - - virtual int iPow(int man, int exp); - virtual double ulAngle(double x, double y); - virtual double sign(double a, double b); - virtual std::vector<double> calcThrust(std::vector<TauConstituent*>* tauConstituents, bool& calcIsValid); - virtual void ludbrb(TMatrix* mom, double the, double phi, double bx, double by, double bz); - virtual std::vector<double> calcFWMoments(std::vector<TauConstituent*>* tauConstituents, bool& calcIsValid); - virtual std::vector<double> calcSphericity(std::vector<TauConstituent*>* tauConstituents, bool& calcIsValid); - - }; //end class Tool_HelperFunctions - - -}//end namespace PanTau - - - - -#endif // PANTAUALGS_TOOL_HELPERFUNCTIONS \ No newline at end of file diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_InformationStore.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_InformationStore.h index 9807ce0851fc8fea5c8e4ef5df1bc8666c8a3fab..803ebf2a922e21b8747c0cd13bcc7539ec72e911 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_InformationStore.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_InformationStore.h @@ -3,7 +3,7 @@ */ /////////////////////////////////////////////////////////////////// -// Header file for class TauImpactParameterExtractionTool +// Header file for class Tool_InformationStore /////////////////////////////////////////////////////////////////// // (c) ATLAS Detector software /////////////////////////////////////////////////////////////////// @@ -20,25 +20,12 @@ #include <map> #include <string> -//! Gaudi -#include "AthenaBaseComps/AthAlgTool.h" +//! ASG +#include "AsgTools/AsgTool.h" //! PanTau -#include "PanTauInterfaces/ITool_InformationStore.h" +#include "PanTauAlgs/ITool_InformationStore.h" -namespace Rec { - class TrackParticleContainer; -} - - -class eflowObjectContainer; -class StoreGateSvc; - -// namespace Analysis { -// class TauJetContainer; -// } - -#include "xAODTau/TauJetContainer.h" namespace PanTau { @@ -46,8 +33,9 @@ namespace PanTau { Tool to store information needed in PanTau Algorithms @author Christian Limbach (limbach@physik.uni-bonn.de) */ -class Tool_InformationStore : public AthAlgTool, virtual public PanTau::ITool_InformationStore { + class Tool_InformationStore : public asg::AsgTool, virtual public PanTau::ITool_InformationStore { + ASG_TOOL_CLASS1(Tool_InformationStore, PanTau::ITool_InformationStore) typedef std::map<std::string, std::string> MapString; typedef std::map<std::string, std::vector<std::string> > MapVecString; @@ -59,13 +47,12 @@ class Tool_InformationStore : public AthAlgTool, virtual public PanTau::ITool_In public: - Tool_InformationStore(const std::string&,const std::string&,const IInterface*); + Tool_InformationStore(const std::string &name); virtual ~Tool_InformationStore (); virtual StatusCode initialize(); // virtual StatusCode finalize (); - virtual StatusCode updateInformation(std::string inputAlg); virtual StatusCode getInfo_Int(std::string varName, int& value); virtual StatusCode getInfo_Double(std::string varName, double& value); virtual StatusCode getInfo_VecDouble(std::string varName, std::vector<double>& value); @@ -74,13 +61,7 @@ class Tool_InformationStore : public AthAlgTool, virtual public PanTau::ITool_In StatusCode dumpMaps() const; - void checkEFOContainer(const eflowObjectContainer* inputContainer, eflowObjectContainer* outputContainer); - - virtual const eflowObjectContainer* getContainer_eflowRec() const; -// virtual const Analysis::TauJetContainer* getContainer_TauRec() const; - virtual const xAOD::TauJetContainer* getContainer_TauRec() const; - virtual const Rec::TrackParticleContainer* getContainer_TrackParticle() const; - + private: //! named strings, ints etc... for configuration @@ -90,20 +71,13 @@ class Tool_InformationStore : public AthAlgTool, virtual public PanTau::ITool_In MapDouble m_Infos_Double; MapVecDouble m_Infos_VecDouble; - StoreGateSvc* m_sgSvc; - //!other information // input containers std::string m_Name_Container_eflowRec; std::string m_Name_Container_TauRec; std::string m_Name_Container_Tracks; - eflowObjectContainer* m_Container_eflowRec; - //const eflowObjectContainer* m_Container_eflowRecFromSG; -// const Analysis::TauJetContainer* m_Container_TauRec; - const xAOD::TauJetContainer* m_Container_TauRec; - const Rec::TrackParticleContainer* m_Container_TrackParticle; - + }; diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_InputConverter.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_InputConverter.h index fa406c31fb6d216439099e5e066e12b876d5b281..677a41a2c62ae43c054de96d90f30b95217cfc63 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_InputConverter.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_InputConverter.h @@ -9,81 +9,63 @@ #include <vector> #include <string> -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ToolHandle.h" -#include "PanTauInterfaces/ITool_InformationStore.h" -#include "PanTauInterfaces/ITool_HelperFunctions.h" -#include "PanTauInterfaces/ITool_InputConverter.h" +//! 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" -namespace Analysis { - class TauPi0Cluster; - class TauJet; -} - namespace Rec { class TrackParticle; } namespace PanTau { - class TauConstituent; + class TauConstituent2; } -class eflowObject; - namespace PanTau { -class Tool_InputConverter : public AthAlgTool, virtual public PanTau::ITool_InputConverter { + class Tool_InputConverter : public asg::AsgTool, virtual public PanTau::ITool_InputConverter { + + ASG_TOOL_CLASS1(Tool_InputConverter, PanTau::ITool_InputConverter) public: - Tool_InputConverter(const std::string&,const std::string&,const IInterface*); + Tool_InputConverter(const std::string &name); virtual ~Tool_InputConverter (); virtual StatusCode initialize(); // virtual StatusCode finalize(); - virtual StatusCode ConvertToTauConstituent(xAOD::PFO* pfo, - PanTau::TauConstituent* &tauConstituent, - const xAOD::TauJet* tauJet, - std::string algName) const; + virtual StatusCode ConvertToTauConstituent2(xAOD::PFO* pfo, + PanTau::TauConstituent2* &tauConstituent, + const xAOD::TauJet* tauJet) const; protected: //member variables ToolHandle<PanTau::ITool_InformationStore> m_Tool_InformationStore; - ToolHandle<PanTau::ITool_HelperFunctions> m_Tool_HelperFunctions; virtual bool passesPreselectionEnergy(double itsEnergy) const; - //cluster based converter -// virtual StatusCode ConvertToTauConstituent(eflowObject* efo, TauConstituent* &tauConstituent) const; - int m_Config_UsePionMass; int m_Config_TauConstituents_UseShrinkingCone; double m_Config_TauConstituents_Types_DeltaRCore; double m_Config_TauConstituents_PreselectionMinEnergy; - int m_Config_eflowRec_UseMomentumAsEnergy; - double m_Config_eflowRec_MinBDTValue_Pi0Neut; - std::vector<double> m_Config_CellBased_BinEdges_Eta; std::vector<double> m_Config_CellBased_EtaBinned_Pi0MVACut_1prong; std::vector<double> m_Config_CellBased_EtaBinned_Pi0MVACut_3prong; - - std::vector<double> m_Config_eflowRec_BinEdges_Eta; - std::vector<double> m_Config_eflowRec_EtaBinned_Pi0MVACut_1prong; - std::vector<double> m_Config_eflowRec_EtaBinned_Pi0MVACut_3prong; - std::vector<double> m_Config_eflowRec_Selection_Pi0Neut_EtaBinned_EtCut_1prong; - std::vector<double> m_Config_eflowRec_Selection_Pi0Neut_EtaBinned_EtCut_3prong; - + }; //end class ConstituentGetter @@ -92,4 +74,4 @@ class Tool_InputConverter : public AthAlgTool, virtual public PanTau::ITool_Inpu -#endif // PANTAUALGS_TOOL_INPUTCONVERTER \ No newline at end of file +#endif // PANTAUALGS_TOOL_INPUTCONVERTER diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_ModeDiscriminator.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_ModeDiscriminator.h index 370b5bd428319313a4bbc731b483d64d35b241d5..6fcbaa6601d42736552cf9e5e74fb961fb585af4 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_ModeDiscriminator.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_ModeDiscriminator.h @@ -15,14 +15,14 @@ #ifndef PANTAUALGS_TOOL_MODEDISCRIMINATOR_H #define PANTAUALGS_TOOL_MODEDISCRIMINATOR_H -//! Gaudi -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ToolHandle.h" +//! ASG +#include "AsgTools/AsgTool.h" +#include "AsgTools/ToolHandle.h" //! PanTau -#include "PanTauInterfaces/ITool_ModeDiscriminator.h" -#include "PanTauInterfaces/ITool_InformationStore.h" -#include "PanTauInterfaces/ITool_HelperFunctions.h" +#include "PanTauAlgs/HelperFunctions.h" +#include "PanTauAlgs/ITool_ModeDiscriminator.h" +#include "PanTauAlgs/ITool_InformationStore.h" //! C++ #include <vector> @@ -34,7 +34,7 @@ namespace TMVA{ } namespace PanTau { - class PanTauSeed; + class PanTauSeed2; } @@ -46,34 +46,34 @@ namespace PanTau { @author Sebastian Fleischmann @author Christian Limbach <limbach@physik.uni-bonn.de> */ - class Tool_ModeDiscriminator : public AthAlgTool, virtual public PanTau::ITool_ModeDiscriminator { + class Tool_ModeDiscriminator : public asg::AsgTool, virtual public PanTau::ITool_ModeDiscriminator { + + ASG_TOOL_CLASS1(Tool_ModeDiscriminator, PanTau::ITool_ModeDiscriminator) public: - Tool_ModeDiscriminator(const std::string&,const std::string&,const IInterface*); + Tool_ModeDiscriminator(const std::string &name); virtual ~Tool_ModeDiscriminator (); virtual StatusCode initialize(); virtual StatusCode finalize (); - virtual double getResponse(PanTau::PanTauSeed* inSeed, bool& isOK); - virtual double getModeLikeliness(PanTau::PanTauSeed* inSeed, bool& wasSuccessful); + virtual double getResponse(PanTau::PanTauSeed2* inSeed, bool& isOK); private: - void updateReaderVariables(PanTau::PanTauSeed* inSeed); + void updateReaderVariables(PanTau::PanTauSeed2* inSeed); std::string m_Name_InputAlg; std::string m_Name_ModeCase; ToolHandle<PanTau::ITool_InformationStore> m_Tool_InformationStore; - ToolHandle<PanTau::ITool_HelperFunctions> m_Tool_HelperFunctions; + PanTau::HelperFunctions m_HelperFunctions; std::vector<TMVA::Reader*> m_TMVA_ReaderList; std::vector<double> m_BinEdges_Pt; std::string m_ReaderOption; std::string m_MethodName; -// std::vector<std::string> m_List_WeightFiles; std::vector<std::string> m_List_BDTVariableNames; std::vector<float> m_List_BDTVariableValues; std::vector<double> m_List_BDTVariableDefaultValues; diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_TauConstituentGetter.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_TauConstituentGetter.h index 850b1aff7e962b50ee8b60633af8d5c649ee5353..7d84d28057df7da008978156c3182d9b7c0c6915 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_TauConstituentGetter.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_TauConstituentGetter.h @@ -9,22 +9,24 @@ #include <vector> #include <string> -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ToolHandle.h" -#include "PanTauInterfaces/ITool_InformationStore.h" -#include "PanTauInterfaces/ITool_HelperFunctions.h" -#include "PanTauInterfaces/ITool_TauConstituentGetter.h" -#include "PanTauInterfaces/ITool_InputConverter.h" +//! ASG +#include "AsgTools/AsgTool.h" +#include "AsgTools/ToolHandle.h" + +#include "PanTauAlgs/HelperFunctions.h" +#include "PanTauAlgs/ITool_InformationStore.h" +#include "PanTauAlgs/ITool_TauConstituentGetter.h" +#include "PanTauAlgs/ITool_InputConverter.h" //! xAOD EDM #include "xAODTau/TauJet.h" -namespace Analysis { - class TauJet; -} +//namespace Analysis { +// class TauJet; +//} namespace PanTau { - class TauConstituent; + class TauConstituent2; } @@ -33,11 +35,13 @@ namespace PanTau { namespace PanTau { -class Tool_TauConstituentGetter : public AthAlgTool, virtual public PanTau::ITool_TauConstituentGetter { +class Tool_TauConstituentGetter : public asg::AsgTool, virtual public PanTau::ITool_TauConstituentGetter { + ASG_TOOL_CLASS1(Tool_TauConstituentGetter, PanTau::ITool_TauConstituentGetter) + public: - Tool_TauConstituentGetter(const std::string&,const std::string&,const IInterface*); + Tool_TauConstituentGetter(const std::string &name); virtual ~Tool_TauConstituentGetter (); virtual StatusCode initialize(); @@ -45,21 +49,17 @@ class Tool_TauConstituentGetter : public AthAlgTool, virtual public PanTau::IToo virtual StatusCode GetTauConstituents(//const Analysis::TauJet*, const xAOD::TauJet* tauJet, - std::vector<TauConstituent*>& outputList, + std::vector<TauConstituent2*>& outputList, std::string algName) const; protected: //member variables + PanTau::HelperFunctions m_HelperFunctions; ToolHandle<PanTau::ITool_InformationStore> m_Tool_InformationStore; - ToolHandle<PanTau::ITool_HelperFunctions> m_Tool_HelperFunctions; ToolHandle<PanTau::ITool_InputConverter> m_Tool_InputConverter; - double m_eflowRec_Assoc_DeltaR; - - - }; //end class ConstituentGetter @@ -69,4 +69,4 @@ class Tool_TauConstituentGetter : public AthAlgTool, virtual public PanTau::IToo -#endif // PANTAUALGS_TOOL_TAUCONSTITUENTGETTER \ No newline at end of file +#endif // PANTAUALGS_TOOL_TAUCONSTITUENTGETTER diff --git a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_TauConstituentSelector.h b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_TauConstituentSelector.h index 0222f49f89d7b4a7cf45bd8ecb6d90ef754e8929..1a9f1edfe3e1dcc0be6f6a2dec57599ad63075a5 100644 --- a/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_TauConstituentSelector.h +++ b/Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/Tool_TauConstituentSelector.h @@ -9,42 +9,46 @@ #include <vector> #include <string> -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ToolHandle.h" -#include "PanTauInterfaces/ITool_InformationStore.h" -#include "PanTauInterfaces/ITool_TauConstituentSelector.h" +//! ASG +#include "AsgTools/AsgTool.h" +#include "AsgTools/ToolHandle.h" -#include "PanTauEvent/TauConstituent.h" +#include "PanTauAlgs/ITool_InformationStore.h" +#include "PanTauAlgs/ITool_TauConstituentSelector.h" + +#include "PanTauAlgs/TauConstituent.h" namespace PanTau { -class Tool_TauConstituentSelector : public AthAlgTool, virtual public PanTau::ITool_TauConstituentSelector { - +class Tool_TauConstituentSelector : public asg::AsgTool, virtual public PanTau::ITool_TauConstituentSelector { + + ASG_TOOL_CLASS1(Tool_TauConstituentSelector, PanTau::ITool_TauConstituentSelector) + public: - Tool_TauConstituentSelector(const std::string&,const std::string&,const IInterface*); + Tool_TauConstituentSelector(const std::string &name); virtual ~Tool_TauConstituentSelector (); virtual StatusCode initialize(); // virtual StatusCode finalize(); - virtual StatusCode SelectTauConstituents( std::vector<TauConstituent*> inputList, - std::vector<TauConstituent*>& outputList) const; + virtual StatusCode SelectTauConstituents( std::vector<TauConstituent2*> inputList, + std::vector<TauConstituent2*>& outputList) const; protected: - 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 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 double getEtCut(double eta, PanTau::TauConstituent::Type constituentType) const; + virtual double getEtCut(double eta, PanTau::TauConstituent2::Type constituentType) const; //member variables diff --git a/Reconstruction/PanTau/PanTauAlgs/src/Tool_HelperFunctions.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx similarity index 74% rename from Reconstruction/PanTau/PanTauAlgs/src/Tool_HelperFunctions.cxx rename to Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx index b6e8bfe34193254ffd7b400a75ebc931abe62728..870bcc2e9a5bd145998cfe7d781bd3eadfa17554 100644 --- a/Reconstruction/PanTau/PanTauAlgs/src/Tool_HelperFunctions.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx @@ -3,28 +3,19 @@ */ -//! Gaudi includes -#include "AthenaKernel/errorcheck.h" - //! PanTau includes -#include "PanTauAlgs/Tool_HelperFunctions.h" -#include "PanTauEvent/TauConstituent.h" +#include "PanTauAlgs/HelperFunctions.h" +#include "PanTauAlgs/TauConstituent.h" #include "xAODPFlow/PFO.h" #include "xAODTau/TauJet.h" #include "xAODTracking/Vertex.h" #include "xAODTracking/VertexContainer.h" -#include "CLHEP/Vector/LorentzVector.h" -// #include "eflowEvent/eflowObject.h" - -// #include "GeoPrimitives/GeoPrimitives.h" -// #include "CLHEP/Geometry/Vector3D.h" - //! ROOT includes -#include "CLHEP/Vector/ThreeVector.h" #include "Math/SpecFuncMathMore.h" #include "TMath.h" #include "TRandom.h" +#include "TLorentzVector.h" #include "TVector3.h" #include "TMatrixDSym.h" #include "TVectorD.h" @@ -34,49 +25,34 @@ #include <sstream> #include <vector> #include <cmath> + - - -PanTau::Tool_HelperFunctions::Tool_HelperFunctions( - const std::string& ty, - const std::string& na, - const IInterface* pa ) : - AthAlgTool(ty,na,pa) -{ - declareInterface<ITool_HelperFunctions>(this); -} - -PanTau::Tool_HelperFunctions::~Tool_HelperFunctions() { -} - - - -void PanTau::Tool_HelperFunctions::dumpFourMomentum(CLHEP::HepLorentzVector FourMom) const { - ATH_MSG_DEBUG("\t\tFourMomentum: pT, Eta, Phi, m: " << FourMom.perp() << " / " << FourMom.eta() << " / " << FourMom.phi() << " / " << FourMom.m()); +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::Tool_HelperFunctions::dumpTauConstituent(PanTau::TauConstituent* tauConstituent) const { - CLHEP::HepLorentzVector hlv_TauConst = tauConstituent->hlv(); - ATH_MSG_DEBUG("\t\tTauConstituent has charge " << tauConstituent->getCharge() << " and types " << tauConstituent->getTypeNameString() << " with BDT Value " << tauConstituent->getBDTValue()); - ATH_MSG_DEBUG("\t\tTauConstituent has pT, Eta, Phi, m: " << hlv_TauConst.perp() << " / " << hlv_TauConst.eta() << " / " << hlv_TauConst.phi() << " / " << hlv_TauConst.m()); +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::TauConstituent* PanTau::Tool_HelperFunctions::getNeutralConstWithLargestAngle( CLHEP::HepLorentzVector charged, - std::vector<PanTau::TauConstituent*> neutral) { +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++) { - CLHEP::HepLorentzVector hlv_CurNeut = neutral[iNeut]->hlv(); - double angle = charged.angle(hlv_CurNeut.vect()); + TLorentzVector tlv_CurNeut = neutral[iNeut]->p4(); + double angle = charged.Angle(tlv_CurNeut.Vect()); if(angle > angle_Neutral) { angle_Neutral = angle; idx_Neutral = iNeut; @@ -88,37 +64,14 @@ PanTau::TauConstituent* PanTau::Tool_HelperFunctions::getNeutralConstWithLargest -std::string PanTau::Tool_HelperFunctions::convertNumberToString(double x) const { +std::string PanTau::HelperFunctions::convertNumberToString(double x) const { std::stringstream tmpStream; tmpStream << x; return tmpStream.str(); } -// void PanTau::Tool_HelperFunctions::vertexCorrection_eflowObjects(TVector3 vertexToCorrectTo, eflowObject* efo){ -// -// double clusterEta = efo->eta(); -// double clusterPhi = efo->phi(); -// double centerMag = efo->getCenterMag(); -// -// double radius = centerMag/cosh(clusterEta); -// -// double EtaVertexCorr = 0.0; -// double PhiVertexCorr = 0.0; -// -// if (radius > 1.0 && centerMag > 1e-3){ -// EtaVertexCorr = (-vertexToCorrectTo.Z()/cosh(clusterEta) + (vertexToCorrectTo.X()*cos(clusterPhi) + vertexToCorrectTo.Y()*sin(clusterPhi))*tanh(clusterEta))/radius; -// PhiVertexCorr = (vertexToCorrectTo.X()*sin(clusterPhi) - vertexToCorrectTo.Y()*cos(clusterPhi))/radius; -// } -// -// clusterEta += EtaVertexCorr; -// clusterPhi += PhiVertexCorr; -// -// efo->set_eta(clusterEta); -// efo->set_phi(clusterPhi); -// - -void PanTau::Tool_HelperFunctions::vertexCorrection_PFOs(const xAOD::TauJet* tauJet, xAOD::PFO* pfo) { +void PanTau::HelperFunctions::vertexCorrection_PFOs(const xAOD::TauJet* tauJet, xAOD::PFO* pfo) const{ const xAOD::Vertex* tauVertex = tauJet->vertexLink().cachedElement(); if(tauVertex == 0) { @@ -151,7 +104,7 @@ void PanTau::Tool_HelperFunctions::vertexCorrection_PFOs(const xAOD::TauJet* tau -int PanTau::Tool_HelperFunctions::getBinIndex(std::vector<double> binEdges, double value) const { +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]; @@ -167,7 +120,7 @@ int PanTau::Tool_HelperFunctions::getBinIndex(std::vector<double> binEdges, doub -double PanTau::Tool_HelperFunctions::stddev(double sumOfSquares, double sumOfValues, int numConsts) const { +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 @@ -181,16 +134,16 @@ double PanTau::Tool_HelperFunctions::stddev(double sumOfSquares, double sumOfVal -double PanTau::Tool_HelperFunctions::deltaRprime(const CLHEP::Hep3Vector& vec1, const CLHEP::Hep3Vector& vec2) const { - const double a = vec1.deltaPhi(vec2); - const double b = vec1.polarAngle(vec2); +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; } -int PanTau::Tool_HelperFunctions::iPow(int man, int exp) { +int PanTau::HelperFunctions::iPow(int man, int exp) const { int ans = 1; for (int k = 0; k < exp; k++) { ans = ans * man; @@ -200,7 +153,7 @@ int PanTau::Tool_HelperFunctions::iPow(int man, int exp) { -double PanTau::Tool_HelperFunctions::ulAngle(double x, double y) { +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) { @@ -221,7 +174,7 @@ double PanTau::Tool_HelperFunctions::ulAngle(double x, double y) { -double PanTau::Tool_HelperFunctions::sign(double a, double b) { +double PanTau::HelperFunctions::sign(double a, double b) const { if (b < 0) { return -TMath::Abs(a); } else { @@ -232,7 +185,7 @@ double PanTau::Tool_HelperFunctions::sign(double a, double b) { // JetProperties Thrust: code stolen from ftp://ftp.slac.stanford.edu/groups/lcd/Physics_tools/ (by M. Iwasaki) -std::vector<double> PanTau::Tool_HelperFunctions::calcThrust(std::vector<TauConstituent*>* tauConstituents, bool& calcIsValid) { +std::vector<double> PanTau::HelperFunctions::calcThrust(std::vector<TauConstituent2*>* tauConstituents, bool& calcIsValid) const{ TRandom random; int maxpart = 1000; double dDeltaThPower(0); @@ -261,18 +214,18 @@ std::vector<double> PanTau::Tool_HelperFunctions::calcThrust(std::vector<TauCons Double_t dThrust[4]; - for (std::vector<TauConstituent*>::iterator p4iter = tauConstituents->begin(); p4iter != tauConstituents->end(); p4iter++) { - CLHEP::Hep3Vector p = (*p4iter)->hlv().vect(); + for (std::vector<TauConstituent2*>::iterator p4iter = tauConstituents->begin(); p4iter != tauConstituents->end(); p4iter++) { + TVector3 p = (*p4iter)->p4().Vect(); if (np >= maxpart) { calcIsValid = false; return std::vector<double>(0); } - mom(np, 1) = p.x(); - mom(np, 2) = p.y(); - mom(np, 3) = p.z(); - mom(np, 4) = p.mag(); + mom(np, 1) = p.X(); + mom(np, 2) = p.Y(); + mom(np, 3) = p.Z(); + mom(np, 4) = p.Mag(); if (TMath::Abs(dDeltaThPower) <= 0.001) { mom(np, 5) = 1.0; @@ -467,8 +420,8 @@ std::vector<double> PanTau::Tool_HelperFunctions::calcThrust(std::vector<TauCons dAxes(i7 + 1, j) = temp(i7, j); } } - CLHEP::Hep3Vector thrustAxis(dAxes(1, 1), dAxes(1, 2), dAxes(1, 3)); - CLHEP::Hep3Vector majorAxis(dAxes(2, 1), dAxes(2, 2), dAxes(2, 3)); + TVector3 thrustAxis(dAxes(1, 1), dAxes(1, 2), dAxes(1, 3)); + TVector3 majorAxis(dAxes(2, 1), dAxes(2, 2), dAxes(2, 3)); std::vector<double> values(0); values.push_back(dThrust[1]); values.push_back(dThrust[2]); @@ -479,12 +432,12 @@ std::vector<double> PanTau::Tool_HelperFunctions::calcThrust(std::vector<TauCons // JetProperties ludbrb: This is used in calcThrust -void PanTau::Tool_HelperFunctions::ludbrb(TMatrix* mom, +void PanTau::HelperFunctions::ludbrb(TMatrix* mom, double the, double phi, double bx, double by, - double bz) { + double bz) const { // Ignore "zeroth" elements in rot,pr,dp. // Trying to use physics-like notation. TMatrix rot(4, 4); @@ -541,7 +494,7 @@ void PanTau::Tool_HelperFunctions::ludbrb(TMatrix* mom, // JetProperties FoxWolfram Moments: See here: http://cepa.fnal.gov/psm/simulation/mcgen/lund/pythia_manual/pythia6.3/pythia6301/node215.html -std::vector<double> PanTau::Tool_HelperFunctions::calcFWMoments(std::vector<TauConstituent*>* tauConstituents, bool& calcIsValid) { +std::vector<double> PanTau::HelperFunctions::calcFWMoments(std::vector<TauConstituent2*>* tauConstituents, bool& calcIsValid) const{ const unsigned int nMomentsToCalc = 5; std::vector<double> fwValues = std::vector<double>(nMomentsToCalc, -9.999); @@ -553,22 +506,22 @@ std::vector<double> PanTau::Tool_HelperFunctions::calcFWMoments(std::vector<TauC } double jetE = 0.; - for (std::vector<TauConstituent*>::iterator p4iter1 = tauConstituents->begin(); p4iter1 != tauConstituents->end(); p4iter1++) { - CLHEP::Hep3Vector p1 = (*p4iter1)->hlv().vect(); - jetE += (*p4iter1)->hlv().e(); + for (std::vector<TauConstituent2*>::iterator p4iter1 = tauConstituents->begin(); p4iter1 != tauConstituents->end(); p4iter1++) { + TVector3 p1 = (*p4iter1)->p4().Vect(); + jetE += (*p4iter1)->p4().E(); - for (std::vector<TauConstituent*>::iterator p4iter2 = tauConstituents->begin(); p4iter2 != tauConstituents->end(); p4iter2++) { + for (std::vector<TauConstituent2*>::iterator p4iter2 = tauConstituents->begin(); p4iter2 != tauConstituents->end(); p4iter2++) { - CLHEP::Hep3Vector p2 = (*p4iter2)->hlv().vect(); + TVector3 p2 = (*p4iter2)->p4().Vect(); //find angle between vectors - double angle = (double) p1.angle(p2) ; + double angle = (double) p1.Angle(p2) ; //new calculation for(unsigned int iMoment=0; iMoment<nMomentsToCalc; iMoment++) { - if(p1.mag() == 0) continue; //curMoment will be 0 and not change anything in this case - if(p2.mag() == 0) continue; // - double curMoment = (p1.mag() * p2.mag() * ROOT::Math::legendre( iMoment, TMath::Cos(angle))); + if(p1.Mag() == 0) continue; //curMoment will be 0 and not change anything in this case + if(p2.Mag() == 0) continue; // + double curMoment = (p1.Mag() * p2.Mag() * ROOT::Math::legendre( iMoment, TMath::Cos(angle))); fwValues[iMoment] += curMoment; }//end loop over moments }//end loop over second particle @@ -607,7 +560,7 @@ std::vector<double> PanTau::Tool_HelperFunctions::calcFWMoments(std::vector<TauC //! ////////////////////////////////////////// /// JetProperties: Sphericity //! ////////////////////////////////////////// -std::vector<double> PanTau::Tool_HelperFunctions::calcSphericity(std::vector<TauConstituent*>* tauConstituents, bool& calcIsValid) { +std::vector<double> PanTau::HelperFunctions::calcSphericity(std::vector<TauConstituent2*>* tauConstituents, bool& calcIsValid) const{ double sphTensor[9]; double norm = 0.; @@ -616,19 +569,19 @@ std::vector<double> PanTau::Tool_HelperFunctions::calcSphericity(std::vector<Tau } - for (std::vector<TauConstituent*>::iterator p4iter = tauConstituents->begin(); p4iter != tauConstituents->end(); p4iter++) { + for (std::vector<TauConstituent2*>::iterator p4iter = tauConstituents->begin(); p4iter != tauConstituents->end(); p4iter++) { - sphTensor[0] += (*p4iter)->px() * (*p4iter)->px(); - sphTensor[1] += (*p4iter)->px() * (*p4iter)->py(); - sphTensor[2] += (*p4iter)->px() * (*p4iter)->pz(); - sphTensor[3] += (*p4iter)->py() * (*p4iter)->px(); - sphTensor[4] += (*p4iter)->py() * (*p4iter)->py(); - sphTensor[5] += (*p4iter)->py() * (*p4iter)->pz(); - sphTensor[6] += (*p4iter)->pz() * (*p4iter)->px(); - sphTensor[7] += (*p4iter)->pz() * (*p4iter)->py(); - sphTensor[8] += (*p4iter)->pz() * (*p4iter)->pz(); + sphTensor[0] += (*p4iter)->p4().Px() * (*p4iter)->p4().Px(); + sphTensor[1] += (*p4iter)->p4().Px() * (*p4iter)->p4().Py(); + sphTensor[2] += (*p4iter)->p4().Px() * (*p4iter)->p4().Pz(); + sphTensor[3] += (*p4iter)->p4().Py() * (*p4iter)->p4().Px(); + sphTensor[4] += (*p4iter)->p4().Py() * (*p4iter)->p4().Py(); + sphTensor[5] += (*p4iter)->p4().Py() * (*p4iter)->p4().Pz(); + sphTensor[6] += (*p4iter)->p4().Pz() * (*p4iter)->p4().Px(); + sphTensor[7] += (*p4iter)->p4().Pz() * (*p4iter)->p4().Py(); + sphTensor[8] += (*p4iter)->p4().Pz() * (*p4iter)->p4().Pz(); - norm += (*p4iter)->hlv().vect() * (*p4iter)->hlv().vect(); + norm += (*p4iter)->p4().Vect() * (*p4iter)->p4().Vect(); } diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/LinkDef.h b/Reconstruction/PanTau/PanTauAlgs/Root/LinkDef.h new file mode 100644 index 0000000000000000000000000000000000000000..3415207b462f3317542c4b0a48f6de27a076efa2 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/Root/LinkDef.h @@ -0,0 +1,65 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef __PANTAUALGS__ +#define __PANTAUALGS__ + +#include "PanTauAlgs/PanTauSeed.h" +#include "PanTauAlgs/TauClassificationTypes.h" +/* #include "PanTauAlgs/TauConstituent.h" */ +#include "PanTauAlgs/TauFeature.h" + +#include "PanTauAlgs/ITool_PanTauTools.h" +#include "PanTauAlgs/ITool_InformationStore.h" +#include "PanTauAlgs/ITool_InputConverter.h" +#include "PanTauAlgs/ITool_ModeDiscriminator.h" +#include "PanTauAlgs/ITool_TauConstituentGetter.h" +#include "PanTauAlgs/ITool_TauConstituentSelector.h" + +#include "PanTauAlgs/PanTauProcessor.h" +#include "PanTauAlgs/Tool_DecayModeDeterminator.h" +#include "PanTauAlgs/Tool_DetailsArranger.h" +#include "PanTauAlgs/Tool_FeatureExtractor.h" +#include "PanTauAlgs/Tool_InformationStore.h" +#include "PanTauAlgs/Tool_InputConverter.h" +#include "PanTauAlgs/Tool_ModeDiscriminator.h" +#include "PanTauAlgs/Tool_TauConstituentGetter.h" +#include "PanTauAlgs/Tool_TauConstituentSelector.h" + +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ namespace PanTau; + +#pragma link C++ class PanTau::PanTauSeed2; +/* #pragma link C++ class PanTau::TauConstituent; */ +#pragma link C++ class PanTau::TauFeature2; + +#pragma link C++ class PanTau::ITool_PanTauTools; +#pragma link C++ class PanTau::ITool_InformationStore; +#pragma link C++ class PanTau::ITool_InputConverter; +#pragma link C++ class PanTau::ITool_ModeDiscriminator; +#pragma link C++ class PanTau::ITool_TauConstituentGetter; +#pragma link C++ class PanTau::ITool_TauConstituentSelector; + +#pragma link C++ class PanTau::Tool_DecayModeDeterminator; +#pragma link C++ class PanTau::Tool_DetailsArranger; +#pragma link C++ class PanTau::Tool_FeatureExtractor; +#pragma link C++ class PanTau::Tool_InformationStore; +#pragma link C++ class PanTau::Tool_InputConverter; +#pragma link C++ class PanTau::Tool_ModeDiscriminator; +#pragma link C++ class PanTau::Tool_TauConstituentGetter; +#pragma link C++ class PanTau::Tool_TauConstituentSelector; + +#pragma link C++ enum PanTau::TauClassificationTypes::TruthTauType; +#pragma link C++ enum PanTau::TauClassificationTypes::SeedTauType; +#pragma link C++ enum PanTau::TauClassificationTypes::PanTauRecoMode; + +//#pragma link C++ enum TauID::Types::MethodType; + +#endif +#endif diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/PanTauProcessor.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/PanTauProcessor.cxx new file mode 100644 index 0000000000000000000000000000000000000000..536d9eeb8e1afd0f650be01cd7ee3e8337db34e6 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/Root/PanTauProcessor.cxx @@ -0,0 +1,274 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// PanTauProcessor.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +//! 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/PanTauSeed.h" + + + +/// ////////////////////////////////////////////////////////// +/// Constructor +/// ////////////////////////////////////////////////////////// +PanTau::PanTauProcessor::PanTauProcessor(const std::string& name) + : TauRecToolBase(name), + m_Name_InputAlg(""), + + //Initialise members for tools + m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore"), + m_Tool_TauConstituentGetter("PanTau::Tool_TauConstituentGetter/Tool_TauConstituentGetter"), + m_Tool_TauConstituentSelector("PanTau::Tool_TauConstituentSelector/Tool_TauConstituentSelector"), + m_Tool_FeatureExtractor("PanTau::Tool_FeatureExtractor/Tool_FeatureExtractor"), + m_Tool_DecayModeDeterminator("PanTau::Tool_DecayModeDeterminator/Tool_DecayModeDeterminator"), + m_Tool_DetailsArranger("PanTau::Tool_DetailsArranger/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"); +} + + + +/// ////////////////////////////////////////////////////////// +/// Destructor +/// ////////////////////////////////////////////////////////// +PanTau::PanTauProcessor::~PanTauProcessor() { +} + + + +/// ////////////////////////////////////////////////////////// +/// Initialize +/// ////////////////////////////////////////////////////////// +StatusCode PanTau::PanTauProcessor::initialize() { + + ATH_MSG_INFO(name() << " initialize()"); + + // 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->dumpMaps() ); + + 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 + + + +/// ////////////////////////////////////////////////////////// +/// Finalize +/// ////////////////////////////////////////////////////////// +StatusCode PanTau::PanTauProcessor::finalize() { + return StatusCode::SUCCESS; +}//end finalize + + + +StatusCode PanTau::PanTauProcessor::eventInitialize(){ + xAOD::ParticleContainer* pi0Container = new xAOD::ParticleContainer(); + xAOD::ParticleAuxContainer* pi0AuxContainer = new xAOD::ParticleAuxContainer(); + pi0Container->setStore(pi0AuxContainer); + ATH_CHECK(evtStore()->record(pi0Container, "finalTauPi0s")); + ATH_CHECK(evtStore()->record(pi0AuxContainer, "finalTauPi0sAux.")); + + return StatusCode::SUCCESS; +} + +/// ////////////////////////////////////////////////////////// +/// Execute +/// ////////////////////////////////////////////////////////// +StatusCode PanTau::PanTauProcessor::execute(xAOD::TauJet& pTau) { + + ATH_MSG_DEBUG("==========================================================="); + ATH_MSG_DEBUG("=== PanTau::PanTauProcessor --- Seed Creation ==="); + ATH_MSG_DEBUG("==========================================================="); + ATH_MSG_DEBUG("Executing PanTau::PanTauProcessor::execute() for input alg: " << m_Name_InputAlg); + + //get the current TauJet + xAOD::TauJet* curTauJet = &pTau; + ATH_MSG_DEBUG("===> Tau: "); + //curTauJet->dump(); + + //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; + } + + + // 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); + + 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(hasCoreConstituents == false) { + pantauSeed_TechnicalQuality.at((int)PanTau::PanTauSeed2::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, + curTauJet, + l_List_SelectedTauConstituents, + l_List_TauConstituents, pantauSeed_TechnicalQuality); + + unsigned int nPi0LinksCellBased = curTauJet->protoPi0PFOLinks().size(); + curPanTauSeed->makePrivateStore(); + ATH_MSG_DEBUG("Created new PanTauSeed2 at " << curPanTauSeed << " with proto mode " << curPanTauSeed->getDecayModeBySubAlg() << " and nPi0 CellBased = " << nPi0LinksCellBased); + + // Get the features for this PanTauSeed + ATH_MSG_DEBUG("Calculate features for this PanTauSeed"); + ATH_CHECK(m_Tool_FeatureExtractor->execute(curPanTauSeed) ); + + //ATH_MSG_VERBOSE("Dumping features of finalized PanTauSeed2 =========================================="); + //curPanTauSeed->getFeatures()->dump(m_log, MSG::VERBOSE); + //ATH_MSG_VERBOSE("Dumped features of finalized PanTauSeed2 ==========================================="); + + ATH_MSG_DEBUG("Finished adding input taus as PantauSeeds"); + + + + //! ======================================================================================= + //! Finalize the seeds + ATH_MSG_DEBUG("==========================================================="); + ATH_MSG_DEBUG("=== PanTau::PanTauProcessor --- Seed Finalization ==="); + ATH_MSG_DEBUG("==========================================================="); + + // 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_MSG_DEBUG("calling decay mode determinator for valid 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) ); + + //that's it :) + ATH_MSG_DEBUG("PanTau::PanTauProcessor for input alg" << m_Name_InputAlg << " was successful!"); + + delete curPanTauSeed; + return StatusCode::SUCCESS; +}//end of execute + + + +void PanTau::PanTauProcessor::fillDefaultValuesToTau(xAOD::TauJet* tauJet) { + + tauJet->setP4(xAOD::TauJetParameters::PanTauCellBased, -1111., -1111., -1111., -1111.); + + //charged + std::vector< ElementLink< xAOD::PFOContainer > > chrgPFOLinks = tauJet->protoChargedPFOLinks(); + tauJet->setChargedPFOLinks(chrgPFOLinks); + + //pi0 + std::vector< ElementLink< xAOD::PFOContainer > > pi0PFOLinks = tauJet->protoPi0PFOLinks(); + tauJet->setPi0PFOLinks(pi0PFOLinks); + + //neutrals + std::vector< ElementLink< xAOD::PFOContainer > > neutralPFOLinks = tauJet->protoNeutralPFOLinks(); + tauJet->setNeutralPFOLinks(neutralPFOLinks); + + return; +} + + + + + + + + + + + + + + + + + diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/PanTauSeed.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/PanTauSeed.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5c86087516ffd211b1071c296ffc6e1dc3ff761b --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/Root/PanTauSeed.cxx @@ -0,0 +1,424 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PanTauAlgs/PanTauSeed.h" + +#include "PanTauAlgs/TauConstituent.h" + +#include <iostream> + +#include "xAODTau/TauJet.h" + +// default constructor +PanTau::PanTauSeed2::PanTauSeed2() + : + IParticle(), + m_p4(), m_p4Cached( false ), + m_IsValidSeed(false), + m_TechnicalQuality(), + m_NameInputAlgorithm("InvalidAlg"), + m_TauJet(0), + m_Constituents(), + m_TypeHLVs(), + m_ConstituentsList_Core(), + m_ConstituentsList_Wide(), + m_ConstituentsList_AllSelected(), + m_ConstituentsList_All(), + m_DecayMode_BySubAlg(0), + m_DecayMode_ByPanTau(0), + m_decayModeHack_CellBasedShots(false), + m_Features(0) +{ +} + + + +// destructor +PanTau::PanTauSeed2::~PanTauSeed2() +{ + 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]; + if(curConst != 0) delete curConst; + } + m_ConstituentsList_All.clear(); + m_ConstituentsList_AllSelected.clear(); + 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 + for(unsigned int iType=0; iType<m_Constituents.size(); iType++) { + std::vector<PanTau::TauConstituent2*> curConsts = m_Constituents[iType]; + curConsts.clear(); + } + m_Constituents.clear(); + +} + + +//copy constructor +PanTau::PanTauSeed2::PanTauSeed2(const PanTau::PanTauSeed2& rhs) + : + IParticle(rhs), + m_p4(rhs.m_p4), m_p4Cached(rhs.m_p4Cached), + m_IsValidSeed(rhs.m_IsValidSeed), + m_TechnicalQuality(rhs.m_TechnicalQuality), + m_NameInputAlgorithm(rhs.m_NameInputAlgorithm), + m_TauJet(rhs.m_TauJet), + m_Constituents(rhs.m_Constituents), + m_TypeHLVs(rhs.m_TypeHLVs), + m_ConstituentsList_Core(rhs.m_ConstituentsList_Core), + m_ConstituentsList_Wide(rhs.m_ConstituentsList_Wide), + m_ConstituentsList_AllSelected(rhs.m_ConstituentsList_AllSelected), + m_ConstituentsList_All(rhs.m_ConstituentsList_All), + m_DecayMode_BySubAlg(rhs.m_DecayMode_BySubAlg), + m_DecayMode_ByPanTau(rhs.m_DecayMode_ByPanTau), + m_decayModeHack_CellBasedShots(rhs.m_decayModeHack_CellBasedShots), + // is this not set on purpose? + //m_ProtoMomentum_Wide = seed.m_ProtoMomentum_Wide; + //m_ProtoMomentum_Core = seed.m_ProtoMomentum_Core; + //m_FinalMomentum = seed.m_FinalMomentum; + m_Features( (rhs.m_Features ? new PanTau::TauFeature2(*rhs.m_Features) : 0) ) +{ +} + + + +PanTau::PanTauSeed2& PanTau::PanTauSeed2::operator=(const PanTau::PanTauSeed2& seed) +{ + if (this != &seed){ + + if (!this->container() && !this->hasStore() ) { + makePrivateStore(); + } + this->IParticle::operator=( seed ); + this->m_p4 = seed.m_p4; + this->m_p4Cached = seed.m_p4Cached; + m_IsValidSeed = seed.m_IsValidSeed; + m_TechnicalQuality = seed.m_TechnicalQuality; + m_NameInputAlgorithm = seed.m_NameInputAlgorithm; + m_TauJet = seed.m_TauJet; + m_Constituents = seed.m_Constituents; + m_TypeHLVs = seed.m_TypeHLVs; + m_ConstituentsList_Core = seed.m_ConstituentsList_Core; + m_ConstituentsList_Wide = seed.m_ConstituentsList_Wide; + m_ConstituentsList_AllSelected = seed.m_ConstituentsList_AllSelected; + m_ConstituentsList_All = seed.m_ConstituentsList_All; + m_decayModeHack_CellBasedShots = seed.m_decayModeHack_CellBasedShots; + // is this not set on purpose? + //m_ProtoMomentum_Wide = seed.m_ProtoMomentum_Wide; + //m_ProtoMomentum_Core = seed.m_ProtoMomentum_Core; + //m_FinalMomentum = seed.m_FinalMomentum; + if(m_Features) delete m_Features; + m_Features = (seed.m_Features ? new PanTau::TauFeature2(*seed.m_Features) : 0); + } + return *this; +} + + + +double PanTau::PanTauSeed2::pt() const { + // static Accessor< float > acc( "pt" ); + // return acc( *this ); + return p4().Pt(); +} + +double PanTau::PanTauSeed2::eta() const { + // static Accessor<float > acc( "eta" ); + // return acc( *this ); + return p4().Eta(); +} + +double PanTau::PanTauSeed2::phi() const { + // static Accessor< float > acc( "phi" ); + // return acc( *this ); + return p4().Phi(); +} + +double PanTau::PanTauSeed2::m() const { + // static Accessor< float> acc( "m" ); + // return acc( *this ); + return p4().M(); +} + +double PanTau::PanTauSeed2::e() const{ + return p4().E(); +} + +double PanTau::PanTauSeed2::rapidity() const { + return p4().Rapidity(); +} + +const PanTau::PanTauSeed2::FourMom_t& PanTau::PanTauSeed2::p4() const { + if( ! m_p4Cached ) { + m_p4.SetPtEtaPhiM( pt(), eta(), phi(),m()); + m_p4Cached=true; + } + return m_p4; +} + +void PanTau::PanTauSeed2::setP4(float pt, float eta, float phi, float m){ + static Accessor< float > acc1( "pt" ); + acc1( *this ) = pt; + static Accessor< float > acc2( "eta" ); + acc2( *this ) = eta; + static Accessor< float > acc3( "phi" ); + acc3( *this ) = phi; + static Accessor< float > acc4( "m" ); + acc4( *this ) = m; + //Need to recalculate m_p4 if requested after update + m_p4Cached=false; + +} + +void PanTau::PanTauSeed2::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::PanTauSeed2::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){ + 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){ + static Accessor< float > acc( "m" ); + acc( *this ) = m; + //Need to recalculate m_p4 if requested after update + m_p4Cached=false; +} + + +xAOD::Type::ObjectType PanTau::PanTauSeed2::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 + ) + : + 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() ); + m_p4.SetPtEtaPhiM(tauJet->ptIntermediateAxis(), tauJet->etaIntermediateAxis(), tauJet->phiIntermediateAxis(), tauJet->mIntermediateAxis() ); + m_p4Cached=true; + m_IsValidSeed = true; + m_TechnicalQuality = pantauSeed_TechnicalQuality; + m_NameInputAlgorithm = nameInputAlgorithm; + m_TauJet = tauJet; + m_decayModeHack_CellBasedShots = false; + m_Features = new PanTau::TauFeature2; + + //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); + + 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); + 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) ); + m_TypeHLVs.push_back( TLorentzVector(0,0,0,0) ); + } + + //assign tauConstituents + TLorentzVector hlv_SumConstituents_Wide = TLorentzVector(0,0,0,0); + TLorentzVector hlv_SumConstituents_Core = TLorentzVector(0,0,0,0); + + int nCharged = 0; + int nPi0Neut = 0; + + for(unsigned int iConst=0; iConst<tauConstituents.size(); iConst++) { + PanTau::TauConstituent2* 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((unsigned int)curType >= m_Constituents.size()) { + //std::cout << "PanTau::PanTauSeed\tERROR\tMore types in TauConstituent2 than reserved in PanTau seed constituent matrix!" << std::endl; + continue; + } + + //fill into sorted lists + m_Constituents.at(curType).push_back(curConst); + m_TypeHLVs.at(curType) += curConst->p4(); + + }//end loop over types + + //add each constituent to wide proto momentum + 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;} + + }//end loop over constituents + + m_ProtoMomentum_Wide = hlv_SumConstituents_Wide; + m_ProtoMomentum_Core = hlv_SumConstituents_Core; + + //set mode as obtained from subalg + m_DecayMode_BySubAlg = PanTau::PanTauSeed2::getDecayMode(nCharged, nPi0Neut); + m_DecayMode_ByPanTau = xAOD::TauJetParameters::Mode_Error; + + if(isOfTechnicalQuality(PanTau::PanTauSeed2::t_NoValidInputTau) == true) { + m_DecayMode_ByPanTau = xAOD::TauJetParameters::Mode_NotSet; + } + +} + + +/** Constructor for invalid seeds */ +PanTau::PanTauSeed2::PanTauSeed2( std::string nameInputAlgorithm, + const xAOD::TauJet* tauJet, + std::vector<int> pantauSeed_TechnicalQuality + ) + : + IParticle(), + m_Constituents(), + m_TypeHLVs(), + m_ConstituentsList_AllSelected(), + m_ConstituentsList_All(), + m_DecayMode_BySubAlg(0), + m_DecayMode_ByPanTau(0), + 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() ); + 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; +} + + + +int PanTau::PanTauSeed2::getDecayMode(int nCharged, int nNeutral) { + + int decayMode; + // 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 + 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 + 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) { + + xAOD::TauJetParameters::DecayMode mode = (xAOD::TauJetParameters::DecayMode)decayMode; + + if(mode == xAOD::TauJetParameters::Mode_1p0n) return "1p0n"; + if(mode == xAOD::TauJetParameters::Mode_1p1n) return "1p1n"; + if(mode == xAOD::TauJetParameters::Mode_1pXn) return "1pXn"; + if(mode == xAOD::TauJetParameters::Mode_3p0n) return "3p0n"; + if(mode == xAOD::TauJetParameters::Mode_3pXn) return "3pXn"; + if(mode == xAOD::TauJetParameters::Mode_Other) return "Other"; + if(mode == xAOD::TauJetParameters::Mode_Error) return "Error"; + if(mode == xAOD::TauJetParameters::Mode_NotSet) return "NotSet"; + return "InvalidMode!!!"; +} + + + +bool PanTau::PanTauSeed2::isOfTechnicalQuality(int pantauSeed_TechnicalQuality) const { + if(pantauSeed_TechnicalQuality > PanTau::PanTauSeed2::t_nTechnicalQualities) { + //std::cout << "PanTauSeed\tERROR\tunknown technical quality value: " << pantauSeed_TechnicalQuality << ". Maximum allowed is " << PanTau::PanTauSeed2::t_nTechnicalQualities << "! Check PanTauAlgs/PanTauSeed.h" << std::endl; + return false; + } + if(m_TechnicalQuality[pantauSeed_TechnicalQuality] == 1) return true; + return false; +} + + + + +std::vector<PanTau::TauConstituent2*> PanTau::PanTauSeed2::getConstituentsOfType(int tauConstituent_Type, bool& foundit) { + if(tauConstituent_Type > PanTau::TauConstituent2::t_nTypes) { + foundit = false; + //std::cout << "PanTauSeed\tERROR\tunknown constituent type: " << tauConstituent_Type << " -> it's larger than the known types: " << PanTau::TauConstituent2::t_nTypes << std::endl; + 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); +} + + + +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; +} + + +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); +} + + + + diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/TauConstituent.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/TauConstituent.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ef5e10cb1a753e3a63953d2c2948fdd264cac411 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/Root/TauConstituent.cxx @@ -0,0 +1,311 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PanTauAlgs/TauConstituent.h" + +#include <iostream> + +PanTau::TauConstituent2::TauConstituent2() + : + IParticle(), + m_p4(), m_p4Cached( false ), + m_TypeFlags(), + m_BDTValue(PanTau::TauConstituent2::DefaultBDTValue()), + m_Charge(PanTau::TauConstituent2::DefaultCharge()), + m_PFOLink(0), + m_Shots(), + m_nPhotonsInShot(0) +{ +} + + + +PanTau::TauConstituent2::TauConstituent2(TLorentzVector itsMomentum, + int itsCharge, + std::vector<int> itsType, + double itsBDTValue, + xAOD::PFO* itsPFO + ) + : + IParticle(), + m_p4(itsMomentum), m_p4Cached(true), + m_TypeFlags(itsType), + m_BDTValue(itsBDTValue), + m_Charge(itsCharge), + m_PFOLink(itsPFO), + m_Shots(), + m_nPhotonsInShot(0) +{ +} + + + +PanTau::TauConstituent2::TauConstituent2( + const PanTau::TauConstituent2& rhs + ): + IParticle(rhs), + m_p4(rhs.m_p4), m_p4Cached(rhs.m_p4Cached), + m_TypeFlags(rhs.m_TypeFlags), + m_BDTValue(rhs.m_BDTValue), + m_Charge(rhs.m_Charge), + m_PFOLink(rhs.m_PFOLink), + m_Shots(rhs.m_Shots), + m_nPhotonsInShot(rhs.m_nPhotonsInShot) +{ +} + + + +PanTau::TauConstituent2::~TauConstituent2() +{ + //delete the shot constituents + for(unsigned int iShot=0; iShot<m_Shots.size(); iShot++) { + PanTau::TauConstituent2* curConst = m_Shots[iShot]; + delete curConst; + } +} + + + +PanTau::TauConstituent2& PanTau::TauConstituent2::operator=(const PanTau::TauConstituent2& tauConst) +{ + if (this!=&tauConst){ + + if (!this->container() && !this->hasStore() ) { + makePrivateStore(); + } + this->IParticle::operator=( tauConst ); + this->m_p4 = tauConst.m_p4; + this->m_p4Cached = tauConst.m_p4Cached; + m_TypeFlags = tauConst.m_TypeFlags; + m_BDTValue = tauConst.m_BDTValue; + m_Charge = tauConst.m_Charge; + m_PFOLink = tauConst.m_PFOLink; + m_Shots = tauConst.m_Shots; + m_nPhotonsInShot = tauConst.m_nPhotonsInShot; + } + return *this; +} + + +double PanTau::TauConstituent2::pt() const { + static Accessor< float > acc( "pt" ); + return acc( *this ); +} + +double PanTau::TauConstituent2::eta() const { + static Accessor<float > acc( "eta" ); + return acc( *this ); +} + +double PanTau::TauConstituent2::phi() const { + static Accessor< float > acc( "phi" ); + return acc( *this ); +} + +double PanTau::TauConstituent2::m() const { + static Accessor< float> acc( "m" ); + return acc( *this ); +} + +double PanTau::TauConstituent2::e() const{ + return p4().E(); +} + +double PanTau::TauConstituent2::rapidity() const { + return p4().Rapidity(); +} + +const PanTau::TauConstituent2::FourMom_t& PanTau::TauConstituent2::p4() const { + if( ! m_p4Cached ) { + m_p4.SetPtEtaPhiM( pt(), eta(), phi(),m()); + m_p4Cached=true; + } + return m_p4; +} + +void PanTau::TauConstituent2::setP4(float pt, float eta, float phi, float m){ + static Accessor< float > acc1( "pt" ); + acc1( *this ) = pt; + static Accessor< float > acc2( "eta" ); + acc2( *this ) = eta; + static Accessor< float > acc3( "phi" ); + acc3( *this ) = phi; + static Accessor< float > acc4( "m" ); + acc4( *this ) = m; + //Need to recalculate m_p4 if requested after update + m_p4Cached=false; +} + +void PanTau::TauConstituent2::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){ + 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){ + 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){ + static Accessor< float > acc( "m" ); + acc( *this ) = m; + //Need to recalculate m_p4 if requested after update + m_p4Cached=false; +} + + +xAOD::Type::ObjectType PanTau::TauConstituent2::type() const { + return xAOD::Type::ParticleFlow; +} + + + + +void PanTau::TauConstituent2::removeTypeFlag(TauConstituent2::Type aType) { + unsigned int typeIndex = (unsigned int)aType; + m_TypeFlags.at(typeIndex) = 0; + return; +} + + +//the static getTypeName which does a translation +std::string PanTau::TauConstituent2::getTypeName(PanTau::TauConstituent2::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"; + default: return "UnkownType"; + } +} + + + +bool PanTau::TauConstituent2::isNeutralType(int tauConstituentType) { + PanTau::TauConstituent2::Type type = (PanTau::TauConstituent2::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; + default: return false; + } + return false; +} + + + +bool PanTau::TauConstituent2::isCoreType(int tauConstituentType) { + PanTau::TauConstituent2::Type type = (PanTau::TauConstituent2::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; + default: return false; + } + return false; +} + + + +//the non static getType name, which returns +std::vector<std::string> PanTau::TauConstituent2::getTypeName() const { + std::vector<std::string> res; + for(unsigned int iType=0; iType<TauConstituent2::t_nTypes; iType++) { + if(m_TypeFlags[iType] == 1) { + PanTau::TauConstituent2::Type curType = (PanTau::TauConstituent2::Type)iType; + res.push_back( TauConstituent2::getTypeName(curType) ); + } + } + return res; +} + + + +std::string PanTau::TauConstituent2::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)) + ","; + } + } + return res; +} + + + +double PanTau::TauConstituent2::getBDTValue() const { + return m_BDTValue; +} + + + +std::vector<int> PanTau::TauConstituent2::getTypeFlags() const { + return m_TypeFlags; +} + + +bool PanTau::TauConstituent2::isOfType(PanTau::TauConstituent2::Type theType) const { + int typeIndex = (int)theType; + if(theType >= (int)TauConstituent2::t_nTypes) { + return false; + } + if(m_TypeFlags.at(typeIndex) == 1) return true; + return false; +} + + +int PanTau::TauConstituent2::getCharge() const { + return m_Charge; +} + + + +xAOD::PFO* PanTau::TauConstituent2::getPFO() const { + return m_PFOLink; +} + + + +void PanTau::TauConstituent2::addShot(TauConstituent2* shot) { + if(shot != 0) m_Shots.push_back(shot); +} + + +std::vector<PanTau::TauConstituent2*> PanTau::TauConstituent2::getShots() { + return m_Shots; +} + +unsigned int PanTau::TauConstituent2::getNShots() { + return m_Shots.size(); +} + +void PanTau::TauConstituent2::setNPhotonsInShot(int nPhotons) { + m_nPhotonsInShot = nPhotons; +} +int PanTau::TauConstituent2::getNPhotonsInShot() { + return m_nPhotonsInShot; +} + diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/TauFeature.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/TauFeature.cxx new file mode 100644 index 0000000000000000000000000000000000000000..99cfcffac3e6642f5e1cb02f19a54695fd0a0a57 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/Root/TauFeature.cxx @@ -0,0 +1,151 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PanTauAlgs/TauFeature.h" + +#include <cmath> +#include <stdexcept> +#include <iostream> + + + +static const std::vector<double> s_defaultVec(0); + +PanTau::TauFeature2::TauFeature2() + : + m_featureMap(), + m_vecFeatureMap() + +{ +} + + + +PanTau::TauFeature2::~TauFeature2() +{ +} + + +double PanTau::TauFeature2::value(const std::string& ItsName, bool& isValid) const +{ + FeatureMapConstIter iter = m_featureMap.find(ItsName); +if(m_featureMap.end() == iter) +{ + // not found + isValid=false; + //std::cout << "Could not find key called '" << ItsName << "' in feature map. Either the spelling is wrong or the feature does not exist. Returning -999999." << std::endl; + 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) + { + return s_defaultVec; + } + 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::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; +} + + +int PanTau::TauFeature2::nValues() const { + return m_featureMap.size(); +} + + +int PanTau::TauFeature2::nVecValues() const { + return m_vecFeatureMap.size(); +} + + +void PanTau::TauFeature2::add(PanTau::TauFeature2* 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 + +} + + + +void PanTau::TauFeature2::addFeaturesFromMap(std::map<std::string, double> otherMap, std::string prefix = "") { + + 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); + } + + return; +} + +/* +std::ostream& operator<< ( std::ostream& out, PanTau::TauFeature2 + xAOD::FileMetaData_v1::MetaDataType type ) { +MsgStream& PanTau::TauFeature2::dump( MsgStream& out, MSG::Level debugLevel = MSG::VERBOSE ) const +{ + std::string name("TauFeature2: "); + out << debugLevel << name << endreq; + FeatureMapConstIter iter = m_featureMap.begin(); + FeatureMapConstIter iterEnd = m_featureMap.end(); + for ( ; iter!=iterEnd; iter++) { + out << debugLevel << (*iter).first << " : \t" << (*iter).second <<endreq; + } + + std::string nameVec("TauVecFeature: "); + out << debugLevel << nameVec << endreq; + VectorFeatureMapConstIter iterVec = m_vecFeatureMap.begin(); + VectorFeatureMapConstIter iterEndVec = m_vecFeatureMap.end(); + for ( ; iterVec!=iterEndVec; iterVec++) { + out << debugLevel << (*iterVec).first << " : \t" << (*iterVec).second.size() << " entries" <<endreq; + } + return out; +} +*/ + diff --git a/Reconstruction/PanTau/PanTauAlgs/src/Tool_DecayModeDeterminator.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_DecayModeDeterminator.cxx similarity index 60% rename from Reconstruction/PanTau/PanTauAlgs/src/Tool_DecayModeDeterminator.cxx rename to Reconstruction/PanTau/PanTauAlgs/Root/Tool_DecayModeDeterminator.cxx index 79f856b777b5b2b2baed65a672ab0411988049ec..5f6d80ad76c870a040a415e60de78bd7525881ae 100644 --- a/Reconstruction/PanTau/PanTauAlgs/src/Tool_DecayModeDeterminator.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_DecayModeDeterminator.cxx @@ -3,30 +3,24 @@ */ -//! Gaudi includes -#include "AthenaKernel/errorcheck.h" -#include "StoreGate/StoreGateSvc.h" - //! PanTau includes #include "PanTauAlgs/Tool_DecayModeDeterminator.h" -#include "PanTauAlgs/Tool_ModeDiscriminator.h" -#include "PanTauEvent/PanTauSeed.h" -#include "PanTauEvent/TauClassificationTypes.h" +#include "PanTauAlgs/PanTauSeed.h" +#include "PanTauAlgs/TauClassificationTypes.h" + +#include "xAODTau/TauDefs.h" PanTau::Tool_DecayModeDeterminator::Tool_DecayModeDeterminator( - const std::string& ty, - const std::string& na, - const IInterface* pa ) : - AthAlgTool(ty,na,pa), + 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") { - declareInterface<ITool_DecayModeDeterminator>(this); 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"); @@ -43,34 +37,23 @@ PanTau::Tool_DecayModeDeterminator::~Tool_DecayModeDeterminator() { StatusCode PanTau::Tool_DecayModeDeterminator::initialize() { ATH_MSG_INFO( name() << " initialize()" ); - CHECK( AthAlgTool::initialize() ); - - //get link to store gate - CHECK(service("StoreGateSvc", m_sgSvc)); //get the discri tools - CHECK(m_Tool_ModeDiscriminator_1p0n_vs_1p1n.retrieve()); - CHECK(m_Tool_ModeDiscriminator_1p1n_vs_1pXn.retrieve()); - CHECK(m_Tool_ModeDiscriminator_3p0n_vs_3pXn.retrieve()); + 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 - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Basic", m_varTypeName_Prefix_Basic) ); - + ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Basic", m_varTypeName_Prefix_Basic) ); + //get the BDT cut values - CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R10X_CellBased", m_BDTCutValue_R10X_CellBased) ); - CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R11X_CellBased", m_BDTCutValue_R11X_CellBased) ); - CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R110_CellBased", m_BDTCutValue_R110_CellBased) ); - CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R1XX_CellBased", m_BDTCutValue_R1XX_CellBased) ); - CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R30X_CellBased", m_BDTCutValue_R30X_CellBased) ); - CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R3XX_CellBased", m_BDTCutValue_R3XX_CellBased) ); - - CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R10X_eflowRec", m_BDTCutValue_R10X_eflowRec) ); - CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R11X_eflowRec", m_BDTCutValue_R11X_eflowRec) ); - CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R110_eflowRec", m_BDTCutValue_R110_eflowRec) ); - CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R1XX_eflowRec", m_BDTCutValue_R1XX_eflowRec) ); - CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R30X_eflowRec", m_BDTCutValue_R30X_eflowRec) ); - CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R3XX_eflowRec", m_BDTCutValue_R3XX_eflowRec) ); - + 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; } @@ -85,34 +68,34 @@ StatusCode PanTau::Tool_DecayModeDeterminator::initialize() { -StatusCode PanTau::Tool_DecayModeDeterminator::determineDecayMode(PanTau::PanTauSeed* inSeed) const { +StatusCode PanTau::Tool_DecayModeDeterminator::execute(PanTau::PanTauSeed2* inSeed) { - ATH_MSG_DEBUG("determinateDecayMode called for inSeed at " << inSeed); + ATH_MSG_DEBUG("determine DecayMode for inSeed at " << inSeed); std::string inAlgName = inSeed->getNameInputAlgorithm(); - PanTau::TauFeature* features = inSeed->getFeatures(); + PanTau::TauFeature2* 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 noValidInput = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed2::t_NoValidInputTau); + bool noAnyConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed2::t_NoConstituentsAtAll); + bool noSelConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed2::t_NoSelectedConstituents); bool invalidForDecayMode = (noValidInput || noAnyConstituents || noSelConstituents); 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", PanTau::PanTauSeed::Mode_NotSet); + features->addFeature(inAlgName + "_" + m_varTypeName_Prefix_Basic + "_RecoMode_PanTau", xAOD::TauJetParameters::Mode_NotSet); return StatusCode::SUCCESS; } //get the mode as it was determined by the subalgorithm int decayMode_SubAlg = inSeed->getDecayModeBySubAlg(); - int decayMode_PanTau = PanTau::PanTauSeed::Mode_NotSet; + int decayMode_PanTau = xAOD::TauJetParameters::Mode_NotSet; //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 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.; @@ -122,62 +105,60 @@ StatusCode PanTau::Tool_DecayModeDeterminator::determineDecayMode(PanTau::PanTau double BDTCutValue_R30X = 0.; double BDTCutValue_R3XX = 0.; - if(inAlgName == "CellBased") { - 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; - } - - if(inAlgName == "eflowRec") { - BDTCutValue_R10X = m_BDTCutValue_R10X_eflowRec; - BDTCutValue_R110 = m_BDTCutValue_R110_eflowRec; - BDTCutValue_R11X = m_BDTCutValue_R11X_eflowRec; - BDTCutValue_R1XX = m_BDTCutValue_R1XX_eflowRec; - BDTCutValue_R30X = m_BDTCutValue_R30X_eflowRec; - BDTCutValue_R3XX = m_BDTCutValue_R3XX_eflowRec; - } + 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... - ATH_MSG_DEBUG("The subalg mode is set by nChrg/nPi0Neut/nAddNeut = " << nCharged_SubAlg << " / " << nPi0Neut_SubAlg << " / " << AdditionalNeutrals << " to " << decayMode_SubAlg << " - " << PanTau::PanTauSeed::getDecayModeName(decayMode_SubAlg)); + ATH_MSG_DEBUG("The subalg mode is set by nChrg/nPi0Neut/nAddNeut = " << nCharged_SubAlg << " / " << nPi0Neut_SubAlg << " / " << AdditionalNeutrals << " to " << decayMode_SubAlg << " - " << PanTau::PanTauSeed2::getDecayModeName(decayMode_SubAlg)); double bdtResponse = -5; DecayModeTest bdtTest = t_UnknownTest; // 1p0n mode - if(decayMode_SubAlg == PanTau::PanTauSeed::Mode_1p0n) { + if(decayMode_SubAlg == xAOD::TauJetParameters::Mode_1p0n) { //1 prong, and no other objects at all -> use 1p0n if(AdditionalNeutrals == 0) { ATH_MSG_DEBUG("Set 1p0n because there is only one object"); - decayMode_PanTau = PanTau::PanTauSeed::Mode_1p0n; + decayMode_PanTau = xAOD::TauJetParameters::Mode_1p0n; bdtResponse = -3.; //if there are neutrals which are not pi0-tagged, check BDT to maybe set 1p1n } else { + /* + // simplify this code to: + bdtTest = t_1p0n_vs_1p1n; + ATH_MSG_DEBUG("Entering bdtTest " << bdtTest); + decayMode_PanTau=GetPanTauDecayMode(inSeed, m_Tool_ModeDiscriminator_1p0n_vs_1p1n, BDTCutValue_R10X, bdtResponse); + + int GetPanTauDecayMode(PanTauSeed2* inSeed, ToolHandle<PanTau::ITool_ModeDiscriminator> tool_ModeDiscriminator, int decayMode_SubAlg, double BDTCutValue, double &bdtResponse){ + */ + bool isOK = false; bdtResponse = m_Tool_ModeDiscriminator_1p0n_vs_1p1n->getResponse(inSeed, isOK); bdtTest = t_1p0n_vs_1p1n; if(isOK == false) { - ATH_MSG_DEBUG("WARNING: problems getting bdt response for 1p0n + X-neutrals. use subAlg mode"); + 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 = PanTau::PanTauSeed::Mode_1p0n; - if(bdtResponse <= BDTCutValue_R10X) decayMode_PanTau = PanTau::PanTauSeed::Mode_1p1n; - ATH_MSG_DEBUG("R10X: Response is: " << bdtResponse << " Use 1p0n if > " << BDTCutValue_R10X << " -- decision: " << PanTau::PanTauSeed::getDecayModeName(decayMode_PanTau) ); + 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) ); } } - ATH_MSG_DEBUG("SubAlgMode " << decayMode_SubAlg << ". Chrg/Neut: " << nCharged_SubAlg << " / " << nPi0Neut_SubAlg << ". Mode set to: " << decayMode_PanTau << " - " << PanTau::PanTauSeed::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 1p0n //1p1n mode - else if (decayMode_SubAlg == PanTau::PanTauSeed::Mode_1p1n) { + else if (decayMode_SubAlg == xAOD::TauJetParameters::Mode_1p1n) { //1prong, 1pi0 and no other neutrals. check 1p0n-vs-1p1n @@ -186,12 +167,12 @@ StatusCode PanTau::Tool_DecayModeDeterminator::determineDecayMode(PanTau::PanTau bdtResponse = m_Tool_ModeDiscriminator_1p0n_vs_1p1n->getResponse(inSeed, isOK); bdtTest = t_1p0n_vs_1p1n; if(isOK == false) { - ATH_MSG_DEBUG("WARNING problems getting bdt response for 1p1n + 0-neutrals. use subAlg mode"); + 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 = PanTau::PanTauSeed::Mode_1p1n; - if(bdtResponse > BDTCutValue_R110) decayMode_PanTau = PanTau::PanTauSeed::Mode_1p0n; - ATH_MSG_DEBUG("R110: Response is: " << bdtResponse << " Use 1p0n if > " << BDTCutValue_R110 << " -- decision: " << PanTau::PanTauSeed::getDecayModeName(decayMode_PanTau) ); + if(bdtResponse <= BDTCutValue_R110) decayMode_PanTau = xAOD::TauJetParameters::Mode_1p1n; + if(bdtResponse > BDTCutValue_R110) decayMode_PanTau = xAOD::TauJetParameters::Mode_1p0n; + ATH_MSG_DEBUG("R110: Response is: " << bdtResponse << " Use 1p0n if > " << BDTCutValue_R110 << " -- decision: " << PanTau::PanTauSeed2::getDecayModeName(decayMode_PanTau) ); } @@ -202,48 +183,48 @@ StatusCode PanTau::Tool_DecayModeDeterminator::determineDecayMode(PanTau::PanTau bdtResponse = m_Tool_ModeDiscriminator_1p1n_vs_1pXn->getResponse(inSeed, isOK); bdtTest = t_1p1n_vs_1pXn; if(isOK == false) { - ATH_MSG_DEBUG("WARNING problems getting bdt response for 1p1n + X-neutrals. use subAlg mode"); + 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 = PanTau::PanTauSeed::Mode_1p1n; - if(bdtResponse <= BDTCutValue_R11X) decayMode_PanTau = PanTau::PanTauSeed::Mode_1pXn; - ATH_MSG_DEBUG("R11X: Response is: " << bdtResponse << " Use 1p1n if > " << BDTCutValue_R11X << " -- decision: " << PanTau::PanTauSeed::getDecayModeName(decayMode_PanTau) ); + if(bdtResponse > BDTCutValue_R11X) decayMode_PanTau = xAOD::TauJetParameters::Mode_1p1n; + if(bdtResponse <= BDTCutValue_R11X) decayMode_PanTau = xAOD::TauJetParameters::Mode_1pXn; + ATH_MSG_DEBUG("R11X: Response is: " << bdtResponse << " Use 1p1n if > " << BDTCutValue_R11X << " -- decision: " << PanTau::PanTauSeed2::getDecayModeName(decayMode_PanTau) ); } } - ATH_MSG_DEBUG("SubAlgMode " << decayMode_SubAlg << ". Chrg/Neut: " << nCharged_SubAlg << " / " << nPi0Neut_SubAlg << ". Mode set to: " << decayMode_PanTau << " - " << PanTau::PanTauSeed::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 1p1n //1pXn mode - else if (decayMode_SubAlg == PanTau::PanTauSeed::Mode_1pXn) { + 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; if(isOK == false) { - ATH_MSG_DEBUG("WARNING problems getting bdt response for 1p1n + X-neutrals. use subAlg mode"); + 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 = PanTau::PanTauSeed::Mode_1p1n; - if(bdtResponse <= BDTCutValue_R1XX) decayMode_PanTau = PanTau::PanTauSeed::Mode_1pXn; - ATH_MSG_DEBUG("R1XX: Response is: " << bdtResponse << " Use 1p1n if > " << BDTCutValue_R1XX << " -- decision: " << PanTau::PanTauSeed::getDecayModeName(decayMode_PanTau) ); + if(bdtResponse > BDTCutValue_R1XX) decayMode_PanTau = xAOD::TauJetParameters::Mode_1p1n; + if(bdtResponse <= BDTCutValue_R1XX) decayMode_PanTau = xAOD::TauJetParameters::Mode_1pXn; + ATH_MSG_DEBUG("R1XX: Response is: " << bdtResponse << " Use 1p1n if > " << BDTCutValue_R1XX << " -- decision: " << PanTau::PanTauSeed2::getDecayModeName(decayMode_PanTau) ); } - ATH_MSG_DEBUG("SubAlgMode " << decayMode_SubAlg << ". Chrg/Neut: " << nCharged_SubAlg << " / " << nPi0Neut_SubAlg << ". Mode set to: " << decayMode_PanTau << " - " << PanTau::PanTauSeed::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 1pXn //3p0n mode - else if (decayMode_SubAlg == PanTau::PanTauSeed::Mode_3p0n) { + else if (decayMode_SubAlg == xAOD::TauJetParameters::Mode_3p0n) { //no additional neutrals. if(AdditionalNeutrals == 0) { ATH_MSG_DEBUG("Set 3p0n because there are only charged objects"); - decayMode_PanTau = PanTau::PanTauSeed::Mode_3p0n; + decayMode_PanTau = xAOD::TauJetParameters::Mode_3p0n; bdtResponse = -2.5; //additional neutrals @@ -253,38 +234,38 @@ StatusCode PanTau::Tool_DecayModeDeterminator::determineDecayMode(PanTau::PanTau bdtResponse = m_Tool_ModeDiscriminator_3p0n_vs_3pXn->getResponse(inSeed, isOK); bdtTest = t_3p0n_vs_3pXn; if(isOK == false) { - ATH_MSG_DEBUG("WARNING problems getting bdt response for 3p0n + X-neutrals. use subAlg mode"); + 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 = PanTau::PanTauSeed::Mode_3p0n; - if(bdtResponse <= BDTCutValue_R30X) decayMode_PanTau = PanTau::PanTauSeed::Mode_3pXn; - ATH_MSG_DEBUG("R30X: Response is: " << bdtResponse << " Use 3p0n if > " << BDTCutValue_R30X << " -- decision: " << PanTau::PanTauSeed::getDecayModeName(decayMode_PanTau) ); + 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::PanTauSeed::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 //3pXn mode - else if (decayMode_SubAlg == PanTau::PanTauSeed::Mode_3pXn) { + 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; if(isOK == false) { - ATH_MSG_DEBUG("WARNING problems getting bdt response for 3p0n + X-neutrals. use subAlg mode"); + 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 = PanTau::PanTauSeed::Mode_3p0n; - if(bdtResponse <= BDTCutValue_R3XX) decayMode_PanTau = PanTau::PanTauSeed::Mode_3pXn; - ATH_MSG_DEBUG("R3XX: Response is: " << bdtResponse << " Use 3p0n if > " << BDTCutValue_R3XX << " -- decision: " << PanTau::PanTauSeed::getDecayModeName(decayMode_PanTau) ); + if(bdtResponse > BDTCutValue_R3XX) decayMode_PanTau = xAOD::TauJetParameters::Mode_3p0n; + if(bdtResponse <= BDTCutValue_R3XX) decayMode_PanTau = xAOD::TauJetParameters::Mode_3pXn; + ATH_MSG_DEBUG("R3XX: Response is: " << bdtResponse << " Use 3p0n if > " << BDTCutValue_R3XX << " -- decision: " << PanTau::PanTauSeed2::getDecayModeName(decayMode_PanTau) ); } - ATH_MSG_DEBUG("SubAlgMode " << decayMode_SubAlg << ". Chrg/Neut: " << nCharged_SubAlg << " / " << nPi0Neut_SubAlg << ". Mode set to: " << decayMode_PanTau << " - " << PanTau::PanTauSeed::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 3pXn @@ -292,47 +273,45 @@ StatusCode PanTau::Tool_DecayModeDeterminator::determineDecayMode(PanTau::PanTau //it's none of 1p0n, 1p1n, 1pXn, 3p0n, 3pXn -> set other mode else { ATH_MSG_DEBUG("WARNING SubAlg mode of tau is not known. set the 'other' mode"); - decayMode_PanTau = PanTau::PanTauSeed::Mode_Other; + decayMode_PanTau = xAOD::TauJetParameters::Mode_Other; bdtResponse = -4; bdtTest = t_UnknownTest; } - if(inAlgName != "eflowRec" && inAlgName != "CellBased") { + 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; } - //post decay mode -HACK: + // 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(inAlgName == "CellBased") { - if(nCharged_SubAlg == 1 && nPi0Neut_SubAlg == 1) { - ATH_MSG_DEBUG("Potential to apply hack: In case of CellBased 1p1n with >2 photons in shots -> 1pXn"); - //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(); - ATH_MSG_DEBUG("There are " << shots.size() << " shots in the pi0 Neutral"); - for(unsigned int iShot=0; iShot<shots.size(); iShot++) { - nPhotons = nPhotons + (double)(shots.at(iShot)->getNPhotonsInShot()); - } - ATH_MSG_DEBUG("Counted " << nPhotons << " photons in the pi0 neutral"); - if(nPhotons > 2) { - decayMode_SubAlg = PanTau::PanTauSeed::Mode_1pXn; - decayMode_PanTau = PanTau::PanTauSeed::Mode_1pXn; - inSeed->setModeHackedByCellBased(true); - bdtResponse = -2.; - } - - //end check for pi0 neutrals were found - } else { - ATH_MSG_DEBUG("Could not find expected CellBased neutral -> don't hack the pantau mode"); + if(nCharged_SubAlg == 1 && nPi0Neut_SubAlg == 1) { + ATH_MSG_DEBUG("CellBased decay mode 1p1n and a single neutral cluster - check for number of photons in cluster: if >2 then set decay mode 1pXn"); + //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(); + ATH_MSG_DEBUG("There are " << shots.size() << " shots in the pi0 Neutral"); + for(unsigned int iShot=0; iShot<shots.size(); iShot++) { + nPhotons = nPhotons + (double)(shots.at(iShot)->getNPhotonsInShot()); + } + ATH_MSG_DEBUG("Counted " << nPhotons << " photons in the pi0 neutral"); + if(nPhotons > 2) { + decayMode_SubAlg = xAOD::TauJetParameters::Mode_1pXn; + decayMode_PanTau = xAOD::TauJetParameters::Mode_1pXn; + inSeed->setModeHackedByCellBased(true); + bdtResponse = -2.; } - } //end hack check for 1p1n - }//end hack check for cell based + + //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 ATH_MSG_DEBUG("Storing decay mode in tau and features: SubAlg/PanTau = " << (double)decayMode_SubAlg << " / " << (double)decayMode_PanTau); @@ -360,7 +339,7 @@ StatusCode PanTau::Tool_DecayModeDeterminator::determineDecayMode(PanTau::PanTau 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; } @@ -368,23 +347,6 @@ StatusCode PanTau::Tool_DecayModeDeterminator::determineDecayMode(PanTau::PanTau - - - - - - - - - - - - - - - - - diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_DetailsArranger.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_DetailsArranger.cxx new file mode 100644 index 0000000000000000000000000000000000000000..25fc0b7af70b9accd85d624ff23bb1fdc123f1e4 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_DetailsArranger.cxx @@ -0,0 +1,721 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// Implementation file for class Tool_DetailsArranger +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Tool for PID of TauSeeds +/////////////////////////////////////////////////////////////////// +// sebastian.fleischmann@cern.ch +/////////////////////////////////////////////////////////////////// + +//! 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" + + +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") +{ + declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Tool handle to the information store tool"); +} + + + +PanTau::Tool_DetailsArranger::~Tool_DetailsArranger() { +} + + + +StatusCode PanTau::Tool_DetailsArranger::initialize() { + + ATH_MSG_DEBUG( name() << " initialize()" ); + + 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; +} + + +StatusCode PanTau::Tool_DetailsArranger::execute(PanTau::PanTauSeed2* inSeed) { + + std::string inputAlg = inSeed->getNameInputAlgorithm(); + + + ATH_MSG_DEBUG( "Tool_DetailsArranger::execute called for input seed at: " << inSeed << " from inputalg: " << inputAlg); + + 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; + + + //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()); + + ATH_MSG_DEBUG( "check for bad seed -> isBadSeed = " << isBadSeed); + 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_MSG_DEBUG( "arrange for seed from inputalg: " << inputAlg); + + ATH_CHECK(arrangePFOLinks(inSeed, tauJet)); + + //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); + + return StatusCode::SUCCESS; +} + + + +void PanTau::Tool_DetailsArranger::addPanTauDetailToTauJet(PanTauSeed2* inSeed, + std::string featName, + xAOD::TauJetParameters::PanTauDetails detailEnum, + PanTauDetailsType detailType) const { + + ATH_MSG_DEBUG( "addPanTauDetailToTauJet called for feature of type " << detailType << ": " << featName); + bool isValid; + PanTau::TauFeature2* features = inSeed->getFeatures(); + std::string fullFeatName = inSeed->getNameInputAlgorithm() + "_" + featName; + + double theValue; + 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; + } + + ATH_MSG_DEBUG( "the value is" << theValue); + + xAOD::TauJet* tauJet = const_cast<xAOD::TauJet*>(inSeed->getTauJet()); + int valueToAddInt = -1; + float valueToAddFloat = -1.1; + ATH_MSG_DEBUG( "will add it to xAOD::TauJet at " << tauJet); + switch(detailType) { + case PanTau::Tool_DetailsArranger::t_Int: + valueToAddInt = (int)theValue; + ATH_MSG_DEBUG( "Adding int feature: " << valueToAddInt); + tauJet->setPanTauDetail(detailEnum, valueToAddInt); + break; + case PanTau::Tool_DetailsArranger::t_Float: + valueToAddFloat = (float)theValue; + ATH_MSG_DEBUG( "Adding float feature: " << valueToAddFloat); + 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; +} + + + +StatusCode PanTau::Tool_DetailsArranger::arrangePFOLinks(PanTau::PanTauSeed2* inSeed, xAOD::TauJet* tauJet) { + + 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 save + tauJet->clearChargedPFOLinks(); + tauJet->clearNeutralPFOLinks(); + tauJet->clearPi0PFOLinks(); + + 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); + + // 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); + + tauJet->setDetail(xAOD::TauJetParameters::nCharged, (int)chrgPFOLinks.size()); + + + ATH_MSG_DEBUG("Dumping preselected neutral pfo links"); + for(unsigned int iPFO=0; iPFO<preSelected_neutralPFOLinks.size(); iPFO++) { + const xAOD::PFO* pfo = preSelected_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() ); + } + + //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); + + return StatusCode::SUCCESS; + } + + ATH_MSG_DEBUG("Before re-linking: DecayMode Proto / Final: " << decayModeProto << " / " << decayModeFinal); + ATH_MSG_DEBUG("Number of chrg, pi0, neut PFOs in subAlg: " << chrgPFOLinks.size() << ", " << pi0PFOLinks.size() << ", " << neutralPFOLinks.size()); + ATH_MSG_DEBUG("Number of pi0 PFOs in PanTau: " << preLinkPi0PFOLinks.size()); + + //#ifndef NDEBUG + ATH_MSG_DEBUG("Dumping pi0 pfos for subalg"); + for(unsigned int iPFO=0; iPFO<pi0PFOLinks.size(); iPFO++) { + const xAOD::PFO* pfo = pi0PFOLinks.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()); + } + ATH_MSG_DEBUG("Dumping neutral pfos for subalg"); + for(unsigned int iPFO=0; iPFO<neutralPFOLinks.size(); iPFO++) { + const xAOD::PFO* pfo = 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() ); + } + //#endif //NDEBUG + + + //set nPi0 to 0 for neutrals that have no pi0 +// for(unsigned int iPFO=0; iPFO<neutralPFOLinks.size(); iPFO++) { +// xAOD::PFO* curPFO = const_cast<xAOD::PFO*>(neutralPFOLinks.at(iPFO).cachedElement()); +// int nPi0 = -1; +// bool getOK = curPFO->attribute(xAOD::PFODetails::nPi0Proto, nPi0); +// if(getOK == false) { +// ATH_MSG_DEBUG("Could not get nPi0Proto for this PFO -> skip setting of nPi0"); +// continue; +// } +// if(nPi0 < 1) curPFO->setAttribute(xAOD::PFODetails::nPi0Proto, 0); +// } + + +// std::string inputAlg = inSeed->getNameInputAlgorithm(); + + //if pantau sets the same decay mode as the substructure algorithm, just copy the links + if(decayModeProto == decayModeFinal) { + ATH_MSG_DEBUG("Modes are the same"); + + 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) ); + + // set all masses correctly: + SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); + + } else { + + // assign the same constituents to Pantau: + preLinkPi0PFOLinks=pi0PFOLinks; + + // set all masses correctly: + SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); + + } + + + } else { + + // ***** + // if(preSelected_neutralPFOLinks.size() > 0) are not necessary! + // ***** + + 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); + + } else if( decayModeFinal == xAOD::TauJetParameters::Mode_1p0n && decayModeProto == xAOD::TauJetParameters::Mode_1p1n ){ + + // do nothing (leave the pi0 neutrals list empty) + + } else if( decayModeFinal == xAOD::TauJetParameters::Mode_1pXn && decayModeProto == xAOD::TauJetParameters::Mode_1p1n ){ + + + if( pi0PFOLinks.size() == 1 && HasMultPi0sInOneCluster(pi0PFOLinks.at(0).cachedElement(), decayModeProto, inputAlg) ){ + // ATH_MSG_WARNING("RecalculatePantauConstituents: Inconsistent decay mode classification! (wasAlteredByCellBasedShots=true although decay mode = " << decayModeFinal); + // tauJet->setPi0PFOLinks(pi0PFOLinks); + // return StatusCode::SUCCESS; + // } + + // assign twice the pi0 mass to the one pi0 PFO: + SetNeutralConstituentVectorMasses(pi0PFOLinks, 2*MASS_PI0); + + // assign the same constituents to Pantau: + preLinkPi0PFOLinks=pi0PFOLinks; + + } 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!!"); + + // set the mass: + SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); + + } + + } 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) ); + + // set both pi0neutrals to mass 0 (photon mass): + SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, 0.); + + } 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!!"); + + // 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) + + } + + } + + tauJet->setPi0PFOLinks(preLinkPi0PFOLinks); + + + + ATH_MSG_DEBUG("Done setting links"); + ATH_MSG_DEBUG("DecayMode Proto / Final: " << decayModeProto << " / " << decayModeFinal); + ATH_MSG_DEBUG("Number of chrg, pi0, neut PFOs in subAlg: " << chrgPFOLinks.size() << ", " << pi0PFOLinks.size() << ", " << neutralPFOLinks.size()); + + + SetHLVTau(inSeed, tauJet, inputAlg, m_varTypeName_Basic); + +// PanTau::TauFeature2* featureMap = inSeed->getFeatures(); +// featureMap->addFeature(inputAlg + "_" + m_varTypeName_Basic + "_FinalMomentumCore_pt", hlv_PanTau_Final.perp() ); +// featureMap->addFeature(inputAlg + "_" + m_varTypeName_Basic + "_FinalMomentumCore_eta", hlv_PanTau_Final.eta() ); +// featureMap->addFeature(inputAlg + "_" + m_varTypeName_Basic + "_FinalMomentumCore_phi", hlv_PanTau_Final.phi() ); +// featureMap->addFeature(inputAlg + "_" + m_varTypeName_Basic + "_FinalMomentumCore_m", hlv_PanTau_Final.m() ); + + + std::vector< ElementLink< xAOD::PFOContainer > > finalChrgPFOLinks = tauJet->chargedPFOLinks(); + std::vector< ElementLink< xAOD::PFOContainer > > finalPi0PFOLinks = tauJet->pi0PFOLinks(); + std::vector< ElementLink< xAOD::PFOContainer > > finalNeutralPFOLinks = tauJet->neutralPFOLinks(); + + //! DEBUG output + //#ifndef NDEBUG + ATH_MSG_DEBUG("Dumping charged pfos for subalg"); + for(unsigned int iPFO=0; iPFO<chrgPFOLinks.size(); iPFO++) { + const xAOD::PFO* pfo = chrgPFOLinks.at(iPFO).cachedElement(); + ATH_MSG_DEBUG("pfo " << iPFO << " pt, eta, phi, m: " << pfo->pt() << ", " << pfo->eta() << ", " << pfo->phi() << ", " << pfo->m()); + } + ATH_MSG_DEBUG("Dumping charged pfos for pantau"); + for(unsigned int iPFO=0; iPFO<finalChrgPFOLinks.size(); iPFO++) { + const xAOD::PFO* pfo = finalChrgPFOLinks.at(iPFO).cachedElement(); + ATH_MSG_DEBUG("pfo " << iPFO << " pt, eta, phi, m: " << pfo->pt() << ", " << pfo->eta() << ", " << pfo->phi() << ", " << pfo->m()); + } + + ATH_MSG_DEBUG("Dumping pi0 pfos for subalg"); + for(unsigned int iPFO=0; iPFO<pi0PFOLinks.size(); iPFO++) { + const xAOD::PFO* pfo = pi0PFOLinks.at(iPFO).cachedElement(); + int nPi0 = -1; + bool getOK = pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0); + if(getOK == false) ATH_MSG_DEBUG("problems reading pi0 attribute"); + ATH_MSG_DEBUG("pfo " << iPFO << " pt, eta, phi, m: " << pfo->pt() << ", " << pfo->eta() << ", " << pfo->phi() << ", " << pfo->m() << " isPi0: " << nPi0 << " , BDTscore: " << pfo->bdtPi0Score() ); + } + ATH_MSG_DEBUG("Dumping pi0 pfos for pantau"); + for(unsigned int iPFO=0; iPFO<finalPi0PFOLinks.size(); iPFO++) { + const xAOD::PFO* pfo = finalPi0PFOLinks.at(iPFO).cachedElement(); + int nPi0 = -1; + bool getOK = pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0); + if(getOK == false) ATH_MSG_DEBUG("problems reading pi0 attribute"); + ATH_MSG_DEBUG("pfo " << iPFO << " pt, eta, phi, m: " << pfo->pt() << ", " << pfo->eta() << ", " << pfo->phi() << ", " << pfo->m() << " isPi0: " << nPi0 << " , BDTscore: " << pfo->bdtPi0Score() ); + } + + ATH_MSG_DEBUG("Dumping neutral pfos for subalg"); + for(unsigned int iPFO=0; iPFO<neutralPFOLinks.size(); iPFO++) { + const xAOD::PFO* pfo = neutralPFOLinks.at(iPFO).cachedElement(); + int nPi0 = -1; + bool getOK = pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0); + if(getOK == false) ATH_MSG_DEBUG("problems reading pi0 attribute"); + ATH_MSG_DEBUG("pfo " << iPFO << " pt, eta, phi, m: " << pfo->pt() << ", " << pfo->eta() << ", " << pfo->phi() << ", " << pfo->m() << " isPi0: " << nPi0 << " , BDTscore: " << pfo->bdtPi0Score() ); + } + ATH_MSG_DEBUG("Dumping neutral pfos for pantau"); + for(unsigned int iPFO=0; iPFO<finalNeutralPFOLinks.size(); iPFO++) { + const xAOD::PFO* pfo = finalNeutralPFOLinks.at(iPFO).cachedElement(); + int nPi0 = -1; + bool getOK = pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0); + if(getOK == false) ATH_MSG_DEBUG("problems reading pi0 attribute"); + ATH_MSG_DEBUG("pfo " << iPFO << " pt, eta, phi, m: " << pfo->pt() << ", " << pfo->eta() << ", " << pfo->phi() << ", " << pfo->m() << " isPi0: " << nPi0 << " , BDTscore: " << pfo->bdtPi0Score() ); + } + //#endif //NDEBUG + + + + // 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); + + xAOD::ParticleContainer* pi0Container=0; + ATH_CHECK( evtStore()->retrieve(pi0Container, "finalTauPi0s") ); + + 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)); + } + p->auxdecor<std::vector< ElementLink< xAOD::PFOContainer > > >("pi0PFOLinks") = pfo_link_vector; + ElementLink< xAOD::IParticleContainer > linkToPi0; + linkToPi0.toContainedElement(*(static_cast<const xAOD::IParticleContainer*>(pi0Container)), dynamic_cast<xAOD::IParticle*> (p)); + tauJet->addPi0Link(linkToPi0); + } + + + return StatusCode::SUCCESS; +} + + +// Calculate final 4-vector: +void PanTau::Tool_DetailsArranger::SetHLVTau( PanTau::PanTauSeed2* inSeed, xAOD::TauJet* tauJet, std::string inputAlg, std::string m_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(); + ATH_MSG_DEBUG("Number of chrg, pi0, neut PFOs in PanTau: " << finalChrgPFOLinks.size() << ", " << finalPi0PFOLinks.size() << ", " << finalNeutralPFOLinks.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(); + ATH_MSG_DEBUG("pfo " << iPFO << " pt, eta, phi, m: " << pfo->pt() << ", " << pfo->eta() << ", " << pfo->phi() << ", " << pfo->m()); + tlv_PanTau_Final += pfo->p4(); + } + for(unsigned int iPFO=0; iPFO<NPi0Neut; iPFO++) { + const xAOD::PFO* pfo = finalPi0PFOLinks.at(iPFO).cachedElement(); + ATH_MSG_DEBUG("pfo " << iPFO << " pt, eta, phi, m: " << pfo->pt() << ", " << pfo->eta() << ", " << pfo->phi() << ", " << pfo->m()); + tlv_PanTau_Final += pfo->p4(); + } + + ATH_MSG_DEBUG("Final 4-vector: "); + ATH_MSG_DEBUG("\tEt : " << tlv_PanTau_Final.Et()); + ATH_MSG_DEBUG("\tEta: " << tlv_PanTau_Final.Eta()); + ATH_MSG_DEBUG("\tPhi: " << tlv_PanTau_Final.Phi()); + ATH_MSG_DEBUG("\tm : " << tlv_PanTau_Final.M()); + + inSeed->setFinalMomentum(tlv_PanTau_Final); + + PanTau::TauFeature2* featureMap = inSeed->getFeatures(); + featureMap->addFeature(inputAlg + "_" + m_varTypeName_Basic + "_FinalMomentumCore_pt", tlv_PanTau_Final.Pt() ); + featureMap->addFeature(inputAlg + "_" + m_varTypeName_Basic + "_FinalMomentumCore_eta", tlv_PanTau_Final.Eta() ); + featureMap->addFeature(inputAlg + "_" + m_varTypeName_Basic + "_FinalMomentumCore_phi", tlv_PanTau_Final.Phi() ); + featureMap->addFeature(inputAlg + "_" + m_varTypeName_Basic + "_FinalMomentumCore_m", tlv_PanTau_Final.M() ); + + return; + +} + + + +bool PanTau::Tool_DetailsArranger::HasMultPi0sInOneCluster(const xAOD::PFO* pfo, int decayModeProto, TString inputAlg){ + + // this is only relevant for reco 1p1n modes, hence restrict the + // output to these modes + + int nPi0sPerCluster = 1; + + if (inputAlg != "CellBased" ) return (nPi0sPerCluster > 1); + + // cell-based sets this to 1pXn however below this function is + // called with the decayModeProto as evaluated by Pantau! + if (decayModeProto != xAOD::TauJetParameters::Mode_1p1n ) return (nPi0sPerCluster > 1); + + if( !pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0sPerCluster) ) { + ATH_MSG_WARNING("Could not retrieve nPi0Proto. Will set it to 1."); + nPi0sPerCluster = 1; + } + + return (nPi0sPerCluster > 1); + +} + + + +void PanTau::Tool_DetailsArranger::SetNeutralConstituentMass(xAOD::PFO* neutral_pfo, double mass){ + + TLorentzVector momentum; + PanTau::SetP4EEtaPhiM( momentum, neutral_pfo->e(), neutral_pfo->eta(), neutral_pfo->phi(), mass); + neutral_pfo->setP4(momentum.Pt(), neutral_pfo->eta(), neutral_pfo->phi(), mass); + + return; + +} + + +void PanTau::Tool_DetailsArranger::SetNeutralConstituentVectorMasses(std::vector< ElementLink<xAOD::PFOContainer> > neutralPFOLinks, double mass){ + + for(unsigned int iNeutral=0; iNeutral<neutralPFOLinks.size(); iNeutral++) { + ElementLink<xAOD::PFOContainer> curNeutralPFOLink = neutralPFOLinks.at(iNeutral); + xAOD::PFO* curNeutralPFO = const_cast<xAOD::PFO*>(curNeutralPFOLink.cachedElement()); + + 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 ){ + // collect element links from tau constituents in the Pantau + // seed of type "type". cellbased_neutralPFOLinks is only used + // to obtain the ElementLinks. + + std::vector< ElementLink< xAOD::PFOContainer > > new_links; + + unsigned int nConstsOfType=0; + bool foundIt=false; + std::vector<PanTau::TauConstituent2*> tauConstituents=inSeed->getConstituentsOfType(type,foundIt); + + if( (type != PanTau::TauConstituent2::t_Neutral && type != PanTau::TauConstituent2::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; + } + + for(unsigned int iConst=0; iConst<tauConstituents.size(); iConst++) { + bool isOfType = tauConstituents[iConst]->isOfType(type); + if(!isOfType) continue; + + // 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; + ++nConstsOfType; + + for(unsigned int iPFO=0; iPFO<cellbased_neutralPFOLinks.size(); iPFO++) { + const xAOD::PFO* pfo = cellbased_neutralPFOLinks.at(iPFO).cachedElement(); + + 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() << ")!"); + + ATH_MSG_DEBUG("Dumping neutral pfo links from all constituents of type " << type); + 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; + +} + + +//______________________________________________________________________________ +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 + // for the cases where number of pi0s does not match to the decay mode: + size_t iNumPi0PFO = tauJet->nPi0PFOs(); + + int iDecayMode = -1; + tauJet->panTauDetail(xAOD::TauJetParameters::PanTau_DecayMode, iDecayMode); + + if (iDecayMode == xAOD::TauJetParameters::Mode_1p1n && iNumPi0PFO > 1) { + // TODO: find out if the pi0 mass is defined elsewhere in atlas code! + // float fMassPi0 = 134.98; + float fMassPi0Squared = MASS_PI0*MASS_PI0; + + // combine both photons (with 0 mass that is already set) to one pi0 vector: + const xAOD::PFO* xPfo1 = tauJet->pi0PFO(0); + const xAOD::PFO* xPfo2 = tauJet->pi0PFO(1); + vPi0s.push_back(xPfo1->p4() + xPfo2->p4()); + + // re-set the mass to one pi0: + double dNewMomentum = std::sqrt(vPi0s[0].E() * vPi0s[0].E() - fMassPi0Squared); + vPi0s[0].SetPxPyPzE(vPi0s[0].Vect().Unit().Px() * dNewMomentum, + vPi0s[0].Vect().Unit().Py() * dNewMomentum, + vPi0s[0].Vect().Unit().Pz() * dNewMomentum, + vPi0s[0].E()); + + std::vector< ElementLink<xAOD::PFOContainer> > pfovec; + pfovec.push_back(tauJet->pi0PFOLinks()[0]); + pfovec.push_back(tauJet->pi0PFOLinks()[1]); + vec_pi0pfos.push_back( pfovec ); + + } else if (iDecayMode == xAOD::TauJetParameters::DecayMode::Mode_1pXn && iNumPi0PFO == 1){ + + // make a single pi0 from a PFO that contains two pi0s: + const xAOD::PFO* xPfo = tauJet->pi0PFO(0); + // add the 2-pi0 vector preliminarily to the pi0vector: + vPi0s.push_back(xPfo->p4()); + + // re-set the mass back to one pi0: + double dNewMomentum = std::sqrt( (vPi0s[0].E()/2.)*(vPi0s[0].E()/2.) - MASS_PI0*MASS_PI0 ); + vPi0s[0].SetVectM(vPi0s[0].Vect().Unit() * dNewMomentum, MASS_PI0 ); + + // create another pi0 from the same vector: + vPi0s.push_back(vPi0s[0]); + + std::vector< ElementLink<xAOD::PFOContainer> > pfovec; + pfovec.push_back(tauJet->pi0PFOLinks()[0]); + vec_pi0pfos.push_back( pfovec ); + + } else { + + // if it's not any of the special cases above then just collect the PFOs: + for (size_t iPFO = 0; iPFO < iNumPi0PFO; iPFO++){ + vPi0s.push_back(tauJet->pi0PFO(iPFO)->p4()); + std::vector< ElementLink<xAOD::PFOContainer> > pfovec; + pfovec.push_back(tauJet->pi0PFOLinks()[iPFO]); + vec_pi0pfos.push_back( pfovec ); + } + } + +} + + + + diff --git a/Reconstruction/PanTau/PanTauAlgs/src/Tool_FeatureExtractor.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_FeatureExtractor.cxx similarity index 64% rename from Reconstruction/PanTau/PanTauAlgs/src/Tool_FeatureExtractor.cxx rename to Reconstruction/PanTau/PanTauAlgs/Root/Tool_FeatureExtractor.cxx index 0cda28bce9d064eafffbfc9a32405f264d4e91f3..dad780d6fd7f23df2f3f4f7039af6a05d21c2773 100644 --- a/Reconstruction/PanTau/PanTauAlgs/src/Tool_FeatureExtractor.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_FeatureExtractor.cxx @@ -2,6 +2,7 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ + /////////////////////////////////////////////////////////////////// // Implementation file for class Tool_FeatureExtractor /////////////////////////////////////////////////////////////////// @@ -13,20 +14,12 @@ /////////////////////////////////////////////////////////////////// //! Helper classes -#include "tauEvent/TauJet.h" #include "xAODTau/TauJet.h" #include "xAODTracking/Vertex.h" #include "xAODTracking/TrackParticle.h" -#include "TrkVertexFitterInterfaces/ITrackToVertexIPEstimator.h" -// #include "FourMomUtils/Thrust.h" -// #include "FourMomUtils/FoxWolfram.h" -// #include "CLHEP/Units/SystemOfUnits.h" -// #include "CLHEP/Vector/ThreeVector.h" -// #include "Math/SpecFuncMathMore.h" -// #include "AthenaKernel/errorcheck.h" -// #include "CaloEvent/CaloCluster.h" -// #include "CaloEvent/CaloClusterMoment.h" +//#include "TrkParameters/TrackParameters.h" +//#include "TrkVertexFitterInterfaces/ITrackToVertexIPEstimator.h" //! ROOT includes #include "TMath.h" @@ -41,14 +34,14 @@ //! PanTau includes #include "PanTauAlgs/Tool_FeatureExtractor.h" #include "PanTauAlgs/Tool_InformationStore.h" -#include "PanTauEvent/TauConstituent.h" -#include "PanTauEvent/PanTauSeed.h" -#include "PanTauEvent/TauFeature.h" +#include "PanTauAlgs/TauConstituent.h" +#include "PanTauAlgs/PanTauSeed.h" +#include "PanTauAlgs/TauFeature.h" -bool sortTauConstituentMVA(const PanTau::TauConstituent* u, const PanTau::TauConstituent* v) { +bool sortTauConstituentMVA(const PanTau::TauConstituent2* u, const PanTau::TauConstituent2* v) { double uBDT = u->getBDTValue(); double vBDT = v->getBDTValue(); return uBDT > vBDT; @@ -56,9 +49,9 @@ bool sortTauConstituentMVA(const PanTau::TauConstituent* u, const PanTau: -bool sortTauConstituentEt(const PanTau::TauConstituent* u, const PanTau::TauConstituent* v) { - double uEt = u->hlv().et(); - double vEt = v->hlv().et(); +bool sortTauConstituentEt(const PanTau::TauConstituent2* u, const PanTau::TauConstituent2* v) { + double uEt = u->p4().Et(); + double vEt = v->p4().Et(); return uEt > vEt; } @@ -67,17 +60,12 @@ bool sortTauConstituentEt(const PanTau::TauConstituent* u, const PanTau:: PanTau::Tool_FeatureExtractor::Tool_FeatureExtractor( - const std::string& ty, - const std::string& na, - const IInterface* pa) : - AthAlgTool(ty, na, pa), - m_Tool_HelperFunctions("PanTau::Tool_HelperFunctions/Tool_HelperFunctions"), - m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore"), - m_Tool_TrackToVertexIPEstimator("Trk::TrackToVertexIPEstimator/TrackToVertexIPEstimator") { - declareInterface<ITool_FeatureExtractor>(this); - - declareProperty("Tool_HelperFunctions", m_Tool_HelperFunctions, "Tool Handle to Tool_HelperFunctions"); - declareProperty("Tool_TrackToVertexIPEstimator", m_Tool_TrackToVertexIPEstimator, "Tool Handle to track to vertex ip estimator tool"); + const std::string& name ) : + asg::AsgTool(name), + m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore"){ + //m_trackToVertexTool("Reco::TrackToVertex") { + + //declareProperty("TrackToVertexTool", m_trackToVertexTool); declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Tool handle to the information store tool"); } @@ -86,42 +74,40 @@ PanTau::Tool_FeatureExtractor::Tool_FeatureExtractor( StatusCode PanTau::Tool_FeatureExtractor::initialize() { - StatusCode sc = AlgTool::initialize(); ATH_MSG_INFO(" initialize()"); - CHECK( m_Tool_HelperFunctions.retrieve() ); - CHECK( m_Tool_TrackToVertexIPEstimator.retrieve() ); - CHECK( m_Tool_InformationStore.retrieve() ); - - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Sum", m_varTypeName_Sum) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Ratio", m_varTypeName_Ratio) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_EtInRing", m_varTypeName_EtInRing) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Isolation", m_varTypeName_Isolation) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Num", m_varTypeName_Num) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Mean", m_varTypeName_Mean) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_StdDev", m_varTypeName_StdDev) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_HLV", m_varTypeName_HLV) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Angle", m_varTypeName_Angle) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_DeltaR", m_varTypeName_DeltaR) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_JetMoment", m_varTypeName_JetMoment) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Combined", m_varTypeName_Combined) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_JetShape", m_varTypeName_JetShape) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_ImpactParams", m_varTypeName_ImpactParams) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Basic", m_varTypeName_Basic) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_PID", m_varTypeName_PID) ); - - CHECK( m_Tool_InformationStore->getInfo_Int("FeatureExtractor_UseEmptySeeds", m_Config_UseEmptySeeds) ); - - CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_BinEdges_Eta", m_Config_CellBased_BinEdges_Eta) ); - CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_EtaBinned_Pi0MVACut_1prong", m_Config_CellBased_EtaBinned_Pi0MVACut_1prong) ); - CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_EtaBinned_Pi0MVACut_3prong", m_Config_CellBased_EtaBinned_Pi0MVACut_3prong) ); - - return sc; + //ATH_CHECK( m_trackToVertexTool.retrieve() ); + 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; @@ -132,23 +118,23 @@ void PanTau::Tool_FeatureExtractor::fillVariantsSeedEt(std::vector<PanTau::TauCo for(unsigned int iConst = 0; iConst < tauConstituents.size(); iConst++) { //get current constituents - PanTau::TauConstituent* curConstituent = tauConstituents.at(iConst); - double curEt = curConstituent->hlv().et(); + PanTau::TauConstituent2* curConstituent = tauConstituents.at(iConst); + double curEt = curConstituent->p4().Et(); //update the different Et definitions - if(curConstituent->isOfType(PanTau::TauConstituent::t_Charged) == true) { + 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::TauConstituent::t_Neutral) == true) { + if(curConstituent->isOfType(PanTau::TauConstituent2::t_Neutral) == true) { m_Variants_SeedEt["EtAllConsts"] += curEt; } - if(curConstituent->isOfType(PanTau::TauConstituent::t_NeutLowA) == true) { + if(curConstituent->isOfType(PanTau::TauConstituent2::t_NeutLowA) == true) { m_Variants_SeedEt["EtNeutLowA"] += curEt; } - if(curConstituent->isOfType(PanTau::TauConstituent::t_NeutLowB) == true) { + if(curConstituent->isOfType(PanTau::TauConstituent2::t_NeutLowB) == true) { m_Variants_SeedEt["EtNeutLowB"] += curEt; } @@ -159,7 +145,7 @@ void PanTau::Tool_FeatureExtractor::fillVariantsSeedEt(std::vector<PanTau::TauCo -void PanTau::Tool_FeatureExtractor::addFeatureWrtSeedEnergy( PanTau::TauFeature* targetMap, +void PanTau::Tool_FeatureExtractor::addFeatureWrtSeedEnergy( PanTau::TauFeature2* targetMap, std::string featName, double numerator, std::map<std::string, double>* denominatorMap) const { @@ -174,14 +160,14 @@ void PanTau::Tool_FeatureExtractor::addFeatureWrtSeedEnergy( PanTau::TauFeatu -StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* inSeed) { +StatusCode PanTau::Tool_FeatureExtractor::execute(PanTau::PanTauSeed2* inSeed) { ATH_MSG_DEBUG("Calculating features..."); - 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 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; @@ -194,11 +180,11 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* ATH_MSG_DEBUG("Basic features"); - CHECK( calculateBasicFeatures(inSeed) ); + ATH_CHECK( calculateBasicFeatures(inSeed) ); ATH_MSG_DEBUG("RawConstituent 4 vectors"); - CHECK( addConstituentMomenta(inSeed) ); + ATH_CHECK( addConstituentMomenta(inSeed) ); //first, calculate the Et variants for the seed fillVariantsSeedEt(inSeed->getConstituentsAsList_All()); @@ -206,26 +192,26 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* //loop through all types of Constituents in tau and calculate type features for them ATH_MSG_DEBUG("type specific features"); //baseline - CHECK( calculateFeatures(inSeed, PanTau::TauConstituent::t_NoType) ); //=> all constituents - CHECK( calculateFeatures(inSeed, PanTau::TauConstituent::t_Charged) ); //=> charged ones in core - CHECK( calculateFeatures(inSeed, PanTau::TauConstituent::t_Neutral) ); //=> neutral ones in core - CHECK( calculateFeatures(inSeed, PanTau::TauConstituent::t_Pi0Neut) ); //=> pi0 tagged ones in core + 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 - CHECK( calculateFeatures(inSeed, PanTau::TauConstituent::t_NeutLowA) ); //=> same as neutral but with lower Et - CHECK( calculateFeatures(inSeed, PanTau::TauConstituent::t_NeutLowB) ); //=> same as neutral but with even lower et + 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 //fill the combined features ATH_MSG_DEBUG("combined features"); - CHECK( addCombinedFeatures(inSeed) ); + ATH_CHECK( addCombinedFeatures(inSeed) ); //fill the generic jet features ATH_MSG_DEBUG("generic jet features"); - CHECK( addGenericJetFeatures(inSeed) ); + ATH_CHECK( addGenericJetFeatures(inSeed) ); //fill the impact paramter features ATH_MSG_DEBUG("impact parameter features"); - CHECK( addImpactParameterFeatures(inSeed) ); + ATH_CHECK( addImpactParameterFeatures(inSeed) ); ATH_MSG_DEBUG("Finished feature extraction"); return StatusCode::SUCCESS; @@ -233,10 +219,10 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* -StatusCode PanTau::Tool_FeatureExtractor::calculateBasicFeatures(PanTau::PanTauSeed* inSeed) { +StatusCode PanTau::Tool_FeatureExtractor::calculateBasicFeatures(PanTau::PanTauSeed2* inSeed) { ATH_MSG_DEBUG("calculating basic features"); - PanTau::TauFeature* featureMap = inSeed->getFeatures(); + PanTau::TauFeature2* featureMap = inSeed->getFeatures(); std::string featureAlg = inSeed->getNameInputAlgorithm(); std::string featurePrefix = m_varTypeName_Basic; @@ -249,22 +235,22 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateBasicFeatures(PanTau::PanTauS //! Loop over types to fill //! - multiplicity of that type //! - sum charge and abs charge - for(int iType=0; iType<PanTau::TauConstituent::t_nTypes; iType++) { + for(int iType=0; iType<PanTau::TauConstituent2::t_nTypes; iType++) { bool foundIt = false; - std::vector<TauConstituent*> curList = inSeed->getConstituentsOfType(iType, foundIt); + std::vector<TauConstituent2*> curList = inSeed->getConstituentsOfType(iType, foundIt); if(foundIt == false) continue; //store multiplicity of current type - std::string typeName = PanTau::TauConstituent::getTypeName((PanTau::TauConstituent::Type)iType); + std::string typeName = PanTau::TauConstituent2::getTypeName((PanTau::TauConstituent2::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::TauConstituent::t_Charged) continue; + if(iType != (int)PanTau::TauConstituent2::t_Charged) continue; for(unsigned int iConst=0; iConst<nConstituents; iConst++) { - PanTau::TauConstituent* curConstituent = curList[iConst]; + PanTau::TauConstituent2* curConstituent = curList[iConst]; SumCharge += curConstituent->getCharge(); AbsCharge += fabs((double)curConstituent->getCharge()); } @@ -276,23 +262,23 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateBasicFeatures(PanTau::PanTauS //! Fill multiplicity for any constituents //all constituents - std::string typeNameAll = PanTau::TauConstituent::AllConstituentsName(); + 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 - CLHEP::HepLorentzVector hlv_ProtoMomentumCore = inSeed->getProtoMomentumCore(); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumCore_pt", hlv_ProtoMomentumCore.perp()); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumCore_eta", hlv_ProtoMomentumCore.eta()); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumCore_phi", hlv_ProtoMomentumCore.phi()); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumCore_m", hlv_ProtoMomentumCore.m()); + 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()); - CLHEP::HepLorentzVector hlv_ProtoMomentumWide = inSeed->getProtoMomentumWide(); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumWide_pt", hlv_ProtoMomentumWide.perp()); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumWide_eta", hlv_ProtoMomentumWide.eta()); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumWide_phi", hlv_ProtoMomentumWide.phi()); - featureMap->addFeature(featureAlg + "_" + featurePrefix + "_ProtoMomentumWide_m", hlv_ProtoMomentumWide.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; @@ -301,26 +287,25 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateBasicFeatures(PanTau::PanTauS -StatusCode PanTau::Tool_FeatureExtractor::addConstituentMomenta(PanTau::PanTauSeed* inSeed) { - +StatusCode PanTau::Tool_FeatureExtractor::addConstituentMomenta(PanTau::PanTauSeed2* inSeed) { std::string inputAlgName = inSeed->getNameInputAlgorithm(); - TauFeature* tauFeatureMap = inSeed->getFeatures(); + TauFeature2* tauFeatureMap = inSeed->getFeatures(); std::string prefixVARType = m_varTypeName_HLV; - for(int iType=0; iType<(int)PanTau::TauConstituent::t_nTypes; iType++) { + for(int iType=0; iType<(int)PanTau::TauConstituent2::t_nTypes; iType++) { bool isOK; - std::vector<PanTau::TauConstituent*> list_TypeConstituents = inSeed->getConstituentsOfType(iType, isOK); // list of constituents of current type + 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 - CLHEP::HepLorentzVector hlv_TypeConstituents = inSeed->getSubsystemHLV(iType, isOK); // summed hlv of objects of current type - std::string curTypeName = PanTau::TauConstituent::getTypeName((PanTau::TauConstituent::Type)iType); + 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::TauConstituent*> list_TypeConstituents_SortBDT = inSeed->getConstituentsOfType(iType, isOK); + std::vector<PanTau::TauConstituent2*> list_TypeConstituents_SortBDT = inSeed->getConstituentsOfType(iType, isOK); std::sort(list_TypeConstituents_SortBDT.begin(), list_TypeConstituents_SortBDT.end(), sortTauConstituentMVA); if(list_TypeConstituents.size() > 0) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumPt", hlv_TypeConstituents.perp()); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumEta", hlv_TypeConstituents.eta()); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumPhi", hlv_TypeConstituents.phi()); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumM", hlv_TypeConstituents.m()); + 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 (et sort); @@ -329,29 +314,29 @@ StatusCode PanTau::Tool_FeatureExtractor::addConstituentMomenta(PanTau::PanTauSe 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++) { - CLHEP::HepLorentzVector hlv_curConst = list_TypeConstituents[iConst]->hlv(); - curConsts_pt.push_back(hlv_curConst.perp()); - curConsts_eta.push_back(hlv_curConst.eta()); - curConsts_phi.push_back(hlv_curConst.phi()); - curConsts_m.push_back(hlv_curConst.m()); + 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++) { - CLHEP::HepLorentzVector hlv_curConstBDT = list_TypeConstituents_SortBDT[iConst]->hlv(); - curConstsBDT_pt.push_back(hlv_curConstBDT.perp()); - curConstsBDT_eta.push_back(hlv_curConstBDT.eta()); - curConstsBDT_phi.push_back(hlv_curConstBDT.phi()); - curConstsBDT_m.push_back(hlv_curConstBDT.m()); + 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); @@ -365,25 +350,24 @@ StatusCode PanTau::Tool_FeatureExtractor::addConstituentMomenta(PanTau::PanTauSe -StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* inSeed, +StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed2* inSeed, int tauConstituentType) { // - std::string curTypeName = PanTau::TauConstituent::getTypeName( (PanTau::TauConstituent::Type)tauConstituentType ); - std::string curTypeName_All = PanTau::TauConstituent::AllConstituentsName(); - PanTau::TauFeature* tauFeatureMap = inSeed->getFeatures(); + 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(); -// CLHEP::HepLorentzVector hlv_OldReference = const_cast<Analysis::TauJet*>(inSeed->getTauJet())->getHLV(TauJetParameters::IntermediateAxis); - CLHEP::HepLorentzVector hlv_Reference = inSeed->getProtoMomentumCore(); + TLorentzVector tlv_Reference = inSeed->getProtoMomentumCore(); - std::vector<PanTau::TauConstituent*> list_AllConstituents = inSeed->getConstituentsAsList_Core(); + std::vector<PanTau::TauConstituent2*> list_AllConstituents = inSeed->getConstituentsAsList_Core(); 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; + 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(); @@ -395,40 +379,40 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* std::sort(list_AllConstituents.begin(), list_AllConstituents.end(), sortTauConstituentEt); std::sort(list_TypeConstituents.begin(), list_TypeConstituents.end(), sortTauConstituentEt); - CLHEP::HepLorentzVector hlv_1st_Et = CLHEP::HepLorentzVector(); - CLHEP::HepLorentzVector hlv_2nd_Et = CLHEP::HepLorentzVector(); - CLHEP::HepLorentzVector hlv_3rd_Et = CLHEP::HepLorentzVector(); + TLorentzVector tlv_1st_Et; + TLorentzVector tlv_2nd_Et; + TLorentzVector tlv_3rd_Et; - if(list_TypeConstituents.size() > 0) hlv_1st_Et = list_TypeConstituents[0]->hlv(); - if(list_TypeConstituents.size() > 1) hlv_2nd_Et = list_TypeConstituents[1]->hlv(); - if(list_TypeConstituents.size() > 2) hlv_3rd_Et = list_TypeConstituents[2]->hlv(); + 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(); - CLHEP::HepLorentzVector hlv_Last_Et = CLHEP::HepLorentzVector(); - if(list_TypeConstituents.size() > 0) hlv_Last_Et = list_TypeConstituents.back()->hlv(); + 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::vector<PanTau::TauConstituent2*> list_TypeConstituents_SortBDT = list_TypeConstituents; std::sort(list_TypeConstituents_SortBDT.begin(), list_TypeConstituents_SortBDT.end(), sortTauConstituentMVA); - CLHEP::HepLorentzVector hlv_1st_BDT = CLHEP::HepLorentzVector(); - CLHEP::HepLorentzVector hlv_2nd_BDT = CLHEP::HepLorentzVector(); - CLHEP::HepLorentzVector hlv_3rd_BDT = CLHEP::HepLorentzVector(); + TLorentzVector tlv_1st_BDT; + TLorentzVector tlv_2nd_BDT; + TLorentzVector tlv_3rd_BDT; - if(list_TypeConstituents_SortBDT.size() > 0) hlv_1st_BDT = list_TypeConstituents_SortBDT[0]->hlv(); - if(list_TypeConstituents_SortBDT.size() > 1) hlv_2nd_BDT = list_TypeConstituents_SortBDT[1]->hlv(); - if(list_TypeConstituents_SortBDT.size() > 2) hlv_3rd_BDT = list_TypeConstituents_SortBDT[2]->hlv(); + 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 - CLHEP::HepLorentzVector hlv_TypeConstituents; + TLorentzVector tlv_TypeConstituents; // ===> Sum of DeltaR to jet axis double sum_DRToReference = 0; double sum_DR2ToReference = 0; @@ -471,27 +455,27 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* for(unsigned int iTypeConst=0; iTypeConst<list_TypeConstituents.size(); iTypeConst++) { //get hep lorentz vector - CLHEP::HepLorentzVector hlv_curConst = list_TypeConstituents.at(iTypeConst)->hlv(); + TLorentzVector tlv_curConst = list_TypeConstituents.at(iTypeConst)->p4(); //final check (nan & inf) - if (isnan(hlv_curConst.perp()) || isinf(hlv_curConst.perp())) continue; + if (isnan(tlv_curConst.Pt()) || isinf(tlv_curConst.Pt())) continue; //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 - hlv_TypeConstituents += hlv_curConst; + tlv_TypeConstituents += tlv_curConst; //helpers to reduce function calls - double hlp_Et = hlv_curConst.et(); + double hlp_Et = tlv_curConst.Et(); double hlp_Et2 = hlp_Et * hlp_Et; - double hlp_E = hlv_curConst.e(); + double hlp_E = tlv_curConst.E(); double hlp_E2 = hlp_E * hlp_E; - double hlp_DeltaR = hlv_Reference.deltaR(hlv_curConst); + double hlp_DeltaR = tlv_Reference.DeltaR(tlv_curConst); double hlp_DeltaR2 = hlp_DeltaR * hlp_DeltaR; - double hlp_DeltaRLeading = (hlv_1st_Et.perp() == 0 ? 0 : hlv_1st_Et.deltaR(hlv_curConst)); + 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_Tool_HelperFunctions->deltaRprime(hlv_Reference.vect(), hlv_curConst.vect()); - double hlp_Angle = hlv_Reference.angle(hlv_curConst.vect()); + 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; @@ -563,20 +547,21 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* if( isnan(value_BDT) || isinf(value_BDT) ) continue; //correct BDT value based on BDT cut - if(inputAlgName == "CellBased" && tauConstituentType != PanTau::TauConstituent::t_Charged) { + if(tauConstituentType != PanTau::TauConstituent2::t_Charged) { double mvaCorrection = 0.0; - double etaCurConst = list_TypeConstituents_SortBDT[iTypeConst]->eta(); - int etaBinIndex = m_Tool_HelperFunctions->getBinIndex(m_Config_CellBased_BinEdges_Eta, fabs(etaCurConst)); + double etaCurConst = list_TypeConstituents_SortBDT[iTypeConst]->p4().Eta(); + int etaBinIndex = m_HelperFunctions.getBinIndex(m_Config_CellBased_BinEdges_Eta, fabs(etaCurConst)); bool isOK; - int numTrack = inSeed->getConstituentsOfType(PanTau::TauConstituent::t_Charged, isOK).size(); + int numTrack = inSeed->getConstituentsOfType(PanTau::TauConstituent2::t_Charged, isOK).size(); 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; } value_sumBDT_BDTSort += value_BDT; - std::string iConst = m_Tool_HelperFunctions->convertNumberToString((double)(iTypeConst+1)); + std::string iConst = m_HelperFunctions.convertNumberToString((double)(iTypeConst+1)); tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTValues_BDTSort_" + iConst, value_BDT); + //ATH_MSG_DEBUG("\t\tAdded variable " << inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_nPhotons_BDTSort_" + iConstStr << " with value " << totalPhotonsInNeutral); tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_BDTValuesSum_BDTSort_" + iConst, value_sumBDT_BDTSort); } @@ -588,7 +573,7 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* if( isnan(value_BDT) || isinf(value_BDT) ) continue; value_sumBDT_EtSort += value_BDT; - std::string iConst = m_Tool_HelperFunctions->convertNumberToString((double)(iTypeConst+1)); + 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); } @@ -596,11 +581,11 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* //! Shot information /////////////////////////////////////////// prefixVARType = PanTau::Tool_FeatureExtractor::varTypeName_Shots(); - //only execute if the inSeed was built from CellBased and the constituent type is neutral - if(inputAlgName == "CellBased" && PanTau::TauConstituent::isNeutralType(tauConstituentType) == true) { + //only execute if the constituent type is neutral + if(PanTau::TauConstituent2::isNeutralType(tauConstituentType) == true) { ATH_MSG_DEBUG("---> Dumping shot information from " << list_TypeConstituents_SortBDT.size() << " constituents of type " << curTypeName << " in tau"); - CLHEP::HepLorentzVector totalHLV_SumShots = CLHEP::HepLorentzVector(0., 0., 0., 0.); + TLorentzVector totalTLV_SumShots = TLorentzVector(0., 0., 0., 0.); unsigned int totalPhotonsInSeed = 0; unsigned int totalShotsInSeed = 0; double maxDeltaRSumShotToConst = -999; @@ -608,63 +593,61 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* double maxDeltaRSumShotToTau = -999; double minDeltaRSumShotToTau = 999; - std::vector<CLHEP::HepLorentzVector> allShotHLVs = std::vector<CLHEP::HepLorentzVector>(0); + std::vector<TLorentzVector> allShotTLVs = std::vector<TLorentzVector>(0); for(unsigned int iConst=0; iConst<list_TypeConstituents_SortBDT.size(); iConst++) { ATH_MSG_DEBUG("\tConstituent " << iConst << " / " << list_TypeConstituents_SortBDT.size()); - PanTau::TauConstituent* curConst = list_TypeConstituents_SortBDT.at(iConst); - CLHEP::HepLorentzVector hlv_CurConst = curConst->hlv(); - std::vector<PanTau::TauConstituent*> shotConstituents = curConst->getShots(); + 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(); - ATH_MSG_DEBUG("\t\tConstituent has Et/Eta/Phi/M: " << curConst->et() << " / " << curConst->eta() << " / " << curConst->phi() << " / " << curConst->m()); + ATH_MSG_DEBUG("\t\tConstituent has Pt/Eta/Phi/M: " << tlv_CurConst.Pt() << " / " << tlv_CurConst.Eta() << " / " << tlv_CurConst.Phi() << " / " << tlv_CurConst.M()); ATH_MSG_DEBUG("\t\tShots in this constituent: " << nShots); unsigned int totalPhotonsInNeutral = 0; - CLHEP::HepLorentzVector hlv_SumShots = CLHEP::HepLorentzVector(0., 0., 0., 0.); + TLorentzVector tlv_SumShots = TLorentzVector(0., 0., 0., 0.); for(unsigned int iShot=0; iShot<nShots; iShot++) { - PanTau::TauConstituent* curShot = shotConstituents.at(iShot); + PanTau::TauConstituent2* curShot = shotConstituents.at(iShot); unsigned int curNPhotons = curShot->getNPhotonsInShot(); ATH_MSG_DEBUG("\t\t\tPhotons in this shot: " << curNPhotons); totalPhotonsInNeutral += curShot->getNPhotonsInShot(); - ATH_MSG_DEBUG("\t\t\tEt/Eta/Phi/M of this shot: " << curShot->et() << " / " << curShot->eta() << " / " << curShot->phi() << " / " << curShot->m() ); - hlv_SumShots += curShot->hlv(); - allShotHLVs.push_back(curShot->hlv()); + ATH_MSG_DEBUG("\t\t\tPt/Eta/Phi/M of this shot: " << curShot->p4().Pt() << " / " << curShot->p4().Eta() << " / " << curShot->p4().Phi() << " / " << curShot->p4().M() ); + tlv_SumShots += curShot->p4(); + allShotTLVs.push_back(curShot->p4()); }//end loop over shots totalShotsInSeed += nShots; - totalHLV_SumShots += hlv_SumShots; + totalTLV_SumShots += tlv_SumShots; totalPhotonsInSeed += totalPhotonsInNeutral; ATH_MSG_DEBUG("\t\tTotal Photons: " << totalPhotonsInNeutral); - ATH_MSG_DEBUG("\t\tEt/Eta/Phi/M of combined shots: " << hlv_SumShots.et() << " / " << hlv_SumShots.eta() << " / " << hlv_SumShots.phi() << " / " << hlv_SumShots.m() ); - - std::string iConstStr = m_Tool_HelperFunctions->convertNumberToString((double)(iConst+1)); - ATH_MSG_DEBUG("\t\tAdded variable " << inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_nPhotons_BDTSort_" + iConstStr << " with value " << totalPhotonsInNeutral); - + ATH_MSG_DEBUG("\t\tPt/Eta/Phi/M of combined shots: " << tlv_SumShots.Pt() << " / " << tlv_SumShots.Eta() << " / " << tlv_SumShots.Phi() << " / " << tlv_SumShots.M() ); + 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); //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, hlv_SumShots.et()); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumShots_Eta_BDTSort_" + iConstStr, hlv_SumShots.eta()); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumShots_Phi_BDTSort_" + iConstStr, hlv_SumShots.phi()); - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SumShots_M_BDTSort_" + iConstStr, hlv_SumShots.m()); + 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 = hlv_CurConst.deltaR(hlv_SumShots); + 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(hlv_CurConst.et() > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtSumShotsOverConstEt_BDTSort_" + iConstStr, hlv_SumShots.et() / hlv_CurConst.et()); + 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 = hlv_Reference.deltaR(hlv_SumShots); + 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(hlv_Reference.et() > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtSumShotsOverTauEt_BDTSort_" + iConstStr, hlv_SumShots.et() / hlv_Reference.et()); + 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 @@ -676,10 +659,10 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* 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", hlv_Reference.deltaR(totalHLV_SumShots)); + tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_DeltaRAllShotsToTau", tlv_Reference.DeltaR(totalTLV_SumShots)); //et ratio - if(hlv_Reference.et() > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtAllShotsOverEtTau", totalHLV_SumShots.et() / hlv_Reference.et()); + 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); @@ -691,15 +674,15 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* double minDiShotMass = 99999; double bestDiShotMass = -200; double bestPi0Diff = 99999; - for(unsigned int iShot=0; iShot<allShotHLVs.size(); iShot++) { - CLHEP::HepLorentzVector cur_iShot = allShotHLVs.at(iShot); + for(unsigned int iShot=0; iShot<allShotTLVs.size(); iShot++) { + TLorentzVector cur_iShot = allShotTLVs.at(iShot); - for(unsigned int jShot=iShot+1; jShot<allShotHLVs.size(); jShot++) { - CLHEP::HepLorentzVector cur_jShot = allShotHLVs.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); - CLHEP::HepLorentzVector hlv_DiShot = cur_iShot + cur_jShot; - double curDiShotMass = hlv_DiShot.m(); + 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; @@ -720,47 +703,47 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* if(curTypeName != curTypeName_All) addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_EtOver", sum_Et, &m_Variants_SeedEt); - if(hlv_1st_Et.perp() != 0) addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stEtOver", hlv_1st_Et.et(), &m_Variants_SeedEt); - if(hlv_1st_BDT.perp() != 0) addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stBDTEtOver", hlv_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(hlv_Last_Et.perp() != 0) addFeatureWrtSeedEnergy(tauFeatureMap, inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_SoftestEtOver", hlv_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(hlv_1st_Et.perp() != 0 && sum_Et > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stEtOverTypeEt", hlv_1st_Et.et() / sum_Et); - if(hlv_1st_BDT.perp() != 0 && sum_Et > 0.) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stBDTEtOverTypeEt", hlv_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(hlv_1st_Et.perp() != 0 && hlv_2nd_Et.perp() != 0) { - if(hlv_1st_Et.et() > 0. && hlv_2nd_Et.et() > 0. ) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log1stEtOver2ndEt", TMath::Log10(hlv_1st_Et.et() / hlv_2nd_Et.et())); + 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(hlv_1st_Et.perp() != 0 && hlv_3rd_Et.perp() != 0) { - if(hlv_1st_Et.et() > 0. && hlv_3rd_Et.et() > 0.) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log1stEtOver3rdEt", TMath::Log10(hlv_1st_Et.et() / hlv_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(hlv_2nd_Et.perp() != 0 && hlv_3rd_Et.perp() != 0) { - if(hlv_2nd_Et.et() > 0. && hlv_3rd_Et.et() > 0.) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log2ndEtOver3rdEt", TMath::Log10(hlv_2nd_Et.et() / hlv_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(hlv_1st_BDT.perp() != 0 && hlv_2nd_BDT.perp() != 0) { - if(hlv_1st_BDT.et() > 0. && hlv_2nd_BDT.et() > 0. ) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log1stEtOver2ndEt_BDTSort", TMath::Log10(hlv_1st_BDT.et() / hlv_2nd_BDT.et())); + 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(hlv_1st_BDT.perp() != 0 && hlv_3rd_BDT.perp() != 0) { - if(hlv_1st_BDT.et() > 0. && hlv_3rd_BDT.et() > 0.) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log1stEtOver3rdEt_BDTSort", TMath::Log10(hlv_1st_BDT.et() / hlv_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(hlv_2nd_BDT.perp() != 0 && hlv_3rd_BDT.perp() != 0) { - if(hlv_2nd_BDT.et() > 0. && hlv_3rd_BDT.et() > 0.) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_Log2ndEtOver3rdEt_BDTSort", TMath::Log10(hlv_2nd_BDT.et() / hlv_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())); } } @@ -812,10 +795,10 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* //! Standard deviations /////////////////////////////////////////// prefixVARType = m_varTypeName_StdDev; - double stddev_E = m_Tool_HelperFunctions->stddev(sum_E2, sum_E, num_EFOs); - double stddev_Et = m_Tool_HelperFunctions->stddev(sum_Et2, sum_Et, num_EFOs); - double stddev_DRToJetAxis = m_Tool_HelperFunctions->stddev(sum_DR2ToReference, sum_DRToReference, num_EFOs); - double stddev_DRToLeading = m_Tool_HelperFunctions->stddev(sum_DRToLeading, sum_DR2ToLeading, num_EFOs); + 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); @@ -831,26 +814,26 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* double angle_13 = 0; double angle_23 = 0; - if(curTypeName != curTypeName_All) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_ToJetAxis", hlv_Reference.angle(hlv_TypeConstituents)); - if(hlv_1st_Et.perp() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stToJetAxis", hlv_Reference.angle(hlv_1st_Et)); - if(hlv_2nd_Et.perp() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndToJetAxis", hlv_Reference.angle(hlv_2nd_Et)); - if(hlv_3rd_Et.perp() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_3rdToJetAxis", hlv_Reference.angle(hlv_3rd_Et)); - if(hlv_1st_Et.perp() != 0) { - if(hlv_2nd_Et.perp() != 0) { - angle_12 = hlv_1st_Et.angle(hlv_2nd_Et); + 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(hlv_3rd_Et.perp() != 0) { - angle_13 = hlv_1st_Et.angle(hlv_3rd_Et); + 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(hlv_2nd_Et.perp() != 0 && hlv_3rd_Et.perp() != 0) { - angle_23 = hlv_2nd_Et.angle(hlv_3rd_Et); + 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 && hlv_1st_Et.perp() != 0 && hlv_2nd_Et.perp() != 0 && hlv_3rd_Et.perp() != 0) { - double angle_Planes = ( hlv_1st_Et.vect().cross(hlv_2nd_Et.vect()) ).angle( hlv_1st_Et.vect().cross(hlv_3rd_Et.vect()) ); + 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; @@ -869,28 +852,28 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* //! DeltaR /////////////////////////////////////////// prefixVARType = m_varTypeName_DeltaR; - if(curTypeName != curTypeName_All) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_ToJetAxis", hlv_Reference.deltaR(hlv_TypeConstituents)); + 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(hlv_1st_Et.perp() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stToJetAxis_EtSort", hlv_Reference.deltaR(hlv_1st_Et)); - if(hlv_2nd_Et.perp() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndToJetAxis_EtSort", hlv_Reference.deltaR(hlv_2nd_Et)); - if(hlv_3rd_Et.perp() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_3rdToJetAxis_EtSort", hlv_Reference.deltaR(hlv_3rd_Et)); - if(hlv_1st_Et.perp() != 0) { - if(hlv_2nd_Et.perp() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stTo2nd_EtSort", hlv_1st_Et.deltaR(hlv_2nd_Et)); - if(hlv_3rd_Et.perp() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stTo3rd_EtSort", hlv_1st_Et.deltaR(hlv_3rd_Et)); + 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(hlv_2nd_Et.perp() != 0 && hlv_3rd_Et.perp() != 0) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndTo3rd_EtSort", hlv_2nd_Et.deltaR(hlv_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(hlv_1st_BDT.perp() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stToJetAxis_BDTSort", hlv_Reference.deltaR(hlv_1st_BDT)); - if(hlv_2nd_BDT.perp() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndToJetAxis_BDTSort", hlv_Reference.deltaR(hlv_2nd_BDT)); - if(hlv_3rd_BDT.perp() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_3rdToJetAxis_BDTSort", hlv_Reference.deltaR(hlv_3rd_BDT)); - if(hlv_1st_BDT.perp() != 0) { - if(hlv_2nd_BDT.perp() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stTo2nd_BDTSort", hlv_1st_BDT.deltaR(hlv_2nd_BDT)); - if(hlv_3rd_BDT.perp() != 0) tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_1stTo3rd_BDTSort", hlv_1st_BDT.deltaR(hlv_3rd_BDT)); + 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(hlv_2nd_BDT.perp() != 0 && hlv_3rd_BDT.perp() != 0) { - tauFeatureMap->addFeature(inputAlgName + "_" + curTypeName + "_" + prefixVARType + "_2ndTo3rd_BDTSort", hlv_2nd_BDT.deltaR(hlv_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)); } @@ -915,79 +898,79 @@ StatusCode PanTau::Tool_FeatureExtractor::calculateFeatures(PanTau::PanTauSeed* -StatusCode PanTau::Tool_FeatureExtractor::addCombinedFeatures(PanTau::PanTauSeed* inSeed) { +StatusCode PanTau::Tool_FeatureExtractor::addCombinedFeatures(PanTau::PanTauSeed2* inSeed) { //! ////////////////////////////////////////// //! Prepare some short notations for variables //! ////////////////////////////////////////// - PanTau::TauFeature* tauFeatures = inSeed->getFeatures(); + PanTau::TauFeature2* tauFeatures = inSeed->getFeatures(); std::string inputAlgName = inSeed->getNameInputAlgorithm(); //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; + 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::TauConstituent*> list_NeutralConstituents = inSeed->getConstituentsOfType(et_Neutral, 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::TauConstituent::t_nTypes]; - double num_EFOs[PanTau::TauConstituent::t_nTypes]; - CLHEP::HepLorentzVector hlv_System[PanTau::TauConstituent::t_nTypes]; - CLHEP::HepLorentzVector hlv_1stEFO[PanTau::TauConstituent::t_nTypes]; - CLHEP::HepLorentzVector hlv_2ndEFO[PanTau::TauConstituent::t_nTypes]; + 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 hlv_Sys_OK[PanTau::TauConstituent::t_nTypes]; - bool hlv_1st_OK[PanTau::TauConstituent::t_nTypes]; - bool hlv_2nd_OK[PanTau::TauConstituent::t_nTypes]; + 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::TauConstituent::t_nTypes; iType++) { + for(unsigned int iType=0; iType<(unsigned int)PanTau::TauConstituent2::t_nTypes; iType++) { name_EFOType[iType] = ""; num_EFOs[iType] = 0.; - hlv_System[iType] = CLHEP::HepLorentzVector(); - hlv_1stEFO[iType] = CLHEP::HepLorentzVector(); - hlv_2ndEFO[iType] = CLHEP::HepLorentzVector(); - hlv_Sys_OK[iType] = false; - hlv_1st_OK[iType] = false; - hlv_2nd_OK[iType] = false; + 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); + for(int iType=0; iType<(int)PanTau::TauConstituent2::t_nTypes; iType++) { + name_EFOType[iType] = PanTau::TauConstituent2::getTypeName((PanTau::TauConstituent2::Type)iType); - hlv_System[iType] = inSeed->getSubsystemHLV(iType, hlv_Sys_OK[iType]); - if(hlv_Sys_OK[iType] == false) continue; + tlv_System[iType] = inSeed->getSubsystemHLV(iType, tlv_Sys_OK[iType]); + if(tlv_Sys_OK[iType] == false) continue; - std::vector<TauConstituent*> typeConstituents = inSeed->getConstituentsOfType(iType, hlv_Sys_OK[iType]); - if(typeConstituents.size() == 0) hlv_Sys_OK[iType] = false; - if(hlv_Sys_OK[iType] == false) continue; + 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; num_EFOs[iType] = typeConstituents.size(); if(typeConstituents.size() > 0) { - hlv_1stEFO[iType] = typeConstituents.at(0)->hlv(); - hlv_1st_OK[iType] = true; + tlv_1stEFO[iType] = typeConstituents.at(0)->p4(); + tlv_1st_OK[iType] = true; } else { - hlv_1st_OK[iType] = false; + tlv_1st_OK[iType] = false; } if(typeConstituents.size() > 1) { - hlv_2ndEFO[iType] = typeConstituents.at(1)->hlv(); - hlv_2nd_OK[iType] = true; + tlv_2ndEFO[iType] = typeConstituents.at(1)->p4(); + tlv_2nd_OK[iType] = true; } else { - hlv_2nd_OK[iType] = false; + tlv_2nd_OK[iType] = false; } } @@ -1001,31 +984,31 @@ StatusCode PanTau::Tool_FeatureExtractor::addCombinedFeatures(PanTau::PanTauSeed //! Combined-Single Features //////////////////////////////////////// // Ratios of numbers (heavily spiked, just keep them for validation) - if(hlv_Sys_OK[et_Charged] == true && hlv_Sys_OK[et_Neutral] && num_EFOs[et_Neutral] > 0.) { + 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(hlv_Sys_OK[et_Charged] == true && hlv_Sys_OK[et_All] && num_EFOs[et_All] > 0.) { + 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(hlv_1st_OK[et_Charged] && hlv_1st_OK[et_Neutral] && hlv_2nd_OK[et_Neutral]) { - CLHEP::Hep3Vector axis_Plane_cn1 = (hlv_1stEFO[et_Charged].vect()).cross( hlv_1stEFO[et_Neutral].vect() ); - CLHEP::Hep3Vector axis_Plane_cn2 = (hlv_1stEFO[et_Charged].vect()).cross( hlv_2ndEFO[et_Neutral].vect() ); - double anglePlanes = axis_Plane_cn1.angle(axis_Plane_cn2); + 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::TauConstituent* tauConst_NeutralLargestAngle = m_Tool_HelperFunctions->getNeutralConstWithLargestAngle(hlv_System[et_Charged], + PanTau::TauConstituent2* tauConst_NeutralLargestAngle = m_HelperFunctions.getNeutralConstWithLargestAngle(tlv_System[et_Charged], list_NeutralConstituents); if(tauConst_NeutralLargestAngle != 0) { - CLHEP::HepLorentzVector hlv_NeutralLargestAngle = tauConst_NeutralLargestAngle->hlv(); + TLorentzVector tlv_NeutralLargestAngle = tauConst_NeutralLargestAngle->p4(); - tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_FarthestNeutral_AngleToCharged", hlv_System[et_Charged].angle(hlv_NeutralLargestAngle.vect()) ); + tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_FarthestNeutral_AngleToCharged", tlv_System[et_Charged].Angle(tlv_NeutralLargestAngle.Vect()) ); tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_FarthestNeutral_BDTScore", tauConst_NeutralLargestAngle->getBDTValue()); - if(hlv_System[et_Charged].et() > 0) tauFeatures->addFeature(inputAlgName + "_" + prefixVARType + "_FarthestNeutral_EtOverChargedEt", hlv_NeutralLargestAngle.et() / hlv_System[et_Charged].et()); + 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 //////////////////////////////////////// @@ -1033,32 +1016,32 @@ StatusCode PanTau::Tool_FeatureExtractor::addCombinedFeatures(PanTau::PanTauSeed // 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::TauConstituent::t_nTypes; iType++) { + for(int iType=0; iType<PanTau::TauConstituent2::t_nTypes; iType++) { - if(iType == (int)PanTau::TauConstituent::t_NoType) continue; + if(iType == (int)PanTau::TauConstituent2::t_NoType) continue; int type_Denom = iType; - for(int jType=0; jType<PanTau::TauConstituent::t_nTypes; jType++) { + for(int jType=0; jType<PanTau::TauConstituent2::t_nTypes; jType++) { - if(jType == (int)PanTau::TauConstituent::t_NoType) continue; + if(jType == (int)PanTau::TauConstituent2::t_NoType) continue; int type_Nom = jType; if(jType == iType) continue; - std::string typeName_Nom = PanTau::TauConstituent::getTypeName((PanTau::TauConstituent::Type)type_Nom); - std::string typeName_Denom = PanTau::TauConstituent::getTypeName((PanTau::TauConstituent::Type)type_Denom); + std::string typeName_Nom = PanTau::TauConstituent2::getTypeName((PanTau::TauConstituent2::Type)type_Nom); + std::string typeName_Denom = PanTau::TauConstituent2::getTypeName((PanTau::TauConstituent2::Type)type_Denom); double sum_Et_Nom = 0.0; double sum_Et_Denom = 0.0; - if(hlv_Sys_OK[type_Nom] && hlv_Sys_OK[type_Denom]) { - sum_Et_Nom = hlv_System[type_Nom].et(); - sum_Et_Denom = hlv_System[type_Denom].et(); + 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(); } //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(hlv_1st_OK[type_Nom]) { - double LeadEFO_Et_Nom = hlv_1stEFO[type_Nom].et(); + 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) ); } @@ -1073,21 +1056,21 @@ StatusCode PanTau::Tool_FeatureExtractor::addCombinedFeatures(PanTau::PanTauSeed }//end check for div by zero //Angles between systems - if(hlv_Sys_OK[type_Nom] && hlv_Sys_OK[type_Denom]) { - double angle_system = hlv_System[type_Nom].angle( hlv_System[type_Denom] ); - m_Tool_HelperFunctions->dumpFourMomentum(hlv_System[type_Nom]); - m_Tool_HelperFunctions->dumpFourMomentum(hlv_System[type_Denom]); + 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 - if(hlv_1st_OK[type_Nom] && hlv_1st_OK[type_Denom]) { + if(tlv_1st_OK[type_Nom] && tlv_1st_OK[type_Denom]) { //Delta R between 1st and 1st EFO - double deltaR_1st1st = hlv_1stEFO[type_Nom].deltaR( hlv_1stEFO[type_Denom] ); + 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 = hlv_1stEFO[type_Nom].angle( hlv_1stEFO[type_Denom] ); + 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 @@ -1109,25 +1092,25 @@ StatusCode PanTau::Tool_FeatureExtractor::addCombinedFeatures(PanTau::PanTauSeed int et_c = index_charged[cType]; int et_n = index_neutral[nType]; - std::string name_cType = PanTau::TauConstituent::getTypeName((PanTau::TauConstituent::Type)et_c); - std::string name_nType = PanTau::TauConstituent::getTypeName((PanTau::TauConstituent::Type)et_n); + std::string name_cType = PanTau::TauConstituent2::getTypeName((PanTau::TauConstituent2::Type)et_c); + std::string name_nType = PanTau::TauConstituent2::getTypeName((PanTau::TauConstituent2::Type)et_n); - if(hlv_Sys_OK[et_c]==false || hlv_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 = ( hlv_System[et_c].et() + hlv_System[et_n].et() ) / (num_EFOs[et_c] + num_EFOs[et_n]); + 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 = ( hlv_System[et_c] + hlv_System[et_n] ).m(); + 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(hlv_2nd_OK[et_n]) { + if(tlv_2nd_OK[et_n]) { //Angles between 1st and 2nd EFO - double angle_1st2nd = hlv_1stEFO[et_c].angle( hlv_2ndEFO[et_n] ); + 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 @@ -1140,17 +1123,17 @@ StatusCode PanTau::Tool_FeatureExtractor::addCombinedFeatures(PanTau::PanTauSeed -StatusCode PanTau::Tool_FeatureExtractor::addGenericJetFeatures(PanTau::PanTauSeed* inSeed) const { +StatusCode PanTau::Tool_FeatureExtractor::addGenericJetFeatures(PanTau::PanTauSeed2* inSeed) const { std::string inputAlgName = inSeed->getNameInputAlgorithm(); - std::vector<TauConstituent*> allConstituents = inSeed->getConstituentsAsList_Core(); - PanTau::TauFeature* tauFeatures = inSeed->getFeatures(); + std::vector<TauConstituent2*> allConstituents = inSeed->getConstituentsAsList_Core(); + PanTau::TauFeature2* tauFeatures = inSeed->getFeatures(); const std::string namePrefix = m_varTypeName_JetShape; //! Jet Thrust if(allConstituents.size() > 1) { bool thrustOK = false; - std::vector<double> thrustValues = m_Tool_HelperFunctions->calcThrust(&allConstituents, thrustOK); + std::vector<double> thrustValues = m_HelperFunctions.calcThrust(&allConstituents, thrustOK); if (thrustValues.size() == 3 && thrustOK==true) { const double thrust = thrustValues[0]; const double thrust_major = thrustValues[1]; @@ -1169,7 +1152,7 @@ StatusCode PanTau::Tool_FeatureExtractor::addGenericJetFeatures(PanTau::PanTauSe //! Jet Fox Wolfram Moments // described here: http://cepa.fnal.gov/psm/simulation/mcgen/lund/pythia_manual/pythia6.3/pythia6301/node215.html bool fwOK = false; - std::vector<double> fwValues = m_Tool_HelperFunctions->calcFWMoments(&allConstituents, fwOK); + std::vector<double> fwValues = m_HelperFunctions.calcFWMoments(&allConstituents, fwOK); if(fwOK == true) { tauFeatures->addFeature(inputAlgName + "_" + namePrefix + "_JetFoxWolfram1", fwValues[1]); tauFeatures->addFeature(inputAlgName + "_" + namePrefix + "_JetFoxWolfram2", fwValues[2]); @@ -1187,7 +1170,7 @@ StatusCode PanTau::Tool_FeatureExtractor::addGenericJetFeatures(PanTau::PanTauSe //! Sphericity, aplanarity and planarity bool sphericityOK =false; - std::vector<double> sphValues = m_Tool_HelperFunctions->calcSphericity(&allConstituents, sphericityOK); + std::vector<double> sphValues = m_HelperFunctions.calcSphericity(&allConstituents, sphericityOK); if(sphericityOK == true) { tauFeatures->addFeature(inputAlgName + "_" + namePrefix + "_JetSphericity", sphValues[0]); tauFeatures->addFeature(inputAlgName + "_" + namePrefix + "_JetAplanarity", sphValues[1]); @@ -1199,7 +1182,7 @@ StatusCode PanTau::Tool_FeatureExtractor::addGenericJetFeatures(PanTau::PanTauSe -StatusCode PanTau::Tool_FeatureExtractor::addImpactParameterFeatures(PanTau::PanTauSeed* inSeed) const { +StatusCode PanTau::Tool_FeatureExtractor::addImpactParameterFeatures(PanTau::PanTauSeed2* inSeed) const { const xAOD::TauJet* tauJet = inSeed->getTauJet(); // const Trk::RecVertex* vtx_TauJet = 0; //inSeed->getTauJet()->origin(); @@ -1210,7 +1193,7 @@ StatusCode PanTau::Tool_FeatureExtractor::addImpactParameterFeatures(PanTau::Pan return StatusCode::SUCCESS; } - PanTau::TauFeature* tauFeatures = inSeed->getFeatures(); + PanTau::TauFeature2* tauFeatures = inSeed->getFeatures(); std::string inputAlgName = inSeed->getNameInputAlgorithm(); std::string featureNamePrefix = m_varTypeName_ImpactParams; std::vector<double> impactParameters(0); @@ -1218,15 +1201,15 @@ StatusCode PanTau::Tool_FeatureExtractor::addImpactParameterFeatures(PanTau::Pan // get jet direction: // CLHEP::Hep3Vector vec_Tau = const_cast<Analysis::TauJet*>(inSeed->getTauJet())->getHLV(TauJetParameters::IntermediateAxis).vect(); - TLorentzVector hlv_Tau; - hlv_Tau.SetPtEtaPhiM(tauJet->ptIntermediateAxis(), tauJet->etaIntermediateAxis(), tauJet->phiIntermediateAxis(), tauJet->mIntermediateAxis()); - TVector3 vec_Tau = hlv_Tau.Vect(); - const CLHEP::Hep3Vector tauDirection = CLHEP::Hep3Vector(vec_Tau.X(), vec_Tau.Y(), vec_Tau.Z()); + 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::TauConstituent*> list_ChargedConsts = inSeed->getConstituentsOfType(PanTau::TauConstituent::t_Charged, 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); @@ -1237,16 +1220,29 @@ StatusCode PanTau::Tool_FeatureExtractor::addImpactParameterFeatures(PanTau::Pan for(unsigned int iTrk=0; iTrk<list_Tracks.size(); iTrk++) { const xAOD::TrackParticle* curTrack = list_Tracks[iTrk]; + //const Trk::Perigee* perigee = m_trackToVertexTool->perigeeAtVertex(curTrack, (*pTau.vertexLink())->position()); + //const Trk::Perigee* perigee = m_trackToVertexTool->perigeeAtVertex(curTrack, vtx_TauJet->position()); + /* const Trk::ImpactParametersAndSigma* impactParameter = m_Tool_TrackToVertexIPEstimator->estimate(curTrack, vtx_TauJet); if(impactParameter == 0) { ATH_MSG_DEBUG("could not extract impact parameter for track at " << curTrack << " and vtx at " << vtx_TauJet); continue; } + */ //get d0 value and significance - double recoD0 = fabs(impactParameter->IPd0); - double signfD0 = (impactParameter->sigmad0 > 0. ? fabs(recoD0/impactParameter->sigmad0) : -999. ); + //double recoD0 = fabs(impactParameter->IPd0); + //double recoD0 = perigee->parameters()[Trk::d0]; + // from http://acode-browser.usatlas.bnl.gov/lxr/source/atlas/PhysicsAnalysis/StandardModelPhys/Validation/ZeeValidation/src/ReconElectronsPlots.cxx#0242 + double recoD0 = curTrack->d0(); + //double signfD0 = (impactParameter->sigmad0 > 0. ? fabs(recoD0/impactParameter->sigmad0) : -999. ); + //double signfD0 = perigee->parameters()[Trk::d0]/std::sqrt((*perigee->covariance())(Trk::d0, Trk::d0)); + double errD02 = curTrack->definingParametersCovMatrix()(0, 0); + double signfD0 = -999.; + if(errD02 > 0) signfD0 = curTrack->d0() / sqrtf( errD02 ); + /* + // Need that? if (vtx_TauJet) { //FIXME: //xAOD::TrackParticle does not return requested Trk::TrackParameters for get3DLifetimeSignOfTrack @@ -1256,10 +1252,20 @@ StatusCode PanTau::Tool_FeatureExtractor::addImpactParameterFeatures(PanTau::Pan } else { ATH_MSG_WARNING( "No primary vertex, use absolute value of transverse impact parameter" ); } + */ //get z0 value and significance - double recoZ0 = fabs(impactParameter->IPz0); - double signfZ0 = (impactParameter->sigmaz0 > 0. ? fabs(recoZ0/impactParameter->sigmaz0) : -999. ); + //double recoZ0 = fabs(impactParameter->IPz0); + //double recoZ0 = perigee->parameters()[Trk::z0]; + // from http://acode-browser.usatlas.bnl.gov/lxr/source/atlas/PhysicsAnalysis/StandardModelPhys/Validation/ZeeValidation/src/ReconElectronsPlots.cxx#0242 + double recoZ0 = curTrack->z0(); + //double signfZ0 = (impactParameter->sigmaz0 > 0. ? fabs(recoZ0/impactParameter->sigmaz0) : -999. ); + //double signfZ0 = perigee->parameters()[Trk::z0]/std::sqrt((*perigee->covariance())(Trk::z0, Trk::z0)); + double errZ02 = curTrack->definingParametersCovMatrix()(1, 1); + double signfZ0 = -999.; + if(errZ02 > 0) signfZ0 = curTrack->z0() / sqrtf( errZ02 ); + /* + // Need that? if (vtx_TauJet) { //FIXME: //xAOD::TrackParticle does not return requested Trk::TrackParameters for getZLifetimeSignOfTrack @@ -1269,10 +1275,11 @@ StatusCode PanTau::Tool_FeatureExtractor::addImpactParameterFeatures(PanTau::Pan } else { ATH_MSG_WARNING( "No primary vertex, use absolute value of longitudinal impact parameter" ); } + */ // add to features if (iTrk < 4) { - std::string indexTrk = m_Tool_HelperFunctions->convertNumberToString(iTrk+1); + std::string indexTrk = m_HelperFunctions.convertNumberToString(iTrk+1); tauFeatures->addFeature(inputAlgName + "_" + featureNamePrefix + "_TransIPTrack" + indexTrk + "_SortByEt", recoD0 ); tauFeatures->addFeature(inputAlgName + "_" + featureNamePrefix + "_LongIPTrack" + indexTrk + "_SortByEt", recoZ0 ); @@ -1282,9 +1289,11 @@ StatusCode PanTau::Tool_FeatureExtractor::addImpactParameterFeatures(PanTau::Pan impactParameters.push_back(fabs(recoD0)); impactParameterSignf.push_back(fabs(signfD0)); } - + + /* delete impactParameter; impactParameter = 0; + */ }//end loop over tracks @@ -1293,7 +1302,7 @@ StatusCode PanTau::Tool_FeatureExtractor::addImpactParameterFeatures(PanTau::Pan std::sort( impactParameterSignf.begin(), impactParameterSignf.end(), std::greater<double>() ); for(unsigned int iIP=0; iIP<impactParameters.size(); iIP++) { - std::string curNum = m_Tool_HelperFunctions->convertNumberToString(iIP+1); + 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] ); } diff --git a/Reconstruction/PanTau/PanTauAlgs/src/Tool_InformationStore.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_InformationStore.cxx similarity index 57% rename from Reconstruction/PanTau/PanTauAlgs/src/Tool_InformationStore.cxx rename to Reconstruction/PanTau/PanTauAlgs/Root/Tool_InformationStore.cxx index 235e8de33631b457ef2e1c252e2ec31835dd4f10..28732b175ce95b15663c815c04316a12deb77656 100644 --- a/Reconstruction/PanTau/PanTauAlgs/src/Tool_InformationStore.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_InformationStore.cxx @@ -12,33 +12,17 @@ // limbach@physik.uni-bonn.de /////////////////////////////////////////////////////////////////// -//! Gaudi includes -#include "AthenaKernel/errorcheck.h" -#include "StoreGate/StoreGateSvc.h" - //! PanTau includes #include "PanTauAlgs/Tool_InformationStore.h" // ROOT includes #include "TVector2.h" -// #include "tauEvent/TauJetContainer.h" -#include "xAODTau/TauJetContainer.h" - -#include "eflowEvent/eflowObjectContainer.h" -#include "eflowEvent/eflowObject.h" -#include "Particle/TrackParticleContainer.h" PanTau::Tool_InformationStore::Tool_InformationStore( - const std::string& ty, - const std::string& na, - const IInterface* pa ) : - AthAlgTool(ty,na,pa), - m_Container_eflowRec(0), - //m_Container_eflowRecFromSG(0), - m_Container_TauRec(0) - { - declareInterface<ITool_InformationStore>(this); + 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"); @@ -56,14 +40,9 @@ PanTau::Tool_InformationStore::~Tool_InformationStore() { StatusCode PanTau::Tool_InformationStore::initialize() { ATH_MSG_INFO( name() << " initialize()" ); - CHECK( AthAlgTool::initialize() ); - //get link to store gate - CHECK(service("StoreGateSvc", m_sgSvc)); - - CHECK( this->getInfo_String("Name_eflowRecContainer", m_Name_Container_eflowRec) ); - CHECK( this->getInfo_String("Name_TauRecContainer", m_Name_Container_TauRec) ); - 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; } @@ -76,37 +55,6 @@ StatusCode PanTau::Tool_InformationStore::initialize() { // } -StatusCode PanTau::Tool_InformationStore::updateInformation(std::string /*inputAlg*/) { - - //get the tauRec container - StatusCode sc = m_sgSvc->retrieve(m_Container_TauRec, m_Name_Container_TauRec); - if(sc != StatusCode::SUCCESS) { - ATH_MSG_WARNING("Could not get container for tauRec -> skip this execution of PanTau"); - return StatusCode::RECOVERABLE; - } - - return StatusCode::SUCCESS; -} - - - -const eflowObjectContainer* PanTau::Tool_InformationStore::getContainer_eflowRec() const { - return m_Container_eflowRec; -} - - - -const xAOD::TauJetContainer* PanTau::Tool_InformationStore::getContainer_TauRec() const { - return m_Container_TauRec; -} - - -const Rec::TrackParticleContainer* PanTau::Tool_InformationStore::getContainer_TrackParticle() const { - return m_Container_TrackParticle; -} - - - 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()) { @@ -204,52 +152,9 @@ StatusCode PanTau::Tool_InformationStore::dumpMaps() const { ATH_MSG_DEBUG("\t" << key << ": " << val); } -// ATH_MSG_DEBUG("VecString variables: "); -// MapVecString::const_iterator itVS = m_Infos_VecString.begin(); -// for(; itVS != m_Infos_VecString.end(); itVS++) { -// std::string key = itVS->first; -// std::vector<std::string> val = itVS->second; -// ATH_MSG_DEBUG("\t" << key << ": " << val.size()); -// for(unsigned int iVal=0; iVal<val.size(); iVal++) ATH_MSG_DEBUG("\t\t" << val[iVal]); -// } - ATH_MSG_DEBUG("Done dumping information in Tool_InformationStore called " << name()); return StatusCode::SUCCESS; } -void PanTau::Tool_InformationStore::checkEFOContainer(const eflowObjectContainer* inputContainer, eflowObjectContainer* outputContainer) { - - for(unsigned int iEFO=0; iEFO<inputContainer->size(); iEFO++) { - const eflowObject* curEFO = inputContainer->at(iEFO); - double cur_Et = curEFO->et(); - double cur_Eta = curEFO->eta(); - double cur_Phi = curEFO->phi(); - double cur_M = curEFO->m(); - - //loop over EFOs that were already added to check for duplicates - bool isOK = true; - for(unsigned int jEFO=0; jEFO<outputContainer->size(); jEFO++) { - const eflowObject* goodEFO = outputContainer->at(jEFO); - double diff_Et = fabs(goodEFO->et() - cur_Et); - double diff_Eta = fabs(goodEFO->eta() - cur_Eta); - //double diff_Phi = fabs(goodEFO->phi() - cur_Phi); // bug! shouldn't matter much but nevertheless... - double diff_Phi = fabs( TVector2::Phi_mpi_pi( goodEFO->phi() - cur_Phi ) ); - double diff_m = fabs(goodEFO->m() - cur_M); - - if(diff_Et < 0.000001 && diff_Eta < 0.000001 && diff_Phi < 0.000001 && diff_m < 0.000001 ) { - ATH_MSG_DEBUG("Skipping dubplicated EFO at " << curEFO << " of charge " << curEFO->charge() << " with Et/Eta/Phi: " << cur_Et << " / " << cur_Eta << " / " << cur_Phi); - isOK = false; - break; - } - }//end loop over good EFOs - - if(isOK == false) continue; - - outputContainer->push_back( const_cast<eflowObject*>(curEFO) ); - - }//end loop over EFOs -} - - diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_InputConverter.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_InputConverter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..de0fc1d7cd948f16e46a2d4e84562a0650c01fee --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_InputConverter.cxx @@ -0,0 +1,224 @@ +/* + Copyright (C) 2002-2017 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" + +//! 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") +{ + declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Link to tool with all information"); +} + +PanTau::Tool_InputConverter::~Tool_InputConverter() { +} + +StatusCode PanTau::Tool_InputConverter::initialize() { + + ATH_MSG_INFO(" initialize()"); + + 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->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; +} + + +// StatusCode PanTau::Tool_InformationStore::finalize() { +// StatusCode sc = AlgTool::finalize(); +// return sc; +// } + + +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->charge() == 0 && 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; + } + + + //! ================================================== + //! 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(pfoCharge == 0) { + constituentMass = 134.98; + } + } + + + ATH_MSG_DEBUG("About to create 4 vector of EFO. E / Eta / Phi / m: " << 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; + + double mvaValue = PanTau::TauConstituent2::DefaultBDTValue(); + + 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(pfoCharge != 0) { + itsTypeFlags.at((int)PanTau::TauConstituent2::t_OutChrg) = 1; + } + if(pfoCharge == 0) { + 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(pfoCharge != 0) { + itsTypeFlags.at((int)PanTau::TauConstituent2::t_Charged) = 1; + } + if(pfoCharge == 0) { + itsTypeFlags.at((int)PanTau::TauConstituent2::t_Neutral) = 1; + itsTypeFlags.at((int)PanTau::TauConstituent2::t_NeutLowA) = 1; + itsTypeFlags.at((int)PanTau::TauConstituent2::t_NeutLowB) = 1; + + //neutral PFO arranging --- check for pi0 tag + mvaValue = pfo->bdtPi0Score(); + + // bool isThreeProng = false; + // if(tauJet->nTracks() == 3) isThreeProng = true; + // ATH_MSG_DEBUG("numTrack = " << tauJet->nTracks() << ", is Threeprong = " << isThreeProng); + + 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; + + } + }//end if pfo is in core + + + //! ================================================== + //! create the tau constituent + tauConstituent = new PanTau::TauConstituent2(momentum, pfoCharge, itsTypeFlags, mvaValue, pfo); + tauConstituent->makePrivateStore(); + ATH_MSG_DEBUG("Created new TauConstituent2 at: " << tauConstituent); + ATH_MSG_DEBUG("\t Eta value of its 4-vector: " << momentum.Eta()); + + //! ================================================== + //! 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"); + } + + ATH_MSG_DEBUG("Number of shots in cluster:" << list_TauShots.size()); + if(list_TauShots.size() > 0) { + ATH_MSG_DEBUG("Now converting shots of cluster with E, Eta, Phi, M: " << momentum.E() << ", " << momentum.Eta() << ", " << momentum.Phi() << ", " << momentum.M()); + 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; + } + + xAOD::PFO* curShot = const_cast<xAOD::PFO*>( dynamic_cast<const xAOD::PFO*>(list_TauShots.at(iShot)) ); + ATH_MSG_DEBUG("Checking shot E, Eta, Phi, M: " << curShot->e() << ", " << curShot->eta() << ", " << curShot->phi() << ", " << curShot->m()); + 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(); + ATH_MSG_DEBUG("\tAdded shot with E, Eta, Phi, M: " << shotMomentum.E() << ", " << shotMomentum.Eta() << ", " << shotMomentum.Phi() << ", " << shotMomentum.M()); + + 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); + ATH_MSG_DEBUG("\tThe shot has " << shotConstituent->getNPhotonsInShot() << " photons in it"); + tauConstituent->addShot(shotConstituent); + + }//end loop over shots + } + + return StatusCode::SUCCESS; +} + + diff --git a/Reconstruction/PanTau/PanTauAlgs/src/Tool_ModeDiscriminator.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_ModeDiscriminator.cxx similarity index 63% rename from Reconstruction/PanTau/PanTauAlgs/src/Tool_ModeDiscriminator.cxx rename to Reconstruction/PanTau/PanTauAlgs/Root/Tool_ModeDiscriminator.cxx index e844cad80585c4b8a7b80a811b1fb3ee5e85acfd..5bf8a733326d6ce177f496ea3b6255491ef81781 100644 --- a/Reconstruction/PanTau/PanTauAlgs/src/Tool_ModeDiscriminator.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_ModeDiscriminator.cxx @@ -18,8 +18,8 @@ //! PanTau includes #include "PanTauAlgs/Tool_ModeDiscriminator.h" #include "PanTauAlgs/Tool_InformationStore.h" -#include "PanTauEvent/TauFeature.h" -#include "PanTauEvent/PanTauSeed.h" +#include "PanTauAlgs/TauFeature.h" +#include "PanTauAlgs/PanTauSeed.h" //! Root #include "TString.h" @@ -30,26 +30,18 @@ //!Other #include "PathResolver/PathResolver.h" -#include "tauEvent/TauJet.h" - PanTau::Tool_ModeDiscriminator::Tool_ModeDiscriminator( - const std::string& ty, - const std::string& na, - const IInterface* pa ) : - AthAlgTool(ty,na,pa), + const std::string& name ) : + asg::AsgTool(name), m_Name_InputAlg("InvalidInputAlg"), m_Name_ModeCase("InvalidModeCase"), m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore"), - m_Tool_HelperFunctions("PanTau::Tool_HelperFunctions/Tool_HelperFunctions"), m_TMVA_ReaderList() { - declareInterface<ITool_ModeDiscriminator>(this); - 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_HelperFunctions", m_Tool_HelperFunctions, "Handle to the helper functions tool"); } @@ -62,28 +54,26 @@ PanTau::Tool_ModeDiscriminator::~Tool_ModeDiscriminator() { StatusCode PanTau::Tool_ModeDiscriminator::initialize() { ATH_MSG_DEBUG( name() << " initialize()" ); - CHECK( AthAlgTool::initialize() ); ATH_MSG_DEBUG("InputAlg : " << m_Name_InputAlg); ATH_MSG_DEBUG("Mode Case : " << m_Name_ModeCase); - CHECK(m_Tool_InformationStore.retrieve()); - CHECK(m_Tool_HelperFunctions.retrieve()); + ATH_CHECK(m_Tool_InformationStore.retrieve()); //get the required information from the informationstore tool ATH_MSG_DEBUG("Get infos from information store & configure..."); - CHECK( m_Tool_InformationStore->getInfo_VecDouble("ModeDiscriminator_BinEdges_Pt", m_BinEdges_Pt)); - CHECK( m_Tool_InformationStore->getInfo_String("ModeDiscriminator_ReaderOption", m_ReaderOption) ); - CHECK( m_Tool_InformationStore->getInfo_String("ModeDiscriminator_TMVAMethod", m_MethodName) ); + 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; - CHECK( m_Tool_InformationStore->getInfo_VecString(varNameList_Full, m_List_BDTVariableNames) ); + 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; - CHECK( m_Tool_InformationStore->getInfo_VecDouble(varDefaultValueList_Full, m_List_BDTVariableDefaultValues) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble(varDefaultValueList_Full, m_List_BDTVariableDefaultValues) ); //consistency check: @@ -112,8 +102,8 @@ StatusCode PanTau::Tool_ModeDiscriminator::initialize() { double bin_lowerVal = m_BinEdges_Pt[iPtBin]; double bin_upperVal = m_BinEdges_Pt[iPtBin+1]; - std::string bin_lowerStr = m_Tool_HelperFunctions->convertNumberToString(bin_lowerVal/1000.); - std::string bin_upperStr = m_Tool_HelperFunctions->convertNumberToString(bin_upperVal/1000.); + std::string bin_lowerStr = m_HelperFunctions.convertNumberToString(bin_lowerVal/1000.); + std::string bin_upperStr = m_HelperFunctions.convertNumberToString(bin_upperVal/1000.); std::string curPtBin = "ET_" + bin_lowerStr + "_" + bin_upperStr; std::string curModeCase = m_Name_ModeCase; @@ -163,7 +153,6 @@ StatusCode PanTau::Tool_ModeDiscriminator::initialize() { StatusCode PanTau::Tool_ModeDiscriminator::finalize() { - CHECK(AlgTool::finalize()); //delete the readers for(unsigned int iReader=0; iReader<m_TMVA_ReaderList.size(); iReader++) { @@ -176,13 +165,13 @@ StatusCode PanTau::Tool_ModeDiscriminator::finalize() { -void PanTau::Tool_ModeDiscriminator::updateReaderVariables(PanTau::PanTauSeed* inSeed) { +void PanTau::Tool_ModeDiscriminator::updateReaderVariables(PanTau::PanTauSeed2* 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::TauFeature* seedFeatures = inSeed->getFeatures(); + PanTau::TauFeature2* seedFeatures = inSeed->getFeatures(); ATH_MSG_DEBUG( "Update the variables that are used in the readers..."); for(unsigned int iVar=0; iVar<m_List_BDTVariableNames.size(); iVar++) { std::string curVar = m_Name_InputAlg + "_" + m_List_BDTVariableNames[iVar]; @@ -205,13 +194,13 @@ void PanTau::Tool_ModeDiscriminator::updateReaderVariables(PanTau::PanTauSeed -double PanTau::Tool_ModeDiscriminator::getResponse(PanTau::PanTauSeed* inSeed, bool& isOK) { +double PanTau::Tool_ModeDiscriminator::getResponse(PanTau::PanTauSeed2* inSeed, bool& isOK) { ATH_MSG_DEBUG("get bdt response now"); updateReaderVariables(inSeed); - if(inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_BadPtValue) == true) { + 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; @@ -219,7 +208,7 @@ double PanTau::Tool_ModeDiscriminator::getResponse(PanTau::PanTauSeed* inSeed, b //get the pt bin of input Seed //NOTE: could be moved to decay mode determinator tool... - double seedPt = inSeed->hlv().perp(); + 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]) { @@ -255,79 +244,3 @@ double PanTau::Tool_ModeDiscriminator::getResponse(PanTau::PanTauSeed* inSeed, b -double PanTau::Tool_ModeDiscriminator::getModeLikeliness(PanTau::PanTauSeed* inSeed, bool& wasSuccessful) { - wasSuccessful = true; - ATH_MSG_DEBUG( "getModeLikeliness called for input seed at: " << inSeed); - ATH_MSG_DEBUG( "my input alg : " << m_Name_InputAlg); - ATH_MSG_DEBUG( "my signal mode: " << m_Name_ModeCase); - - -// //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(); -// ATH_MSG_DEBUG( "Update the variables that are used in the readers..."); -// 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); -// } -// -// ATH_MSG_DEBUG("\tUpdate variable " << curVar << " from " << m_List_BDTVariableValues[iVar] << " to " << newValue); -// m_List_BDTVariableValues[iVar] = (float)newValue; -// }//end loop over BDT vars for update -// -// if(inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_BadPtValue) == true) { -// ATH_MSG_DEBUG("Leaving getModeLikeliness after variable update because seed pt is bad"); -// return -1; -// } -// -// -// //get the pt bin of input Seed -// //NOTE: could be moved to decay mode determinator tool... -// double seedPt = inSeed->hlv().perp(); -// 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_ERROR("Could not find ptBin for tau seed with pt " << seedPt); -// wasSuccessful = false; -// return -1.; -// } -// -// -// -// //get mva response & transform into reference value -// TMVA::Reader* curReader = m_TMVA_ReaderList[ptBin]; -// TH1F* curRefHist = m_TMVA_ReferenceHists[ptBin]; -// if(curReader == 0 || curRefHist == 0) { -// ATH_MSG_ERROR("TMVA::Reader object for current tau seed and/or reference hist points to 0"); -// wasSuccessful = false; -// return -1.; -// } -// -// double mvaResponse = -9999; -// mvaResponse = curReader->EvaluateMVA((TString)m_MethodName); -// int targetBin = curRefHist->FindFixBin(mvaResponse); -// double modeLikeliness = curRefHist->GetBinContent(targetBin); -// -// ATH_MSG_DEBUG("MVA response from " << m_MethodName << " in " << m_Name_SignalMode << " of " << mvaResponse << " translates into likeliness of " << modeLikeliness); -// - return 0; -} - - - - - diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/Tool_TauConstituentGetter.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_TauConstituentGetter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..61cf9bc850bc9b916015d188a00e85623b205321 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_TauConstituentGetter.cxx @@ -0,0 +1,142 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +//! PanTau includes +#include "PanTauAlgs/Tool_TauConstituentGetter.h" + +#include "PanTauAlgs/TauConstituent.h" +#include "PanTauAlgs/Tool_InformationStore.h" +#include "PanTauAlgs/Tool_InputConverter.h" +//#include "TVector3.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") +{ + 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"); +} + +PanTau::Tool_TauConstituentGetter::~Tool_TauConstituentGetter() { +} + +StatusCode PanTau::Tool_TauConstituentGetter::initialize() { + + ATH_MSG_INFO(" initialize()"); + + ATH_CHECK( m_Tool_InformationStore.retrieve() ); + ATH_CHECK( m_Tool_InputConverter.retrieve() ); + + return StatusCode::SUCCESS; +} + + +// StatusCode PanTau::Tool_InformationStore::finalize() { +// StatusCode sc = AlgTool::finalize(); +// return sc; +// } + + + +/** +* 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::string algName) const { + ATH_MSG_DEBUG("GetTauConstituents..."); + + 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; + } + + //loop over charged PFOs + ATH_MSG_DEBUG("Get charged PFOs"); + unsigned int nChargedPFO = 0; + nChargedPFO = tauJet->nProtoChargedPFOs(); + ATH_MSG_DEBUG("Charged PFOs: " << nChargedPFO); + + 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(); + + //add to list of tau constituents + ATH_MSG_DEBUG("\tDumping contents of constituent at " << curConst); + m_HelperFunctions.dumpTauConstituent2(curConst); + outputConstituents.push_back(curConst); + + }//end loop over charged PFOs + + + // Pi0 tagged PFOs are not collected! + + + //loop over neutral PFOs + ATH_MSG_DEBUG("Get neutral ones..."); + unsigned int nNeutPFO = 0; + nNeutPFO = tauJet->nProtoNeutralPFOs(); + ATH_MSG_DEBUG("Neutral PFOs: " << nNeutPFO); + + for(unsigned int iNeutPFO=0; iNeutPFO<nNeutPFO; iNeutPFO++) { + xAOD::PFO* curNeutPFO = 0; + curNeutPFO = const_cast<xAOD::PFO*>(tauJet->protoNeutralPFO( iNeutPFO )); + + // Call vertex correction here + m_HelperFunctions.vertexCorrection_PFOs(tauJet, curNeutPFO); + + //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; + } + + //add to list of tau constituents + ATH_MSG_DEBUG("\tDumping contents of constituent at " << curConst); + m_HelperFunctions.dumpTauConstituent2(curConst); + outputConstituents.push_back(curConst); + + }//end loop over charged PFOs + + + return StatusCode::SUCCESS; + +}//end PFO getter + + + + + + + + + + + + diff --git a/Reconstruction/PanTau/PanTauAlgs/src/Tool_TauConstituentSelector.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_TauConstituentSelector.cxx similarity index 55% rename from Reconstruction/PanTau/PanTauAlgs/src/Tool_TauConstituentSelector.cxx rename to Reconstruction/PanTau/PanTauAlgs/Root/Tool_TauConstituentSelector.cxx index 9e79611859c896947f223eb937c4a3149f2d8fd6..61a11802818b37179b3bdcbfaaa9333d4dd557dc 100644 --- a/Reconstruction/PanTau/PanTauAlgs/src/Tool_TauConstituentSelector.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/Root/Tool_TauConstituentSelector.cxx @@ -2,27 +2,21 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -//! Gaudi includes -#include "AthenaKernel/errorcheck.h" //! PanTau includes #include "PanTauAlgs/Tool_TauConstituentSelector.h" -#include "PanTauEvent/TauConstituent.h" +#include "PanTauAlgs/TauConstituent.h" #include "PanTauAlgs/Tool_InformationStore.h" #include <math.h> PanTau::Tool_TauConstituentSelector::Tool_TauConstituentSelector( - const std::string& ty, - const std::string& na, - const IInterface* pa ) : - AthAlgTool(ty,na,pa), + const std::string& name ) : + asg::AsgTool(name), m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore") { - declareInterface<ITool_TauConstituentSelector>(this); - declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Link to tool with all information"); } @@ -31,46 +25,45 @@ PanTau::Tool_TauConstituentSelector::~Tool_TauConstituentSelector() { StatusCode PanTau::Tool_TauConstituentSelector::initialize() { - CHECK( AlgTool::initialize() ); ATH_MSG_INFO(" initialize()"); - CHECK( m_Tool_InformationStore.retrieve() ); + ATH_CHECK( m_Tool_InformationStore.retrieve() ); - CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_MaxEta", m_MaxEta) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_MaxEta", m_MaxEta) ); //eta bin edges - CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_BinEdges_Eta", m_BinEdges_Eta) ); + ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_BinEdges_Eta", m_BinEdges_Eta) ); //et cuts for types used in mode reco - CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_Neutral_EtaBinned_EtCut", m_Selection_Neutral_EtaBinned_EtCut) ); - CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_Pi0Neut_EtaBinned_EtCut", m_Selection_Pi0Neut_EtaBinned_EtCut) ); - CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_Charged_EtaBinned_EtCut", m_Selection_Charged_EtaBinned_EtCut) ); + 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 types interesting for jet rej. - CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_OutNeut_EtaBinned_EtCut", m_Selection_OutNeut_EtaBinned_EtCut) ); - CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_OutChrg_EtaBinned_EtCut", m_Selection_OutChrg_EtaBinned_EtCut) ); + 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 - CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_NeutLowA_EtaBinned_EtCut", m_Selection_NeutLowA_EtaBinned_EtCut) ); - CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_NeutLowB_EtaBinned_EtCut", m_Selection_NeutLowB_EtaBinned_EtCut) ); + 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; } -double PanTau::Tool_TauConstituentSelector::getEtCut(double eta, PanTau::TauConstituent::Type constituentType) const { +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::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]; + 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.; } @@ -83,18 +76,22 @@ double PanTau::Tool_TauConstituentSelector::getEtCut(double eta, PanTau::TauCons -StatusCode PanTau::Tool_TauConstituentSelector::SelectTauConstituents( std::vector<TauConstituent*> inputList, - std::vector<TauConstituent*>& outputList) const { +/** +* 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(); ATH_MSG_DEBUG("Perform tau constituent selection on " << nConst << "constituents"); for(unsigned int iConst=0; iConst<nConst; iConst++) { ATH_MSG_DEBUG("===>Constituent " << iConst << " / " << nConst); - PanTau::TauConstituent* curConstituent = inputList[iConst]; + PanTau::TauConstituent2* curConstituent = inputList[iConst]; //general preselection: - double curEta = fabs( curConstituent->hlv().eta() ); + double curEta = fabs( curConstituent->p4().Eta() ); if(curEta > m_MaxEta) { ATH_MSG_DEBUG("\tNot using constituent with eta of " << curEta); continue; @@ -102,10 +99,13 @@ StatusCode PanTau::Tool_TauConstituentSelector::SelectTauConstituents( std::vec bool passesSelection = false; ATH_MSG_DEBUG("Before selection, constituent is of type: " << curConstituent->getTypeNameString() ); - if(curConstituent->isOfType(PanTau::TauConstituent::t_Charged) == true) { + + // check if constituent is charged: + if(curConstituent->isOfType(PanTau::TauConstituent2::t_Charged) == true) { passesSelection = passesSelection_ChargedConstituent(curConstituent); - } else if(curConstituent->isOfType(PanTau::TauConstituent::t_Neutral) == true) { + // check if constituent is neutral, assign correctly pi0neut and neut flags: + } else if(curConstituent->isOfType(PanTau::TauConstituent2::t_Neutral) == true) { passesSelection = passesSelection_NeutralConstituent(curConstituent); //special treatment for the testing neutral flags @@ -114,19 +114,21 @@ StatusCode PanTau::Tool_TauConstituentSelector::SelectTauConstituents( std::vec // => 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); + curConstituent->removeTypeFlag(PanTau::TauConstituent2::t_Neutral); + curConstituent->removeTypeFlag(PanTau::TauConstituent2::t_Pi0Neut); passesSelection = passesSelection_NeutLowAConstituent(curConstituent); if(passesSelection == false) { - curConstituent->removeTypeFlag(PanTau::TauConstituent::t_NeutLowA); + curConstituent->removeTypeFlag(PanTau::TauConstituent2::t_NeutLowA); passesSelection = passesSelection_NeutLowBConstituent(curConstituent); } } - } else if(curConstituent->isOfType(PanTau::TauConstituent::t_OutChrg) == true) { + + // apply further selection to constituent in isolation cone: + } else if(curConstituent->isOfType(PanTau::TauConstituent2::t_OutChrg) == true) { passesSelection = passesSelection_OutChrgConstituent(curConstituent); - } else if(curConstituent->isOfType(PanTau::TauConstituent::t_OutNeut) == true) { + } else if(curConstituent->isOfType(PanTau::TauConstituent2::t_OutNeut) == true) { passesSelection = passesSelection_OutNeutConstituent(curConstituent); } else { @@ -135,7 +137,7 @@ StatusCode PanTau::Tool_TauConstituentSelector::SelectTauConstituents( std::vec } ATH_MSG_DEBUG("After selection (with result " << passesSelection << "), constituent is of type: " << curConstituent->getTypeNameString() ); - if(passesSelection == false) {continue;} + if(passesSelection == false) continue; outputList.push_back(inputList[iConst]); } @@ -147,14 +149,15 @@ StatusCode PanTau::Tool_TauConstituentSelector::SelectTauConstituents( std::vec -bool PanTau::Tool_TauConstituentSelector::passesSelection_NeutralConstituent(PanTau::TauConstituent* tauConstituent) const { +bool PanTau::Tool_TauConstituentSelector::passesSelection_NeutralConstituent(PanTau::TauConstituent2* tauConstituent) const { ATH_MSG_DEBUG("neutral sel for const at: " << tauConstituent); - CLHEP::HepLorentzVector hlv_Constituent = tauConstituent->hlv(); + TLorentzVector tlv_Constituent = tauConstituent->p4(); - double curEta = hlv_Constituent.eta(); - double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent::t_Neutral); - double curEt = hlv_Constituent.et(); - ATH_MSG_DEBUG("curEt (" << curEt << ") < cut_MinEt (" << cut_MinEt << ") ?"); + double curEta = tlv_Constituent.Eta(); + double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_Neutral); + double curEt = tlv_Constituent.Et(); + ATH_MSG_DEBUG("curEt (" << curEt << ") < cut_MinEt (" << cut_MinEt << ") ? "); +// ATH_MSG_DEBUG("curEt (" << curEt << ") < cut_MinEt (" << cut_MinEt << ") ? --- with curEta=" << curEta << "PanTau::TauConstituent2::t_Neutral=" << PanTau::TauConstituent2::t_Neutral); if(curEt < cut_MinEt) { ATH_MSG_DEBUG("\tNot using constituent at eta " << curEta << " with et of " << curEt); return false; @@ -167,13 +170,13 @@ bool PanTau::Tool_TauConstituentSelector::passesSelection_NeutralConstituent( -bool PanTau::Tool_TauConstituentSelector::passesSelection_Pi0NeutConstituent(PanTau::TauConstituent* tauConstituent) const { +bool PanTau::Tool_TauConstituentSelector::passesSelection_Pi0NeutConstituent(PanTau::TauConstituent2* tauConstituent) const { ATH_MSG_DEBUG("pi0neut sel for const at: " << tauConstituent); - CLHEP::HepLorentzVector hlv_Constituent = tauConstituent->hlv(); + TLorentzVector tlv_Constituent = tauConstituent->p4(); - double curEta = hlv_Constituent.eta(); - double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent::t_Pi0Neut); - double curEt = hlv_Constituent.et(); + 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; @@ -184,12 +187,12 @@ bool PanTau::Tool_TauConstituentSelector::passesSelection_Pi0NeutConstituent( -bool PanTau::Tool_TauConstituentSelector::passesSelection_ChargedConstituent(PanTau::TauConstituent* tauConstituent) const { - CLHEP::HepLorentzVector hlv_Constituent = tauConstituent->hlv(); +bool PanTau::Tool_TauConstituentSelector::passesSelection_ChargedConstituent(PanTau::TauConstituent2* tauConstituent) const { + TLorentzVector tlv_Constituent = tauConstituent->p4(); - double curEta = hlv_Constituent.eta(); - double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent::t_Charged); - double curEt = hlv_Constituent.perp(); + double curEta = tlv_Constituent.Eta(); + double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_Charged); + double curEt = tlv_Constituent.Pt(); if(curEt < cut_MinEt) { ATH_MSG_DEBUG("\tNot using constituent at eta " << curEta << " with et of " << curEt); @@ -201,24 +204,24 @@ bool PanTau::Tool_TauConstituentSelector::passesSelection_ChargedConstituent( -bool PanTau::Tool_TauConstituentSelector::passesSelection_OutNeutConstituent(TauConstituent* TauConstituent) const { - CLHEP::HepLorentzVector hlv_Constituent = TauConstituent->hlv(); +bool PanTau::Tool_TauConstituentSelector::passesSelection_OutNeutConstituent(TauConstituent2* TauConstituent) const { + TLorentzVector tlv_Constituent = TauConstituent->p4(); - double curEta = hlv_Constituent.eta(); - double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent::t_OutNeut); - double curEt = hlv_Constituent.et(); + double curEta = tlv_Constituent.Eta(); + double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_OutNeut); + double curEt = tlv_Constituent.Et(); if(curEt < cut_MinEt) return false; return true; } -bool PanTau::Tool_TauConstituentSelector::passesSelection_OutChrgConstituent(TauConstituent* TauConstituent) const { - CLHEP::HepLorentzVector hlv_Constituent = TauConstituent->hlv(); +bool PanTau::Tool_TauConstituentSelector::passesSelection_OutChrgConstituent(TauConstituent2* TauConstituent) const { + TLorentzVector tlv_Constituent = TauConstituent->p4(); - double curEta = hlv_Constituent.eta(); - double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent::t_OutChrg); - double curEt = hlv_Constituent.perp(); + double curEta = tlv_Constituent.Eta(); + double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_OutChrg); + double curEt = tlv_Constituent.Pt(); if(curEt < cut_MinEt) return false; return true; @@ -226,12 +229,12 @@ bool PanTau::Tool_TauConstituentSelector::passesSelection_OutChrgConstituent( -bool PanTau::Tool_TauConstituentSelector::passesSelection_NeutLowAConstituent(TauConstituent* TauConstituent) const { - CLHEP::HepLorentzVector hlv_Constituent = TauConstituent->hlv(); +bool PanTau::Tool_TauConstituentSelector::passesSelection_NeutLowAConstituent(TauConstituent2* TauConstituent) const { + TLorentzVector tlv_Constituent = TauConstituent->p4(); - double curEta = hlv_Constituent.eta(); - double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent::t_NeutLowA); - double curEt = hlv_Constituent.perp(); + double curEta = tlv_Constituent.Eta(); + double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_NeutLowA); + double curEt = tlv_Constituent.Pt(); if(curEt < cut_MinEt) return false; return true; @@ -239,12 +242,12 @@ bool PanTau::Tool_TauConstituentSelector::passesSelection_NeutLowAConstituent -bool PanTau::Tool_TauConstituentSelector::passesSelection_NeutLowBConstituent(TauConstituent* TauConstituent) const { - CLHEP::HepLorentzVector hlv_Constituent = TauConstituent->hlv(); +bool PanTau::Tool_TauConstituentSelector::passesSelection_NeutLowBConstituent(TauConstituent2* TauConstituent) const { + TLorentzVector tlv_Constituent = TauConstituent->p4(); - double curEta = hlv_Constituent.eta(); - double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent::t_NeutLowB); - double curEt = hlv_Constituent.perp(); + double curEta = tlv_Constituent.Eta(); + double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_NeutLowB); + double curEt = tlv_Constituent.Pt(); if(curEt < cut_MinEt) return false; return true; diff --git a/Reconstruction/PanTau/PanTauAlgs/cmt/Makefile b/Reconstruction/PanTau/PanTauAlgs/cmt/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..c2c9dbbed79a7894e694cf7a0c7d1bf0756334c3 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/cmt/Makefile @@ -0,0 +1,4 @@ +include $(CMTROOT)/src/Makefile.header + +include $(CMTROOT)/src/constituents.make + diff --git a/Reconstruction/PanTau/PanTauAlgs/cmt/Makefile.RootCore b/Reconstruction/PanTau/PanTauAlgs/cmt/Makefile.RootCore new file mode 100644 index 0000000000000000000000000000000000000000..d01cb3b13b02e34adbe73e7a1bce814fa23ae828 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/cmt/Makefile.RootCore @@ -0,0 +1,54 @@ +# this makefile also gets parsed by shell scripts +# therefore it does not support full make syntax and features +# edit with care + +# for full documentation check: +# https://twiki.cern.ch/twiki/bin/viewauth/Atlas/RootCore#Package_Makefile + + +# the name of the package: +PACKAGE = PanTauAlgs + +# the libraries to link with this one: +PACKAGE_PRELOAD = MathCore MathMore Tree Hist Matrix TMVA + +# additional compilation flags to pass (not propagated to dependent packages): +PACKAGE_CXXFLAGS = -std=c++11 + +# additional compilation flags to pass (propagated to dependent packages): +PACKAGE_OBJFLAGS = + +# additional linker flags to pass (for compiling the library): +PACKAGE_LDFLAGS = + +# additional linker flags to pass (for compiling binaries): +PACKAGE_BINFLAGS = + +# additional linker flags to pass (propagated to client libraries): +PACKAGE_LIBFLAGS = + +# the list of packages we depend on: +#PACKAGE_DEP = AthLinks xAODCore AthContainersInterfaces xAODRootAccess AsgTools xAODRootAccessInterfaces CxxUtils AthContainers xAODEventFormat xAODBTagging xAODBase EventPrimitives xAODTau PathResolver GeoPrimitives xAODCaloEvent xAODPFlow xAODJet CaloGeoHelpers xAODTracking FourMomUtils PATInterfaces tauRecTools +PACKAGE_DEP = AthLinks xAODCore AthContainersInterfaces xAODRootAccess AsgTools xAODRootAccessInterfaces CxxUtils AthContainers xAODEventFormat xAODBase EventPrimitives xAODTau PathResolver GeoPrimitives xAODCaloEvent xAODPFlow xAODJet CaloGeoHelpers xAODTracking FourMomUtils PATInterfaces tauRecTools + +# the list of packages we use if present, but that we can work without : +PACKAGE_TRYDEP = + +# list pattern of scripts to link directly into binary path: +PACKAGE_SCRIPTS = + +# whether to use pedantic compilation: +PACKAGE_PEDANTIC = 1 + +# whether to turn *off* optimization (set to dict to do it only for +# dictionaries): +PACKAGE_NOOPT = 0 + +# whether to build no library (needs to be set if no source files are +# present): +PACKAGE_NOCC = 0 + +# whether we build a reflex dictionary: +PACKAGE_REFLEX = 0 + +include $(ROOTCOREDIR)/Makefile-common diff --git a/Reconstruction/PanTau/PanTauAlgs/cmt/requirements b/Reconstruction/PanTau/PanTauAlgs/cmt/requirements index e9fc08a9b9a3d8c8fcc0253a1cbe75c731c2596d..512c0f356058729ce5dc409c1d3024362e5e19cc 100644 --- a/Reconstruction/PanTau/PanTauAlgs/cmt/requirements +++ b/Reconstruction/PanTau/PanTauAlgs/cmt/requirements @@ -9,35 +9,28 @@ author Robindra Prabhu <robindra.prabhakar.prabhu@cern.ch> public use AtlasPolicy AtlasPolicy-* -use AthenaBaseComps AthenaBaseComps-* Control -use GaudiInterface GaudiInterface-* External use AtlasROOT AtlasROOT-* External -use NavFourMom NavFourMom-* Event -use PanTauEvent PanTauEvent-* Reconstruction/PanTau -use PanTauInterfaces PanTauInterfaces-* Reconstruction/PanTau +#use NavFourMom NavFourMom-* Event +use xAODBase xAODBase-* Event/xAOD use xAODTau xAODTau-* Event/xAOD use xAODPFlow xAODPFlow-* Event/xAOD +use tauRecTools tauRecTools-* Reconstruction +use AsgTools AsgTools-* Control/AthToolSupport + +use AtlasReflex AtlasReflex-* External -no_auto_imports +use CxxUtils CxxUtils-* Control + private -use StoreGate StoreGate-* Control -use FourMom FourMom-* Event -use Particle Particle-* Reconstruction -use eflowEvent eflowEvent-* Reconstruction -use tauEvent tauEvent-* Reconstruction +use GaudiInterface GaudiInterface-* External use PathResolver PathResolver-* Tools -use AtlasCLHEP AtlasCLHEP-* External -use CaloEvent CaloEvent-* Calorimeter -use FourMomUtils FourMomUtils-* Event -use VxVertex VxVertex-* Tracking/TrkEvent -use TrkVertexFitterInterfaces TrkVertexFitterInterfaces-* Tracking/TrkVertexFitter use xAODTracking xAODTracking-* Event/xAOD -use DataModel DataModel-* Control - +use xAODParticleEvent xAODParticleEvent-* Event/xAOD -use AthenaKernel AthenaKernel-* Control # use TrkEventPrimitives TrkEventPrimitives-* Tracking/TrkEvent -use GeoPrimitives GeoPrimitives-* DetectorDescription +#use TrkVertexFitterInterfaces TrkVertexFitterInterfaces-* Tracking/TrkVertexFitter +# use VxVertex VxVertex-* Tracking/TrkEvent public @@ -45,11 +38,19 @@ public # Specify required ROOT components to cmake (transparent to CMT) apply_pattern cmake_add_command command="find_package(ROOT COMPONENTS MathCore MathMore Matrix TMVA)" +# dual use changes: +apply_pattern dual_use_library files="../Root/*.cxx ../src/*.cxx" +#apply_pattern component_library + apply_pattern declare_runtime files="../data/*.root ../data/weights/*.txt ../data/weights/*.xml" apply_pattern declare_joboptions files="*.py" -apply_pattern component_library -library PanTauAlgs *.cxx components/*.cxx +apply_pattern declare_python_modules files="*.py" + + +#library PanTauAlgs Root/*.cxx components/*.cxx + +#apply_pattern installed_library private apply_tag ROOTBasicLibs diff --git a/Reconstruction/PanTau/PanTauAlgs/python/Class_FeatureHandler.py b/Reconstruction/PanTau/PanTauAlgs/python/Class_FeatureHandler.py new file mode 100644 index 0000000000000000000000000000000000000000..ee43e1ab658cfcaf69d52baeea58c4d31df6b10a --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/python/Class_FeatureHandler.py @@ -0,0 +1,688 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +import string + +class FeatureHandler: + + def getFeatureNames(self): + listFeatNames = [] + for iFeature in self.m_Feature_Names: + listFeatNames += [self.m_Feature_Names[iFeature]] + return listFeatNames + #end getFeatureNames + + def getFeatureTypes(self): + listFeatTypes = [] + for iFeature in self.m_Feature_Types: + listFeatTypes += [self.m_Feature_Types[iFeature]] + return listFeatTypes + #end getFeatureTypes + + def getFeatureDefaultValues(self): + listFeatDefaults = [] + for iFeature in self.m_Feature_Defaults: + listFeatDefaults += [self.m_Feature_Defaults[iFeature]] + return listFeatDefaults + #end getFeatureDefaultValues + + def addToFeatures(self, theBaseName, theVarTypeName, theFeatureType, defaultValueOverride=0): + """ Add a single feature with given name, type and default value """ + + #set feature name and default value + featureName = theVarTypeName + "_" + theBaseName + defaultValue = self.m_DefaultValues[theVarTypeName] + if defaultValueOverride != 0: + defaultValue = defaultValueOverride + + #add to features + self.m_Feature_Names[featureName] = featureName + self.m_Feature_Defaults[featureName] = defaultValue + self.m_Feature_Types[featureName] = theFeatureType + #end addToFeatures + + def addToFeatures_FullName(self, completeFeatureName, theVarTypeName, theFeatureType, defaultValueOverride=0): + #set feature name and default value + featureName = completeFeatureName + defaultValue = self.m_DefaultValues[theVarTypeName] + if defaultValueOverride != 0: + defaultValue = defaultValueOverride + + #add to features + self.m_Feature_Names[featureName] = featureName + self.m_Feature_Defaults[featureName] = defaultValue + self.m_Feature_Types[featureName] = theFeatureType + #end addToFeatures_FullName + + + def addToFeatures_AllTypes(self, theBaseName, theVarTypeName, theFeatureType, defaultValueOverride=0): + """ Add the feature described by theName, theType and theDefault for all known constituent types""" + + #set default value + defaultValue = self.m_DefaultValues[theVarTypeName] + if defaultValueOverride != 0: + defaultValue = defaultValueOverride + + #fill feature for all types + for iConstType in self.m_ConstituentTypes: + featureName = iConstType + "_" + theVarTypeName + "_" + theBaseName + + self.m_Feature_Names[featureName] = featureName + self.m_Feature_Defaults[featureName] = defaultValue + self.m_Feature_Types[featureName] = theFeatureType + #end loop over types + #end addToFeatures_AllTypes + + + def addToFeatures_AllTypes_AllEnergyVariants(self, theBaseName, theVarTypeName, theFeatureType, defaultValueOverride=0): + """ Add the feature described by theName, theType and theDefault for all known constituent types""" + for iEnergyType in self.m_EnergyVariantsList: + featureName = theBaseName + iEnergyType + self.addToFeatures_AllTypes(featureName, theVarTypeName, theFeatureType, defaultValueOverride) + #end loop over energy types + #end addToFeatures_AllTypes + + def __init__(self): + + #setup the varType prefixes + # they are passed to the feature extractor later on - avoids errors due to typos + self.m_VarTypeName_Sum = "Sum" + self.m_VarTypeName_Ratio = "Ratio" + self.m_VarTypeName_EtInRing = "EtInRing" + self.m_VarTypeName_Isolation = "Isolation" + self.m_VarTypeName_Num = "Num" + self.m_VarTypeName_Mean = "Mean" + self.m_VarTypeName_StdDev = "StdDev" + self.m_VarTypeName_HLV = "HLV" + self.m_VarTypeName_Angle = "Angle" + self.m_VarTypeName_DeltaR = "DeltaR" + self.m_VarTypeName_JetMoment = "JetMoment" + self.m_VarTypeName_Combined = "Combined" + self.m_VarTypeName_JetShape = "JetShape" + self.m_VarTypeName_ImpactParams = "ImpactParams" + self.m_VarTypeName_Basic = "Basic" + self.m_VarTypeName_PID = "PID" + self.m_VarTypeName_Shots = "Shots" + + #setup the default values for the different variable types + self.m_DefaultValues = {} + self.m_DefaultValues[self.m_VarTypeName_Sum] = -4000.0 + self.m_DefaultValues[self.m_VarTypeName_Ratio] = -0.2 + self.m_DefaultValues[self.m_VarTypeName_EtInRing] = -1000.0 + self.m_DefaultValues[self.m_VarTypeName_Isolation] = -0.2 + self.m_DefaultValues[self.m_VarTypeName_Num] = -5.0 + self.m_DefaultValues[self.m_VarTypeName_Mean] = -0.2 + self.m_DefaultValues[self.m_VarTypeName_StdDev] = -0.2 + self.m_DefaultValues[self.m_VarTypeName_HLV] = -4000.0 + self.m_DefaultValues[self.m_VarTypeName_Angle] = -0.2 + self.m_DefaultValues[self.m_VarTypeName_DeltaR] = -0.2 + self.m_DefaultValues[self.m_VarTypeName_JetMoment] = -0.2 + self.m_DefaultValues[self.m_VarTypeName_Combined] = -10.0 + self.m_DefaultValues[self.m_VarTypeName_JetShape] = -2.0 + self.m_DefaultValues[self.m_VarTypeName_ImpactParams] = -100. + self.m_DefaultValues[self.m_VarTypeName_Basic] = -5.0 + self.m_DefaultValues[self.m_VarTypeName_PID] = -9.0 + self.m_DefaultValues[self.m_VarTypeName_Shots] = -2.0 + + #setup the constituent types + self.m_ConstituentTypeName_All = "All" + self.m_ConstituentTypeName_Charged = "Charged" + self.m_ConstituentTypeName_Neutral = "Neutral" + self.m_ConstituentTypeName_Pi0Neut = "Pi0Neut" + self.m_ConstituentTypeName_OutNeut = "OuterNeut" + self.m_ConstituentTypeName_OutChrg = "OuterChrg" + self.m_ConstituentTypeName_NeutLowA = "NeutLowA" + self.m_ConstituentTypeName_NeutLowB = "NeutLowB" + + self.m_ConstituentTypes = [] + #baseline + self.m_ConstituentTypes += [self.m_ConstituentTypeName_Charged] + self.m_ConstituentTypes += [self.m_ConstituentTypeName_Neutral] + self.m_ConstituentTypes += [self.m_ConstituentTypeName_Pi0Neut] + #for testing + self.m_ConstituentTypes += [self.m_ConstituentTypeName_NeutLowA] + self.m_ConstituentTypes += [self.m_ConstituentTypeName_NeutLowB] + + self.m_EnergyVariantsList = [] + self.m_EnergyVariantsList += ["EtAllConsts"] + self.m_EnergyVariantsList += ["EtNeutLowA"] + self.m_EnergyVariantsList += ["EtNeutLowB"] + # ============================================== + + + #setup member variables to hold feature info + self.m_Feature_Names = {} + self.m_Feature_Defaults = {} + self.m_Feature_Types = {} + + #fill member variables + self.addSingleVariables() + self.addMultiplicities() + self.addFourMomentum() + self.addTypeSpecificFeatures_Num() + self.addTypeSpecificFeatures_PID() + self.addTypeSpecificFeatures_Shots() + self.addTypeSpecificFeatures_Ratios() + #self.addTypeSpecificFeatures_EtRings() #Note wrt EtRings and Isolations: + #self.addTypeSpecificFeatures_Isolations() # Move to different function in FeatureCalc + self.addTypeSpecificFeatures_Mean() + self.addTypeSpecificFeatures_StdDevs() + self.addTypeSpecificFeatures_HLV() + self.addTypeSpecificFeatures_Angle() + self.addTypeSpecificFeatures_DeltaR() + self.addTypeSpecificFeatures_JetMoment() + self.addCombinedFeatures_Single() + self.addCombinedFeatures_TypeVsType() + self.addCombinedFeatures_SelectedTypes() + self.addGenericJetFeatures() + self.addImpactParameterFeatures() + + #end init + + + def dump(self): + print("config_FeatureCalculator: Dumping features:") + for iFeature in sorted(self.m_Feature_Names.iterkeys()): + featName = self.m_Feature_Names[iFeature] + featType = self.m_Feature_Types[iFeature] + featDefault = self.m_Feature_Defaults[iFeature] + print("\t" + string.ljust(featName, 50) + " of type " + featType + " defaults to " + string.rjust(str(featDefault), 10) ) + #print("\t" + featName + " of type " + featType + " defaults to " + str(featDefault) ) + #end for over features + print("config_FeatureCalculator: Done dumping features") + #end dump + + + def addSingleVariables(self): + Variables = [] + Variables += ["isPanTauCandidate"] + Variables += ["RecoMode"] + Variables += ["RecoMode_PanTau"] + Variables += ["BDTValue_1p0n_vs_1p1n"] + Variables += ["BDTValue_1p1n_vs_1pXn"] + Variables += ["BDTValue_3p0n_vs_3pXn"] + Variables += ["SumCharge"] + Variables += ["AbsCharge"] + for iVar in Variables: + curDefVal = self.m_DefaultValues[self.m_VarTypeName_Basic] + if iVar == "isPanTauCandidate": + curDefVal = 0 + if iVar == "RecoMode" or iVar == "RecoMode_PanTau": + curDefVal = -10 + self.addToFeatures(iVar, self.m_VarTypeName_Basic, "F", curDefVal) + #end loop over variables + #end def addSingleVariables + + + def addMultiplicities(self): + Variables = self.m_ConstituentTypes + + for iVar in Variables: + featName = "N" + iVar + "Consts" + self.addToFeatures(featName, self.m_VarTypeName_Basic, "F") + #end loop over variables + + #add the inclusive one + self.addToFeatures("N" + self.m_ConstituentTypeName_All + "Consts", self.m_VarTypeName_Basic, "F") + self.addToFeatures("N" + self.m_ConstituentTypeName_OutChrg + "Consts", self.m_VarTypeName_Basic, "F") + self.addToFeatures("N" + self.m_ConstituentTypeName_OutNeut + "Consts", self.m_VarTypeName_Basic, "F") + + #end def addMultiplicities + + + def addFourMomentum(self): + Variables = [] + Variables += ["pt"] + Variables += ["eta"] + Variables += ["phi"] + Variables += ["m"] + + Types = [] + Types += ["ProtoMomentumCore"] + Types += ["ProtoMomentumWide"] + #Types += ["ValMomCore2GeV"] + + + for iVar in Variables: + for iType in Types: + curFeatName = iType + "_" + iVar + curDefVal = -4000. + if iVar == "eta" or iVar == "phi": + curDefVal = -9. + if iVar == "m": + curDefVal = -200. + self.addToFeatures(curFeatName, self.m_VarTypeName_Basic, "F", curDefVal) + #end loop types + #end loop vars + #end def addFourMomentum + + + def addTypeSpecificFeatures_Num(self): + Variables = [] + Variables += ["ConstsIn00To01"] + Variables += ["ConstsIn01To02"] + Variables += ["ConstsIn02To03"] + Variables += ["ConstsIn03To04"] + for iVar in Variables: + self.addToFeatures_AllTypes(iVar, self.m_VarTypeName_Num, "F") + #end addTypeSpecificFeatures + + + def addTypeSpecificFeatures_PID(self): + Variables = [] + Variables += ["BDTValues"] + Variables += ["BDTValuesSum"] + + Sorts = [] + Sorts += ["BDTSort"] + Sorts += ["EtSort"] + + MaxNum = 4 + + for iVar in Variables: + for iSort in Sorts: + for iNum in range(1, MaxNum): + featName = iVar + "_" + iSort + "_" + str(iNum) + self.addToFeatures_AllTypes(featName, self.m_VarTypeName_PID, "F") + #end loop over num + #end loop over sort + #end loop over variables + #end addTypeSpecificFeatures + + + def addTypeSpecificFeatures_Shots(self): + Variables = [] + Variables += ["nPhotons"] + Variables += ["nShots"] + Variables += ["SumShots_Et"] + Variables += ["SumShots_Eta"] + Variables += ["SumShots_Phi"] + Variables += ["SumShots_M"] + Variables += ["ConstDeltaRToSumShots"] + Variables += ["EtSumShotsOverConstEt"] + Variables += ["TauDeltaRToSumShots"] + Variables += ["EtSumShotsOverTauEt"] + + Sorts = [] + Sorts += ["BDTSort"] + + MaxNum = 4 + + for iVar in Variables: + for iSort in Sorts: + for iNum in range(1, MaxNum): + featName = iVar + "_" + iSort + "_" + str(iNum) + curDefVal = self.m_DefaultValues[self.m_VarTypeName_Shots] + if iVar == "Et": + curDefVal = -1000 + if iVar == "Eta" or iVar == "Phi": + curDefVal = -8 + if iVar == "M": + curDefVal = -200 + + self.addToFeatures_FullName(self.m_ConstituentTypeName_Neutral + "_" + self.m_VarTypeName_Shots + "_" + featName, self.m_VarTypeName_Shots, "F", curDefVal) + self.addToFeatures_FullName(self.m_ConstituentTypeName_Pi0Neut + "_" + self.m_VarTypeName_Shots + "_" + featName, self.m_VarTypeName_Shots, "F", curDefVal) + self.addToFeatures_FullName(self.m_ConstituentTypeName_NeutLowA + "_" + self.m_VarTypeName_Shots + "_" + featName, self.m_VarTypeName_Shots, "F", curDefVal) + self.addToFeatures_FullName(self.m_ConstituentTypeName_NeutLowB + "_" + self.m_VarTypeName_Shots + "_" + featName, self.m_VarTypeName_Shots, "F", curDefVal) + #end loop over iNum + #end loop over sorts + #end loop over variables + + Variables = [] + Variables += ["MaxDeltaRSumShotToConst"] + Variables += ["MinDeltaRSumShotToConst"] + Variables += ["MaxDeltaRSumShotToTau"] + Variables += ["MinDeltaRSumShotToTau"] + Variables += ["DeltaRAllShotsToTau"] + Variables += ["EtAllShotsOverEtTau"] + Variables += ["NShotsInSeed"] + Variables += ["NPhotonsInSeed"] + Variables += ["BestDiShotMass"] + Variables += ["MinDiShotMass"] + Variables += ["MaxDiShotMass"] + for iVar in Variables: + featName = iVar + curDefVal = self.m_DefaultValues[self.m_VarTypeName_Shots] + if iVar == "BestDiShotMass" or iVar == "MinDiShotMass" or iVar == "MaxDiShotMass": + curDefVal = -200 + + self.addToFeatures_FullName(self.m_ConstituentTypeName_Neutral + "_" + self.m_VarTypeName_Shots + "_" + featName, self.m_VarTypeName_Shots, "F", curDefVal) + self.addToFeatures_FullName(self.m_ConstituentTypeName_Pi0Neut + "_" + self.m_VarTypeName_Shots + "_" + featName, self.m_VarTypeName_Shots, "F", curDefVal) + self.addToFeatures_FullName(self.m_ConstituentTypeName_NeutLowA + "_" + self.m_VarTypeName_Shots + "_" + featName, self.m_VarTypeName_Shots, "F", curDefVal) + self.addToFeatures_FullName(self.m_ConstituentTypeName_NeutLowB + "_" + self.m_VarTypeName_Shots + "_" + featName, self.m_VarTypeName_Shots, "F", curDefVal) + + #end loop over variables + #end addTypeSpecificFeatures_Shots + + def addTypeSpecificFeatures_Ratios(self): + + Variables_WithEnergyTypes = [] + Variables_WithEnergyTypes += ["EtOver"] + Variables_WithEnergyTypes += ["1stEtOver"] + Variables_WithEnergyTypes += ["1stBDTEtOver"] + for iVar in Variables_WithEnergyTypes: + self.addToFeatures_AllTypes_AllEnergyVariants(iVar, self.m_VarTypeName_Ratio, "F") + #end loop over variables with energy types + + Variables = [] + Variables += ["1stEtOverTypeEt"] + Variables += ["1stBDTEtOverTypeEt"] + Variables += ["EFOsOverTotalEFOs"] + Variables += ["Log1stEtOver2ndEt"] + Variables += ["Log1stEtOver3rdEt"] + Variables += ["Log2ndEtOver3rdEt"] + Variables += ["Log1stEtOver2ndEt_BDTSort"] + Variables += ["Log1stEtOver3rdEt_BDTSort"] + Variables += ["Log2ndEtOver3rdEt_BDTSort"] + for iVar in Variables: + self.addToFeatures_AllTypes(iVar, self.m_VarTypeName_Ratio, "F") + #end loop over variables with energy types + #end addTypeSpecificFeatures_Ratios + + + def addTypeSpecificFeatures_EtRings(self): + Variables = [] + Variables += ["00To01"] + Variables += ["01To02"] + Variables += ["02To03"] + Variables += ["03To04"] + Variables += ["04To05"] + for iVar in Variables: + completeFeatureName = self.m_ConstituentTypeName_All + "_" + self.m_VarTypeName_EtInRing + "_" + iVar + self.addToFeatures_FullName(completeFeatureName, self.m_VarTypeName_EtInRing, "F") + #end loop over variables + #end addTypeSpecificFeatures_EtRings + + + def addTypeSpecificFeatures_Isolations(self): + Variables = [] + Variables += ["EtIn01Over"] + Variables += ["EtIn02Over"] + Variables += ["EtIn03Over"] + Variables += ["EtIn04Over"] + Variables += ["EtIn00To02Over"] + Variables += ["EtIn02To04Over"] + + for iVar in Variables: + for iEnergyType in self.m_EnergyVariantsList: + completeFeatureName = self.m_ConstituentTypeName_All + "_" + self.m_VarTypeName_Isolation + "_" + iVar + iEnergyType + self.addToFeatures_FullName(completeFeatureName, self.m_VarTypeName_Isolation, "F") + #end loop over variables + + Variables = [] + Variables += ["EtIn01OverEtIn02"] + Variables += ["EtIn01OverEtIn04"] + for iVar in Variables: + completeFeatureName = self.m_ConstituentTypeName_All + "_" + self.m_VarTypeName_Isolation + iVar + self.addToFeatures_FullName(completeFeatureName, self.m_VarTypeName_Isolation, "F") + #end loop over variables + + #end addTypeSpecificFeatures_Isolations + + + def addTypeSpecificFeatures_Mean(self): + Variables_WithEnergyTypes = [] + Variables_WithEnergyTypes += ["Et_Wrt"] + Variables_WithEnergyTypes += ["DRToJetAxis_Wrt"] + Variables_WithEnergyTypes += ["DRToLeading_Wrt"] + for iVar in Variables_WithEnergyTypes: + self.addToFeatures_AllTypes_AllEnergyVariants(iVar, self.m_VarTypeName_Mean, "F") + #end loop over variables + #end addTypeSpecificFeatures_Mean + + + def addTypeSpecificFeatures_StdDevs(self): + Variables = [] + Variables += ["E"] + Variables += ["Et"] + Variables += ["DRToJetAxis"] + Variables += ["DRToLeading"] + for iVar in Variables: + self.addToFeatures_AllTypes(iVar, self.m_VarTypeName_StdDev, "F") + #end loop over variables + + Variables_WithEnergyTypes = [] + Variables_WithEnergyTypes += ["Et_Wrt"] + for iVar in Variables_WithEnergyTypes: + self.addToFeatures_AllTypes_AllEnergyVariants(iVar, self.m_VarTypeName_StdDev, "F") + #end addTypeSpecificFeatures_StdDevs + + + def addTypeSpecificFeatures_HLV(self): + Variables = [] + Variables += ["SumPt"] + Variables += ["SumEta"] + Variables += ["SumPhi"] + Variables += ["SumM"] + for iVar in Variables: + curDefVal = -4000. + if iVar == "SumEta" or iVar == "SumPhi": + curDefVal = -9. + if iVar == "SumM": + curDefVal = -200. + self.addToFeatures_AllTypes(iVar, self.m_VarTypeName_HLV, "F", curDefVal) + + # also add the OutChrg and OutNeut + featName = self.m_ConstituentTypeName_OutChrg + "_" + self.m_VarTypeName_HLV + "_" + iVar + self.addToFeatures_FullName(featName, self.m_VarTypeName_HLV, "F", curDefVal) + + featName = self.m_ConstituentTypeName_OutNeut + "_" + self.m_VarTypeName_HLV + "_" + iVar + self.addToFeatures_FullName(featName, self.m_VarTypeName_HLV, "F", curDefVal) + + #end loop over variables + + VariablesVec = [] + VariablesVec += ["Constituents_pt"] + VariablesVec += ["Constituents_eta"] + VariablesVec += ["Constituents_phi"] + VariablesVec += ["Constituents_m"] + + VariablesVecSort = [] + VariablesVecSort += ["EtSort"] + VariablesVecSort += ["BDTSort"] + + for iSort in VariablesVecSort: + for iVecVar in VariablesVec: + featName = iSort + "_" + iVecVar + curDefVal = -4000. + if iVecVar == "Constituents_eta" or iVecVar == "Constituents_phi": + curDefVal = -9. + if iVecVar == "Constituents_m": + curDefVal = -200. + self.addToFeatures_AllTypes(featName, self.m_VarTypeName_HLV, "V", curDefVal) + + # also add the OutChrg and OutNeut + featName = self.m_ConstituentTypeName_OutChrg + "_" + self.m_VarTypeName_HLV + "_" + iSort + "_" + iVecVar + self.addToFeatures_FullName(featName, self.m_VarTypeName_HLV, "V", curDefVal) + + featName = self.m_ConstituentTypeName_OutNeut + "_" + self.m_VarTypeName_HLV + "_" + iSort + "_" + iVecVar + self.addToFeatures_FullName(featName, self.m_VarTypeName_HLV, "V", curDefVal) + + #end loop over variables + #end addTypeSpecificFeatures_HLV + + + def addTypeSpecificFeatures_Angle(self): + Variables = [] + Variables += ["ToJetAxis"] + Variables += ["1stToJetAxis"] + Variables += ["2ndToJetAxis"] + Variables += ["3rdToJetAxis"] + Variables += ["1stTo2nd"] + Variables += ["1stTo3rd"] + Variables += ["2ndTo3rd"] + Variables += ["MaxToJetAxis"] + Variables += ["MeanValue123"] + Variables += ["Btw1213Planes"] + for iVar in Variables: + self.addToFeatures_AllTypes(iVar, self.m_VarTypeName_Angle, "F") + #end loop over variables + #end addTypeSpecificFeatures_Angle + + + def addTypeSpecificFeatures_DeltaR(self): + Variables = [] + Variables += ["ToJetAxis"] + Variables += ["MaxToJetAxis"] + Variables += ["1stToJetAxis"] + Variables += ["2ndToJetAxis"] + Variables += ["3rdToJetAxis"] + Variables += ["1stTo2nd"] + Variables += ["1stTo3rd"] + Variables += ["2ndTo3rd"] + + Sorts = [] + Sorts += ["EtSort"] + Sorts += ["BDTSort"] + + for iSort in Sorts: + for iVar in Variables: + featName = iVar + "_" + iSort + self.addToFeatures_AllTypes(featName, self.m_VarTypeName_DeltaR, "F") + #end loop over variables + #end addTypeSpecificFeatures_DeltaR + + + def addTypeSpecificFeatures_JetMoment(self): + Variables = [] + Variables += ["EtDR"] + Variables += ["EtDRprime"] + Variables += ["EtDR2"] + Variables += ["EtAngle"] + Variables += ["EtDRxTotalEt"] + for iVar in Variables: + self.addToFeatures_AllTypes(iVar, self.m_VarTypeName_JetMoment, "F") + #end loop over variables + #end addTypeSpecificFeatures_JetMoment + + + def addCombinedFeatures_Single(self): + Variables = [] + Variables += ["NumChargedOverNumNeutral"] + Variables += ["NumChargedOverNumTotal"] + Variables += ["AnglePlane1stCharged1st2ndNeutral"] + Variables += ["FarthestNeutral_AngleToCharged"] + Variables += ["FarthestNeutral_BDTScore"] + Variables += ["FarthestNeutral_EtOverChargedEt"] + + for iVar in Variables: + self.addToFeatures(iVar, self.m_VarTypeName_Combined, "F") + #end loop over variables + #end addCombinedFeatures_Single + + + def addCombinedFeatures_TypeVsType(self): + Types = [] + Types += ["Charged"] + Types += ["Neutral"] + Types += ["Pi0Neut"] + + Variables = [] + Variables += [ ["Log1st", "EtOver", "Et"] ] + Variables += [ ["Log", "EtOver", "Et"] ] + Variables += [ ["Angle", "To", ""] ] + Variables += [ ["DeltaR1st", "To1st", ""] ] + Variables += [ ["Angle1st", "To1st", ""] ] + for iType in Types: + for jType in Types: + + #skip if types are equal + if iType == jType: + continue + + for iVar in Variables: + featName = iVar[0] + iType + iVar[1] + jType + iVar[2] + #if iVar[2] != "-": + #featName = featName + iVar[2] + self.addToFeatures(featName, self.m_VarTypeName_Combined, "F") + #end loop over variables + #end loop over jType + #end loop over iType + #end addCombinedFeatures_TypeVsType + + + def addCombinedFeatures_SelectedTypes(self): + iTypes = [] + iTypes += ["Charged"] + + jTypes = [] + jTypes += ["Pi0Neut"] + jTypes += ["Neutral"] + + Variables_WithEnergyTypes = [] + Variables_WithEnergyTypes += [ ["Mean", "Et_Wrt"] ] + + Variables = [] + Variables += [ ["InvMass", ""] ] + Variables += [ ["Angle1st2nd", ""] ] + for iType in iTypes: + for jType in jTypes: + + for iVar in Variables: + featName = iVar[0] + iType + jType + iVar[1] + self.addToFeatures(featName, self.m_VarTypeName_Combined, "F") + #end loop over variables + + for iVar in Variables_WithEnergyTypes: + featName = iVar[0] + iType + jType + iVar[1] + for iEnergyType in self.m_EnergyVariantsList: + featNameWithEnergy = featName + iEnergyType + self.addToFeatures(featNameWithEnergy, self.m_VarTypeName_Combined, "F") + #end loop over variables for energy types + + #end loop over jTypes + #end loop over iTypes + #end addCombinedFeatures_SelectedTypes + + + def addGenericJetFeatures(self): + Variables = [] + + #thrust and such + Variables += ["JetThrust"] + Variables += ["JetThrustMajor"] + Variables += ["JetThrustMinor"] + Variables += ["JetOblateness"] + Variables += ["JetSphericity"] + Variables += ["JetAplanarity"] + Variables += ["JetPlanarity"] + + #fox wolfram moments + Variables += ["JetFoxWolfram1"] + Variables += ["JetFoxWolfram1"] + Variables += ["JetFoxWolfram1"] + Variables += ["JetFoxWolfram1"] + Variables += ["JetFoxWolframRatioFW2OverFW1"] + Variables += ["JetFoxWolframRatioFW4pow4OverFW1"] + Variables += ["JetFoxWolframRatioFW234OverFW1pow4"] + Variables += ["JetFoxWolframRatioFW1PlusFW2OverFW4"] + + for iVar in Variables: + self.addToFeatures(iVar, self.m_VarTypeName_JetShape, "F") + #end loop over variables + #end addGenericJetFeatures + + + def addImpactParameterFeatures(self): + maxTrack = 4 + + Variables = [] + Variables += [ ["TransIPTrack", "_SortByEt"] ] + Variables += [ ["LongIPTrack", "_SortByEt"] ] + Variables += [ ["TransSignfIPTrack", "_SortByEt"] ] + Variables += [ ["LongSignfIPTrack", "_SortByEt"] ] + Variables += [ ["TransIP", "_SortByValue"] ] + Variables += [ ["TransSignfIP", "_SortByValue"] ] + + for iTrk in range(1, maxTrack): + for iVar in Variables: + featName = iVar[0] + str(iTrk) + iVar[1] + self.addToFeatures(featName, self.m_VarTypeName_ImpactParams, "F") + #end loop over variables + #end loop over tracks + #end addGenericJetFeatures + + +#end class config_FeatureCalculator + + + diff --git a/Reconstruction/PanTau/PanTauAlgs/python/Class_InformationHandler.py b/Reconstruction/PanTau/PanTauAlgs/python/Class_InformationHandler.py new file mode 100644 index 0000000000000000000000000000000000000000..7099c2539f5b7ae7807cc35101975b96fdb6a8fc --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/python/Class_InformationHandler.py @@ -0,0 +1,219 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + + +import string + + + + +class InformationHandler: + + def __init__(self): + + #setup the member variables + # they are filled in the helper functions setupInfo_* + self.m_Infos_Int = {} + self.m_Infos_Double = {} + self.m_Infos_String = {} + self.m_Infos_VecDouble = {} + self.m_Infos_VecString = {} + + #fill member variables + self.setupInfo_Int() + self.setupInfo_Double() + self.setupInfo_String() + self.setupInfo_VecDouble() + self.setupInfo_VecString() + + #fill the feature types and default values + # -> a bit more involved, have extra function for this + self.setupInfo_Features() + #end init + + + def dump(self): + print("PanTau::InformationHandler: Printing stored information") + + print("PanTau::InformationHandler: \tIntegers:") + for iInfo in sorted(self.m_Infos_Int.iterkeys()): + print("\t\t" + string.ljust(iInfo, 50) + ": " + string.rjust(str(self.m_Infos_Int[iInfo]), 10) ) + + print("PanTau::InformationHandler: \tDoubles:") + for iInfo in sorted(self.m_Infos_Double.iterkeys()): + print("\t\t" + string.ljust(iInfo, 50) + ": " + string.rjust(str(self.m_Infos_Double[iInfo]), 10) ) + + print("PanTau::InformationHandler: \tStrings:") + for iInfo in sorted(self.m_Infos_String.iterkeys()): + print("\t\t" + string.ljust(iInfo, 50) + ": " + string.ljust(self.m_Infos_String[iInfo], 80) ) + + print("PanTau::InformationHandler: \tVecDoubles:") + for iInfo in sorted(self.m_Infos_VecDouble.iterkeys()): + print("InformationHandler: \t\t" + string.ljust(iInfo, 50) + ":") + for iVal in self.m_Infos_VecDouble[iInfo]: + print("InformationHandler: \t\t\t" + string.rjust(str(iVal), 10) ) + + print("PanTau::InformationHandler: \tVecStrings:") + for iInfo in sorted(self.m_Infos_VecString.iterkeys()): + print("InformationHandler: \t\t" + string.ljust(iInfo, 50) + ":") + for iVal in self.m_Infos_VecString[iInfo]: + print("InformationHandler: \t\t\t" + string.ljust(str(iVal), 80) ) + + print("PanTau::InformationHandler: Done printing stored information") + #end dump + + + def setupInfo_Int(self): + from PanTauAlgs.Config_PanTau import config_PanTau +# self.m_Infos_Int["EnableXAODMigrationHacks"] = int(config_PanTau.EnableXAODMigrationHacks()) + self.m_Infos_Int["TauConstituents_UsePionMass"] = int(config_PanTau.TauConstituents_UsePionMass()) + self.m_Infos_Int["FeatureExtractor_UseEmptySeeds"] = int(config_PanTau.FeatureExtractor_UseEmptySeeds()) + self.m_Infos_Int["TauConstituents_eflowRec_UseMomentumAsEnergy"] = int(config_PanTau.TauConstituents_eflowRec_UseMomentumAsEnergy()) + self.m_Infos_Int["TauConstituents_UseShrinkingCone"] = int(config_PanTau.TauConstituents_UseShrinkingCone()) + #nothing to do here yet (no integer infos...) + #end def setupInfo_Int + + + def setupInfo_Double(self): + from PanTauAlgs.Config_PanTau import config_PanTau + + self.m_Infos_Double["eflowRec_Assoc_DeltaR"] = config_PanTau.eflowRec_Assoc_DeltaR() + self.m_Infos_Double["TauConstituents_Types_DeltaRCore"] = config_PanTau.TauConstituents_Types_DeltaRCore() + self.m_Infos_Double["TauConstituents_MaxEta"] = config_PanTau.TauConstituents_MaxEta() + self.m_Infos_Double["TauConstituents_PreselectionMinEnergy"] = config_PanTau.TauConstituents_PreselectionMinEnergy() + self.m_Infos_Double["TauConstituents_eflowRec_BDTThreshold_Pi0Neut"] = config_PanTau.TauConstituents_eflowRec_BDTThreshold_Pi0Neut() + + self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R10X_CellBased"] = config_PanTau.DecayModeDeterminator_BDTCutValue_R10X_CellBased() + self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R11X_CellBased"] = config_PanTau.DecayModeDeterminator_BDTCutValue_R11X_CellBased() + self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R110_CellBased"] = config_PanTau.DecayModeDeterminator_BDTCutValue_R110_CellBased() + self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R1XX_CellBased"] = config_PanTau.DecayModeDeterminator_BDTCutValue_R1XX_CellBased() + self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R30X_CellBased"] = config_PanTau.DecayModeDeterminator_BDTCutValue_R30X_CellBased() + self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R3XX_CellBased"] = config_PanTau.DecayModeDeterminator_BDTCutValue_R3XX_CellBased() + + self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R10X_eflowRec"] = config_PanTau.DecayModeDeterminator_BDTCutValue_R10X_eflowRec() + self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R11X_eflowRec"] = config_PanTau.DecayModeDeterminator_BDTCutValue_R11X_eflowRec() + self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R110_eflowRec"] = config_PanTau.DecayModeDeterminator_BDTCutValue_R110_eflowRec() + self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R1XX_eflowRec"] = config_PanTau.DecayModeDeterminator_BDTCutValue_R1XX_eflowRec() + self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R30X_eflowRec"] = config_PanTau.DecayModeDeterminator_BDTCutValue_R30X_eflowRec() + self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R3XX_eflowRec"] = config_PanTau.DecayModeDeterminator_BDTCutValue_R3XX_eflowRec() + + + #self.m_Infos_Double[""] = config_PanTau.() + + #end def setupInfo_Double + + + def setupInfo_String(self): + from PanTauAlgs.Config_PanTau import config_PanTau + self.m_Infos_String["Name_TauRecContainer"] = config_PanTau.Name_TauRecContainer() + self.m_Infos_String["Name_eflowRecContainer"] = config_PanTau.Name_eflowRecContainer() + self.m_Infos_String["Name_TrackParticleContainer"] = config_PanTau.Name_TrackParticleContainer() + self.m_Infos_String["Name_PanTauSeedsContainer"] = config_PanTau.Name_PanTauSeedsContainer() +# self.m_Infos_String["Name_PanTauDetailsContainer"] = config_PanTau.Name_PanTauDetailsContainer() + self.m_Infos_String["ModeDiscriminator_ReaderOption"] = config_PanTau.ModeDiscriminator_ReaderOption() + self.m_Infos_String["ModeDiscriminator_TMVAMethod"] = config_PanTau.ModeDiscriminator_TMVAMethod() + #self.m_Infos_Double[""] = config_PanTau.() + + #end def setupInfo_String + + + def setupInfo_VecDouble(self): + from PanTauAlgs.Config_PanTau import config_PanTau + self.m_Infos_VecDouble["TauConstituents_BinEdges_Eta"] = config_PanTau.TauConstituents_BinEdges_Eta() + self.m_Infos_VecDouble["TauConstituents_Selection_Neutral_EtaBinned_EtCut"] = config_PanTau.TauConstituents_Selection_Neutral_EtaBinned_EtCut() + self.m_Infos_VecDouble["TauConstituents_Selection_Pi0Neut_EtaBinned_EtCut"] = config_PanTau.TauConstituents_Selection_Pi0Neut_EtaBinned_EtCut() + self.m_Infos_VecDouble["TauConstituents_Selection_Charged_EtaBinned_EtCut"] = config_PanTau.TauConstituents_Selection_Charged_EtaBinned_EtCut() + self.m_Infos_VecDouble["TauConstituents_Selection_OutNeut_EtaBinned_EtCut"] = config_PanTau.TauConstituents_Selection_OutNeut_EtaBinned_EtCut() + self.m_Infos_VecDouble["TauConstituents_Selection_OutChrg_EtaBinned_EtCut"] = config_PanTau.TauConstituents_Selection_OutChrg_EtaBinned_EtCut() + self.m_Infos_VecDouble["TauConstituents_Selection_NeutLowA_EtaBinned_EtCut"] = config_PanTau.TauConstituents_Selection_NeutLowA_EtaBinned_EtCut() + self.m_Infos_VecDouble["TauConstituents_Selection_NeutLowB_EtaBinned_EtCut"] = config_PanTau.TauConstituents_Selection_NeutLowB_EtaBinned_EtCut() + self.m_Infos_VecDouble["eflowRec_Selection_Pi0Neut_EtaBinned_EtCut_1prong"] = config_PanTau.eflowRec_Selection_Pi0Neut_EtaBinned_EtCut_1prong() + self.m_Infos_VecDouble["eflowRec_Selection_Pi0Neut_EtaBinned_EtCut_3prong"] = config_PanTau.eflowRec_Selection_Pi0Neut_EtaBinned_EtCut_3prong() + self.m_Infos_VecDouble["CellBased_BinEdges_Eta"] = config_PanTau.CellBased_BinEdges_Eta() + self.m_Infos_VecDouble["CellBased_EtaBinned_Pi0MVACut_1prong"] = config_PanTau.CellBased_EtaBinned_Pi0MVACut_1prong() + self.m_Infos_VecDouble["CellBased_EtaBinned_Pi0MVACut_3prong"] = config_PanTau.CellBased_EtaBinned_Pi0MVACut_3prong() + self.m_Infos_VecDouble["eflowRec_BinEdges_Eta"] = config_PanTau.eflowRec_BinEdges_Eta() + self.m_Infos_VecDouble["eflowRec_EtaBinned_Pi0MVACut_1prong"] = config_PanTau.eflowRec_EtaBinned_Pi0MVACut_1prong() + self.m_Infos_VecDouble["eflowRec_EtaBinned_Pi0MVACut_3prong"] = config_PanTau.eflowRec_EtaBinned_Pi0MVACut_3prong() + self.m_Infos_VecDouble["ModeDiscriminator_BinEdges_Pt"] = config_PanTau.ModeDiscriminator_BinEdges_Pt() + #self.m_Infos_VecDouble[""] = config_PanTau.() + + #end def setupInfo_VecDouble + + + def setupInfo_VecString(self): + from PanTauAlgs.Config_PanTau import config_PanTau + self.m_Infos_VecString["ModeDiscriminator_BDTVariableNames_eflowRec_1p0n_vs_1p1n"] = config_PanTau.ModeDiscriminator_BDTVariableNames_eflowRec_1p0n_vs_1p1n() + self.m_Infos_VecString["ModeDiscriminator_BDTVariableNames_eflowRec_1p1n_vs_1pXn"] = config_PanTau.ModeDiscriminator_BDTVariableNames_eflowRec_1p1n_vs_1pXn() + self.m_Infos_VecString["ModeDiscriminator_BDTVariableNames_eflowRec_3p0n_vs_3pXn"] = config_PanTau.ModeDiscriminator_BDTVariableNames_eflowRec_3p0n_vs_3pXn() + self.m_Infos_VecString["ModeDiscriminator_BDTVariableNames_CellBased_1p0n_vs_1p1n"] = config_PanTau.ModeDiscriminator_BDTVariableNames_CellBased_1p0n_vs_1p1n() + self.m_Infos_VecString["ModeDiscriminator_BDTVariableNames_CellBased_1p1n_vs_1pXn"] = config_PanTau.ModeDiscriminator_BDTVariableNames_CellBased_1p1n_vs_1pXn() + self.m_Infos_VecString["ModeDiscriminator_BDTVariableNames_CellBased_3p0n_vs_3pXn"] = config_PanTau.ModeDiscriminator_BDTVariableNames_CellBased_3p0n_vs_3pXn() + #self.m_Infos_VecString[""] = config_PanTau.() + + #end def setupInfo_VecString + + + def setupInfo_Features(self): + + #get list of algorithms and signal modes from config + from PanTauAlgs.Config_PanTau import config_PanTau + List_InputAlgs = config_PanTau.Names_InputAlgorithms() + List_ModeCases = config_PanTau.Names_ModeCases() + + #get the feature handler + from PanTauAlgs.Class_FeatureHandler import FeatureHandler + theFeatureHandler = FeatureHandler() + + #for each algorithm and mode, loop over variables to be used in BDT + # and fetch the type of the variable and the name + # these are needed for the PanTauFillerTool in TauD3PDMaker + for iAlg in List_InputAlgs: + for iModeCase in List_ModeCases: + + infoKey_Names = "ModeDiscriminator_BDTVariableNames_" + iAlg + "_" + iModeCase + curVarList = self.m_Infos_VecString[infoKey_Names] + + BDTVariable_TypeList = [] + BDTVariable_DefaultValList = [] + + for iVar in curVarList: + theType = theFeatureHandler.m_Feature_Types[iVar] + theDefVal = theFeatureHandler.m_Feature_Defaults[iVar] + BDTVariable_TypeList += [theType] + BDTVariable_DefaultValList += [theDefVal] + #end loop over variables + + infoKey_Types = "ModeDiscriminator_BDTVariableTypes_" + iAlg + "_" + iModeCase + self.m_Infos_VecString[infoKey_Types] = BDTVariable_TypeList + + infoKey_Defaults = "ModeDiscriminator_BDTVariableDefaults_" + iAlg + "_" + iModeCase + self.m_Infos_VecDouble[infoKey_Defaults] = BDTVariable_DefaultValList + + #end loop over signal modes + #end loop over algs for default value creation for ModeDiscriminator tools + + #add the prefixes for the variables + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Sum"] = theFeatureHandler.m_VarTypeName_Sum + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Ratio"] = theFeatureHandler.m_VarTypeName_Ratio + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_EtInRing"] = theFeatureHandler.m_VarTypeName_EtInRing + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Isolation"] = theFeatureHandler.m_VarTypeName_Isolation + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Num"] = theFeatureHandler.m_VarTypeName_Num + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Mean"] = theFeatureHandler.m_VarTypeName_Mean + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_StdDev"] = theFeatureHandler.m_VarTypeName_StdDev + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_HLV"] = theFeatureHandler.m_VarTypeName_HLV + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Angle"] = theFeatureHandler.m_VarTypeName_Angle + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_DeltaR"] = theFeatureHandler.m_VarTypeName_DeltaR + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_JetMoment"] = theFeatureHandler.m_VarTypeName_JetMoment + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Combined"] = theFeatureHandler.m_VarTypeName_Combined + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_JetShape"] = theFeatureHandler.m_VarTypeName_JetShape + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_ImpactParams"]= theFeatureHandler.m_VarTypeName_ImpactParams + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Basic"] = theFeatureHandler.m_VarTypeName_Basic + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_PID"] = theFeatureHandler.m_VarTypeName_PID + self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Shots"] = theFeatureHandler.m_VarTypeName_Shots + #end def setupInfo_Features + +#end class config_FeatureCalculator + + + + diff --git a/Reconstruction/PanTau/PanTauAlgs/python/Config_PanTau.py b/Reconstruction/PanTau/PanTauAlgs/python/Config_PanTau.py new file mode 100644 index 0000000000000000000000000000000000000000..ed600a005a3df57fb9304cc0bef3902b694c48a0 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/python/Config_PanTau.py @@ -0,0 +1,553 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +## +## @file PanTauAlgs/python/JobOptionFlags_PanTau.py +## @purpose Python module to hold common flags to configure PanTau +## + +""" PanTauFlags + Python module to hold flags to configure PanTau. + + From the python prompt: + >>> from PanTauAlgs.JobOptionFlags_PanTau import panTauFlags + +""" + +__author__ = "C.Limbach" +__version__= "$Revision: $" +__doc__ = "Config_PanTau" + +__all__ = [ "Config_PanTau" ] + +##----------------------------------------------------------------------------- +## Import + +from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer +from AthenaCommon.JobProperties import jobproperties +import AthenaCommon.SystemOfUnits as Units + +##----------------------------------------------------------------------------- +## 1st step: define JobProperty classes + + +### ========================================================== +### +### Flags to steer job options +### +### ========================================================== + +### ///////////////////////// +### Boolean values +### ///////////////////////// + +class UseDefaultCellBasedConfig(JobProperty): + """ If this is true, the configuration for pi0s will be copied from cellbased""" + statusOn = True + allowedTypes = ['bool'] + StoredValue = True + + +class TauConstituents_UsePionMass(JobProperty): + """ """ + statusOn = True + allowedTypes = ['bool'] + StoredValue = True + + +class FeatureExtractor_UseEmptySeeds(JobProperty): + """ """ + statusOn = True + allowedTypes = ['bool'] + StoredValue = False + + +class TauConstituents_eflowRec_UseMomentumAsEnergy(JobProperty): + """ """ + statusOn = True + allowedTypes = ['bool'] + StoredValue = False + +class TauConstituents_UseShrinkingCone(JobProperty): + """ """ + statusOn = True + allowedTypes = ['bool'] + StoredValue = False + + + +### ///////////////////////// +### Float values +### ///////////////////////// + +class eflowRec_Assoc_DeltaR(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = 0.4 + +class TauConstituents_Types_DeltaRCore(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = 0.2 + + +class TauConstituents_MaxEta(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = 9.9 + + +class TauConstituents_PreselectionMinEnergy(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = 500. + + +class TauConstituents_eflowRec_BDTThreshold_Pi0Neut(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = -0.04 + + + +# +# PanTau BDT Cut values --- CellBased +# + +class DecayModeDeterminator_BDTCutValue_R10X_CellBased(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = 0.19 + +class DecayModeDeterminator_BDTCutValue_R11X_CellBased(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = -0.11 + +class DecayModeDeterminator_BDTCutValue_R110_CellBased(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = 0.37 + +class DecayModeDeterminator_BDTCutValue_R1XX_CellBased(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = 0.07 + +class DecayModeDeterminator_BDTCutValue_R30X_CellBased(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = -0.01 + +class DecayModeDeterminator_BDTCutValue_R3XX_CellBased(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = -0.03 + +# +# PanTau BDT Cut values --- eflowRec +# + +class DecayModeDeterminator_BDTCutValue_R10X_eflowRec(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = -0.15 + +class DecayModeDeterminator_BDTCutValue_R11X_eflowRec(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = -0.60 + +class DecayModeDeterminator_BDTCutValue_R110_eflowRec(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = -0.08 + +class DecayModeDeterminator_BDTCutValue_R1XX_eflowRec(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = 0.03 + +class DecayModeDeterminator_BDTCutValue_R30X_eflowRec(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = -0.25 + +class DecayModeDeterminator_BDTCutValue_R3XX_eflowRec(JobProperty): + """ """ + statusOn = True + allowedTypes = ['float'] + StoredValue = -0.23 + + + +### ///////////////////////// +### String values +### ///////////////////////// + +class Name_TauRecContainer(JobProperty): + """ """ + statusOn = True + allowedTypes = ['str'] + StoredValue = "TauJets" + + +class Name_eflowRecContainer(JobProperty): + """ """ + statusOn = True + allowedTypes = ['str'] + StoredValue = "eflowObjects_tauMode" + + +class Name_TrackParticleContainer(JobProperty): + """ """ + statusOn = True + allowedTypes = ['str'] + StoredValue = "TrackParticleCandidate" + + +class Name_PanTauSeedsContainer(JobProperty): + """ """ + statusOn = True + allowedTypes = ['str'] + StoredValue = "PanTau_OutputSeeds" + + +#class Name_PanTauDetailsContainer(JobProperty): +# """ """ +# statusOn = True +# allowedTypes = ['str'] +# StoredValue = "PanTau_SeedDetails" + + +class ModeDiscriminator_ReaderOption(JobProperty): + """ """ + statusOn = True + allowedTypes = ['str'] + StoredValue = "!Color:Silent" + + +class ModeDiscriminator_TMVAMethod(JobProperty): + """ """ + statusOn = True + allowedTypes = ['str'] + StoredValue = "BDTG" + + + +### ///////////////////////// +### vector<float> values +### ///////////////////////// + + +# +# Eta Binned E T C U T S +# + +class TauConstituents_BinEdges_Eta(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [0.000, 0.800, 1.400, 1.500, 1.900, 9.900] + + +class TauConstituents_Selection_Neutral_EtaBinned_EtCut(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [ 2.1*Units.GeV, 2.5*Units.GeV, 2.6*Units.GeV, 2.4*Units.GeV, 1.9*Units.GeV ] + + +class TauConstituents_Selection_Pi0Neut_EtaBinned_EtCut(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [ 2.1*Units.GeV, 2.5*Units.GeV, 2.6*Units.GeV, 2.4*Units.GeV, 1.9*Units.GeV ] + + +class TauConstituents_Selection_Charged_EtaBinned_EtCut(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [ 1.0*Units.GeV, 1.0*Units.GeV, 1.0*Units.GeV, 1.0*Units.GeV, 1.0*Units.GeV ] + + +class TauConstituents_Selection_OutNeut_EtaBinned_EtCut(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [ 1.0*Units.GeV, 1.0*Units.GeV, 1.0*Units.GeV, 1.0*Units.GeV, 1.0*Units.GeV ] + + +class TauConstituents_Selection_OutChrg_EtaBinned_EtCut(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [ 1.0*Units.GeV, 1.0*Units.GeV, 1.0*Units.GeV, 1.0*Units.GeV, 1.0*Units.GeV ] + +# Temporary test neutral type with lower Et cut (-250 MeV) +class TauConstituents_Selection_NeutLowA_EtaBinned_EtCut(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [ 1.85*Units.GeV, 2.25*Units.GeV, 2.35*Units.GeV, 2.15*Units.GeV, 1.65*Units.GeV ] + +# Temporary test neutral type with lower Et cut (-500 MeV) +class TauConstituents_Selection_NeutLowB_EtaBinned_EtCut(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [ 1.6*Units.GeV, 2.0*Units.GeV, 2.1*Units.GeV, 1.9*Units.GeV, 1.4*Units.GeV ] + + + +class eflowRec_Selection_Pi0Neut_EtaBinned_EtCut_1prong(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [ 2.5*Units.GeV, 2.5*Units.GeV, 1.9*Units.GeV, 2.5*Units.GeV, 2.3*Units.GeV ] + +class eflowRec_Selection_Pi0Neut_EtaBinned_EtCut_3prong(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [ 2.5*Units.GeV, 2.5*Units.GeV, 2.5*Units.GeV, 2.5*Units.GeV, 2.5*Units.GeV ] + +# +# Eta Binned P I 0 - B D T C U T S +# + +class CellBased_BinEdges_Eta(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [0.000, 0.800, 1.400, 1.500, 1.900, 9.900] + + +class CellBased_EtaBinned_Pi0MVACut_1prong(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [ 0.46, 0.39, 0.51, 0.47, 0.54 ] + + +class CellBased_EtaBinned_Pi0MVACut_3prong(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [ 0.47, 0.52, 0.60, 0.55, 0.50 ] + + + +class eflowRec_BinEdges_Eta(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [0.000, 0.800, 1.400, 1.500, 1.900, 9.900] + + +class eflowRec_EtaBinned_Pi0MVACut_1prong(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [ 0.09, 0.09, 0.09, 0.08, 0.05 ] + + +class eflowRec_EtaBinned_Pi0MVACut_3prong(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [ 0.09, 0.09, 0.09, 0.09, 0.07 ] + + +# +# P T B I N S +# + +class ModeDiscriminator_BinEdges_Pt(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = [10*Units.GeV, 100000*Units.GeV] + + + +### ///////////////////////// +### vector<string> values +### ///////////////////////// + +class Names_InputAlgorithms(JobProperty): + """ Valid names are: CellBased and eflowRec """ + statusOn = True + allowedTypes = ['list'] + StoredValue = ["CellBased"] + + +class Names_ModeCases(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = ["1p0n_vs_1p1n", + "1p1n_vs_1pXn", + "3p0n_vs_3pXn"] + + +### ---> eflowRec BDT variables +class ModeDiscriminator_BDTVariableNames_eflowRec_1p0n_vs_1p1n(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = ["Charged_Ratio_EtOverEtAllConsts", + "Basic_NPi0NeutConsts", + "Neutral_PID_BDTValues_EtSort_1", + "Combined_DeltaR1stNeutralTo1stCharged"] + +class ModeDiscriminator_BDTVariableNames_eflowRec_1p1n_vs_1pXn(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = ["Neutral_PID_BDTValues_BDTSort_2", + "Neutral_Ratio_EtOverEtAllConsts", + "Basic_NNeutralConsts", + "Neutral_HLV_SumM"] + +class ModeDiscriminator_BDTVariableNames_eflowRec_3p0n_vs_3pXn(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = ["Basic_NPi0NeutConsts", + "Neutral_PID_BDTValues_BDTSort_1", + "Charged_HLV_SumPt", + "Charged_Ratio_EtOverEtAllConsts", + "Neutral_Mean_DRToLeading_WrtEtAllConsts"] + + +### ---> CellBased BDT variables +class ModeDiscriminator_BDTVariableNames_CellBased_1p0n_vs_1p1n(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = ["Neutral_PID_BDTValues_BDTSort_1", + "Neutral_Ratio_1stBDTEtOverEtAllConsts", + "Combined_DeltaR1stNeutralTo1stCharged", + "Charged_JetMoment_EtDRxTotalEt", + "Neutral_Shots_NPhotonsInSeed"] + +class ModeDiscriminator_BDTVariableNames_CellBased_1p1n_vs_1pXn(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = ["Neutral_PID_BDTValues_BDTSort_2", + "Neutral_HLV_SumM", + "Neutral_Ratio_EtOverEtAllConsts", + "Basic_NNeutralConsts", + "Neutral_Shots_NPhotonsInSeed"] + +class ModeDiscriminator_BDTVariableNames_CellBased_3p0n_vs_3pXn(JobProperty): + """ """ + statusOn = True + allowedTypes = ['list'] + StoredValue = ["Neutral_Ratio_EtOverEtAllConsts", + "Neutral_PID_BDTValues_BDTSort_1", + "Charged_StdDev_Et_WrtEtAllConsts", + "Neutral_Shots_NPhotonsInSeed", + "Charged_HLV_SumM"] + + + +##----------------------------------------------------------------------------- +## 2nd step +## Definition of the PanTau flag container +class Config_PanTau(JobPropertyContainer): + """Container for the common flags + """ + pass + +##----------------------------------------------------------------------------- +## 3rd step +## adding the container to the general top-level container +jobproperties.add_Container(Config_PanTau) + +##----------------------------------------------------------------------------- +## 4th step +## adding athena common flags to the AthenaCommonFlags container +jobproperties.Config_PanTau.add_JobProperty(UseDefaultCellBasedConfig) +jobproperties.Config_PanTau.add_JobProperty(TauConstituents_UsePionMass) +jobproperties.Config_PanTau.add_JobProperty(FeatureExtractor_UseEmptySeeds) +jobproperties.Config_PanTau.add_JobProperty(TauConstituents_PreselectionMinEnergy) +jobproperties.Config_PanTau.add_JobProperty(TauConstituents_eflowRec_UseMomentumAsEnergy) +jobproperties.Config_PanTau.add_JobProperty(TauConstituents_UseShrinkingCone) +jobproperties.Config_PanTau.add_JobProperty(eflowRec_Assoc_DeltaR) +jobproperties.Config_PanTau.add_JobProperty(TauConstituents_Types_DeltaRCore) +jobproperties.Config_PanTau.add_JobProperty(TauConstituents_MaxEta) +jobproperties.Config_PanTau.add_JobProperty(TauConstituents_eflowRec_BDTThreshold_Pi0Neut) +jobproperties.Config_PanTau.add_JobProperty(DecayModeDeterminator_BDTCutValue_R10X_CellBased) +jobproperties.Config_PanTau.add_JobProperty(DecayModeDeterminator_BDTCutValue_R11X_CellBased) +jobproperties.Config_PanTau.add_JobProperty(DecayModeDeterminator_BDTCutValue_R110_CellBased) +jobproperties.Config_PanTau.add_JobProperty(DecayModeDeterminator_BDTCutValue_R1XX_CellBased) +jobproperties.Config_PanTau.add_JobProperty(DecayModeDeterminator_BDTCutValue_R30X_CellBased) +jobproperties.Config_PanTau.add_JobProperty(DecayModeDeterminator_BDTCutValue_R3XX_CellBased) +jobproperties.Config_PanTau.add_JobProperty(DecayModeDeterminator_BDTCutValue_R10X_eflowRec) +jobproperties.Config_PanTau.add_JobProperty(DecayModeDeterminator_BDTCutValue_R11X_eflowRec) +jobproperties.Config_PanTau.add_JobProperty(DecayModeDeterminator_BDTCutValue_R110_eflowRec) +jobproperties.Config_PanTau.add_JobProperty(DecayModeDeterminator_BDTCutValue_R1XX_eflowRec) +jobproperties.Config_PanTau.add_JobProperty(DecayModeDeterminator_BDTCutValue_R30X_eflowRec) +jobproperties.Config_PanTau.add_JobProperty(DecayModeDeterminator_BDTCutValue_R3XX_eflowRec) +jobproperties.Config_PanTau.add_JobProperty(Name_TauRecContainer) +jobproperties.Config_PanTau.add_JobProperty(Name_eflowRecContainer) +jobproperties.Config_PanTau.add_JobProperty(Name_TrackParticleContainer) +jobproperties.Config_PanTau.add_JobProperty(Name_PanTauSeedsContainer) +#jobproperties.Config_PanTau.add_JobProperty(Name_PanTauDetailsContainer) +jobproperties.Config_PanTau.add_JobProperty(ModeDiscriminator_ReaderOption) +jobproperties.Config_PanTau.add_JobProperty(ModeDiscriminator_TMVAMethod) +jobproperties.Config_PanTau.add_JobProperty(TauConstituents_BinEdges_Eta) +jobproperties.Config_PanTau.add_JobProperty(TauConstituents_Selection_Neutral_EtaBinned_EtCut) +jobproperties.Config_PanTau.add_JobProperty(TauConstituents_Selection_Pi0Neut_EtaBinned_EtCut) +jobproperties.Config_PanTau.add_JobProperty(TauConstituents_Selection_Charged_EtaBinned_EtCut) +jobproperties.Config_PanTau.add_JobProperty(TauConstituents_Selection_OutNeut_EtaBinned_EtCut) +jobproperties.Config_PanTau.add_JobProperty(TauConstituents_Selection_OutChrg_EtaBinned_EtCut) +jobproperties.Config_PanTau.add_JobProperty(TauConstituents_Selection_NeutLowA_EtaBinned_EtCut) +jobproperties.Config_PanTau.add_JobProperty(TauConstituents_Selection_NeutLowB_EtaBinned_EtCut) +jobproperties.Config_PanTau.add_JobProperty(eflowRec_Selection_Pi0Neut_EtaBinned_EtCut_1prong) +jobproperties.Config_PanTau.add_JobProperty(eflowRec_Selection_Pi0Neut_EtaBinned_EtCut_3prong) +jobproperties.Config_PanTau.add_JobProperty(CellBased_BinEdges_Eta) +jobproperties.Config_PanTau.add_JobProperty(CellBased_EtaBinned_Pi0MVACut_1prong) +jobproperties.Config_PanTau.add_JobProperty(CellBased_EtaBinned_Pi0MVACut_3prong) +jobproperties.Config_PanTau.add_JobProperty(eflowRec_BinEdges_Eta) +jobproperties.Config_PanTau.add_JobProperty(eflowRec_EtaBinned_Pi0MVACut_1prong) +jobproperties.Config_PanTau.add_JobProperty(eflowRec_EtaBinned_Pi0MVACut_3prong) +jobproperties.Config_PanTau.add_JobProperty(Names_InputAlgorithms) +jobproperties.Config_PanTau.add_JobProperty(Names_ModeCases) +jobproperties.Config_PanTau.add_JobProperty(ModeDiscriminator_BinEdges_Pt) +jobproperties.Config_PanTau.add_JobProperty(ModeDiscriminator_BDTVariableNames_eflowRec_1p0n_vs_1p1n) +jobproperties.Config_PanTau.add_JobProperty(ModeDiscriminator_BDTVariableNames_eflowRec_1p1n_vs_1pXn) +jobproperties.Config_PanTau.add_JobProperty(ModeDiscriminator_BDTVariableNames_eflowRec_3p0n_vs_3pXn) +jobproperties.Config_PanTau.add_JobProperty(ModeDiscriminator_BDTVariableNames_CellBased_1p0n_vs_1p1n) +jobproperties.Config_PanTau.add_JobProperty(ModeDiscriminator_BDTVariableNames_CellBased_1p1n_vs_1pXn) +jobproperties.Config_PanTau.add_JobProperty(ModeDiscriminator_BDTVariableNames_CellBased_3p0n_vs_3pXn) + + + +##----------------------------------------------------------------------------- +## 5th step +## short-cut for lazy people +## carefull: do not select PanTauFlags as a short name as well. +## otherwise problems with pickle +## Note: you still have to import it: +## >>> from PanTauAlgs.PanTauFlags import panTauFlags +config_PanTau = jobproperties.Config_PanTau diff --git a/Reconstruction/PanTau/PanTauAlgs/python/JobOptions_Main_PanTau.py b/Reconstruction/PanTau/PanTauAlgs/python/JobOptions_Main_PanTau.py new file mode 100644 index 0000000000000000000000000000000000000000..728f2a1c95d232ba694cb290da461000b7ffb63b --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/python/JobOptions_Main_PanTau.py @@ -0,0 +1,173 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + + +from AthenaCommon.SystemOfUnits import * +from AthenaCommon.Constants import * + +cached_instances = {} + +sPrefix = 'tauRec_' +bAODmode = False + +from tauRec.tauRecFlags import jobproperties as config_TauRec + +######################################################################## +# PanTau +def getPanTau(): + _name = sPrefix + 'PanTau' + + if _name in cached_instances: + return cached_instances[_name] + + # set message limit + from AthenaCommon.AppMgr import ServiceMgr as svcMgr + svcMgr.MessageSvc.defaultLimit = 9999999 + + + # set up the job properties + from PanTauAlgs.Class_InformationHandler import InformationHandler + infoHandler = InformationHandler() + + + # copy the configuration from cellbased if requested + from PanTauAlgs.Config_PanTau import config_PanTau + #if config_PanTau.UseDefaultCellBasedConfig == True: + + # pi0-BDT cuts + #config_PanTau.CellBased_EtaBinned_Pi0MVACut_1prong.set_Value_and_Lock( config_TauRec.tauRecFlags.pi0MVACuts_1prong() ) + #config_PanTau.CellBased_EtaBinned_Pi0MVACut_3prong.set_Value_and_Lock( config_TauRec.tauRecFlags.pi0MVACuts_mprong() ) + + # Et cuts + #config_PanTau.TauConstituents_Selection_Neutral_EtaBinned_EtCut.set_Value_and_Lock( config_TauRec.tauRecFlags.pi0EtCuts() ) + #config_PanTau.TauConstituents_Selection_Pi0Neut_EtaBinned_EtCut.set_Value_and_Lock( config_TauRec.tauRecFlags.pi0EtCuts() ) + + + # Create tools + # ================================================================== + from AthenaCommon.AppMgr import ToolSvc + from PanTauAlgs.PanTauAlgsConf import PanTau__Tool_InformationStore + from PanTauAlgs.PanTauAlgsConf import PanTau__Tool_InputConverter + from PanTauAlgs.PanTauAlgsConf import PanTau__Tool_TauConstituentGetter + from PanTauAlgs.PanTauAlgsConf import PanTau__Tool_TauConstituentSelector + from PanTauAlgs.PanTauAlgsConf import PanTau__Tool_FeatureExtractor + from PanTauAlgs.PanTauAlgsConf import PanTau__Tool_ModeDiscriminator + from PanTauAlgs.PanTauAlgsConf import PanTau__Tool_DecayModeDeterminator + from PanTauAlgs.PanTauAlgsConf import PanTau__Tool_DetailsArranger + from PanTauAlgs.PanTauAlgsConf import PanTau__PanTauProcessor + + # ===> Information Store + python_Tool_InformationStore = PanTau__Tool_InformationStore( "PanTau_InformationStore", + Infos_Int = infoHandler.m_Infos_Int, + Infos_Double = infoHandler.m_Infos_Double, + 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() + + #for curInAlg in List_InputAlgs: + curInAlg = 'CellBased' + + print("TopOptions_NewPanTau: Adding PanTau algorithms for input alg: " + curInAlg) + + + # ===> create the discri tools for this input algorithm + python_Tool_ModeDiscri_1p0n_vs_1p1n = PanTau__Tool_ModeDiscriminator( "PanTau_ModeDiscri_1p0n_vs_1p1n_" + curInAlg, + 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, + 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, + 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 + + + # ===> Tau Decay Mode Determinator for current input alg + Name_DecayModeDeterminator = "PanTau_DecayModeDeterminator_" + curInAlg + python_Tool_DecayModeDeterminator = PanTau__Tool_DecayModeDeterminator( Name_DecayModeDeterminator, + Tool_InformationStore = python_Tool_InformationStore, + 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, + Tool_TauConstituentGetter = python_Tool_TauConstituentGetter, + Tool_TauConstituentSelector = python_Tool_TauConstituentSelector, + 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 + + + + + + + + + + + + diff --git a/Reconstruction/PanTau/PanTauAlgs/python/__init__.py b/Reconstruction/PanTau/PanTauAlgs/python/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..74583d364ec2ca794156596c7254d9b234a940c6 --- /dev/null +++ b/Reconstruction/PanTau/PanTauAlgs/python/__init__.py @@ -0,0 +1,2 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + diff --git a/Reconstruction/PanTau/PanTauAlgs/src/Alg_SeedBuilder.cxx b/Reconstruction/PanTau/PanTauAlgs/src/Alg_SeedBuilder.cxx deleted file mode 100644 index 081d7b42cff9b4fc0affa105bfa121e949e0ac97..0000000000000000000000000000000000000000 --- a/Reconstruction/PanTau/PanTauAlgs/src/Alg_SeedBuilder.cxx +++ /dev/null @@ -1,389 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// Alg_SeedBuilder.cxx, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -//! C++ includes -#include <string> - -//! core ATHENA includes -#include "GaudiKernel/StatusCode.h" -#include "StoreGate/StoreGateSvc.h" -#include "AthenaKernel/errorcheck.h" - -//! ATHENA physics objects includes -#include "tauEvent/TauJetContainer.h" -#include "xAODTau/TauJet.h" -#include "xAODTau/TauJetContainer.h" - -//! PanTau includes -#include "PanTauAlgs/Alg_SeedBuilder.h" -#include "PanTauAlgs/Tool_InformationStore.h" -#include "PanTauAlgs/Tool_InputConverter.h" - -#include "PanTauEvent/TauConstituent.h" -#include "PanTauEvent/PanTauSeed.h" -#include "PanTauEvent/PanTauSeedContainer.h" - -#include "PanTauEvent/PanTauDetails.h" -#include "tauEvent/TauJet.h" - -//! xAOD EDM -#include "xAODTau/TauJet.h" - -//! Helper includes - - -/// ////////////////////////////////////////////////////////// -/// Constructor -/// ////////////////////////////////////////////////////////// -PanTau::Alg_SeedBuilder::Alg_SeedBuilder(const std::string& name, ISvcLocator* pSvcLocator) - : - AthAlgorithm(name, pSvcLocator), - m_log(msgSvc(), name), - m_sgSvc(0), - m_Name_InputAlg(""), - - //Initialise members for tools - m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore"), - m_Tool_TauConstituentGetter("PanTau::Tool_TauConstituentGetter/Tool_TauConstituentGetter"), - m_Tool_TauConstituentSelector("PanTau::Tool_TauConstituentSelector/Tool_TauConstituentSelector"), - m_Tool_FeatureExtractor("PanTau::Tool_FeatureExtractor/Tool_FeatureExtractor"), - m_Tool_DecayModeDeterminator("PanTau::Tool_DecayModeDeterminator/Tool_DecayModeDeterminator"), - m_Tool_FourMomentumCalculator("PanTau::Tool_FourMomentumCalculator/Tool_FourMomentumCalculator"), - m_Tool_DetailsArranger("PanTau::Tool_DetailsArranger/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 hanlde to Tool_InformationStore"); - declareProperty("Tool_TauConstituentGetter", m_Tool_TauConstituentGetter, "Tool hanlde to Tool_TauConstituentGetter"); - declareProperty("Tool_TauConstituentSelector", m_Tool_TauConstituentSelector, "Tool hanlde to Tool_TauConstituentSelector"); - declareProperty("Tool_FeatureExtractor", m_Tool_FeatureExtractor, "Tool hanlde to Tool_FeatureExtractor"); - declareProperty("Tool_DecayModeDeterminator", m_Tool_DecayModeDeterminator, "Tool hanlde to Tool_DecayModeDeterminator"); - declareProperty("Tool_FourMomentumCalculator", m_Tool_FourMomentumCalculator, "Tool hanlde to Tool_FourMomentumCalculator"); - declareProperty("Tool_DetailsArranger", m_Tool_DetailsArranger, "Tool hanlde to Tool_DetailsArranger"); -} - - - -/// ////////////////////////////////////////////////////////// -/// Destructor -/// ////////////////////////////////////////////////////////// -PanTau::Alg_SeedBuilder::~Alg_SeedBuilder() { -} - - - -/// ////////////////////////////////////////////////////////// -/// Initialize -/// ////////////////////////////////////////////////////////// -StatusCode PanTau::Alg_SeedBuilder::initialize() { - - ATH_MSG_INFO(name() << " initialize()"); - - // retrieve StoreGate Service and the tools - CHECK(service("StoreGateSvc", m_sgSvc)); - CHECK( m_Tool_InformationStore.retrieve() ); - CHECK( m_Tool_TauConstituentGetter.retrieve() ); - CHECK( m_Tool_TauConstituentSelector.retrieve() ); - CHECK( m_Tool_FeatureExtractor.retrieve() ); - CHECK( m_Tool_DecayModeDeterminator.retrieve() ); - CHECK( m_Tool_DetailsArranger.retrieve() ); - - CHECK( m_Tool_InformationStore->dumpMaps() ); - - 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(); - - int enableXAODHacks = 0; - CHECK (m_Tool_InformationStore->getInfo_Int("EnableXAODMigrationHacks", enableXAODHacks) ); - if(enableXAODHacks == 1) { - ATH_MSG_WARNING("EnableXAODMigrationHacks is set to true! PanTau will run in xAOD EDM migration mode (limited functionality)!"); - ATH_MSG_WARNING("Once xAOD migration is finished, set that flag to false in PanTauAnalysis/Config_PanTau.py!"); - } - - return StatusCode::SUCCESS; -}//end of initialize - - - -/// ////////////////////////////////////////////////////////// -/// Finalize -/// ////////////////////////////////////////////////////////// -StatusCode PanTau::Alg_SeedBuilder::finalize() { - return StatusCode::SUCCESS; -}//end finalize - - - - -/// ////////////////////////////////////////////////////////// -/// Execute -/// ////////////////////////////////////////////////////////// -StatusCode PanTau::Alg_SeedBuilder::execute() { - - ATH_MSG_DEBUG("==========================================================="); - ATH_MSG_DEBUG("=== PanTau::Alg_SeedBuilder --- Seed Creation ==="); - ATH_MSG_DEBUG("==========================================================="); - ATH_MSG_DEBUG("Executing PanTau::Alg_SeedBuilder::execute() for input alg: " << m_Name_InputAlg); - - - //! ======================================================================================= - //! Update information in InformationStore to reflect current event - ATH_MSG_DEBUG("Update Informationstore"); - StatusCode sc = m_Tool_InformationStore->updateInformation(m_Name_InputAlg); - if(sc == StatusCode::RECOVERABLE) { - ATH_MSG_WARNING("Could not get all required containers from StoreGate -> skip this execution of PanTau"); - return StatusCode::SUCCESS; - } - - - //! ======================================================================================= - //! Get TauRec Container (input) -// const Analysis::TauJetContainer* l_Container_TauRec = m_Tool_InformationStore->getContainer_TauRec(); - const xAOD::TauJetContainer* l_Container_TauRec = m_Tool_InformationStore->getContainer_TauRec(); - unsigned int l_Number_InputSeeds = l_Container_TauRec->size(); - - ATH_MSG_DEBUG("Recieved tauRec container with " << l_Number_InputSeeds << " entries at " << l_Container_TauRec); - - - //! ======================================================================================= - //! Create Output Containers - PanTau::PanTauSeedContainer* l_Container_PanTauSeeds = new PanTauSeedContainer(SG::OWN_ELEMENTS); - - - //! ======================================================================================= - //! Loop over taus - for(unsigned int iTau=0; iTau<l_Number_InputSeeds; iTau++) { - - //get the current TauJet - ATH_MSG_DEBUG("===> Tau " << iTau+1 << " / " << l_Number_InputSeeds << " will enter seed creation now"); -// Analysis::TauJet* curTauJet = const_cast<Analysis::TauJet*>(l_Container_TauRec->at(iTau)); - xAOD::TauJet* curTauJet = const_cast<xAOD::TauJet*>(l_Container_TauRec->at(iTau)); - - //check for null pointer - if(curTauJet == 0) { - ATH_MSG_WARNING("Pointer to Analysis::TauJet in tauRec container is 0! -> Skip & continue with next"); - continue; - } - - 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::PanTauSeed::t_nTechnicalQualities, 0); - - //check if the tau is valid for the given input alg: - if(m_Name_InputAlg == "eflowRec") { - 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[(int)PanTau::PanTauSeed::t_NoValidInputTau] = 1; - } - } - - if(m_Name_InputAlg == "CellBased") { - 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[(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[(int)PanTau::PanTauSeed::t_NoValidInputTau] == 0) { - // Get the constituents for the current tau - CHECK( m_Tool_TauConstituentGetter->GetTauConstituents(curTauJet, l_List_TauConstituents, m_Name_InputAlg) ); - if(l_List_TauConstituents.size() == 0) { - pantauSeed_TechnicalQuality[(int)PanTau::PanTauSeed::t_NoConstituentsAtAll] = 1; - ATH_MSG_DEBUG("Seed has no associated constituents!"); - } - - - // Call the TauConstituentSelector tool to throw out bad constituents - CHECK(m_Tool_TauConstituentSelector->SelectTauConstituents(l_List_TauConstituents, l_List_SelectedTauConstituents) ); - if(l_List_SelectedTauConstituents.size() == 0) { - pantauSeed_TechnicalQuality[(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[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[(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[(int)PanTau::PanTauSeed::t_NoValidInputTau] == 1) { - pantauSeed_TechnicalQuality[(int)PanTau::PanTauSeed::t_NoConstituentsAtAll] = 1; - pantauSeed_TechnicalQuality[(int)PanTau::PanTauSeed::t_NoSelectedConstituents] = 1; - } - - //check for the pT flag - //NOTE: make sure to use correct 4-momentum version - double tauJet_pT = curTauJet->ptIntermediateAxis(); - if(tauJet_pT < m_Config_MinPt || tauJet_pT > m_Config_MaxPt) { - pantauSeed_TechnicalQuality[(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); - - unsigned int nPi0LinksCellBased = curTauJet->protoPi0PFOLinks().size(); - ATH_MSG_DEBUG("Created new PanTauSeed at " << curPanTauSeed << " with proto mode " << curPanTauSeed->getDecayModeBySubAlg() << " and nPi0 CellBased = " << nPi0LinksCellBased); - - // Get the features for this PanTauSeed - ATH_MSG_DEBUG("Calculate features for this PanTauSeed"); - CHECK(m_Tool_FeatureExtractor->calculateFeatures(curPanTauSeed) ); - - //debug output - //ATH_MSG_VERBOSE("Dumping features of finalized PanTauSeed =========================================="); - //curPanTauSeed->getFeatures()->dump(m_log, MSG::VERBOSE); - //ATH_MSG_VERBOSE("Dumped features of finalized PanTauSeed ==========================================="); - - //store in output container - ATH_MSG_DEBUG("Saving valid PanTauSeed to seed container"); - l_Container_PanTauSeeds->push_back(curPanTauSeed); - - //link it in the source TauJet -// curTauJet->addPanTauSeed(curPanTauSeed); - - }//end loop over taus - - ATH_MSG_DEBUG("Finished loop over input taus"); - - - - //! ======================================================================================= - //! Finalize the seeds - ATH_MSG_DEBUG("==========================================================="); - ATH_MSG_DEBUG("=== PanTau::Alg_SeedBuilder --- Seed Finalization ==="); - ATH_MSG_DEBUG("==========================================================="); - - //! Create the details container - //! NOTE: Not needed in rel19+ -> details are added to xAOD::TauJet directly -// std::string l_Name_PanTauDetailsContainer; -// CHECK( m_Tool_InformationStore->getInfo_String("Name_PanTauDetailsContainer", l_Name_PanTauDetailsContainer) ); -// l_Name_PanTauDetailsContainer = l_Name_PanTauDetailsContainer + m_Name_InputAlg; -// Analysis::TauDetailsContainer* l_Container_PanTauDetails = new Analysis::TauDetailsContainer(); -// CHECK( m_sgSvc->record(l_Container_PanTauDetails, l_Name_PanTauDetailsContainer) ); - - // Seed finalizing: - // 1. Pass the seed to the decay mode determination tool - // 2. Pass the seed to the FourMomentumCalculator tool - // 3. Add the details to tauJet - unsigned int l_Number_PanTauSeeds = l_Container_PanTauSeeds->size(); - ATH_MSG_DEBUG("Begin loop over " << l_Number_PanTauSeeds << " PanTau seeds to finalize them"); - for(unsigned int iPanTau=0; iPanTau<l_Number_PanTauSeeds; iPanTau++) { - ATH_MSG_DEBUG("===> PanTauSeed " << iPanTau+1 << " / " << l_Number_InputSeeds << " will be finalized now..."); - PanTau::PanTauSeed* curPanTauSeed = l_Container_PanTauSeeds->at(iPanTau); - - - - // 1. call decay mode determinator for this seed - ATH_MSG_DEBUG("calling decay mode determinator for valid seed "); - CHECK( m_Tool_DecayModeDeterminator->determineDecayMode(curPanTauSeed) ); - - // 2. call the FourMomentumCalculator for this seed - ATH_MSG_DEBUG("calling four momentum calculator for valid seed "); - CHECK( m_Tool_FourMomentumCalculator->calculateFourMomentum(curPanTauSeed) ); - - // 3. Link the details to the tauJet -// CHECK( m_Tool_DetailsArranger->arrangeDetails(curPanTauSeed, l_Container_PanTauDetails) ); - CHECK( m_Tool_DetailsArranger->arrangeDetails(curPanTauSeed) ); - - }//end loop over output pantau seeds - -// CHECK( m_sgSvc->setConst( l_Container_PanTauDetails ) ); - - //! ======================================================================================= - //! Store the output seeds - - // NOTE: This container is not used at the moment... :) -// ATH_MSG_DEBUG("Storing output for " << l_Container_TauRec->size() << " input seeds in two PanTauSeedContainers"); - - // store the seeds - // not needed in 19.0.1 - // NOTE: Need to rethink how to dump ALL development variables - delete l_Container_PanTauSeeds; - -// std::string l_Name_ValidSeedContainer; -// CHECK(m_Tool_InformationStore->getInfo_String("Name_PanTauSeedsContainer", l_Name_ValidSeedContainer)); -// l_Name_ValidSeedContainer = l_Name_ValidSeedContainer + m_Name_InputAlg; -// CHECK( m_sgSvc->record(l_Container_PanTauSeeds, l_Name_ValidSeedContainer, false) ); -// ATH_MSG_DEBUG("Stored " << l_Number_PanTauSeeds << " PanTauSeeds"); - - - //that's it :) - ATH_MSG_DEBUG("PanTau::Alg_SeedBuilder for input alg" << m_Name_InputAlg << " was successful!"); - return StatusCode::SUCCESS; -}//end of execute - - - -void PanTau::Alg_SeedBuilder::fillDefaultValuesToTau(xAOD::TauJet* tauJet) { - - - if(m_Name_InputAlg == "CellBased") { - tauJet->setP4(xAOD::TauJetParameters::PanTauCellBased, -1111., -1111., -1111., -1111.); - - // - //charged - std::vector< ElementLink< xAOD::PFOContainer > > chrgPFOLinks = tauJet->protoChargedPFOLinks(); - tauJet->setChargedPFOLinks(chrgPFOLinks); - - //pi0 - std::vector< ElementLink< xAOD::PFOContainer > > pi0PFOLinks = tauJet->protoPi0PFOLinks(); - tauJet->setPi0PFOLinks(pi0PFOLinks); - - //neutrals - std::vector< ElementLink< xAOD::PFOContainer > > neutralPFOLinks = tauJet->protoNeutralPFOLinks(); - tauJet->setNeutralPFOLinks(neutralPFOLinks); - } - - - if(m_Name_InputAlg == "eflowRec") { - tauJet->setP4(xAOD::TauJetParameters::PanTauEFlowRec, -1111., -1111., -1111., -1111.); - } - - return; -} - - - - - - - - - - - - - - - - - diff --git a/Reconstruction/PanTau/PanTauAlgs/src/RunTimeMonitoring.cxx b/Reconstruction/PanTau/PanTauAlgs/src/RunTimeMonitoring.cxx deleted file mode 100644 index 2df5362feb524c346827af41c6b4abdeeaaa4059..0000000000000000000000000000000000000000 --- a/Reconstruction/PanTau/PanTauAlgs/src/RunTimeMonitoring.cxx +++ /dev/null @@ -1,119 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - - -#include "PanTauAlgs/RunTimeMonitoring.h" - - -PanTau::RunTimeMonitoring::RunTimeMonitoring(bool isActive) { - m_IsActivated = isActive; - m_THistSvc = 0; -} - -PanTau::RunTimeMonitoring::RunTimeMonitoring( const RunTimeMonitoring& other ) { - m_IsActivated = other.m_IsActivated; - m_THistSvc = other.m_THistSvc; -} - -PanTau::RunTimeMonitoring::~RunTimeMonitoring() { - m_THistSvc = 0; - m_HistMap.clear(); -} - -PanTau::RunTimeMonitoring PanTau::RunTimeMonitoring::operator=( RunTimeMonitoring rhs ) { - m_THistSvc = rhs.m_THistSvc; - m_HistMap = rhs.m_HistMap; - m_IsActivated = rhs.m_IsActivated; - return *this; -} - - -void PanTau::RunTimeMonitoring::SetTHistSvcLink(ITHistSvc* histSvc) { - m_THistSvc = histSvc; -} - - - -// Histogram Creation --------------------------------------------------------------------- - -void PanTau::RunTimeMonitoring::CreateHist1D(std::string Name, std::string xTitle, int nBins, double MinBin, double MaxBin) { - //check if this histo already exists - HistMap::iterator it = m_HistMap.find(Name); - if(it != m_HistMap.end()) { - std::cout << "PanTau-RunTimeMonitoring\t\tWARNING\tRTM:CreateHist1D: Histogram with name " << Name << " already exists in HistMap" << std::endl; - return; - } - TString HistName = Name; - TString HistxTitle = xTitle; - std::pair<std::string, TH1F*> toInsert = std::pair<std::string, TH1F*>(Name, new TH1F(HistName, HistName, nBins, MinBin, MaxBin)); - toInsert.second->GetXaxis()->SetTitle(HistxTitle); - m_HistMap.insert(toInsert); - return; -} - -void PanTau::RunTimeMonitoring::CreateHist1DMap( - std::vector<std::string> Names, - std::vector<std::string> xTitles, - std::vector<int> nBins, - std::vector<double> MinBins, - std::vector<double> MaxBins - ) { - //int nHists = 0; - bool valid = false; - if(Names.size() == xTitles.size() && Names.size() == nBins.size() && Names.size() == MinBins.size() && Names.size() == MaxBins.size()) { - valid = true; - //nHists = Names.size(); - } - if(valid == false) { - std::cout << "PanTau-RunTimeMonitoring\t\tWARNING\tRTM:CreateHist1DMap: Mismatch in sizes of input vectors" << std::endl; - return; - } - for(unsigned int i=0; i<Names.size(); i++) { - CreateHist1D(Names[i], xTitles[i], nBins[i], MinBins[i], MaxBins[i]); - } - return; -} - - - -bool PanTau::RunTimeMonitoring::RegisterHistos() { - //loop through map and register - HistMap::iterator itHist = m_HistMap.begin(); - HistMap::iterator itHistEnd = m_HistMap.end(); - - for(; itHist != itHistEnd; itHist++) { - //register the histogram with the hist service - std::string curName = itHist->first; - std::string SavePath = "/PanTauHists/RunTimeHistograms/"; - std::string SubFolder = "other/"; - if(curName[1] == 'G') SubFolder = "EventVariables/"; - if(curName[1] == 'T') SubFolder = "TauVariables/"; - if(curName[1] == 'E') SubFolder = "EFOVariables/"; - if(curName[1] == 'R') SubFolder = "RunTimeVariables/"; - SavePath = SavePath + SubFolder; - SavePath = SavePath + curName; - StatusCode scRegHist = m_THistSvc->regHist(SavePath.c_str(), itHist->second); - if( scRegHist.isFailure() ) { - std::cout << "PanTau-RunTimeMonitoring\t\tERROR\tRegistration of histo " << curName << " failed" << std::endl; - return false; - } - } - return true; -} - - - -// Histogram Filling ----------------------------------------------------------------------- - -void PanTau::RunTimeMonitoring::FillHisto(std::string itsName, double fillValue) { - if(m_IsActivated == false) return; - - //search histogram called itsName in HistMap and fill fillValue into it if it is found - HistMap::iterator itHist = m_HistMap.find(itsName); - if(itHist == m_HistMap.end()) return; - - itHist->second->Fill(fillValue); - return; -} diff --git a/Reconstruction/PanTau/PanTauAlgs/src/Tool_DetailsArranger.cxx b/Reconstruction/PanTau/PanTauAlgs/src/Tool_DetailsArranger.cxx deleted file mode 100644 index a98559b381e65a1d02177689f127350a7a3deaf2..0000000000000000000000000000000000000000 --- a/Reconstruction/PanTau/PanTauAlgs/src/Tool_DetailsArranger.cxx +++ /dev/null @@ -1,894 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// Implementation file for class Tool_DetailsArranger -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// -// Tool for PID of TauSeeds -/////////////////////////////////////////////////////////////////// -// sebastian.fleischmann@cern.ch -/////////////////////////////////////////////////////////////////// - -//! C++ -#include <string> -#include <vector> - -#include "DataModel/ElementLink.h" - -//! xAOD EDM -// #include "xAODTau/TauDefs.h" -#include "xAODTau/TauJet.h" -#include "xAODPFlow/PFOContainer.h" - -//! PanTau includes -#include "PanTauAlgs/Tool_DetailsArranger.h" -#include "PanTauEvent/PanTauSeed.h" -#include "PanTauEvent/PanTauDetails.h" -#include "PanTauEvent/PanTauDetails_eflowRec.h" -#include "PanTauEvent/PanTauDetails_CellBased.h" -// #include "tauEvent/TauDetailsContainer.h" - -#include "StoreGate/StoreGateSvc.h" -#include "AthenaKernel/errorcheck.h" - - -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& ty, - const std::string& na, - const IInterface* pa ) : - AthAlgTool(ty,na,pa), - m_sgSvc(0), - m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore") -{ - declareInterface<ITool_DetailsArranger>(this); - declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Tool handle to the information store tool"); -} - - - -PanTau::Tool_DetailsArranger::~Tool_DetailsArranger() { -} - - - -StatusCode PanTau::Tool_DetailsArranger::initialize() { - - ATH_MSG_DEBUG( name() << " initialize()" ); - CHECK( AthAlgTool::initialize() ); - - CHECK(service("StoreGateSvc", m_sgSvc)); - - CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_Types_DeltaRCore", m_CoreCone) ); - CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_BinEdges_Eta", m_EtaBinEdges) ); - CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_Neutral_EtaBinned_EtCut", m_EtaBinnedEtCuts) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Sum", m_varTypeName_Sum) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Ratio", m_varTypeName_Ratio) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_EtInRing", m_varTypeName_EtInRing) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Isolation", m_varTypeName_Isolation) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Num", m_varTypeName_Num) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Mean", m_varTypeName_Mean) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_StdDev", m_varTypeName_StdDev) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_HLV", m_varTypeName_HLV) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Angle", m_varTypeName_Angle) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_DeltaR", m_varTypeName_DeltaR) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_JetMoment", m_varTypeName_JetMoment) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Combined", m_varTypeName_Combined) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_JetShape", m_varTypeName_JetShape) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_ImpactParams", m_varTypeName_ImpactParams) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Basic", m_varTypeName_Basic) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_PID", m_varTypeName_PID) ); - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Shots", m_varTypeName_Shots) ); - - return StatusCode::SUCCESS; -} - - - -// StatusCode PanTau::Tool_DetailsArranger::finalize() { -// CHECK(AlgTool::finalize()); -// -// return StatusCode::SUCCESS; -// } - - - - - -StatusCode PanTau::Tool_DetailsArranger::arrangeDetails(PanTau::PanTauSeed* inSeed) {//, Analysis::TauDetailsContainer* detailsCont) { - std::string inputAlg = inSeed->getNameInputAlgorithm(); - - ATH_MSG_DEBUG( "arrangeDetails called for input seed at: " << inSeed << " from inputalg: " << inputAlg); -// ATH_MSG_DEBUG( "arrangeDetails called for container at : " << detailsCont); - - 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; - - - //create the general part of the details - // relevant ID variables are taken care of in construction by passing the input seed -// PanTau::PanTauDetails* Details_PanTau_General = new PanTau::PanTauDetails(inSeed); - - - //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()); - - ATH_MSG_DEBUG( "check for bad seed -> isBadSeed = " << isBadSeed); - if(isBadSeed == true) { - ATH_MSG_DEBUG("This seed is not useable for detail arraning (other than validity flag)"); - if(inputAlg == "CellBased") tauJet->setPanTauDetail(xAOD::TauJetParameters::pantau_CellBasedInput_isPanTauCandidate, 0); - if(inputAlg == "eflowRec") tauJet->setPanTauDetail(xAOD::TauJetParameters::pantau_eflowRecInput_isPanTauCandidate, 0); - return StatusCode::SUCCESS; - } - - - ATH_MSG_DEBUG( "arrange for seed from inputalg: " << inputAlg); - if(inputAlg == "CellBased") { - - arrangePFOLinks(inSeed, tauJet); - - //Basic variables - addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_isPanTauCandidate", xAOD::TauJetParameters::pantau_CellBasedInput_isPanTauCandidate, PanTau::Tool_DetailsArranger::t_Int); -// addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_RecoMode", xAOD::TauJetParameters::pantau_CellBasedInput_DecayModeProto, PanTau::Tool_DetailsArranger::t_Int); - addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_RecoMode_PanTau", xAOD::TauJetParameters::pantau_CellBasedInput_DecayMode, PanTau::Tool_DetailsArranger::t_Int); - addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_BDTValue_1p0n_vs_1p1n", xAOD::TauJetParameters::pantau_CellBasedInput_BDTValue_1p0n_vs_1p1n, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_BDTValue_1p1n_vs_1pXn", xAOD::TauJetParameters::pantau_CellBasedInput_BDTValue_1p1n_vs_1pXn, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_BDTValue_3p0n_vs_3pXn", xAOD::TauJetParameters::pantau_CellBasedInput_BDTValue_3p0n_vs_3pXn, PanTau::Tool_DetailsArranger::t_Float); - - - //Final 4-vector - tauJet->setP4(xAOD::TauJetParameters::PanTauCellBased, inSeed->getFinalMomentum().perp(), inSeed->getFinalMomentum().eta(), inSeed->getFinalMomentum().phi(), inSeed->getFinalMomentum().m()); - - //BDT variables - addPanTauDetailToTauJet(inSeed, "Basic_NNeutralConsts", - xAOD::TauJetParameters::pantau_CellBasedInput_BDTVar_Basic_NNeutralConsts, PanTau::Tool_DetailsArranger::t_Int); - addPanTauDetailToTauJet(inSeed, "Charged_JetMoment_EtDRxTotalEt", - xAOD::TauJetParameters::pantau_CellBasedInput_BDTVar_Charged_JetMoment_EtDRxTotalEt, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Charged_StdDev_Et_WrtEtAllConsts", - xAOD::TauJetParameters::pantau_CellBasedInput_BDTVar_Charged_StdDev_Et_WrtEtAllConsts, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_HLV_SumM", - xAOD::TauJetParameters::pantau_CellBasedInput_BDTVar_Neutral_HLV_SumM, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_PID_BDTValues_BDTSort_1", - xAOD::TauJetParameters::pantau_CellBasedInput_BDTVar_Neutral_PID_BDTValues_BDTSort_1, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_PID_BDTValues_BDTSort_2", - xAOD::TauJetParameters::pantau_CellBasedInput_BDTVar_Neutral_PID_BDTValues_BDTSort_2, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_Ratio_1stBDTEtOverEtAllConsts", - xAOD::TauJetParameters::pantau_CellBasedInput_BDTVar_Neutral_Ratio_1stBDTEtOverEtAllConsts, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_Ratio_EtOverEtAllConsts", - xAOD::TauJetParameters::pantau_CellBasedInput_BDTVar_Neutral_Ratio_EtOverEtAllConsts, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_Shots_NPhotonsInSeed", - xAOD::TauJetParameters::pantau_CellBasedInput_BDTVar_Neutral_Shots_NPhotonsInSeed, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Combined_DeltaR1stNeutralTo1stCharged", - xAOD::TauJetParameters::pantau_CellBasedInput_BDTVar_Combined_DeltaR1stNeutralTo1stCharged, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Charged_HLV_SumM", - xAOD::TauJetParameters::pantau_CellBasedInput_BDTVar_Charged_HLV_SumM, PanTau::Tool_DetailsArranger::t_Float); - - } - - if(inputAlg == "eflowRec") { - - //Basic variables - addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_isPanTauCandidate", xAOD::TauJetParameters::pantau_eflowRecInput_isPanTauCandidate, PanTau::Tool_DetailsArranger::t_Int); - addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_RecoMode", xAOD::TauJetParameters::pantau_eflowRecInput_DecayModeProto, PanTau::Tool_DetailsArranger::t_Int); - addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_RecoMode_PanTau", xAOD::TauJetParameters::pantau_eflowRecInput_DecayMode, PanTau::Tool_DetailsArranger::t_Int); - addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_BDTValue_1p0n_vs_1p1n", xAOD::TauJetParameters::pantau_eflowRecInput_BDTValue_1p0n_vs_1p1n, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_BDTValue_1p1n_vs_1pXn", xAOD::TauJetParameters::pantau_eflowRecInput_BDTValue_1p1n_vs_1pXn, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_BDTValue_3p0n_vs_3pXn", xAOD::TauJetParameters::pantau_eflowRecInput_BDTValue_3p0n_vs_3pXn, PanTau::Tool_DetailsArranger::t_Float); - - //Proto 4-vector -// ATH_MSG_WARNING("elfowRec: ProtoMomentumCore pt, eta, phi, m: " << inSeed->getProtoMomentumCore().perp() << ", " << inSeed->getProtoMomentumCore().eta() << ", " << inSeed->getProtoMomentumCore().phi() << ", " << inSeed->getProtoMomentumCore().m()); - tauJet->setP4(xAOD::TauJetParameters::PanTauEFlowRecProto, inSeed->getProtoMomentumCore().perp(), inSeed->getProtoMomentumCore().eta(), inSeed->getProtoMomentumCore().phi(), inSeed->getProtoMomentumCore().m() ); -// tauJet->setPtPanTauEFlowRecProto(inSeed->getProtoMomentumCore().perp()); -// tauJet->setPhiPanTauEFlowRecProto(inSeed->getProtoMomentumCore().phi()); -// tauJet->setEtaPanTauEFlowRecProto(inSeed->getProtoMomentumCore().eta()); -// tauJet->setMPanTauEFlowRecProto(inSeed->getProtoMomentumCore().m()); -// TLorentzVector eflowRecProto = tauJet->p4(xAOD::TauJetParameters::PanTauEFlowRecProto); -// ATH_MSG_WARNING("eflowRec: Proto from xAOD TLV : " << eflowRecProto.Pt() << ", " << eflowRecProto.Eta() << ", " << eflowRecProto.Phi() << ", " << eflowRecProto.M()); -// ATH_MSG_WARNING("eflowRec: Proto from xAOD single: " << tauJet->ptPanTauEFlowRecProto() << ", " << tauJet->etaPanTauEFlowRecProto() << ", " << tauJet->phiPanTauEFlowRecProto() << ", " << tauJet->mPanTauEFlowRecProto()); - - //Final 4-vector -// ATH_MSG_WARNING("elfowRec: ProtoMomentumCore pt, eta, phi, m: " << inSeed->getFinalMomentum().perp() << ", " << inSeed->getFinalMomentum().eta() << ", " << inSeed->getFinalMomentum().phi() << ", " << inSeed->getFinalMomentum().m()); - tauJet->setP4(xAOD::TauJetParameters::PanTauEFlowRec, inSeed->getFinalMomentum().perp(), inSeed->getFinalMomentum().eta(), inSeed->getFinalMomentum().phi(), inSeed->getFinalMomentum().m() ); -// tauJet->setPtPanTauEFlowRec(inSeed->getFinalMomentum().perp()); -// tauJet->setPhiPanTauEFlowRec(inSeed->getFinalMomentum().phi()); -// tauJet->setEtaPanTauEFlowRec(inSeed->getFinalMomentum().eta()); -// tauJet->setMPanTauEFlowRec(inSeed->getFinalMomentum().m()); - - //BDT variables - addPanTauDetailToTauJet(inSeed, "Basic_NPi0NeutConsts", - xAOD::TauJetParameters::pantau_eflowRecInput_BDTVar_Basic_NPi0NeutConsts, PanTau::Tool_DetailsArranger::t_Int); - addPanTauDetailToTauJet(inSeed, "Basic_NNeutralConsts", - xAOD::TauJetParameters::pantau_eflowRecInput_BDTVar_Basic_NNeutralConsts, PanTau::Tool_DetailsArranger::t_Int); - addPanTauDetailToTauJet(inSeed, "Charged_HLV_SumPt", - xAOD::TauJetParameters::pantau_eflowRecInput_BDTVar_Charged_HLV_SumPt, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Charged_Ratio_EtOverEtAllConsts", - xAOD::TauJetParameters::pantau_eflowRecInput_BDTVar_Charged_Ratio_EtOverEtAllConsts, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_HLV_SumM", - xAOD::TauJetParameters::pantau_eflowRecInput_BDTVar_Neutral_HLV_SumM, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_PID_BDTValues_EtSort_1", - xAOD::TauJetParameters::pantau_eflowRecInput_BDTVar_Neutral_PID_BDTValues_EtSort_1, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_PID_BDTValues_BDTSort_2", - xAOD::TauJetParameters::pantau_eflowRecInput_BDTVar_Neutral_PID_BDTValues_BDTSort_2, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_Ratio_EtOverEtAllConsts", - xAOD::TauJetParameters::pantau_eflowRecInput_BDTVar_Neutral_Ratio_EtOverEtAllConsts, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Neutral_Mean_DRToLeading_WrtEtAllConsts", - xAOD::TauJetParameters::pantau_eflowRecInput_BDTVar_Neutral_Mean_DRToLeading_WrtEtAllConsts, PanTau::Tool_DetailsArranger::t_Float); - addPanTauDetailToTauJet(inSeed, "Combined_DeltaR1stNeutralTo1stCharged", - xAOD::TauJetParameters::pantau_eflowRecInput_BDTVar_Combined_DeltaR1stNeutralTo1stCharged, PanTau::Tool_DetailsArranger::t_Float); - - - }//end eflowRec details setting - - return StatusCode::SUCCESS; -} - - - -void PanTau::Tool_DetailsArranger::addPanTauDetailToTauJet(PanTauSeed* inSeed, - std::string featName, - xAOD::TauJetParameters::PanTauDetails detailEnum, - PanTauDetailsType detailType) const { - - ATH_MSG_DEBUG( "addPanTauDetailToTauJet called for feature of type " << detailType << ": " << featName); - bool isValid; - PanTau::TauFeature* features = inSeed->getFeatures(); - std::string fullFeatName = inSeed->getNameInputAlgorithm() + "_" + featName; - - double theValue; - 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; - } - - ATH_MSG_DEBUG( "the value is" << theValue); - - xAOD::TauJet* tauJet = const_cast<xAOD::TauJet*>(inSeed->getTauJet()); - int valueToAddInt = -1; - float valueToAddFloat = -1.1; - ATH_MSG_DEBUG( "will add it to xAOD::TauJet at " << tauJet); - switch(detailType) { - case PanTau::Tool_DetailsArranger::t_Int: - valueToAddInt = (int)theValue; - ATH_MSG_DEBUG( "Adding int feature: " << valueToAddInt); - tauJet->setPanTauDetail(detailEnum, valueToAddInt); - break; - case PanTau::Tool_DetailsArranger::t_Float: - valueToAddFloat = (float)theValue; - ATH_MSG_DEBUG( "Adding float feature: " << valueToAddFloat); - 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; -} - - - - - -void PanTau::Tool_DetailsArranger::arrangeScalarDetail(PanTau::PanTauDetails* targetDetails, std::string featName, int featEnumFromPanTauDetails) const { - - bool isValid; - PanTau::PanTauSeed* sourceSeed = targetDetails->getPanTauSeed(); - PanTau::TauFeature* features = targetDetails->getFeatures(); - std::string fullFeatName = sourceSeed->getNameInputAlgorithm() + "_" + featName; - - double theValue; - 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; - } - - - targetDetails->setScalarDetailByEnum(theValue, featEnumFromPanTauDetails); - - return; -} - - - -void PanTau::Tool_DetailsArranger::arrangeVectorDetail(PanTau::PanTauDetails* targetDetails, std::string featName, int featEnumFromPanTauDetails) const { - - PanTau::PanTauSeed* sourceSeed = targetDetails->getPanTauSeed(); - PanTau::TauFeature* features = targetDetails->getFeatures(); - std::string fullFeatName = sourceSeed->getNameInputAlgorithm() + "_" + featName; - - std::vector<double> theValue; - if(sourceSeed->getIsValidSeed() == true) { - theValue = features->vecValue(fullFeatName); - } else {//seed was not valid to begin with - theValue = std::vector<double>(0); - } - - #ifndef NDEBUG - ATH_MSG_DEBUG("Tool_DetailsArranger: vector detail " << fullFeatName << " set to have entries: " << theValue.size()); - for(unsigned int iVal=0; iVal<theValue.size(); iVal++) { - ATH_MSG_DEBUG("\t\t" << iVal+1 << ": " << theValue[iVal]); - } - #endif // NDEBUG - - - targetDetails->setVectorDetailByEnum(theValue, featEnumFromPanTauDetails); - - return; -} - - -/* -void PanTau::Tool_DetailsArranger::StripPi0ConstsFromNeutralConsts(std::vector< ElementLink< xAOD::PFOContainer > > &neutralPFOLinks, std::vector< ElementLink< xAOD::PFOContainer > > pi0PFOLinks){ - - unsigned int neut_orig_size = neutralPFOLinks.size(); - - for(unsigned int iconsts_Pi0Neut=0; iconsts_Pi0Neut < pi0PFOLinks.size(); ++iconsts_Pi0Neut){ - - int neut_index=-1; - for(unsigned int iconsts_Neutral=0; iconsts_Neutral < neutralPFOLinks.size(); ++iconsts_Neutral){ - - if( neutralPFOLinks.at(iconsts_Neutral).cachedElement() == pi0PFOLinks.at(iconsts_Pi0Neut).cachedElement() ) { neut_index = iconsts_Neutral; } - - } - - if(neut_index > -1) neutralPFOLinks.erase( neutralPFOLinks.begin() + neut_index); - else { - ATH_MSG_WARNING("StripPi0ConstsFromNeutralConsts: No neutral found for pi0neutral with index " << iconsts_Pi0Neut); - } - - } - - // did we find a neutral PFO to each pi0 PFO? - if(neutralPFOLinks.size() != (neut_orig_size - pi0PFOLinks.size()) ){ - ATH_MSG_WARNING("StripPi0ConstsFromNeutralConsts: neutralPFOLinks.size() != (neut_orig_size - pi0PFOLinks.size()) -- " << neutralPFOLinks.size() << " != (" << neut_orig_size << " - " << pi0PFOLinks.size() << ")" ); - } - - return; - -} -*/ - - - -void PanTau::Tool_DetailsArranger::arrangePFOLinks(PanTau::PanTauSeed* inSeed, xAOD::TauJet* tauJet) { - - //get the PFO links - std::vector< ElementLink< xAOD::PFOContainer > > chrgPFOLinks = tauJet->protoChargedPFOLinks(); - //std::vector< ElementLink< xAOD::PFOContainer > > pi0PFOLinks = tauJet->protoPi0PFOLinks(); - 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 ); - - /* - ATH_MSG_DEBUG("Dumping neutral pfo links from constituents"); - for(unsigned int iPFO=0; iPFO<neutralPFOLinks_tmp.size(); iPFO++) { - const xAOD::PFO* pfo = neutralPFOLinks_tmp.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() ); - } - ATH_MSG_DEBUG("Dumping pi0 pfo links from constituents"); - for(unsigned int iPFO=0; iPFO<pi0PFOLinks_tmp.size(); iPFO++) { - const xAOD::PFO* pfo = pi0PFOLinks_tmp.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() ); - } - */ - - //clear the default links, just to be save - tauJet->clearChargedPFOLinks(); - tauJet->clearNeutralPFOLinks(); - tauJet->clearPi0PFOLinks(); - - //std::vector< ElementLink< xAOD::PFOContainer > > preLinkChrgPFOLinks = tauJet->chargedPFOLinks(); - std::vector< ElementLink< xAOD::PFOContainer > > preLinkPi0PFOLinks = tauJet->pi0PFOLinks(); - //std::vector< ElementLink< xAOD::PFOContainer > > preLinkNeutralPFOLinks = tauJet->neutralPFOLinks(); - - // 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.); - - // 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()); - - - ATH_MSG_DEBUG("Dumping preselected neutral pfo links"); - for(unsigned int iPFO=0; iPFO<preSelected_neutralPFOLinks.size(); iPFO++) { - const xAOD::PFO* pfo = preSelected_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() ); - } - /* - std::vector< ElementLink< xAOD::PFOContainer > > preSelected_neutralPFOLinks=PreselectNeutralLinks(neutralPFOLinks, tauJet); - ATH_MSG_DEBUG("Dumping preselected neutral pfo links"); - for(unsigned int iPFO=0; iPFO<preSelected_neutralPFOLinks.size(); iPFO++) { - const xAOD::PFO* pfo = preSelected_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() ); - } - - - StripPi0ConstsFromNeutralConsts(preSelected_neutralPFOLinks, pi0PFOLinks); - ATH_MSG_DEBUG("Dumping preselected neutral pfo links after stripping pi0 neutrals"); - for(unsigned int iPFO=0; iPFO<preSelected_neutralPFOLinks.size(); iPFO++) { - const xAOD::PFO* pfo = preSelected_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() ); - } - */ - - //arrange pi0 pfos: depends on decay mode classification - int decayModeProto = inSeed->getDecayModeBySubAlg(); - int decayModeFinal = inSeed->getDecayModeByPanTau(); - - if(decayModeFinal == PanTau::PanTauSeed::Mode_Other) { - tauJet->setPi0PFOLinks(pi0PFOLinks); - return; - } - - ATH_MSG_DEBUG("Before re-linking: DecayMode Proto / Final: " << decayModeProto << " / " << decayModeFinal); - ATH_MSG_DEBUG("Number of chrg, pi0, neut PFOs in subAlg: " << chrgPFOLinks.size() << ", " << pi0PFOLinks.size() << ", " << neutralPFOLinks.size()); - ATH_MSG_DEBUG("Number of pi0 PFOs in PanTau: " << preLinkPi0PFOLinks.size()); - - //#ifndef NDEBUG - ATH_MSG_DEBUG("Dumping pi0 pfos for subalg"); - for(unsigned int iPFO=0; iPFO<pi0PFOLinks.size(); iPFO++) { - const xAOD::PFO* pfo = pi0PFOLinks.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()); - } - ATH_MSG_DEBUG("Dumping neutral pfos for subalg"); - for(unsigned int iPFO=0; iPFO<neutralPFOLinks.size(); iPFO++) { - const xAOD::PFO* pfo = 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() ); - } - //#endif //NDEBUG - - - //set nPi0 to 0 for neutrals that have no pi0 -// for(unsigned int iPFO=0; iPFO<neutralPFOLinks.size(); iPFO++) { -// xAOD::PFO* curPFO = const_cast<xAOD::PFO*>(neutralPFOLinks.at(iPFO).cachedElement()); -// int nPi0 = -1; -// bool getOK = curPFO->attribute(xAOD::PFODetails::nPi0Proto, nPi0); -// if(getOK == false) { -// ATH_MSG_DEBUG("Could not get nPi0Proto for this PFO -> skip setting of nPi0"); -// continue; -// } -// if(nPi0 < 1) curPFO->setAttribute(xAOD::PFODetails::nPi0Proto, 0); -// } - - - std::string inputAlg = inSeed->getNameInputAlgorithm(); - - //if pantau sets the same decay mode as the substructure algorithm, just copy the links - if(decayModeProto == decayModeFinal) { - ATH_MSG_DEBUG("Modes are the same"); - - if( decayModeFinal == PanTau::PanTauSeed::Mode_3pXn && pi0PFOLinks.size() > 1 ){ - - // assign all neutrals but only one pi0 neutral to Pantau: - preLinkPi0PFOLinks.push_back( pi0PFOLinks.at(0) ); - - // set all masses correctly: - SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); - - } else { - - // assign the same constituents to Pantau: - preLinkPi0PFOLinks=pi0PFOLinks; - - // set all masses correctly: - SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); - - } - - - } else { - - // ***** - // if(preSelected_neutralPFOLinks.size() > 0) are not necessary! - // ***** - - if( decayModeFinal == PanTau::PanTauSeed::Mode_1p1n && decayModeProto == PanTau::PanTauSeed::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); - - } else if( decayModeFinal == PanTau::PanTauSeed::Mode_1p0n && decayModeProto == PanTau::PanTauSeed::Mode_1p1n ){ - - // do nothing (leave the pi0 neutrals list empty) - - } else if( decayModeFinal == PanTau::PanTauSeed::Mode_1pXn && decayModeProto == PanTau::PanTauSeed::Mode_1p1n ){ - - - if( pi0PFOLinks.size() == 1 && HasMultPi0sInOneCluster(pi0PFOLinks.at(0).cachedElement(), decayModeProto, inputAlg) ){ - // ATH_MSG_WARNING("RecalculatePantauConstituents: Inconsistent decay mode classification! (wasAlteredByCellBasedShots=true although decay mode = " << decayModeFinal); - // tauJet->setPi0PFOLinks(pi0PFOLinks); - // return; - // } - - // assign twice the pi0 mass to the one pi0 PFO: - SetNeutralConstituentVectorMasses(pi0PFOLinks, 2*MASS_PI0); - - // assign the same constituents to Pantau: - preLinkPi0PFOLinks=pi0PFOLinks; - - } 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!!"); - - // set the mass: - SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); - - } - - } else if( decayModeFinal == PanTau::PanTauSeed::Mode_1p1n && decayModeProto == PanTau::PanTauSeed::Mode_1pXn ){ - - // 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.); - - } else if( decayModeFinal == PanTau::PanTauSeed::Mode_3pXn && decayModeProto == PanTau::PanTauSeed::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!!"); - - // set the mass: - SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, MASS_PI0); - - } else if( decayModeFinal == PanTau::PanTauSeed::Mode_3p0n && decayModeProto == PanTau::PanTauSeed::Mode_3pXn ){ - - // do nothing (leave the pi0 neutrals list empty) - - } - - } - - tauJet->setPi0PFOLinks(preLinkPi0PFOLinks); - - - - ATH_MSG_DEBUG("Done setting links"); - ATH_MSG_DEBUG("DecayMode Proto / Final: " << decayModeProto << " / " << decayModeFinal); - ATH_MSG_DEBUG("Number of chrg, pi0, neut PFOs in subAlg: " << chrgPFOLinks.size() << ", " << pi0PFOLinks.size() << ", " << neutralPFOLinks.size()); - - std::vector< ElementLink< xAOD::PFOContainer > > finalChrgPFOLinks = tauJet->chargedPFOLinks(); - std::vector< ElementLink< xAOD::PFOContainer > > finalPi0PFOLinks = tauJet->pi0PFOLinks(); - std::vector< ElementLink< xAOD::PFOContainer > > finalNeutralPFOLinks = tauJet->neutralPFOLinks(); - ATH_MSG_DEBUG("Number of chrg, pi0, neut PFOs in PanTau: " << finalChrgPFOLinks.size() << ", " << finalPi0PFOLinks.size() << ", " << finalNeutralPFOLinks.size()); - - - - //! DEBUG output - //#ifndef NDEBUG - ATH_MSG_DEBUG("Dumping charged pfos for subalg"); - for(unsigned int iPFO=0; iPFO<chrgPFOLinks.size(); iPFO++) { - const xAOD::PFO* pfo = chrgPFOLinks.at(iPFO).cachedElement(); - ATH_MSG_DEBUG("pfo " << iPFO << " pt, eta, phi, m: " << pfo->pt() << ", " << pfo->eta() << ", " << pfo->phi() << ", " << pfo->m()); - } - ATH_MSG_DEBUG("Dumping charged pfos for pantau"); - for(unsigned int iPFO=0; iPFO<finalChrgPFOLinks.size(); iPFO++) { - const xAOD::PFO* pfo = finalChrgPFOLinks.at(iPFO).cachedElement(); - ATH_MSG_DEBUG("pfo " << iPFO << " pt, eta, phi, m: " << pfo->pt() << ", " << pfo->eta() << ", " << pfo->phi() << ", " << pfo->m()); - } - - ATH_MSG_DEBUG("Dumping pi0 pfos for subalg"); - for(unsigned int iPFO=0; iPFO<pi0PFOLinks.size(); iPFO++) { - const xAOD::PFO* pfo = pi0PFOLinks.at(iPFO).cachedElement(); - int nPi0 = -1; - bool getOK = pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0); - if(getOK == false) ATH_MSG_DEBUG("problems reading pi0 attribute"); - ATH_MSG_DEBUG("pfo " << iPFO << " pt, eta, phi, m: " << pfo->pt() << ", " << pfo->eta() << ", " << pfo->phi() << ", " << pfo->m() << " isPi0: " << nPi0 << " , BDTscore: " << pfo->bdtPi0Score() ); - } - ATH_MSG_DEBUG("Dumping pi0 pfos for pantau"); - for(unsigned int iPFO=0; iPFO<finalPi0PFOLinks.size(); iPFO++) { - const xAOD::PFO* pfo = finalPi0PFOLinks.at(iPFO).cachedElement(); - int nPi0 = -1; - bool getOK = pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0); - if(getOK == false) ATH_MSG_DEBUG("problems reading pi0 attribute"); - ATH_MSG_DEBUG("pfo " << iPFO << " pt, eta, phi, m: " << pfo->pt() << ", " << pfo->eta() << ", " << pfo->phi() << ", " << pfo->m() << " isPi0: " << nPi0 << " , BDTscore: " << pfo->bdtPi0Score() ); - } - - ATH_MSG_DEBUG("Dumping neutral pfos for subalg"); - for(unsigned int iPFO=0; iPFO<neutralPFOLinks.size(); iPFO++) { - const xAOD::PFO* pfo = neutralPFOLinks.at(iPFO).cachedElement(); - int nPi0 = -1; - bool getOK = pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0); - if(getOK == false) ATH_MSG_DEBUG("problems reading pi0 attribute"); - ATH_MSG_DEBUG("pfo " << iPFO << " pt, eta, phi, m: " << pfo->pt() << ", " << pfo->eta() << ", " << pfo->phi() << ", " << pfo->m() << " isPi0: " << nPi0 << " , BDTscore: " << pfo->bdtPi0Score() ); - } - ATH_MSG_DEBUG("Dumping neutral pfos for pantau"); - for(unsigned int iPFO=0; iPFO<finalNeutralPFOLinks.size(); iPFO++) { - const xAOD::PFO* pfo = finalNeutralPFOLinks.at(iPFO).cachedElement(); - int nPi0 = -1; - bool getOK = pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0); - if(getOK == false) ATH_MSG_DEBUG("problems reading pi0 attribute"); - ATH_MSG_DEBUG("pfo " << iPFO << " pt, eta, phi, m: " << pfo->pt() << ", " << pfo->eta() << ", " << pfo->phi() << ", " << pfo->m() << " isPi0: " << nPi0 << " , BDTscore: " << pfo->bdtPi0Score() ); - } - //#endif //NDEBUG - - - - return; -} - - - -/* -std::vector< ElementLink< xAOD::PFOContainer > > PanTau::Tool_DetailsArranger::PreselectNeutralLinks(std::vector< ElementLink<xAOD::PFOContainer> > neutralPFOLinks, xAOD::TauJet* tauJet) { - - ATH_MSG_DEBUG("\tPreselectNeutralLinks called"); - // the neutral links are already ordered by BDT score - - std::vector< ElementLink< xAOD::PFOContainer > > preSelected_neutralPFOLinks; - - // unsigned int index1stBDTScoreNeutral = 9999; - // unsigned int index2ndBDTScoreNeutral = 9999; - // float BDTScore1st = -1111.; - // float BDTScore2nd = -1111.; - - for(unsigned int iNeutral=0; iNeutral<neutralPFOLinks.size(); iNeutral++) { - - const xAOD::PFO* curPi0PFO = neutralPFOLinks.at(iNeutral).cachedElement(); - - ATH_MSG_DEBUG("\tPreselectNeutralLinks: PFO Pt / Eta / Phi / m: " << curPi0PFO->pt() << " / " << curPi0PFO->eta() << " / " << curPi0PFO->phi() << " / " << curPi0PFO->m()); - - int nPi0sPerCluster = 0; - if( !curPi0PFO->attribute(xAOD::PFODetails::nPi0Proto, nPi0sPerCluster) ) { - ATH_MSG_WARNING("Could not retrieve nPi0Proto. Will set it to 0."); - nPi0sPerCluster = 0; - } - - //check whether this neutral is in the core region - ATH_MSG_DEBUG("\tPreselectNeutralLinks: tauJet->p4(xAOD::TauJetParameters::IntermediateAxis).DeltaR(curPi0PFO->p4()) (" << tauJet->p4(xAOD::TauJetParameters::IntermediateAxis).DeltaR(curPi0PFO->p4()) << ") > m_CoreCone (" << m_CoreCone << ")!"); - if(tauJet->p4(xAOD::TauJetParameters::IntermediateAxis).DeltaR(curPi0PFO->p4()) > m_CoreCone) { - //continue; - if(nPi0sPerCluster<1) continue; // hack (as long as dR cut doesn't work) to make sure pi0s pass - // TODO: Replace by shrinking cone? - } - - ATH_MSG_DEBUG("\tPreselectNeutralLinks: Passed DR cut!"); - - //check for et cut - double etCut = 99999999; - for(unsigned int iEtaBin=0; iEtaBin<m_EtaBinEdges.size()-1; iEtaBin++) { - double curEta = fabs(curPi0PFO->p4().Eta()); - double minEta = m_EtaBinEdges.at(iEtaBin); - double maxEta = m_EtaBinEdges.at(iEtaBin+1); - if(curEta >= minEta && curEta < maxEta) { - etCut = m_EtaBinnedEtCuts.at(iEtaBin); - break; - } - } - - ATH_MSG_DEBUG("\tPreselectNeutralLinks: curPi0PFO->p4().Et() (" << curPi0PFO->p4().Et() << ") < etCut (" << etCut << ")?"); - - if(curPi0PFO->p4().Et() < etCut) { - //continue; - if(nPi0sPerCluster<1) continue; // hack (as long as dR cut doesn't work) to make sure pi0s pass - } - - ATH_MSG_DEBUG("\tPreselectNeutralLinks: Passed!"); - - preSelected_neutralPFOLinks.push_back( neutralPFOLinks.at(iNeutral) ); - - - // float curBDTValue = curPi0PFO->bdtPi0Score(); - // ATH_MSG_DEBUG("\t\tneutral " << iNeutral << ", BDT score = " << curBDTValue); - - - // if(curBDTValue > BDTScore1st) { - // BDTScore2nd = BDTScore1st; - // index2ndBDTScoreNeutral = index1stBDTScoreNeutral; - // BDTScore1st = curBDTValue; - // index1stBDTScoreNeutral = iNeutral; - // } else if(curBDTValue > BDTScore2nd) { - // BDTScore2nd = curBDTValue; - // index2ndBDTScoreNeutral = iNeutral; - // } - // ATH_MSG_DEBUG("\t\t 1st highestBDT score at " << index1stBDTScoreNeutral); - // ATH_MSG_DEBUG("\t\t 2nd highestBDT score at " << index2ndBDTScoreNeutral); - - - }//end loop over neutrals - - // std::vector<unsigned int> indexList; - // if(nPi0ToSelects >= 1) indexList.push_back(index1stBDTScoreNeutral); - // if(nPi0ToSelects >= 2) indexList.push_back(index2ndBDTScoreNeutral); - - // ATH_MSG_DEBUG("\t1st highestBDT score at " << index1stBDTScoreNeutral); - // ATH_MSG_DEBUG("\t2nd highestBDT score at " << index2ndBDTScoreNeutral); - - // return indexList; - - return preSelected_neutralPFOLinks; - -} -*/ - - - -bool PanTau::Tool_DetailsArranger::HasMultPi0sInOneCluster(const xAOD::PFO* pfo, int decayModeProto, TString inputAlg){ - - // this is only relevant for reco 1p1n modes, hence restrict the - // output to these modes - - int nPi0sPerCluster = 1; - - if (inputAlg != "CellBased" ) return (nPi0sPerCluster > 1); - - // cell-based sets this to 1pXn however below this function is - // called with the decayModeProto as evaluated by Pantau! - if (decayModeProto != PanTau::PanTauSeed::Mode_1p1n ) return (nPi0sPerCluster > 1); - - if( !pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0sPerCluster) ) { - ATH_MSG_WARNING("Could not retrieve nPi0Proto. Will set it to 1."); - nPi0sPerCluster = 1; - } - - return (nPi0sPerCluster > 1); - -} - - - -void PanTau::Tool_DetailsArranger::SetNeutralConstituentMass(xAOD::PFO* neutral_pfo, double mass){ - - P4EEtaPhiM momentum = P4EEtaPhiM(neutral_pfo->e(), neutral_pfo->eta(), neutral_pfo->phi(), mass); - neutral_pfo->setP4(momentum.pt(), neutral_pfo->eta(), neutral_pfo->phi(), mass); - - // double new_P=sqrt( neutral_pfo->p4().E()*neutral_pfo->p4().E() - // + neutral_pfo->p4().M()*neutral_pfo->p4().M() - // - mass*mass ); - // TLorentzVector neutral_hlv; - // neutral_hlv.SetVectM( new_P*neutral_pfo->p4().Vect().Unit(), mass ); - - // neutral_pfo->setP4( neutral_hlv ); - - return; - -} - - -void PanTau::Tool_DetailsArranger::SetNeutralConstituentVectorMasses(std::vector< ElementLink<xAOD::PFOContainer> > neutralPFOLinks, double mass){ - - for(unsigned int iNeutral=0; iNeutral<neutralPFOLinks.size(); iNeutral++) { - ElementLink<xAOD::PFOContainer> curNeutralPFOLink = neutralPFOLinks.at(iNeutral); - xAOD::PFO* curNeutralPFO = const_cast<xAOD::PFO*>(curNeutralPFOLink.cachedElement()); - - SetNeutralConstituentMass(curNeutralPFO, mass); - - } - - return; - -} - - - -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. - - std::vector< ElementLink< xAOD::PFOContainer > > new_links; - - unsigned int nConstsOfType=0; - bool foundIt=false; - std::vector<PanTau::TauConstituent*> tauConstituents=inSeed->getConstituentsOfType(type,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; - } - - for(unsigned int iConst=0; iConst<tauConstituents.size(); iConst++) { - //bool isCoreNeut = tauConstituents[iConst]->isOfType(PanTau::TauConstituent::t_Neutral); - //bool isCorePi0 = tauConstituents[iConst]->isOfType(PanTau::TauConstituent::t_Pi0Neut); - bool isOfType = tauConstituents[iConst]->isOfType(type); - if(!isOfType) continue; - - // 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::TauConstituent::t_Neutral && tauConstituents[iConst]->isOfType(PanTau::TauConstituent::t_Pi0Neut) ) continue; - ++nConstsOfType; - - for(unsigned int iPFO=0; iPFO<cellbased_neutralPFOLinks.size(); iPFO++) { - const xAOD::PFO* pfo = cellbased_neutralPFOLinks.at(iPFO).cachedElement(); - - 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() << ")!"); - - ATH_MSG_DEBUG("Dumping neutral pfo links from all constituents of type " << type); - 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; - -} diff --git a/Reconstruction/PanTau/PanTauAlgs/src/Tool_FourMomentumCalculator.cxx b/Reconstruction/PanTau/PanTauAlgs/src/Tool_FourMomentumCalculator.cxx deleted file mode 100644 index fd4ddd11d6873488c8e11bb48f2d2ea0ee9de180..0000000000000000000000000000000000000000 --- a/Reconstruction/PanTau/PanTauAlgs/src/Tool_FourMomentumCalculator.cxx +++ /dev/null @@ -1,325 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -//! Gaudi includes -#include "AthenaKernel/errorcheck.h" -#include "StoreGate/StoreGateSvc.h" - -//! PanTau includes -#include "PanTauAlgs/Tool_FourMomentumCalculator.h" - -#include "PanTauEvent/PanTauSeed.h" - - -bool sortNeutralTauConstituentMVA(const PanTau::TauConstituent* u, const PanTau::TauConstituent* v) { - double uBDT = u->getBDTValue(); - double vBDT = v->getBDTValue(); - return uBDT > vBDT; -} - - -PanTau::Tool_FourMomentumCalculator::Tool_FourMomentumCalculator( - const std::string& ty, - const std::string& na, - const IInterface* pa ) : - AthAlgTool(ty,na,pa), - m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore") - { - declareInterface<ITool_FourMomentumCalculator>(this); - - declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Tool handle to the information store tool"); -} - - - -PanTau::Tool_FourMomentumCalculator::~Tool_FourMomentumCalculator() { -} - - - -StatusCode PanTau::Tool_FourMomentumCalculator::initialize() { - ATH_MSG_INFO( name() << " initialize()" ); - CHECK( AthAlgTool::initialize() ); - - CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Basic", m_varTypeName_Basic) ); - - return StatusCode::SUCCESS; -} - - - -StatusCode PanTau::Tool_FourMomentumCalculator::calculateFourMomentum(PanTau::PanTauSeed* inSeed) const { - - ATH_MSG_DEBUG("calculateFourMomentum called for inSeed at " << 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(isBadSeed == true) { - ATH_MSG_DEBUG("Seed is not valid for four momentum calculation!"); - return StatusCode::SUCCESS; - } - - ATH_MSG_DEBUG("Seed is valid for four momentum calculation!"); - - //get variables needed later on - std::string inputAlg = inSeed->getNameInputAlgorithm(); - - int mode_SubAlg = inSeed->getDecayModeBySubAlg(); - int mode_PanTau = inSeed->getDecayModeByPanTau(); - - bool isOK = false; - std::vector<PanTau::TauConstituent*> consts_Charged = inSeed->getConstituentsOfType(PanTau::TauConstituent::t_Charged, isOK); - if(isOK == false) return StatusCode::SUCCESS; - std::vector<PanTau::TauConstituent*> consts_Pi0Neut = inSeed->getConstituentsOfType(PanTau::TauConstituent::t_Pi0Neut, isOK); - if(isOK == false) return StatusCode::SUCCESS; - std::vector<PanTau::TauConstituent*> consts_Neutral = inSeed->getConstituentsOfType(PanTau::TauConstituent::t_Neutral, isOK); - if(isOK == false) return StatusCode::SUCCESS; - - //sort neutrals by pi0 BDT value - std::sort(consts_Pi0Neut.begin(), consts_Pi0Neut.end(), sortNeutralTauConstituentMVA); - std::sort(consts_Neutral.begin(), consts_Neutral.end(), sortNeutralTauConstituentMVA); - - unsigned int subAlg_NCharged = consts_Charged.size(); - unsigned int subAlg_NPi0Neut = consts_Pi0Neut.size(); - unsigned int subAlg_NNeutral = consts_Neutral.size(); - - - CLHEP::HepLorentzVector hlv_CoreObjects = CLHEP::HepLorentzVector(); - for(unsigned int iConst=0; iConst<subAlg_NCharged; iConst++) hlv_CoreObjects += consts_Charged.at(iConst)->hlv(); - for(unsigned int iConst=0; iConst<subAlg_NPi0Neut; iConst++) hlv_CoreObjects += consts_Pi0Neut.at(iConst)->hlv(); - - - - //!DEBUG output - #ifndef NDEBUG - ATH_MSG_DEBUG("Starting 4-momentum recalculation..."); - ATH_MSG_DEBUG("Original 4-vector: "); - ATH_MSG_DEBUG("\tEt : " << hlv_CoreObjects.et()); - ATH_MSG_DEBUG("\tEta: " << hlv_CoreObjects.eta()); - ATH_MSG_DEBUG("\tPhi: " << hlv_CoreObjects.phi()); - ATH_MSG_DEBUG("\tm : " << hlv_CoreObjects.m()); - - ATH_MSG_DEBUG("4-vectors of charged constituents:"); - for(unsigned int iConst=0; iConst<subAlg_NCharged; iConst++) { - CLHEP::HepLorentzVector cC = consts_Charged.at(iConst)->hlv(); - ATH_MSG_DEBUG("\tEt / Eta / Phi / M: " << cC.et() << " / " << cC.eta() << " / " << cC.phi() << " / " << cC.m()); - } - ATH_MSG_DEBUG("4-vectors of pi0 constituents:"); - for(unsigned int iConst=0; iConst<subAlg_NPi0Neut; iConst++) { - CLHEP::HepLorentzVector cC = consts_Pi0Neut.at(iConst)->hlv(); - ATH_MSG_DEBUG("\tEt / Eta / Phi / M: " << cC.et() << " / " << cC.eta() << " / " << cC.phi() << " / " << cC.m()); - } - ATH_MSG_DEBUG("4-vectors of neutral constituents:"); - for(unsigned int iConst=0; iConst<subAlg_NNeutral; iConst++) { - CLHEP::HepLorentzVector cC = consts_Neutral.at(iConst)->hlv(); - ATH_MSG_DEBUG("\tEt / Eta / Phi / M: " << cC.et() << " / " << cC.eta() << " / " << cC.phi() << " / " << cC.m()); - } - #endif //NDEBUG - - - /// /////////////////////////// - /// Get the 4 momentum correct - /// - /// - //the TLV to replace the default pantau one - CLHEP::HepLorentzVector hlv_PanTau_Final = CLHEP::HepLorentzVector(); - - - //prepare Vector of pi0-neutrals to be used: updated version! - // i.e. the list of pi0 neutrals to replace the default list from sub alg - std::vector<CLHEP::HepLorentzVector> consts_Pi0NeutralUpdate = std::vector<CLHEP::HepLorentzVector>(0); -// int nPi0AfterPanTau = subAlg_NPi0Neut; - - if(mode_PanTau == mode_SubAlg) { - ATH_MSG_DEBUG("SubAlg mode == pantau Mode (" << PanTau::PanTauSeed::getDecayModeName(mode_PanTau) << " => use constituents as mode suggests)"); - - if(inSeed->getModeHackedByCellBased() == true) { - ATH_MSG_DEBUG("deal with the case that mode was alterd by cell based shots"); - //1p1n moved to 1pXn by cell based, mode not altered by pantau, set 4 vector here - for(unsigned int iChrg=0; iChrg<subAlg_NCharged; iChrg++) hlv_PanTau_Final += consts_Charged.at(iChrg)->hlv(); - - CLHEP::HepLorentzVector hlv_SumPi0; - - if(subAlg_NPi0Neut > 0) { - CLHEP::HepLorentzVector hlv_1st_pi0Neut = consts_Pi0Neut.at(0)->hlv(); - CLHEP::HepLorentzVector hlv_Pi0NeutA = CLHEP::HepLorentzVector(hlv_1st_pi0Neut.px(), hlv_1st_pi0Neut.py(), hlv_1st_pi0Neut.pz(), 0); - hlv_PanTau_Final += hlv_Pi0NeutA; - hlv_SumPi0 += hlv_Pi0NeutA; - } - - if(subAlg_NPi0Neut > 1) { - CLHEP::HepLorentzVector hlv_2nd_pi0Neut = consts_Pi0Neut.at(1)->hlv(); - CLHEP::HepLorentzVector hlv_Pi0NeutB = CLHEP::HepLorentzVector(hlv_2nd_pi0Neut.px(), hlv_2nd_pi0Neut.py(), hlv_2nd_pi0Neut.pz(), 0); - hlv_PanTau_Final += hlv_Pi0NeutB; - hlv_SumPi0 += hlv_Pi0NeutB; - } else if(subAlg_NNeutral > 1) { - CLHEP::HepLorentzVector hlv_1st_Neutral = consts_Neutral.at(1)->hlv(); - CLHEP::HepLorentzVector hlv_NeutralA = CLHEP::HepLorentzVector(hlv_1st_Neutral.px(), hlv_1st_Neutral.py(), hlv_1st_Neutral.pz(), 0); - hlv_PanTau_Final += hlv_NeutralA; - hlv_SumPi0 += hlv_NeutralA; - } - consts_Pi0NeutralUpdate.push_back(hlv_SumPi0); -// nPi0AfterPanTau = 1; - - } else if(mode_PanTau != PanTau::PanTauSeed::Mode_3pXn) { - ATH_MSG_DEBUG("Non 3pXn mode"); - //Just use the same objects as CellBased if the mode was not altered (and is not 3pXn) - for(unsigned int iChrg=0; iChrg<subAlg_NCharged; iChrg++) hlv_PanTau_Final += consts_Charged.at(iChrg)->hlv(); - for(unsigned int iPi0=0; iPi0<subAlg_NPi0Neut; iPi0++) { - hlv_PanTau_Final += consts_Pi0Neut.at(iPi0)->hlv(); - consts_Pi0NeutralUpdate.push_back(consts_Pi0Neut.at(iPi0)->hlv()); - } - } else { - ATH_MSG_DEBUG("3pXn mode"); - //use 2 pi0 maximum - for(unsigned int iChrg=0; iChrg<subAlg_NCharged; iChrg++) hlv_PanTau_Final += consts_Charged.at(iChrg)->hlv(); - if(consts_Pi0Neut.size() > 0) { - hlv_PanTau_Final += consts_Pi0Neut.at(0)->hlv(); - consts_Pi0NeutralUpdate.push_back( consts_Pi0Neut.at(0)->hlv() ); - } - if(consts_Pi0Neut.size() > 1) { - hlv_PanTau_Final += consts_Pi0Neut.at(1)->hlv(); - consts_Pi0NeutralUpdate.push_back( consts_Pi0Neut.at(1)->hlv() ); - } - } - - - } - if(mode_PanTau != mode_SubAlg) { - ATH_MSG_DEBUG("SubAlg mode != pantau Mode => case dependent 4-mom calculation"); - - bool updatedMomentum = false; - - // 1p0n -> 1p1n - if(mode_SubAlg == PanTau::PanTauSeed::Mode_1p0n && mode_PanTau == PanTau::PanTauSeed::Mode_1p1n) { - ATH_MSG_DEBUG("\t1p0n -> 1p1n: Use tracks & highest pi0 score neutral"); - for(unsigned int iChrg=0; iChrg<subAlg_NCharged; iChrg++) hlv_PanTau_Final += consts_Charged.at(iChrg)->hlv(); - if(consts_Neutral.size() > 0) { - hlv_PanTau_Final += consts_Neutral.at(0)->hlv(); - consts_Pi0NeutralUpdate.push_back(consts_Neutral.at(0)->hlv()); - consts_Neutral.erase(consts_Neutral.begin()); - } -// nPi0AfterPanTau = 1; - updatedMomentum = true; - } - - // 1p1n -> 1p0n - if(mode_SubAlg == PanTau::PanTauSeed::Mode_1p1n && mode_PanTau == PanTau::PanTauSeed::Mode_1p0n) { - ATH_MSG_DEBUG("\t1p1n -> 1p0n: Use tracks only"); - for(unsigned int iChrg=0; iChrg<subAlg_NCharged; iChrg++) hlv_PanTau_Final += consts_Charged.at(iChrg)->hlv(); -// nPi0AfterPanTau = 0; - updatedMomentum = true; - } - - // 1p1n -> 1pXn - if(mode_SubAlg == PanTau::PanTauSeed::Mode_1p1n && mode_PanTau == PanTau::PanTauSeed::Mode_1pXn) { - ATH_MSG_DEBUG("\t1p1n -> 1pXn: Use tracks, the pi0 from sub alg and highest pi0 score neutral"); - for(unsigned int iChrg=0; iChrg<subAlg_NCharged; iChrg++) hlv_PanTau_Final += consts_Charged.at(iChrg)->hlv(); - - if(consts_Pi0Neut.size() > 0) { - hlv_PanTau_Final += consts_Pi0Neut.at(0)->hlv(); - consts_Pi0NeutralUpdate.push_back(consts_Pi0Neut.at(0)->hlv()); - } - - if(consts_Neutral.size() > 1) { - hlv_PanTau_Final += consts_Neutral.at(1)->hlv(); - consts_Pi0NeutralUpdate.push_back(consts_Neutral.at(1)->hlv()); - consts_Neutral.erase(consts_Neutral.begin()+1); - } -// nPi0AfterPanTau = 2; - updatedMomentum = true; - } - - // 1pXn -> 1p1n - if(mode_SubAlg == PanTau::PanTauSeed::Mode_1pXn && mode_PanTau == PanTau::PanTauSeed::Mode_1p1n) { - ATH_MSG_DEBUG("\t1pXn -> 1p1n: Use tracks & both pi0 from sub alg with mass 0"); - for(unsigned int iChrg=0; iChrg<subAlg_NCharged; iChrg++) hlv_PanTau_Final += consts_Charged.at(iChrg)->hlv(); - - P4EEtaPhiM hlv_Pi0NeutA; - if(consts_Pi0Neut.size() > 0) { - TauConstituent* curConst = consts_Pi0Neut.at(0); - double newEnergy = sqrt(curConst->e()*curConst->e() - curConst->m()*curConst->m()); - hlv_Pi0NeutA = P4EEtaPhiM(newEnergy, curConst->eta(), curConst->phi(), 0); - hlv_PanTau_Final += hlv_Pi0NeutA.hlv(); - } - - P4EEtaPhiM hlv_Pi0NeutB; - if(consts_Pi0Neut.size() > 1) { - TauConstituent* curConst = consts_Pi0Neut.at(1); - double newEnergy = sqrt(curConst->e()*curConst->e() - curConst->m()*curConst->m()); - hlv_Pi0NeutB = P4EEtaPhiM(newEnergy, curConst->eta(), curConst->phi(), 0); - hlv_PanTau_Final += hlv_Pi0NeutB.hlv(); - } - - consts_Pi0NeutralUpdate.push_back(hlv_Pi0NeutA.hlv() + hlv_Pi0NeutB.hlv()); - -// nPi0AfterPanTau = 1; - updatedMomentum = true; - } - - // 3p0n -> 3pXn - if(mode_SubAlg == PanTau::PanTauSeed::Mode_3p0n && mode_PanTau == PanTau::PanTauSeed::Mode_3pXn) { - ATH_MSG_DEBUG("\t3p0n -> 3pXn: Use tracks & best pi0 score neutral"); - for(unsigned int iChrg=0; iChrg<subAlg_NCharged; iChrg++) hlv_PanTau_Final += consts_Charged.at(iChrg)->hlv(); - - if(consts_Neutral.size() > 0) { - hlv_PanTau_Final += consts_Neutral.at(0)->hlv(); - consts_Pi0NeutralUpdate.push_back(consts_Neutral.at(0)->hlv()); - consts_Neutral.erase(consts_Neutral.begin()); - } -// nPi0AfterPanTau = 1; - updatedMomentum = true; - } - - // 3pXn -> 3p0n - if(mode_SubAlg == PanTau::PanTauSeed::Mode_3pXn && mode_PanTau == PanTau::PanTauSeed::Mode_3p0n) { - ATH_MSG_DEBUG("\t3pXn -> 3p0n: Use tracks only"); - for(unsigned int iChrg=0; iChrg<subAlg_NCharged; iChrg++) hlv_PanTau_Final += consts_Charged.at(iChrg)->hlv(); -// nPi0AfterPanTau = 0; - updatedMomentum = true; - } - - - if(updatedMomentum == false) { - ATH_MSG_WARNING("\tUnknown subAlgMode and PanTauMode combination: SubAlg -> PanTau: " << mode_SubAlg << " -> " << mode_PanTau); - ATH_MSG_WARNING("\tUse default 4-momentum and constituents"); - for(unsigned int iChrg=0; iChrg<subAlg_NCharged; iChrg++) hlv_PanTau_Final += consts_Charged.at(iChrg)->hlv(); - for(unsigned int iPi0=0; iPi0<subAlg_NPi0Neut; iPi0++) { - hlv_PanTau_Final += consts_Pi0Neut.at(iPi0)->hlv(); - consts_Pi0NeutralUpdate.push_back(consts_Pi0Neut.at(iPi0)->hlv()); - } - } - - - } //end if(PanTauMode != subAlgMode) - - //mode altered - ATH_MSG_DEBUG("Mode altered: " << mode_SubAlg << " -> " << mode_PanTau); - ATH_MSG_DEBUG("Pi0s altered: " << consts_Pi0Neut.size() << " -> " << consts_Pi0NeutralUpdate.size()); - - - ATH_MSG_DEBUG("Final 4-vector: "); - ATH_MSG_DEBUG("\tEt : " << hlv_PanTau_Final.et()); - ATH_MSG_DEBUG("\tEta: " << hlv_PanTau_Final.eta()); - ATH_MSG_DEBUG("\tPhi: " << hlv_PanTau_Final.phi()); - ATH_MSG_DEBUG("\tm : " << hlv_PanTau_Final.m()); - - inSeed->setFinalMomentum(hlv_PanTau_Final); - - PanTau::TauFeature* featureMap = inSeed->getFeatures(); - featureMap->addFeature(inputAlg + "_" + m_varTypeName_Basic + "_FinalMomentumCore_pt", hlv_PanTau_Final.perp() ); - featureMap->addFeature(inputAlg + "_" + m_varTypeName_Basic + "_FinalMomentumCore_eta", hlv_PanTau_Final.eta() ); - featureMap->addFeature(inputAlg + "_" + m_varTypeName_Basic + "_FinalMomentumCore_phi", hlv_PanTau_Final.phi() ); - featureMap->addFeature(inputAlg + "_" + m_varTypeName_Basic + "_FinalMomentumCore_m", hlv_PanTau_Final.m() ); - - - return StatusCode::SUCCESS; -} - - - diff --git a/Reconstruction/PanTau/PanTauAlgs/src/Tool_InputConverter.cxx b/Reconstruction/PanTau/PanTauAlgs/src/Tool_InputConverter.cxx deleted file mode 100644 index c4ada1ce2d8121401e3e2da083588eda69bfeca3..0000000000000000000000000000000000000000 --- a/Reconstruction/PanTau/PanTauAlgs/src/Tool_InputConverter.cxx +++ /dev/null @@ -1,314 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -//! Gaudi includes -#include "AthenaKernel/errorcheck.h" - -//! PanTau includes -#include "PanTauAlgs/Tool_InputConverter.h" -#include "PanTauAlgs/Tool_InformationStore.h" -#include "PanTauEvent/TauConstituent.h" - -//! input object headers -#include "eflowEvent/eflowObject.h" -#include "tauEvent/TauPi0Cluster.h" -#include "tauEvent/TauShot.h" -#include "tauEvent/TauJet.h" - -#include "Particle/TrackParticle.h" - -//! helpers -#include "FourMom/P4EEtaPhiM.h" - -//! xAOD EDM -#include "xAODTau/TauJet.h" -#include "xAODPFlow/PFO.h" -#include "xAODPFlow/PFODefs.h" - - -PanTau::Tool_InputConverter::Tool_InputConverter( - const std::string& ty, - const std::string& na, - const IInterface* pa ) : - AthAlgTool(ty,na,pa), - m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore"), - m_Tool_HelperFunctions("PanTau::Tool_InformationStore/Tool_HelperFunctions") -{ - declareInterface<ITool_InputConverter>(this); - - declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Link to tool with all information"); - declareProperty("Tool_HelperFunctions", m_Tool_HelperFunctions, "Link to tool with helper functions"); -} - -PanTau::Tool_InputConverter::~Tool_InputConverter() { -} - -StatusCode PanTau::Tool_InputConverter::initialize() { - - StatusCode sc = AlgTool::initialize(); - ATH_MSG_INFO(" initialize()"); - - CHECK( m_Tool_InformationStore.retrieve() ); - CHECK( m_Tool_HelperFunctions.retrieve() ); - - CHECK( m_Tool_InformationStore->getInfo_Int("TauConstituents_UsePionMass", m_Config_UsePionMass) ); - CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_eflowRec_BDTThreshold_Pi0Neut", m_Config_eflowRec_MinBDTValue_Pi0Neut) ); - CHECK( m_Tool_InformationStore->getInfo_Int("TauConstituents_eflowRec_UseMomentumAsEnergy", m_Config_eflowRec_UseMomentumAsEnergy) ); - CHECK( m_Tool_InformationStore->getInfo_Int("TauConstituents_UseShrinkingCone", m_Config_TauConstituents_UseShrinkingCone) ); - - - CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_Types_DeltaRCore", m_Config_TauConstituents_Types_DeltaRCore) ); - CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_PreselectionMinEnergy", m_Config_TauConstituents_PreselectionMinEnergy) ); - - - CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_BinEdges_Eta", m_Config_CellBased_BinEdges_Eta) ); - CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_EtaBinned_Pi0MVACut_1prong", m_Config_CellBased_EtaBinned_Pi0MVACut_1prong) ); - CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_EtaBinned_Pi0MVACut_3prong", m_Config_CellBased_EtaBinned_Pi0MVACut_3prong) ); - - CHECK( m_Tool_InformationStore->getInfo_VecDouble("eflowRec_BinEdges_Eta", m_Config_eflowRec_BinEdges_Eta) ); - CHECK( m_Tool_InformationStore->getInfo_VecDouble("eflowRec_EtaBinned_Pi0MVACut_1prong", m_Config_eflowRec_EtaBinned_Pi0MVACut_1prong) ); - CHECK( m_Tool_InformationStore->getInfo_VecDouble("eflowRec_EtaBinned_Pi0MVACut_3prong", m_Config_eflowRec_EtaBinned_Pi0MVACut_3prong) ); - CHECK( m_Tool_InformationStore->getInfo_VecDouble("eflowRec_Selection_Pi0Neut_EtaBinned_EtCut_1prong", m_Config_eflowRec_Selection_Pi0Neut_EtaBinned_EtCut_1prong) ); - CHECK( m_Tool_InformationStore->getInfo_VecDouble("eflowRec_Selection_Pi0Neut_EtaBinned_EtCut_3prong", m_Config_eflowRec_Selection_Pi0Neut_EtaBinned_EtCut_3prong) ); - - return sc; -} - - -// StatusCode PanTau::Tool_InformationStore::finalize() { -// StatusCode sc = AlgTool::finalize(); -// return sc; -// } - - -bool PanTau::Tool_InputConverter::passesPreselectionEnergy(double itsEnergy) const { - if(itsEnergy < m_Config_TauConstituents_PreselectionMinEnergy) return false; - return true; -} - - - -//! ============================================ -//! PFO converter -//! ============================================ - - -StatusCode PanTau::Tool_InputConverter::ConvertToTauConstituent(xAOD::PFO* pfo, - PanTau::TauConstituent* &tauConstituent, - const xAOD::TauJet* tauJet, - std::string algName) const { - // - - //! ================================================== - //! check for invalid eta, phi, e 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->charge() == 0 && pfo->m() != 0) { - P4EEtaPhiM hlvUpdate = P4EEtaPhiM(pfo->e(), pfo->eta(), pfo->phi(), 0); - pfo->setP4(hlvUpdate.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; - } - - - //! ================================================== - //! 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(pfoCharge == 0) { - constituentMass = 134.98; - } - //tracks: change energy and set pion mass, so measured momentum is not changed - if(pfoCharge != 0) { - constituentMass = 139.57; - constituentEnergy = sqrt(constituentEnergy * constituentEnergy + constituentMass*constituentMass); - } - } - - ATH_MSG_DEBUG("About to create 4 vector of EFO. E / Eta / Phi / m: " << constituentEnergy << " / " << pfo->eta() << " / " << pfo->phi() << " / " << constituentMass); - P4EEtaPhiM momentum = P4EEtaPhiM(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::TauConstituent::t_nTypes, 0); - itsTypeFlags[(int)PanTau::TauConstituent::t_NoType] = 1; - - double mvaValue = PanTau::TauConstituent::DefaultBDTValue(); - - TLorentzVector hlv_intAxis = tauJet->p4(xAOD::TauJetParameters::IntermediateAxis); - double deltaR_toTauJet = hlv_intAxis.DeltaR( pfo->p4() ); - - if(deltaR_toTauJet > m_Config_TauConstituents_Types_DeltaRCore) { - if(pfoCharge != 0) { - itsTypeFlags[(int)PanTau::TauConstituent::t_OutChrg] = 1; - } - if(pfoCharge == 0) { - itsTypeFlags[(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(pfoCharge != 0) { - itsTypeFlags[(int)PanTau::TauConstituent::t_Charged] = 1; - } - if(pfoCharge == 0) { - itsTypeFlags[(int)PanTau::TauConstituent::t_Neutral] = 1; - itsTypeFlags[(int)PanTau::TauConstituent::t_NeutLowA] = 1; - itsTypeFlags[(int)PanTau::TauConstituent::t_NeutLowB] = 1; - - //neutral PFO arranging --- check for pi0 tag - mvaValue = pfo->bdtPi0Score(); - - bool isThreeProng = false; - if(tauJet->nTracks() == 3) isThreeProng = true; -// ATH_MSG_DEBUG("numTrack = " << tauJet->nTracks() << ", is Threeprong = " << isThreeProng); - -/* -// original code by Christian; allows to configure the BDT cuts in a -// config file - might give more flexibility than the cell-based code -// below! - - int etaBinIndex = -1; - if(algName == "CellBased") etaBinIndex = m_Tool_HelperFunctions->getBinIndex(m_Config_CellBased_BinEdges_Eta, fabs(pfo->eta()) ); - if(algName == "eflowRec") etaBinIndex = m_Tool_HelperFunctions->getBinIndex(m_Config_eflowRec_BinEdges_Eta, fabs(pfo->eta()) ); - - if(isThreeProng == false) { - double minMVAValue = -5; - if(algName == "CellBased") minMVAValue = m_Config_CellBased_EtaBinned_Pi0MVACut_1prong.at(etaBinIndex); - if(algName == "eflowRec") minMVAValue = m_Config_eflowRec_EtaBinned_Pi0MVACut_1prong.at(etaBinIndex); - if(mvaValue > minMVAValue) itsTypeFlags[(int)PanTau::TauConstituent::t_Pi0Neut] = 1; - } - - if(isThreeProng == true) { - double minMVAValue = -5; - if(algName == "CellBased") minMVAValue = m_Config_CellBased_EtaBinned_Pi0MVACut_3prong.at(etaBinIndex); - if(algName == "eflowRec") minMVAValue = m_Config_eflowRec_EtaBinned_Pi0MVACut_3prong.at(etaBinIndex); - if(mvaValue > minMVAValue) itsTypeFlags[(int)PanTau::TauConstituent::t_Pi0Neut] = 1; - } - -// end: original code -*/ - - if(algName == "CellBased"){ - - 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[(int)PanTau::TauConstituent::t_Pi0Neut] = 1; - - } - - if(algName == "eflowRec"){ - - int etaBinIndex = -1; - etaBinIndex = m_Tool_HelperFunctions->getBinIndex(m_Config_eflowRec_BinEdges_Eta, fabs(pfo->eta()) ); - - if(isThreeProng == false) { - double minMVAValue = -5; - minMVAValue = m_Config_eflowRec_EtaBinned_Pi0MVACut_1prong.at(etaBinIndex); - if(mvaValue > minMVAValue) itsTypeFlags[(int)PanTau::TauConstituent::t_Pi0Neut] = 1; - } - - if(isThreeProng == true) { - double minMVAValue = -5; - if(algName == "eflowRec") minMVAValue = m_Config_eflowRec_EtaBinned_Pi0MVACut_3prong.at(etaBinIndex); - if(mvaValue > minMVAValue) itsTypeFlags[(int)PanTau::TauConstituent::t_Pi0Neut] = 1; - } - - } - - } - }//end if pfo is in core - - - //! ================================================== - //! create the tau constituent - tauConstituent = new PanTau::TauConstituent(momentum, pfoCharge, itsTypeFlags, mvaValue, pfo); - ATH_MSG_DEBUG("Created new TauConstituent at: " << tauConstituent); - ATH_MSG_DEBUG("\t Eta value of its 4-vector: " << momentum.eta()); - - - //! ================================================== - //! 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"); - } - - ATH_MSG_DEBUG("Number of shots in cluster:" << list_TauShots.size()); - if(list_TauShots.size() > 0) { - ATH_MSG_DEBUG("Now converting shots of cluster with E, Eta, Phi, M: " << momentum.e() << ", " << momentum.eta() << ", " << momentum.phi() << ", " << momentum.m()); - for(unsigned int iShot=0; iShot<list_TauShots.size(); iShot++) { - - if(list_TauShots[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[iShot]) ); - ATH_MSG_DEBUG("Checking shot E, Eta, Phi, M: " << curShot->e() << ", " << curShot->eta() << ", " << curShot->phi() << ", " << curShot->m()); - P4EEtaPhiM shotMomentum = P4EEtaPhiM(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); - ATH_MSG_DEBUG("\tAdded shot with E, Eta, Phi, M: " << shotMomentum.e() << ", " << shotMomentum.eta() << ", " << shotMomentum.phi() << ", " << shotMomentum.m()); - - 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); - ATH_MSG_DEBUG("\tThe shot has " << shotConstituent->getNPhotonsInShot() << " photons in it"); - tauConstituent->addShot(shotConstituent); - - }//end loop over shots - } - - return StatusCode::SUCCESS; -} - - - - - - - - - - - - diff --git a/Reconstruction/PanTau/PanTauAlgs/src/Tool_TauConstituentGetter.cxx b/Reconstruction/PanTau/PanTauAlgs/src/Tool_TauConstituentGetter.cxx deleted file mode 100644 index bdd773d03c99360fd5bfec02f91a521a847422d2..0000000000000000000000000000000000000000 --- a/Reconstruction/PanTau/PanTauAlgs/src/Tool_TauConstituentGetter.cxx +++ /dev/null @@ -1,225 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -//! Gaudi includes -#include "AthenaKernel/errorcheck.h" - -//! PanTau includes -#include "PanTauAlgs/Tool_TauConstituentGetter.h" - -#include "PanTauEvent/TauConstituent.h" -#include "PanTauAlgs/Tool_InformationStore.h" -#include "PanTauAlgs/Tool_InputConverter.h" -#include "PanTauAlgs/Tool_HelperFunctions.h" -#include "TVector3.h" - - - -#include "tauEvent/TauJet.h" -#include "tauEvent/TauCommonDetails.h" -#include "tauEvent/TauPi0Details.h" -#include "tauEvent/TauPi0Cluster.h" - -#include "eflowEvent/eflowObjectContainer.h" -#include "eflowEvent/eflowObject.h" - -#include "Particle/TrackParticle.h" -#include "VxVertex/RecVertex.h" -//#include "TrkEventPrimitives/GlobalPosition.h" -#include "GeoPrimitives/GeoPrimitives.h" -#include "CLHEP/Geometry/Vector3D.h" -#include "CaloEvent/CaloCluster.h" - -#include "CLHEP/Vector/LorentzVector.h" -#include "FourMomUtils/P4Helpers.h" - -//! xAOD EDM -#include "xAODTau/TauJet.h" -#include "xAODPFlow/PFO.h" -#include "xAODTracking/Vertex.h" - - - -PanTau::Tool_TauConstituentGetter::Tool_TauConstituentGetter( - const std::string& ty, - const std::string& na, - const IInterface* pa ) : - AthAlgTool(ty,na,pa), - m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore"), - m_Tool_HelperFunctions("PanTau::Tool_HelperFunctions/Tool_HelperFunctions"), - m_Tool_InputConverter("PanTau::Tool_InputConverter/Tool_InputConverter") -{ - declareInterface<ITool_TauConstituentGetter>(this); - - declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Link to tool with all information"); - declareProperty("Tool_HelperFunctions", m_Tool_HelperFunctions, "Link to tool with all information"); - declareProperty("Tool_InputConverter", m_Tool_InputConverter, "Link to tool to convert into TauConstituents"); -} - -PanTau::Tool_TauConstituentGetter::~Tool_TauConstituentGetter() { -} - -StatusCode PanTau::Tool_TauConstituentGetter::initialize() { - - StatusCode sc = AlgTool::initialize(); - ATH_MSG_INFO(" initialize()"); - - CHECK( m_Tool_InformationStore.retrieve() ); - CHECK( m_Tool_HelperFunctions.retrieve() ); - CHECK( m_Tool_InputConverter.retrieve() ); - - //FIXME: this value will depend on what the shrinking cone algorithm found out. - //NOTE: Need to make sure the collection Delta R is available in the tauObject - CHECK (m_Tool_InformationStore->getInfo_Double("eflowRec_Assoc_DeltaR", m_eflowRec_Assoc_DeltaR) ); - - return sc; -} - - -// StatusCode PanTau::Tool_InformationStore::finalize() { -// StatusCode sc = AlgTool::finalize(); -// return sc; -// } - - - -/** -* Function to get the tau constituents for a given TauJet object and a given algorithm that got the substructure -* -*/ -StatusCode PanTau::Tool_TauConstituentGetter::GetTauConstituents(//const Analysis::TauJet* tauJet, - const xAOD::TauJet* tauJet, - std::vector<TauConstituent*>& outputConstituents, - std::string algName) const { - // - ATH_MSG_DEBUG("GetTauConstituents..."); - - int enableXAODHacks = 0; - CHECK (m_Tool_InformationStore->getInfo_Int("EnableXAODMigrationHacks", enableXAODHacks) ); - - bool inputAlgIsValid = false; - if(algName == "eflowRec") inputAlgIsValid = true; - if(algName == "CellBased") inputAlgIsValid = true; - if(inputAlgIsValid == false) { - ATH_MSG_WARNING("Unknown input algorithm: " << algName << " -> not getting constituents for this tau"); - return StatusCode::SUCCESS; - } - - //loop over chared PFOs - ATH_MSG_DEBUG("Get charged ones..."); - unsigned int nChargedPFO = 0; - if(algName == "eflowRec") nChargedPFO = tauJet->nProtoChargedPFOs(); - if(algName == "CellBased") nChargedPFO = tauJet->nProtoChargedPFOs(); - ATH_MSG_DEBUG("Charged PFOs: " << nChargedPFO); - - for(unsigned int iChrgPFO=0; iChrgPFO<nChargedPFO; iChrgPFO++) { - xAOD::PFO* curChrgPFO = 0; - if(algName == "eflowRec") curChrgPFO = const_cast<xAOD::PFO*>(tauJet->protoChargedPFO( iChrgPFO )); - if(algName == "CellBased") curChrgPFO = const_cast<xAOD::PFO*>(tauJet->protoChargedPFO( iChrgPFO )); - - if(enableXAODHacks == 1) { - ATH_MSG_DEBUG("EnableXAODMigrationHacks is true -> call vertex correctio for charged PFOs to check whether it runs & does something"); - m_Tool_HelperFunctions->vertexCorrection_PFOs(tauJet, curChrgPFO); - } - - //convert to tau constituent - PanTau::TauConstituent* curConst = 0; - CHECK(m_Tool_InputConverter->ConvertToTauConstituent(curChrgPFO, curConst, tauJet, algName) ); - if(curConst == 0) { - ATH_MSG_DEBUG("Problems converting charged PFO into tau constituent -> skip PFO"); - continue; - } - - //add to list of tau constituents - ATH_MSG_DEBUG("\tDumping contents of constituent at " << curConst); - m_Tool_HelperFunctions->dumpTauConstituent(curConst); - outputConstituents.push_back(curConst); - - }//end loop over charged PFOs - - - //loop over pi0 tagged PFOs - - if(enableXAODHacks == 1) { - ATH_MSG_DEBUG("Stopping constituent selection here, because EnableXAODMigrationHacks is set to true"); - return StatusCode::SUCCESS; - } - -// ATH_MSG_DEBUG("Get pi0 ones..."); - unsigned int nPi0PFO = 0; - if(algName == "eflowRec") nPi0PFO = tauJet->nProtoPi0PFOs(); - if(algName == "CellBased") nPi0PFO = tauJet->nProtoPi0PFOs(); - ATH_MSG_DEBUG("Pi0 tagged PFOs in neutral PFOs: " << nPi0PFO); -// -// for(unsigned int iPi0PFO=0; iPi0PFO<nPi0PFO; iPi0PFO++) { -// xAOD::PFO* curPi0PFO = 0; -// if(algName == "eflowRec") curPi0PFO = const_cast<xAOD::PFO*>(tauJet->protopi0PFO( iPi0PFO )); -// if(algName == "CellBased") curPi0PFO = const_cast<xAOD::PFO*>(tauJet->protopi0PFO( iPi0PFO )); -// -// // Call vertex correction here -// m_Tool_HelperFunctions->vertexCorrection_PFOs(tauJet, curPi0PFO); -// -// //convert to tau constituent -// PanTau::TauConstituent* curConst = 0; -// CHECK( m_Tool_InputConverter->ConvertToTauConstituent(curPi0PFO, curConst, tauJet, algName) ); -// if(curConst == 0) { -// ATH_MSG_DEBUG("Problems converting pi0 PFO into tau constituent -> skip PFO"); -// continue; -// } -// -// //add to list of tau constituents -// ATH_MSG_DEBUG("\tDumping contents of constituent at " << curConst); -// m_Tool_HelperFunctions->dumpTauConstituent(curConst); -// outputConstituents.push_back(curConst); -// -// }//end loop over charged PFOs - - - //loop over neutral PFOs - ATH_MSG_DEBUG("Get neutral ones..."); - unsigned int nNeutPFO = 0; - if(algName == "eflowRec") nNeutPFO = tauJet->nProtoNeutralPFOs(); - if(algName == "CellBased") nNeutPFO = tauJet->nProtoNeutralPFOs(); - ATH_MSG_DEBUG("Neutral PFOs: " << nNeutPFO); - - for(unsigned int iNeutPFO=0; iNeutPFO<nNeutPFO; iNeutPFO++) { - xAOD::PFO* curNeutPFO = 0; - if(algName == "eflowRec") curNeutPFO = const_cast<xAOD::PFO*>(tauJet->protoNeutralPFO( iNeutPFO )); - if(algName == "CellBased") curNeutPFO = const_cast<xAOD::PFO*>(tauJet->protoNeutralPFO( iNeutPFO )); - - // Call vertex correction here - m_Tool_HelperFunctions->vertexCorrection_PFOs(tauJet, curNeutPFO); - - //convert to tau constituent - PanTau::TauConstituent* curConst = 0; - CHECK( m_Tool_InputConverter->ConvertToTauConstituent(curNeutPFO, curConst, tauJet, algName) ); - if(curConst == 0) { - ATH_MSG_DEBUG("Problems converting neutral PFO into tau constituent -> skip PFO"); - continue; - } - - //add to list of tau constituents - ATH_MSG_DEBUG("\tDumping contents of constituent at " << curConst); - m_Tool_HelperFunctions->dumpTauConstituent(curConst); - outputConstituents.push_back(curConst); - - }//end loop over charged PFOs - - - return StatusCode::SUCCESS; - -}//end PFO getter - - - - - - - - - - - - diff --git a/Reconstruction/PanTau/PanTauAlgs/src/components/PanTauAlgs_entries.cxx b/Reconstruction/PanTau/PanTauAlgs/src/components/PanTauAlgs_entries.cxx index 016fb8304f82f00c8bbff98e3182f6ee49d6039b..af5630fa4e36c1b5e659a4b009c122efef185df1 100644 --- a/Reconstruction/PanTau/PanTauAlgs/src/components/PanTauAlgs_entries.cxx +++ b/Reconstruction/PanTau/PanTauAlgs/src/components/PanTauAlgs_entries.cxx @@ -1,44 +1,41 @@ #include "GaudiKernel/DeclareFactoryEntries.h" #include "PanTauAlgs/Tool_InformationStore.h" -#include "PanTauAlgs/Tool_HelperFunctions.h" #include "PanTauAlgs/Tool_InputConverter.h" #include "PanTauAlgs/Tool_TauConstituentGetter.h" #include "PanTauAlgs/Tool_TauConstituentSelector.h" #include "PanTauAlgs/Tool_FeatureExtractor.h" #include "PanTauAlgs/Tool_ModeDiscriminator.h" #include "PanTauAlgs/Tool_DecayModeDeterminator.h" -#include "PanTauAlgs/Tool_FourMomentumCalculator.h" #include "PanTauAlgs/Tool_DetailsArranger.h" -#include "PanTauAlgs/Alg_SeedBuilder.h" +#include "PanTauAlgs/PanTauProcessor.h" DECLARE_NAMESPACE_TOOL_FACTORY( PanTau, Tool_InformationStore ) -DECLARE_NAMESPACE_TOOL_FACTORY( PanTau, Tool_HelperFunctions ) DECLARE_NAMESPACE_TOOL_FACTORY( PanTau, Tool_InputConverter ) DECLARE_NAMESPACE_TOOL_FACTORY( PanTau, Tool_TauConstituentGetter ) DECLARE_NAMESPACE_TOOL_FACTORY( PanTau, Tool_TauConstituentSelector ) DECLARE_NAMESPACE_TOOL_FACTORY( PanTau, Tool_FeatureExtractor ) DECLARE_NAMESPACE_TOOL_FACTORY( PanTau, Tool_ModeDiscriminator ) DECLARE_NAMESPACE_TOOL_FACTORY( PanTau, Tool_DecayModeDeterminator ) -DECLARE_NAMESPACE_TOOL_FACTORY( PanTau, Tool_FourMomentumCalculator ) DECLARE_NAMESPACE_TOOL_FACTORY( PanTau, Tool_DetailsArranger ) -DECLARE_NAMESPACE_ALGORITHM_FACTORY( PanTau, Alg_SeedBuilder ) + +DECLARE_NAMESPACE_TOOL_FACTORY( PanTau, PanTauProcessor ) +//DECLARE_NAMESPACE_ALGORITHM_FACTORY( PanTau, PanTauProcessor ) DECLARE_FACTORY_ENTRIES( PanTauAlgs ) { DECLARE_NAMESPACE_TOOL( PanTau, Tool_InformationStore ) -DECLARE_NAMESPACE_TOOL( PanTau, Tool_HelperFunctions ) DECLARE_NAMESPACE_TOOL( PanTau, Tool_InputConverter ) DECLARE_NAMESPACE_TOOL( PanTau, Tool_TauConstituentGetter ) DECLARE_NAMESPACE_TOOL( PanTau, Tool_TauConstituentSelector ) DECLARE_NAMESPACE_TOOL( PanTau, Tool_FeatureExtractor ) DECLARE_NAMESPACE_TOOL( PanTau, Tool_ModeDiscriminator ) DECLARE_NAMESPACE_TOOL( PanTau, Tool_DecayModeDeterminator ) -DECLARE_NAMESPACE_TOOL( PanTau, Tool_FourMomentumCalculator ) DECLARE_NAMESPACE_TOOL( PanTau, Tool_DetailsArranger ) -DECLARE_NAMESPACE_ALGORITHM( PanTau , Alg_SeedBuilder ) +//DECLARE_NAMESPACE_ALGORITHM( PanTau , PanTauProcessor ) +DECLARE_NAMESPACE_TOOL( PanTau, PanTauProcessor ) }