ATLAS Offline Software
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 
18 using std::cout;
19 using std::endl;
20 
21 namespace LVL1 {
22 
24  {
25  }
26 
28 
29  }
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 
59 unsigned 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 );
301 for ( 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
LVL1::JEPRoIDecoder::energyOverflow
bool energyOverflow(unsigned int energyRoIWord) const
returns overflow flag energy RoIWord
Definition: JEPRoIDecoder.cxx:271
LVL1::JEPRoIDecoder::mEtSigThresholdsFlags
unsigned int mEtSigThresholdsFlags(const unsigned int energyRoIWord0) const
Definition: JEPRoIDecoder.cxx:343
LVL1::JEPRoIDecoder::sumEtThresholdPassed
bool sumEtThresholdPassed(const unsigned int energyRoIWord1, const unsigned int thresh) const
returns true if thresh is passed
Definition: JEPRoIDecoder.cxx:332
LVL1::TrigT1CaloDefs::JetEtRoIWordType
@ JetEtRoIWordType
Definition: TrigT1CaloDefs.h:169
LVL1::JEPRoIDecoder::fwdThresholdsPassed
const std::vector< unsigned int > fwdThresholdsPassed(const unsigned int word) const
returns a vector containing the numbers of threshold passed i.e.
Definition: JEPRoIDecoder.cxx:122
LVL1::JEPRoIDecoder::crate
unsigned int crate(const unsigned int word) const
Return hardware coordinates.
Definition: JEPRoIDecoder.cxx:79
LVL1::TrigT1CaloDefs::energyRoIWord1
@ energyRoIWord1
Definition: TrigT1CaloDefs.h:203
TrigCompositeUtils::passed
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
Definition: TrigCompositeUtilsRoot.cxx:117
LVL1::JEPRoIDecoder::JEPRoIDecoder
JEPRoIDecoder()
Definition: JEPRoIDecoder.cxx:23
physval_make_web_display.thresh
thresh
Definition: physval_make_web_display.py:36
LVL1::JEPRoIDecoder::sumEtThresholdsFlags
unsigned int sumEtThresholdsFlags(const unsigned int energyRoIWord1) const
Definition: JEPRoIDecoder.cxx:348
LVL1::JEPRoIDecoder::decodeEnergyComponent
int decodeEnergyComponent(const unsigned int energyRoIWord) const
No descriptions.
Definition: JEPRoIDecoder.cxx:358
LVL1::TrigT1CaloDefs::Run1JetType
@ Run1JetType
Definition: TrigT1CaloDefs.h:156
M_PI
#define M_PI
Definition: ActiveFraction.h:11
xAOD::etaMax
etaMax
Definition: HIEventShape_v2.cxx:46
LVL1::JEPRoIDecoder::etSumThresholdsPassed
std::vector< unsigned int > etSumThresholdsPassed(const unsigned int energyRoIWord1) const
returns a vector containing the numbers of threshold passed i.e.
Definition: JEPRoIDecoder.cxx:297
LVL1::JEPRoIDecoder::etMissThresholdsPassed
std::vector< unsigned int > etMissThresholdsPassed(const unsigned int energyRoIWord2) const
returns a vector containing the numbers of threshold passed i.e.
Definition: JEPRoIDecoder.cxx:312
athena.value
value
Definition: athena.py:124
LVL1::JEPRoIDecoder::midJEMCoordinate
CoordinateRange midJEMCoordinate(const unsigned int jem, const unsigned int roiWord) const
return a CoordinateRange for the JEMs coving -2.4<eta<2.4
Definition: JEPRoIDecoder.cxx:154
LVL1::JEPRoIDecoder::energyX
int energyX(unsigned int energyRoIWord0) const
returns the (signed) Ex energy projection.
Definition: JEPRoIDecoder.cxx:250
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::JEPRoIDecoder::rightEndJEMCoordinate
CoordinateRange rightEndJEMCoordinate(const unsigned int jem, const unsigned int roiWord) const
returns a CoordinateRange for the end JEMs, i.e.
Definition: JEPRoIDecoder.cxx:207
LVL1::JEPRoIDecoder::mEtSigThresholdPassed
bool mEtSigThresholdPassed(const unsigned int energyRoIWord0, const unsigned int thresh) const
returns true if thresh is passed
Definition: JEPRoIDecoder.cxx:326
LVL1::TrigT1CaloDefs::energyRoIWord0
@ energyRoIWord0
Definition: TrigT1CaloDefs.h:202
LVL1::JEPRoIDecoder::etSmall
unsigned int etSmall(const unsigned int word) const
Extract smaller cluster ET value from Jet RoI word.
Definition: JEPRoIDecoder.cxx:147
LVL1::TrigT1CaloDefs::EnergyRoIWordType1
@ EnergyRoIWordType1
Definition: TrigT1CaloDefs.h:171
LVL1::TrigT1CaloDefs::EnergyRoIWordType2
@ EnergyRoIWordType2
Definition: TrigT1CaloDefs.h:172
xAOD::roiWord
roiWord
Definition: TrigMissingET_v1.cxx:36
LVL1::TrigT1CaloDefs::EnergyRoIWordType0
@ EnergyRoIWordType0
Definition: TrigT1CaloDefs.h:170
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:148
LVL1::TrigT1CaloDefs::Run2JetType
@ Run2JetType
Definition: TrigT1CaloDefs.h:153
LVL1::CoordinateRange
CoordinateRange class declaration.
Definition: CoordinateRange.h:36
LVL1::JEPRoIDecoder::thresholdsPassed
const std::vector< unsigned int > thresholdsPassed(const unsigned int word) const
returns a vector containing the numbers of threshold passed i.e.
Definition: JEPRoIDecoder.cxx:103
LVL1::TrigT1CaloDefs::RoIWordTypeError
@ RoIWordTypeError
Definition: TrigT1CaloDefs.h:175
LVL1::TrigT1CaloDefs::numOfSumEtThresholds
static const unsigned int numOfSumEtThresholds
Definition: TrigT1CaloDefs.h:129
JEPRoIDecoder.h
LVL1::JEPRoIDecoder::energyY
int energyY(unsigned int energyRoIWord1) const
returns the (signed) Ex energy projection.
Definition: JEPRoIDecoder.cxx:257
LVL1::JEPRoIDecoder::jetRoIVersion
unsigned int jetRoIVersion(unsigned int word) const
Identify Jet RoI Version.
Definition: JEPRoIDecoder.cxx:59
LVL1::JEPRoIDecoder::module
unsigned int module(const unsigned int word) const
Extract module number from Jet RoI word.
Definition: JEPRoIDecoder.cxx:84
TrigT1CaloDefs.h
query_example.col
col
Definition: query_example.py:7
LVL1::JEPRoIDecoder::setPhiCoords
void setPhiCoords(const unsigned int jem, const unsigned int roiWord, double &phiMin, double &phiMax) const
set phi coords for Jet RoI
Definition: JEPRoIDecoder.cxx:234
JetVoronoiDiagramHelpers::coord
double coord
Definition: JetVoronoiDiagramHelpers.h:45
LVL1::JEPRoIDecoder::etMissThresholdPassed
bool etMissThresholdPassed(const unsigned int energyRoIWord2, const unsigned int thresh) const
returns true if thresh is passed
Definition: JEPRoIDecoder.cxx:338
PlotCalibFromCool.rl
rl
Definition: PlotCalibFromCool.py:529
LVL1::TrigT1CaloDefs::RoIType
RoIType
Definition: TrigT1CaloDefs.h:166
LVL1::TrigT1CaloDefs::energyRoIWord2
@ energyRoIWord2
Definition: TrigT1CaloDefs.h:204
LVL1::TrigT1CaloDefs::JetRoIWordType
@ JetRoIWordType
Definition: TrigT1CaloDefs.h:168
LArCellBinning.etaMin
etaMin
Definition: LArCellBinning.py:84
LVL1::TrigT1CaloDefs::JetEtType
@ JetEtType
Definition: TrigT1CaloDefs.h:157
LVL1::JEPRoIDecoder::column
unsigned int column(const unsigned int word) const
Extract RoI column number within module from Jet RoI word.
Definition: JEPRoIDecoder.cxx:96
TSU::complement
T complement(const T &v, const unsigned int &p)
Definition: L1TopoDataTypes.cxx:18
LVL1::TrigT1CaloDefs::numOfMEtSigThresholds
static const unsigned int numOfMEtSigThresholds
Definition: TrigT1CaloDefs.h:130
LVL1::JEPRoIDecoder::energyT
int energyT(unsigned int energyRoIWord2) const
returns the (signed) Ex energy projection.
Definition: JEPRoIDecoder.cxx:264
LVL1::JEPRoIDecoder::etLarge
unsigned int etLarge(const unsigned int word) const
Return ET values from Run 2 Jet RoIs.
Definition: JEPRoIDecoder.cxx:141
LVL1::TrigT1CaloDefs::numOfMissingEtThresholds
static const unsigned int numOfMissingEtThresholds
Definition: TrigT1CaloDefs.h:128
LVL1::JEPRoIDecoder::leftEndJEMCoordinate
CoordinateRange leftEndJEMCoordinate(const unsigned int jem, const unsigned int roiWord) const
returns a CoordinateRange for the end JEMs, i.e.
Definition: JEPRoIDecoder.cxx:179
LVL1::JEPRoIDecoder::~JEPRoIDecoder
virtual ~JEPRoIDecoder()
Definition: JEPRoIDecoder.cxx:27
LVL1::JEPRoIDecoder::coordinate
virtual CoordinateRange coordinate(const unsigned int roiWord) const override
Return eta/phi coordinate object.
Definition: JEPRoIDecoder.cxx:66
LVL1::JEPRoIDecoder::mEtSigThresholdsPassed
std::vector< unsigned int > mEtSigThresholdsPassed(const unsigned int energyRoIWord0) const
returns a vector containing the numbers of threshold passed i.e.
Definition: JEPRoIDecoder.cxx:282
LVL1::RoIDecoder::extractBits
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"
Definition: RoIDecoder.cxx:34
LVL1::JEPRoIDecoder::row
unsigned int row(const unsigned int word) const
Extract RoI row number within module from Jet RoI word.
Definition: JEPRoIDecoder.cxx:89
LVL1::JEPRoIDecoder::roiType
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)
Definition: JEPRoIDecoder.cxx:33
LVL1::JEPRoIDecoder::missEtThresholdsFlags
unsigned int missEtThresholdsFlags(const unsigned int energyRoIWord1) const
Definition: JEPRoIDecoder.cxx:353