ATLAS Offline Software
BCM_RodEncoder.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // BCM_RodEncoder.cxx
7 // Implementation file for class BCM_RodEncoder
11 // Version 00-00-01 12/05/2008 Daniel Dobos
13 
14 #include "BCM_RodEncoder.h"
15 
17 // constructor
19 BCM_RodEncoder::BCM_RodEncoder():m_RodBlockVersion{}, m_RDOs{}
20 {
21 }
22 
24 // destructor
27 {
28 }
29 
31 // fillROD() - convert BCM RDO to a vector of 32-bit words
33 void BCM_RodEncoder::fillROD(std::vector<uint32_t>& v32rod, int /*BCs_per_LVL1ID*/) {
34 
35  // Loop over the hits in a RDO
36  VRDO::iterator rdo_it = m_RDOs.begin();
37  VRDO::iterator rdo_it_end = m_RDOs.end();
38 
39  if (rdo_it!=rdo_it_end) {
40 
41  const RDO * rdo_element;
42  unsigned int offlineId = 99;
43  unsigned int prev_offlineId = 99;
44  unsigned int dataword_position;
45  unsigned int Pulse1Position[8] = {0};
46  unsigned int Pulse1Width[8] = {0};
47  unsigned int Pulse2Position[8] = {0};
48  unsigned int Pulse2Width[8] = {0};
49  unsigned int BCID = 0;
50  unsigned int Error = 0;
51 
52  for(; rdo_it!=rdo_it_end; ++rdo_it) {
53  rdo_element = (*rdo_it);
54  offlineId = rdo_element->getChannel();
55  dataword_position = getDataword_position(offlineId);
56  if (offlineId != prev_offlineId) {
57  prev_offlineId = offlineId;
58  Pulse1Position[dataword_position] = rdo_element->getPulse1Position();
59  Pulse1Width[dataword_position] = rdo_element->getPulse1Width();
60  Pulse2Position[dataword_position] = rdo_element->getPulse2Position();
61  Pulse2Width[dataword_position] = rdo_element->getPulse2Width();
62  BCID = rdo_element->getBCID();
63  }
64  }
65  encode_data_block(v32rod, BCID, Pulse1Position, Pulse1Width, Pulse2Position, Pulse2Width, Error);
66  }
67  return;
68 }
69 
71 // encode_data_block() - convert eight RDOs into six data words
73 unsigned int BCM_RodEncoder::encode_data_block(std::vector<uint32_t>& data_block,unsigned int BCID, unsigned int Pulse1Position[8], unsigned int Pulse1Width[8], unsigned int Pulse2Position[8], unsigned int Pulse2Width[8], unsigned int Error){
74  uint32_t data_word = 0;
75  data_word += (BCID & 0xfff) << 20;
76  data_word += (Pulse1Position[0] & 0x3f) << 14;
77  data_word += (Pulse1Width[0] & 0x1f) << 9;
78  data_word += (Pulse2Position[0] & 0x3f) << 3;
79  data_word += (Pulse2Width[0] & 0x1c) >> 2;
80  data_block.push_back(data_word);
81  data_word = 0;
82  data_word += (Pulse2Width[0] & 0x3) << 30;
83  data_word += (Pulse1Position[1] & 0x3f) << 24;
84  data_word += (Pulse1Width[1] & 0x1f) << 19;
85  data_word += (Pulse2Position[1] & 0x3f) << 13;
86  data_word += (Pulse2Width[1] & 0x1f) << 8;
87  data_word += (Pulse1Position[2] & 0x3f) << 2;
88  data_word += (Pulse1Width[2] & 0x18) >> 3;
89  data_block.push_back(data_word);
90  data_word = 0;
91  data_word += (Pulse1Width[2] & 0x7) << 29;
92  data_word += (Pulse2Position[2] & 0x3f) << 23;
93  data_word += (Pulse2Width[2] & 0x1f) << 18;
94  data_word += (Pulse1Position[3] & 0x3f) << 12;
95  data_word += (Pulse1Width[3] & 0x1f) << 7;
96  data_word += (Pulse2Position[3] & 0x3f) << 1;
97  data_word += (Pulse2Width[3] & 0x10) >> 4;
98  data_block.push_back(data_word);
99  data_word = 0;
100  data_word += (Pulse2Width[3] & 0xf) << 28;
101  data_word += (Pulse1Position[4] & 0x3f) << 22;
102  data_word += (Pulse1Width[4] & 0x1f) << 17;
103  data_word += (Pulse2Position[4] & 0x3f) << 11;
104  data_word += (Pulse2Width[4] & 0x1f) << 6;
105  data_word += (Pulse1Position[5] & 0x3f) << 0;
106  data_block.push_back(data_word);
107  data_word = 0;
108  data_word += (Pulse1Width[5] & 0x1f) << 27;
109  data_word += (Pulse2Position[5] & 0x3f) << 21;
110  data_word += (Pulse2Width[5] & 0x1f) << 16;
111  data_word += (Pulse1Position[6] & 0x3f) << 10;
112  data_word += (Pulse1Width[6] & 0x1f) << 5;
113  data_word += (Pulse2Position[6] & 0x3e) >> 1;
114  data_block.push_back(data_word);
115  data_word = 0;
116  data_word += (Pulse2Position[6] & 0x1) << 31;
117  data_word += (Pulse2Width[6] & 0x1f) << 26;
118  data_word += (Pulse1Position[7] & 0x3f) << 20;
119  data_word += (Pulse1Width[7] & 0x1f) << 15;
120  data_word += (Pulse2Position[7] & 0x3f) << 9;
121  data_word += (Pulse2Width[7] & 0x1f) << 4;
122  data_word += (Error & 0xf) << 0;
123  data_block.push_back(data_word);
124  return 6;
125 }
126 
128 // getDataword_position() - convert channelID into dataword_position
130 unsigned int BCM_RodEncoder::getDataword_position(int ChannelID) {
131  switch(ChannelID) {
132  case 0:
133  return 0;
134  case 1:
135  return 1;
136  case 2:
137  return 2;
138  case 3:
139  return 3;
140  case 4:
141  return 4;
142  case 5:
143  return 5;
144  case 6:
145  return 6;
146  case 7:
147  return 7;
148  case 8:
149  return 0;
150  case 9:
151  return 1;
152  case 10:
153  return 2;
154  case 11:
155  return 3;
156  case 12:
157  return 4;
158  case 13:
159  return 5;
160  case 14:
161  return 6;
162  case 15:
163  return 7;
164  default:
165  return 0xffffffff;
166  }
167 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
BCM_RawData::getPulse2Width
int getPulse2Width() const
Definition: BCM_RawData.h:84
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
BCM_RodEncoder::BCM_RodEncoder
BCM_RodEncoder()
Definition: BCM_RodEncoder.cxx:19
BCM_RawData::getChannel
int getChannel() const
Definition: BCM_RawData.h:80
BCM_RodEncoder::fillROD
void fillROD(std::vector< uint32_t > &v, int BCs_per_LVL1ID)
Definition: BCM_RodEncoder.cxx:33
BCM_RodEncoder::~BCM_RodEncoder
~BCM_RodEncoder()
Definition: BCM_RodEncoder.cxx:26
PixelByteStreamErrors::BCID
@ BCID
Definition: PixelByteStreamErrors.h:13
BCM_RawData::getPulse1Position
int getPulse1Position() const
Definition: BCM_RawData.h:81
BCM_RawData
Definition: BCM_RawData.h:36
BCM_RodEncoder::getDataword_position
unsigned int getDataword_position(int ChannelID)
Definition: BCM_RodEncoder.cxx:130
BCM_RodEncoder.h
BCM_RodEncoder::m_RDOs
VRDO m_RDOs
Definition: BCM_RodEncoder.h:56
BCM_RodEncoder::encode_data_block
unsigned int encode_data_block(std::vector< uint32_t > &data_block, unsigned int BCID, unsigned int Pulse1Position[8], unsigned int Pulse1Width[8], unsigned int Pulse2Position[8], unsigned int Pulse2Width[8], unsigned int Error)
Definition: BCM_RodEncoder.cxx:73
BCM_RawData::getPulse2Position
int getPulse2Position() const
Definition: BCM_RawData.h:83
BCM_RawData::getPulse1Width
int getPulse1Width() const
Definition: BCM_RawData.h:82
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
BCM_RawData::getBCID
int getBCID() const
Definition: BCM_RawData.h:86