CMS 3D CMS Logo

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 // C. Heidemann -- RWTH Aachen
14 //
15 //
16 // Changes & Notes:
17 // This version is able to unpack the normal and the zero suppressed data
18 // For storing the additional info from the ud flag in the raw data and not changing the output data format of the unpacker, it will be stored as the sign to the station number for Phi In and Out segments. ud == 0 is stored as a positive station number, while ud==1 is stored as a negative station number. Use abs(station) to obtain the real station.
19 // This change is transparent to old data, too.
20 // The switch between old and new unpacker code is done by the firmware revision. If it >= 93 the new unpacker code is used, otherwise the old and unmodified code is used.
21 //
22 //--------------------------------------------------
23 
24 #include "L1TTwinMuxRawToDigi.h"
25 
29 
30 #include <iostream>
31 #include <fstream>
32 
34 
35  debug_( pset.getUntrackedParameter<bool>("debug", false) ),
36  nfeds_(0),
37  DTTM7InputTag_( pset.getParameter<edm::InputTag>("DTTM7_FED_Source") ),
38  feds_( pset.getUntrackedParameter<std::vector<int> >("feds", std::vector<int>()) ),
39  wheels_( pset.getUntrackedParameter<std::vector<int> >("wheels", std::vector<int>())),
40  amcsecmap_( pset.getUntrackedParameter<std::vector<long long int> >("amcsecmap", std::vector<long long int>()))
41 
42 {
43 
44  produces<L1MuDTChambPhContainer>("PhIn").setBranchAlias("PhIn");
45  produces<L1MuDTChambThContainer>("ThIn").setBranchAlias("ThIn");
46  produces<L1MuDTChambPhContainer>("PhOut").setBranchAlias("PhOut");
47 
48  Raw_token = consumes<FEDRawDataCollection> (DTTM7InputTag_);
49 
50  nfeds_ = feds_.size();
51 
52  if ( nfeds_ != wheels_.size() )
53  throw cms::Exception("TwinMux_unpacker") << "Configuration file error. Size of \'wheels\' and \'feds\' differs.\n";
54 
55  if ( amcsecmap_.size() != wheels_.size() )
56  throw cms::Exception("TwinMux_unpacker") << "Configuration file error. Size of \'wheels\' and \'amcsecmap\' differs.\n";
57 
58  for (size_t wh_i = 0; wh_i < amcsecmap_.size(); ++wh_i){
59  std::array<short, 12> whmap;
60  for (size_t amc_i = 1; amc_i < 13; ++amc_i ){
61  short shift = (12-amc_i)*4;
62  whmap[amc_i-1] = ( amcsecmap_[wh_i] >> shift ) & 0xF;
63  }
64  amcsec_.push_back(whmap);
65  }
66 
67 }
68 
70 
72  const edm::EventSetup& c) {
73 
74  std::unique_ptr<L1MuDTChambPhContainer> TM7phi_product(new L1MuDTChambPhContainer);
75  std::unique_ptr<L1MuDTChambThContainer> TM7the_product(new L1MuDTChambThContainer);
76  std::unique_ptr<L1MuDTChambPhContainer> TM7phi_out_product(new L1MuDTChambPhContainer);
77 
81 
82  if ( !fillRawData(e, phi_data, the_data, phi_out_data) ) return;
83 
84  TM7phi_product->setContainer(phi_data);
85  TM7the_product->setContainer(the_data);
86  TM7phi_out_product->setContainer(phi_out_data);
87 
88  e.put(std::move(TM7phi_product), "PhIn");
89  e.put(std::move(TM7the_product), "ThIn");
90  e.put(std::move(TM7phi_out_product), "PhOut");
91 
92 }
93 
94 
99 
101  e.getByToken( Raw_token, data );
102 
103  for ( size_t w_i = 0; w_i < nfeds_; ++w_i ) {
104  processFed( feds_[w_i], wheels_[w_i], amcsec_[w_i], data, phi_data, the_data, phi_out_data);
105  }
106 
107  return true;
108 }
109 
111  int bxCnt_ ){
112 
113  int bxNorm_ = bx_ - bxCnt_;
114  if ( abs( bxNorm_ ) < 3000 ) return bxNorm_;
115 
116  if ( bxNorm_ > 0 ) return bxNorm_ - 3564;
117  if ( bxNorm_ < 0 ) return bxNorm_ + 3564;
118 
119  return -99;
120 
121 }
122 
124 
125  if (radAng_>2047)
126  return radAng_-4096;
127 
128  return radAng_;
129 
130 }
131 
133 
134  if (benAng_>511)
135  return benAng_-1024;
136 
137  return benAng_;
138 
139 }
140 
141 void L1TTwinMuxRawToDigi::processFed( int twinMuxFed,
142  int twinMuxWheel,
143  std::array<short, 12> twinMuxAmcSec,
147  L1MuDTChambPhContainer::Phi_Container& phioutSegments ) {
148 
149  const unsigned int fw_rev_with_zerosupression = 93 ; // put the correct Firmware Revision of the first version with zerosuppression
150  int previous_selector = -100;
152  std::vector<long> DTTM7WordContainer;
153 
155  std::ofstream logfile;
156  if ( debug_ ) {
157  std::ostringstream fname;
158  fname << "eventDump_" << twinMuxFed << ".txt";
159  logfile.open( fname.str() );
160  }
161 
163  FEDRawData TM7data = data->FEDData(twinMuxFed);
164  if ( TM7data.size() == 0 ) return;
165 
167  LineFED_ = TM7data.data();
168  int nline = 0; // counting already include header
169  long dataWord = 0;
170  int newCRC = 0xFFFF;
171 
173  readline( nline, dataWord );
174  calcCRC( dataWord, newCRC );
175 
176  int TM7fedId = ( dataWord >> 8 ) & 0xFFF; // positions 8 -> 19
177  /*** NOT UNPACKED
178  int bunchCnt = ( dataWord >> 20 ) & 0xFFF; // positions 20 -> 31
179  int eventCnt = ( dataWord >> 32 ) & 0xFFFFFF; // positions 32 -> 55
180  ***/
181  int BOEevTy = ( dataWord >> 60 ) & 0xF; // positions 60 -> 63
182 
183  int linecounter = 0;
184  if ( debug_ ) logfile << '[' << ++linecounter << "]\t"
185  << std::hex << dataWord << std::dec << "\t|\t"
186  << "BOEevTy " << BOEevTy << '\t'
187  << "TM7fedId " << TM7fedId << '\n';
188 
189  if ( (BOEevTy != 0x5) || ( TM7fedId != twinMuxFed ) ) {
190 
191  edm::LogWarning("TwinMux_unpacker") << "Not a TM7 of FED "
192  << twinMuxFed << " header "
193  << std::hex << dataWord;
194  return;
195 
196  }
197 
199  readline( nline, dataWord );
200  calcCRC( dataWord, newCRC );
201 
202  std::map<int, int> AMCsizes;
203  /*** NOT UNPACKED
204  int orbit = ( dataWord >> 4 ) & 0xFFFFFFFF; // positions 4 -> 35
205  ***/
206  int nAMC = ( dataWord >> 52 ) & 0xF; // positions 52 -> 55
207 
208  if ( debug_ ) logfile << '[' << ++linecounter << "]\t" << std::hex
209  << dataWord << std::dec << "\t|\t"
210  << "nAMC " << nAMC << '\n';
211 
213  for ( int j = 0; j < nAMC; ++j ) {
214 
215  readline( nline, dataWord );
216  calcCRC( dataWord, newCRC );
217 
218  int AMCno = (dataWord >> 16 ) & 0xF; // positions 16 -> 19
219  /*** NOT UNPACKED
220  int TM7boardID = dataWord & 0xFFFF; // positions 0 -> 15
221  int bulkno = (dataWord >> 20 ) & 0xFF; // positions 20 -> 27
222  ***/
223  if ( (AMCno < 1) || (AMCno > 12) ) {
224  edm::LogWarning("TwinMux_unpacker") << "AMCnumber " << std::dec << AMCno
225  << " out of range (1-12)";
226  return;
227  }
228 
229  AMCsizes[AMCno] = ( dataWord >> 32 ) & 0xFFFFFF; // positions 32 -> 55
230 
231  if ( debug_ ) logfile << '[' << ++linecounter << "]\t"
232  << std::hex << dataWord
233  << std::dec << "\t|\t"
234  << "AMCsizes[" << AMCno << "] "
235  << AMCsizes[AMCno]
236  << std::dec << '\n';
237  }
238 
240  std::map<int,int>::iterator AMCiterator = AMCsizes.begin();
241  std::map<int,int>::iterator AMCitend = AMCsizes.end();
242  for ( ; AMCiterator != AMCitend; ++AMCiterator ) {
243 
244  for ( int k=0; k<AMCiterator->second; ++k) {
245 
246  readline( nline, dataWord );
247  calcCRC( dataWord, newCRC);
248  DTTM7WordContainer.push_back( dataWord );
249  }
250  }
251 
253  readline( nline, dataWord );
254  calcCRC( dataWord, newCRC);
255 
257 
258  readline( nline, dataWord );
259  calcCRC( dataWord & 0xFFFFFFFF0000FFFF, newCRC);
260 
262  int chkEOE = (dataWord >> 60 ) & 0xF; // positions 60 -> 63
263  int CRC = ( dataWord >> 16 ) & 0xFFFF; // positions 17 ->32
264  int evtLgth = ( dataWord >> 32 ) & 0xFFFFFF; // positions 33 ->56
265 
266  if ( chkEOE != 0xA ) {
267  edm::LogWarning("TwinMux_unpacker") << "AMC block closing line " << std::hex << dataWord
268  << std::dec << " does not start with 0xA";
269  return;
270  }
271 
272  if ( debug_ ) logfile << "\tevtLgth " << std::hex
273  << evtLgth << "\tCRC " << CRC << std::dec << '\n';
274 
275  if ( nline != evtLgth ) {
276  edm::LogWarning("TwinMux_unpacker") << "Number of words read " << std::dec << nline
277  << " and event length " << std::dec << evtLgth
278  << " differ ";
279  return;
280  }
281 
282  if ( newCRC != CRC ) {
283  edm::LogWarning("TwinMux_unpacker") << "Calculated CRC " << std::hex << newCRC
284  << " differs from CRC in trailer " << std::hex << CRC;
285  return;
286  }
287 
288  // --> Analyze event
289  std::vector<long>::iterator DTTM7iterator = DTTM7WordContainer.begin();
290  std::vector<long>::iterator DTTM7itend = DTTM7WordContainer.end();
291 
292  int lcounter = 0;
293  for ( ; DTTM7iterator != DTTM7itend; ++DTTM7iterator ) {
294 
295  dataWord = (*DTTM7iterator);
296  int dataLenght = (dataWord & 0xFFFFF); // positions 0 -> 19
297  int bxCounter = (dataWord >> 20 ) & 0xFFF; // positions 20 -> 31
298  int event = (dataWord >> 32 ) & 0xFFFFFF; // positions 32 -> 55
299  int AMC_ID = (dataWord >> 56 ) & 0xF; // positions 56 -> 59
300  int control = (dataWord >> 60 ) & 0xF; // positions 59 -> 63
301  int wheel = twinMuxWheel;
302 
303  if( ( AMC_ID < 1 ) or ( AMC_ID > 12 ) ) {
304  edm::LogWarning("TwinMux_unpacker") << "%%%%%% AMC_ID OUT OF RANGE \n"
305  << " TM7fedId " << TM7fedId
306  << " AMC_ID " << AMC_ID;
307  break;
308  }
309 
310  int sector = twinMuxAmcSec[AMC_ID-1];
311 
312  if( ( sector < 1 ) or ( sector > 12 ) ) {
313  if( sector != 15 ) edm::LogWarning("TwinMux_unpacker") << "%%%%%% VALID AMC_ID POINTS TO SECTOR OUT OF RANGE \n"
314  << " TM7fedId " << TM7fedId
315  << " AMC_ID " << AMC_ID
316  << " wheel " << wheel
317  << " sector " << sector;
318  break;
319  }
320 
321  if ( debug_ ) logfile << '[' << ++lcounter << "]\t"
322  << std::hex << dataWord << std::dec << "\t|\t"
323  << "AMC_ID " << AMC_ID << '\t'
324  << "control " << control << '\t'
325  << "event " << event << '\t'
326  << "bxCounter " << bxCounter << '\t'
327  << "dataLenght " << dataLenght << '\n';
328 
329  ++DTTM7iterator; // User word empty /// ==>> increment 2
330  if( DTTM7iterator == DTTM7itend ) {
331  edm::LogInfo("TwinMux_unpacker") << "TRAILING WORD AS A PAYLOAD END in FED "
332  << std::hex << TM7fedId
333  << std::hex << dataWord
334  << std::dec<< " [it pos "
335  << int(DTTM7iterator - DTTM7itend) << " ]";
336  break;
337  }
338 
339  dataWord = (*DTTM7iterator);
340  unsigned int firmware_rev = (dataWord >>7) & 0x1FF ;
341  int boardID = (dataWord & 0xFFFF); // positions 0 -> 15
342  int orbit = (dataWord >> 16 ) & 0xFFFF; // positions 15 -> 32
343 
344  if ( DTTM7iterator == DTTM7itend ) {
345  edm::LogWarning("TwinMux_unpacker") << "%%%%%% AMC_ID " << AMC_ID
346  << " control " << control
347  << " event " << event
348  << " bxCounter " << bxCounter
349  << " size " << dataLenght
350  << " orbit " << orbit
351  << " board " << boardID
352  << " AMCsizes " << AMCsizes[AMC_ID]
353  << " it pos " << int(DTTM7iterator - DTTM7itend);
354  break;
355  }
356 
357  if (debug_ ) logfile << '[' << ++lcounter << "]\t"
358  << std::hex << dataWord
359  << std::dec << "\t|\t"
360  << " orbit " << orbit
361  << " board " << boardID << '\n';
362 
363  int AMCsize = AMCsizes[AMC_ID] - 1;
364  int bxID = 99;
365  int bc0 = -99;
366  int bxNr = -99;
367 
369  for ( int tm7eventsize = 2; tm7eventsize < AMCsize; ++tm7eventsize ) {
370 
371  ++DTTM7iterator;
372  if ( DTTM7iterator == DTTM7itend ) {
373 
374  edm::LogWarning("TwinMux_unpacker") << "UNEXPECTED END OF PAYLOAD INSIDE CHAMBER DESCRIPTION"
375  << " [it pos " << int(DTTM7iterator - DTTM7itend) << " ]" ;
376  break;
377 
378  }
379 
380  long dataWordSub = (*DTTM7iterator);
381  int selector = ( dataWordSub >> 60 ) & 0xF; // positions 60 -> 63
382 
383  if (firmware_rev >= fw_rev_with_zerosupression ){ // zerosuppressed data unpacking
384  if ( selector == 0xC ) {
385 
386  bc0 = ( dataWordSub >> 59 ) & 0x1; // position 59
387  /*** NOT UNPACKED
388  int L1A = ( dataWordSub >> 58) & 0x1; // position 58
389  ***/
390  int bxOffset = ( dataWordSub >> 48 ) & 0x3F; // positions 48 -> 53
394  bxNr = bxOffset < 32 ? bxOffset : bxOffset - 64;
395 
396 
397 
398  //eta info
399 
400  int posBTI[7], qualBTI[7];
401 
402  int mb3_eta = ( dataWordSub & 0xFF ); // positions 0 -> 7
403  int mb3_eta_HQ = ( dataWordSub >> 8 ) & 0xFF; // positions 8 -> 15
404  int mb2_eta = ( dataWordSub >> 16 ) & 0xFF; // positions 16 -> 23
405  int mb2_eta_HQ = ( dataWordSub >> 24 ) & 0xFF; // positions 24 -> 31
406  int mb1_eta = ( dataWordSub >> 32 ) & 0xFF; // positions 32 -> 39
407  int mb1_eta_HQ = ( dataWordSub >> 40 ) & 0xFF; // positions 40 -> 47
408 
409  //MB1
410  for (int i = 0 ; i<=5; i++){
411  posBTI[i] = (mb1_eta >> i) & 0x01;
412  qualBTI[i] = (mb1_eta_HQ >> i) & 0x01;
413  }
414  posBTI[6] = (((mb1_eta >> 6) & 0x01) || ((mb1_eta >> 7) & 0x01));
415  qualBTI[6] = (((mb1_eta_HQ >> 6) & 0x01) || ((mb1_eta_HQ >> 7) & 0x01));
416 
417  theSegments.push_back( L1MuDTChambThDigi( bxNr, wheel, sector-1, 1, posBTI, qualBTI) );
418 
419  // posBTI and qualBTI are reused!
420 
421  //MB2
422  for (int i = 0 ; i<=5; i++){
423  posBTI[i] = (mb2_eta >> i) & 0x01;
424  qualBTI[i] = (mb2_eta_HQ >> i) & 0x01;
425  }
426  posBTI[6] = ((mb2_eta >> 6) & 0x01) || ((mb2_eta >> 7) & 0x01);
427  qualBTI[6] = ((mb2_eta_HQ >> 6) & 0x01) || ((mb2_eta_HQ >> 7) & 0x01);
428 
429  theSegments.push_back( L1MuDTChambThDigi( bxNr, wheel, sector-1, 2, posBTI, qualBTI) );
430 
431  //MB3
432  for (int i = 0 ; i<=5; i++){
433  posBTI[i] = (mb3_eta >> i) & 0x01;
434  qualBTI[i] = (mb3_eta_HQ >> i) & 0x01;
435  }
436  posBTI[6] = ((mb3_eta >> 6) & 0x01) || ((mb3_eta >> 7) & 0x01);
437  qualBTI[6] = ((mb3_eta_HQ >> 6) & 0x01) || ((mb3_eta_HQ >> 7) & 0x01);
438 
439  theSegments.push_back( L1MuDTChambThDigi( bxNr, wheel, sector-1, 3, posBTI, qualBTI) );
440 
441  if ( debug_ ) logfile << '[' << ++lcounter << "]\t" << std::hex
442  << dataWordSub << std::dec
443  << "\t bx info word\t"
444  << "bxOffset " << bxOffset << '\t'
445  << "bc0 " << bc0 << '\t'
446  << "mb1_eta " << mb1_eta << '\t'
447  << "mb2_eta " << mb2_eta << '\t'
448  << "mb3_eta " << mb3_eta << '\t'
449  << "mb1_eta_HQ " << mb1_eta_HQ << '\t'
450  << "mb2_eta_HQ " << mb2_eta_HQ << '\t'
451  << "mb3_eta_HQ " << mb3_eta_HQ << '\n';
452 
453  }
454 
455  else if ( selector >= 1 && selector <= 4 ) {
456 
457  int out_phi = ( dataWordSub >> 0 ) & 0xFFF;// positions 0 -> 11
458  int out_phib = ( dataWordSub >> 12 ) & 0x3FF; // positions 12 -> 21
459  int out_qual = ( dataWordSub >> 22 ) & 0x7; // positions 22 -> 24
460  int out_q3 = ( dataWordSub >> 25 ) & 0x1; // positions 25
461  int out_q4 = ( dataWordSub >> 26 ) & 0x1; // positions 26
462  int out_updown = ( dataWordSub >> 27 ) & 0x1; // positions 27
463  int out_ts2tag = ( dataWordSub >> 28 ) & 0x1; // positions 28
464  /*** NOT UNPACKED
465  int out_parity = ( dataWordSub >> 29) & 0x1; // positions 29
466  ***/
467  int in_phi = ( dataWordSub >> 30 ) & 0xFFF;// positions 30 -> 41
468  int in_phib = ( dataWordSub >> 42 ) & 0x3FF; // positions 42 -> 51
469  int in_qual = ( dataWordSub >> 52 ) & 0x7; // positions 52 -> 54
470  int in_updown = ( dataWordSub >> 57 ) & 0x1; // positions 57
471  int in_ts2tag = ( dataWordSub >> 58 ) & 0x1; // positions 58
472  /*** NOT UNPACKED
473  int in_parity = ( dataWordSub >> 59) & 0x1; // positions 59
474  ***/
475 
476  int in_phi_conv = radAngConversion(in_phi);
477  int in_phib_conv = benAngConversion(in_phib);
478  int out_phi_conv = radAngConversion(out_phi);
479  int out_phib_conv = benAngConversion(out_phib);
480 
481  if (previous_selector != selector ) { // first track
482  if ( in_qual != 7) {
483 
484  phiSegments.push_back( L1MuDTChambPhDigi( bxNr, wheel, sector-1,
485  selector,
486  in_phi_conv, in_phib_conv,
487  in_qual, in_ts2tag + in_updown*2, bxCounter ) );
488  }
489  if ( out_qual != 7) {
490  phioutSegments.push_back( L1MuDTChambPhDigi( bxNr, wheel, sector-1,
491  selector,
492  out_phi_conv, out_phib_conv,
493  out_qual, out_ts2tag+ out_updown*2, bxCounter,
494  out_q3 + 2*out_q4 ) );
495  }
496  } else { // currently no seperation between first/second in data, keep it for possible later fix
497  // second track
498  if ( in_qual != 7) {
499  phiSegments.push_back( L1MuDTChambPhDigi( bxNr, wheel, sector-1,
500  selector,
501  in_phi_conv, in_phib_conv,
502  in_qual, in_ts2tag + in_updown*2, bxCounter ) );
503  }
504 
505  if ( out_qual != 7) {
506  phioutSegments.push_back( L1MuDTChambPhDigi( bxNr, wheel, sector-1,
507  selector,
508  out_phi_conv, out_phib_conv,
509  out_qual, out_ts2tag + out_updown*2, bxCounter,
510  out_q3 + 2*out_q4 ) );
511  }
512 
513  }
514  if ( debug_ ) logfile << '[' << ++lcounter << "]\t"<< std::hex
515  << dataWordSub << std::dec << "\t|\t"
516  << "in_ts2tag " << in_ts2tag << '\t'
517  << "in_updown " << in_updown << '\t'
518  << "in_qual " << in_qual << '\t'
519  << "in_phib " << in_phib_conv << '\t'
520  << "in_phi " << in_phi_conv << '\t'
521  << "out_ts2tag " << out_ts2tag << '\t'
522  << "out_updown " << out_updown << '\t'
523  << "out_qual " << out_qual << '\t'
524  << "out_q3_out " << out_q3 << '\t'
525  << "out_q4_out " << out_q4 << '\t'
526  << "out_phib " << out_phib_conv << '\t'
527  << "out_phi " << out_phi_conv << '\t'
528  << "2nd track " << ((previous_selector == selector)?1:0) << '\n';
529  }
530 
531  else if ( selector == 0x9 || selector == 0xE ) { //RPC word
532 
533  edm::LogInfo("TwinMux_unpacker") << "RPC WORD [" << std::dec << tm7eventsize << "] : "
534  << std::hex << dataWordSub << std::dec
535  << " it pos " << int(DTTM7iterator - DTTM7itend);
536 
537  if ( debug_ ) logfile << '[' << ++lcounter << "]\t" << std::hex
538  << dataWordSub << std::dec
539  << "\t RPC WORD\n";
540 
541  }//RPC word
542 
543  else if ( selector == 0x6 ) { //HO word
544 
545  edm::LogInfo("TwinMux_unpacker") << "HO WORD [" << std::dec << tm7eventsize << "] : "
546  << std::hex << dataWordSub << std::dec
547  << " it pos " << int(DTTM7iterator - DTTM7itend);
548 
549  if ( debug_ ) logfile << '[' << ++lcounter << "]\t" << std::hex
550  << dataWordSub << std::dec
551  << "\t HO WORD\n";
552 
553  }//HO word
554 
555  else if ( selector == 0xF ) { //ERROR word
556 
557  edm::LogInfo("TwinMux_unpacker") << "ERROR WORD [" << std::dec << tm7eventsize << "] : "
558  << std::hex << dataWordSub << std::dec
559  << " it pos " << int(DTTM7iterator - DTTM7itend);
560 
561  if ( debug_ ) logfile << '[' << ++lcounter << "]\t" << std::hex
562  << dataWordSub << std::dec
563  << "\t ERROR WORD\n";
564  }//ERROR word
565 
566  else { //unkown word
567 
568  edm::LogInfo("TwinMux_unpacker") << "UNKNOWN WORD received " << std::hex << dataWordSub
569  << " in FED " << std::hex << TM7fedId;
570 
571  if ( debug_ ) logfile << '[' << ++lcounter << "]\t" << std::hex
572  << dataWordSub << std::dec
573  << "\t UNKNOWN WORD\n";
574  }
575  previous_selector = selector ; // store selector to identify 2nd track
576  } else {
577  // normal data unpacking below
578  if ( selector == 0x4 ) { //TSC word
579 
580  bxID = ( dataWordSub >> 48 ) & 0xFFF; // positions 48 -> 60
581  bc0 = ( dataWordSub >> 22 ) & 0x1; // positions 22 -> 23
582  bxNr = normBx(bxID, bxCounter);
583 
584  if ( debug_ ) logfile << '[' << ++lcounter << "]\t" << std::hex
585  << dataWordSub << std::dec
586  << "\t TSC WORD\t"
587  << "bxID " << bxID << '\t'
588  << "bc0 " << bc0 << '\n';
589 
590  }//TSC WORD
591 
592  else if ( selector == 0x1 ) { //MB1/2 word
593 
594  int mb2_phi = ( dataWordSub & 0xFFF); // positions 0 -> 11
595  int mb2_phib = ( dataWordSub >> 12 ) & 0x3FF; // positions 12 -> 21
596  int mb2_qual = ( dataWordSub >> 22 ) & 0x7; // positions 22 -> 24
597  int mb2_ts2tag = ( dataWordSub >> 28 ) & 0x1; // positions 28
598  /*** NOT UNPACKED
599  int mb2_parity = ( dataWordSub >> 29) & 0x1; // positions 29
600  ***/
601 
602  int mb1_phi = ( dataWordSub >> 30 ) & 0xFFF; // positions 30 -> 41
603  int mb1_phib = ( dataWordSub >> 42 ) & 0x3FF; // positions 42 -> 51
604  int mb1_qual = ( dataWordSub >> 52 ) & 0x7; // positions 52 -> 54
605  int mb1_ts2tag = ( dataWordSub >> 58 ) & 0x1; // positions 58
606  /*** NOT UNPACKED
607  int mb1_parity = ( dataWordSub >> 59 ) &0x1; // positions 59
608  ***/
609 
610  int mb1_phi_conv = radAngConversion(mb1_phi);
611  int mb1_phib_conv = benAngConversion(mb1_phib);
612 
613  int mb2_phi_conv = radAngConversion(mb2_phi);
614  int mb2_phib_conv = benAngConversion(mb2_phib);
615 
616  phiSegments.push_back( L1MuDTChambPhDigi( bxNr, wheel, sector-1,
617  1, mb1_phi_conv, mb1_phib_conv,
618  mb1_qual, mb1_ts2tag, bxCounter , -1) );
619  phiSegments.push_back( L1MuDTChambPhDigi( bxNr, wheel, sector-1,
620  2, mb2_phi_conv, mb2_phib_conv,
621  mb2_qual, mb2_ts2tag, bxCounter , -1) );
622 
623  if ( debug_ ) logfile << '[' << ++lcounter << "]\t"<< std::hex
624  << dataWordSub << std::dec << "\t|\t"
625  << "mb1_ts2tag " << mb1_ts2tag << '\t'
626  << "mb1_qual " << mb1_qual << '\t'
627  << "mb1_phib " << mb1_phib_conv << '\t'
628  << "mb1_phi " << mb1_phi_conv << '\t'
629  << "mb2_ts2tag " << mb2_ts2tag << '\t'
630  << "mb2_qual " << mb2_qual << '\t'
631  << "mb2_phib " << mb2_phib_conv << '\t'
632  << "mb2_phi " << mb2_phi_conv << '\n';
633  }//MB1/2 word
634 
635  else if ( selector == 0x2 ) {
636 
637  int mb4_phi = ( dataWordSub & 0xFFF); // positions 0 -> 11
638  int mb4_phib = ( dataWordSub >> 12 ) & 0x3FF; // positions 12 -> 21
639  int mb4_qual = ( dataWordSub >> 22 ) & 0x7; // positions 22 -> 24
640  int mb4_ts2tag = ( dataWordSub >> 28 ) & 0x1; // positions 28
641  /*** NOT UNPACKED
642  int mb4_parity = ( dataWordSub >> 29) & 0x1; // positions 29
643  ***/
644 
645  int mb3_phi = ( dataWordSub >> 30 ) & 0xFFF; // positions 30 -> 41
646  int mb3_phib = ( dataWordSub >> 42 ) & 0x3FF; // positions 42 -> 51
647  int mb3_qual = ( dataWordSub >> 52 ) & 0x7; // positions 52 -> 54
648  int mb3_ts2tag = ( dataWordSub >> 58 ) & 0x1; // positions 58
649  /*** NOT UNPACKED
650  int mb3_parity = ( dataWordSub >> 59 ) &0x1; // positions 59
651  ***/
652 
653  int mb3_phi_conv = radAngConversion(mb3_phi);
654  int mb3_phib_conv = benAngConversion(mb3_phib);
655 
656  int mb4_phi_conv = radAngConversion(mb4_phi);
657  int mb4_phib_conv = benAngConversion(mb4_phib);
658 
659  phiSegments.push_back( L1MuDTChambPhDigi( bxNr, wheel, sector-1,
660  3, mb3_phi_conv, mb3_phib_conv,
661  mb3_qual, mb3_ts2tag, bxCounter, -1) );
662  phiSegments.push_back( L1MuDTChambPhDigi( bxNr, wheel, sector-1,
663  4, mb4_phi_conv, mb4_phib_conv,
664  mb4_qual, mb4_ts2tag, bxCounter, -1) );
665 
666  if ( debug_ ) logfile << '[' << ++lcounter << "]\t"<< std::hex
667  << dataWordSub << std::dec << "\t|\t"
668  << "mb3_ts2tag " << mb3_ts2tag << '\t'
669  << "mb3_qual " << mb3_qual << '\t'
670  << "mb3_phib " << mb3_phib_conv << '\t'
671  << "mb3_phi " << mb3_phi_conv << '\t'
672  << "mb4_ts2tag " << mb4_ts2tag << '\t'
673  << "mb4_qual " << mb4_qual << '\t'
674  << "mb4_phib " << mb4_phib_conv << '\t'
675  << "mb4_phi " << mb4_phi_conv << '\n';
676 
677  }//MB3/4 word
678 
679  else if ( selector == 0x3 ) { //etha word
680 
681  int posBTI[7], qualBTI[7];
682 
683  int mb3_eta = ( dataWordSub & 0xFF ); // positions 0 -> 7
684  int mb2_eta = ( dataWordSub >> 16 ) & 0xFF; // positions 16 -> 23
685  int mb1_eta = ( dataWordSub >> 40 ) & 0xFF; // positions 40 -> 47
686 
687  int mb3_eta_HQ = ( dataWordSub >> 8 ) & 0xFF; // positions 8 -> 15
688  int mb2_eta_HQ = ( dataWordSub >> 32 ) & 0xFF; // positions 32 -> 39
689  int mb1_eta_HQ = ( dataWordSub >> 48 ) & 0xFF; // positions 48 -> 55
690 
691  if ( debug_ ) logfile << '[' << ++lcounter << "]\t" << std::hex
692  << dataWordSub << std::dec << "\t|\t"
693  << "mb1_eta " << mb1_eta << '\t'
694  << "mb2_eta " << mb2_eta << '\t'
695  << "mb3_eta " << mb3_eta << '\t'
696  << "mb1_eta_HQ " << mb1_eta_HQ << '\t'
697  << "mb2_eta_HQ " << mb2_eta_HQ << '\t'
698  << "mb3_eta_HQ " << mb3_eta_HQ << '\n';
699 
700  //MB1
701  posBTI[0] = (mb1_eta & 0x01);
702  posBTI[1] = ((mb1_eta & 0x02)>>1);
703  posBTI[2] = ((mb1_eta & 0x04)>>2);
704  posBTI[3] = ((mb1_eta & 0x08)>>3);
705  posBTI[4] = ((mb1_eta & 0x10)>>4);
706  posBTI[5] = ((mb1_eta & 0x20)>>5);
707  posBTI[6] = (((mb1_eta & 0x40)>>6) || ((mb1_eta & 0x80)>>7));
708 
709  qualBTI[0] = (mb1_eta_HQ & 0x01);
710  qualBTI[1] = ((mb1_eta_HQ & 0x02)>>1);
711  qualBTI[2] = ((mb1_eta_HQ & 0x04)>>2);
712  qualBTI[3] = ((mb1_eta_HQ & 0x08)>>3);
713  qualBTI[4] = ((mb1_eta_HQ & 0x10)>>4);
714  qualBTI[5] = ((mb1_eta_HQ & 0x20)>>5);
715  qualBTI[6] = (((mb1_eta_HQ & 0x40)>>6) || ((mb1_eta_HQ & 0x80)>>7));
716 
717  theSegments.push_back( L1MuDTChambThDigi( bxNr, wheel, sector-1, 1, posBTI, qualBTI) );
718 
719  //MB2
720  posBTI[0] = (mb2_eta & 0x01);
721  posBTI[1] = ((mb2_eta & 0x02)>>1);
722  posBTI[2] = ((mb2_eta & 0x04)>>2);
723  posBTI[3] = ((mb2_eta & 0x08)>>3);
724  posBTI[4] = ((mb2_eta & 0x10)>>4);
725  posBTI[5] = ((mb2_eta & 0x20)>>5);
726  posBTI[6] = (((mb2_eta & 0x40)>>6) || ((mb2_eta & 0x80)>>7));
727 
728  qualBTI[0] = (mb2_eta_HQ & 0x01);
729  qualBTI[1] = ((mb2_eta_HQ & 0x02)>>1);
730  qualBTI[2] = ((mb2_eta_HQ & 0x04)>>2);
731  qualBTI[3] = ((mb2_eta_HQ & 0x08)>>3);
732  qualBTI[4] = ((mb2_eta_HQ & 0x10)>>4);
733  qualBTI[5] = ((mb2_eta_HQ & 0x20)>>5);
734  qualBTI[6] = (((mb2_eta_HQ & 0x40)>>6) || ((mb2_eta_HQ & 0x80)>>7));
735 
736  theSegments.push_back( L1MuDTChambThDigi( bxNr, wheel, sector-1, 2, posBTI, qualBTI) );
737 
738  //MB3
739  posBTI[0] = (mb3_eta & 0x01);
740  posBTI[1] = ((mb3_eta & 0x02)>>1);
741  posBTI[2] = ((mb3_eta & 0x04)>>2);
742  posBTI[3] = ((mb3_eta & 0x08)>>3);
743  posBTI[4] = ((mb3_eta & 0x10)>>4);
744  posBTI[5] = ((mb3_eta & 0x20)>>5);
745  posBTI[6] = (((mb3_eta & 0x40)>>6) || ((mb3_eta & 0x80)>>7));
746 
747  qualBTI[0] = (mb3_eta_HQ & 0x01);
748  qualBTI[1] = ((mb3_eta_HQ & 0x02)>>1);
749  qualBTI[2] = ((mb3_eta_HQ & 0x04)>>2);
750  qualBTI[3] = ((mb3_eta_HQ & 0x08)>>3);
751  qualBTI[4] = ((mb3_eta_HQ & 0x10)>>4);
752  qualBTI[5] = ((mb3_eta_HQ & 0x20)>>5);
753  qualBTI[6] = (((mb3_eta_HQ & 0x40)>>6) || ((mb3_eta_HQ & 0x80)>>7));
754 
755  theSegments.push_back( L1MuDTChambThDigi( bxNr, wheel, sector-1, 3, posBTI, qualBTI) );
756 
757  }//etha word
758 
759  else if ( selector == 0xB ) { //MB1/2 output word
760 
761  int mb2_phi = ( dataWordSub & 0xFFF); // positions 0 -> 11
762  int mb2_phib = ( dataWordSub >> 12 ) & 0x3FF; // positions 12 -> 21
763  int mb2_qual = ( dataWordSub >> 22 ) & 0x7; // positions 22 -> 24
764  int mb2_q3 = ( dataWordSub >> 25 ) & 0x1; // positions 25
765  int mb2_q4 = ( dataWordSub >> 26 ) & 0x1; // positions 26
766  int mb2_ts2tag = ( dataWordSub >> 28 ) & 0x1; // positions 28
767  /*** NOT UNPACKED
768  int mb2_parity = ( dataWordSub >> 29) & 0x1; // positions 29
769  ***/
770 
771  int mb1_phi = ( dataWordSub >> 30 ) & 0xFFF; // positions 30 -> 41
772  int mb1_phib = ( dataWordSub >> 42 ) & 0x3FF; // positions 42 -> 51
773  int mb1_qual = ( dataWordSub >> 52 ) & 0x7; // positions 52 -> 54
774  int mb1_q3 = ( dataWordSub >> 55 ) & 0x1; // positions 55
775  int mb1_q4 = ( dataWordSub >> 56 ) & 0x1; // positions 56
776  int mb1_ts2tag = ( dataWordSub >> 58 ) & 0x1; // positions 58
777  /*** NOT UNPACKED
778  int mb1_parity = ( dataWordSub >> 59 ) &0x1; // positions 59
779  ***/
780 
781  int mb1_phi_conv = radAngConversion(mb1_phi);
782  int mb1_phib_conv = benAngConversion(mb1_phib);
783 
784  int mb2_phi_conv = radAngConversion(mb2_phi);
785  int mb2_phib_conv = benAngConversion(mb2_phib);
786 
787  phioutSegments.push_back( L1MuDTChambPhDigi( bxNr, wheel, sector-1,
788  1, mb1_phi_conv, mb1_phib_conv,
789  mb1_qual, mb1_ts2tag, bxCounter, mb1_q3 + 2*mb1_q4 ) );
790  phioutSegments.push_back( L1MuDTChambPhDigi( bxNr, wheel, sector-1,
791  2, mb2_phi_conv, mb2_phib_conv,
792  mb2_qual, mb2_ts2tag, bxCounter, mb2_q3 + 2*mb2_q4 ) );
793 
794  if ( debug_ ) logfile << '[' << ++lcounter << "]\t"<< std::hex
795  << dataWordSub << std::dec << "\t|\t"
796  << "mb1_ts2tag_out " << mb1_ts2tag << '\t'
797  << "mb1_qual_out " << mb1_qual << '\t'
798  << "mb1_q3_out " << mb1_q3 << '\t'
799  << "mb1_q4_out " << mb1_q4 << '\t'
800  << "mb1_phib_out " << mb1_phib_conv << '\t'
801  << "mb1_phi_out " << mb1_phi_conv << '\t'
802  << "mb2_ts2tag_out " << mb2_ts2tag << '\t'
803  << "mb2_qual_out " << mb2_qual << '\t'
804  << "mb2_q3_out " << mb2_q3 << '\t'
805  << "mb2_q4_out " << mb2_q4 << '\t'
806  << "mb2_phib_out " << mb2_phib_conv << '\t'
807  << "mb2_phi_out " << mb2_phi_conv << '\n';
808 
809  }//MB1/2 output word
810 
811 
812  else if ( selector == 0xC ) { //MB3/4 output word
813 
814  int mb4_phi = ( dataWordSub & 0xFFF); // positions 0 -> 11
815  int mb4_phib = ( dataWordSub >> 12 ) & 0x3FF; // positions 12 -> 21
816  int mb4_qual = ( dataWordSub >> 22 ) & 0x7; // positions 22 -> 24
817  int mb4_q3 = ( dataWordSub >> 25 ) & 0x1; // positions 25
818  int mb4_q4 = ( dataWordSub >> 26 ) & 0x1; // positions 26
819  int mb4_ts2tag = ( dataWordSub >> 28 ) & 0x1; // positions 28
820  /*** NOT UNPACKED
821  int mb4_parity = ( dataWordSub >> 29) & 0x1; // positions 29
822  ***/
823 
824  int mb3_phi = ( dataWordSub >> 30 ) & 0xFFF; // positions 30 -> 41
825  int mb3_phib = ( dataWordSub >> 42 ) & 0x3FF; // positions 42 -> 51
826  int mb3_qual = ( dataWordSub >> 52 ) & 0x7; // positions 52 -> 54
827  int mb3_q3 = ( dataWordSub >> 55 ) & 0x1; // positions 55
828  int mb3_q4 = ( dataWordSub >> 56 ) & 0x1; // positions 56
829  int mb3_ts2tag = ( dataWordSub >> 58 ) & 0x1; // positions 58
830  /*** NOT UNPACKED
831  int mb3_parity = ( dataWordSub >> 59 ) &0x1; // positions 59
832  ***/
833 
834  int mb3_phi_conv = radAngConversion(mb3_phi);
835  int mb3_phib_conv = benAngConversion(mb3_phib);
836 
837  int mb4_phi_conv = radAngConversion(mb4_phi);
838  int mb4_phib_conv = benAngConversion(mb4_phib);
839 
840  phioutSegments.push_back( L1MuDTChambPhDigi( bxNr, wheel, sector-1,
841  3, mb3_phi_conv, mb3_phib_conv,
842  mb3_qual, mb3_ts2tag, bxCounter, mb3_q3 + 2*mb3_q4 ) );
843  phioutSegments.push_back( L1MuDTChambPhDigi( bxNr, wheel, sector-1,
844  4, mb4_phi_conv, mb4_phib_conv,
845  mb4_qual, mb4_ts2tag, bxCounter, mb4_q3 + 2*mb4_q4 ) );
846 
847  if ( debug_ ) logfile << '[' << ++lcounter << "]\t"<< std::hex
848  << dataWordSub << std::dec << "\t|\t"
849  << "mb3_ts2tag_out " << mb3_ts2tag << '\t'
850  << "mb3_qual_out " << mb3_qual << '\t'
851  << "mb3_q3_out " << mb3_q3 << '\t'
852  << "mb3_q4_out " << mb3_q4 << '\t'
853  << "mb3_phib_out " << mb3_phib_conv << '\t'
854  << "mb3_phi_out " << mb3_phi_conv << '\t'
855  << "mb4_ts2tag_out " << mb4_ts2tag << '\t'
856  << "mb4_qual_out " << mb4_qual << '\t'
857  << "mb4_q3_out " << mb4_q3 << '\t'
858  << "mb4_q4_out " << mb4_q4 << '\t'
859  << "mb4_phib_out " << mb4_phib_conv << '\t'
860  << "mb4_phi_out " << mb4_phi_conv << '\n';
861 
862  }//MB3/4 output word
863 
864  else if ( selector == 0xD ) { //etha output word
865 
866  if ( debug_ ) logfile << '[' << ++lcounter << "]\t" << std::hex
867  << dataWordSub << std::dec
868  << "\t ETHA OUTPUT WORD\n";
869 
870  }//etha output word
871 
872  else if ( selector == 0x9 || selector == 0xE ) { //RPC word
873 
874  edm::LogInfo("TwinMux_unpacker") << "RPC WORD [" << std::dec << tm7eventsize << "] : "
875  << std::hex << dataWordSub << std::dec
876  << " it pos " << int(DTTM7iterator - DTTM7itend);
877 
878  if ( debug_ ) logfile << '[' << ++lcounter << "]\t" << std::hex
879  << dataWordSub << std::dec
880  << "\t RPC WORD\n";
881 
882  }//RPC word
883 
884  else if ( selector == 0x6 ) { //HO word
885 
886  edm::LogInfo("TwinMux_unpacker") << "HO WORD [" << std::dec << tm7eventsize << "] : "
887  << std::hex << dataWordSub << std::dec
888  << " it pos " << int(DTTM7iterator - DTTM7itend);
889 
890  if ( debug_ ) logfile << '[' << ++lcounter << "]\t" << std::hex
891  << dataWordSub << std::dec
892  << "\t HO WORD\n";
893 
894  }//HO word
895 
896  else if ( selector == 0xF ) { //ERROR word
897 
898  edm::LogInfo("TwinMux_unpacker") << "ERROR WORD [" << std::dec << tm7eventsize << "] : "
899  << std::hex << dataWordSub << std::dec
900  << " it pos " << int(DTTM7iterator - DTTM7itend);
901 
902  if ( debug_ ) logfile << '[' << ++lcounter << "]\t" << std::hex
903  << dataWordSub << std::dec
904  << "\t ERROR WORD\n";
905  }//ERROR word
906 
907  else { //unkown word
908 
909  edm::LogInfo("TwinMux_unpacker") << "UNKNOWN WORD received " << std::hex << dataWordSub
910  << " in FED " << std::hex << TM7fedId;
911 
912  if ( debug_ ) logfile << '[' << ++lcounter << "]\t" << std::hex
913  << dataWordSub << std::dec
914  << "\t UNKNOWN WORD\n";
915  }
916 
917  if( DTTM7iterator == DTTM7itend ) break;
918  }
919  } //end of loop over AMCsize
920 
921 
923  ++DTTM7iterator;
924 
925  if( DTTM7iterator == DTTM7itend ) break;
926 
927  } // end for-loop container content
928 
929  return;
930 }
931 
932 
933 
934 void L1TTwinMuxRawToDigi::calcCRC( long word, int & myC ) {
935 
936  int myCRC[16], D[64], C[16];
937 
938  for ( int i = 0; i < 64; ++i ) { D[i] = (word >> i) & 0x1; }
939  for ( int i = 0; i < 16; ++i ) { C[i] = (myC>>i) & 0x1; }
940 
941  myCRC[0] = ( D[63] + D[62] + D[61] + D[60] + D[55] + D[54] +
942  D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
943  D[47] + D[46] + D[45] + D[43] + D[41] + D[40] +
944  D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
945  D[33] + D[32] + D[31] + D[30] + D[27] + D[26] +
946  D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
947  D[19] + D[18] + D[17] + D[16] + D[15] + D[13] +
948  D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
949  D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
950  D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
951  C[5] + C[6] + C[7] + C[12] + C[13] + C[14] +
952  C[15] )%2;
953 
954  myCRC[1] = ( D[63] + D[62] + D[61] + D[56] + D[55] + D[54] +
955  D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
956  D[47] + D[46] + D[44] + D[42] + D[41] + D[40] +
957  D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
958  D[33] + D[32] + D[31] + D[28] + D[27] + D[26] +
959  D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
960  D[19] + D[18] + D[17] + D[16] + D[14] + D[13] +
961  D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
962  D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
963  C[0] + C[1] + C[2] + C[3] + C[4] + C[5] +
964  C[6] + C[7] + C[8] + C[13] + C[14] + C[15] )%2;
965 
966  myCRC[2] = ( D[61] + D[60] + D[57] + D[56] + D[46] + D[42] +
967  D[31] + D[30] + D[29] + D[28] + D[16] + D[14] +
968  D[1] + D[0] + C[8] + C[9] + C[12] + C[13] )%2;
969 
970  myCRC[3] = ( D[62] + D[61] + D[58] + D[57] + D[47] + D[43] +
971  D[32] + D[31] + D[30] + D[29] + D[17] + D[15] +
972  D[2] + D[1] + C[9] + C[10] + C[13] + C[14] )%2;
973 
974  myCRC[4] = ( D[63] + D[62] + D[59] + D[58] + D[48] + D[44] +
975  D[33] + D[32] + D[31] + D[30] + D[18] + D[16] +
976  D[3] + D[2] + C[0] + C[10] + C[11] + C[14] +
977  C[15] )%2;
978 
979  myCRC[5] = ( D[63] + D[60] + D[59] + D[49] + D[45] + D[34] +
980  D[33] + D[32] + D[31] + D[19] + D[17] + D[4] +
981  D[3] + C[1] + C[11] + C[12] + C[15] )%2;
982 
983  myCRC[6] = ( D[61] + D[60] + D[50] + D[46] + D[35] + D[34] +
984  D[33] + D[32] + D[20] + D[18] + D[5] + D[4] +
985  C[2] + C[12] + C[13] )%2;
986 
987  myCRC[7] = ( D[62] + D[61] + D[51] + D[47] + D[36] + D[35] +
988  D[34] + D[33] + D[21] + D[19] + D[6] + D[5] +
989  C[3] + C[13] + C[14] )%2;
990 
991  myCRC[8] = ( D[63] + D[62] + D[52] + D[48] + D[37] + D[36] +
992  D[35] + D[34] + D[22] + D[20] + D[7] + D[6] +
993  C[0] + C[4] + C[14] + C[15] )%2;
994 
995  myCRC[9] = ( D[63] + D[53] + D[49] + D[38] + D[37] + D[36] +
996  D[35] + D[23] + D[21] + D[8] + D[7] + C[1] +
997  C[5] + C[15] )%2;
998 
999  myCRC[10] = ( D[54] + D[50] + D[39] + D[38] + D[37] + D[36] +
1000  D[24] + D[22] + D[9] + D[8] + C[2] + C[6] )%2;
1001 
1002  myCRC[11] = ( D[55] + D[51] + D[40] + D[39] + D[38] + D[37] +
1003  D[25] + D[23] + D[10] + D[9] + C[3] + C[7] )%2;
1004 
1005  myCRC[12] = ( D[56] + D[52] + D[41] + D[40] + D[39] + D[38] +
1006  D[26] + D[24] + D[11] + D[10] + C[4] + C[8] )%2;
1007 
1008  myCRC[13] = ( D[57] + D[53] + D[42] + D[41] + D[40] + D[39] +
1009  D[27] + D[25] + D[12] + D[11] + C[5] + C[9] )%2;
1010 
1011  myCRC[14] = ( D[58] + D[54] + D[43] + D[42] + D[41] + D[40] +
1012  D[28] + D[26] + D[13] + D[12] + C[6] + C[10] )%2;
1013 
1014  myCRC[15] = ( D[63] + D[62] + D[61] + D[60] + D[59] + D[54] +
1015  D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
1016  D[47] + D[46] + D[45] + D[44] + D[42] + D[40] +
1017  D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
1018  D[33] + D[32] + D[31] + D[30] + D[29] + D[26] +
1019  D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
1020  D[19] + D[18] + D[17] + D[16] + D[15] + D[14] +
1021  D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
1022  D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
1023  D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
1024  C[5] + C[6] + C[11] + C[12] + C[13] + C[14] +
1025  C[15] )%2;
1026 
1027  int tempC = 0x0;
1028  for ( int i = 0; i < 16 ; ++i) { tempC = tempC + ( myCRC[i] << i ); }
1029  myC = tempC;
1030  return;
1031 }
1032 
1033 
1034 //define this as a plug-in
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
~L1TTwinMuxRawToDigi() override
Destructor.
int normBx(int bx_, int bxCnt_)
std::vector< long long int > amcsecmap_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< std::array< short, 12 > > amcsec_
L1TTwinMuxRawToDigi(const edm::ParameterSet &pset)
Constructor.
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, L1MuDTChambPhContainer::Phi_Container &phi_out_data)
int radAngConversion(int radAng_)
void readline(int &lines, long &dataWord)
bool fillRawData(edm::Event &e, L1MuDTChambPhContainer::Phi_Container &phi_data, L1MuDTChambThContainer::The_Container &the_data, L1MuDTChambPhContainer::Phi_Container &phi_out_data)
Generate and fill FED raw data for a full event.
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
std::vector< int > feds_
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::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< L1MuDTChambPhDigi > Phi_Container
std::vector< L1MuDTChambThDigi > The_Container
std::vector< int > wheels_
edm::EDGetTokenT< FEDRawDataCollection > Raw_token
edm::InputTag DTTM7InputTag_
int k[5][pyjets_maxn]
int benAngConversion(int benAng_)
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:151
unsigned char * LineFED_
string fname
main script
void calcCRC(long word, int &myC)
HLT enums.
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
void produce(edm::Event &e, const edm::EventSetup &c) override
Produce digis out of raw data.
def move(src, dest)
Definition: eostools.py:510