Commit 8c912242 authored by Teng Jian Khoo's avatar Teng Jian Khoo Committed by Graeme Stewart
Browse files

'weight method cleanup' (PFlowUtils-00-00-10)

parent 2b582d6c
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.
......
/*
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
/*
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
/*
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;
}
}
#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)
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment