ATLAS Offline Software
Loading...
Searching...
No Matches
JEPRoIDecoder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4/***************************************************************************
5 JEPRoIDecoder.cxx - description
6 -------------------
7 begin : Fri Apr 19 2002
8 email : moyse@ph.qmw.ac.uk
9***************************************************************************/
10
11
12#include <cmath>
13#include <iostream>
14
17
18using std::cout;
19using std::endl;
20
21namespace LVL1 {
22
26
30
31
34 unsigned int temp=extractBits(word, 30, 3);
35 if (temp == TrigT1CaloDefs::Run1JetType) {
37 }
38 else if (temp == TrigT1CaloDefs::Run2JetType) {
40 }
41 else if (temp == TrigT1CaloDefs::JetEtType) {
43 }
44 else {
45 unsigned int temp2 = extractBits(word, 29, 4);
46 if (temp2 == TrigT1CaloDefs::energyRoIWord0) {
48 }
49 else if (temp2 == TrigT1CaloDefs::energyRoIWord1) {
51 }
52 else if (temp2 == TrigT1CaloDefs::energyRoIWord2) {
54 }
55 }
57}
58
59unsigned int LVL1::JEPRoIDecoder::jetRoIVersion( unsigned int word ) const {
60 unsigned int temp=extractBits(word, 30, 3);
61 if (temp == TrigT1CaloDefs::Run1JetType) return 1;
62 else if (temp == TrigT1CaloDefs::Run2JetType) return 2;
63 else return 999;
64}
65
66 CoordinateRange JEPRoIDecoder::coordinate( const unsigned int roiWord ) const {
67
68 const unsigned int jem = this->module (roiWord);
69 unsigned int temp = jem % 8;
70 if ( temp == 0 ){
71 return leftEndJEMCoordinate(jem, roiWord);
72 } else if( temp == 7 ){
73 return rightEndJEMCoordinate(jem, roiWord);
74 } else return midJEMCoordinate(jem, roiWord);
75
76 }
77
79 unsigned int JEPRoIDecoder::crate( const unsigned int roiWord ) const {
80 return extractBits( roiWord, 29, 1 );
81 }
82
84 unsigned int JEPRoIDecoder::module( const unsigned int roiWord ) const {
85 return extractBits( roiWord, 25, 4 );
86 }
87
89 unsigned int JEPRoIDecoder::row( const unsigned int roiWord ) const {
90 unsigned int rl = extractBits( roiWord, 20, 2 );
91 unsigned int frame = extractBits( roiWord, 22, 3 );
92 return ( frame & 3 ) * 2 + ( rl >> 1 );
93 }
94
96 unsigned int JEPRoIDecoder::column( const unsigned int roiWord ) const {
97 unsigned int rl = extractBits( roiWord, 20, 2 );
98 unsigned int frame = extractBits( roiWord, 22, 3 );
99 return ( frame >> 2 ) * 2 + ( rl & 1 );
100 }
101
103 const std::vector<unsigned int> JEPRoIDecoder::thresholdsPassed( const unsigned int word ) const {
104
105 std::vector<unsigned int> threshPassedVec;
106
107 if (jetRoIVersion(word) == 1) {
108 unsigned int thresholdsPassed = extractBits( word, 1, 8 );
109 for ( unsigned int thresh = 0; thresh < 16; ++thresh ) {
110 if ( ( 1 << thresh ) & thresholdsPassed ) {
111 threshPassedVec.push_back( thresh + 1 );
112 }
113 }
114 }
115
116 return threshPassedVec;
117
118 }
119
122 const std::vector<unsigned int> JEPRoIDecoder::fwdThresholdsPassed( const unsigned int word ) const {
123
124 std::vector<unsigned int> fwdThreshPassedVec;
125
126 if (jetRoIVersion(word) == 1) {
127 unsigned int fwdThresholdsPassed = extractBits( word, 9, 4 );
128 for ( unsigned int thresh = 0; thresh < 4;thresh++ ) {
129 if ( ( 1 << thresh ) & fwdThresholdsPassed ) {
130 fwdThreshPassedVec.push_back( thresh + 1 );
131 }
132 } //endfor
133 }
134
135 return fwdThreshPassedVec;
136
137 }
138
139
141 unsigned int JEPRoIDecoder::etLarge( const unsigned int word ) const {
142 if (jetRoIVersion(word) == 1) return 0;
143 return extractBits( word, 1, 10 );
144 }
145
147 unsigned int JEPRoIDecoder::etSmall( const unsigned int word ) const {
148 if (jetRoIVersion(word) == 1) return 0;
149 return extractBits( word, 11, 9 );
150 }
151
152
155 const unsigned int roiWord) const {
156
157 double phiMin = 0.0;
158 double phiMax = 0.0;
159 setPhiCoords( jem, roiWord, phiMin, phiMax );
160
161 //eta
162 const double JEMEtaSize = 0.8;
163 const double jeEtaSize = 0.2;
164
165 const unsigned int col = this->column (roiWord);
166 int etaBin = ( jem % 8 ) - 4; //bins range from -4 to +3
167 double etaMin = ( etaBin * JEMEtaSize ) + ( jeEtaSize * col );
168 double etaMax = etaMin + 2. * jeEtaSize;
169
170 // there is one nasty "special case" as well
171 if ( etaMax > 2.5 && etaMax < 2.7 ) etaMax = 2.7;
172
174 coord.setRanges( phiMin, phiMax, etaMin, etaMax );
175 return coord;
176 }
177
180 const unsigned int roiWord) const {
181
182 double phiMin = 0.0;
183 double phiMax = 0.0;
184 setPhiCoords( jem, roiWord, phiMin, phiMax );
185
186 double etaMin = 0.0; double etaMax = 0.0;
187 switch ( this->column (roiWord) ) {
188 case 0:
189 etaMin = -4.9; etaMax = -2.9;
190 break;
191 case 1:
192 etaMin = -3.2; etaMax = -2.7;
193 break;
194 case 2:
195 etaMin = -2.9; etaMax = -2.4;
196 break;
197 case 3:
198 etaMin = -2.7; etaMax = -2.2;
199 break;
200 }
201
202 CoordinateRange coord( phiMin, phiMax, etaMin, etaMax );
203 return coord;
204 }
205
208 const unsigned int roiWord) const {
209
210 double phiMin = 0.0;
211 double phiMax = 0.0;
212 setPhiCoords( jem, roiWord, phiMin, phiMax );
213 double etaMin = 0.0; double etaMax = 0.0;
214 switch ( this->column (roiWord) ) {
215 case 0:
216 etaMin = 2.4; etaMax = 2.9;
217 break;
218 case 1:
219 etaMin = 2.7; etaMax = 3.2;
220 break;
221 case 2:
222 etaMin = 2.9; etaMax = 4.9; // to put centre at HEC-FCAL boundary
223 break;
224 case 3:
225 etaMin = 2.9; etaMax = 4.9; // distinction between these 2 not useful to L2
226 break;
227 }
228
229 CoordinateRange coord( phiMin, phiMax, etaMin, etaMax );
230 return coord;
231 }
232
234 void JEPRoIDecoder::setPhiCoords( const unsigned int jem, const unsigned int roiWord,
235 double& phiMin, double& phiMax ) const {
236
237 const unsigned int row = this->row (roiWord);
238 const unsigned int crate = this->crate (roiWord);
239
240 const double jemPhiSize = M_PI / 2;
241 const double jePhiSize = M_PI / 16;
242 int crateModifier = ( jem / 8 ) * 2; //=0 or 2
243 phiMin = ( crate + crateModifier ) * jemPhiSize + ( jePhiSize * row );
244 phiMax = phiMin + 2. * jePhiSize;
245
246 return;
247 }
248
250 int JEPRoIDecoder::energyX( unsigned int energyRoIWord0 ) const {
251
252 if ( roiType( energyRoIWord0 ) != TrigT1CaloDefs::EnergyRoIWordType0 ) return 0; // wrong type of word
253 return decodeEnergyComponent( energyRoIWord0 );
254 }
255
257 int JEPRoIDecoder::energyY( unsigned int energyRoIWord1 ) const {
258
259 if ( roiType( energyRoIWord1 ) != TrigT1CaloDefs::EnergyRoIWordType1 ) return 0; // wrong type of word
260 return decodeEnergyComponent( energyRoIWord1 );
261 }
262
264 int JEPRoIDecoder::energyT( unsigned int energyRoIWord2 ) const {
265
266 if ( roiType( energyRoIWord2 ) != TrigT1CaloDefs::EnergyRoIWordType2 ) return 0; // wrong type of word
267 return extractBits( energyRoIWord2, 1, 15 );
268 }
269
271 bool JEPRoIDecoder::energyOverflow( unsigned int energyRoIWord ) const {
272
273 if ( extractBits( energyRoIWord, 16, 1 ) != 0 ) {
274 return true;
275 } else {
276 return false;
277 }
278 }
279
282 std::vector<unsigned int> JEPRoIDecoder::mEtSigThresholdsPassed( const unsigned int energyRoIWord0 ) const {
283
284 std::vector<unsigned int> mEtSigThreshPassedVec;
285 unsigned int passed = mEtSigThresholdsFlags( energyRoIWord0 );
286 for ( unsigned int thresh = 0; thresh < TrigT1CaloDefs::numOfMEtSigThresholds; thresh++ ) {
287 if ( passed & (1<<thresh)) {
288 mEtSigThreshPassedVec.push_back( thresh + 1 );
289 }
290 } //endfor
291
292 return mEtSigThreshPassedVec;
293 }
294
297 std::vector<unsigned int> JEPRoIDecoder::etSumThresholdsPassed( const unsigned int energyRoIWord1 ) const {
298
299 std::vector<unsigned int> sumEtThreshPassedVec;
300 unsigned int passed = sumEtThresholdsFlags( energyRoIWord1 );
301for ( unsigned int thresh = 0; thresh < TrigT1CaloDefs::numOfSumEtThresholds; thresh++ ) {
302 if ( passed & (1<<thresh)) {
303 sumEtThreshPassedVec.push_back( thresh + 1 );
304 }
305 } //endfor
306
307 return sumEtThreshPassedVec;
308 }
309
312 std::vector<unsigned int> JEPRoIDecoder::etMissThresholdsPassed( const unsigned int energyRoIWord2 ) const {
313
314 std::vector<unsigned int> missEtThreshPassedVec;
315 unsigned int passed = missEtThresholdsFlags( energyRoIWord2 );
316 for ( unsigned int thresh = 0; thresh < TrigT1CaloDefs::numOfMissingEtThresholds; thresh++ ) {
317 if ( passed & (1<<thresh)) {
318 missEtThreshPassedVec.push_back( thresh + 1 );
319 }
320 } //endfor
321
322 return missEtThreshPassedVec;
323 }
324
326 bool JEPRoIDecoder::mEtSigThresholdPassed( const unsigned int energyRoIWord0, const unsigned int thresh ) const {
327
328 return ( ( 1 << thresh ) & mEtSigThresholdsFlags( energyRoIWord0 ) );
329 }
330
332 bool JEPRoIDecoder::sumEtThresholdPassed( const unsigned int energyRoIWord1, const unsigned int thresh ) const {
333
334 return ( ( 1 << thresh ) & sumEtThresholdsFlags( energyRoIWord1) );
335 }
336
338 bool JEPRoIDecoder::etMissThresholdPassed( const unsigned int energyRoIWord2, const unsigned int thresh ) const {
339
340 return ( ( 1 << thresh ) & missEtThresholdsFlags( energyRoIWord2 ) );
341 }
342
343 unsigned int JEPRoIDecoder::mEtSigThresholdsFlags( const unsigned int energyRoIWord0 ) const {
344
345 return extractBits( energyRoIWord0, 17, TrigT1CaloDefs::numOfMEtSigThresholds );
346 }
347
348 unsigned int JEPRoIDecoder::sumEtThresholdsFlags( const unsigned int energyRoIWord1 ) const {
349
350 return extractBits( energyRoIWord1, 17, TrigT1CaloDefs::numOfSumEtThresholds );
351 }
352
353 unsigned int JEPRoIDecoder::missEtThresholdsFlags( const unsigned int energyRoIWord2 ) const {
354
355 return extractBits( energyRoIWord2, 17, TrigT1CaloDefs::numOfMissingEtThresholds );
356 }
357
358 int JEPRoIDecoder::decodeEnergyComponent( const unsigned int energyRoIWord ) const {
359
361 int value = extractBits( energyRoIWord, 1, 15 );
362 int negative = extractBits( energyRoIWord, 15, 1 );
363
365 if ( negative != 0 ) {
366 int complement = ~value;
367 value = -( (complement+1)&0x7FFF) ;
368 }
369
370 return value;
371 }
372
373} // namespace LVL1
#define M_PI
double coord
Type of coordination system.
bool passed(DecisionID id, const DecisionIDContainer &)
checks if required decision ID is in the set of IDs in the container
CoordinateRange class declaration.
bool sumEtThresholdPassed(const unsigned int energyRoIWord1, const unsigned int thresh) const
returns true if thresh is passed
int energyY(unsigned int energyRoIWord1) const
returns the (signed) Ex energy projection.
CoordinateRange rightEndJEMCoordinate(const unsigned int jem, const unsigned int roiWord) const
returns a CoordinateRange for the end JEMs, i.e.
const std::vector< unsigned int > thresholdsPassed(const unsigned int word) const
returns a vector containing the numbers of threshold passed i.e.
CoordinateRange leftEndJEMCoordinate(const unsigned int jem, const unsigned int roiWord) const
returns a CoordinateRange for the end JEMs, i.e.
unsigned int missEtThresholdsFlags(const unsigned int energyRoIWord1) const
unsigned int jetRoIVersion(unsigned int word) const
Identify Jet RoI Version.
bool energyOverflow(unsigned int energyRoIWord) const
returns overflow flag energy RoIWord
unsigned int module(const unsigned int word) const
Extract module number from Jet RoI word.
const std::vector< unsigned int > fwdThresholdsPassed(const unsigned int word) const
returns a vector containing the numbers of threshold passed i.e.
unsigned int etLarge(const unsigned int word) const
Return ET values from Run 2 Jet RoIs.
int energyX(unsigned int energyRoIWord0) const
returns the (signed) Ex energy projection.
unsigned int sumEtThresholdsFlags(const unsigned int energyRoIWord1) const
void setPhiCoords(const unsigned int jem, const unsigned int roiWord, double &phiMin, double &phiMax) const
set phi coords for Jet RoI
unsigned int row(const unsigned int word) const
Extract RoI row number within module from Jet RoI word.
std::vector< unsigned int > mEtSigThresholdsPassed(const unsigned int energyRoIWord0) const
returns a vector containing the numbers of threshold passed i.e.
virtual CoordinateRange coordinate(const unsigned int roiWord) const override
Return eta/phi coordinate object.
bool etMissThresholdPassed(const unsigned int energyRoIWord2, const unsigned int thresh) const
returns true if thresh is passed
bool mEtSigThresholdPassed(const unsigned int energyRoIWord0, const unsigned int thresh) const
returns true if thresh is passed
int decodeEnergyComponent(const unsigned int energyRoIWord) const
No descriptions.
int energyT(unsigned int energyRoIWord2) const
returns the (signed) Ex energy projection.
unsigned int etSmall(const unsigned int word) const
Extract smaller cluster ET value from Jet RoI word.
std::vector< unsigned int > etSumThresholdsPassed(const unsigned int energyRoIWord1) const
returns a vector containing the numbers of threshold passed i.e.
unsigned int column(const unsigned int word) const
Extract RoI column number within module from Jet RoI word.
unsigned int crate(const unsigned int word) const
Return hardware coordinates.
CoordinateRange midJEMCoordinate(const unsigned int jem, const unsigned int roiWord) const
return a CoordinateRange for the JEMs coving -2.4<eta<2.4
TrigT1CaloDefs::RoIType roiType(unsigned int word) const
Override base method - allows us to handle both Run 1 & Run 2 data for JEP (up to a point)
std::vector< unsigned int > etMissThresholdsPassed(const unsigned int energyRoIWord2) const
returns a vector containing the numbers of threshold passed i.e.
unsigned int mEtSigThresholdsFlags(const unsigned int energyRoIWord0) const
unsigned int extractBits(unsigned int word, const unsigned int start, const unsigned int length) const
returns the value of bits in word between bit "start" and bit "start" + "length"
static const unsigned int numOfSumEtThresholds
static const unsigned int numOfMEtSigThresholds
static const unsigned int numOfMissingEtThresholds
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...