29 produces<L1MuDTChambPhContainer>();
30 produces<L1MuDTChambThContainer>();
31 produces<L1MuDTTrackContainer>(
"DATA");
37 Raw_token = consumes<FEDRawDataCollection>(DTTFInputTag);
53 if (!fillRawData(e, phi_data, the_data, tra_data))
return;
55 phi_product->setContainer(phi_data);
56 the_product->setContainer(the_data);
57 tra_product->setContainer(tra_data);
93 vector<int> DTTFWordContainer;
94 vector<int>::iterator DTTFiterator;
101 int DTTFChan, bitsID;
102 int addr1[2] = { 3, 3};
103 int addr2[2] = {15, 15};
104 int addr3[2] = {15, 15};
105 int addr4[2] = {15, 15};
115 if ( dttfdata.
size() == 0 )
return;
117 int* dataWord1 =
new int;
118 int* dataWord2 =
new int;
119 unsigned char* LineFED=dttfdata.
data();
120 *dataWord2=*((
int*)LineFED);
122 *dataWord1=*((
int*)LineFED);
125 BOEevTy = ((*dataWord1)&0xFF000000)>>24;
126 DTTFId = ((*dataWord2)&0x000FFF00)>>8;
128 if( (BOEevTy != 0x50) || ( DTTFId != 0x030C) ){
130 <<
"Not a DTTF header " << hex << *dataWord1;
142 *dataWord2=*((
int*)LineFED);
144 *dataWord1=*((
int*)LineFED);
145 int chkEOE = ((*dataWord1)&0xFFF00000)>>20;
148 while(chkEOE != 0xA00){
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;
184 <<
"Calculated CRC " << hex << newCRC <<
" differs from CRC in trailer " << hex << CRC;
190 if( lines != evtLgth){
192 <<
"Number of words read != event length " <<
dec << lines <<
" " << evtLgth;
201 for( DTTFiterator = DTTFWordContainer.begin();
202 DTTFiterator != DTTFWordContainer.end();
205 DTTFChan = ((*DTTFiterator)&0xFF000000)>>24;
207 bitsID = ((*DTTFiterator)&0xF0000000)>>28;
209 int bxID = bxNr(DTTFChan);
210 if(bxID == -999)
continue;
211 int wheelID =
wheel(DTTFChan);
212 if(wheelID == -999)
continue;
213 int sectorID = sector(DTTFChan);
214 if(sectorID == -999)
continue;
217 if(wheelID!=0 && bitsID<=0x9){
219 int wheelPh = (
abs(wheelID)-1)*wheelID/
abs(wheelID);
226 if ( ( bitsID >> 1 ) == 0 ){ stationID = 1;}
227 if ( ( bitsID >> 1 ) == 1 ){ stationID = 2;}
228 if ( ( bitsID >> 1 ) == 4 ){ stationID = 3;}
229 if ( ( bitsID >> 1 ) == 2 ){ stationID = 4;}
233 ts2tag = (bitsID)&0
x1;
234 tsqual = (~(*DTTFiterator)&0x07)-1;
235 ba = (~(*DTTFiterator)&0x1FF8)>>3;
236 if( ba>0x1FF) ba-=0x400;
237 ra = (~(*DTTFiterator)&0x1FFE000)>>13;
238 if( ra>0x7FF) ra-=0x1000;
242 ts2tag = (bitsID)&0
x1;
243 tsqual = (~(*DTTFiterator)&0x07)-1;
244 ra = (~(*DTTFiterator)&0x7FF8)>>3;
245 if( ra>0x7FF) ra-=0x1000;
248 if(tsqual!=7 && wheelID!=-1){
249 phiSegments.push_back(
251 ra, ba, tsqual, ts2tag, 0) );
257 if(wheelID==0 && bitsID<=0x4){
259 int wheelTh = bitsID-2;
261 int posALL, posBTI[7];
263 if ( wheelTh == -2 || wheelTh == -1 ||
264 ( wheelTh == 0 && (sectorID == 0 || sectorID == 3 || sectorID == 4 || sectorID == 7 || sectorID == 8 || sectorID == 11) ) ) {
266 posALL = ~(*DTTFiterator)&0x7F;
267 posBTI[0] = ~(*DTTFiterator)&0x01;
268 posBTI[1] = (~(*DTTFiterator)&0x02)>>1;
269 posBTI[2] = (~(*DTTFiterator)&0x04)>>2;
270 posBTI[3] = (~(*DTTFiterator)&0x08)>>3;
271 posBTI[4] = (~(*DTTFiterator)&0x10)>>4;
272 posBTI[5] = (~(*DTTFiterator)&0x20)>>5;
273 posBTI[6] = (~(*DTTFiterator)&0x40)>>6;
276 theSegments.push_back(
280 posALL = ~(*DTTFiterator)&0x3F80;
281 posBTI[0] = (~(*DTTFiterator)&0x0080)>>7;
282 posBTI[1] = (~(*DTTFiterator)&0x0100)>>8;
283 posBTI[2] = (~(*DTTFiterator)&0x0200)>>9;
284 posBTI[3] = (~(*DTTFiterator)&0x0400)>>10;
285 posBTI[4] = (~(*DTTFiterator)&0x0800)>>11;
286 posBTI[5] = (~(*DTTFiterator)&0x1000)>>12;
287 posBTI[6] = (~(*DTTFiterator)&0x2000)>>13;
290 theSegments.push_back(
294 posALL = ~(*DTTFiterator)&0x1FC000;
295 posBTI[0] = (~(*DTTFiterator)&0x004000)>>14;
296 posBTI[1] = (~(*DTTFiterator)&0x008000)>>15;
297 posBTI[2] = (~(*DTTFiterator)&0x010000)>>16;
298 posBTI[3] = (~(*DTTFiterator)&0x020000)>>17;
299 posBTI[4] = (~(*DTTFiterator)&0x040000)>>18;
300 posBTI[5] = (~(*DTTFiterator)&0x080000)>>19;
301 posBTI[6] = (~(*DTTFiterator)&0x100000)>>20;
304 theSegments.push_back(
311 posALL = ~(*DTTFiterator)&0x7F;
312 posBTI[6] = ~(*DTTFiterator)&0x01;
313 posBTI[5] = (~(*DTTFiterator)&0x02)>>1;
314 posBTI[4] = (~(*DTTFiterator)&0x04)>>2;
315 posBTI[3] = (~(*DTTFiterator)&0x08)>>3;
316 posBTI[2] = (~(*DTTFiterator)&0x10)>>4;
317 posBTI[1] = (~(*DTTFiterator)&0x20)>>5;
318 posBTI[0] = (~(*DTTFiterator)&0x40)>>6;
321 theSegments.push_back(
325 posALL = ~(*DTTFiterator)&0x3F80;
326 posBTI[6] = (~(*DTTFiterator)&0x0080)>>7;
327 posBTI[5] = (~(*DTTFiterator)&0x0100)>>8;
328 posBTI[4] = (~(*DTTFiterator)&0x0200)>>9;
329 posBTI[3] = (~(*DTTFiterator)&0x0400)>>10;
330 posBTI[2] = (~(*DTTFiterator)&0x0800)>>11;
331 posBTI[1] = (~(*DTTFiterator)&0x1000)>>12;
332 posBTI[0] = (~(*DTTFiterator)&0x2000)>>13;
335 theSegments.push_back(
339 posALL = ~(*DTTFiterator)&0x1FC000;
340 posBTI[6] = (~(*DTTFiterator)&0x004000)>>14;
341 posBTI[5] = (~(*DTTFiterator)&0x008000)>>15;
342 posBTI[4] = (~(*DTTFiterator)&0x010000)>>16;
343 posBTI[3] = (~(*DTTFiterator)&0x020000)>>17;
344 posBTI[2] = (~(*DTTFiterator)&0x040000)>>18;
345 posBTI[1] = (~(*DTTFiterator)&0x080000)>>19;
346 posBTI[0] = (~(*DTTFiterator)&0x100000)>>20;
349 theSegments.push_back(
357 if(wheelID!=0 && bitsID>=0xA && bitsID<=0xB){
359 int candID = bitsID - 0xA;
361 addr4[candID] = ((*DTTFiterator)&0x0F);
362 addr3[candID] = ((*DTTFiterator)&0xF0)>>4;
363 addr2[candID] = ((*DTTFiterator)&0xF00)>>8;
364 addr1[candID] = ((*DTTFiterator)&0x3000)>>12;
369 if(wheelID!=0 && bitsID>=0xC){
377 muonID = (bitsID&0x1);
378 qual = (~(*DTTFiterator)&0x07);
379 phi = ((*DTTFiterator)&0x7F8)>>3;
380 ch = (~(*DTTFiterator)&0x800)>>11;
381 pt = (~(*DTTFiterator)&0x1F000)>>12;
385 L1MuDTTrackCand( 0, phi, 0, pt, ch, 1, 0, qual, bxID, wheelID, sectorID,
386 muonID, addr1[muonID], addr2[muonID], addr3[muonID], addr4[muonID] ) );
392 if(wheelID==0 && bitsID>=0x8){
394 int wheelTh = bitsID&0x7;
398 etaALL = ~(*DTTFiterator)&0x007F;
400 etTrack[bxID+1][sectorID][wheelTh][0] = (*DTTFiterator)&0x003F;
401 efTrack[bxID+1][sectorID][wheelTh][0] = (~(*DTTFiterator)&0x0040)>>6;
404 etaALL = (~(*DTTFiterator)&0x3F80)>>7;
406 etTrack[bxID+1][sectorID][wheelTh][1]= ( (*DTTFiterator)&0x1F80)>>7;
407 efTrack[bxID+1][sectorID][wheelTh][1]= (~(*DTTFiterator)&0x2000)>>13;
424 int bxTh =
i->bx()+1;
425 int sectorTh =
i->scNum();
426 int wheelTh =
i->whNum()+3;
427 if(wheelTh > 3) wheelTh-=1;
428 int muonTh =
i->TrkTag();
430 i->setEtaPacked(etTrack[bxTh][sectorTh][wheelTh][muonTh]);
431 i->setFineHaloPacked(efTrack[bxTh][sectorTh][wheelTh][muonTh]);
455 for(
int i=0;
i<3;
i++){
456 for(
int j=0; j<12; j++){
457 for(
int k=0;
k<6;
k++){
458 for(
int l=0;
l<2;
l++){
459 etTrack[
i][j][
k][
l] = 0;
460 efTrack[
i][j][
k][
l] = 0;
478 if (
abs(bx) > 1) {
return myChannel; }
479 if ( sector < 0 || sector > 11) {
return myChannel; }
480 if (
abs(wheel) > 3) {
return myChannel; }
482 myChannel = sector*21 + wheel*3 - bx + 10 ;
484 if (myChannel > 125) myChannel += 2;
491 int myChannel = channel;
493 if (myChannel > 127) myChannel -= 2;
495 if (myChannel < 0 || myChannel > 251 ){
return -999; }
497 int myBx = 1-(myChannel%3);
504 int myChannel = channel;
506 if (myChannel > 127) myChannel -= 2;
508 if (myChannel < 0 || myChannel > 251 ){
return -999; }
515 int myChannel = channel;
517 if (myChannel > 127) myChannel -= 2;
519 if (myChannel < 0 || myChannel > 251 ){
return -999; }
521 int myWheel = ((myChannel%21)/3)-3;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
size_t size() const
Lenght of the data buffer in bytes.
const L1MuDTChambThContainer::The_Container & t_data()
void produce(edm::Event &e, const edm::EventSetup &c) override
Produce digis out of raw data.
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
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(long, int &)
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()
~DTTFFEDReader() override
Destructor.