ATLAS Offline Software
Loading...
Searching...
No Matches
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
7
11
12
13#include <iostream>
14#include <iomanip>
15using namespace std;
16using namespace jet;
17
18
20 : asg::AsgTool(name)
21{
22}
23
24
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
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
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
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
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).
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") {
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") {
104 } else if ( calcN == "HECQuality") {
106 // the calculator class has its name backward (QualityHEC)
107 // but really sets the attribute has "HECQuality"
108 } else if ( calcN == "NegativeE") {
110 } else if ( calcN == "AverageLArQF") {
112 } else if ( calcN == "Centroid") {
114 } else if ( calcN == "N90Constituents") {
117 } else if ( calcN == "BchCorrCell") {
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
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
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
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Handle class for adding a decoration to an object.
#define ADDCALCULATOR(klass)
bool msgLvl(const MSG::Level lvl) const
Gaudi::Property< std::vector< std::string > > m_calculationNames
JetCaloQualityTool(const std::string &name)
jet::JetCaloCalculations * m_calcProcessor
Gaudi::Property< std::vector< double > > m_timingTimeCuts
Gaudi::Property< std::string > m_jetContainerName
virtual StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
jet::JetCaloCalculations m_jetCalculations
This objects holds a list of cluster-based calculators.
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
SG::WriteDecorHandleKeyArray< xAOD::JetContainer > m_writeDecorKeys
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
Fraction of Bad energy in jet. From cluster moment ENG_BAD_CELLS.
Base class to support cpu-efficient calculation on calorimeter jets either at CaloCell or constituent...
static double fracSamplingMax(const Jet *jet, int &SamplingMax)
STL namespace.
std::string name(xAOD::JetAttribute::AttributeID id)
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".
MsgStream & msg
Definition testRead.cxx:32