ATLAS Offline Software
Loading...
Searching...
No Matches
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
10JetLArHVTool::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
26
27 ATH_CHECK(m_fracKey.initialize());
28 ATH_CHECK(m_nCellKey.initialize());
29 return StatusCode::SUCCESS;
30}
31
32
33StatusCode JetLArHVTool::decorate(const xAOD::JetContainer& jets) const
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
Handle class for adding a decoration to an object.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_fracKey
Gaudi::Property< std::string > m_jetContainerName
virtual StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
JetLArHVTool(const std::string &name)
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_nCellKey
Handle class for adding a decoration to an object.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
@ ENG_BAD_HV_CELLS
Total em-scale energy of cells with bad HV in this cluster.
@ N_BAD_HV_CELLS
number of cells with bad HV
Jet_v1 Jet
Definition of the current "jet version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
@ JetEMScaleMomentum
Definition JetTypes.h:28
JetContainer_v1 JetContainer
Definition of the current "jet container version".