32 produces<L1MuDTChambPhContainer>();
33 produces<L1MuDTChambThContainer>();
34 produces<L1MuDTTrackContainer>(
"DATA");
54 if (!fillRawData(e, phi_data, the_data, tra_data))
return;
56 phi_product->setContainer(phi_data);
57 the_product->setContainer(the_data);
58 tra_product->setContainer(tra_data);
62 e.
put(tra_product,
"DATA");
94 vector<int> DTTFWordContainer;
95 vector<int>::iterator DTTFiterator;
102 int DTTFChan, bitsID;
103 int addr1[2] = { 3, 3};
104 int addr2[2] = {15, 15};
105 int addr3[2] = {15, 15};
106 int addr4[2] = {15, 15};
116 if ( dttfdata.
size() == 0 )
return;
118 int* dataWord1 =
new int;
119 int* dataWord2 =
new int;
120 unsigned char* LineFED=dttfdata.
data();
121 *dataWord2=*((
int*)LineFED);
123 *dataWord1=*((
int*)LineFED);
126 BOEevTy = ((*dataWord1)&0xFF000000)>>24;
127 DTTFId = ((*dataWord2)&0x000FFF00)>>8;
129 if( (BOEevTy != 0x50) || ( DTTFId != 0x030C) ){
131 <<
"Not a DTTF header " << hex << *dataWord1;
138 calcCRC(*dataWord1, *dataWord2, newCRC);
144 *dataWord2=*((
int*)LineFED);
146 *dataWord1=*((
int*)LineFED);
147 int chkEOE = ((*dataWord1)&0xFFF00000)>>20;
150 while(chkEOE != 0xA00){
152 calcCRC(*dataWord1, *dataWord2, newCRC);
154 DTTFWord = *dataWord1;
155 DTTFWordContainer.push_back(DTTFWord);
156 DTTFWord = *dataWord2;
157 DTTFWordContainer.push_back(DTTFWord);
160 *dataWord2=*((
int*)LineFED);
162 *dataWord1=*((
int*)LineFED);
163 chkEOE = ((*dataWord1)&0xFFF00000)>>20;
168 <<
"Warning : number of DTTF lines > 3026 ";
179 evtLgth = ((*dataWord1)&0x00FFFFFF);
180 CRC = ((*dataWord2)&0xFFFF0000)>>16;
182 calcCRC(*dataWord1, (*dataWord2)&0xFFFF, newCRC);
185 <<
"Calculated CRC " << hex << newCRC <<
" differs from CRC in trailer " << hex << CRC;
191 if( lines != evtLgth){
193 <<
"Number of words read != event length " << dec << lines <<
" " << evtLgth;
202 for( DTTFiterator = DTTFWordContainer.begin();
203 DTTFiterator != DTTFWordContainer.end();
206 DTTFChan = ((*DTTFiterator)&0xFF000000)>>24;
208 bitsID = ((*DTTFiterator)&0xF0000000)>>28;
210 int bxID = bxNr(DTTFChan);
211 if(bxID == -999)
continue;
212 int wheelID = wheel(DTTFChan);
213 if(wheelID == -999)
continue;
214 int sectorID = sector(DTTFChan);
215 if(sectorID == -999)
continue;
218 if(wheelID!=0 && bitsID<=0x9){
220 int wheelPh = (
abs(wheelID)-1)*wheelID/
abs(wheelID);
227 if ( ( bitsID >> 1 ) == 0 ){ stationID = 1;}
228 if ( ( bitsID >> 1 ) == 1 ){ stationID = 2;}
229 if ( ( bitsID >> 1 ) == 4 ){ stationID = 3;}
230 if ( ( bitsID >> 1 ) == 2 ){ stationID = 4;}
234 ts2tag = (bitsID)&0x1;
235 tsqual = (~(*DTTFiterator)&0x07)-1;
236 ba = (~(*DTTFiterator)&0x1FF8)>>3;
237 if( ba>0x1FF) ba-=0x400;
238 ra = (~(*DTTFiterator)&0x1FFE000)>>13;
239 if( ra>0x7FF) ra-=0x1000;
243 ts2tag = (bitsID)&0x1;
244 tsqual = (~(*DTTFiterator)&0x07)-1;
245 ra = (~(*DTTFiterator)&0x7FF8)>>3;
246 if( ra>0x7FF) ra-=0x1000;
249 if(tsqual!=7 && wheelID!=-1){
250 phiSegments.push_back(
252 ra, ba, tsqual, ts2tag, 0) );
258 if(wheelID==0 && bitsID<=0x4){
260 int wheelTh = bitsID-2;
262 int posALL, posBTI[7];
264 if ( wheelTh == -2 || wheelTh == -1 ||
265 ( wheelTh == 0 && (sectorID == 0 || sectorID == 3 || sectorID == 4 || sectorID == 7 || sectorID == 8 || sectorID == 11) ) ) {
267 posALL = ~(*DTTFiterator)&0x7F;
268 posBTI[0] = ~(*DTTFiterator)&0x01;
269 posBTI[1] = (~(*DTTFiterator)&0x02)>>1;
270 posBTI[2] = (~(*DTTFiterator)&0x04)>>2;
271 posBTI[3] = (~(*DTTFiterator)&0x08)>>3;
272 posBTI[4] = (~(*DTTFiterator)&0x10)>>4;
273 posBTI[5] = (~(*DTTFiterator)&0x20)>>5;
274 posBTI[6] = (~(*DTTFiterator)&0x40)>>6;
277 theSegments.push_back(
281 posALL = ~(*DTTFiterator)&0x3F80;
282 posBTI[0] = (~(*DTTFiterator)&0x0080)>>7;
283 posBTI[1] = (~(*DTTFiterator)&0x0100)>>8;
284 posBTI[2] = (~(*DTTFiterator)&0x0200)>>9;
285 posBTI[3] = (~(*DTTFiterator)&0x0400)>>10;
286 posBTI[4] = (~(*DTTFiterator)&0x0800)>>11;
287 posBTI[5] = (~(*DTTFiterator)&0x1000)>>12;
288 posBTI[6] = (~(*DTTFiterator)&0x2000)>>13;
291 theSegments.push_back(
295 posALL = ~(*DTTFiterator)&0x1FC000;
296 posBTI[0] = (~(*DTTFiterator)&0x004000)>>14;
297 posBTI[1] = (~(*DTTFiterator)&0x008000)>>15;
298 posBTI[2] = (~(*DTTFiterator)&0x010000)>>16;
299 posBTI[3] = (~(*DTTFiterator)&0x020000)>>17;
300 posBTI[4] = (~(*DTTFiterator)&0x040000)>>18;
301 posBTI[5] = (~(*DTTFiterator)&0x080000)>>19;
302 posBTI[6] = (~(*DTTFiterator)&0x100000)>>20;
305 theSegments.push_back(
312 posALL = ~(*DTTFiterator)&0x7F;
313 posBTI[6] = ~(*DTTFiterator)&0x01;
314 posBTI[5] = (~(*DTTFiterator)&0x02)>>1;
315 posBTI[4] = (~(*DTTFiterator)&0x04)>>2;
316 posBTI[3] = (~(*DTTFiterator)&0x08)>>3;
317 posBTI[2] = (~(*DTTFiterator)&0x10)>>4;
318 posBTI[1] = (~(*DTTFiterator)&0x20)>>5;
319 posBTI[0] = (~(*DTTFiterator)&0x40)>>6;
322 theSegments.push_back(
326 posALL = ~(*DTTFiterator)&0x3F80;
327 posBTI[6] = (~(*DTTFiterator)&0x0080)>>7;
328 posBTI[5] = (~(*DTTFiterator)&0x0100)>>8;
329 posBTI[4] = (~(*DTTFiterator)&0x0200)>>9;
330 posBTI[3] = (~(*DTTFiterator)&0x0400)>>10;
331 posBTI[2] = (~(*DTTFiterator)&0x0800)>>11;
332 posBTI[1] = (~(*DTTFiterator)&0x1000)>>12;
333 posBTI[0] = (~(*DTTFiterator)&0x2000)>>13;
336 theSegments.push_back(
340 posALL = ~(*DTTFiterator)&0x1FC000;
341 posBTI[6] = (~(*DTTFiterator)&0x004000)>>14;
342 posBTI[5] = (~(*DTTFiterator)&0x008000)>>15;
343 posBTI[4] = (~(*DTTFiterator)&0x010000)>>16;
344 posBTI[3] = (~(*DTTFiterator)&0x020000)>>17;
345 posBTI[2] = (~(*DTTFiterator)&0x040000)>>18;
346 posBTI[1] = (~(*DTTFiterator)&0x080000)>>19;
347 posBTI[0] = (~(*DTTFiterator)&0x100000)>>20;
350 theSegments.push_back(
358 if(wheelID!=0 && bitsID>=0xA && bitsID<=0xB){
360 int candID = bitsID - 0xA;
362 addr4[candID] = ((*DTTFiterator)&0x0F);
363 addr3[candID] = ((*DTTFiterator)&0xF0)>>4;
364 addr2[candID] = ((*DTTFiterator)&0xF00)>>8;
365 addr1[candID] = ((*DTTFiterator)&0x3000)>>12;
370 if(wheelID!=0 && bitsID>=0xC){
378 muonID = (bitsID&0x1);
379 qual = (~(*DTTFiterator)&0x07);
380 phi = ((*DTTFiterator)&0x7F8)>>3;
381 ch = (~(*DTTFiterator)&0x800)>>11;
382 pt = (~(*DTTFiterator)&0x1F000)>>12;
386 L1MuDTTrackCand( 0, phi, 0, pt, ch, 1, 0, qual, bxID, wheelID, sectorID,
387 muonID, addr1[muonID], addr2[muonID], addr3[muonID], addr4[muonID] ) );
393 if(wheelID==0 && bitsID>=0x8){
395 int wheelTh = bitsID&0x7;
399 etaALL = ~(*DTTFiterator)&0x007F;
401 etTrack[bxID+1][sectorID][wheelTh][0] = (*DTTFiterator)&0x003F;
402 efTrack[bxID+1][sectorID][wheelTh][0] = (~(*DTTFiterator)&0x0040)>>6;
405 etaALL = (~(*DTTFiterator)&0x3F80)>>7;
407 etTrack[bxID+1][sectorID][wheelTh][1]= ( (*DTTFiterator)&0x1F80)>>7;
408 efTrack[bxID+1][sectorID][wheelTh][1]= (~(*DTTFiterator)&0x2000)>>13;
425 int bxTh =
i->bx()+1;
426 int sectorTh =
i->scNum();
427 int wheelTh =
i->whNum()+3;
428 if(wheelTh > 3) wheelTh-=1;
429 int muonTh =
i->TrkTag();
431 i->setEtaPacked(etTrack[bxTh][sectorTh][wheelTh][muonTh]);
432 i->setFineHaloPacked(efTrack[bxTh][sectorTh][wheelTh][muonTh]);
456 for(
int i=0;
i<3;
i++){
457 for(
int j=0;
j<12;
j++){
458 for(
int k=0;
k<6;
k++){
459 for(
int l=0;
l<2;
l++){
460 etTrack[
i][
j][
k][
l] = 0;
461 efTrack[
i][
j][
k][
l] = 0;
479 if (
abs(bx) > 1) {
return myChannel; }
480 if ( sector < 0 || sector > 11) {
return myChannel; }
481 if (
abs(wheel) > 3) {
return myChannel; }
483 myChannel = sector*21 + wheel*3 - bx + 10 ;
485 if (myChannel > 125) myChannel += 2;
492 int myChannel = channel;
494 if (myChannel > 127) myChannel -= 2;
496 if (myChannel < 0 || myChannel > 251 ){
return -999; }
498 int myBx = 1-(myChannel%3);
505 int myChannel = channel;
507 if (myChannel > 127) myChannel -= 2;
509 if (myChannel < 0 || myChannel > 251 ){
return -999; }
516 int myChannel = channel;
518 if (myChannel > 127) myChannel -= 2;
520 if (myChannel < 0 || myChannel > 251 ){
return -999; }
522 int myWheel = ((myChannel%21)/3)-3;
529 int myCRC[16],
D[64],
C[16];
531 for(
int i=0;
i < 32;
i++ ){ D[
i]=(myD2>>
i)&0x1; }
532 for(
int i=0;
i < 32;
i++ ){ D[
i+32]=(myD1>>
i)&0x1; }
533 for(
int i=0;
i < 16;
i++ ){ C[
i]=(myC>>
i)&0x1; }
535 myCRC[0] = ( D[63] + D[62] + D[61] + D[60] + D[55] + D[54] +
536 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
537 D[47] + D[46] + D[45] + D[43] + D[41] + D[40] +
538 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
539 D[33] + D[32] + D[31] + D[30] + D[27] + D[26] +
540 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
541 D[19] + D[18] + D[17] + D[16] + D[15] + D[13] +
542 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
543 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
544 D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
545 C[5] + C[6] + C[7] + C[12] + C[13] + C[14] +
548 myCRC[1] = ( D[63] + D[62] + D[61] + D[56] + D[55] + D[54] +
549 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
550 D[47] + D[46] + D[44] + D[42] + D[41] + D[40] +
551 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
552 D[33] + D[32] + D[31] + D[28] + D[27] + D[26] +
553 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
554 D[19] + D[18] + D[17] + D[16] + D[14] + D[13] +
555 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
556 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
557 C[0] + C[1] + C[2] + C[3] + C[4] + C[5] +
558 C[6] + C[7] + C[8] + C[13] + C[14] + C[15] )%2;
560 myCRC[2] = ( D[61] + D[60] + D[57] + D[56] + D[46] + D[42] +
561 D[31] + D[30] + D[29] + D[28] + D[16] + D[14] +
562 D[1] + D[0] + C[8] + C[9] + C[12] + C[13] )%2;
564 myCRC[3] = ( D[62] + D[61] + D[58] + D[57] + D[47] + D[43] +
565 D[32] + D[31] + D[30] + D[29] + D[17] + D[15] +
566 D[2] + D[1] + C[9] + C[10] + C[13] + C[14] )%2;
568 myCRC[4] = ( D[63] + D[62] + D[59] + D[58] + D[48] + D[44] +
569 D[33] + D[32] + D[31] + D[30] + D[18] + D[16] +
570 D[3] + D[2] + C[0] + C[10] + C[11] + C[14] +
573 myCRC[5] = ( D[63] + D[60] + D[59] + D[49] + D[45] + D[34] +
574 D[33] + D[32] + D[31] + D[19] + D[17] + D[4] +
575 D[3] + C[1] + C[11] + C[12] + C[15] )%2;
577 myCRC[6] = ( D[61] + D[60] + D[50] + D[46] + D[35] + D[34] +
578 D[33] + D[32] + D[20] + D[18] + D[5] + D[4] +
579 C[2] + C[12] + C[13] )%2;
581 myCRC[7] = ( D[62] + D[61] + D[51] + D[47] + D[36] + D[35] +
582 D[34] + D[33] + D[21] + D[19] + D[6] + D[5] +
583 C[3] + C[13] + C[14] )%2;
585 myCRC[8] = ( D[63] + D[62] + D[52] + D[48] + D[37] + D[36] +
586 D[35] + D[34] + D[22] + D[20] + D[7] + D[6] +
587 C[0] + C[4] + C[14] + C[15] )%2;
589 myCRC[9] = ( D[63] + D[53] + D[49] + D[38] + D[37] + D[36] +
590 D[35] + D[23] + D[21] + D[8] + D[7] + C[1] +
593 myCRC[10] = ( D[54] + D[50] + D[39] + D[38] + D[37] + D[36] +
594 D[24] + D[22] + D[9] + D[8] + C[2] + C[6] )%2;
596 myCRC[11] = ( D[55] + D[51] + D[40] + D[39] + D[38] + D[37] +
597 D[25] + D[23] + D[10] + D[9] + C[3] + C[7] )%2;
599 myCRC[12] = ( D[56] + D[52] + D[41] + D[40] + D[39] + D[38] +
600 D[26] + D[24] + D[11] + D[10] + C[4] + C[8] )%2;
602 myCRC[13] = ( D[57] + D[53] + D[42] + D[41] + D[40] + D[39] +
603 D[27] + D[25] + D[12] + D[11] + C[5] + C[9] )%2;
605 myCRC[14] = ( D[58] + D[54] + D[43] + D[42] + D[41] + D[40] +
606 D[28] + D[26] + D[13] + D[12] + C[6] + C[10] )%2;
608 myCRC[15] = ( D[63] + D[62] + D[61] + D[60] + D[59] + D[54] +
609 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
610 D[47] + D[46] + D[45] + D[44] + D[42] + D[40] +
611 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
612 D[33] + D[32] + D[31] + D[30] + D[29] + D[26] +
613 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
614 D[19] + D[18] + D[17] + D[16] + D[15] + D[14] +
615 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
616 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
617 D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
618 C[5] + C[6] + C[11] + C[12] + C[13] + C[14] +
622 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
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