ATLAS Offline Software
EnergyCorrelatorTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
11 {
12  declareProperty("Beta", m_Beta = 1.0);
13  declareProperty("BetaList", m_rawBetaVals = {});
14  declareProperty("DoC3", m_doC3 = false);
15  declareProperty("DoC4", m_doC4 = false);
16  declareProperty("DoDichroic", m_doDichroic = false);
17 }
18 
20  if(m_jetContainerName.empty()){
21  ATH_MSG_ERROR("EnergyCorrelatorTool needs to have its input jet container name configured!");
22  return StatusCode::FAILURE;
23  }
24 
27 
29  m_moments.emplace_back( 1.0, moments_t(1.0, m_prefix) );
30 
32  if( std::abs(m_Beta-1.0) > 1.0e-5 ) {
33 
35  ATH_MSG_WARNING( "The Beta property is deprecated, please use the BetaList property to provide a list of values");
36 
38  m_moments.emplace_back( m_Beta, moments_t(m_Beta, m_prefix) );
39 
40  }
41 
43  for( float beta : m_rawBetaVals ) {
44 
46  float betaFix = round( beta * 10.0 ) / 10.0;
47  if( std::abs(beta-betaFix) > 1.0e-5 ) ATH_MSG_DEBUG( "beta = " << beta << " has been rounded to " << betaFix );
48 
50  if( betaFix < 0.0 ) {
51  ATH_MSG_WARNING( "beta must be positive. Skipping beta = " << beta );
52  continue;
53  }
54 
56  m_moments.emplace_back( betaFix, moments_t(betaFix, m_prefix) );
57 
58  }
59 
61  for( auto const& moment : m_moments ) {
62  ATH_MSG_DEBUG( "Including beta = " << moment.first );
63  }
64 
67  if( m_doC4 ) m_doC3 = true;
68 
69  // Initialise WriteDecorHandleKeys
70  for( const auto& [beta, moment] : m_moments ) {
71  m_ECF1_Keys.emplace_back(m_jetContainerName + "." + moment.prefix +
72  "ECF1" + moment.suffix);
73  m_ECF2_Keys.emplace_back(m_jetContainerName + "." + moment.prefix +
74  "ECF2" + moment.suffix);
75  m_ECF3_Keys.emplace_back(m_jetContainerName + "." + moment.prefix +
76  "ECF3" + moment.suffix);
77  m_ECF4_Keys.emplace_back(m_jetContainerName + "." + moment.prefix +
78  "ECF4" + moment.suffix);
79  m_ECF5_Keys.emplace_back(m_jetContainerName + "." + moment.prefix +
80  "ECF5" + moment.suffix);
81  m_ECF1_ungroomed_Keys.emplace_back(m_jetContainerName + "." + moment.prefix +
82  "ECF1_ungroomed" + moment.suffix);
83  m_ECF2_ungroomed_Keys.emplace_back(m_jetContainerName + "." + moment.prefix +
84  "ECF2_ungroomed" + moment.suffix);
85  m_ECF3_ungroomed_Keys.emplace_back(m_jetContainerName + "." + moment.prefix +
86  "ECF3_ungroomed" + moment.suffix);
87  }
88 
89  ATH_CHECK(m_ECF1_Keys.initialize());
90  ATH_CHECK(m_ECF2_Keys.initialize());
91  ATH_CHECK(m_ECF3_Keys.initialize());
92  ATH_CHECK(m_ECF4_Keys.initialize());
93  ATH_CHECK(m_ECF5_Keys.initialize());
94  ATH_CHECK(m_ECF1_ungroomed_Keys.initialize());
95  ATH_CHECK(m_ECF2_ungroomed_Keys.initialize());
96  ATH_CHECK(m_ECF3_ungroomed_Keys.initialize());
97 
98  return StatusCode::SUCCESS;
99 
100 }
101 
103 
104  std::vector<SG::WriteDecorHandle<xAOD::JetContainer, float>> wdhs_ECF1;
105  std::vector<SG::WriteDecorHandle<xAOD::JetContainer, float>> wdhs_ECF2;
106  std::vector<SG::WriteDecorHandle<xAOD::JetContainer, float>> wdhs_ECF3;
107  std::vector<SG::WriteDecorHandle<xAOD::JetContainer, float>> wdhs_ECF4;
108  std::vector<SG::WriteDecorHandle<xAOD::JetContainer, float>> wdhs_ECF5;
109 
110  std::vector<SG::WriteDecorHandle<xAOD::JetContainer, float>> wdhs_ECF1_ungroomed;
111  std::vector<SG::WriteDecorHandle<xAOD::JetContainer, float>> wdhs_ECF2_ungroomed;
112  std::vector<SG::WriteDecorHandle<xAOD::JetContainer, float>> wdhs_ECF3_ungroomed;
113 
114  for(unsigned int i=0; i<m_moments.size(); i++) {
115  wdhs_ECF1.emplace_back(m_ECF1_Keys[i]);
116  wdhs_ECF2.emplace_back(m_ECF2_Keys[i]);
117  wdhs_ECF3.emplace_back(m_ECF3_Keys[i]);
118  wdhs_ECF4.emplace_back(m_ECF4_Keys[i]);
119  wdhs_ECF5.emplace_back(m_ECF5_Keys[i]);
120 
121  wdhs_ECF1_ungroomed.emplace_back(m_ECF1_ungroomed_Keys[i]);
122  wdhs_ECF2_ungroomed.emplace_back(m_ECF2_ungroomed_Keys[i]);
123  wdhs_ECF3_ungroomed.emplace_back(m_ECF3_ungroomed_Keys[i]);
124  }
125 
126  for(const xAOD::Jet* injet : jets){
127 
128  fastjet::PseudoJet jet;
129  fastjet::PseudoJet jet_ungroomed;
130 
132  bool calculate = SetupDecoration(jet,*injet);
133 
135  bool calculate_ungroomed = false;
136 
137  if( m_doDichroic ) {
138 
140  static const SG::ConstAccessor<ElementLink<xAOD::JetContainer> > ParentAcc ("Parent");
141  ElementLink<xAOD::JetContainer> parentLink = ParentAcc (*injet);
142 
144  if( !parentLink.isValid() ) {
145  ATH_MSG_ERROR( "Parent element link is not valid. Aborting" );
146  return StatusCode::FAILURE;
147  }
148 
149  const xAOD::Jet* parentJet = *(parentLink);
150  calculate_ungroomed = SetupDecoration(jet_ungroomed,*parentJet);
151 
152  }
153 
154  for(unsigned int i=0; i<m_moments.size(); i++) {
155  float beta = m_moments[i].first;
156 
157  float ECF1_value = -999;
158  float ECF2_value = -999;
159  float ECF3_value = -999;
160  float ECF4_value = -999;
161  float ECF5_value = -999;
162 
163  float ECF1_ungroomed_value = -999;
164  float ECF2_ungroomed_value = -999;
165  float ECF3_ungroomed_value = -999;
166 
167  if( calculate ) {
168 
169  JetSubStructureUtils::EnergyCorrelator ECF1(1, beta, JetSubStructureUtils::EnergyCorrelator::pt_R);
170  JetSubStructureUtils::EnergyCorrelator ECF2(2, beta, JetSubStructureUtils::EnergyCorrelator::pt_R);
171  JetSubStructureUtils::EnergyCorrelator ECF3(3, beta, JetSubStructureUtils::EnergyCorrelator::pt_R);
172 
173  ECF1_value = ECF1.result(jet);
174  ECF2_value = ECF2.result(jet);
175  ECF3_value = ECF3.result(jet);
176 
177  if( m_doC3 ) {
178  JetSubStructureUtils::EnergyCorrelator ECF4(4, beta, JetSubStructureUtils::EnergyCorrelator::pt_R);
179  ECF4_value = ECF4.result(jet);
180  }
181 
182  if( m_doC4 ) {
183  JetSubStructureUtils::EnergyCorrelator ECF5(5, beta, JetSubStructureUtils::EnergyCorrelator::pt_R);
184  ECF5_value = ECF5.result(jet);
185  }
186 
187  if( calculate_ungroomed ) {
188  ECF1_ungroomed_value = ECF1.result(jet_ungroomed);
189  ECF2_ungroomed_value = ECF2.result(jet_ungroomed);
190  ECF3_ungroomed_value = ECF3.result(jet_ungroomed);
191  }
192 
193  }
194 
195  wdhs_ECF1[i](*injet) = ECF1_value;
196  wdhs_ECF2[i](*injet) = ECF2_value;
197  wdhs_ECF3[i](*injet) = ECF3_value;
198  wdhs_ECF4[i](*injet) = ECF4_value;
199  wdhs_ECF5[i](*injet) = ECF5_value;
200 
201  wdhs_ECF1_ungroomed[i](*injet) = ECF1_ungroomed_value;
202  wdhs_ECF2_ungroomed[i](*injet) = ECF2_ungroomed_value;
203  wdhs_ECF3_ungroomed[i](*injet) = ECF3_ungroomed_value;
204  }
205 
206  }
207 
208  return StatusCode::SUCCESS;
209 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
EnergyCorrelatorTool::m_ECF3_Keys
SG::WriteDecorHandleKeyArray< xAOD::JetContainer > m_ECF3_Keys
Definition: EnergyCorrelatorTool.h:85
JetSubStructureUtils::EnergyCorrelator::result
virtual double result(const fastjet::PseudoJet &jet) const
Definition: EnergyCorrelator.h:20
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
defineDB.jets
jets
Definition: JetTagCalibration/share/defineDB.py:24
JetSubStructureUtils::EnergyCorrelator
Definition: EnergyCorrelator.h:14
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
EnergyCorrelatorTool::m_ECF4_Keys
SG::WriteDecorHandleKeyArray< xAOD::JetContainer > m_ECF4_Keys
Definition: EnergyCorrelatorTool.h:87
EnergyCorrelatorTool::m_doC4
bool m_doC4
Definition: EnergyCorrelatorTool.h:74
EnergyCorrelatorTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: EnergyCorrelatorTool.cxx:19
EnergyCorrelatorTool.h
EnergyCorrelatorTool::m_jetContainerName
Gaudi::Property< std::string > m_jetContainerName
Definition: EnergyCorrelatorTool.h:43
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition: AthCommonDataStore.h:145
JetSubStructureMomentToolsBase::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: JetSubStructureMomentToolsBase.cxx:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EnergyCorrelatorTool::moments_t
ECF moments structure.
Definition: EnergyCorrelatorTool.h:54
EnergyCorrelatorTool::m_rawBetaVals
std::vector< float > m_rawBetaVals
Definition: EnergyCorrelatorTool.h:75
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
EnergyCorrelatorTool::m_ECF1_Keys
SG::WriteDecorHandleKeyArray< xAOD::JetContainer > m_ECF1_Keys
Definition: EnergyCorrelatorTool.h:81
EnergyCorrelatorTool::EnergyCorrelatorTool
EnergyCorrelatorTool(const std::string &name)
Constructor.
Definition: EnergyCorrelatorTool.cxx:9
EMFourMomBuilder::calculate
void calculate(xAOD::Electron &electron)
Definition: EMFourMomBuilder.cxx:69
JetSubStructureMomentToolsBase::m_prefix
std::string m_prefix
Definition: JetSubStructureMomentToolsBase.h:30
JetSubStructureMomentToolsBase::SetupDecoration
bool SetupDecoration(fastjet::PseudoJet &pseudojet, const xAOD::Jet &jet, bool requireJetStructure=false) const
Definition: JetSubStructureMomentToolsBase.cxx:30
EnergyCorrelatorTool::m_ECF5_Keys
SG::WriteDecorHandleKeyArray< xAOD::JetContainer > m_ECF5_Keys
Definition: EnergyCorrelatorTool.h:89
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
EnergyCorrelatorTool::m_doC3
bool m_doC3
Definition: EnergyCorrelatorTool.h:73
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
EnergyCorrelatorTool::m_ECF2_ungroomed_Keys
SG::WriteDecorHandleKeyArray< xAOD::JetContainer > m_ECF2_ungroomed_Keys
Definition: EnergyCorrelatorTool.h:94
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
EnergyCorrelatorTool::m_Beta
float m_Beta
Configurable as properties.
Definition: EnergyCorrelatorTool.h:72
EnergyCorrelatorTool::m_moments
std::vector< std::pair< float, moments_t > > m_moments
Map of moment calculators and decorators using beta as the key.
Definition: EnergyCorrelatorTool.h:79
JetSubStructureMomentToolsBase
Definition: JetSubStructureMomentToolsBase.h:18
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
EnergyCorrelatorTool::m_ECF3_ungroomed_Keys
SG::WriteDecorHandleKeyArray< xAOD::JetContainer > m_ECF3_ungroomed_Keys
Definition: EnergyCorrelatorTool.h:96
MuonParameters::beta
@ beta
Definition: MuonParamDefs.h:144
EnergyCorrelator.h
EnergyCorrelatorTool::m_ECF1_ungroomed_Keys
SG::WriteDecorHandleKeyArray< xAOD::JetContainer > m_ECF1_ungroomed_Keys
Definition: EnergyCorrelatorTool.h:92
EnergyCorrelatorTool::modify
StatusCode modify(xAOD::JetContainer &jets) const override
Loop over calls to modifyJet.
Definition: EnergyCorrelatorTool.cxx:102
EnergyCorrelatorTool::m_ECF2_Keys
SG::WriteDecorHandleKeyArray< xAOD::JetContainer > m_ECF2_Keys
Definition: EnergyCorrelatorTool.h:83
EnergyCorrelatorTool::m_doDichroic
bool m_doDichroic
Vector of input values before cleaning.
Definition: EnergyCorrelatorTool.h:76