diff --git a/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetCaloQualityTool.h b/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetCaloQualityTool.h index 34a34260d264d5c5f18288aabc8e507e323d108c..94ddbc0543c9dd052a58bfc2ef8372f33c0bccbb 100644 --- a/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetCaloQualityTool.h +++ b/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetCaloQualityTool.h @@ -1,7 +1,7 @@ // this file is -*- C++ -*- /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ /** @@ -25,37 +25,30 @@ #ifndef JETREC_JETCALOQUALITYTOOL_H #define JETREC_JETCALOQUALITYTOOL_H -#include "AsgTools/AsgTool.h" -#include "JetInterface/IJetDecorator.h" +#include "JetRec/JetModifierBase.h" + #include "JetUtils/JetCaloCalculations.h" -#include "StoreGate/WriteDecorHandleKeyArray.h" #include <vector> #include <string> -class JetCaloQualityTool: public asg::AsgTool, - virtual public IJetDecorator { +class JetCaloQualityTool: public JetModifierBase { ASG_TOOL_CLASS0(JetCaloQualityTool) public: JetCaloQualityTool(const std::string & name); - virtual StatusCode decorate(const xAOD::JetContainer& jets) const override; + virtual int modifyJet(xAOD::Jet& ) const ; - virtual StatusCode initialize() override; + virtual StatusCode initialize(); protected: + /// Names of calo quantities to compute and to add as attributes + std::vector<std::string> m_calculationNames; - Gaudi::Property<std::vector<std::string> > m_calculationNames{this, "Calculations", {}, - "Name of calo quantities to compute and add as decorations"}; - Gaudi::Property<std::vector<double> > m_timingTimeCuts{this, "TimingCuts", {}, - "Time cuts for out-of-time calo quantities"}; - Gaudi::Property<std::string> m_jetContainerName{this, "JetContainer", "", - "SG key of input jet container"}; - - SG::WriteDecorHandleKeyArray<xAOD::JetContainer> m_writeDecorKeys{this, "OutputDecorKeys", {}, - "SG keys for output decorations (not to be configured manually!)"}; + /// Time cuts for Out-of-time calo quantities. + std::vector <double> m_timingTimeCuts; /// This objects holds a list of cluster-based calculators jet::JetCaloCalculations m_jetCalculations; @@ -63,6 +56,7 @@ public: // internal pointer to m_jetCalculations (this pointer is also used in the cell-based derived tool) jet::JetCaloCalculations * m_calcProcessor; + bool m_doFracSamplingMax; // internal }; #endif diff --git a/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetECPSFractionTool.h b/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetECPSFractionTool.h index e341c78e4b8a5be40db1aeecaa0e7040a985aed5..c54cf78214f5c4a878bdaf14d48f91dc0f508f62 100644 --- a/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetECPSFractionTool.h +++ b/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetECPSFractionTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ // JetECPSFractionTool.h @@ -21,37 +21,27 @@ /// ECPSFraction: Fraction of jet energy in the ECPS /// -#include "AsgTools/AsgTool.h" -#include "StoreGate/WriteDecorHandleKey.h" -#include "JetInterface/IJetDecorator.h" - -class JetECPSFractionTool : public asg::AsgTool, - virtual public IJetDecorator{ - ASG_TOOL_CLASS(JetECPSFractionTool, IJetDecorator) +#include "JetRec/JetModifierBase.h" +class JetECPSFractionTool : public JetModifierBase { + ASG_TOOL_CLASS(JetECPSFractionTool, IJetModifier) + public: // Constructor from tool name. JetECPSFractionTool(std::string myname); - // Inherited method to decorate a jet. - virtual StatusCode decorate(const xAOD::JetContainer& jets) const override; - - // Inherited from AsgTool - virtual StatusCode initialize() override; + // Inherited method to modify a jet. + // Calls width and puts the result on the jet. + int modifyJet(xAOD::Jet& jet) const; // Local method to calculate and return the energy fraction. double energyFraction(const xAOD::Jet& jet) const; private: - Gaudi::Property<double> m_fraclimit{this, "ECPSFractionThreshold", 0.8, - "Threshold for identifying a cluser as ECPS"}; - Gaudi::Property<std::string> m_jetContainerName{this, "JetContainer", "", - "SG key for input jet container"}; - - SG::WriteDecorHandleKey<xAOD::JetContainer> m_fracKey{this, "ECPSFractionDecorKey", "ECPSFraction", - "Name for output ECPS fraction decoration"}; + // Properties. + double m_fraclimit; }; diff --git a/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetLArHVTool.h b/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetLArHVTool.h index 928ec6670cd32a00664afc22f07b2b1178d06f8f..2f75f0ca085816eebf238e7d69714c2fc9463e9c 100644 --- a/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetLArHVTool.h +++ b/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetLArHVTool.h @@ -1,7 +1,7 @@ // this file is -*- C++ -*- /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ @@ -17,32 +17,23 @@ #ifndef JETMOMENTTOOLS_JETLARHVTOOL_H #define JETMOMENTTOOLS_JETLARHVTOOL_H +#include "JetRec/JetModifierBase.h" #include "AsgTools/ToolHandle.h" -#include "AsgTools/AsgTool.h" -#include "StoreGate/WriteDecorHandleKey.h" -#include "JetInterface/IJetDecorator.h" -class JetLArHVTool: public asg::AsgTool, - virtual public IJetDecorator{ +class JetLArHVTool: public JetModifierBase { ASG_TOOL_CLASS0(JetLArHVTool) public: JetLArHVTool(const std::string & name); - virtual StatusCode decorate(const xAOD::JetContainer& jets) const override; - - virtual StatusCode initialize() override; + virtual int modifyJet(xAOD::Jet& ) const ; + + virtual StatusCode initialize(); private: - Gaudi::Property<std::string> m_jetContainerName{this, "JetContainer", "", - "SG key for the input jet container"}; - SG::WriteDecorHandleKey<xAOD::JetContainer> m_fracKey{this, "EnergyFracDecorKey", "LArBadHVEnergyFrac", - "SG key for energy fraction decoration (not including jet container name)"}; - SG::WriteDecorHandleKey<xAOD::JetContainer> m_nCellKey{this, "NCellDecorKey", "LArBadHVNCell", - "SG key for nCell decoration (not including jet container name)"}; }; #endif diff --git a/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetVoronoiMomentsTool.h b/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetVoronoiMomentsTool.h index 90a11066acf8aa7f792ed7ea04ba7734556854e1..2310dec2b53113269b7d2ba0eb67a32d48292c94 100644 --- a/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetVoronoiMomentsTool.h +++ b/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetVoronoiMomentsTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ // JetVoronoiMomentsTool.h @@ -17,45 +17,35 @@ /// #include <string> -#include "AsgTools/AsgTool.h" -#include "StoreGate/WriteDecorHandleKey.h" -#include "JetInterface/IJetDecorator.h" +#include "JetRec/JetModifierBase.h" +#include "xAODJet/Jet.h" namespace JetVoronoiDiagramHelpers{ struct Diagram; } -class JetVoronoiMomentsTool : public asg::AsgTool, - virtual public IJetDecorator { -ASG_TOOL_CLASS(JetVoronoiMomentsTool,IJetDecorator) +class JetVoronoiMomentsTool : public JetModifierBase { +ASG_TOOL_CLASS(JetVoronoiMomentsTool,IJetModifier) public: // Constructor from tool name JetVoronoiMomentsTool(const std::string& name); - // Inherited from AsgTool via IJetDecorator - virtual StatusCode initialize() override; - - // Inherited method to decorate a jet container - virtual StatusCode decorate(const xAOD::JetContainer& jets) const override; + // Inherited methods to modify a jet container + virtual StatusCode modify(xAOD::JetContainer& jets) const; + virtual int modifyJet(xAOD::Jet& jet) const; private: // parameters - Gaudi::Property<float> m_x_min{this, "AreaXmin", -10, - "Minimum x-value for Voronoi diagram"}; - Gaudi::Property<float> m_x_max{this, "AreaXmax", 10, - "Maximum x-value for Voronoi diagram"}; - Gaudi::Property<float> m_y_min{this, "AreaYmin", -4, - "Minimum y-value for Voronoi diagram"}; - Gaudi::Property<float> m_y_max{this, "AreaYmax", 4, - "Maximum y-value for Voronoi diagram"}; - Gaudi::Property<std::string> m_jetContainerName{this, "JetContainer", "", - "SG key for the input jet container"}; - - SG::WriteDecorHandleKey<xAOD::JetContainer> m_voronoiAreaKey{this, "VoronoiAreaKey", "VoronoiArea", - "SG key for Voronoi area decoration (not including jet container name)"}; + float m_x_min; + float m_x_max; + float m_y_min; + float m_y_max; + + int modifyJet(xAOD::Jet& jet, const JetVoronoiDiagramHelpers::Diagram & voro) const; + }; #endif diff --git a/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetWidthTool.h b/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetWidthTool.h index 8b4df942064856c73c433492b47a449919981c4a..a768a18daf6bafdaa9bf18dc72239ac8a3cb4ddf 100644 --- a/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetWidthTool.h +++ b/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetWidthTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ // JetWidthTool.h @@ -12,40 +12,28 @@ /// /// Tool to calculate the jet width. -#include "JetInterface/IJetDecorator.h" -#include "AsgTools/AsgTool.h" +#include "JetRec/JetModifierBase.h" #include "AsgTools/ToolHandle.h" -#include "StoreGate/WriteDecorHandleKey.h" #include "PFlowUtils/IWeightPFOTool.h" -class JetWidthTool : public asg::AsgTool, - virtual public IJetDecorator { - ASG_TOOL_CLASS(JetWidthTool, IJetDecorator) - +class JetWidthTool : public JetModifierBase { + ASG_TOOL_CLASS(JetWidthTool, IJetModifier) + public: // Constructor from tool name. JetWidthTool(std::string myname); - virtual StatusCode initialize() override; - - // Inherited method to decorate a jet container. - // Calls width and puts the result on the jets. - virtual StatusCode decorate(const xAOD::JetContainer& jets) const override; + // Inherited method to modify a jet. + // Calls width and puts the result on the jet. + virtual int modifyJet(xAOD::Jet& jet) const; // Local method to calculate and return the width. - float width(const xAOD::Jet& jet, float& widthEta, float& widthPhi) const; + //double width(const xAOD::Jet& jet) const; + double width(const xAOD::Jet& jet, double& widthEta, double& widthPhi) const; private: - - Gaudi::Property<std::string> m_jetContainerName{this, "JetContainer", "", - "SG key for the input jet container"}; - - SG::WriteDecorHandleKey<xAOD::JetContainer> m_widthKey{this, "WidthKey", "Width", - "SG key for width decoration (not including jet container name)"}; - SG::WriteDecorHandleKey<xAOD::JetContainer> m_widthPhiKey{this, "WidthPhiKey", "WidthPhi", - "SG key for width phi decoration (not including jet container name)"}; }; #endif diff --git a/Reconstruction/Jet/JetMomentTools/Root/JetCaloQualityTool.cxx b/Reconstruction/Jet/JetMomentTools/Root/JetCaloQualityTool.cxx index fff60c74d56b5907b4e951e285605527e55ef9b3..2d4b5bea816c0cc91fef94d3800b2e90111157b2 100644 --- a/Reconstruction/Jet/JetMomentTools/Root/JetCaloQualityTool.cxx +++ b/Reconstruction/Jet/JetMomentTools/Root/JetCaloQualityTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ @@ -7,7 +7,6 @@ #include "JetMomentTools/JetCaloQualityTool.h" #include "xAODJet/JetAccessorMap.h" -#include "StoreGate/WriteDecorHandle.h" #include <iostream> @@ -17,69 +16,50 @@ using namespace jet; JetCaloQualityTool::JetCaloQualityTool(const std::string& name) - : asg::AsgTool(name) + : JetModifierBase(name) { - declareInterface<IJetDecorator>(this); -} - -StatusCode JetCaloQualityTool::decorate(const xAOD::JetContainer& jets) const -{ - if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Inside decorate() method" << endmsg; + declareProperty("TimingCuts", m_timingTimeCuts); + declareProperty("Calculations", m_calculationNames); +} - //bool checkedContainer = false; - const size_t nDecorations = m_writeDecorKeys.size(); - if(m_doFracSamplingMax==true){ - // Special case : we want to store more than 1 value (max sampling AND its index). - // AND there's no code available for direct cell access. - // So we just use a direct function instead of a calculator for now. +int JetCaloQualityTool::modifyJet( xAOD::Jet& jet ) const +{ - // We specifically put these in last earlier - SG::WriteDecorHandle<xAOD::JetContainer, float> maxHandle(m_writeDecorKeys.at(nDecorations-2)); - SG::WriteDecorHandle<xAOD::JetContainer, int> samplingHandle(m_writeDecorKeys.at(nDecorations-1)); + if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Inside process() method" << endmsg; + + if(m_doFracSamplingMax==true) + { + // Special case : we want to store more than 1 value (max sampling AND its index). + // AND there's no code available for direct cell access. + // So we just use a direct function instead of a calculator for now. - for(const xAOD::Jet* jet : jets){ int sampling=-1; - double fracSamplingMax=JetCaloQualityUtils::fracSamplingMax(jet,sampling); + double fracSamplingMax=JetCaloQualityUtils::fracSamplingMax(&jet,sampling); ATH_MSG_VERBOSE("Setting " << xAOD::JetAttribute::FracSamplingMax << " to " << fracSamplingMax); - maxHandle(*jet) = fracSamplingMax; - samplingHandle(*jet) = sampling; + jet.setAttribute<float>(xAOD::JetAttribute::FracSamplingMax,fracSamplingMax ); + jet.setAttribute<int>(xAOD::JetAttribute::FracSamplingMaxIndex,sampling ); } - } - + // Do all other calculations - for(const xAOD::Jet* jet : jets){ - - std::vector<double> results = m_calcProcessor->process(jet); - - // store them in the jet - for(size_t i=0;i < m_calcProcessor->numCalculators();i++) { - // We inserted WriteDecorKeys in the same order as calculators - SG::WriteDecorHandle<xAOD::JetContainer, float> decHandle(m_writeDecorKeys.at(i)); - - const JetCaloCalculator* calc = m_calcProcessor->at(i); - ATH_MSG_DEBUG( calc->name() << " -> "<<results[i] ); - decHandle(*jet) = results[i]; - } + std::vector<double> results = m_calcProcessor->process(&jet); + + // store them in the jet + for(size_t i=0;i < m_calcProcessor->numCalculators();i++) { + const JetCaloCalculator* calc = m_calcProcessor->at(i); + ATH_MSG_DEBUG( calc->name() << " -> "<<results[i] ); + jet.setAttribute<float>( calc->name(), results[i] ); } - return StatusCode::SUCCESS; + + return 1; } StatusCode JetCaloQualityTool::initialize() { ATH_MSG_DEBUG( "Inside initialize() method" ); - if(!m_writeDecorKeys.empty()){ - ATH_MSG_ERROR("OutputDecorKeys should not be configured manually!"); - return StatusCode::FAILURE; - } - if(m_jetContainerName.empty()){ - ATH_MSG_ERROR("JetCaloQualityTool needs to have its input jet container name configured!"); - return StatusCode::FAILURE; - } - // In this tool we're using the cluster-based calculators // (this is different in the cell-based calculation tool). m_calcProcessor = & m_jetCalculations; @@ -120,13 +100,10 @@ StatusCode JetCaloQualityTool::initialize() { } else if (calcN == "FracSamplingMax") { m_doFracSamplingMax = true; // no calculator, as this is a special case. } - }// end loop over m_calculationNames - // Set the DecorHandleKeys with the correct strings - for(size_t i=0; i < m_jetCalculations.numCalculators(); i++){ - m_writeDecorKeys.emplace_back(m_jetContainerName + "." + m_jetCalculations.at(i)->name()); - } + }// end loop over m_calculationNames + // Define OOT calculators. for( double & timeCut : m_timingTimeCuts){ @@ -138,17 +115,8 @@ StatusCode JetCaloQualityTool::initialize() { c->setName(s.str()); c->timecut = timeCut; m_jetCalculations.addCalculator( c ); - m_writeDecorKeys.emplace_back(m_jetContainerName + "." + s.str()); } - // Add these last so m_jetCalculations and m_writeDecorKeys have corresponding indices - if (m_doFracSamplingMax){ - m_writeDecorKeys.emplace_back(m_jetContainerName + ".FracSamplingMax"); - m_writeDecorKeys.emplace_back(m_jetContainerName + ".FracSamplingMaxIndex"); - } - - ATH_CHECK(m_writeDecorKeys.initialize()); - return StatusCode::SUCCESS; } diff --git a/Reconstruction/Jet/JetMomentTools/Root/JetECPSFractionTool.cxx b/Reconstruction/Jet/JetMomentTools/Root/JetECPSFractionTool.cxx index 3a317b528928979150f484ad8e13d005206b92bd..9ad518155d8a5d6c6e439aa439b3efb9e2481626 100644 --- a/Reconstruction/Jet/JetMomentTools/Root/JetECPSFractionTool.cxx +++ b/Reconstruction/Jet/JetMomentTools/Root/JetECPSFractionTool.cxx @@ -1,10 +1,9 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // JetECPSFractionTool.cxx -#include "StoreGate/WriteDecorHandle.h" #include "JetMomentTools/JetECPSFractionTool.h" #include "xAODCaloEvent/CaloCluster.h" #include "xAODPFlow/PFO.h" @@ -21,35 +20,16 @@ using xAOD::JetFourMom_t; //********************************************************************** JetECPSFractionTool::JetECPSFractionTool(std::string myname) -: asg::AsgTool(myname) { - - declareInterface<IJetDecorator>(this); +: JetModifierBase(myname) { + declareProperty("ECPSFractionThreshold", m_fraclimit =0.8); } -//********************************************************************** - -StatusCode JetECPSFractionTool::initialize(){ - - if(m_jetContainerName.empty()){ - ATH_MSG_ERROR("JetECPSFractionTool needs to have its input jet container name configured!"); - return StatusCode::FAILURE; - } - - // Prepend jet collection name - m_fracKey = m_jetContainerName + "." + m_fracKey.key(); - - ATH_CHECK(m_fracKey.initialize()); - return StatusCode::SUCCESS; -} //********************************************************************** -StatusCode JetECPSFractionTool::decorate(const xAOD::JetContainer& jets) const { - - SG::WriteDecorHandle<xAOD::JetContainer, float> fracHandle(m_fracKey); - - for(const xAOD::Jet* jet : jets) fracHandle(*jet) = energyFraction(*jet); - return StatusCode::SUCCESS; +int JetECPSFractionTool::modifyJet(xAOD::Jet& jet) const { + jet.setAttribute("ECPSFraction", energyFraction(jet)); + return 0; } //********************************************************************** diff --git a/Reconstruction/Jet/JetMomentTools/Root/JetLArHVTool.cxx b/Reconstruction/Jet/JetMomentTools/Root/JetLArHVTool.cxx index 41cfeec79ae3fbfe7851a1eb4ebbb64da4f80a4d..59707dfe6c1128ec5580ddfe58e452c9c06fdf93 100644 --- a/Reconstruction/Jet/JetMomentTools/Root/JetLArHVTool.cxx +++ b/Reconstruction/Jet/JetMomentTools/Root/JetLArHVTool.cxx @@ -1,65 +1,46 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#include "StoreGate/WriteDecorHandle.h" #include "JetUtils/JetDistances.h" #include "JetMomentTools/JetLArHVTool.h" #include "xAODCaloEvent/CaloCluster.h" JetLArHVTool::JetLArHVTool(const std::string& name) - : asg::AsgTool(name) + : JetModifierBase(name) { - declareInterface<IJetDecorator>(this); } StatusCode JetLArHVTool::initialize() { - if(m_fracKey.key().at(0) == '.' || m_nCellKey.key().at(0) == '.'){ - ATH_MSG_ERROR("JetLArHVTool needs to have its input jet container name configured!"); - return StatusCode::FAILURE; - } - - // Prepend jet container name - m_fracKey = m_jetContainerName + "." + m_fracKey.key(); - m_nCellKey = m_jetContainerName + "." + m_nCellKey.key(); - - ATH_CHECK(m_fracKey.initialize()); - ATH_CHECK(m_nCellKey.initialize()); return StatusCode::SUCCESS; } -StatusCode JetLArHVTool::decorate(const xAOD::JetContainer& jets) const +int JetLArHVTool::modifyJet( xAOD::Jet& jet ) const { - - SG::WriteDecorHandle<xAOD::JetContainer, float> fracHandle(m_fracKey); - SG::WriteDecorHandle<xAOD::JetContainer, int> nCellHandle(m_nCellKey); - - for(const xAOD::Jet* jet : jets){ - - double energyHVaff=0; - int numCellsHVaff=0; - - // loop over raw constituents. Look for clusters - size_t num = jet->numConstituents(); - for(size_t i=0;i<num;i++) { - const xAOD::CaloCluster * cl = dynamic_cast<const xAOD::CaloCluster *>(jet->rawConstituent(i)); - if( !cl) continue; - - double m; - if(cl->retrieveMoment(xAOD::CaloCluster::ENG_BAD_HV_CELLS,m) ) energyHVaff += m; - if(cl->retrieveMoment(xAOD::CaloCluster::N_BAD_HV_CELLS, m) ) numCellsHVaff += m; - } - - double emE = jet->jetP4(xAOD::JetEMScaleMomentum).E(); - // set the attributes - fracHandle(*jet) = energyHVaff / emE; - nCellHandle(*jet) = numCellsHVaff; + double energyHVaff=0; + int numCellsHVaff=0; + + // loop over raw constituents. Look for clusters + size_t num = jet.numConstituents(); + for(size_t i=0;i<num;i++) { + const xAOD::CaloCluster * cl = dynamic_cast<const xAOD::CaloCluster *>(jet.rawConstituent(i)); + if( !cl) continue; + + double m; + if(cl->retrieveMoment(xAOD::CaloCluster::ENG_BAD_HV_CELLS,m) ) energyHVaff += m; + if(cl->retrieveMoment(xAOD::CaloCluster::N_BAD_HV_CELLS, m) ) numCellsHVaff += m; } - return StatusCode::SUCCESS; + + double emE = jet.jetP4(xAOD::JetEMScaleMomentum).E(); + // set the attributes + jet.setAttribute<float>("LArBadHVEnergyFrac", energyHVaff / emE); + jet.setAttribute<int>("LArBadHVNCell", numCellsHVaff); + + return 0; } diff --git a/Reconstruction/Jet/JetMomentTools/Root/JetWidthTool.cxx b/Reconstruction/Jet/JetMomentTools/Root/JetWidthTool.cxx index d18ec0d813ad5d582e1590d8ca43417b9ebce4e3..823c17576ab0a8b65b75444ca4d378f538a3774d 100644 --- a/Reconstruction/Jet/JetMomentTools/Root/JetWidthTool.cxx +++ b/Reconstruction/Jet/JetMomentTools/Root/JetWidthTool.cxx @@ -1,11 +1,11 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ // JetWidthTool.cxx #include "JetMomentTools/JetWidthTool.h" -#include "StoreGate/WriteDecorHandle.h" + #include "xAODJet/JetConstituentVector.h" #include "JetUtils/JetDistances.h" #include "PFlowUtils/IWeightPFOTool.h" @@ -13,47 +13,52 @@ //********************************************************************** JetWidthTool::JetWidthTool(std::string myname) - : asg::AsgTool(myname) + : JetModifierBase(myname) { - declareInterface<IJetDecorator>(this); } //********************************************************************** -StatusCode JetWidthTool::initialize(){ - - if(m_jetContainerName.empty()){ - ATH_MSG_ERROR("JetWidthTool needs to have its input jet container name configured!"); - return StatusCode::FAILURE; - } - - // Prepend jet container name - m_widthKey = m_jetContainerName + "." + m_widthKey.key(); - m_widthPhiKey = m_jetContainerName + "." + m_widthPhiKey.key(); +int JetWidthTool::modifyJet(xAOD::Jet& jet) const { - ATH_CHECK(m_widthKey.initialize()); - ATH_CHECK(m_widthPhiKey.initialize()); - return StatusCode::SUCCESS; + double widthEta = 0, widthPhi = 0; + //jet.setAttribute("Width", width(jet)); + jet.setAttribute("Width", width(jet,widthEta,widthPhi)); + //jet.setAttribute("WidthEta",widthEta); + jet.setAttribute("WidthPhi",widthPhi); + return 0; } //********************************************************************** -StatusCode JetWidthTool::decorate(const xAOD::JetContainer& jets) const { - - SG::WriteDecorHandle<xAOD::JetContainer, float> widthHandle(m_widthKey); - SG::WriteDecorHandle<xAOD::JetContainer, float> widthPhiHandle(m_widthPhiKey); - - for(const xAOD::Jet* jet : jets){ - float widthEta = 0, widthPhi = 0; - widthHandle(*jet) = width(*jet,widthEta,widthPhi); - widthPhiHandle(*jet) = widthPhi; - } - return StatusCode::SUCCESS; -} - -//********************************************************************** - -float JetWidthTool::width(const xAOD::Jet& jet, float& widthEta, float& widthPhi) const { +//double JetWidthTool::width(const xAOD::Jet& jet) const { +// +// // Get the constituents of the jet +// const xAOD::JetConstituentVector constituents = jet.getConstituents(); +// xAOD::JetConstituentVector::iterator iter = constituents.begin(); +// xAOD::JetConstituentVector::iterator iEnd = constituents.end(); +// +// // TODO: Switch to using helper function once JetUtils has been updated +// // Set the width +// // jetWidth = JetKinematics::ptWeightedWidth(iter,iEnd,&jet); +// +// // Calculate the pt weighted width +// const double jetEta = jet.eta(); +// const double jetPhi = jet.phi(); +// double weightedWidth = 0; +// double ptSum = 0; +// +// for ( ; iter != iEnd; ++iter) { +// const double dR = jet::JetDistances::deltaR(jetEta, jetPhi, iter->eta(), iter->phi() ); +// const double pt = iter->pt(); +// weightedWidth += dR * pt; +// ptSum += pt; +// } +// +// return ptSum > 0 ? weightedWidth/ptSum : -1; +//} + +double JetWidthTool::width(const xAOD::Jet& jet, double& widthEta, double& widthPhi) const { // Get the constituents of the jet // TODO: Switch to using helper function once JetUtils has been updated @@ -61,19 +66,19 @@ float JetWidthTool::width(const xAOD::Jet& jet, float& widthEta, float& widthPhi // jetWidth = JetKinematics::ptWeightedWidth(iter,iEnd,&jet); // Calculate the pt weighted width - const float jetEta = jet.eta(); - const float jetPhi = jet.phi(); - float weightedWidth = 0; - float weightedWidthEta = 0; - float weightedWidthPhi = 0; - float ptSum = 0; + const double jetEta = jet.eta(); + const double jetPhi = jet.phi(); + double weightedWidth = 0; + double weightedWidthEta = 0; + double weightedWidthPhi = 0; + double ptSum = 0; const xAOD::JetConstituentVector constituents = jet.getConstituents(); for (const auto& constituent : constituents) { - const float dR = jet::JetDistances::deltaR(jetEta, jetPhi, constituent->eta(), constituent->phi() ); - const float dEta = fabs(jet::JetDistances::deltaEta(jetEta, constituent->eta() )); - const float dPhi = fabs(jet::JetDistances::deltaPhi(jetPhi, constituent->phi() )); - const float pt = constituent->pt(); + const double dR = jet::JetDistances::deltaR(jetEta, jetPhi, constituent->eta(), constituent->phi() ); + const double dEta = fabs(jet::JetDistances::deltaEta(jetEta, constituent->eta() )); + const double dPhi = fabs(jet::JetDistances::deltaPhi(jetPhi, constituent->phi() )); + const double pt = constituent->pt(); weightedWidth += dR * pt; weightedWidthEta += dEta * pt; @@ -87,3 +92,5 @@ float JetWidthTool::width(const xAOD::Jet& jet, float& widthEta, float& widthPhi return ptSum > 0 ? weightedWidth/ptSum : -1; } + +//********************************************************************** diff --git a/Reconstruction/Jet/JetMomentTools/src/JetVoronoiMomentsTool.cxx b/Reconstruction/Jet/JetMomentTools/src/JetVoronoiMomentsTool.cxx index cfd83cac24b8a01e5fe2d8979944190ef592abb3..439da17b1a3a2d074964818b968928f32185948e 100644 --- a/Reconstruction/Jet/JetMomentTools/src/JetVoronoiMomentsTool.cxx +++ b/Reconstruction/Jet/JetMomentTools/src/JetVoronoiMomentsTool.cxx @@ -1,9 +1,8 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#include "StoreGate/WriteDecorHandle.h" #include "JetMomentTools/JetVoronoiMomentsTool.h" // helpers @@ -20,29 +19,24 @@ using JetVoronoiDiagramHelpers::Diagram; JetVoronoiMomentsTool::JetVoronoiMomentsTool(const std::string& name) - : asg::AsgTool(name) + : JetModifierBase(name) + //, m_voronoitool("") + , m_x_min(-10.) + , m_x_max( 10.) + , m_y_min(-4. ) + , m_y_max( 4. ) + //, m_jetcontainer ("") + //, m_scaleIntFloat (1e3) { - declareInterface<IJetDecorator>(this); -} - -StatusCode JetVoronoiMomentsTool::initialize() { - - if(m_jetContainerName.empty()){ - ATH_MSG_ERROR("JetVoronoiMomentsTool needs to have its input jet container name configured!"); - return StatusCode::FAILURE; - } - - // Prepend jet collection name - m_voronoiAreaKey = m_jetContainerName + "." + m_voronoiAreaKey.key(); + declareProperty("AreaXmin",m_x_min); + declareProperty("AreaXmax",m_x_max); + declareProperty("AreaYmin",m_y_min); + declareProperty("AreaYmax",m_y_max); + //declareProperty("JetContainerName",m_jetcontainer); - ATH_CHECK(m_voronoiAreaKey.initialize()); - return StatusCode::SUCCESS; } -StatusCode JetVoronoiMomentsTool::decorate(const xAOD::JetContainer& jets) const { - - SG::WriteDecorHandle<xAOD::JetContainer, float> outputHandle(m_voronoiAreaKey); - +StatusCode JetVoronoiMomentsTool::modify(xAOD::JetContainer& jets) const { // setup diagram class Diagram voro ("VoronoiDiagram"); voro.m_x_min = m_x_min; @@ -58,9 +52,21 @@ StatusCode JetVoronoiMomentsTool::decorate(const xAOD::JetContainer& jets) const if ( voro.createVoronoiDiagram().isFailure() ) { ATH_MSG_WARNING("Could not calculate Voronoi diagram"); } - // decorate the jets - for (const xAOD::Jet *jet : jets ){ - outputHandle(*jet) = voro.getCellArea(jet->eta(), jet->phi()); - } + for ( xAOD::Jet *jet : jets ) modifyJet(*jet,voro); return StatusCode::SUCCESS; } + +int JetVoronoiMomentsTool::modifyJet(xAOD::Jet&) const { + ATH_MSG_WARNING("Don't use this function. We need to compare space with other jets."); + return 0; +} + +int JetVoronoiMomentsTool::modifyJet(xAOD::Jet& jet, const Diagram & voro) const { + // Collate info + float VoronoiArea = voro.getCellArea(jet.eta(), jet.phi() ); + // Set info + jet.setAttribute( "VoronoiArea" , VoronoiArea ); + return 0; +} + + diff --git a/Reconstruction/Jet/JetRec/python/JetToolSupport.py b/Reconstruction/Jet/JetRec/python/JetToolSupport.py index f6d198b4debe2d0d9055e81cb7bbb94b294574c4..45b155247ad0d03c7196c51472f77033b5e04f9e 100644 --- a/Reconstruction/Jet/JetRec/python/JetToolSupport.py +++ b/Reconstruction/Jet/JetRec/python/JetToolSupport.py @@ -139,17 +139,8 @@ class JetToolManager: self.msg(0, "Error adding jet builder without area.") raise LookupError - # Configures any tools in the given modifier list with the property - # "JetContainer" to set that property to the given string containerName. - def configureContainerName(self, modifiers, containerName): - for mod in modifiers: - if "JetContainer" in mod.properties(): - print ("configuring " + mod.name() + " to have container name " + containerName) - mod.JetContainer = containerName - # Return the list of modifiers associated with a name. - # If the argument is a list, a copy is returned directly. - # Also configures any necessary container names in the copy. + # If the argument is a list, it is returned directly. def getModifiers(self, modifiersin, altname =None): if modifiersin == None: if altname in ["lctopo","emtopo"]: @@ -299,6 +290,7 @@ class JetToolManager: jetlog.info( self.prefix + "Calibration option (" + calibOpt + ") provided with multiple calibration modifiers." ) raise Exception + return outmods # Create a jet finder without a JetRecToosl. @@ -419,7 +411,6 @@ class JetToolManager: ptminSave = self.ptminFilter if ptminFilter > 0.0: self.ptminFilter = ptminFilter jetrec.JetModifiers = self.buildModifiers(modifiersin, lofinder, getters, gettersin, output, calibOpt) - self.configureContainerName(jetrec.JetModifiers, output) if consumers != None: jetrec.JetConsumers = consumers self.ptminFilter = ptminSave @@ -467,7 +458,6 @@ class JetToolManager: jetrec.InputContainer = input jetrec.OutputContainer = output jetrec.JetModifiers = self.getModifiers(modifiersin) - self.configureContainerName(jetrec.JetModifiers, output) jetrec.Trigger = isTrigger or useTriggerStore jetrec.Timer = jetFlags.timeJetRecTool() self += jetrec @@ -502,7 +492,6 @@ class JetToolManager: jetrec.InputContainer = input jetrec.OutputContainer = output jetrec.JetModifiers = self.getModifiers(modifiersin) - self.configureContainerName(jetrec.JetModifiers, output) jetrec.Trigger = isTrigger or useTriggerStore jetrec.Timer = jetFlags.timeJetRecTool() if pseudojetRetriever in self.tools: @@ -550,7 +539,6 @@ class JetToolManager: jetrec.InputContainer = input jetrec.OutputContainer = output jetrec.JetModifiers = self.getModifiers(modifiersin) - self.configureContainerName(jetrec.JetModifiers, output) jetrec.Trigger = isTrigger or useTriggerStore jetrec.Timer = jetFlags.timeJetRecTool() self += jetrec @@ -609,7 +597,6 @@ class JetToolManager: jetrec.OutputContainer = output jetrec.JetGroomer = groomer jetrec.JetModifiers = self.getModifiers(modifiersin) - self.configureContainerName(jetrec.JetModifiers, output) if consumers != None: jetrec.JetConsumers = consumers jetrec.Trigger = isTrigger or useTriggerStore @@ -641,7 +628,6 @@ class JetToolManager: Label = inp getters = [get] jetrec.JetModifiers = self.buildModifiers(modifiersin, finder, getters, None, output, calibOpt) - self.configureContainerName(jetrec.JetModifiers, output) self.ptminFilter = ptminSave jetrec.Trigger = isTrigger or useTriggerStore jetrec.Timer = jetFlags.timeJetRecTool() @@ -793,11 +779,6 @@ class JetToolManager: for m in modifiers: self.setOutputLevel(m, OutputLevel) - # Temporary hard-coded solution until this config is deprecated. - triggerPrefix = "HLT_xAOD__JetContainer_" - - self.configureContainerName(modifiers, triggerPrefix + name.split('_')[1]) - self.ptminFilter = ptminSave @@ -821,8 +802,8 @@ class JetToolManager: self += builder return builder + def addTriggerJetTrimmer(self, - output, name, rclus, ptfrac, @@ -876,7 +857,6 @@ class JetToolManager: triggerGroomerTool = TriggerJetGroomerTool(name) triggerGroomerTool.JetGroomer = trimmerTool triggerGroomerTool.JetModifiers = self.getModifiers(modifiersin) - self.configureContainerName(triggerGroomerTool.JetModifiers, name.split('_')[1]) triggerGroomerTool.OutputLevel = OutputLevel # TriggerJetGroomerTool obtains a TriggerJetGroomerTool, will pass it @@ -894,3 +874,4 @@ class JetToolManager: self.trigjetrecs += [triggerGroomerTool] return triggerGroomerTool + diff --git a/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py b/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py index 08e126ccae6104fddc0ae9d257311f7e9c9a6792..71811d6aa2a1b989904a09834be6095df0892e26 100644 --- a/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py +++ b/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py @@ -210,14 +210,6 @@ def expandPrereqs(reqtype,prereqs): return None return reqdefs -######################################################################## -# For each modifier in the given list with a configurable input container -# name ("JetContainer"), configure it to containerName. -def configureContainerName(modifiers, containerName): - for mod in modifiers: - if "JetContainer" in mod.properties(): - mod.JetContainer = containerName - ######################################################################## # Function producing an EventShapeAlg to calculate @@ -475,7 +467,6 @@ def getJetRecTool(jetname, finder, pjs, mods): JetFinder = finder, JetModifiers = mods ) - configureContainerName(jetrec.JetModifiers, jetname) return jetrec diff --git a/Trigger/TrigAlgorithms/TrigHLTJetRec/python/TrigHLTJetRecConfig.py b/Trigger/TrigAlgorithms/TrigHLTJetRec/python/TrigHLTJetRecConfig.py index 91fd431f7f5569ec52c1981bf116c3f6e515e515..ce15acea18e54feda1da3e5341119090cd462882 100644 --- a/Trigger/TrigAlgorithms/TrigHLTJetRec/python/TrigHLTJetRecConfig.py +++ b/Trigger/TrigAlgorithms/TrigHLTJetRec/python/TrigHLTJetRecConfig.py @@ -810,12 +810,6 @@ def _getJetTrimmerTool2 (merge_param, make heavy use of dynamic stores, so all modifiers other than calibration are currently disabled.""" - # Output collection name isn't needed here since only calibration modifiers - # are used, but the function below requires one even if it won't be used. - # No need for a nicer solution since this whole config should be deprecated - # and phased out by 2021. - output = "DummyCollectionName" - # declare jtm as global as this function body may modify it # with the += operator @@ -883,7 +877,6 @@ def _getJetTrimmerTool2 (merge_param, try: # Ask the jtm to creat and register the trimmer jetTrimmerTool = jtm.addTriggerJetTrimmer( - output, name, rclus, ptfrac,