ATLAS Offline Software
JetLArHVTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
9 
10 JetLArHVTool::JetLArHVTool(const std::string& name)
11  : asg::AsgTool(name)
12 {
13 }
14 
15 
17 {
18  if(m_fracKey.key().at(0) == '.' || m_nCellKey.key().at(0) == '.'){
19  ATH_MSG_ERROR("JetLArHVTool needs to have its input jet container name configured!");
20  return StatusCode::FAILURE;
21  }
22 
23  // Prepend jet container name
24  m_fracKey = m_jetContainerName + "." + m_fracKey.key();
26 
27  ATH_CHECK(m_fracKey.initialize());
28  ATH_CHECK(m_nCellKey.initialize());
29  return StatusCode::SUCCESS;
30 }
31 
32 
34 {
35 
38 
39  for(const xAOD::Jet* jet : jets){
40 
41  double energyHVaff=0;
42  int numCellsHVaff=0;
43 
44  // loop over raw constituents. Look for clusters
45  size_t num = jet->numConstituents();
46  for(size_t i=0;i<num;i++) {
47  const xAOD::CaloCluster * cl = dynamic_cast<const xAOD::CaloCluster *>(jet->rawConstituent(i));
48  if( !cl) continue;
49 
50  double m;
51  if(cl->retrieveMoment(xAOD::CaloCluster::ENG_BAD_HV_CELLS,m) ) energyHVaff += m;
52  if(cl->retrieveMoment(xAOD::CaloCluster::N_BAD_HV_CELLS, m) ) numCellsHVaff += m;
53  }
54 
55  double emE = jet->jetP4(xAOD::JetEMScaleMomentum).E();
56  // set the attributes
57  fracHandle(*jet) = energyHVaff / emE;
58  nCellHandle(*jet) = numCellsHVaff;
59  }
60  return StatusCode::SUCCESS;
61 }
62 
63 
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
xAOD::CaloCluster_v1::ENG_BAD_HV_CELLS
@ ENG_BAD_HV_CELLS
Total em-scale energy of cells with bad HV in this cluster.
Definition: CaloCluster_v1.h:167
JetLArHVTool::m_jetContainerName
Gaudi::Property< std::string > m_jetContainerName
Definition: JetLArHVTool.h:40
asg
Definition: DataHandleTestTool.h:28
JetLArHVTool::decorate
virtual StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
Definition: JetLArHVTool.cxx:33
JetLArHVTool::m_nCellKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_nCellKey
Definition: JetLArHVTool.h:45
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
JetLArHVTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: JetLArHVTool.cxx:16
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloCluster.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
WriteDecorHandle.h
Handle class for adding a decoration to an object.
xAOD::JetEMScaleMomentum
@ JetEMScaleMomentum
Definition: JetTypes.h:28
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
JetLArHVTool::m_fracKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_fracKey
Definition: JetLArHVTool.h:43
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
xAOD::CaloCluster_v1::N_BAD_HV_CELLS
@ N_BAD_HV_CELLS
number of cells with bad HV
Definition: CaloCluster_v1.h:168
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
JetLArHVTool.h
JetLArHVTool::JetLArHVTool
JetLArHVTool(const std::string &name)
Definition: JetLArHVTool.cxx:10
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26