ATLAS Offline Software
Loading...
Searching...
No Matches
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
22
24// destructor
29
31// fillROD() - convert BCM RDO to a vector of 32-bit words
33void 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
73unsigned 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
130unsigned 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}
int getPulse1Width() const
Definition BCM_RawData.h:82
int getPulse2Position() const
Definition BCM_RawData.h:83
int getPulse2Width() const
Definition BCM_RawData.h:84
int getChannel() const
Definition BCM_RawData.h:80
int getPulse1Position() const
Definition BCM_RawData.h:81
int getBCID() const
Definition BCM_RawData.h:86
BCM_RawData RDO
void fillROD(std::vector< uint32_t > &v, int BCs_per_LVL1ID)
unsigned short m_RodBlockVersion
unsigned int getDataword_position(int ChannelID)
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)