diff --git a/Reconstruction/PFlow/PFlowUtils/Changelog b/Reconstruction/PFlow/PFlowUtils/Changelog index b2de69e02cb75391b35597b33401c2ca27318fa2..7abc979514aa59e0e8ee2e603992856ad28922bb 100644 --- a/Reconstruction/PFlow/PFlowUtils/Changelog +++ b/Reconstruction/PFlow/PFlowUtils/Changelog @@ -1,3 +1,17 @@ +2016-09-12 Teng Jian Khoo <khoo@cern.ch> + * Reorganise the weight method and fix the 60 GeV track case again + * Tagging as PFlowUtils-00-00-10 + +2016-09-11 Teng Jian Khoo <khoo@cern.ch> + * Don't weight 60 GeV tracks to 0 unless in dense environment + * Set tiny but non-zero weights to ensure high-pt cPFOs that are weighted down become jet constituents + * Needed for PF MET + * Tagging as PFlowUtils-00-00-09 + +2016-08-04 Teng Jian Khoo <khoo@cern.ch> + * Added WeightPFOTool for extraction of charged PFO weights + * Tagging as PFlowUtils-00-00-08 (missed files in 07 tag) + 2016-04-16 Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> * Created a new tag with a slightly adjusted CMakeLists.txt file. diff --git a/Reconstruction/PFlow/PFlowUtils/PFlowUtils/IWeightPFOTool.h b/Reconstruction/PFlow/PFlowUtils/PFlowUtils/IWeightPFOTool.h new file mode 100644 index 0000000000000000000000000000000000000000..5a84ecf748be944c8af92999181ac660acb15476 --- /dev/null +++ b/Reconstruction/PFlow/PFlowUtils/PFlowUtils/IWeightPFOTool.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef IWEIGHTPFOTOOL_H +#define IWEIGHTPFOTOOL_H + +/** Simple class to retrieve PFO for jets and met in the two possible configurations we provide */ + +#include "AsgTools/IAsgTool.h" + +#include "xAODPFlow/PFOContainer.h" +#include "PFlowUtils/PFODefs.h" + +namespace CP { + + class IWeightPFOTool : public virtual asg::IAsgTool { + + /** Declare the interface that the class provides */ + ASG_TOOL_INTERFACE( CP::IWeightPFOTool ) + + public: + + /** given a PFO, extract weight */ + virtual StatusCode fillWeight( const xAOD::PFO& cpfo, float& weight ) = 0; + + }; + +} +#endif diff --git a/Reconstruction/PFlow/PFlowUtils/PFlowUtils/WeightPFOTool.h b/Reconstruction/PFlow/PFlowUtils/PFlowUtils/WeightPFOTool.h new file mode 100644 index 0000000000000000000000000000000000000000..99fe86720d6c409cc3365521badcc4641576a64d --- /dev/null +++ b/Reconstruction/PFlow/PFlowUtils/PFlowUtils/WeightPFOTool.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef WEIGHTPFOTOOL_H +#define WEIGHTPFOTOOL_H + +/** Simple class to weight charged PFO for jets and met */ + +#include "AsgTools/AsgTool.h" + +#include "PFlowUtils/IWeightPFOTool.h" + +#include <string> + +namespace CP { + + class WeightPFOTool : public virtual IWeightPFOTool, public asg::AsgTool { + + /** Athena constructor */ + ASG_TOOL_CLASS( WeightPFOTool, IWeightPFOTool ); + + public: + /** Rootcore constructor */ + WeightPFOTool(const std::string& name); + + // given a PFO, extract weight + StatusCode fillWeight( const xAOD::PFO& cpfo, float& weight ); + + private: + + }; + +} +#endif diff --git a/Reconstruction/PFlow/PFlowUtils/Root/WeightPFOTool.cxx b/Reconstruction/PFlow/PFlowUtils/Root/WeightPFOTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7efc85d56ffc30b90ec0a18f6d6c13e55ad24b4b --- /dev/null +++ b/Reconstruction/PFlow/PFlowUtils/Root/WeightPFOTool.cxx @@ -0,0 +1,63 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PFlowUtils/WeightPFOTool.h" + +namespace CP { + + WeightPFOTool::WeightPFOTool(const std::string& name) : asg::AsgTool( name ) { } + + // The intended result: + // + // Subtraction applied (inDenseEnvironment==false) + // pt < 30 GeV: Ptrk [weight = 1] + // 30 <= pt < 60 GeV: Ptrk ( E/P + (1-E/P)(1 - (pt - 30)/30 ) ) [weight = E/P + (1-E/P)(1 - (pt - 30)/30 )] + // pt >= 60 GeV: Ptrk * E/P [weight = E/P] + // + // Subtraction not applied (inDenseEnvironment==true) + // pt < 30 GeV: Ptrk (1 - E/P) + Ecal [weight = (1-E/P] + // 30 <= pt < 60 GeV: Ptrk ( (1-E/P)(1 - (pt - 30)/30 ) ) + Ecal [weight = (1-E/P)(1 - (pt - 30)/30 )] + // pt >= 60 GeV: Ecal [weight = 0] + + StatusCode WeightPFOTool::fillWeight( const xAOD::PFO& cpfo, float& weight ) { + // Compute the weights internally + weight = 0.; + if(cpfo.pt()>100e3) { + ATH_MSG_WARNING("PFO with invalid pt " << cpfo.pt() << ", quitting."); + return StatusCode::FAILURE; + } + + int isInDenseEnvironment = false; + float expectedEnergy = 0.0; + bool gotVariable = cpfo.attribute(xAOD::PFODetails::PFOAttributes::eflowRec_isInDenseEnvironment,isInDenseEnvironment); + gotVariable &= cpfo.attribute(xAOD::PFODetails::PFOAttributes::eflowRec_tracksExpectedEnergyDeposit,expectedEnergy); + if (!gotVariable) { + ATH_MSG_WARNING("This charged PFO did not have eflowRec_isInDenseEnvironment or eflowRec_tracksExpectedEnergyDeposit set"); + return StatusCode::FAILURE; + } else { + // Start by computing the correction as though we subtracted the calo energy + // This interpolates between the full track P and the expected calo E + float EoverP = expectedEnergy/cpfo.e(); // divide once only + if(cpfo.pt()<30e3) { // take full track + weight = 1.; + } else if(cpfo.pt()<60e3) { // linearly interpolate between 1 and E/P + float interpolf = (1.0 - (cpfo.pt()-30000)/30000); + weight = EoverP + interpolf * (1-EoverP); + } else { // take the expected energy + weight = EoverP; + } + + if(isInDenseEnvironment) { + // In this case we further remove the expected deposited energy from the track + weight -= EoverP; + } + // If the weight went to 0, set it to the ghost scale, so that the cPFOs + // are always added to the track. + if (weight<1e-9) {weight = 1e-40;} + } + + return StatusCode::SUCCESS; + } + +} diff --git a/Reconstruction/PFlow/PFlowUtils/src/components/PFlowUtils_entries.cxx b/Reconstruction/PFlow/PFlowUtils/src/components/PFlowUtils_entries.cxx index 5237b8b75ad23a4deece54dc71029a43668680b5..c6aebb4fde9bec1b27f23b18e607f3adfd050fde 100644 --- a/Reconstruction/PFlow/PFlowUtils/src/components/PFlowUtils_entries.cxx +++ b/Reconstruction/PFlow/PFlowUtils/src/components/PFlowUtils_entries.cxx @@ -1,11 +1,14 @@ #include "GaudiKernel/DeclareFactoryEntries.h" #include "PFlowUtils/RetrievePFOTool.h" +#include "PFlowUtils/WeightPFOTool.h" #include "PFlowUtils/ParticleFlowEventFilter_r207.h" DECLARE_NAMESPACE_TOOL_FACTORY( CP, RetrievePFOTool) +DECLARE_NAMESPACE_TOOL_FACTORY( CP, WeightPFOTool) DECLARE_ALGORITHM_FACTORY(ParticleFlowEventFilter_r207) DECLARE_FACTORY_ENTRIES(PFlowUtils){ DECLARE_NAMESPACE_TOOL (CP, RetrievePFOTool) + DECLARE_NAMESPACE_TOOL (CP, WeightPFOTool) DECLARE_ALGORITHM(ParticleFlowEventFilter_r207) }