ATLAS Offline Software
CpmRoiSubBlockV2.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 
8 #include "CpmRoiSubBlockV2.h"
9 
10 namespace LVL1BS {
11 
12 // Constant definitions
13 
15 
21 
22 
24 {
25 }
26 
28 {
29 }
30 
31 // Clear all data
32 
34 {
36  m_roiData.clear();
37 }
38 
39 // Store header
40 
41 void CpmRoiSubBlockV2::setRoiHeader(const int version, const int crate,
42  const int module)
43 {
45 }
46 
47 // Store RoI
48 
50 {
51  const LVL1::CPMTobRoI roiTemp(crate(), module(), 0, 0, 0, 0, 0);
52  if (roi.crate() == roiTemp.crate() && roi.cpm() == roiTemp.cpm()) {
53  m_roiData.resize(2*s_glinkPins);
54  const int pin = (roi.chip() << 1) |
55  ((roi.location() >> s_locationLen) & 0x1);
56  const int type = roi.type(); // em or tau (0/1)
57  m_roiData[2*pin+type] = roi;
58  }
59 }
60 
61 // Return RoI for given chip and location (left/right) and type (em/tau)
62 
63 LVL1::CPMTobRoI CpmRoiSubBlockV2::roi(const int chip, const int loc,
64  const int type) const
65 {
66  const int pin = (chip << 1) | (loc & 0x1);
67  if (pin < s_glinkPins && !m_roiData.empty()) return m_roiData[2*pin+type];
68  else return LVL1::CPMTobRoI(0);
69 }
70 
71 // Packing/Unpacking routines
72 
74 {
75  bool rc = false;
76  switch (version()) {
77  case 2: // <<== CHECK
78  switch (format()) {
79  case NEUTRAL:
80  rc = packNeutral();
81  break;
82  default:
83  break;
84  }
85  break;
86  default:
87  break;
88  }
89  return rc;
90 }
91 
93 {
94  bool rc = false;
95  switch (version()) {
96  case 2: // <<== CHECK
97  switch (format()) {
98  case NEUTRAL:
99  rc = unpackNeutral();
100  break;
101  default:
103  break;
104  }
105  break;
106  default:
108  break;
109  }
110  return rc;
111 }
112 
113 // Pack neutral data
114 
116 {
117  m_roiData.resize(2*s_glinkPins);
118  for (int pin = 0; pin < s_glinkPins; ++pin) {
119  // RoI data
120  const int idx = 2*pin;
121  const LVL1::CPMTobRoI& roiEm(m_roiData[idx]);
122  const LVL1::CPMTobRoI& roiTau(m_roiData[idx+1]);
123  packerNeutral(pin, roiEm.energy(), s_energyLen);
124  packerNeutral(pin, roiEm.isolation(), s_isolLen);
125  packerNeutral(pin, 0, 1); //parity
126  packerNeutral(pin, roiTau.energy(), s_energyLen);
127  packerNeutral(pin, roiTau.isolation(), s_isolLen);
128  packerNeutral(pin, 0, 1); //parity
129  packerNeutral(pin, 0, 1); //error
130  packerNeutral(pin, (roiEm.location()|roiTau.location()), s_locationLen);
131  // Bunch Crossing number
132  if (pin < s_bunchCrossingBits) {
133  packerNeutral(pin, bunchCrossing() >> pin, 1);
134  } else packerNeutral(pin, 0, 1);
135  // G-Link parity
136  packerNeutralParity(pin);
137  }
138  return true;
139 }
140 
141 // Unpack neutral data
142 
144 {
145  m_roiData.resize(2*s_glinkPins);
146  int bunchCrossing = 0;
147  for (int pin = 0; pin < s_glinkPins; ++pin) {
148  // RoI data
149  const int energyEm = unpackerNeutral(pin, s_energyLen);
150  const int isolEm = unpackerNeutral(pin, s_isolLen);
151  unpackerNeutral(pin, 1); //parity
152  const int energyTau = unpackerNeutral(pin, s_energyLen);
153  const int isolTau = unpackerNeutral(pin, s_isolLen);
154  unpackerNeutral(pin, 1); //parity
155  unpackerNeutral(pin, 1); //error
156  const int loc = unpackerNeutral(pin, s_locationLen) |
157  ((pin & 0x1) << s_locationLen);
158  const int chip = pin >> 1;
159  const int idx = 2*pin;
160  m_roiData[idx] = LVL1::CPMTobRoI(crate(), module(), chip, loc, 0,
161  energyEm, isolEm);
162  m_roiData[idx+1] = LVL1::CPMTobRoI(crate(), module(), chip, loc, 1,
163  energyTau, isolTau);
164  // Bunch Crossing number
165  if (pin < s_bunchCrossingBits) {
166  bunchCrossing |= unpackerNeutral(pin, 1) << pin;
167  } else unpackerNeutral(pin, 1);
168  // G-Link parity error
170  }
172  const bool rc = unpackerSuccess();
174  return rc;
175 }
176 
177 } // end namespace
LVL1BS::L1CaloSubBlock::setBunchCrossing
void setBunchCrossing(int bc)
Set the Bunch Crossing number (neutral format only)
Definition: L1CaloSubBlock.h:328
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
LVL1::CPMTobRoI::cpm
int cpm() const
Return CPM number (1-14)
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMTobRoI.h:82
LVL1::CPMTobRoI::type
int type() const
Return type em/tau (0/1)
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMTobRoI.h:97
LVL1BS::CpmRoiSubBlockV2::packNeutral
bool packNeutral()
Pack neutral data.
Definition: CpmRoiSubBlockV2.cxx:115
LVL1::CPMTobRoI::energy
int energy() const
Return energy.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMTobRoI.h:102
LVL1BS::L1CaloSubBlock::clear
void clear()
Clear all data.
Definition: L1CaloSubBlock.cxx:82
LVL1BS::L1CaloSubBlock::packerNeutral
void packerNeutral(int pin, uint32_t datum, int nbits)
Pack given neutral data from given pin.
Definition: L1CaloSubBlock.cxx:413
LVL1BS::CpmRoiSubBlockV2::s_locationLen
static const int s_locationLen
Definition: CpmRoiSubBlockV2.h:55
LVL1BS::L1CaloSubBlock::NEUTRAL
@ NEUTRAL
Definition: L1CaloSubBlock.h:28
LVL1BS::L1CaloSubBlock::setHeader
void setHeader(int wordId, int version, int format, int seqno, int crate, int module, int slices2, int slices1)
Store header data.
Definition: L1CaloSubBlock.cxx:99
LVL1BS::L1CaloSubBlock::bunchCrossing
int bunchCrossing() const
Return the Bunch Crossing number (neutral format only)
Definition: L1CaloSubBlock.h:333
LVL1BS::CpmRoiSubBlockV2::unpackNeutral
bool unpackNeutral()
Unpack neutral data.
Definition: CpmRoiSubBlockV2.cxx:143
LVL1BS::CpmRoiSubBlockV2::roi
LVL1::CPMTobRoI roi(int chip, int loc, int type) const
Return RoI for given chip and location (left/right) and type (em/tau)
Definition: CpmRoiSubBlockV2.cxx:63
LVL1BS::L1CaloSubBlock::crate
int crate() const
Definition: L1CaloSubBlock.h:263
CpmRoiSubBlockV2.h
python.PyAthena.module
module
Definition: PyAthena.py:131
LVL1BS::CpmRoiSubBlockV2::s_bunchCrossingBits
static const int s_bunchCrossingBits
Definition: CpmRoiSubBlockV2.h:56
LVL1BS::L1CaloSubBlock::UNPACK_DATA_TRUNCATED
@ UNPACK_DATA_TRUNCATED
Definition: L1CaloSubBlock.h:40
LVL1BS::CpmRoiSubBlockV2::CpmRoiSubBlockV2
CpmRoiSubBlockV2()
Definition: CpmRoiSubBlockV2.cxx:23
LVL1BS::L1CaloSubBlock::unpackerNeutralParityError
bool unpackerNeutralParityError(int pin)
Unpack and test G-Link parity bit for given pin.
Definition: L1CaloSubBlock.cxx:464
LVL1BS::L1CaloSubBlock::format
int format() const
Definition: L1CaloSubBlock.h:248
CPMTobRoI.h
LVL1BS::L1CaloSubBlock::UNPACK_VERSION
@ UNPACK_VERSION
Definition: L1CaloSubBlock.h:38
LVL1::CPMTobRoI::crate
int crate() const
Return crate number (0-1)
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMTobRoI.h:77
LVL1BS::CpmRoiSubBlockV2::unpack
bool unpack()
Unpack data.
Definition: CpmRoiSubBlockV2.cxx:92
LVL1::CPMTobRoI::chip
int chip() const
Return CP chip number (0-7)
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMTobRoI.h:87
LVL1BS::L1CaloSubBlock::version
int version() const
Definition: L1CaloSubBlock.h:243
LVL1BS::CpmRoiSubBlockV2::s_energyLen
static const int s_energyLen
Definition: CpmRoiSubBlockV2.h:53
LVL1::CPMTobRoI
CPM RoI data.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMTobRoI.h:19
LVL1BS::L1CaloSubBlock::unpackerSuccess
bool unpackerSuccess() const
Return unpacker success flag.
Definition: L1CaloSubBlock.h:354
LVL1::CPMTobRoI::isolation
int isolation() const
Return isolation.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMTobRoI.h:107
LVL1::CPMTobRoI::location
int location() const
Return location (RoI local coords) (0-7)
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMTobRoI.h:92
LVL1BS::CpmRoiSubBlockV2::~CpmRoiSubBlockV2
~CpmRoiSubBlockV2()
Definition: CpmRoiSubBlockV2.cxx:27
LVL1BS::L1CaloSubBlock::module
int module() const
Definition: L1CaloSubBlock.h:268
get_generator_info.version
version
Definition: get_generator_info.py:33
LVL1BS::CpmRoiSubBlockV2::setRoiHeader
void setRoiHeader(int version, int crate, int module)
Store header.
Definition: CpmRoiSubBlockV2.cxx:41
LVL1BS::CpmRoiSubBlockV2::s_isolLen
static const int s_isolLen
Definition: CpmRoiSubBlockV2.h:54
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LVL1BS::CpmRoiSubBlockV2::m_roiData
std::vector< LVL1::CPMTobRoI > m_roiData
RoI words.
Definition: CpmRoiSubBlockV2.h:64
LVL1BS
Definition: ZdcByteStreamReadV1V2Tool.h:47
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
LVL1BS::CpmRoiSubBlockV2::s_wordIdVal
static const int s_wordIdVal
Header word ID.
Definition: CpmRoiSubBlockV2.h:50
LVL1BS::L1CaloSubBlock::setUnpackErrorCode
void setUnpackErrorCode(int code)
Set the unpacking error code.
Definition: L1CaloSubBlock.h:338
LVL1BS::CpmRoiSubBlockV2::pack
bool pack()
Pack data.
Definition: CpmRoiSubBlockV2.cxx:73
LVL1BS::CpmRoiSubBlockV2::clear
void clear()
Clear all data.
Definition: CpmRoiSubBlockV2.cxx:33
LVL1BS::L1CaloSubBlock::unpackerNeutral
uint32_t unpackerNeutral(int pin, int nbits)
Unpack given number of bits of neutral data for given pin.
Definition: L1CaloSubBlock.cxx:445
LVL1BS::CpmRoiSubBlockV2::s_glinkPins
static const int s_glinkPins
Definition: CpmRoiSubBlockV2.h:52
LVL1BS::CpmRoiSubBlockV2::fillRoi
void fillRoi(LVL1::CPMTobRoI roi)
Store RoI.
Definition: CpmRoiSubBlockV2.cxx:49
xAOD::CPMTobRoI
CPMTobRoI_v1 CPMTobRoI
Define the latest version of the CPMTobRoI class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/CPMTobRoI.h:17
LVL1BS::L1CaloSubBlock::UNPACK_FORMAT
@ UNPACK_FORMAT
Definition: L1CaloSubBlock.h:39
LVL1BS::L1CaloSubBlock::packerNeutralParity
void packerNeutralParity(int pin)
Pack current G-Link parity bit for given pin.
Definition: L1CaloSubBlock.cxx:434