27 produces<FEDRawDataCollection>();
61 lines += phtrig->bxSize(-1, 1);
65 lines += thtrig->bxSize(-1, 1);
69 lines += trtrig->bxSize(-1, 1)*3;
73 unsigned char* LineFED=dttfdata.
data();
75 int* dataWord1 =
new int;
76 int* dataWord2 =
new int;
80 *dataWord1 = 0x50000000
82 *dataWord2 = 0x00030C00;
85 calcCRC(*dataWord1, *dataWord2, newCRC);
86 *((
int*)LineFED)=*dataWord2;
88 *((
int*)LineFED)=*dataWord1;
92 int TS1Id[4], TS2Id[4];
105 for ( tsphi = phtrig->getContainer()->begin();
106 tsphi != phtrig->getContainer()->end();
108 if ( tsphi->code() != 7 ) {
110 int wheelID = tsphi->whNum()+1;
111 if ( wheelID <= 0 ) wheelID -= 2;
112 int stationID = tsphi->stNum()-1;
113 int is2nd = tsphi->Ts2Tag();
115 int channelNr =
channel(wheelID, tsphi->scNum(), tsphi->bxNum()-is2nd);
116 if ( channelNr == 255 )
continue;
117 int TSId = ( is2nd == 0 ) ? TS1Id[stationID] : TS2Id[stationID];
119 *dataWord1 = ((channelNr&0xFF)<<24)
122 if ( stationID != 2 ){
123 *dataWord2 = ( (TSId&0x0FF)<<24)
124 + (~(tsphi->code()+1)&0x007)
125 + ( (~tsphi->phiB()&0x3FF)<<3)
126 + ( (~tsphi->phi()&0xFFF)<<13);
129 *dataWord2 = ( (TSId&0xFFFFF)<<12)
130 + (~(tsphi->code()+1)&0x00007)
131 + ( (~tsphi->phi()&0x00FFF)<<3);
134 calcCRC(*dataWord1, *dataWord2, newCRC);
136 *((
int*)LineFED)=*dataWord2;
138 *((
int*)LineFED)=*dataWord1;
146 for ( tsthe = thtrig->getContainer()->begin();
147 tsthe != thtrig->getContainer()->end();
150 int wheelTh = tsthe->whNum();
151 int sectorID = tsthe->scNum();
153 int channelNr =
channel(0, sectorID, tsthe->bxNum());
154 if ( channelNr == 255 )
continue;
155 int TSId = wheelTh+2;
157 *dataWord1 = ((channelNr&0xFF)<<24)
160 *dataWord2 = ((TSId&0x07)<<28)
163 int stationID = tsthe->stNum()-1;
164 for (
int bti = 0; bti < 7; bti++ )
165 if ( wheelTh == -2 || wheelTh == -1 ||
166 ( wheelTh == 0 && (sectorID == 0 || sectorID == 3 || sectorID == 4 || sectorID == 7 || sectorID == 8 || sectorID == 11) ) )
167 *dataWord2 -= (tsthe->position(bti)&0x1)<<(stationID*7+bti);
169 *dataWord2 -= (tsthe->position(6-bti)&0x1)<<(stationID*7+bti);
171 calcCRC(*dataWord1, *dataWord2, newCRC);
173 *((
int*)LineFED)=*dataWord2;
175 *((
int*)LineFED)=*dataWord1;
182 for ( tstrk = trtrig->getContainer()->begin();
183 tstrk != trtrig->getContainer()->end();
186 int channelNr =
channel(tstrk->whNum(), tstrk->scNum(), tstrk->bx());
187 if ( channelNr == 255 )
continue;
188 int TSId = ( tstrk->TrkTag() == 0 ) ? 0xAFFF : 0xBFFF;
190 *dataWord1 = ((channelNr&0xFF)<<24)
193 *dataWord2 = ( (TSId&0xFFFF)<<16)
194 + ( tstrk->stNum(4)&0x0000F)
195 + ((tstrk->stNum(3)&0x0000F)<<4)
196 + ((tstrk->stNum(2)&0x0000F)<<8)
197 + ((tstrk->stNum(1)&0x00003)<<12);
199 calcCRC(*dataWord1, *dataWord2, newCRC);
201 *((
int*)LineFED)=*dataWord2;
203 *((
int*)LineFED)=*dataWord1;
205 TSId = ( tstrk->TrkTag() == 0 ) ? 0xCFFE : 0xDFFE;
207 *dataWord1 = ((channelNr&0xFF)<<24)
210 *dataWord2 = ( (TSId&0xFFFE)<<16)
211 + ( ~tstrk->quality_packed()&0x0007)
212 + ( (tstrk->phi_packed()&0x00FF)<<3)
213 + ( (~tstrk->charge_packed()&0x0001)<<11)
214 + ( (~tstrk->pt_packed()&0x001F)<<12);
216 calcCRC(*dataWord1, *dataWord2, newCRC);
218 *((
int*)LineFED)=*dataWord2;
220 *((
int*)LineFED)=*dataWord1;
222 channelNr =
channel(0, tstrk->scNum(), tstrk->bx());
223 if ( channelNr == 255 )
continue;
224 TSId = (tstrk->whNum()+3)<<16;
225 TSId += ( tstrk->whNum() < 0 ) ? 0x8FFFC : 0x7FFFC;
227 *dataWord1 = ((channelNr&0xFF)<<24)
230 *dataWord2 = (TSId&0xFFFFC)<<12;
232 if ( tstrk->TrkTag() == 0 ) {
234 + ( tstrk->eta_packed()&0x003F)
235 + ((~tstrk->finehalo_packed()&0x0001)<<6);
239 + ( ( tstrk->eta_packed()&0x003F)<<7)
240 + ((~tstrk->finehalo_packed()&0x0001)<<13);
243 calcCRC(*dataWord1, *dataWord2, newCRC);
245 *((
int*)LineFED)=*dataWord2;
247 *((
int*)LineFED)=*dataWord1;
253 *dataWord1 = 0xA0000000
257 calcCRC(*dataWord1, *dataWord2&0xFFFF, newCRC);
259 *dataWord2 += (newCRC&0xFFFF)<<16;
262 *((
int*)LineFED)=*dataWord2;
264 *((
int*)LineFED)=*dataWord1;
280 if (
abs(bx) > 1) {
return myChannel; }
281 if ( sector < 0 || sector > 11) {
return myChannel; }
282 if (
abs(wheel) > 3) {
return myChannel; }
284 myChannel = sector*21 + wheel*3 - bx + 10 ;
286 if (myChannel > 125) myChannel += 2;
295 if (myChannel > 127) myChannel -= 2;
297 if (myChannel < 0 || myChannel > 251 ){
return -999; }
299 int myBx = 1-(myChannel%3);
308 if (myChannel > 127) myChannel -= 2;
310 if (myChannel < 0 || myChannel > 251 ){
return -999; }
319 if (myChannel > 127) myChannel -= 2;
321 if (myChannel < 0 || myChannel > 251 ){
return -999; }
323 int myWheel = ((myChannel%21)/3)-3;
330 int myCRC[16],
D[64],
C[16];
332 for(
int i=0;
i < 32;
i++ ){ D[
i]=(myD2>>
i)&0x1; }
333 for(
int i=0;
i < 32;
i++ ){ D[
i+32]=(myD1>>
i)&0x1; }
334 for(
int i=0;
i < 16;
i++ ){ C[
i]=(myC>>
i)&0x1; }
336 myCRC[0] = ( D[63] + D[62] + D[61] + D[60] + D[55] + D[54] +
337 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
338 D[47] + D[46] + D[45] + D[43] + D[41] + D[40] +
339 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
340 D[33] + D[32] + D[31] + D[30] + D[27] + D[26] +
341 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
342 D[19] + D[18] + D[17] + D[16] + D[15] + D[13] +
343 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
344 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
345 D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
346 C[5] + C[6] + C[7] + C[12] + C[13] + C[14] +
349 myCRC[1] = ( D[63] + D[62] + D[61] + D[56] + D[55] + D[54] +
350 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
351 D[47] + D[46] + D[44] + D[42] + D[41] + D[40] +
352 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
353 D[33] + D[32] + D[31] + D[28] + D[27] + D[26] +
354 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
355 D[19] + D[18] + D[17] + D[16] + D[14] + D[13] +
356 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
357 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
358 C[0] + C[1] + C[2] + C[3] + C[4] + C[5] +
359 C[6] + C[7] + C[8] + C[13] + C[14] + C[15] )%2;
361 myCRC[2] = ( D[61] + D[60] + D[57] + D[56] + D[46] + D[42] +
362 D[31] + D[30] + D[29] + D[28] + D[16] + D[14] +
363 D[1] + D[0] + C[8] + C[9] + C[12] + C[13] )%2;
365 myCRC[3] = ( D[62] + D[61] + D[58] + D[57] + D[47] + D[43] +
366 D[32] + D[31] + D[30] + D[29] + D[17] + D[15] +
367 D[2] + D[1] + C[9] + C[10] + C[13] + C[14] )%2;
369 myCRC[4] = ( D[63] + D[62] + D[59] + D[58] + D[48] + D[44] +
370 D[33] + D[32] + D[31] + D[30] + D[18] + D[16] +
371 D[3] + D[2] + C[0] + C[10] + C[11] + C[14] +
374 myCRC[5] = ( D[63] + D[60] + D[59] + D[49] + D[45] + D[34] +
375 D[33] + D[32] + D[31] + D[19] + D[17] + D[4] +
376 D[3] + C[1] + C[11] + C[12] + C[15] )%2;
378 myCRC[6] = ( D[61] + D[60] + D[50] + D[46] + D[35] + D[34] +
379 D[33] + D[32] + D[20] + D[18] + D[5] + D[4] +
380 C[2] + C[12] + C[13] )%2;
382 myCRC[7] = ( D[62] + D[61] + D[51] + D[47] + D[36] + D[35] +
383 D[34] + D[33] + D[21] + D[19] + D[6] + D[5] +
384 C[3] + C[13] + C[14] )%2;
386 myCRC[8] = ( D[63] + D[62] + D[52] + D[48] + D[37] + D[36] +
387 D[35] + D[34] + D[22] + D[20] + D[7] + D[6] +
388 C[0] + C[4] + C[14] + C[15] )%2;
390 myCRC[9] = ( D[63] + D[53] + D[49] + D[38] + D[37] + D[36] +
391 D[35] + D[23] + D[21] + D[8] + D[7] + C[1] +
394 myCRC[10] = ( D[54] + D[50] + D[39] + D[38] + D[37] + D[36] +
395 D[24] + D[22] + D[9] + D[8] + C[2] + C[6] )%2;
397 myCRC[11] = ( D[55] + D[51] + D[40] + D[39] + D[38] + D[37] +
398 D[25] + D[23] + D[10] + D[9] + C[3] + C[7] )%2;
400 myCRC[12] = ( D[56] + D[52] + D[41] + D[40] + D[39] + D[38] +
401 D[26] + D[24] + D[11] + D[10] + C[4] + C[8] )%2;
403 myCRC[13] = ( D[57] + D[53] + D[42] + D[41] + D[40] + D[39] +
404 D[27] + D[25] + D[12] + D[11] + C[5] + C[9] )%2;
406 myCRC[14] = ( D[58] + D[54] + D[43] + D[42] + D[41] + D[40] +
407 D[28] + D[26] + D[13] + D[12] + C[6] + C[10] )%2;
409 myCRC[15] = ( D[63] + D[62] + D[61] + D[60] + D[59] + D[54] +
410 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
411 D[47] + D[46] + D[45] + D[44] + D[42] + D[40] +
412 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
413 D[33] + D[32] + D[31] + D[30] + D[29] + D[26] +
414 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
415 D[19] + D[18] + D[17] + D[16] + D[15] + D[14] +
416 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
417 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
418 D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
419 C[5] + C[6] + C[11] + C[12] + C[13] + C[14] +
423 for(
int i=0;
i<16 ;
i++){ tempC = tempC + (myCRC[
i]<<
i); }
T getParameter(std::string const &) const
EventNumber_t event() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual ~DTTFFEDSim()
Destructor.
edm::EDGetTokenT< L1MuDTChambThContainer > ChTh_tok
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)
Abs< T >::type abs(const T &t)
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
DecomposeProduct< arg, typename Div::arg > D
bool fillRawData(edm::Event &e, FEDRawDataCollection &data)
Generate and fill FED raw data for a full event.
edm::EDGetTokenT< L1MuDTTrackContainer > Trk_tok
edm::EDGetTokenT< L1MuDTChambPhContainer > ChPh_tok
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
edm::InputTag DTPHTFInputTag
DTTFFEDSim(const edm::ParameterSet &pset)
Constructor.