ATLAS Offline Software
RoIFormatUpdater.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 /* **********************************************************
5 *
6 * Quick and dirty hack to work around fact that there is no RoI
7 * format version at the moment. Hopefully this is a short-term
8 * fix which will be suppressed soon and never needed again.
9 * Author: Alan Watson <Alan.Watson@cern.ch> 17-5-06
10 *
11 ********************************************************** */
12 
13 #include "TrigT1Interfaces/BitOp.h"
16 #include "GaudiKernel/MsgStream.h"
17 
18 using namespace std;
19 
20 namespace LVL1 {
21 
22  unsigned int RoIFormatUpdater::UpdateEMTauRoI(unsigned int RoIWord) {
23  // Check ionput is consistent with old format EMTau RoI
24  if ((RoIWord&0xf0000000)==0) {
25  unsigned int coord = ((RoIWord&0x0fff0000)<<2);
26  unsigned int hits = (RoIWord&0x0000ffff);
27  return coord+hits;
28  }
29  else {
30  cout << "EMTau RoI type not incorrect. Return RoIWord unmodified" << endl;
31  return RoIWord;
32  }
33  }
34 
35  unsigned int RoIFormatUpdater::UpdateJetEnergyRoI(unsigned int RoIWord) {
36  // What type of JetEnergy RoI is it?
37  unsigned int type = OldJetEnergyType(RoIWord);
38 
39  if (type == TrigT1CaloDefs::JetRoIWordType) {
40  return UpdateJetRoI(RoIWord);
41  }
42  else if (type == TrigT1CaloDefs::EnergyRoIWordType0) {
43  return UpdateEnergyRoI0(RoIWord);
44  }
45  else if (type == TrigT1CaloDefs::EnergyRoIWordType1) {
46  return UpdateEnergyRoI1(RoIWord);
47  }
48  else if (type == TrigT1CaloDefs::EnergyRoIWordType2) {
49  return UpdateEnergyRoI2(RoIWord);
50  }
51  else if (type == TrigT1CaloDefs::JetEtRoIWordType) {
52  return UpdateJetEtRoI(RoIWord);
53  }
54  else {
55  cout << "JetEnergy RoI type not recognised. Return RoIWord unmodified" << endl;
56  return RoIWord;
57  }
58  }
59 
60  unsigned int RoIFormatUpdater::OldJetEnergyType(unsigned int RoIWord) {
61  if ( BitOp::getValue( &RoIWord, 0xf0000000 ) == 1) {
62  return TrigT1CaloDefs::JetRoIWordType;
63  }
64  else if ( BitOp::getValue( &RoIWord, 0xf0000000 ) == 3) {
65  int subType = BitOp::getValue( &RoIWord, 0x0c000000 );
66  if (subType == 0) {
67  return TrigT1CaloDefs::EnergyRoIWordType0;
68  }
69  else if (subType == 1) {
70  return TrigT1CaloDefs::EnergyRoIWordType1;
71  }
72  else if (subType == 2) {
73  return TrigT1CaloDefs::EnergyRoIWordType2;
74  }
75  }
76  else if ( BitOp::getValue( &RoIWord, 0xf0000000 ) == 2) {
77  return TrigT1CaloDefs::JetEtRoIWordType;
78  }
79  return 9999; // not recognised as an old-style JetEnergy RoI
80  }
81 
82  unsigned int RoIFormatUpdater::UpdateJetRoI(unsigned int RoIWord) {
83  unsigned int header =
84  (static_cast<unsigned int>(TrigT1CaloDefs::jetRoIType)<<30) +
85  (static_cast<unsigned int>(TrigT1CaloDefs::jetRoI)<<29);
86  unsigned int hits = (RoIWord&0x00000fff);
87  unsigned int fwdjet(0);
88  if (RoIWord&0x00000f00) fwdjet = 1<<18;
89 
90  // That was the easy bit. Unfortunately the coordinate format has
91  // also changed. This does make sense, but it isn't pretty!
92  unsigned int crate = BitOp::getValue( &RoIWord, 0x00200000);
93  unsigned int jem = BitOp::getValue( &RoIWord, 0x001e0000);
94  unsigned int row = BitOp::getValue( &RoIWord, 0x0001c000);
95  unsigned int col = BitOp::getValue( &RoIWord, 0x00003000);
96  unsigned int frame = 4*(col>>1) + (row>>1);
97  unsigned int rl = 2*(row%2) + (col%2);
98  unsigned int coord = (crate<<9) + (jem<<5) +(frame<<2) + rl;
99  coord = (coord<<19);
100 
101  return header+coord+fwdjet+hits;
102  }
103 
104  unsigned int RoIFormatUpdater::UpdateJetEtRoI(unsigned int RoIWord) {
105  unsigned int header =
106  (static_cast<unsigned int>(TrigT1CaloDefs::jetRoIType)<<30) +
107  (static_cast<unsigned int>(TrigT1CaloDefs::jetEtRoI)<<29);
108  unsigned int hits = (RoIWord&0x0000000f);
109  return header+hits;
110  }
111 
112  unsigned int RoIFormatUpdater::UpdateEnergyRoI0(unsigned int RoIWord) {
113  unsigned int header = (TrigT1CaloDefs::energyRoIType<<30) + (TrigT1CaloDefs::energyRoI0<<28);
114  unsigned int Ex = (RoIWord&0x0000ffff);
115  return header+Ex;
116  }
117 
118  unsigned int RoIFormatUpdater::UpdateEnergyRoI1(unsigned int RoIWord) {
119  unsigned int header = (TrigT1CaloDefs::energyRoIType<<30) + (TrigT1CaloDefs::energyRoI1<<28);
120  unsigned int hits = (RoIWord&0x000f0000);
121  unsigned int Ey = (RoIWord&0x0000ffff);
122  return header+hits+Ey;
123  }
124 
125  unsigned int RoIFormatUpdater::UpdateEnergyRoI2(unsigned int RoIWord) {
126  unsigned int header = (TrigT1CaloDefs::energyRoIType<<30) + (TrigT1CaloDefs::energyRoI2<<28);
127  unsigned int hits = (RoIWord&0x00ff0000);
128  unsigned int Et = (RoIWord&0x0000ffff);
129  return header+hits+Et;
130  }
131 
132 } // namespace ROIB
RoIFormatUpdater.h
query_example.row
row
Definition: query_example.py:24
header
Definition: hcg.cxx:526
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
BitOp.h
LArG4ShowerLibProcessing.hits
hits
Definition: LArG4ShowerLibProcessing.py:136
TrigT1CaloDefs.h
query_example.col
col
Definition: query_example.py:7
JetVoronoiDiagramHelpers::coord
double coord
Definition: JetVoronoiDiagramHelpers.h:45
PlotCalibFromCool.rl
rl
Definition: PlotCalibFromCool.py:529
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
BitOp::getValue
static unsigned int getValue(const unsigned int *uintValue, const unsigned int mask)
get the value in the input word represented by a bit pattern given as a bitmask
Definition: BitOp.cxx:47