ATLAS Offline Software
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>
15 using namespace std;
16 using 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 
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;
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 
JetCaloQualityTool::m_timingTimeCuts
Gaudi::Property< std::vector< double > > m_timingTimeCuts
Definition: JetCaloQualityTool.h:53
jet::JetCalcBadCellsFrac
Fraction of Bad energy in jet. From cluster moment ENG_BAD_CELLS.
Definition: JetCaloQualityUtils.h:171
jet::JetCalcTimeCells
Definition: JetCaloQualityUtils.h:106
jet::JetCalcnLeadingCells
Definition: JetCaloQualityUtils.h:84
jet::JetCalcOutOfTimeEnergyFraction
Definition: JetCaloQualityUtils.h:95
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
jet::JetCalcQualityHEC
Definition: JetCaloQualityUtils.h:139
JetCaloQualityTool::JetCaloQualityTool
JetCaloQualityTool(const std::string &name)
Definition: JetCaloQualityTool.cxx:19
xAOD::JetAttribute::FracSamplingMax
@ FracSamplingMax
Definition: JetAttributes.h:116
jet::JetCalcCentroid
Definition: JetCaloQualityUtils.h:162
asg
Definition: DataHandleTestTool.h:28
JetCaloQualityTool::m_calculationNames
Gaudi::Property< std::vector< std::string > > m_calculationNames
Definition: JetCaloQualityTool.h:51
xAOD::JetAttributeAccessor::name
std::string name(xAOD::JetAttribute::AttributeID id)
Definition: JetAccessorMap.h:30
jet::JetCaloCalculations::process
virtual std::vector< double > process(const xAOD::Jet *jet) const
Perform all tasks correspondings to the associated JetCaloCalculators on Jet jet.
Definition: JetCaloCalculations.cxx:269
jet::JetCaloCalculations::numCalculators
size_t numCalculators() const
Definition: JetCaloCalculations.h:161
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
jet::JetCalcNegativeEnergy
Definition: JetCaloQualityUtils.h:154
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
JetCaloQualityTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: JetCaloQualityTool.cxx:70
JetCaloQualityTool::m_doFracSamplingMax
bool m_doFracSamplingMax
Definition: JetCaloQualityTool.h:67
JetAccessorMap.h
JetCaloQualityTool::m_jetCalculations
jet::JetCaloCalculations m_jetCalculations
This objects holds a list of cluster-based calculators
Definition: JetCaloQualityTool.h:62
JetCaloQualityTool::m_writeDecorKeys
SG::WriteDecorHandleKeyArray< xAOD::JetContainer > m_writeDecorKeys
Definition: JetCaloQualityTool.h:58
jet::JetCaloCalculations::at
const JetCaloCalculator * at(size_t i) const
Definition: JetCaloCalculations.h:162
ADDCALCULATOR
#define ADDCALCULATOR(klass)
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:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:99
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
jet::JetCalcAverageLArQualityF
Definition: JetCaloQualityUtils.h:116
JetCaloQualityTool::m_calcProcessor
jet::JetCaloCalculations * m_calcProcessor
Definition: JetCaloQualityTool.h:65
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::JetAttribute::N90Constituents
@ N90Constituents
Definition: JetAttributes.h:91
WriteDecorHandle.h
Handle class for adding a decoration to an object.
JetCaloQualityTool::decorate
virtual StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
Definition: JetCaloQualityTool.cxx:25
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
JetCaloQualityTool.h
python.ami.results
def results
Definition: ami.py:386
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
jet::JetCaloCalculations::addCalculator
void addCalculator(JetCaloCalculator *c)
Definition: JetCaloCalculations.cxx:257
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
JetCaloQualityTool::m_jetContainerName
Gaudi::Property< std::string > m_jetContainerName
Definition: JetCaloQualityTool.h:55
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
JetCaloQualityUtils.h
jet::JetCaloCalculator
Definition: JetCaloCalculations.h:76
jet::JetCaloCalculator::name
virtual std::string name() const
Definition: JetCaloCalculations.h:102
beamspotnt.calc
calc
Definition: bin/beamspotnt.py:1252
python.compressB64.c
def c
Definition: compressB64.py:93
jet::JetCalcQuality
Definition: JetCaloQualityUtils.h:125