ATLAS Offline Software
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 
9 #include "xAODTracking/Vertex.h"
11 
12 #include "StoreGate/ReadHandle.h"
13 #include "StoreGate/WriteHandle.h"
14 
15 //**********************************************************************
16 
19 {
20 }
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 
72  xAOD::IParticle::FourMom_t p4_unsubtr;
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 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
HIJetConstituentSubtractionTool::m_subtractorTool
ToolHandle< IHISubtractorTool > m_subtractorTool
handle to IHISubtractorTool that determines the subtracted kinematics for each constituent
Definition: HIJetConstituentSubtractionTool.h:81
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
HIJetConstituentSubtractionTool::m_eventShapeMapTool
ToolHandle< IHIEventShapeMapTool > m_eventShapeMapTool
Definition: HIJetConstituentSubtractionTool.h:83
HIJetConstituentSubtractionTool::HIJetConstituentSubtractionTool
HIJetConstituentSubtractionTool(const std::string &t)
Definition: HIJetConstituentSubtractionTool.cxx:17
HIJetConstituentSubtractionTool::m_eventShapeKey
SG::ReadHandleKey< xAOD::HIEventShapeContainer > m_eventShapeKey
Name of HIEventShapeContainer.
Definition: HIJetConstituentSubtractionTool.h:64
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
HIJetConstituentSubtractionTool.h
JetConstituentVector.h
This file defines helper classes to deal with jet constituents.
xAOD::IParticle::FourMom_t
TLorentzVector FourMom_t
Definition of the 4-momentum type.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:69
HIJetConstituentSubtractionTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: HIJetConstituentSubtractionTool.cxx:23
HIJetConstituentSubtractionTool::m_modulatorTool
ToolHandle< IHIUEModulatorTool > m_modulatorTool
Definition: HIJetConstituentSubtractionTool.h:82
xAOD::HIEventShape_v2
Interface class for the HI reconstruction EDM.
Definition: HIEventShape_v2.h:32
WriteHandle.h
Handle class for recording to StoreGate.
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
beamspotman.n
n
Definition: beamspotman.py:731
HIJetConstituentSubtractionTool::momentOnly
bool momentOnly() const
Definition: HIJetConstituentSubtractionTool.h:94
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::ReadHandle::get
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
HIEventShapeContainer.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
Vertex.h
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::JetEMScaleMomentum
@ JetEMScaleMomentum
Definition: JetTypes.h:28
xAOD::JetFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition: JetTypes.h:17
HIJetConstituentSubtractionTool::momentName
const std::string & momentName() const
Definition: HIJetConstituentSubtractionTool.h:93
HIJetConstituentSubtractionTool::modify
virtual StatusCode modify(xAOD::JetContainer &jets) const override
Implementing abstract methods from base.
Definition: HIJetConstituentSubtractionTool.cxx:33
HIEventShapeIndex
Definition: HIEventShapeIndex.h:16
VertexContainer.h
DEBUG
#define DEBUG
Definition: page_access.h:11
HIJetRec::unsubtractedClusterState
constexpr xAOD::CaloCluster::State unsubtractedClusterState()
Definition: HIJetRecDefs.h:25
HIJetRec::subtractedConstitState
constexpr xAOD::JetConstitScale subtractedConstitState()
Definition: HIJetRecDefs.h:22
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
xAOD::JetConstituentVector
A vector of jet constituents at the scale used during jet finding.
Definition: JetConstituentVector.h:117
HIJetRecDefs.h
ReadHandle.h
Handle class for reading from StoreGate.
JetModifierBase
Definition: JetModifierBase.h:22
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26