ATLAS Offline Software
Loading...
Searching...
No Matches
HIJetConstituentSubtractionTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
11
14
15//**********************************************************************
16
21
22
24{
25 ATH_MSG_VERBOSE("HIJetConstituentSubtractionTool initialize");
26 ATH_CHECK( m_eventShapeKey.initialize( !m_eventShapeKey.key().empty()) );
27 return StatusCode::SUCCESS;
28}
29
30//**********************************************************************
31
32//Fix from conflict beetween d1493284 (master) and 5af8a733 (21.0)
34{
35 float E_min=m_subtractorTool->minEnergyForMoments();
36 //const jet::cellset_t & badcells = badCellMap.cells() ;
37
38 //retrieve UE
39 //Introduction of a read handle for the HIShapeContainer
41
42 const xAOD::HIEventShapeContainer* shape=nullptr;
43 const HIEventShapeIndex* es_index=nullptr;
44 if(m_eventShapeKey.key().compare("") != 0)
45 {
46 if (!readHandleEvtShape.isValid())
47 {
48 ATH_MSG_ERROR("Could not retrieve input HIEventShape " << m_eventShapeKey.key() );
49 return StatusCode::FAILURE;
50 }
51 shape = readHandleEvtShape.get();
52 es_index=m_eventShapeMapTool->getIndexFromShape(shape);
53 if(es_index==nullptr)
54 {
55 ATH_MSG_ERROR("No HIEventShapeIndex w/ name " << m_eventShapeKey.key());
56 return StatusCode::FAILURE;
57 }
58 }
59
60 const xAOD::HIEventShape* eshape = nullptr;
61 if(m_modulatorTool->getShape(eshape).isFailure())
62 {
63 ATH_MSG_ERROR("Could not retrieve output shape w/ modulator tool");
64 return StatusCode::FAILURE;
65 }
66
67 for ( xAOD::JetContainer::iterator ijet=jets.begin(); ijet!=jets.end(); ++ijet)
68 {
69
73 const xAOD::JetConstituentVector constituents = (*ijet)->getConstituents();
74 for (const auto* constituent : constituents)
75 {
76 m_subtractorTool->subtract(p4_cl,constituent->rawConstituent(),shape,es_index,m_modulatorTool, eshape); //modifies p4_cl to be constituent 4-vector AFTER subtraction
77 p4_subtr+=p4_cl;
78
79 if( msgLvl(MSG::DEBUG) )
80 {
81 const xAOD::CaloCluster* cl=static_cast<const xAOD::CaloCluster*>(constituent->rawConstituent());
82 //here we can still keep cl->p4 because it's taking the unsubtracted state - moreover is debug
83 p4_unsubtr+=cl->p4(HIJetRec::unsubtractedClusterState());
84 }
85 }
86
87 ATH_MSG_DEBUG("Subtracting"
88 << std::setw(12) << "Before:"
89 << std::setw(10) << std::setprecision(3) << p4_unsubtr.Pt()*1e-3
90 << std::setw(10) << std::setprecision(3) << p4_unsubtr.Eta()
91 << std::setw(10) << std::setprecision(3) << p4_unsubtr.Phi()
92 << std::setw(10) << std::setprecision(3) << p4_unsubtr.E()*1e-3
93 << std::setw(10) << std::setprecision(3) << p4_unsubtr.M()*1e-3
94 << std::setw(12) << "After:"
95 << std::setw(10) << std::setprecision(3) << p4_subtr.Pt()*1e-3
96 << std::setw(10) << std::setprecision(3) << p4_subtr.Eta()
97 << std::setw(10) << std::setprecision(3) << p4_subtr.Phi()
98 << std::setw(10) << std::setprecision(3) << p4_subtr.E()*1e-3
99 << std::setw(10) << std::setprecision(3) << p4_subtr.M()*1e-3);
100
101 xAOD::JetFourMom_t jet4vec;
102 //if entire jet has negative E, do no subtraction but set to ghost scale
103 //prevents cases with large cancellations with small E but pT non-trivial
104 if(p4_subtr.E()/std::cosh(p4_subtr.Eta()) < E_min)
105 {
106 p4_subtr=p4_unsubtr;
107 p4_subtr*=1e-7;//ghost scale
108 }
109 jet4vec.SetCoordinates(p4_subtr.Pt(),p4_subtr.Eta(),p4_subtr.Phi(),p4_subtr.M());
110
111 (*ijet)->setJetP4(momentName(),jet4vec);
112
113 if(!momentOnly())
114 {
115 //hack for now to allow use of pp calib tool skipping pileup subtraction
116 //can be skipped in future if custom HI calibration configuration file exists
117 (*ijet)->setJetP4("JetPileupScaleMomentum", jet4vec );
118 (*ijet)->setJetP4(xAOD::JetEMScaleMomentum, jet4vec);
119
120 (*ijet)->setConstituentsSignalState(HIJetRec::subtractedConstitState());
121 }
122 }
123
124 return StatusCode::SUCCESS;
125}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
This file defines helper classes to deal with jet constituents.
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
bool msgLvl(const MSG::Level lvl) const
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
ToolHandle< IHISubtractorTool > m_subtractorTool
handle to IHISubtractorTool that determines the subtracted kinematics for each constituent
ToolHandle< IHIEventShapeMapTool > m_eventShapeMapTool
virtual StatusCode modify(xAOD::JetContainer &jets) const override
Implementing abstract methods from base.
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
SG::ReadHandleKey< xAOD::HIEventShapeContainer > m_eventShapeKey
Name of HIEventShapeContainer.
ToolHandle< IHIUEModulatorTool > m_modulatorTool
JetModifierBase(const std::string &myname)
Ctor.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
TLorentzVector FourMom_t
Definition of the 4-momentum type.
A vector of jet constituents at the scale used during jet finding.
constexpr xAOD::CaloCluster::State unsubtractedClusterState()
constexpr xAOD::JetConstitScale subtractedConstitState()
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
@ JetEMScaleMomentum
Definition JetTypes.h:28
HIEventShapeContainer_v2 HIEventShapeContainer
Define the latest version of the container.
JetContainer_v1 JetContainer
Definition of the current "jet container version".
HIEventShape_v2 HIEventShape
Definition of the latest event info version.
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17