ATLAS Offline Software
JetCaloCellQualityUtils.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef XAOD_ANALYSIS
6 
8 
9 #include "TileEvent/TileCell.h"
11 
12 namespace jet {
13 
14 
16  if (! setupJet( jet ) ) return 0;
17  size_t nConstit = jet->numConstituents();
18  if( nConstit == 0) return true;
19 
22 
23  for( ; it != itE ; ++it) {
24  processCell(*it, it.weight());
25  }
26  return jetCalculation();
27  }
28 
29 
30 
31 
32 
34  m_cellcalculators.push_back(c);
36  }
37 
38  std::vector<double> JetCaloCellCalculations::process(const xAOD::Jet* jet) const {
39 
40  size_t nConstit = jet->numConstituents();
41  std::vector<double> results;
42  results.reserve(m_calculators.size());
43 
44  if( nConstit == 0) {
45  results.resize(m_calculators.size(),0);
46  return results;
47  }
48 
49  // Clone calculators
50  std::vector<JetCaloCellCalculator*> clonedCalc;
51  clonedCalc.reserve(m_calculators.size());
52  for( const JetCaloCellCalculator *calc : m_cellcalculators) clonedCalc.push_back( calc->clone() );
53 
54 
55 
56  // navigate from cell
59  for( ; it != itE ; ++it) {
60  double w= it.weight();
61  const CaloCell* cell = *it;
62  for( JetCaloCellCalculator *calc : clonedCalc) {
63  calc->processCell(cell, w);
64  }
65  }
66 
67  // copy results & clear the cloned calc
68  for(JetCaloCalculator* calc: clonedCalc) {
69  results.push_back( calc->jetCalculation() );
70  delete calc;
71  }
72 
73  return results;
74  }
75 
76 
77 
78 
79 
80 
81 
82 
83 
84  bool timeAndQualityDefined(const CaloCell* theCell){
85  // ensure timing information is defined
86  bool timeIsDefined(false);
87  if(theCell->caloDDE()->is_tile())
88  {
89  if ( (theCell->provenance()) & 0x8080)
90  timeIsDefined = true;
91  }
92  else //is_lar
93  {
94  if ( (theCell->provenance() & 0x2000) &&
95  !(theCell->provenance() & 0x0800 ) // do not take masked-patched cells int
96  ) timeIsDefined = true;
97  }
98  return timeIsDefined;
99  }
100 
101 
102 
103  bool JetCalcnLeadingCells_fromCells::processCell(const CaloCell *thisCell, weight_t )
104  {
105 
106  m_cell_energies.push_back(thisCell->e());
107  m_sumE_cells+=thisCell->e();
108  return true;
109  }
110 
111 
112  bool JetCalcOutOfTimeEnergyFraction_fromCells::processCell(const CaloCell *thisCell, weight_t ) {
113  m_sumE+=thisCell->e();
114 
115  // ensure timing information is defined
116  bool timeIsDefined = timeAndQualityDefined(thisCell);
117  if ( timeIsDefined ) {
118  double time = thisCell->time();
119  if(fabs(time)>timecut)m_sumE_OOT+=thisCell->e();
120  }
121  return true;
122  }
123 
124 
125  bool JetCalcTimeCells_fromCells::processCell(const CaloCell *theCell, weight_t weight)
126  {
127  // ensure timing information is defined
128  bool timeIsDefined = timeAndQualityDefined(theCell);
129 
130  if ( timeIsDefined )
131  {
132  double thisNorm = weight * fabs(weight) * theCell->e() * theCell->e();
133  double thisTime = thisNorm * theCell->time();
134 
135  m_time += thisTime;
136  m_norm += thisNorm;
137  }
138 
139  return true;
140  }
141 
142 
143  bool JetCalcAverageLArQualityF_fromCells::processCell(const CaloCell *theCell, weight_t weight)
144  {
145  // ensure timing information is defined ...
146  bool timeIsDefined = timeAndQualityDefined(theCell);
147  // ... and restrict to LAr cells
148  if ( timeIsDefined && ( theCell->caloDDE()->is_tile() == m_useTile ) )
149  {
150  double thisNorm = weight * fabs(weight) * theCell->e() * theCell->e();
151  double thisQf = thisNorm * theCell->quality();
152 
153  m_qf += thisQf;
154  m_norm += thisNorm;
155  }
156 
157  return true;
158  }
159 
160 
161  bool JetCalcQuality_fromCells::processCell(const CaloCell *theCell, weight_t)
162  {
163  // Calculate the fraction of energy in cells flagged with a 'bad' quality
164  // The cuts used are fairly approximative, and are used to flag obviously problematic cells
165  // The quality factor might have an energy/gain dependence, so choosing a single cut
166  // is surely a coarse approximation...
167 
168  if(theCell->caloDDE()->is_tile() && includeTile )
169  {
170  const TileCell* theTileCell = dynamic_cast<const TileCell*>(theCell);
171  if(theTileCell)
172  {
173  if((theCell->provenance()) & 0x8080)
174  {
175  m_totE += theCell->e();
176  int tileQuality = std::max(theTileCell->qual1(), theTileCell->qual2());
177  if(tileQuality > TileQualityCut)
178  m_badE += theCell->e();
179  }
180  }
181  }
182  else
183  {
184  if( includeLAr &&
185  (theCell->provenance() & 0x2000) &&
186  !(theCell->provenance() & 0x0800 ) // do not take masked-patched cells into account
187  )
188  {
189  m_totE += theCell->e();
190  if(theCell->quality() > LArQualityCut)
191  m_badE += theCell->e();
192  }
193  }
194 
195  return true;
196  }
197 
198 
199  bool JetCalcQualityHEC_fromCells::processCell(const CaloCell *theCell, weight_t)
200  {
201  if(theCell->caloDDE()->is_lar_hec())
202  {
203  if( ((theCell->provenance()) & 0x2000) &&
204  !(theCell->provenance() & 0x0800 ) )// do not take masked-patched cells into account
205  {
206  m_totE += theCell->e();
207  if(theCell->quality() > LArQualityCut)
208  m_badE += theCell->e();
209  }
210  }
211 
212  return true;
213  }
214 
215 
216  bool JetCalcNegativeEnergy_fromCells::processCell(const CaloCell *theCell, weight_t)
217  {
218  if(theCell->e()<-2500)
219  m_totE += theCell->e();
220  return true;
221  }
222 
223 
224  bool JetCalcCentroid_fromCells::processCell(const CaloCell */*theCell*/, weight_t)
225  {
226  return true;
227  }
228 
229  // // Not implemented yet.
230  // bool JetCalcBadCellsFrac_fromCells::processCell(const CaloCell *, weight_t) { return true; }
231 
232 }
233 #endif
jet::JetCellAccessor::end
static const_iterator end(const xAOD::Jet *jet)
Definition: JetCellAccessor.cxx:81
TileCell
Definition: TileCell.h:57
jet::JetCaloCellCalculator::processCell
virtual bool processCell(const CaloCell *, weight_t)=0
perform calculation for a single cell
jet::timeAndQualityDefined
bool timeAndQualityDefined(const CaloCell *theCell)
Definition: JetCaloCellQualityUtils.cxx:84
verify_menu_config.results
results
Definition: verify_menu_config.py:67
jet::JetCellAccessor::const_iterator
Definition: JetCellAccessor.h:43
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
max
#define max(a, b)
Definition: cfImp.cxx:41
skel.it
it
Definition: skel.GENtoEVGEN.py:396
jet::JetCaloCellCalculator
Base class (inheriting JetCaloCalculator) for calculations accessing CaloCell directly.
Definition: JetCaloCellQualityUtils.h:37
CaloCell::e
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition: CaloCell.h:317
CaloCell::provenance
uint16_t provenance() const
get provenance (data member)
Definition: CaloCell.h:338
CaloCell::time
float time() const
get time (data member)
Definition: CaloCell.h:352
jet::JetCaloCalculator::setupJet
virtual bool setupJet(const xAOD::Jet *)=0
JetCaloCellQualityUtils.h
TruthTest.itE
itE
Definition: TruthTest.py:25
JetCellAccessor.h
jet::JetCaloCellCalculations::addCellCalculator
void addCellCalculator(JetCaloCellCalculator *c)
Definition: JetCaloCellQualityUtils.cxx:33
MissingETBase::Types::weight_t
xAOD::MissingETComponent_v1::Weight weight_t
Type for kinematic weight.
Definition: MissingETComponent_v1.h:264
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
TileCell::qual2
uint8_t qual2(void) const
get quality of second PMT (data member)
Definition: TileCell.h:206
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
CaloCell::caloDDE
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition: CaloCell.h:305
TileCell.h
jet::JetCellAccessor::begin
static const_iterator begin(const xAOD::Jet *jet)
Definition: JetCellAccessor.cxx:76
CaloCell::quality
uint16_t quality() const
get quality (data member)
Definition: CaloCell.h:332
CaloDetDescrElement::is_tile
bool is_tile() const
cell belongs to Tile
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:442
xAOD::JetConstitScale
JetConstitScale
Definition: JetTypes.h:20
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
jet::JetCaloCalculations::addCalculator
void addCalculator(JetCaloCalculator *c)
Definition: JetCaloCalculations.cxx:257
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
jet::JetCaloCalculator::jetCalculation
virtual double jetCalculation() const
return the result of the calculation
Definition: JetCaloCalculations.h:97
TileCell::qual1
uint8_t qual1(void) const
get quality of first PMT (data member)
Definition: TileCell.h:203
jet::JetCaloCalculator
Definition: JetCaloCalculations.h:76
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
CaloDetDescrElement::is_lar_hec
bool is_lar_hec() const
cell belongs to HEC
Definition: CaloDetDescrElement.cxx:130
jet::JetCaloCalculations::m_calculators
std::vector< JetCaloCalculator * > m_calculators
Definition: JetCaloCalculations.h:167
jet::JetCaloCellCalculations::m_cellcalculators
std::vector< JetCaloCellCalculator * > m_cellcalculators
Definition: JetCaloCellQualityUtils.h:91
beamspotnt.calc
calc
Definition: bin/beamspotnt.py:1252
jet::JetCaloCellCalculator::operator()
virtual double operator()(const xAOD::Jet *jet, xAOD::JetConstitScale s=xAOD::UncalibratedJetConstituent)
convenience function to perform the full calculation on a given jet
Definition: JetCaloCellQualityUtils.cxx:15
python.compressB64.c
def c
Definition: compressB64.py:93
jet::JetCaloCellCalculations::process
virtual std::vector< double > process(const xAOD::Jet *jet) const
Perform all tasks correspondings to the associated JetCaloCalculators on Jet jet.
Definition: JetCaloCellQualityUtils.cxx:38