27 produces<L1MuDTChambPhContainer>();
28 produces<L1MuDTChambThContainer>();
29 produces<L1MuDTTrackContainer>(
"DATA");
35 Raw_token = consumes<FEDRawDataCollection>(DTTFInputTag);
51 if (!fillRawData(e, phi_data, the_data, tra_data))
return;
53 phi_product->setContainer(phi_data);
54 the_product->setContainer(the_data);
55 tra_product->setContainer(tra_data);
59 e.
put(tra_product,
"DATA");
91 vector<int> DTTFWordContainer;
92 vector<int>::iterator DTTFiterator;
100 int addr1[2] = { 3, 3};
101 int addr2[2] = {15, 15};
102 int addr3[2] = {15, 15};
103 int addr4[2] = {15, 15};
113 if ( dttfdata.
size() == 0 )
return;
115 int* dataWord1 =
new int;
116 int* dataWord2 =
new int;
117 unsigned char* LineFED=dttfdata.
data();
118 *dataWord2=*((
int*)LineFED);
120 *dataWord1=*((
int*)LineFED);
123 BOEevTy = ((*dataWord1)&0xFF000000)>>24;
124 DTTFId = ((*dataWord2)&0x000FFF00)>>8;
126 if( (BOEevTy != 0x50) || ( DTTFId != 0x030C) ){
128 <<
"Not a DTTF header " << hex << *dataWord1;
135 calcCRC(*dataWord1, *dataWord2, newCRC);
141 *dataWord2=*((
int*)LineFED);
143 *dataWord1=*((
int*)LineFED);
144 int chkEOE = ((*dataWord1)&0xFFF00000)>>20;
147 while(chkEOE != 0xA00){
149 calcCRC(*dataWord1, *dataWord2, newCRC);
151 DTTFWord = *dataWord1;
152 DTTFWordContainer.push_back(DTTFWord);
153 DTTFWord = *dataWord2;
154 DTTFWordContainer.push_back(DTTFWord);
157 *dataWord2=*((
int*)LineFED);
159 *dataWord1=*((
int*)LineFED);
160 chkEOE = ((*dataWord1)&0xFFF00000)>>20;
165 <<
"Warning : number of DTTF lines > 3026 ";
176 evtLgth = ((*dataWord1)&0x00FFFFFF);
177 CRC = ((*dataWord2)&0xFFFF0000)>>16;
179 calcCRC(*dataWord1, (*dataWord2)&0xFFFF, newCRC);
182 <<
"Calculated CRC " << hex << newCRC <<
" differs from CRC in trailer " << hex << CRC;
188 if( lines != evtLgth){
190 <<
"Number of words read != event length " << dec << lines <<
" " << evtLgth;
199 for( DTTFiterator = DTTFWordContainer.begin();
200 DTTFiterator != DTTFWordContainer.end();
203 DTTFChan = ((*DTTFiterator)&0xFF000000)>>24;
205 bitsID = ((*DTTFiterator)&0xF0000000)>>28;
207 int bxID = bxNr(DTTFChan);
208 if(bxID == -999)
continue;
209 int wheelID = wheel(DTTFChan);
210 if(wheelID == -999)
continue;
211 int sectorID = sector(DTTFChan);
212 if(sectorID == -999)
continue;
215 if(wheelID!=0 && bitsID<=0x9){
217 int wheelPh = (
abs(wheelID)-1)*wheelID/
abs(wheelID);
224 if ( ( bitsID >> 1 ) == 0 ){ stationID = 1;}
225 if ( ( bitsID >> 1 ) == 1 ){ stationID = 2;}
226 if ( ( bitsID >> 1 ) == 4 ){ stationID = 3;}
227 if ( ( bitsID >> 1 ) == 2 ){ stationID = 4;}
231 ts2tag = (bitsID)&0x1;
232 tsqual = (~(*DTTFiterator)&0x07)-1;
233 ba = (~(*DTTFiterator)&0x1FF8)>>3;
234 if( ba>0x1FF) ba-=0x400;
235 ra = (~(*DTTFiterator)&0x1FFE000)>>13;
236 if( ra>0x7FF) ra-=0x1000;
240 ts2tag = (bitsID)&0x1;
241 tsqual = (~(*DTTFiterator)&0x07)-1;
242 ra = (~(*DTTFiterator)&0x7FF8)>>3;
243 if( ra>0x7FF) ra-=0x1000;
246 if(tsqual!=7 && wheelID!=-1){
247 phiSegments.push_back(
249 ra, ba, tsqual, ts2tag, 0) );
255 if(wheelID==0 && bitsID<=0x4){
257 int wheelTh = bitsID-2;
259 int posALL, posBTI[7];
261 if ( wheelTh == -2 || wheelTh == -1 ||
262 ( wheelTh == 0 && (sectorID == 0 || sectorID == 3 || sectorID == 4 || sectorID == 7 || sectorID == 8 || sectorID == 11) ) ) {
264 posALL = ~(*DTTFiterator)&0x7F;
265 posBTI[0] = ~(*DTTFiterator)&0x01;
266 posBTI[1] = (~(*DTTFiterator)&0x02)>>1;
267 posBTI[2] = (~(*DTTFiterator)&0x04)>>2;
268 posBTI[3] = (~(*DTTFiterator)&0x08)>>3;
269 posBTI[4] = (~(*DTTFiterator)&0x10)>>4;
270 posBTI[5] = (~(*DTTFiterator)&0x20)>>5;
271 posBTI[6] = (~(*DTTFiterator)&0x40)>>6;
274 theSegments.push_back(
278 posALL = ~(*DTTFiterator)&0x3F80;
279 posBTI[0] = (~(*DTTFiterator)&0x0080)>>7;
280 posBTI[1] = (~(*DTTFiterator)&0x0100)>>8;
281 posBTI[2] = (~(*DTTFiterator)&0x0200)>>9;
282 posBTI[3] = (~(*DTTFiterator)&0x0400)>>10;
283 posBTI[4] = (~(*DTTFiterator)&0x0800)>>11;
284 posBTI[5] = (~(*DTTFiterator)&0x1000)>>12;
285 posBTI[6] = (~(*DTTFiterator)&0x2000)>>13;
288 theSegments.push_back(
292 posALL = ~(*DTTFiterator)&0x1FC000;
293 posBTI[0] = (~(*DTTFiterator)&0x004000)>>14;
294 posBTI[1] = (~(*DTTFiterator)&0x008000)>>15;
295 posBTI[2] = (~(*DTTFiterator)&0x010000)>>16;
296 posBTI[3] = (~(*DTTFiterator)&0x020000)>>17;
297 posBTI[4] = (~(*DTTFiterator)&0x040000)>>18;
298 posBTI[5] = (~(*DTTFiterator)&0x080000)>>19;
299 posBTI[6] = (~(*DTTFiterator)&0x100000)>>20;
302 theSegments.push_back(
309 posALL = ~(*DTTFiterator)&0x7F;
310 posBTI[6] = ~(*DTTFiterator)&0x01;
311 posBTI[5] = (~(*DTTFiterator)&0x02)>>1;
312 posBTI[4] = (~(*DTTFiterator)&0x04)>>2;
313 posBTI[3] = (~(*DTTFiterator)&0x08)>>3;
314 posBTI[2] = (~(*DTTFiterator)&0x10)>>4;
315 posBTI[1] = (~(*DTTFiterator)&0x20)>>5;
316 posBTI[0] = (~(*DTTFiterator)&0x40)>>6;
319 theSegments.push_back(
323 posALL = ~(*DTTFiterator)&0x3F80;
324 posBTI[6] = (~(*DTTFiterator)&0x0080)>>7;
325 posBTI[5] = (~(*DTTFiterator)&0x0100)>>8;
326 posBTI[4] = (~(*DTTFiterator)&0x0200)>>9;
327 posBTI[3] = (~(*DTTFiterator)&0x0400)>>10;
328 posBTI[2] = (~(*DTTFiterator)&0x0800)>>11;
329 posBTI[1] = (~(*DTTFiterator)&0x1000)>>12;
330 posBTI[0] = (~(*DTTFiterator)&0x2000)>>13;
333 theSegments.push_back(
337 posALL = ~(*DTTFiterator)&0x1FC000;
338 posBTI[6] = (~(*DTTFiterator)&0x004000)>>14;
339 posBTI[5] = (~(*DTTFiterator)&0x008000)>>15;
340 posBTI[4] = (~(*DTTFiterator)&0x010000)>>16;
341 posBTI[3] = (~(*DTTFiterator)&0x020000)>>17;
342 posBTI[2] = (~(*DTTFiterator)&0x040000)>>18;
343 posBTI[1] = (~(*DTTFiterator)&0x080000)>>19;
344 posBTI[0] = (~(*DTTFiterator)&0x100000)>>20;
347 theSegments.push_back(
355 if(wheelID!=0 && bitsID>=0xA && bitsID<=0xB){
357 int candID = bitsID - 0xA;
359 addr4[candID] = ((*DTTFiterator)&0x0F);
360 addr3[candID] = ((*DTTFiterator)&0xF0)>>4;
361 addr2[candID] = ((*DTTFiterator)&0xF00)>>8;
362 addr1[candID] = ((*DTTFiterator)&0x3000)>>12;
367 if(wheelID!=0 && bitsID>=0xC){
375 muonID = (bitsID&0x1);
376 qual = (~(*DTTFiterator)&0x07);
377 phi = ((*DTTFiterator)&0x7F8)>>3;
378 ch = (~(*DTTFiterator)&0x800)>>11;
379 pt = (~(*DTTFiterator)&0x1F000)>>12;
383 L1MuDTTrackCand( 0, phi, 0, pt, ch, 1, 0, qual, bxID, wheelID, sectorID,
384 muonID, addr1[muonID], addr2[muonID], addr3[muonID], addr4[muonID] ) );
390 if(wheelID==0 && bitsID>=0x8){
392 int wheelTh = bitsID&0x7;
396 etaALL = ~(*DTTFiterator)&0x007F;
398 etTrack[bxID+1][sectorID][wheelTh][0] = (*DTTFiterator)&0x003F;
399 efTrack[bxID+1][sectorID][wheelTh][0] = (~(*DTTFiterator)&0x0040)>>6;
402 etaALL = (~(*DTTFiterator)&0x3F80)>>7;
404 etTrack[bxID+1][sectorID][wheelTh][1]= ( (*DTTFiterator)&0x1F80)>>7;
405 efTrack[bxID+1][sectorID][wheelTh][1]= (~(*DTTFiterator)&0x2000)>>13;
422 int bxTh =
i->bx()+1;
423 int sectorTh =
i->scNum();
424 int wheelTh =
i->whNum()+3;
425 if(wheelTh > 3) wheelTh-=1;
426 int muonTh =
i->TrkTag();
428 i->setEtaPacked(etTrack[bxTh][sectorTh][wheelTh][muonTh]);
429 i->setFineHaloPacked(efTrack[bxTh][sectorTh][wheelTh][muonTh]);
453 for(
int i=0;
i<3;
i++){
454 for(
int j=0;
j<12;
j++){
455 for(
int k=0;
k<6;
k++){
456 for(
int l=0;
l<2;
l++){
457 etTrack[
i][
j][
k][
l] = 0;
458 efTrack[
i][
j][
k][
l] = 0;
476 if (
abs(bx) > 1) {
return myChannel; }
477 if ( sector < 0 || sector > 11) {
return myChannel; }
478 if (
abs(wheel) > 3) {
return myChannel; }
480 myChannel = sector*21 + wheel*3 - bx + 10 ;
482 if (myChannel > 125) myChannel += 2;
489 int myChannel = channel;
491 if (myChannel > 127) myChannel -= 2;
493 if (myChannel < 0 || myChannel > 251 ){
return -999; }
495 int myBx = 1-(myChannel%3);
502 int myChannel = channel;
504 if (myChannel > 127) myChannel -= 2;
506 if (myChannel < 0 || myChannel > 251 ){
return -999; }
513 int myChannel = channel;
515 if (myChannel > 127) myChannel -= 2;
517 if (myChannel < 0 || myChannel > 251 ){
return -999; }
519 int myWheel = ((myChannel%21)/3)-3;
526 int myCRC[16],
D[64],
C[16];
528 for(
int i=0;
i < 32;
i++ ){ D[
i]=(myD2>>
i)&0x1; }
529 for(
int i=0;
i < 32;
i++ ){ D[
i+32]=(myD1>>
i)&0x1; }
530 for(
int i=0;
i < 16;
i++ ){ C[
i]=(myC>>
i)&0x1; }
532 myCRC[0] = ( D[63] + D[62] + D[61] + D[60] + D[55] + D[54] +
533 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
534 D[47] + D[46] + D[45] + D[43] + D[41] + D[40] +
535 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
536 D[33] + D[32] + D[31] + D[30] + D[27] + D[26] +
537 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
538 D[19] + D[18] + D[17] + D[16] + D[15] + D[13] +
539 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
540 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
541 D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
542 C[5] + C[6] + C[7] + C[12] + C[13] + C[14] +
545 myCRC[1] = ( D[63] + D[62] + D[61] + D[56] + D[55] + D[54] +
546 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
547 D[47] + D[46] + D[44] + D[42] + D[41] + D[40] +
548 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
549 D[33] + D[32] + D[31] + D[28] + D[27] + D[26] +
550 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
551 D[19] + D[18] + D[17] + D[16] + D[14] + D[13] +
552 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
553 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
554 C[0] + C[1] + C[2] + C[3] + C[4] + C[5] +
555 C[6] + C[7] + C[8] + C[13] + C[14] + C[15] )%2;
557 myCRC[2] = ( D[61] + D[60] + D[57] + D[56] + D[46] + D[42] +
558 D[31] + D[30] + D[29] + D[28] + D[16] + D[14] +
559 D[1] + D[0] + C[8] + C[9] + C[12] + C[13] )%2;
561 myCRC[3] = ( D[62] + D[61] + D[58] + D[57] + D[47] + D[43] +
562 D[32] + D[31] + D[30] + D[29] + D[17] + D[15] +
563 D[2] + D[1] + C[9] + C[10] + C[13] + C[14] )%2;
565 myCRC[4] = ( D[63] + D[62] + D[59] + D[58] + D[48] + D[44] +
566 D[33] + D[32] + D[31] + D[30] + D[18] + D[16] +
567 D[3] + D[2] + C[0] + C[10] + C[11] + C[14] +
570 myCRC[5] = ( D[63] + D[60] + D[59] + D[49] + D[45] + D[34] +
571 D[33] + D[32] + D[31] + D[19] + D[17] + D[4] +
572 D[3] + C[1] + C[11] + C[12] + C[15] )%2;
574 myCRC[6] = ( D[61] + D[60] + D[50] + D[46] + D[35] + D[34] +
575 D[33] + D[32] + D[20] + D[18] + D[5] + D[4] +
576 C[2] + C[12] + C[13] )%2;
578 myCRC[7] = ( D[62] + D[61] + D[51] + D[47] + D[36] + D[35] +
579 D[34] + D[33] + D[21] + D[19] + D[6] + D[5] +
580 C[3] + C[13] + C[14] )%2;
582 myCRC[8] = ( D[63] + D[62] + D[52] + D[48] + D[37] + D[36] +
583 D[35] + D[34] + D[22] + D[20] + D[7] + D[6] +
584 C[0] + C[4] + C[14] + C[15] )%2;
586 myCRC[9] = ( D[63] + D[53] + D[49] + D[38] + D[37] + D[36] +
587 D[35] + D[23] + D[21] + D[8] + D[7] + C[1] +
590 myCRC[10] = ( D[54] + D[50] + D[39] + D[38] + D[37] + D[36] +
591 D[24] + D[22] + D[9] + D[8] + C[2] + C[6] )%2;
593 myCRC[11] = ( D[55] + D[51] + D[40] + D[39] + D[38] + D[37] +
594 D[25] + D[23] + D[10] + D[9] + C[3] + C[7] )%2;
596 myCRC[12] = ( D[56] + D[52] + D[41] + D[40] + D[39] + D[38] +
597 D[26] + D[24] + D[11] + D[10] + C[4] + C[8] )%2;
599 myCRC[13] = ( D[57] + D[53] + D[42] + D[41] + D[40] + D[39] +
600 D[27] + D[25] + D[12] + D[11] + C[5] + C[9] )%2;
602 myCRC[14] = ( D[58] + D[54] + D[43] + D[42] + D[41] + D[40] +
603 D[28] + D[26] + D[13] + D[12] + C[6] + C[10] )%2;
605 myCRC[15] = ( D[63] + D[62] + D[61] + D[60] + D[59] + D[54] +
606 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
607 D[47] + D[46] + D[45] + D[44] + D[42] + D[40] +
608 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
609 D[33] + D[32] + D[31] + D[30] + D[29] + D[26] +
610 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
611 D[19] + D[18] + D[17] + D[16] + D[15] + D[14] +
612 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
613 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
614 D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
615 C[5] + C[6] + C[11] + C[12] + C[13] + C[14] +
619 for(
int i=0;
i<16 ;
i++){ tempC = tempC + (myCRC[
i]<<
i); }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void produce(edm::Event &e, const edm::EventSetup &c)
Produce digis out of raw data.
size_t size() const
Lenght of the data buffer in bytes.
const L1MuDTChambThContainer::The_Container & t_data()
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual ~DTTFFEDReader()
Destructor.
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
DTTFFEDReader(const edm::ParameterSet &pset)
Constructor.
std::vector< L1MuDTTrackCand > TrackContainer
Abs< T >::type abs(const T &t)
std::vector< L1MuDTChambPhDigi > Phi_Container
std::vector< L1MuDTChambThDigi > The_Container
TrackContainer::iterator TrackIterator
void process(edm::Event &e)
void calcCRC(int myD1, int myD2, int &myC)
char data[epos_bytes_allocation]
const L1MuDTTrackContainer::TrackContainer & k_data()
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
int channel(int wheel, int sector, int bx)
void analyse(edm::Event &e)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
bool fillRawData(edm::Event &e, L1MuDTChambPhContainer::Phi_Container &phi_data, L1MuDTChambThContainer::The_Container &the_data, L1MuDTTrackContainer::TrackContainer &tra_data)
Generate and fill FED raw data for a full event.
const L1MuDTChambPhContainer::Phi_Container & p_data()
DecomposeProduct< arg, typename Div::arg > D