ATLAS Offline Software
JetTileCorrectionAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 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 
15 // Global accessors and decorators
16 static SG::AuxElement::Accessor<unsigned int> acc_tileok("TileStatus");
17 static SG::AuxElement::Accessor<float> acc_ptraw("Ptraw");
18 
19 using namespace CP;
20 
21 JetTileCorrectionAlg::JetTileCorrectionAlg( const std::string& name, ISvcLocator* pSvcLocator )
22  : AthAnalysisAlgorithm( name, pSvcLocator )
23  , m_jtcTool( "CP::JetTileCorrectionTool/JetTileCorrectionTool", this )
24 {
25 
26  declareProperty( "JetContainer", m_jetKey = "AntiKt4EMTopoJets" );
27  declareProperty( "JetTileCorrectionTool", m_jtcTool );
28 }
29 
30 
32 
33 
35  ATH_MSG_INFO ("Initializing " << name() << "...");
36 
37  return StatusCode::SUCCESS;
38 }
39 
41  ATH_MSG_INFO ("First execute " << name() << "...");
42 
43  ATH_CHECK( m_jtcTool.retrieve() );
44 
45  return StatusCode::SUCCESS;
46 }
47 
48 
50 
51  ATH_MSG_INFO ("Finalizing " << name() << "...");
52 
53  return StatusCode::SUCCESS;
54 }
55 
57  ATH_MSG_DEBUG ("Executing " << name() << "...");
58 
59  // Retrieve the jets:
60  const xAOD::JetContainer* jets = nullptr;
62 
63  ATH_MSG_INFO("--------------------");
64  ATH_MSG_INFO( "Number of jets: " << jets->size() );
65 
66  // Loop over them:
67  xAOD::JetContainer::const_iterator jet_itr = jets->begin();
69  for( ; jet_itr != jet_end; ++jet_itr ){
70 
71  //if ((*jet_itr)->pt() < 20000. || fabs((*jet_itr)->eta()) > 2.8) continue;
72 
73  // copy constant objects to non-constant
74  xAOD::Jet* jet = nullptr;
75  jet = new xAOD::Jet();
76  jet->makePrivateStore( **jet_itr );
77 
78  //--- apply tile dead module correction
79  CP::CorrectionCode retCode = m_jtcTool->applyCorrection(*jet);
80 
82  ATH_MSG_VERBOSE("No valid pt/eta range. No correction applied.");
83  }
84  else if( retCode != CP::CorrectionCode::Ok ){
85  ATH_MSG_ERROR("Failed to apply JetTileCorrection!");
86  //return StatusCode::FAILURE;
87  }
88 
89  unsigned int j_status = acc_tileok(*jet);
90  std::string str_status="";
91 
92  if(j_status == (unsigned int)JTC::TS::GOOD)
93  str_status = "NotAffected";
94  else if(j_status == (unsigned int)JTC::TS::EDGE)
95  str_status = "EdgeAffected";
96  else if(j_status == (unsigned int)JTC::TS::CORE)
97  str_status = "CoreAffected";
98  else
99  str_status = "Unknown";
100 
101  ATH_MSG_INFO("Jet status : " << str_status << ", Pt raw = " << acc_ptraw(*jet)*0.001 << " GeV, Pt corrected = " << jet->pt()*0.001 << " GeV");
102  }
103  ATH_MSG_INFO("--------------------\n");
104 
105  return StatusCode::SUCCESS;
106 }
107 
108 
109 
110 
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:66
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
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:48
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:49
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:56
JetTileCorrectionAlg.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
JTC::TS::EDGE
@ EDGE
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CP::JetTileCorrectionAlg::initialize
virtual StatusCode initialize()
Definition: JetTileCorrectionAlg.cxx:34
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:21
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
JTC::TS::GOOD
@ GOOD
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
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:40