diff --git a/Reconstruction/tauRec/python/TauAlgorithmsHolder.py b/Reconstruction/tauRec/python/TauAlgorithmsHolder.py index 36736c809530963090d7a551011356ff68d438c2..0813b0abb0204113bb691ab6954d13e8f618347c 100644 --- a/Reconstruction/tauRec/python/TauAlgorithmsHolder.py +++ b/Reconstruction/tauRec/python/TauAlgorithmsHolder.py @@ -74,19 +74,10 @@ def getTauAxis(): if _name in cached_instances: return cached_instances[_name] - from JetRec.JetRecFlags import jetFlags - - doJetVertexCorrection = False - if tauFlags.isStandalone: - doJetVertexCorrection = True - if jetFlags.useVertices() and jetFlags.useTracks(): - doJetVertexCorrection = True - from tauRecTools.tauRecToolsConf import TauAxisSetter TauAxisSetter = TauAxisSetter( name = _name, ClusterCone = 0.2, - VertexCorrection = True, - JetVertexCorrection = doJetVertexCorrection) + VertexCorrection = True ) cached_instances[_name] = TauAxisSetter return TauAxisSetter @@ -1035,23 +1026,15 @@ def getTauVertexCorrection(): def getTauVertexedClusterDecorator(): from tauRec.tauRecFlags import tauFlags from tauRecTools.tauRecToolsConf import TauVertexedClusterDecorator - from JetRec.JetRecFlags import jetFlags _name = sPrefix + 'TauVertexedClusterDecorator' if _name in cached_instances: return cached_instances[_name] - doJetVertexCorrection = False - if tauFlags.isStandalone: - doJetVertexCorrection = True - if jetFlags.useVertices() and jetFlags.useTracks(): - doJetVertexCorrection = True - myTauVertexedClusterDecorator = TauVertexedClusterDecorator(name = _name, SeedJet = tauFlags.tauRecSeedJetCollection(), - VertexCorrection = True, - JetVertexCorrection = doJetVertexCorrection) + VertexCorrection = True) cached_instances[_name] = myTauVertexedClusterDecorator return myTauVertexedClusterDecorator diff --git a/Reconstruction/tauRecTools/Root/HelperFunctions.cxx b/Reconstruction/tauRecTools/Root/HelperFunctions.cxx index ceba5edcb3c923781b94c7df27892fd940a88adf..980c6aad09f6cf74ca4cdf15da65288465e04201 100644 --- a/Reconstruction/tauRecTools/Root/HelperFunctions.cxx +++ b/Reconstruction/tauRecTools/Root/HelperFunctions.cxx @@ -17,9 +17,43 @@ namespace tauRecTools { +const xAOD::Vertex* tauRecTools::getJetVertex(const xAOD::Jet& jet) { + const xAOD::Vertex* jetVertex = nullptr; + + bool isAvailable = jet.getAssociatedObject("OriginVertex", jetVertex); + if (! isAvailable) { + return nullptr; + } + + return jetVertex; +} + + + +const xAOD::Vertex* tauRecTools::getTauVertex(const xAOD::TauJet& tau, bool inTrigger) { + using namespace tauRecTools::msgHelperFunction; + + const xAOD::Vertex* tauVertex = nullptr; + if (tau.vertexLink().isValid()) { + tauVertex = tau.vertex(); + } + else if (! inTrigger) { + if (! tau.jetLink().isValid()) { + ANA_MSG_WARNING("Link to seed jet is not valid !"); + return nullptr; + } + const xAOD::Jet* seedJet = tau.jet(); + tauVertex = tauRecTools::getJetVertex(*seedJet); + } + + return tauVertex; +} + + + TLorentzVector tauRecTools::getTauAxis(const xAOD::TauJet& tau, bool doVertexCorrection) { TLorentzVector tauAxis; - if (doVertexCorrection && tau.vertexLink().isValid()) { + if (doVertexCorrection) { tauAxis = tau.p4(xAOD::TauJetParameters::IntermediateAxis); } else { @@ -29,7 +63,6 @@ TLorentzVector tauRecTools::getTauAxis(const xAOD::TauJet& tau, bool doVertexCor return tauAxis; } - //________________________________________________________________________________ xAOD::TauTrack::TrackFlagType tauRecTools::isolateClassifiedBits(xAOD::TauTrack::TrackFlagType flag){ const int flagsize=sizeof(flag)*8; diff --git a/Reconstruction/tauRecTools/Root/TauVertexedClusterDecorator.cxx b/Reconstruction/tauRecTools/Root/TauVertexedClusterDecorator.cxx index b3357e50c7177c6d1d97e7005b818bdb4fc8821b..08b004206d6d6009123a2934fe1a92940832d4e5 100644 --- a/Reconstruction/tauRecTools/Root/TauVertexedClusterDecorator.cxx +++ b/Reconstruction/tauRecTools/Root/TauVertexedClusterDecorator.cxx @@ -3,6 +3,7 @@ */ #include "tauRecTools/TauVertexedClusterDecorator.h" +#include "tauRecTools/HelperFunctions.h" #include "xAODCaloEvent/CaloVertexedTopoCluster.h" @@ -10,7 +11,6 @@ TauVertexedClusterDecorator::TauVertexedClusterDecorator(const std::string& name TauRecToolBase(name) { declareProperty("SeedJet", m_seedJet = ""); declareProperty("VertexCorrection", m_doVertexCorrection = true); - declareProperty("JetVertexCorrection", m_doJetVertexCorrection = true); } @@ -35,23 +35,6 @@ StatusCode TauVertexedClusterDecorator::initialize() { -const xAOD::Vertex* TauVertexedClusterDecorator::getJetVertex(const xAOD::Jet& jet) const { - - const xAOD::Vertex* jetVertex = nullptr; - - if (m_doJetVertexCorrection && !inTrigger()) { - bool isAvailable = jet.getAssociatedObject("OriginVertex", jetVertex); - if (!isAvailable) { - ATH_MSG_WARNING("OriginVertex not available !"); - jetVertex = nullptr; - } - } - - return jetVertex; -} - - - StatusCode TauVertexedClusterDecorator::execute(xAOD::TauJet& tau) const { if (! tau.jetLink().isValid()) { ATH_MSG_WARNING("Link to the seed jet is invalid"); @@ -59,31 +42,29 @@ StatusCode TauVertexedClusterDecorator::execute(xAOD::TauJet& tau) const { } // Obtain the vertex to correct the cluster - const xAOD::Vertex* vertex = nullptr; - if (m_doVertexCorrection) { - if (tau.vertexLink().isValid()) { - vertex = tau.vertex(); - } - } - else { - const xAOD::Jet* jetSeed = tau.jet(); - vertex = getJetVertex(*jetSeed); - } + const xAOD::Vertex* vertex = tauRecTools::getTauVertex(tau, inTrigger()); std::vector<const xAOD::IParticle*> particleList = tau.clusters(); std::vector<xAOD::CaloVertexedTopoCluster> vertexedClusterList; for (const xAOD::IParticle* particle : particleList) { const xAOD::CaloCluster* cluster = static_cast<const xAOD::CaloCluster*>(particle); - - if (vertex) { - vertexedClusterList.emplace_back(*cluster, m_clusterState, vertex->position()); - } - else if (!inTrigger()) { - vertexedClusterList.emplace_back(*cluster, m_clusterState); + + if (inTrigger()) { // In trigger, we use the default calibration state + if (vertex) { + vertexedClusterList.emplace_back(*cluster, vertex->position()); + } + else { + vertexedClusterList.emplace_back(*cluster); + } } - else { - vertexedClusterList.emplace_back(*cluster); + else { // In offline reconstruction, the calibration state is based on the name of seed jet + if (vertex) { + vertexedClusterList.emplace_back(*cluster, m_clusterState, vertex->position()); + } + else { + vertexedClusterList.emplace_back(*cluster, m_clusterState); + } } } diff --git a/Reconstruction/tauRecTools/src/TauAxisSetter.cxx b/Reconstruction/tauRecTools/src/TauAxisSetter.cxx index 04260136c458c00ce963ceff4713276106f67199..c1f321116dedf5f0071a4daa221d3850ad96a20d 100644 --- a/Reconstruction/tauRecTools/src/TauAxisSetter.cxx +++ b/Reconstruction/tauRecTools/src/TauAxisSetter.cxx @@ -66,10 +66,13 @@ StatusCode TauAxisSetter::execute(xAOD::TauJet& tau) const { // Tau intermediate axis (corrected for tau vertex) TLorentzVector tauInterAxis; - const xAOD::Vertex* jetVertex = getJetVertex(*jetSeed); - - const xAOD::Vertex* tauVertex = nullptr; - if (tau.vertexLink().isValid()) tauVertex = tau.vertex(); + // In trigger, jet candidate do not have a vertex + const xAOD::Vertex* jetVertex = nullptr; + if (!inTrigger()) { + jetVertex = tauRecTools::getJetVertex(*jetSeed); + } + + const xAOD::Vertex* tauVertex = tauRecTools::getTauVertex(tau, inTrigger()); // Redo the vertex correction when tau vertex is different from jet vertex if (jetVertex != tauVertex) { @@ -120,23 +123,6 @@ StatusCode TauAxisSetter::execute(xAOD::TauJet& tau) const { -const xAOD::Vertex* TauAxisSetter::getJetVertex(const xAOD::Jet& jet) const { - - const xAOD::Vertex* jetVertex = nullptr; - - if (m_doJetVertexCorrection && !inTrigger()) { - bool isAvailable = jet.getAssociatedObject("OriginVertex", jetVertex); - if (!isAvailable) { - ATH_MSG_WARNING("OriginVertex not available !"); - jetVertex = nullptr; - } - } - - return jetVertex; -} - - - TLorentzVector TauAxisSetter::getVertexCorrectedP4(const xAOD::JetConstituent& constituent, const Amg::Vector3D& position) const { TLorentzVector vertexCorrectedP4; @@ -170,15 +156,9 @@ TLorentzVector TauAxisSetter::getVertexCorrectedP4(const xAOD::PFO& pfo, // If there is a vertex correction in jet reconstruction, then pfo.p4() is the four momentum // at EM scale. Otherwise, pfo.p4() is at LC scale (not clear), and pfo.p4EM() is the four - // momentum at EM scale. - // TODO: May need further modifications, depending on how the jet reconstruction fix ATLJETMET-1280 - // The strategy only works for PFlow at EM scale. - if (m_doJetVertexCorrection && !inTrigger()) { - vertexCorrectedP4 = pfo.GetVertexCorrectedFourVec(pos); - } - else { - vertexCorrectedP4 = pfo.GetVertexCorrectedEMFourVec(pos); - } + // momentum at EM scale. Here, we assume jet always perform the vertex correction in offline + // reconstruction. + vertexCorrectedP4 = pfo.GetVertexCorrectedFourVec(pos); } else { vertexCorrectedP4 = pfo.p4(); diff --git a/Reconstruction/tauRecTools/src/TauAxisSetter.h b/Reconstruction/tauRecTools/src/TauAxisSetter.h index 3205430370c043c326b2ffdd419304d48afc50ad..909b6e9318e161f3b77bc385004f7f7f0c12dc80 100644 --- a/Reconstruction/tauRecTools/src/TauAxisSetter.h +++ b/Reconstruction/tauRecTools/src/TauAxisSetter.h @@ -24,35 +24,31 @@ class TauAxisSetter : public TauRecToolBase { - public: - - ASG_TOOL_CLASS2(TauAxisSetter, TauRecToolBase, ITauToolBase); - - /** @brief Constructor */ - TauAxisSetter(const std::string& name); +public: + + ASG_TOOL_CLASS2(TauAxisSetter, TauRecToolBase, ITauToolBase) + + /** @brief Constructor */ + TauAxisSetter(const std::string& name); - /** @brief Destructor */ - virtual ~TauAxisSetter() = default; + /** @brief Destructor */ + virtual ~TauAxisSetter() = default; - /** @brief Execution of this tool */ - virtual StatusCode execute(xAOD::TauJet& tau) const override; + /** @brief Execution of this tool */ + virtual StatusCode execute(xAOD::TauJet& tau) const override; - private: +private: - /** Get the jet vertex */ - const xAOD::Vertex* getJetVertex(const xAOD::Jet& jet) const; - - /**@brief Get the vertex corrected four momentum */ - TLorentzVector getVertexCorrectedP4(const xAOD::JetConstituent& constituent, - const Amg::Vector3D& position) const; - - /**@brief Get the vertex corrected four momentum */ - TLorentzVector getVertexCorrectedP4(const xAOD::PFO& pfo, - const Amg::Vector3D& position) const; - - Gaudi::Property<double> m_clusterCone {this, "ClusterCone", 0.2, "cone of tau candidate"}; - Gaudi::Property<bool> m_doVertexCorrection {this, "VertexCorrection", true, "switch of tau vertex correction"}; - Gaudi::Property<bool> m_doJetVertexCorrection {this, "JetVertexCorrection", true, "switch of jet vertex correction"}; + /**@brief Get the vertex corrected four momentum */ + TLorentzVector getVertexCorrectedP4(const xAOD::JetConstituent& constituent, + const Amg::Vector3D& position) const; + + /**@brief Get the vertex corrected four momentum */ + TLorentzVector getVertexCorrectedP4(const xAOD::PFO& pfo, + const Amg::Vector3D& position) const; + + Gaudi::Property<double> m_clusterCone {this, "ClusterCone", 0.2, "cone of tau candidate"}; + Gaudi::Property<bool> m_doVertexCorrection {this, "VertexCorrection", true, "switch of tau vertex correction"}; }; #endif diff --git a/Reconstruction/tauRecTools/tauRecTools/HelperFunctions.h b/Reconstruction/tauRecTools/tauRecTools/HelperFunctions.h index 763799a7cfaebdb4b9acf86a2627288d92084c2c..b7b1c92c8d8043370d4703cf9a26ab0663a49a28 100644 --- a/Reconstruction/tauRecTools/tauRecTools/HelperFunctions.h +++ b/Reconstruction/tauRecTools/tauRecTools/HelperFunctions.h @@ -5,14 +5,15 @@ #ifndef TAURECTOOLS_HELPERFUNCTIONS_H #define TAURECTOOLS_HELPERFUNCTIONS_H -#include "AsgMessaging/MessageCheck.h" #include "xAODTracking/VertexContainer.h" +#include "xAODJet/Jet.h" #include "xAODTau/TauJet.h" #include "xAODCaloEvent/CaloCluster.h" #include "xAODPFlow/PFO.h" -#include "MVAUtils/BDT.h" +#include "AsgMessaging/MessageCheck.h" +#include "MVAUtils/BDT.h" #include "TLorentzVector.h" #include "TString.h" @@ -24,6 +25,26 @@ namespace tauRecTools { ANA_MSG_HEADER(msgHelperFunction) + /** + * @brief Return the vertex of jet candidate + * @warning In trigger, jet candidate does not have a candidate, and an ERROR + * message will be print out ! + */ + const xAOD::Vertex* getJetVertex(const xAOD::Jet& jet); + + /** + * @brief Return the vertex of tau candidate + * If the vertex link of tau candidate is valid, then the vertex which the link point to will + * be returned. Otherwise, it will try to retrieve the vertex of the seed jet in offline reconstruction + */ + const xAOD::Vertex* getTauVertex(const xAOD::TauJet& tau, bool inTrigger = false); + + /** + * @brief Return the four momentum of the tau axis + * The tau axis is widely used to select clusters and cells in tau reconstruction. + * If doVertexCorrection is true, then IntermediateAxis is returned. Otherwise, + * DetectorAxis is returned. + */ TLorentzVector getTauAxis(const xAOD::TauJet& tau, bool doVertexCorrection = true); TLorentzVector GetConstituentP4(const xAOD::JetConstituent& constituent); diff --git a/Reconstruction/tauRecTools/tauRecTools/TauVertexedClusterDecorator.h b/Reconstruction/tauRecTools/tauRecTools/TauVertexedClusterDecorator.h index f48bfa3eac23fc2e98e7e372b658d6474f919efc..5dcb7ad604ccfbf209ec8ac3ffd75c84dc4f6a93 100644 --- a/Reconstruction/tauRecTools/tauRecTools/TauVertexedClusterDecorator.h +++ b/Reconstruction/tauRecTools/tauRecTools/TauVertexedClusterDecorator.h @@ -30,8 +30,6 @@ public: virtual StatusCode execute(xAOD::TauJet& tau) const override; private: - //* Get the vertex used in jet reconstruction */ - const xAOD::Vertex* getJetVertex(const xAOD::Jet& jet) const; /// Name of the seed jet std::string m_seedJet; @@ -39,9 +37,6 @@ private: /// Switch of the tau vertex correction bool m_doVertexCorrection; - /// Switch of the jet vertex correction - bool m_doJetVertexCorrection; - /// Calibration state of cluster xAOD::CaloCluster::State m_clusterState; //! }; diff --git a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py index d7a5d98d0d469a69d15d5080de65049a7108bb41..8fd01362166d534ea16bf1ea0c189553637df7c4 100644 --- a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py +++ b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py @@ -100,9 +100,7 @@ def getTauAxis(): from tauRecTools.tauRecToolsConf import TauAxisSetter TauAxisSetter = TauAxisSetter( name = _name, ClusterCone = 0.2, - VertexCorrection = doVertexCorrection, - JetVertexCorrection = False - ) + VertexCorrection = doVertexCorrection ) # No Axis correction at trigger level cached_instances[_name] = TauAxisSetter @@ -738,8 +736,7 @@ def getTauVertexedClusterDecorator(): myTauVertexedClusterDecorator = TauVertexedClusterDecorator(name = _name, SeedJet = "", - VertexCorrection = doVertexCorrection, - JetVertexCorrection = False) + VertexCorrection = doVertexCorrection) cached_instances[_name] = myTauVertexedClusterDecorator return myTauVertexedClusterDecorator