CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TTwinMuxRawToDigi.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: DTTM7FEDReader
4 //
5 // L1 DT TwinMux Raw-to-Digi
6 //
7 //
8 //
9 // Author :
10 // C. F. Bedoya - CIEMAT
11 // G. Codispoti -- INFN Bologna
12 // J. Pazzini -- INFN Padova
13 //
14 //--------------------------------------------------
15 
16 #include "L1TTwinMuxRawToDigi.h"
17 
21 
22 #include <iostream>
23 #include <fstream>
24 
26 
27  debug_( pset.getUntrackedParameter<bool>("debug", false) ),
28  passbc0_( pset.getUntrackedParameter<bool>("passbc0", false) ),
29  nfeds_(0),
30  DTTM7InputTag_( pset.getParameter<edm::InputTag>("DTTM7_FED_Source") ),
31  feds_( pset.getUntrackedParameter<std::vector<int> >("feds", std::vector<int>()) ),
32  wheels_( pset.getUntrackedParameter<std::vector<int> >("wheels", std::vector<int>())),
33  amcsecmap_( pset.getUntrackedParameter<std::vector<long long int> >("amcsecmap", std::vector<long long int>()))
34 
35 {
36 
37  produces<L1MuDTChambPhContainer>();
38  produces<L1MuDTChambThContainer>();
39  Raw_token = consumes<FEDRawDataCollection> (DTTM7InputTag_);
40 
41  nfeds_ = feds_.size();
42 
43  if ( nfeds_ != wheels_.size() )
44  throw cms::Exception("TwinMux_unpacker") << "Configuration file error. Size of \'wheels\' and \'feds\' differs.\n";
45 
46  if ( amcsecmap_.size() != wheels_.size() )
47  throw cms::Exception("TwinMux_unpacker") << "Configuration file error. Size of \'wheels\' and \'amcsecmap\' differs.\n";
48 
49  for (size_t wh_i = 0; wh_i < amcsecmap_.size(); ++wh_i){
50  std::array<short, 12> whmap;
51  for (size_t amc_i = 1; amc_i < 13; ++amc_i ){
52  short shift = (12-amc_i)*4;
53  whmap[amc_i-1] = ( amcsecmap_[wh_i] >> shift ) & 0xF;
54  }
55  amcsec_.push_back(whmap);
56  }
57 
58 }
59 
61 
63  const edm::EventSetup& c) {
64 
65  std::auto_ptr<L1MuDTChambPhContainer> TM7phi_product(new L1MuDTChambPhContainer);
66  std::auto_ptr<L1MuDTChambThContainer> TM7the_product(new L1MuDTChambThContainer);
67 
70 
71  if ( !fillRawData(e, phi_data, the_data) ) return;
72 
73  TM7phi_product->setContainer(phi_data);
74  TM7the_product->setContainer(the_data);
75 
76  e.put(TM7phi_product);
77  e.put(TM7the_product);
78 
79 }
80 
81 
85 
87  e.getByToken( Raw_token, data );
88 
89  for ( size_t w_i = 0; w_i < nfeds_; ++w_i ) {
90  processFed( feds_[w_i], wheels_[w_i], amcsec_[w_i], data, phi_data, the_data );
91  }
92 
93  return true;
94 }
95 
97  int bxCnt_ ){
98 
99  int bxNorm_ = bx_ - bxCnt_;
100  if ( abs( bxNorm_ ) < 3000 ) return bxNorm_;
101 
102  if ( bxNorm_ > 0 ) return bxNorm_ - 3564;
103  if ( bxNorm_ < 0 ) return bxNorm_ + 3564;
104 
105  return -99;
106 
107 }
108 
110 
111  if (radAng_>2047)
112  return radAng_-4096;
113 
114  return radAng_;
115 
116 }
117 
119 
120  if (benAng_>511)
121  return benAng_-1024;
122 
123  return benAng_;
124 
125 }
126 
127 void L1TTwinMuxRawToDigi::processFed( int twinMuxFed,
128  int twinMuxWheel,
129  std::array<short, 12> twinMuxAmcSec,
133 
135  std::vector<long> DTTM7WordContainer;
136 
138  std::ofstream logfile;
139  if ( debug_ ) {
140  std::ostringstream fname;
141  fname << "eventDump_" << twinMuxFed << ".txt";
142  logfile.open( fname.str() );
143  }
144 
146  FEDRawData TM7data = data->FEDData(twinMuxFed);
147  if ( TM7data.size() == 0 ) return;
148 
150  LineFED_ = TM7data.data();
151  int nline = 0; // counting already include header
152  long dataWord = 0;
153  int newCRC = 0xFFFF;
154 
156  readline( nline, dataWord );
157  calcCRC( dataWord, newCRC );
158 
159  int TM7fedId = ( dataWord >> 8 ) & 0xFFF; // positions 8 -> 19
160  /*** NOT UNPACKED
161  int bunchCnt = ( dataWord >> 20 ) & 0xFFF; // positions 20 -> 31
162  int eventCnt = ( dataWord >> 32 ) & 0xFFFFFF; // positions 32 -> 55
163  ***/
164  int BOEevTy = ( dataWord >> 60 ) & 0xF; // positions 60 -> 63
165 
166  int linecounter = 0;
167  if ( debug_ ) logfile << '[' << ++linecounter << "]\t"
168  << std::hex << dataWord << std::dec << "\t|\t"
169  << "BOEevTy " << BOEevTy << '\t'
170  << "TM7fedId " << TM7fedId << '\n';
171 
172  if ( (BOEevTy != 0x5) || ( TM7fedId != twinMuxFed ) ) {
173 
174  edm::LogWarning("TwinMux_unpacker") << "Not a TM7 of FED "
175  << twinMuxFed << " header "
176  << std::hex << dataWord;
177  return;
178 
179  }
180 
182  readline( nline, dataWord );
183  calcCRC( dataWord, newCRC );
184 
185  std::map<int, int> AMCsizes;
186  /*** NOT UNPACKED
187  int orbit = ( dataWord >> 4 ) & 0xFFFFFFFF; // positions 4 -> 35
188  ***/
189  int nAMC = ( dataWord >> 52 ) & 0xF; // positions 52 -> 55
190 
191  if ( debug_ ) logfile << '[' << ++linecounter << "]\t" << std::hex
192  << dataWord << std::dec << "\t|\t"
193  << "nAMC " << nAMC << '\n';
194 
196  for ( int j = 0; j < nAMC; ++j ) {
197 
198  readline( nline, dataWord );
199  calcCRC( dataWord, newCRC );
200 
201  int AMCno = (dataWord >> 16 ) & 0xF; // positions 16 -> 19
202  /*** NOT UNPACKED
203  int TM7boardID = dataWord & 0xFFFF; // positions 0 -> 15
204  int bulkno = (dataWord >> 20 ) & 0xFF; // positions 20 -> 27
205  ***/
206  if ( (AMCno < 1) || (AMCno > 12) ) {
207  edm::LogWarning("TwinMux_unpacker") << "AMCnumber " << std::dec << AMCno
208  << " out of range (1-12)";
209  return;
210  }
211 
212  AMCsizes[AMCno] = ( dataWord >> 32 ) & 0xFFFFFF; // positions 32 -> 55
213 
214  if ( debug_ ) logfile << '[' << ++linecounter << "]\t"
215  << std::hex << dataWord
216  << std::dec << "\t|\t"
217  << "AMCsizes[" << AMCno << "] "
218  << AMCsizes[AMCno]
219  << std::dec << '\n';
220  }
221 
223  std::map<int,int>::iterator AMCiterator = AMCsizes.begin();
224  std::map<int,int>::iterator AMCitend = AMCsizes.end();
225  for ( ; AMCiterator != AMCitend; ++AMCiterator ) {
226 
227  for ( int k=0; k<AMCiterator->second; ++k) {
228 
229  readline( nline, dataWord );
230  calcCRC( dataWord, newCRC);
231  DTTM7WordContainer.push_back( dataWord );
232  }
233  }
234 
236  readline( nline, dataWord );
237  calcCRC( dataWord, newCRC);
238 
240 
241  readline( nline, dataWord );
242  calcCRC( dataWord & 0xFFFFFFFF0000FFFF, newCRC);
243 
245  int chkEOE = (dataWord >> 60 ) & 0xF; // positions 60 -> 63
246  int CRC = ( dataWord >> 16 ) & 0xFFFF; // positions 17 ->32
247  int evtLgth = ( dataWord >> 32 ) & 0xFFFFFF; // positions 33 ->56
248 
249  if ( chkEOE != 0xA ) {
250  edm::LogWarning("TwinMux_unpacker") << "AMC block closing line " << std::hex << dataWord
251  << std::dec << " does not start with 0xA";
252  return;
253  }
254 
255  if ( debug_ ) logfile << "\tevtLgth " << std::hex
256  << evtLgth << "\tCRC " << CRC << std::dec << '\n';
257 
258  if ( nline != evtLgth ) {
259  edm::LogWarning("TwinMux_unpacker") << "Number of words read " << std::dec << nline
260  << " and event length " << std::dec << evtLgth
261  << " differ ";
262  return;
263  }
264 
265  if ( newCRC != CRC ) {
266  edm::LogWarning("TwinMux_unpacker") << "Calculated CRC " << std::hex << newCRC
267  << " differs from CRC in trailer " << std::hex << CRC;
268  return;
269  }
270 
271  // --> Analyze event
272  std::vector<long>::iterator DTTM7iterator = DTTM7WordContainer.begin();
273  std::vector<long>::iterator DTTM7itend = DTTM7WordContainer.end();
274 
275  int lcounter = 0;
276  for ( ; DTTM7iterator != DTTM7itend; ++DTTM7iterator ) {
277 
278  dataWord = (*DTTM7iterator);
279  int dataLenght = (dataWord & 0xFFFFF); // positions 0 -> 19
280  int bxCounter = (dataWord >> 20 ) & 0xFFF; // positions 20 -> 31
281  int event = (dataWord >> 32 ) & 0xFFFFFF; // positions 32 -> 55
282  int AMC_ID = (dataWord >> 56 ) & 0xF; // positions 56 -> 59
283  int control = (dataWord >> 60 ) & 0xF; // positions 59 -> 63
284  int wheel = twinMuxWheel;
285 
286  if( ( AMC_ID < 1 ) or ( AMC_ID > 12 ) ) {
287  edm::LogWarning("TwinMux_unpacker") << "%%%%%% AMC_ID OUT OF RANGE \n"
288  << " TM7fedId " << TM7fedId
289  << " AMC_ID " << AMC_ID;
290  break;
291  }
292 
293  int sector = twinMuxAmcSec[AMC_ID-1];
294 
295  if( ( sector < 1 ) or ( sector > 12 ) ) {
296  if( sector != 15 ) edm::LogWarning("TwinMux_unpacker") << "%%%%%% VALID AMC_ID POINTS TO SECTOR OUT OF RANGE \n"
297  << " TM7fedId " << TM7fedId
298  << " AMC_ID " << AMC_ID
299  << " wheel " << wheel
300  << " sector " << sector;
301  break;
302  }
303 
304  if ( debug_ ) logfile << '[' << ++lcounter << "]\t"
305  << std::hex << dataWord << std::dec << "\t|\t"
306  << "AMC_ID " << AMC_ID << '\t'
307  << "control " << control << '\t'
308  << "event " << event << '\t'
309  << "bxCounter " << bxCounter << '\t'
310  << "dataLenght " << dataLenght << '\n';
311 
312  ++DTTM7iterator; // User word empty /// ==>> increment 2
313  if( DTTM7iterator == DTTM7itend ) {
314  edm::LogInfo("TwinMux_unpacker") << "TRAILING WORD AS A PAYLOAD END in FED "
315  << std::hex << TM7fedId
316  << std::hex << dataWord
317  << std::dec<< " [it pos "
318  << int(DTTM7iterator - DTTM7itend) << " ]";
319  break;
320  }
321 
322  dataWord = (*DTTM7iterator);
323  int boardID = (dataWord & 0xFFFF); // positions 0 -> 15
324  int orbit = (dataWord >> 16 ) & 0xFFFF; // positions 15 -> 32
325 
326  if ( DTTM7iterator == DTTM7itend ) {
327  edm::LogWarning("TwinMux_unpacker") << "%%%%%% AMC_ID " << AMC_ID
328  << " control " << control
329  << " event " << event
330  << " bxCounter " << bxCounter
331  << " size " << dataLenght
332  << " orbit " << orbit
333  << " board " << boardID
334  << " AMCsizes " << AMCsizes[AMC_ID]
335  << " it pos " << int(DTTM7iterator - DTTM7itend);
336  break;
337  }
338 
339  if (debug_ ) logfile << '[' << ++lcounter << "]\t"
340  << std::hex << dataWord
341  << std::dec << "\t|\t"
342  << " orbit " << orbit
343  << " board " << boardID << '\n';
344 
345  int AMCsize = AMCsizes[AMC_ID] - 1;
346  int bxID = 99;
347  int bc0 = -99;
348  int bxNr = -99;
349 
351  for ( int tm7eventsize = 2; tm7eventsize < AMCsize; ++tm7eventsize ) {
352 
353  ++DTTM7iterator;
354  if ( DTTM7iterator == DTTM7itend ) {
355 
356  edm::LogWarning("TwinMux_unpacker") << "UNEXPECTED END OF PAYLOAD INSIDE CHAMBER DESCRIPTION"
357  << " [it pos " << int(DTTM7iterator - DTTM7itend) << " ]" ;
358  break;
359 
360  }
361 
362  long dataWordSub = (*DTTM7iterator);
363  int selector = ( dataWordSub >> 60 ) & 0xF; // positions 60 -> 63
364 
365  if ( selector == 0x4 ) { //TSC word
366 
367  bxID = ( dataWordSub >> 48 ) & 0xFFF; // positions 48 -> 60
368  bc0 = ( dataWordSub >> 22 ) & 0x1; // positions 22 -> 23
369 
370  if ( debug_ ) {
371  logfile << '[' << ++lcounter << "]\t" << std::hex
372  << dataWordSub << '\t' << dataWordSub
373  << std::dec << "\t|\t"
374  << "bxID " << bxID << '\t'
375  << "bc0 " << bc0 << '\n';
376  }
377 
378  bxNr = normBx(bxID, bxCounter);
379 
380  }//TSC WORD
381 
382  else if ( selector == 0x1 ) { //MB1/2 word
383 
384  int mb2_phi = ( dataWordSub & 0xFFF); // positions 0 -> 11
385  int mb2_phib = ( dataWordSub >> 12 ) & 0x3FF; // positions 12 -> 21
386  int mb2_qual = ( dataWordSub >> 22 ) & 0x7; // positions 22 -> 24
387  int mb2_ts2tag = ( dataWordSub >> 26 ) & 0x1; // positions 26
388  /*** NOT UNPACKED
389  int mb2_parity = ( dataWordSub >> 27) & 0x1; // positions 27
390  ***/
391 
392  int mb1_phi = ( dataWordSub >> 32 ) & 0xFFF; // positions 32 -> 43
393  int mb1_phib = ( dataWordSub >> 44 ) & 0x3FF; // positions 44 -> 53
394  int mb1_qual = ( dataWordSub >> 54 ) & 0x7; // positions 54 -> 56
395  int mb1_ts2tag = ( dataWordSub >> 58 ) & 0x1; // positions 58
396  /*** NOT UNPACKED
397  int mb1_parity = ( dataWordSub >> 59 ) &0x1; // positions 59
398  ***/
399 
400  int mb1_phi_conv = radAngConversion(mb1_phi);
401  int mb1_phib_conv = benAngConversion(mb1_phib);
402 
403  int mb2_phi_conv = radAngConversion(mb2_phi);
404  int mb2_phib_conv = benAngConversion(mb2_phib);
405 
406  phiSegments.push_back( L1MuDTChambPhDigi( bxNr, wheel, sector-1,
407  1, mb1_phi_conv, mb1_phib_conv,
408  mb1_qual, mb1_ts2tag, bxCounter ) );
409  phiSegments.push_back( L1MuDTChambPhDigi( bxNr, wheel, sector-1,
410  2, mb2_phi_conv, mb2_phib_conv,
411  mb2_qual, mb2_ts2tag, bxCounter ) );
412 
413  if ( debug_ ) logfile << '[' << ++lcounter << "]\t"<< std::hex
414  << dataWordSub << std::dec << "\t|\t"
415  << "mb1_ts2tag " << mb1_ts2tag << '\t'
416  << "mb1_qual " << mb1_qual << '\t'
417  << "mb1_phib " << mb1_phib_conv << '\t'
418  << "mb1_phi " << mb1_phi_conv << '\t'
419  << "mb2_ts2tag " << mb2_ts2tag << '\t'
420  << "mb2_qual " << mb2_qual << '\t'
421  << "mb2_phib " << mb2_phib_conv << '\t'
422  << "mb2_phi " << mb2_phi_conv << '\n';
423  }//MB1/2 word
424 
425  else if ( selector == 0x2 ) {
426 
427  int mb4_phi = ( dataWordSub & 0xFFF); // positions 0 -> 11
428  int mb4_phib = ( dataWordSub >> 12 ) & 0x3FF; // positions 12 -> 21
429  int mb4_qual = ( dataWordSub >> 22 ) & 0x7; // positions 22 -> 24
430  int mb4_ts2tag = ( dataWordSub >> 26 ) & 0x1; // positions 26
431  /*** NOT UNPACKED
432  int mb4_parity = ( dataWordSub >> 27) & 0x1; // positions 27
433  ***/
434 
435  int mb3_phi = ( dataWordSub >> 32 ) & 0xFFF; // positions 32 -> 43
436  int mb3_qual = ( dataWordSub >> 54 ) & 0x7; // positions 54 -> 56
437  int mb3_ts2tag = ( dataWordSub >> 58 ) & 0x1; // positions 58
438  /*** NOT UNPACKED
439  int mb3_parity = ( dataWordSub >> 59 ) &0x1; // positions 59
440  ***/
441 
442  int mb3_phi_conv = radAngConversion(mb3_phi);
443  int mb3_phib_conv = 0;
444  if (passbc0_)
445  mb3_phib_conv = bc0; // fill 'mb3_phib' with the 'bc0' information
446 
447  int mb4_phi_conv = radAngConversion(mb4_phi);
448  int mb4_phib_conv = benAngConversion(mb4_phib);
449 
450  phiSegments.push_back( L1MuDTChambPhDigi( bxNr, wheel, sector-1,
451  3, mb3_phi_conv, mb3_phib_conv,
452  mb3_qual, mb3_ts2tag, bxCounter) );
453  phiSegments.push_back( L1MuDTChambPhDigi( bxNr, wheel, sector-1,
454  4, mb4_phi_conv, mb4_phib_conv,
455  mb4_qual, mb4_ts2tag, bxCounter) );
456 
457  if ( debug_ ) logfile << '[' << ++lcounter << "]\t"<< std::hex
458  << dataWordSub << std::dec << "\t|\t"
459  << "mb3_ts2tag " << mb3_ts2tag << '\t'
460  << "mb3_qual " << mb3_qual << '\t'
461  << "mb3_phib " << mb3_phib_conv << '\t'
462  << "mb3_phi " << mb3_phi_conv << '\t'
463  << "mb4_ts2tag " << mb4_ts2tag << '\t'
464  << "mb4_qual " << mb4_qual << '\t'
465  << "mb4_phib " << mb4_phib_conv << '\t'
466  << "mb4_phi " << mb4_phi_conv << '\n';
467 
468  }//MB3/4 word
469 
470 
471  else if ( selector == 0x3 ) { //etha word
472 
473  int posALL, posBTI[7];
474 
475  int mb3_eta = ( dataWordSub & 0xFF ); // positions 0 -> 7
476  int mb3_eta_HQ = ( dataWordSub >> 8 ) & 0xFF; // positions 8 -> 15
477  int mb2_eta = ( dataWordSub >> 16 ) & 0xFF; // positions 16 -> 23
478 
479  int mb2_eta_HQ = ( dataWordSub >> 32 ) & 0xFF; // positions 32 -> 39
480  int mb1_eta = ( dataWordSub >> 40 ) & 0xFF; // positions 40 -> 47
481  int mb1_eta_HQ = ( dataWordSub >> 48 ) & 0xFF; // positions 48 -> 55
482 
483  if ( debug_ ) logfile << '[' << ++lcounter << "]\t" << std::hex
484  << dataWordSub << std::dec << "\t|\t"
485  << "mb1_eta_HQ " << mb1_eta_HQ << '\t'
486  << "mb1_eta " << mb1_eta << '\t'
487  << "mb2_eta_HQ " << mb2_eta_HQ << '\t'
488  << "mb2_eta " << mb2_eta << '\t'
489  << "mb3_eta_HQ " << mb3_eta_HQ << '\t'
490  << "mb3_eta " << mb3_eta << '\n';
491 
492  posALL = mb1_eta_HQ & 0x7F;
493  posBTI[0] = mb1_eta_HQ & 0x01;
494  posBTI[1] = (mb1_eta_HQ & 0x02)>>1;
495  posBTI[2] = (mb1_eta_HQ & 0x04)>>2;
496  posBTI[3] = (mb1_eta_HQ & 0x08)>>3;
497  posBTI[4] = (mb1_eta_HQ & 0x10)>>4;
498  posBTI[5] = (mb1_eta_HQ & 0x20)>>5;
499  posBTI[6] = (mb1_eta_HQ & 0x40)>>6;
500 
501  if ( posALL ) {
502 
503  theSegments.push_back( L1MuDTChambThDigi( bxNr, wheel, sector-1, 1, posBTI) );
504 
505  }
506 
507  posALL = mb2_eta_HQ & 0x7F;
508  posBTI[0] = mb2_eta_HQ & 0x01;
509  posBTI[1] = (mb2_eta_HQ & 0x02)>>1;
510  posBTI[2] = (mb2_eta_HQ & 0x04)>>2;
511  posBTI[3] = (mb2_eta_HQ & 0x08)>>3;
512  posBTI[4] = (mb2_eta_HQ & 0x10)>>4;
513  posBTI[5] = (mb2_eta_HQ & 0x20)>>5;
514  posBTI[6] = (mb2_eta_HQ & 0x40)>>6;
515 
516  if ( posALL ) {
517 
518  theSegments.push_back( L1MuDTChambThDigi( bxNr, wheel, sector-1, 2, posBTI) );
519 
520  }
521 
522  posALL = mb3_eta_HQ & 0x7F;
523  posBTI[0] = mb3_eta_HQ & 0x01;
524  posBTI[1] = (mb3_eta_HQ & 0x02)>>1;
525  posBTI[2] = (mb3_eta_HQ & 0x04)>>2;
526  posBTI[3] = (mb3_eta_HQ & 0x08)>>3;
527  posBTI[4] = (mb3_eta_HQ & 0x10)>>4;
528  posBTI[5] = (mb3_eta_HQ & 0x20)>>5;
529  posBTI[6] = (mb3_eta_HQ & 0x40)>>6;
530 
531  if ( posALL ) {
532 
533  theSegments.push_back( L1MuDTChambThDigi( bxNr, wheel, sector-1, 3, posBTI) );
534 
535  }
536 
537  }//etha word
538 
539  else if ( selector == 0xB || selector == 0xC || selector == 0xD ) { //output etha word
540 
541  if ( debug_ ) logfile << '[' << ++lcounter << "]\t" << std::hex
542  << dataWordSub << std::dec << '\n';
543 
544  }//output etha word
545 
546  else if ( selector == 0xF ) { //ERROR word
547 
548  edm::LogInfo("TwinMux_unpacker") << "ERROR WORD [" << std::dec << tm7eventsize << "] : "
549  << std::hex << dataWordSub << std::dec
550  << " it pos " << int(DTTM7iterator - DTTM7itend);
551 
552  if ( debug_ ) logfile << '[' << ++lcounter << "]\t" << std::hex
553  << dataWordSub << std::dec
554  << "\t ERROR WORD\n";
555  }//ERROR word
556 
557  else { //unkown word
558 
559  edm::LogInfo("TwinMux_unpacker") << "UNKNOWN WORD received " << std::hex << dataWordSub
560  << " in FED " << std::hex << TM7fedId;
561 
562  if ( debug_ ) logfile << '[' << ++lcounter << "]\t" << std::hex
563  << dataWordSub << std::dec
564  << "\t UNKNOWN WORD\n";
565  }
566 
567  if( DTTM7iterator == DTTM7itend ) break;
568 
569  } //end of loop over AMCsize
570 
571 
573  ++DTTM7iterator;
574 
575  if( DTTM7iterator == DTTM7itend ) break;
576 
577  } // end for-loop container content
578 
579  return;
580 }
581 
582 
583 
584 void L1TTwinMuxRawToDigi::calcCRC( long word, int & myC ) {
585 
586  int myCRC[16], D[64], C[16];
587 
588  for ( int i = 0; i < 64; ++i ) { D[i] = (word >> i) & 0x1; }
589  for ( int i = 0; i < 16; ++i ) { C[i] = (myC>>i) & 0x1; }
590 
591  myCRC[0] = ( D[63] + D[62] + D[61] + D[60] + D[55] + D[54] +
592  D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
593  D[47] + D[46] + D[45] + D[43] + D[41] + D[40] +
594  D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
595  D[33] + D[32] + D[31] + D[30] + D[27] + D[26] +
596  D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
597  D[19] + D[18] + D[17] + D[16] + D[15] + D[13] +
598  D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
599  D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
600  D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
601  C[5] + C[6] + C[7] + C[12] + C[13] + C[14] +
602  C[15] )%2;
603 
604  myCRC[1] = ( D[63] + D[62] + D[61] + D[56] + D[55] + D[54] +
605  D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
606  D[47] + D[46] + D[44] + D[42] + D[41] + D[40] +
607  D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
608  D[33] + D[32] + D[31] + D[28] + D[27] + D[26] +
609  D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
610  D[19] + D[18] + D[17] + D[16] + D[14] + D[13] +
611  D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
612  D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
613  C[0] + C[1] + C[2] + C[3] + C[4] + C[5] +
614  C[6] + C[7] + C[8] + C[13] + C[14] + C[15] )%2;
615 
616  myCRC[2] = ( D[61] + D[60] + D[57] + D[56] + D[46] + D[42] +
617  D[31] + D[30] + D[29] + D[28] + D[16] + D[14] +
618  D[1] + D[0] + C[8] + C[9] + C[12] + C[13] )%2;
619 
620  myCRC[3] = ( D[62] + D[61] + D[58] + D[57] + D[47] + D[43] +
621  D[32] + D[31] + D[30] + D[29] + D[17] + D[15] +
622  D[2] + D[1] + C[9] + C[10] + C[13] + C[14] )%2;
623 
624  myCRC[4] = ( D[63] + D[62] + D[59] + D[58] + D[48] + D[44] +
625  D[33] + D[32] + D[31] + D[30] + D[18] + D[16] +
626  D[3] + D[2] + C[0] + C[10] + C[11] + C[14] +
627  C[15] )%2;
628 
629  myCRC[5] = ( D[63] + D[60] + D[59] + D[49] + D[45] + D[34] +
630  D[33] + D[32] + D[31] + D[19] + D[17] + D[4] +
631  D[3] + C[1] + C[11] + C[12] + C[15] )%2;
632 
633  myCRC[6] = ( D[61] + D[60] + D[50] + D[46] + D[35] + D[34] +
634  D[33] + D[32] + D[20] + D[18] + D[5] + D[4] +
635  C[2] + C[12] + C[13] )%2;
636 
637  myCRC[7] = ( D[62] + D[61] + D[51] + D[47] + D[36] + D[35] +
638  D[34] + D[33] + D[21] + D[19] + D[6] + D[5] +
639  C[3] + C[13] + C[14] )%2;
640 
641  myCRC[8] = ( D[63] + D[62] + D[52] + D[48] + D[37] + D[36] +
642  D[35] + D[34] + D[22] + D[20] + D[7] + D[6] +
643  C[0] + C[4] + C[14] + C[15] )%2;
644 
645  myCRC[9] = ( D[63] + D[53] + D[49] + D[38] + D[37] + D[36] +
646  D[35] + D[23] + D[21] + D[8] + D[7] + C[1] +
647  C[5] + C[15] )%2;
648 
649  myCRC[10] = ( D[54] + D[50] + D[39] + D[38] + D[37] + D[36] +
650  D[24] + D[22] + D[9] + D[8] + C[2] + C[6] )%2;
651 
652  myCRC[11] = ( D[55] + D[51] + D[40] + D[39] + D[38] + D[37] +
653  D[25] + D[23] + D[10] + D[9] + C[3] + C[7] )%2;
654 
655  myCRC[12] = ( D[56] + D[52] + D[41] + D[40] + D[39] + D[38] +
656  D[26] + D[24] + D[11] + D[10] + C[4] + C[8] )%2;
657 
658  myCRC[13] = ( D[57] + D[53] + D[42] + D[41] + D[40] + D[39] +
659  D[27] + D[25] + D[12] + D[11] + C[5] + C[9] )%2;
660 
661  myCRC[14] = ( D[58] + D[54] + D[43] + D[42] + D[41] + D[40] +
662  D[28] + D[26] + D[13] + D[12] + C[6] + C[10] )%2;
663 
664  myCRC[15] = ( D[63] + D[62] + D[61] + D[60] + D[59] + D[54] +
665  D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
666  D[47] + D[46] + D[45] + D[44] + D[42] + D[40] +
667  D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
668  D[33] + D[32] + D[31] + D[30] + D[29] + D[26] +
669  D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
670  D[19] + D[18] + D[17] + D[16] + D[15] + D[14] +
671  D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
672  D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
673  D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
674  C[5] + C[6] + C[11] + C[12] + C[13] + C[14] +
675  C[15] )%2;
676 
677  int tempC = 0x0;
678  for ( int i = 0; i < 16 ; ++i) { tempC = tempC + ( myCRC[i] << i ); }
679  myC = tempC;
680  return;
681 }
682 
683 
684 //define this as a plug-in
int i
Definition: DBlmapReader.cc:9
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
int normBx(int bx_, int bxCnt_)
std::vector< long long int > amcsecmap_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< std::array< short, 12 > > amcsec_
L1TTwinMuxRawToDigi(const edm::ParameterSet &pset)
Constructor.
int radAngConversion(int radAng_)
void readline(int &lines, long &dataWord)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
virtual ~L1TTwinMuxRawToDigi()
Destructor.
bool fillRawData(edm::Event &e, L1MuDTChambPhContainer::Phi_Container &phi_data, L1MuDTChambThContainer::The_Container &the_data)
Generate and fill FED raw data for a full event.
std::vector< int > feds_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
void produce(edm::Event &e, const edm::EventSetup &c)
Produce digis out of raw data.
std::vector< L1MuDTChambPhDigi > Phi_Container
std::vector< L1MuDTChambThDigi > The_Container
std::vector< int > wheels_
edm::EDGetTokenT< FEDRawDataCollection > Raw_token
edm::InputTag DTTM7InputTag_
int benAngConversion(int benAng_)
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
unsigned char * LineFED_
string fname
main script
void calcCRC(long word, int &myC)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
static unsigned int const shift
volatile std::atomic< bool > shutdown_flag false
void processFed(int twinmuxfed, int wheel, std::array< short, 12 > twinMuxAmcSec, edm::Handle< FEDRawDataCollection > data, L1MuDTChambPhContainer::Phi_Container &phi_data, L1MuDTChambThContainer::The_Container &the_data)