Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
JetTileCorrectionAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // JetTileCorrection includes
6 #include "JetTileCorrectionAlg.h"
8 
9 // EDM include(s):
10 #include "xAODJet/JetContainer.h"
11 
13 #include "AsgTools/ToolStore.h"
14 #include "AthContainers/Accessor.h"
15 
16 // Global accessors and decorators
17 static const SG::Accessor<unsigned int> acc_tileok("TileStatus");
18 static const SG::Accessor<float> acc_ptraw("Ptraw");
19 
20 using namespace CP;
21 
22 JetTileCorrectionAlg::JetTileCorrectionAlg( const std::string& name, ISvcLocator* pSvcLocator )
23  : AthAnalysisAlgorithm( name, pSvcLocator )
24  , m_jtcTool( "CP::JetTileCorrectionTool/JetTileCorrectionTool", this )
25 {
26 
27  declareProperty( "JetContainer", m_jetKey = "AntiKt4EMTopoJets" );
28  declareProperty( "JetTileCorrectionTool", m_jtcTool );
29 }
30 
31 
33 
34 
36  ATH_MSG_INFO ("Initializing " << name() << "...");
37 
38  return StatusCode::SUCCESS;
39 }
40 
42  ATH_MSG_INFO ("First execute " << name() << "...");
43 
44  ATH_CHECK( m_jtcTool.retrieve() );
45 
46  return StatusCode::SUCCESS;
47 }
48 
49 
51 
52  ATH_MSG_INFO ("Finalizing " << name() << "...");
53 
54  return StatusCode::SUCCESS;
55 }
56 
58  ATH_MSG_DEBUG ("Executing " << name() << "...");
59 
60  // Retrieve the jets:
61  const xAOD::JetContainer* jets = nullptr;
63 
64  ATH_MSG_INFO("--------------------");
65  ATH_MSG_INFO( "Number of jets: " << jets->size() );
66 
67  // Loop over them:
68  xAOD::JetContainer::const_iterator jet_itr = jets->begin();
70  for( ; jet_itr != jet_end; ++jet_itr ){
71 
72  //if ((*jet_itr)->pt() < 20000. || fabs((*jet_itr)->eta()) > 2.8) continue;
73 
74  // copy constant objects to non-constant
75  xAOD::Jet* jet = nullptr;
76  jet = new xAOD::Jet();
77  jet->makePrivateStore( **jet_itr );
78 
79  //--- apply tile dead module correction
80  CP::CorrectionCode retCode = m_jtcTool->applyCorrection(*jet);
81 
83  ATH_MSG_VERBOSE("No valid pt/eta range. No correction applied.");
84  }
85  else if( retCode != CP::CorrectionCode::Ok ){
86  ATH_MSG_ERROR("Failed to apply JetTileCorrection!");
87  //return StatusCode::FAILURE;
88  }
89 
90  unsigned int j_status = acc_tileok(*jet);
91  std::string str_status="";
92 
93  if(j_status == (unsigned int)JTC::TS::GOOD)
94  str_status = "NotAffected";
95  else if(j_status == (unsigned int)JTC::TS::EDGE)
96  str_status = "EdgeAffected";
97  else if(j_status == (unsigned int)JTC::TS::CORE)
98  str_status = "CoreAffected";
99  else
100  str_status = "Unknown";
101 
102  ATH_MSG_INFO("Jet status : " << str_status << ", Pt raw = " << acc_ptraw(*jet)*0.001 << " GeV, Pt corrected = " << jet->pt()*0.001 << " GeV");
103  }
104  ATH_MSG_INFO("--------------------\n");
105 
106  return StatusCode::SUCCESS;
107 }
108 
109 
110 
111 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
AthAnalysisAlgorithm
Definition: AthAnalysisAlgorithm.h:34
JetTileCorrectionTool.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
defineDB.jets
jets
Definition: JetTagCalibration/share/defineDB.py:24
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:49
CP::JetTileCorrectionAlg::m_jtcTool
ToolHandle< IJetTileCorrectionTool > m_jtcTool
Definition: JetTileCorrectionAlg.h:30
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition: CorrectionCode.h:37
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CP::JetTileCorrectionAlg::finalize
virtual StatusCode finalize()
Definition: JetTileCorrectionAlg.cxx:50
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CP::JetTileCorrectionAlg::execute
virtual StatusCode execute()
Definition: JetTileCorrectionAlg.cxx:57
JetTileCorrectionAlg.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
JTC::TS::EDGE
@ EDGE
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Accessor.h
Helper class to provide type-safe access to aux data.
CP::JetTileCorrectionAlg::initialize
virtual StatusCode initialize()
Definition: JetTileCorrectionAlg.cxx:35
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
CP::JetTileCorrectionAlg::m_jetKey
std::string m_jetKey
Definition: JetTileCorrectionAlg.h:28
JetContainer.h
CP::JetTileCorrectionAlg::~JetTileCorrectionAlg
virtual ~JetTileCorrectionAlg()
CP::JetTileCorrectionAlg::JetTileCorrectionAlg
JetTileCorrectionAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: JetTileCorrectionAlg.cxx:22
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
JTC::TS::GOOD
@ GOOD
ToolStore.h
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition: Event/xAOD/xAODJet/xAODJet/Jet.h:17
JTC::TS::CORE
@ CORE
CP::JetTileCorrectionAlg::firstExecute
virtual StatusCode firstExecute()
Function called when first execute is encountered user can read event information with evtStore()
Definition: JetTileCorrectionAlg.cxx:41