30 produces<L1MuDTChambPhContainer>();
31 produces<L1MuDTChambThContainer>();
32 produces<L1MuDTTrackContainer>(
"DATA");
52 if (!fillRawData(e, phi_data, the_data, tra_data))
return;
54 phi_product->setContainer(phi_data);
55 the_product->setContainer(the_data);
56 tra_product->setContainer(tra_data);
60 e.
put(tra_product,
"DATA");
92 vector<int> DTTFWordContainer;
93 vector<int>::iterator DTTFiterator;
100 int DTTFChan, bitsID;
101 int addr1[2] = { 3, 3};
102 int addr2[2] = {15, 15};
103 int addr3[2] = {15, 15};
104 int addr4[2] = {15, 15};
114 if ( dttfdata.
size() == 0 )
return;
116 int* dataWord1 =
new int;
117 int* dataWord2 =
new int;
118 unsigned char* LineFED=dttfdata.
data();
119 *dataWord2=*((
int*)LineFED);
121 *dataWord1=*((
int*)LineFED);
124 BOEevTy = ((*dataWord1)&0xFF000000)>>24;
125 DTTFId = ((*dataWord2)&0x000FFF00)>>8;
127 if( (BOEevTy != 0x50) || ( DTTFId != 0x030C) ){
129 <<
"Not a DTTF header " << hex << *dataWord1;
136 calcCRC(*dataWord1, *dataWord2, newCRC);
142 *dataWord2=*((
int*)LineFED);
144 *dataWord1=*((
int*)LineFED);
145 int chkEOE = ((*dataWord1)&0xFFF00000)>>20;
148 while(chkEOE != 0xA00){
150 calcCRC(*dataWord1, *dataWord2, newCRC);
152 DTTFWord = *dataWord1;
153 DTTFWordContainer.push_back(DTTFWord);
154 DTTFWord = *dataWord2;
155 DTTFWordContainer.push_back(DTTFWord);
158 *dataWord2=*((
int*)LineFED);
160 *dataWord1=*((
int*)LineFED);
161 chkEOE = ((*dataWord1)&0xFFF00000)>>20;
166 <<
"Warning : number of DTTF lines > 3026 ";
177 evtLgth = ((*dataWord1)&0x00FFFFFF);
178 CRC = ((*dataWord2)&0xFFFF0000)>>16;
180 calcCRC(*dataWord1, (*dataWord2)&0xFFFF, newCRC);
183 <<
"Calculated CRC " << hex << newCRC <<
" differs from CRC in trailer " << hex << CRC;
189 if( lines != evtLgth){
191 <<
"Number of words read != event length " << dec << lines <<
" " << evtLgth;
200 for( DTTFiterator = DTTFWordContainer.begin();
201 DTTFiterator != DTTFWordContainer.end();
204 DTTFChan = ((*DTTFiterator)&0xFF000000)>>24;
206 bitsID = ((*DTTFiterator)&0xF0000000)>>28;
208 int bxID = bxNr(DTTFChan);
209 if(bxID == -999)
continue;
210 int wheelID = wheel(DTTFChan);
211 if(wheelID == -999)
continue;
212 int sectorID = sector(DTTFChan);
213 if(sectorID == -999)
continue;
216 if(wheelID!=0 && bitsID<=0x9){
218 int wheelPh = (
abs(wheelID)-1)*wheelID/
abs(wheelID);
225 if ( ( bitsID >> 1 ) == 0 ){ stationID = 1;}
226 if ( ( bitsID >> 1 ) == 1 ){ stationID = 2;}
227 if ( ( bitsID >> 1 ) == 4 ){ stationID = 3;}
228 if ( ( bitsID >> 1 ) == 2 ){ stationID = 4;}
232 ts2tag = (bitsID)&0x1;
233 tsqual = (~(*DTTFiterator)&0x07)-1;
234 ba = (~(*DTTFiterator)&0x1FF8)>>3;
235 if( ba>0x1FF) ba-=0x400;
236 ra = (~(*DTTFiterator)&0x1FFE000)>>13;
237 if( ra>0x7FF) ra-=0x1000;
241 ts2tag = (bitsID)&0x1;
242 tsqual = (~(*DTTFiterator)&0x07)-1;
243 ra = (~(*DTTFiterator)&0x7FF8)>>3;
244 if( ra>0x7FF) ra-=0x1000;
247 if(tsqual!=7 && wheelID!=-1){
248 phiSegments.push_back(
250 ra, ba, tsqual, ts2tag, 0) );
256 if(wheelID==0 && bitsID<=0x4){
258 int wheelTh = bitsID-2;
260 int posALL, posBTI[7];
262 if ( wheelTh == -2 || wheelTh == -1 ||
263 ( wheelTh == 0 && (sectorID == 0 || sectorID == 3 || sectorID == 4 || sectorID == 7 || sectorID == 8 || sectorID == 11) ) ) {
265 posALL = ~(*DTTFiterator)&0x7F;
266 posBTI[0] = ~(*DTTFiterator)&0x01;
267 posBTI[1] = (~(*DTTFiterator)&0x02)>>1;
268 posBTI[2] = (~(*DTTFiterator)&0x04)>>2;
269 posBTI[3] = (~(*DTTFiterator)&0x08)>>3;
270 posBTI[4] = (~(*DTTFiterator)&0x10)>>4;
271 posBTI[5] = (~(*DTTFiterator)&0x20)>>5;
272 posBTI[6] = (~(*DTTFiterator)&0x40)>>6;
275 theSegments.push_back(
279 posALL = ~(*DTTFiterator)&0x3F80;
280 posBTI[0] = (~(*DTTFiterator)&0x0080)>>7;
281 posBTI[1] = (~(*DTTFiterator)&0x0100)>>8;
282 posBTI[2] = (~(*DTTFiterator)&0x0200)>>9;
283 posBTI[3] = (~(*DTTFiterator)&0x0400)>>10;
284 posBTI[4] = (~(*DTTFiterator)&0x0800)>>11;
285 posBTI[5] = (~(*DTTFiterator)&0x1000)>>12;
286 posBTI[6] = (~(*DTTFiterator)&0x2000)>>13;
289 theSegments.push_back(
293 posALL = ~(*DTTFiterator)&0x1FC000;
294 posBTI[0] = (~(*DTTFiterator)&0x004000)>>14;
295 posBTI[1] = (~(*DTTFiterator)&0x008000)>>15;
296 posBTI[2] = (~(*DTTFiterator)&0x010000)>>16;
297 posBTI[3] = (~(*DTTFiterator)&0x020000)>>17;
298 posBTI[4] = (~(*DTTFiterator)&0x040000)>>18;
299 posBTI[5] = (~(*DTTFiterator)&0x080000)>>19;
300 posBTI[6] = (~(*DTTFiterator)&0x100000)>>20;
303 theSegments.push_back(
310 posALL = ~(*DTTFiterator)&0x7F;
311 posBTI[6] = ~(*DTTFiterator)&0x01;
312 posBTI[5] = (~(*DTTFiterator)&0x02)>>1;
313 posBTI[4] = (~(*DTTFiterator)&0x04)>>2;
314 posBTI[3] = (~(*DTTFiterator)&0x08)>>3;
315 posBTI[2] = (~(*DTTFiterator)&0x10)>>4;
316 posBTI[1] = (~(*DTTFiterator)&0x20)>>5;
317 posBTI[0] = (~(*DTTFiterator)&0x40)>>6;
320 theSegments.push_back(
324 posALL = ~(*DTTFiterator)&0x3F80;
325 posBTI[6] = (~(*DTTFiterator)&0x0080)>>7;
326 posBTI[5] = (~(*DTTFiterator)&0x0100)>>8;
327 posBTI[4] = (~(*DTTFiterator)&0x0200)>>9;
328 posBTI[3] = (~(*DTTFiterator)&0x0400)>>10;
329 posBTI[2] = (~(*DTTFiterator)&0x0800)>>11;
330 posBTI[1] = (~(*DTTFiterator)&0x1000)>>12;
331 posBTI[0] = (~(*DTTFiterator)&0x2000)>>13;
334 theSegments.push_back(
338 posALL = ~(*DTTFiterator)&0x1FC000;
339 posBTI[6] = (~(*DTTFiterator)&0x004000)>>14;
340 posBTI[5] = (~(*DTTFiterator)&0x008000)>>15;
341 posBTI[4] = (~(*DTTFiterator)&0x010000)>>16;
342 posBTI[3] = (~(*DTTFiterator)&0x020000)>>17;
343 posBTI[2] = (~(*DTTFiterator)&0x040000)>>18;
344 posBTI[1] = (~(*DTTFiterator)&0x080000)>>19;
345 posBTI[0] = (~(*DTTFiterator)&0x100000)>>20;
348 theSegments.push_back(
356 if(wheelID!=0 && bitsID>=0xA && bitsID<=0xB){
358 int candID = bitsID - 0xA;
360 addr4[candID] = ((*DTTFiterator)&0x0F);
361 addr3[candID] = ((*DTTFiterator)&0xF0)>>4;
362 addr2[candID] = ((*DTTFiterator)&0xF00)>>8;
363 addr1[candID] = ((*DTTFiterator)&0x3000)>>12;
368 if(wheelID!=0 && bitsID>=0xC){
376 muonID = (bitsID&0x1);
377 qual = (~(*DTTFiterator)&0x07);
378 phi = ((*DTTFiterator)&0x7F8)>>3;
379 ch = (~(*DTTFiterator)&0x800)>>11;
380 pt = (~(*DTTFiterator)&0x1F000)>>12;
384 L1MuDTTrackCand( 0, phi, 0, pt, ch, 1, 0, qual, bxID, wheelID, sectorID,
385 muonID, addr1[muonID], addr2[muonID], addr3[muonID], addr4[muonID] ) );
391 if(wheelID==0 && bitsID>=0x8){
393 int wheelTh = bitsID&0x7;
397 etaALL = ~(*DTTFiterator)&0x007F;
399 etTrack[bxID+1][sectorID][wheelTh][0] = (*DTTFiterator)&0x003F;
400 efTrack[bxID+1][sectorID][wheelTh][0] = (~(*DTTFiterator)&0x0040)>>6;
403 etaALL = (~(*DTTFiterator)&0x3F80)>>7;
405 etTrack[bxID+1][sectorID][wheelTh][1]= ( (*DTTFiterator)&0x1F80)>>7;
406 efTrack[bxID+1][sectorID][wheelTh][1]= (~(*DTTFiterator)&0x2000)>>13;
423 int bxTh =
i->bx()+1;
424 int sectorTh =
i->scNum();
425 int wheelTh =
i->whNum()+3;
426 if(wheelTh > 3) wheelTh-=1;
427 int muonTh =
i->TrkTag();
429 i->setEtaPacked(etTrack[bxTh][sectorTh][wheelTh][muonTh]);
430 i->setFineHaloPacked(efTrack[bxTh][sectorTh][wheelTh][muonTh]);
454 for(
int i=0;
i<3;
i++){
455 for(
int j=0;
j<12;
j++){
456 for(
int k=0;
k<6;
k++){
457 for(
int l=0;
l<2;
l++){
458 etTrack[
i][
j][
k][
l] = 0;
459 efTrack[
i][
j][
k][
l] = 0;
477 if (
abs(bx) > 1) {
return myChannel; }
478 if ( sector < 0 || sector > 11) {
return myChannel; }
479 if (
abs(wheel) > 3) {
return myChannel; }
481 myChannel = sector*21 + wheel*3 - bx + 10 ;
483 if (myChannel > 125) myChannel += 2;
490 int myChannel = channel;
492 if (myChannel > 127) myChannel -= 2;
494 if (myChannel < 0 || myChannel > 251 ){
return -999; }
496 int myBx = 1-(myChannel%3);
503 int myChannel = channel;
505 if (myChannel > 127) myChannel -= 2;
507 if (myChannel < 0 || myChannel > 251 ){
return -999; }
514 int myChannel = channel;
516 if (myChannel > 127) myChannel -= 2;
518 if (myChannel < 0 || myChannel > 251 ){
return -999; }
520 int myWheel = ((myChannel%21)/3)-3;
527 int myCRC[16],
D[64],
C[16];
529 for(
int i=0;
i < 32;
i++ ){ D[
i]=(myD2>>
i)&0x1; }
530 for(
int i=0;
i < 32;
i++ ){ D[
i+32]=(myD1>>
i)&0x1; }
531 for(
int i=0;
i < 16;
i++ ){ C[
i]=(myC>>
i)&0x1; }
533 myCRC[0] = ( D[63] + D[62] + D[61] + D[60] + D[55] + D[54] +
534 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
535 D[47] + D[46] + D[45] + D[43] + D[41] + D[40] +
536 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
537 D[33] + D[32] + D[31] + D[30] + D[27] + D[26] +
538 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
539 D[19] + D[18] + D[17] + D[16] + D[15] + D[13] +
540 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
541 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
542 D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
543 C[5] + C[6] + C[7] + C[12] + C[13] + C[14] +
546 myCRC[1] = ( D[63] + D[62] + D[61] + D[56] + D[55] + D[54] +
547 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
548 D[47] + D[46] + D[44] + D[42] + D[41] + D[40] +
549 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
550 D[33] + D[32] + D[31] + D[28] + D[27] + D[26] +
551 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
552 D[19] + D[18] + D[17] + D[16] + D[14] + D[13] +
553 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
554 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
555 C[0] + C[1] + C[2] + C[3] + C[4] + C[5] +
556 C[6] + C[7] + C[8] + C[13] + C[14] + C[15] )%2;
558 myCRC[2] = ( D[61] + D[60] + D[57] + D[56] + D[46] + D[42] +
559 D[31] + D[30] + D[29] + D[28] + D[16] + D[14] +
560 D[1] + D[0] + C[8] + C[9] + C[12] + C[13] )%2;
562 myCRC[3] = ( D[62] + D[61] + D[58] + D[57] + D[47] + D[43] +
563 D[32] + D[31] + D[30] + D[29] + D[17] + D[15] +
564 D[2] + D[1] + C[9] + C[10] + C[13] + C[14] )%2;
566 myCRC[4] = ( D[63] + D[62] + D[59] + D[58] + D[48] + D[44] +
567 D[33] + D[32] + D[31] + D[30] + D[18] + D[16] +
568 D[3] + D[2] + C[0] + C[10] + C[11] + C[14] +
571 myCRC[5] = ( D[63] + D[60] + D[59] + D[49] + D[45] + D[34] +
572 D[33] + D[32] + D[31] + D[19] + D[17] + D[4] +
573 D[3] + C[1] + C[11] + C[12] + C[15] )%2;
575 myCRC[6] = ( D[61] + D[60] + D[50] + D[46] + D[35] + D[34] +
576 D[33] + D[32] + D[20] + D[18] + D[5] + D[4] +
577 C[2] + C[12] + C[13] )%2;
579 myCRC[7] = ( D[62] + D[61] + D[51] + D[47] + D[36] + D[35] +
580 D[34] + D[33] + D[21] + D[19] + D[6] + D[5] +
581 C[3] + C[13] + C[14] )%2;
583 myCRC[8] = ( D[63] + D[62] + D[52] + D[48] + D[37] + D[36] +
584 D[35] + D[34] + D[22] + D[20] + D[7] + D[6] +
585 C[0] + C[4] + C[14] + C[15] )%2;
587 myCRC[9] = ( D[63] + D[53] + D[49] + D[38] + D[37] + D[36] +
588 D[35] + D[23] + D[21] + D[8] + D[7] + C[1] +
591 myCRC[10] = ( D[54] + D[50] + D[39] + D[38] + D[37] + D[36] +
592 D[24] + D[22] + D[9] + D[8] + C[2] + C[6] )%2;
594 myCRC[11] = ( D[55] + D[51] + D[40] + D[39] + D[38] + D[37] +
595 D[25] + D[23] + D[10] + D[9] + C[3] + C[7] )%2;
597 myCRC[12] = ( D[56] + D[52] + D[41] + D[40] + D[39] + D[38] +
598 D[26] + D[24] + D[11] + D[10] + C[4] + C[8] )%2;
600 myCRC[13] = ( D[57] + D[53] + D[42] + D[41] + D[40] + D[39] +
601 D[27] + D[25] + D[12] + D[11] + C[5] + C[9] )%2;
603 myCRC[14] = ( D[58] + D[54] + D[43] + D[42] + D[41] + D[40] +
604 D[28] + D[26] + D[13] + D[12] + C[6] + C[10] )%2;
606 myCRC[15] = ( D[63] + D[62] + D[61] + D[60] + D[59] + D[54] +
607 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
608 D[47] + D[46] + D[45] + D[44] + D[42] + D[40] +
609 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
610 D[33] + D[32] + D[31] + D[30] + D[29] + D[26] +
611 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
612 D[19] + D[18] + D[17] + D[16] + D[15] + D[14] +
613 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
614 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
615 D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
616 C[5] + C[6] + C[11] + C[12] + C[13] + C[14] +
620 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
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
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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