ATLAS Offline Software
EnergyCorrelatorGeneralizedRatiosTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
10 {
11  declareProperty("BetaList", m_rawBetaVals = {});
12  declareProperty("DoM3", m_doM3 = false);
13  declareProperty("DoN3", m_doN3 = false);
14  declareProperty("DoLSeries", m_doLSeries = false);
15  declareProperty("DoDichroic", m_doDichroic = false);
16 }
17 
19 
22 
24  m_moments.emplace( 1.0, moments_t(1.0, m_prefix) );
25 
27  for( float beta : m_rawBetaVals ) {
28 
30  float betaFix = round( beta * 10.0 ) / 10.0;
31  if( std::abs(beta-betaFix) > 1.0e-5 ) ATH_MSG_DEBUG( "beta = " << beta << " has been rounded to " << betaFix );
32 
34  if( betaFix < 0.0 ) {
35  ATH_MSG_WARNING( "beta must be positive. Skipping beta = " << beta );
36  continue;
37  }
38 
40  m_moments.emplace( betaFix, moments_t(betaFix, m_prefix) );
41 
42  }
43 
45  for( auto const& moment : m_moments ) {
46  ATH_MSG_DEBUG( "Including beta = " << moment.first );
47  }
48 
50  m_acc_ECFG_2_1_2 = std::make_unique< SG::AuxElement::Accessor<float> >(m_prefix+"ECFG_2_1_2");
51  m_acc_ECFG_3_1_1 = std::make_unique< SG::AuxElement::Accessor<float> >(m_prefix+"ECFG_3_1_1");
52  m_acc_ECFG_3_2_1 = std::make_unique< SG::AuxElement::Accessor<float> >(m_prefix+"ECFG_3_2_1");
53  m_acc_ECFG_3_2_2 = std::make_unique< SG::AuxElement::Accessor<float> >(m_prefix+"ECFG_3_2_2");
54  m_acc_ECFG_3_3_1 = std::make_unique< SG::AuxElement::Accessor<float> >(m_prefix+"ECFG_3_3_1");
55  m_acc_ECFG_4_2_2 = std::make_unique< SG::AuxElement::Accessor<float> >(m_prefix+"ECFG_4_2_2");
56  m_acc_ECFG_4_4_1 = std::make_unique< SG::AuxElement::Accessor<float> >(m_prefix+"ECFG_4_4_1");
57 
59  m_dec_L1 = std::make_unique< SG::AuxElement::Decorator<float> >(m_prefix+"L1");
60  m_dec_L2 = std::make_unique< SG::AuxElement::Decorator<float> >(m_prefix+"L2");
61  m_dec_L3 = std::make_unique< SG::AuxElement::Decorator<float> >(m_prefix+"L3");
62  m_dec_L4 = std::make_unique< SG::AuxElement::Decorator<float> >(m_prefix+"L4");
63  m_dec_L5 = std::make_unique< SG::AuxElement::Decorator<float> >(m_prefix+"L5");
64 
65  return StatusCode::SUCCESS;
66 
67 }
68 
70 
71  for( auto const& moment : m_moments ) {
72 
73  std::string suffix = moment.second.suffix;
74 
76  if( !moment.second.acc_ECFG_2_1->isAvailable(jet) ) {
77  ATH_MSG_WARNING( "Energy correlation function " << m_prefix << "ECFG_2_1" << suffix << "' is not available. Exiting." );
78  return 1;
79  }
80 
81  if( !moment.second.acc_ECFG_3_2->isAvailable(jet) ) {
82  ATH_MSG_WARNING( "Energy correlation function " << m_prefix << "ECFG_3_2" << suffix << "' is not available. Exiting." );
83  return 1;
84  }
85 
86  if( m_doM3 || m_doN3 ) {
87  if( !moment.second.acc_ECFG_3_1->isAvailable(jet) ) {
88  ATH_MSG_WARNING( "Energy correlation function " << m_prefix << "ECFG_3_1" << suffix << "' is not available. Exiting." );
89  return 1;
90  }
91  }
92 
93  if( m_doM3 ) {
94  if( !moment.second.acc_ECFG_4_1->isAvailable(jet) ) {
95  ATH_MSG_WARNING( "Energy correlation function " << m_prefix << "ECFG_4_1" << suffix << "' is not available. Exiting." );
96  return 1;
97  }
98  }
99 
100  if( m_doN3 ) {
101  if( !moment.second.acc_ECFG_4_2->isAvailable(jet) ) {
102  ATH_MSG_WARNING( "Energy correlation function " << m_prefix << "ECFG_4_2" << suffix << "' is not available. Exiting." );
103  return 1;
104  }
105  }
106 
107  if( m_doDichroic ) {
108  if( !moment.second.acc_ECFG_2_1_ungroomed->isAvailable(jet) ) {
109  ATH_MSG_WARNING( "Energy correlation function " << m_prefix << "ECFG_2_1_ungroomed" << suffix << "' is not available. Exiting." );
110  return 1;
111  }
112 
113  if( !moment.second.acc_ECFG_3_1_ungroomed->isAvailable(jet) ) {
114  ATH_MSG_WARNING( "Energy correlation function " << m_prefix << "ECFG_3_1_ungroomed" << suffix << "' is not available. Exiting." );
115  return 1;
116  }
117 
118  if( !moment.second.acc_ECFG_3_2_ungroomed->isAvailable(jet) ) {
119  ATH_MSG_WARNING( "Energy correlation function " << m_prefix << "ECFG_3_2_ungroomed" << suffix << "' is not available. Exiting." );
120  return 1;
121  }
122  }
123 
124  float ecfg_2_1 = (*moment.second.acc_ECFG_2_1)(jet);
125  float ecfg_3_1 = (*moment.second.acc_ECFG_3_1)(jet);
126  float ecfg_3_2 = (*moment.second.acc_ECFG_3_2)(jet);
127  float ecfg_4_1 = (*moment.second.acc_ECFG_4_2)(jet);
128  float ecfg_4_2 = (*moment.second.acc_ECFG_4_2)(jet);
129 
130  float ecfg_2_1_ungroomed = -999.0;
131  float ecfg_3_1_ungroomed = -999.0;
132  float ecfg_3_2_ungroomed = -999.0;
133 
134  if( m_doDichroic ) {
135  ecfg_2_1_ungroomed = (*moment.second.acc_ECFG_2_1_ungroomed)(jet);
136  ecfg_3_1_ungroomed = (*moment.second.acc_ECFG_3_1_ungroomed)(jet);
137  ecfg_3_2_ungroomed = (*moment.second.acc_ECFG_3_2_ungroomed)(jet);
138  }
139 
140  float M2 = -999.0;
141  float M3 = -999.0;
142 
143  float N2 = -999.0;
144  float N3 = -999.0;
145 
146  float M2_dichroic = -999.0;
147  float N2_dichroic = -999.0;
148 
150  if( ecfg_2_1 > 1e-8 )
151  {
152 
153  M2 = ecfg_3_1 / ecfg_2_1;
154 
155  if( ecfg_3_1_ungroomed > 1e-8 )
156  {
157  M2_dichroic = ecfg_3_1_ungroomed / ecfg_2_1;
158  }
159 
160  }
161 
163  if( m_doM3 && ecfg_3_1 > 1e-8 )
164  {
165  M3 = ecfg_4_1 / ecfg_3_1;
166  }
167 
169  if( ecfg_2_1 > 1e-8 )
170  {
171 
172  N2 = ecfg_3_2 / pow( ecfg_2_1, 2.0 );
173 
174  if( ecfg_3_2_ungroomed > 1e-8 && ecfg_2_1_ungroomed > 1e-8 )
175  {
176  N2_dichroic = ecfg_3_2_ungroomed / ( ecfg_2_1_ungroomed * ecfg_2_1 );
177  }
178 
179  }
180 
182  if( m_doN3 && ecfg_3_1 > 1e-8 )
183  {
184  N3 = ecfg_4_2 / pow( ecfg_3_1, 2.0 );
185  }
186 
187  (*moment.second.dec_M2)(jet) = M2;
188  (*moment.second.dec_M3)(jet) = M3;
189 
190  (*moment.second.dec_N2)(jet) = N2;
191  (*moment.second.dec_N3)(jet) = N3;
192 
193  (*moment.second.dec_M2_dichroic)(jet) = M2_dichroic;
194  (*moment.second.dec_N2_dichroic)(jet) = N2_dichroic;
195 
196  }
197 
213  float L1 = -999.0;
214  float L2 = -999.0;
215  float L3 = -999.0;
216  float L4 = -999.0;
217  float L5 = -999.0;
218 
219  if( m_doLSeries ) {
220 
221  if( !m_acc_ECFG_2_1_2->isAvailable(jet) ||
222  !m_acc_ECFG_3_1_1->isAvailable(jet) ||
223  !m_acc_ECFG_3_2_1->isAvailable(jet) ||
224  !m_acc_ECFG_3_2_2->isAvailable(jet) ||
225  !m_acc_ECFG_3_3_1->isAvailable(jet) ||
226  !m_acc_ECFG_4_2_2->isAvailable(jet) ||
227  !m_acc_ECFG_4_4_1->isAvailable(jet) ) {
228  ATH_MSG_WARNING("L series energy correlation functions with prefix '" << m_prefix << "' are not all available. Exiting..");
229  return 1;
230  }
231 
232  float ecfg_2_1_2 = (*m_acc_ECFG_2_1_2)(jet);
233  float ecfg_3_1_1 = (*m_acc_ECFG_3_1_1)(jet);
234  float ecfg_3_2_1 = (*m_acc_ECFG_3_2_1)(jet);
235  float ecfg_3_2_2 = (*m_acc_ECFG_3_2_2)(jet);
236  float ecfg_3_3_1 = (*m_acc_ECFG_3_3_1)(jet);
237  float ecfg_4_2_2 = (*m_acc_ECFG_4_2_2)(jet);
238  float ecfg_4_4_1 = (*m_acc_ECFG_4_4_1)(jet);
239 
240  if( ecfg_2_1_2 > 1e-8 )
241  {
242  L1 = ecfg_3_2_1 / pow( ecfg_2_1_2, 1.0 );
243  L2 = ecfg_3_3_1 / pow( ecfg_2_1_2, (3.0/2.0) );
244  }
245 
246  if( ecfg_3_3_1 > 1e-8 )
247  {
248  L3 = ecfg_3_1_1 / pow( ecfg_3_3_1, (1.0/3.0) );
249  L4 = ecfg_3_2_2 / pow( ecfg_3_3_1, (4.0/3.0) );
250  }
251 
252  if( ecfg_4_4_1 > 1e-8 )
253  {
254  L5 = ecfg_4_2_2 / pow( ecfg_4_4_1, 1.0 );
255  }
256 
257 
258  }
259 
260  (*m_dec_L1)(jet) = L1;
261  (*m_dec_L2)(jet) = L2;
262  (*m_dec_L3)(jet) = L3;
263  (*m_dec_L4)(jet) = L4;
264  (*m_dec_L5)(jet) = L5;
265 
266  return 0;
267 
268 }
Trk::L2
@ L2
Definition: AlignModuleList.h:32
dqt_zlumi_pandas.N2
N2
Definition: dqt_zlumi_pandas.py:318
hotSpotInTAG.suffix
string suffix
Definition: hotSpotInTAG.py:186
EnergyCorrelatorGeneralizedRatiosTool::m_dec_L4
std::unique_ptr< SG::AuxElement::Decorator< float > > m_dec_L4
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:66
EnergyCorrelatorGeneralizedRatiosTool::m_doLSeries
bool m_doLSeries
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:46
EnergyCorrelatorGeneralizedRatiosTool::m_rawBetaVals
std::vector< float > m_rawBetaVals
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:47
EnergyCorrelatorGeneralizedRatiosTool.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
EnergyCorrelatorGeneralizedRatiosTool::m_acc_ECFG_4_4_1
std::unique_ptr< SG::AuxElement::ConstAccessor< float > > m_acc_ECFG_4_4_1
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:60
EnergyCorrelatorGeneralizedRatiosTool::modifyJet
int modifyJet(xAOD::Jet &jet) const override
Modify a single jet. This is obsolete and set to be removed.
Definition: EnergyCorrelatorGeneralizedRatiosTool.cxx:69
Trk::L1
@ L1
Definition: AlignModuleList.h:32
EnergyCorrelatorGeneralizedRatiosTool::m_dec_L3
std::unique_ptr< SG::AuxElement::Decorator< float > > m_dec_L3
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:65
EnergyCorrelatorGeneralizedRatiosTool::m_acc_ECFG_2_1_2
std::unique_ptr< SG::AuxElement::ConstAccessor< float > > m_acc_ECFG_2_1_2
ConstAccessors for L-series ECFs.
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:54
EnergyCorrelatorGeneralizedRatiosTool::m_acc_ECFG_3_2_1
std::unique_ptr< SG::AuxElement::ConstAccessor< float > > m_acc_ECFG_3_2_1
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:56
EnergyCorrelatorGeneralizedRatiosTool::m_acc_ECFG_3_3_1
std::unique_ptr< SG::AuxElement::ConstAccessor< float > > m_acc_ECFG_3_3_1
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:58
EnergyCorrelatorGeneralizedRatiosTool::m_moments
std::map< float, moments_t > m_moments
Map of moment accessors and decorators using beta as the key.
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:51
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
EnergyCorrelatorGeneralizedRatiosTool::m_acc_ECFG_3_1_1
std::unique_ptr< SG::AuxElement::ConstAccessor< float > > m_acc_ECFG_3_1_1
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:55
EnergyCorrelatorGeneralizedRatiosTool::moments_t
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:79
EnergyCorrelatorGeneralizedRatiosTool::m_dec_L5
std::unique_ptr< SG::AuxElement::Decorator< float > > m_dec_L5
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:67
EnergyCorrelatorGeneralizedRatiosTool::m_doN3
bool m_doN3
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:45
Trk::L3
@ L3
Definition: AlignModuleList.h:32
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
EnergyCorrelatorGeneralizedRatiosTool::m_dec_L1
std::unique_ptr< SG::AuxElement::Decorator< float > > m_dec_L1
Decorator for L-series ECFRs.
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:63
JetSubStructureMomentToolsBase::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: JetSubStructureMomentToolsBase.cxx:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EnergyCorrelatorGeneralizedRatiosTool::m_acc_ECFG_3_2_2
std::unique_ptr< SG::AuxElement::ConstAccessor< float > > m_acc_ECFG_3_2_2
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:57
EnergyCorrelatorGeneralizedRatiosTool::m_doDichroic
bool m_doDichroic
Vector of input values before cleaning.
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:48
EnergyCorrelatorGeneralizedRatiosTool::EnergyCorrelatorGeneralizedRatiosTool
EnergyCorrelatorGeneralizedRatiosTool(const std::string &name)
Constructor.
Definition: EnergyCorrelatorGeneralizedRatiosTool.cxx:8
EnergyCorrelatorGeneralizedRatiosTool::m_dec_L2
std::unique_ptr< SG::AuxElement::Decorator< float > > m_dec_L2
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:64
JetSubStructureMomentToolsBase::m_prefix
std::string m_prefix
Definition: JetSubStructureMomentToolsBase.h:30
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
EnergyCorrelatorGeneralizedRatiosTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: EnergyCorrelatorGeneralizedRatiosTool.cxx:18
EnergyCorrelatorGeneralizedRatiosTool::m_doM3
bool m_doM3
Configurable as properties.
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:41
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
EnergyCorrelatorGeneralized.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
JetSubStructureMomentToolsBase
Definition: JetSubStructureMomentToolsBase.h:18
MuonParameters::beta
@ beta
Definition: MuonParamDefs.h:144
EnergyCorrelatorGeneralizedRatiosTool::m_acc_ECFG_4_2_2
std::unique_ptr< SG::AuxElement::ConstAccessor< float > > m_acc_ECFG_4_2_2
Definition: EnergyCorrelatorGeneralizedRatiosTool.h:59