ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetMomentTools
Root
JetCaloQualityTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include "
JetUtils/JetCaloQualityUtils.h
"
7
8
#include "
JetMomentTools/JetCaloQualityTool.h
"
9
#include "
xAODJet/JetAccessorMap.h
"
10
#include "
AsgDataHandles/WriteDecorHandle.h
"
11
12
13
#include <iostream>
14
#include <iomanip>
15
using namespace
std
;
16
using namespace
jet
;
17
18
19
JetCaloQualityTool::JetCaloQualityTool
(
const
std::string& name)
20
:
asg
::
AsgTool
(name)
21
{
22
}
23
24
25
StatusCode
JetCaloQualityTool::decorate
(
const
xAOD::JetContainer
& jets)
const
26
{
27
28
if
(
msgLvl
(MSG::DEBUG))
msg
(MSG::DEBUG) <<
"Inside decorate() method"
<<
endmsg
;
29
30
//bool checkedContainer = false;
31
const
size_t
nDecorations =
m_writeDecorKeys
.size();
32
33
if
(
m_doFracSamplingMax
){
34
// Special case : we want to store more than 1 value (max sampling AND its index).
35
// AND there's no code available for direct cell access.
36
// So we just use a direct function instead of a calculator for now.
37
38
// We specifically put these in last earlier
39
SG::WriteDecorHandle<xAOD::JetContainer, float>
maxHandle(
m_writeDecorKeys
.at(nDecorations-2));
40
SG::WriteDecorHandle<xAOD::JetContainer, int>
samplingHandle(
m_writeDecorKeys
.at(nDecorations-1));
41
42
for
(
const
xAOD::Jet
*
jet
: jets){
43
int
sampling=-1;
44
double
fracSamplingMax=
JetCaloQualityUtils::fracSamplingMax
(
jet
,sampling);
45
ATH_MSG_VERBOSE
(
"Setting "
<<
xAOD::JetAttribute::FracSamplingMax
<<
" to "
<< fracSamplingMax);
46
maxHandle(*
jet
) = fracSamplingMax;
47
samplingHandle(*
jet
) = sampling;
48
}
49
}
50
51
// Do all other calculations
52
for
(
const
xAOD::Jet
*
jet
: jets){
53
54
std::vector<double> results =
m_calcProcessor
->process(
jet
);
55
56
// store them in the jet
57
for
(
size_t
i=0;i <
m_calcProcessor
->numCalculators();i++) {
58
// We inserted WriteDecorKeys in the same order as calculators
59
SG::WriteDecorHandle<xAOD::JetContainer, float>
decHandle(
m_writeDecorKeys
.at(i));
60
61
const
JetCaloCalculator
* calc =
m_calcProcessor
->at(i);
62
ATH_MSG_DEBUG
( calc->name() <<
" -> "
<<results[i] );
63
decHandle(*
jet
) = results[i];
64
}
65
}
66
return
StatusCode::SUCCESS;
67
}
68
69
70
StatusCode
JetCaloQualityTool::initialize
() {
71
ATH_MSG_DEBUG
(
"Inside initialize() method"
);
72
73
if
(!
m_writeDecorKeys
.empty()){
74
ATH_MSG_ERROR
(
"OutputDecorKeys should not be configured manually!"
);
75
return
StatusCode::FAILURE;
76
}
77
if
(
m_jetContainerName
.empty()){
78
ATH_MSG_ERROR
(
"JetCaloQualityTool needs to have its input jet container name configured!"
);
79
return
StatusCode::FAILURE;
80
}
81
82
// In this tool we're using the cluster-based calculators
83
// (this is different in the cell-based calculation tool).
84
m_calcProcessor
= &
m_jetCalculations
;
85
86
// Define and use a macro to compactify the addition of calo calculators
87
// The macro defines a JetCalculator as 'c' in case addition setting are needed.
88
#define ADDCALCULATOR( klass ) klass *c = new klass(); m_jetCalculations.addCalculator(c)
89
90
// convert names passed as property into calo calculators
91
for
(
const
std::string & calcN :
m_calculationNames
){
92
93
if
( calcN ==
"LArQuality"
) {
94
ADDCALCULATOR
(
jet::JetCalcQuality
);
95
}
else
if
( calcN ==
"TileQuality"
) {
96
ATH_MSG_ERROR
(
"TileQuality calculated from clusters is actually identical to LArQuality. "
);
97
ATH_MSG_ERROR
(
"No meaningful TileQuality calculation possible from cluster yet"
);
98
return
StatusCode::FAILURE;
99
// ADDCALCULATOR( jet::JetCalcQuality );
100
// c->includeTile = true;
101
// c->includeLAr = false;
102
}
else
if
( calcN ==
"Timing"
) {
103
ADDCALCULATOR
(
jet::JetCalcTimeCells
);
104
}
else
if
( calcN ==
"HECQuality"
) {
105
ADDCALCULATOR
(
jet::JetCalcQualityHEC
);
106
// the calculator class has its name backward (QualityHEC)
107
// but really sets the attribute has "HECQuality"
108
}
else
if
( calcN ==
"NegativeE"
) {
109
ADDCALCULATOR
(
jet::JetCalcNegativeEnergy
);
110
}
else
if
( calcN ==
"AverageLArQF"
) {
111
ADDCALCULATOR
(
jet::JetCalcAverageLArQualityF
);
112
}
else
if
( calcN ==
"Centroid"
) {
113
ADDCALCULATOR
(
jet::JetCalcCentroid
);
114
}
else
if
( calcN ==
"N90Constituents"
) {
115
ADDCALCULATOR
(
jet::JetCalcnLeadingCells
);
116
c->setName(
xAOD::JetAttributeAccessor::name
(
xAOD::JetAttribute::N90Constituents
));
117
}
else
if
( calcN ==
"BchCorrCell"
) {
118
ADDCALCULATOR
(
jet::JetCalcBadCellsFrac
);
119
}
else
if
(calcN ==
"FracSamplingMax"
) {
120
m_doFracSamplingMax
=
true
;
// no calculator, as this is a special case.
121
}
122
}
// end loop over m_calculationNames
123
124
// Set the DecorHandleKeys with the correct strings
125
for
(
size_t
i=0; i <
m_jetCalculations
.numCalculators(); i++){
126
m_writeDecorKeys
.emplace_back(
m_jetContainerName
+
"."
+
m_jetCalculations
.at(i)->name());
127
}
128
129
// Define OOT calculators.
130
for
(
const
double
timeCut :
m_timingTimeCuts
){
131
132
// build the moment name from the base-name and the value of the timing cut
133
std::stringstream s;
134
s << std::setprecision(0) << std::fixed <<
"OotFracClusters"
<< timeCut;
135
136
JetCalcOutOfTimeEnergyFraction
* c =
new
jet::JetCalcOutOfTimeEnergyFraction
();
137
c->setName(s.str());
138
c->timecut = timeCut;
139
m_jetCalculations
.addCalculator( c );
140
m_writeDecorKeys
.emplace_back(
m_jetContainerName
+
"."
+ s.str());
141
}
142
143
// Add these last so m_jetCalculations and m_writeDecorKeys have corresponding indices
144
if
(
m_doFracSamplingMax
){
145
m_writeDecorKeys
.emplace_back(
m_jetContainerName
+
".FracSamplingMax"
);
146
m_writeDecorKeys
.emplace_back(
m_jetContainerName
+
".FracSamplingMaxIndex"
);
147
}
148
149
ATH_CHECK
(
m_writeDecorKeys
.initialize());
150
151
return
StatusCode::SUCCESS;
152
}
153
154
155
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:61
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
WriteDecorHandle.h
Handle class for adding a decoration to an object.
JetAccessorMap.h
ADDCALCULATOR
#define ADDCALCULATOR(klass)
JetCaloQualityTool.h
JetCaloQualityUtils.h
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition
AthCommonMsg.h:30
JetCaloQualityTool::m_calculationNames
Gaudi::Property< std::vector< std::string > > m_calculationNames
Definition
JetCaloQualityTool.h:51
JetCaloQualityTool::JetCaloQualityTool
JetCaloQualityTool(const std::string &name)
Definition
JetCaloQualityTool.cxx:19
JetCaloQualityTool::m_calcProcessor
jet::JetCaloCalculations * m_calcProcessor
Definition
JetCaloQualityTool.h:65
JetCaloQualityTool::m_timingTimeCuts
Gaudi::Property< std::vector< double > > m_timingTimeCuts
Definition
JetCaloQualityTool.h:53
JetCaloQualityTool::m_doFracSamplingMax
bool m_doFracSamplingMax
Definition
JetCaloQualityTool.h:67
JetCaloQualityTool::m_jetContainerName
Gaudi::Property< std::string > m_jetContainerName
Definition
JetCaloQualityTool.h:55
JetCaloQualityTool::decorate
virtual StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
Definition
JetCaloQualityTool.cxx:25
JetCaloQualityTool::m_jetCalculations
jet::JetCaloCalculations m_jetCalculations
This objects holds a list of cluster-based calculators.
Definition
JetCaloQualityTool.h:62
JetCaloQualityTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
JetCaloQualityTool.cxx:70
JetCaloQualityTool::m_writeDecorKeys
SG::WriteDecorHandleKeyArray< xAOD::JetContainer > m_writeDecorKeys
Definition
JetCaloQualityTool.h:58
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
jet::JetCalcAverageLArQualityF
Definition
JetCaloQualityUtils.h:116
jet::JetCalcBadCellsFrac
Fraction of Bad energy in jet. From cluster moment ENG_BAD_CELLS.
Definition
JetCaloQualityUtils.h:171
jet::JetCalcCentroid
Definition
JetCaloQualityUtils.h:162
jet::JetCalcNegativeEnergy
Definition
JetCaloQualityUtils.h:154
jet::JetCalcOutOfTimeEnergyFraction
Definition
JetCaloQualityUtils.h:95
jet::JetCalcQualityHEC
Definition
JetCaloQualityUtils.h:139
jet::JetCalcQuality
Definition
JetCaloQualityUtils.h:125
jet::JetCalcTimeCells
Definition
JetCaloQualityUtils.h:106
jet::JetCalcnLeadingCells
Definition
JetCaloQualityUtils.h:84
jet::JetCaloCalculator
Base class to support cpu-efficient calculation on calorimeter jets either at CaloCell or constituent...
Definition
JetCaloCalculations.h:76
jet::JetCaloQualityUtils::fracSamplingMax
static double fracSamplingMax(const Jet *jet, int &SamplingMax)
Definition
JetCaloQualityUtils.cxx:107
asg
Definition
DataHandleTestTool.h:28
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
std
STL namespace.
xAOD::JetAttributeAccessor::name
std::string name(xAOD::JetAttribute::AttributeID id)
Definition
JetAccessorMap.h:30
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition
JetContainer.h:17
xAOD::JetAttribute::FracSamplingMax
@ FracSamplingMax
Definition
JetAttributes.h:116
xAOD::JetAttribute::N90Constituents
@ N90Constituents
Definition
JetAttributes.h:91
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0