ATLAS Offline Software
Loading...
Searching...
No Matches
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
11
12namespace 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
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
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
float time() const
get time (data member)
Definition CaloCell.h:368
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition CaloCell.h:333
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition CaloCell.h:321
uint16_t provenance() const
get provenance (data member)
Definition CaloCell.h:354
uint16_t quality() const
get quality (data member)
Definition CaloCell.h:348
bool is_lar_hec() const
cell belongs to HEC
uint8_t qual1(void) const
get quality of first PMT (data member)
Definition TileCell.h:197
uint8_t qual2(void) const
get quality of second PMT (data member)
Definition TileCell.h:200
std::vector< JetCaloCalculator * > m_calculators
void addCalculator(JetCaloCalculator *c)
Base class to support cpu-efficient calculation on calorimeter jets either at CaloCell or constituent...
virtual double jetCalculation() const
return the result of the calculation
virtual bool setupJet(const xAOD::Jet *)=0
void addCellCalculator(JetCaloCellCalculator *c)
std::vector< JetCaloCellCalculator * > m_cellcalculators
virtual std::vector< double > process(const xAOD::Jet *jet) const
Perform all tasks correspondings to the associated JetCaloCalculators on Jet jet.
Base class (inheriting JetCaloCalculator) for calculations accessing CaloCell directly.
virtual double operator()(const xAOD::Jet *jet, xAOD::JetConstitScale s=xAOD::UncalibratedJetConstituent)
convenience function to perform the full calculation on a given jet
virtual bool processCell(const CaloCell *, weight_t)=0
perform calculation for a single cell
static const_iterator begin(const xAOD::Jet *jet)
static const_iterator end(const xAOD::Jet *jet)
time(flags, cells_name, *args, **kw)
bool timeAndQualityDefined(const CaloCell *theCell)
Jet_v1 Jet
Definition of the current "jet version".
JetConstitScale
Definition JetTypes.h:20