32 produces<FEDRawDataCollection>();
62 lines += phtrig->bxSize(-1, 1);
66 lines += thtrig->bxSize(-1, 1);
70 lines += trtrig->bxSize(-1, 1)*3;
74 unsigned char* LineFED=dttfdata.
data();
76 int* dataWord1 =
new int;
77 int* dataWord2 =
new int;
81 *dataWord1 = 0x50000000
83 *dataWord2 = 0x00030C00;
86 calcCRC(*dataWord1, *dataWord2, newCRC);
87 *((
int*)LineFED)=*dataWord2;
89 *((
int*)LineFED)=*dataWord1;
93 int TS1Id[4], TS2Id[4];
106 for ( tsphi = phtrig->getContainer()->begin();
107 tsphi != phtrig->getContainer()->end();
109 if ( tsphi->code() != 7 ) {
111 int wheelID = tsphi->whNum()+1;
112 if ( wheelID <= 0 ) wheelID -= 2;
113 int stationID = tsphi->stNum()-1;
114 int is2nd = tsphi->Ts2Tag();
116 int channelNr =
channel(wheelID, tsphi->scNum(), tsphi->bxNum()-is2nd);
117 if ( channelNr == 255 )
continue;
118 int TSId = ( is2nd == 0 ) ? TS1Id[stationID] : TS2Id[stationID];
120 *dataWord1 = ((channelNr&0xFF)<<24)
123 if ( stationID != 2 ){
124 *dataWord2 = ( (TSId&0x0FF)<<24)
125 + (~(tsphi->code()+1)&0x007)
126 + ( (~tsphi->phiB()&0x3FF)<<3)
127 + ( (~tsphi->phi()&0xFFF)<<13);
130 *dataWord2 = ( (TSId&0xFFFFF)<<12)
131 + (~(tsphi->code()+1)&0x00007)
132 + ( (~tsphi->phi()&0x00FFF)<<3);
135 calcCRC(*dataWord1, *dataWord2, newCRC);
137 *((
int*)LineFED)=*dataWord2;
139 *((
int*)LineFED)=*dataWord1;
147 for ( tsthe = thtrig->getContainer()->begin();
148 tsthe != thtrig->getContainer()->end();
151 int wheelTh = tsthe->whNum();
152 int sectorID = tsthe->scNum();
154 int channelNr =
channel(0, sectorID, tsthe->bxNum());
155 if ( channelNr == 255 )
continue;
156 int TSId = wheelTh+2;
158 *dataWord1 = ((channelNr&0xFF)<<24)
161 *dataWord2 = ((TSId&0x07)<<28)
164 int stationID = tsthe->stNum()-1;
165 for (
int bti = 0; bti < 7; bti++ )
166 if ( wheelTh == -2 || wheelTh == -1 ||
167 ( wheelTh == 0 && (sectorID == 0 || sectorID == 3 || sectorID == 4 || sectorID == 7 || sectorID == 8 || sectorID == 11) ) )
168 *dataWord2 -= (tsthe->position(bti)&0x1)<<(stationID*7+bti);
170 *dataWord2 -= (tsthe->position(6-bti)&0x1)<<(stationID*7+bti);
172 calcCRC(*dataWord1, *dataWord2, newCRC);
174 *((
int*)LineFED)=*dataWord2;
176 *((
int*)LineFED)=*dataWord1;
183 for ( tstrk = trtrig->getContainer()->begin();
184 tstrk != trtrig->getContainer()->end();
187 int channelNr =
channel(tstrk->whNum(), tstrk->scNum(), tstrk->bx());
188 if ( channelNr == 255 )
continue;
189 int TSId = ( tstrk->TrkTag() == 0 ) ? 0xAFFF : 0xBFFF;
191 *dataWord1 = ((channelNr&0xFF)<<24)
194 *dataWord2 = ( (TSId&0xFFFF)<<16)
195 + ( tstrk->stNum(4)&0x0000F)
196 + ((tstrk->stNum(3)&0x0000F)<<4)
197 + ((tstrk->stNum(2)&0x0000F)<<8)
198 + ((tstrk->stNum(1)&0x00003)<<12);
200 calcCRC(*dataWord1, *dataWord2, newCRC);
202 *((
int*)LineFED)=*dataWord2;
204 *((
int*)LineFED)=*dataWord1;
206 TSId = ( tstrk->TrkTag() == 0 ) ? 0xCFFE : 0xDFFE;
208 *dataWord1 = ((channelNr&0xFF)<<24)
211 *dataWord2 = ( (TSId&0xFFFE)<<16)
212 + ( ~tstrk->quality_packed()&0x0007)
213 + ( (tstrk->phi_packed()&0x00FF)<<3)
214 + ( (~tstrk->charge_packed()&0x0001)<<11)
215 + ( (~tstrk->pt_packed()&0x001F)<<12);
217 calcCRC(*dataWord1, *dataWord2, newCRC);
219 *((
int*)LineFED)=*dataWord2;
221 *((
int*)LineFED)=*dataWord1;
223 channelNr =
channel(0, tstrk->scNum(), tstrk->bx());
224 if ( channelNr == 255 )
continue;
225 TSId = (tstrk->whNum()+3)<<16;
226 TSId += ( tstrk->whNum() < 0 ) ? 0x8FFFC : 0x7FFFC;
228 *dataWord1 = ((channelNr&0xFF)<<24)
231 *dataWord2 = (TSId&0xFFFFC)<<12;
233 if ( tstrk->TrkTag() == 0 ) {
235 + ( tstrk->eta_packed()&0x003F)
236 + ((~tstrk->finehalo_packed()&0x0001)<<6);
240 + ( ( tstrk->eta_packed()&0x003F)<<7)
241 + ((~tstrk->finehalo_packed()&0x0001)<<13);
244 calcCRC(*dataWord1, *dataWord2, newCRC);
246 *((
int*)LineFED)=*dataWord2;
248 *((
int*)LineFED)=*dataWord1;
254 *dataWord1 = 0xA0000000
258 calcCRC(*dataWord1, *dataWord2&0xFFFF, newCRC);
260 *dataWord2 += (newCRC&0xFFFF)<<16;
263 *((
int*)LineFED)=*dataWord2;
265 *((
int*)LineFED)=*dataWord1;
281 if (
abs(bx) > 1) {
return myChannel; }
282 if ( sector < 0 || sector > 11) {
return myChannel; }
283 if (
abs(wheel) > 3) {
return myChannel; }
285 myChannel = sector*21 + wheel*3 - bx + 10 ;
287 if (myChannel > 125) myChannel += 2;
296 if (myChannel > 127) myChannel -= 2;
298 if (myChannel < 0 || myChannel > 251 ){
return -999; }
300 int myBx = 1-(myChannel%3);
309 if (myChannel > 127) myChannel -= 2;
311 if (myChannel < 0 || myChannel > 251 ){
return -999; }
320 if (myChannel > 127) myChannel -= 2;
322 if (myChannel < 0 || myChannel > 251 ){
return -999; }
324 int myWheel = ((myChannel%21)/3)-3;
331 int myCRC[16],
D[64],
C[16];
333 for(
int i=0;
i < 32;
i++ ){ D[
i]=(myD2>>
i)&0x1; }
334 for(
int i=0;
i < 32;
i++ ){ D[
i+32]=(myD1>>
i)&0x1; }
335 for(
int i=0;
i < 16;
i++ ){ C[
i]=(myC>>
i)&0x1; }
337 myCRC[0] = ( D[63] + D[62] + D[61] + D[60] + D[55] + D[54] +
338 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
339 D[47] + D[46] + D[45] + D[43] + D[41] + D[40] +
340 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
341 D[33] + D[32] + D[31] + D[30] + D[27] + D[26] +
342 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
343 D[19] + D[18] + D[17] + D[16] + D[15] + D[13] +
344 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
345 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
346 D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
347 C[5] + C[6] + C[7] + C[12] + C[13] + C[14] +
350 myCRC[1] = ( D[63] + D[62] + D[61] + D[56] + D[55] + D[54] +
351 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
352 D[47] + D[46] + D[44] + D[42] + D[41] + D[40] +
353 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
354 D[33] + D[32] + D[31] + D[28] + D[27] + D[26] +
355 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
356 D[19] + D[18] + D[17] + D[16] + D[14] + D[13] +
357 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
358 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
359 C[0] + C[1] + C[2] + C[3] + C[4] + C[5] +
360 C[6] + C[7] + C[8] + C[13] + C[14] + C[15] )%2;
362 myCRC[2] = ( D[61] + D[60] + D[57] + D[56] + D[46] + D[42] +
363 D[31] + D[30] + D[29] + D[28] + D[16] + D[14] +
364 D[1] + D[0] + C[8] + C[9] + C[12] + C[13] )%2;
366 myCRC[3] = ( D[62] + D[61] + D[58] + D[57] + D[47] + D[43] +
367 D[32] + D[31] + D[30] + D[29] + D[17] + D[15] +
368 D[2] + D[1] + C[9] + C[10] + C[13] + C[14] )%2;
370 myCRC[4] = ( D[63] + D[62] + D[59] + D[58] + D[48] + D[44] +
371 D[33] + D[32] + D[31] + D[30] + D[18] + D[16] +
372 D[3] + D[2] + C[0] + C[10] + C[11] + C[14] +
375 myCRC[5] = ( D[63] + D[60] + D[59] + D[49] + D[45] + D[34] +
376 D[33] + D[32] + D[31] + D[19] + D[17] + D[4] +
377 D[3] + C[1] + C[11] + C[12] + C[15] )%2;
379 myCRC[6] = ( D[61] + D[60] + D[50] + D[46] + D[35] + D[34] +
380 D[33] + D[32] + D[20] + D[18] + D[5] + D[4] +
381 C[2] + C[12] + C[13] )%2;
383 myCRC[7] = ( D[62] + D[61] + D[51] + D[47] + D[36] + D[35] +
384 D[34] + D[33] + D[21] + D[19] + D[6] + D[5] +
385 C[3] + C[13] + C[14] )%2;
387 myCRC[8] = ( D[63] + D[62] + D[52] + D[48] + D[37] + D[36] +
388 D[35] + D[34] + D[22] + D[20] + D[7] + D[6] +
389 C[0] + C[4] + C[14] + C[15] )%2;
391 myCRC[9] = ( D[63] + D[53] + D[49] + D[38] + D[37] + D[36] +
392 D[35] + D[23] + D[21] + D[8] + D[7] + C[1] +
395 myCRC[10] = ( D[54] + D[50] + D[39] + D[38] + D[37] + D[36] +
396 D[24] + D[22] + D[9] + D[8] + C[2] + C[6] )%2;
398 myCRC[11] = ( D[55] + D[51] + D[40] + D[39] + D[38] + D[37] +
399 D[25] + D[23] + D[10] + D[9] + C[3] + C[7] )%2;
401 myCRC[12] = ( D[56] + D[52] + D[41] + D[40] + D[39] + D[38] +
402 D[26] + D[24] + D[11] + D[10] + C[4] + C[8] )%2;
404 myCRC[13] = ( D[57] + D[53] + D[42] + D[41] + D[40] + D[39] +
405 D[27] + D[25] + D[12] + D[11] + C[5] + C[9] )%2;
407 myCRC[14] = ( D[58] + D[54] + D[43] + D[42] + D[41] + D[40] +
408 D[28] + D[26] + D[13] + D[12] + C[6] + C[10] )%2;
410 myCRC[15] = ( D[63] + D[62] + D[61] + D[60] + D[59] + D[54] +
411 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
412 D[47] + D[46] + D[45] + D[44] + D[42] + D[40] +
413 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
414 D[33] + D[32] + D[31] + D[30] + D[29] + D[26] +
415 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
416 D[19] + D[18] + D[17] + D[16] + D[15] + D[14] +
417 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
418 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
419 D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
420 C[5] + C[6] + C[11] + C[12] + C[13] + C[14] +
424 for(
int i=0;
i<16 ;
i++){ tempC = tempC + (myCRC[
i]<<
i); }
T getParameter(std::string const &) const
EventNumber_t event() const
edm::InputTag getDTPHTFInputTag()
virtual ~DTTFFEDSim()
Destructor.
The_Container::const_iterator The_iterator
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
edm::InputTag DTDigiInputTag
void resize(size_t newsize)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void calcCRC(int myD1, int myD2, int &myC)
edm::InputTag getDTDigiInputTag()
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Phi_Container::const_iterator Phi_iterator
int channel(int wheel, int sector, int bx)
void produce(edm::Event &e, const edm::EventSetup &c)
Produce digis out of raw data.
TrackContainer::const_iterator Trackiterator
bool fillRawData(edm::Event &e, FEDRawDataCollection &data)
Generate and fill FED raw data for a full event.
char data[epos_bytes_allocation]
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
edm::InputTag DTPHTFInputTag
DecomposeProduct< arg, typename Div::arg > D
DTTFFEDSim(const edm::ParameterSet &pset)
Constructor.