ATLAS Offline Software
Loading...
Searching...
No Matches
PileupAreaCalibStep.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <TEnv.h>
7
9
13
15 : asg::AsgTool( name ) { }
16
17
18
19
21
22 ATH_MSG_INFO("Initializing pileup area correction.");
23
24 ATH_MSG_DEBUG("Reading from " << m_jetInScale << " and writing to " << m_jetOutScale);
25
26 ATH_CHECK( m_rhoKey.initialize() );
27 return StatusCode::SUCCESS;
28}
29
31
33 double rho=0;
34 if(!rhRhoKey.isValid()){
35 ATH_MSG_FATAL("Could not retrieve xAOD::EventShape DataHandle : "<< m_rhoKey.key());
36 return StatusCode::FAILURE;
37 }
38 const xAOD::EventShape * eventShape = rhRhoKey.cptr();
39
40 if ( !eventShape->getDensity( xAOD::EventShape::Density, rho ) ) {
41 ATH_MSG_FATAL("Could not retrieve xAOD::EventShape::Density from xAOD::EventShape "<< m_rhoKey.key());
42 return StatusCode::FAILURE;
43 }
44
45 ATH_MSG_DEBUG(" Rho = " << 0.001*rho << " GeV");
46
49 SG::AuxElement::Accessor<int> puCorrectedAcc("PileupCorrected");
50 for(xAOD::Jet *jet : jetCont){
51
52 const xAOD::JetFourMom_t jetStartP4 = jet->getAttribute<xAOD::JetFourMom_t>(m_jetInScale);
53 jet->setJetP4(jetStartP4);
54
55 xAOD::JetFourMom_t jetareaP4 = areaAcc.getAttribute(*jet);
56 ATH_MSG_VERBOSE(" Area = " << jetareaP4);
57
58 xAOD::JetFourMom_t calibP4;
59
61 calibP4 = jetStartP4 - rho*jetareaP4;
62 } else {
63 ATH_MSG_VERBOSE(" Applying postive-only area-subtraction calibration to jet " << jet->index() << " with pT = " << 0.001*jet->pt() << " GeV");
64 const double pT_det = jetStartP4.pt();
65 const double E_det = jetStartP4.e();
66 //Set the jet pT to 10 MeV if the pT or energy is negative after the jet area correction
67 const double area_SF = (pT_det-rho*jetareaP4.pt()<=0 || E_det-rho*jetareaP4.e()<=0) ? 10/pT_det : (pT_det-rho*jetareaP4.pt())/pT_det;
68 calibP4 = jetStartP4*area_SF;
69 }
70
71 //Attribute to track if a jet has received the pileup subtraction (always true if this code was run)
72 puCorrectedAcc(*jet) = 1 ;
73 //Transfer calibrated jet properties to the Jet object
74 outScaleMomAcc.setAttribute(*jet, calibP4 );
75 jet->setJetP4( calibP4 );
76 }
77 return StatusCode::SUCCESS;
78}
79
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading a decoration on an object.
This header defines wrapper classes around SG::AuxElement::Accessor used internally in the Jet EDM.
PileupAreaCalibStep(const std::string &name="PileupAreaCalibStep")
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
virtual StatusCode calibrate(xAOD::JetContainer &jetCont) const override
Apply calibration to a jet container.
SG::ReadHandleKey< xAOD::EventShape > m_rhoKey
Gaudi::Property< std::string > m_jetInScale
Gaudi::Property< bool > m_useFull4vectorArea
Gaudi::Property< std::string > m_jetOutScale
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
bool getDensity(EventDensityID id, double &v) const
Get a density variable from the object.
void getAttribute(const SG::AuxElement &p, TYPE &v) const
void setAttribute(SG::AuxElement &p, const TYPE &v) const
Jet_v1 Jet
Definition of the current "jet version".
EventShape_v1 EventShape
Definition of the current event format version.
Definition EventShape.h:16
JetContainer_v1 JetContainer
Definition of the current "jet container version".
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17