CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCDCCUnpacker.cc
Go to the documentation of this file.
2 
3 //Framework stuff
10 
11 //FEDRawData
14 
15 //Digi stuff
24 
46 
48 
64 
65 #include <iostream>
66 #include <sstream>
67 #include <string>
68 #include <iomanip>
69 #include <cstdio>
70 
72  numOfEvents(0) {
73 
74  // Tracked
75  i_token = consumes<FEDRawDataCollection>( pset.getParameter<edm::InputTag>("InputObjects") );
76 
77  useExaminer = pset.getParameter<bool>("UseExaminer");
78  examinerMask = pset.getParameter<unsigned int>("ExaminerMask");
80  useSelectiveUnpacking = pset.getParameter<bool>("UseSelectiveUnpacking");
81  errorMask = pset.getParameter<unsigned int>("ErrorMask");
82  unpackStatusDigis = pset.getParameter<bool>("UnpackStatusDigis");
84  useFormatStatus = pset.getParameter<bool>("UseFormatStatus");
85 
86  // Untracked
87 
88  printEventNumber = pset.getUntrackedParameter<bool>("PrintEventNumber", true);
89  debug = pset.getUntrackedParameter<bool>("Debug", false);
90  instantiateDQM = pset.getUntrackedParameter<bool>("runDQM", false);
91 
93  visualFEDInspect = pset.getUntrackedParameter<bool>("VisualFEDInspect", false);
94  visualFEDShort = pset.getUntrackedParameter<bool>("VisualFEDShort", false);
95  formatedEventDump = pset.getUntrackedParameter<bool>("FormatedEventDump", false);
96 
98  SuppressZeroLCT = pset.getUntrackedParameter<bool>("SuppressZeroLCT", true);
99 
100 
101 
102  if(instantiateDQM) {
104  }
105 
106  produces<CSCWireDigiCollection>("MuonCSCWireDigi");
107  produces<CSCStripDigiCollection>("MuonCSCStripDigi");
108  produces<CSCComparatorDigiCollection>("MuonCSCComparatorDigi");
109  produces<CSCALCTDigiCollection>("MuonCSCALCTDigi");
110  produces<CSCCLCTDigiCollection>("MuonCSCCLCTDigi");
111  produces<CSCRPCDigiCollection>("MuonCSCRPCDigi");
112  produces<CSCCorrelatedLCTDigiCollection>("MuonCSCCorrelatedLCTDigi");
113 
114  if (unpackStatusDigis) {
115  produces<CSCCFEBStatusDigiCollection>("MuonCSCCFEBStatusDigi");
116  produces<CSCTMBStatusDigiCollection>("MuonCSCTMBStatusDigi");
117  produces<CSCDMBStatusDigiCollection>("MuonCSCDMBStatusDigi");
118  produces<CSCALCTStatusDigiCollection>("MuonCSCALCTStatusDigi");
119  produces<CSCDDUStatusDigiCollection>("MuonCSCDDUStatusDigi");
120  produces<CSCDCCStatusDigiCollection>("MuonCSCDCCStatusDigi");
121  }
122 
123  if (useFormatStatus) {
124  produces<CSCDCCFormatStatusDigiCollection>("MuonCSCDCCFormatStatusDigi");
125  }
126  //CSCAnodeData::setDebug(debug);
128  CSCCLCTData::setDebug(debug);
129  CSCEventData::setDebug(debug);
130  CSCTMBData::setDebug(debug);
133  CSCTMBHeader::setDebug(debug);
134  CSCRPCData::setDebug(debug);
136 
137 }
138 
140  //fill destructor here
141 }
142 
143 
145 
147  // Do we really have to do this every event???
148  // ... Yes, because framework is more efficient than you are at caching :)
149  // (But if you want to actually DO something specific WHEN the mapping changes, check out ESWatcher)
151  c.get<CSCCrateMapRcd>().get(hcrate);
152  const CSCCrateMap* pcrate = hcrate.product();
153 
154 
156 
159  e.getByToken( i_token, rawdata);
160 
162  std::auto_ptr<CSCWireDigiCollection> wireProduct(new CSCWireDigiCollection);
163  std::auto_ptr<CSCStripDigiCollection> stripProduct(new CSCStripDigiCollection);
164  std::auto_ptr<CSCALCTDigiCollection> alctProduct(new CSCALCTDigiCollection);
165  std::auto_ptr<CSCCLCTDigiCollection> clctProduct(new CSCCLCTDigiCollection);
166  std::auto_ptr<CSCComparatorDigiCollection> comparatorProduct(new CSCComparatorDigiCollection);
167  std::auto_ptr<CSCRPCDigiCollection> rpcProduct(new CSCRPCDigiCollection);
168  std::auto_ptr<CSCCorrelatedLCTDigiCollection> corrlctProduct(new CSCCorrelatedLCTDigiCollection);
169  std::auto_ptr<CSCCFEBStatusDigiCollection> cfebStatusProduct(new CSCCFEBStatusDigiCollection);
170  std::auto_ptr<CSCDMBStatusDigiCollection> dmbStatusProduct(new CSCDMBStatusDigiCollection);
171  std::auto_ptr<CSCTMBStatusDigiCollection> tmbStatusProduct(new CSCTMBStatusDigiCollection);
172  std::auto_ptr<CSCDDUStatusDigiCollection> dduStatusProduct(new CSCDDUStatusDigiCollection);
173  std::auto_ptr<CSCDCCStatusDigiCollection> dccStatusProduct(new CSCDCCStatusDigiCollection);
174  std::auto_ptr<CSCALCTStatusDigiCollection> alctStatusProduct(new CSCALCTStatusDigiCollection);
175 
176  std::auto_ptr<CSCDCCFormatStatusDigiCollection> formatStatusProduct(new CSCDCCFormatStatusDigiCollection);
177 
178 
179  // If set selective unpacking mode
180  // hardcoded examiner mask below to check for DCC and DDU level errors will be used first
181  // then examinerMask for CSC level errors will be used during unpacking of each CSC block
182  unsigned long dccBinCheckMask = 0x06080016;
183 
184  for (int id=FEDNumbering::MINCSCFEDID;
185  id<=FEDNumbering::MAXCSCFEDID; ++id) { // loop over DCCs
188 
190  const FEDRawData& fedData = rawdata->FEDData(id);
191  unsigned long length = fedData.size();
192 
193 
194  if (length>=32){
195  CSCDCCExaminer* examiner = NULL;
196  std::stringstream examiner_out, examiner_err;
197  goodEvent = true;
198  if (useExaminer) {
199  // CSCDCCExaminer examiner;
200  examiner = new CSCDCCExaminer();
201  examiner->output1().redirect(examiner_out);
202  examiner->output2().redirect(examiner_err);
203  if( examinerMask&0x40000 ) examiner->crcCFEB(1);
204  if( examinerMask&0x8000 ) examiner->crcTMB (1);
205  if( examinerMask&0x0400 ) examiner->crcALCT(1);
206  examiner->output1().show();
207  examiner->output2().show();
208  examiner->setMask(examinerMask);
209  const short unsigned int *data = (short unsigned int *)fedData.data();
210 
211  LogTrace("badData") << "Length: "<< length/2;
212  // Event data hex dump
213  /*
214  short unsigned * buf = (short unsigned int *)fedData.data();
215  std::cout <<std::endl<<length/2<<" words of data:"<<std::endl;
216  for (short unsigned int i=0;i<length/2;i++) {
217  printf("%04x %04x %04x %04x\n",buf[i+3],buf[i+2],buf[i+1],buf[i]);
218  i+=3;
219  }
220  */
221 
222  int res = examiner->check(data,long(fedData.size()/2));
223  if( res < 0 ) {
224  goodEvent=false;
225  }
226  else {
227  if (useSelectiveUnpacking) goodEvent=!(examiner->errors()&dccBinCheckMask);
228  else goodEvent=!(examiner->errors()&examinerMask);
229  }
230 
231  /*
232  std::cout << "FED" << id << " " << fedData.size() << " " << goodEvent << " "
233  << std::hex << examiner->errors() << std::dec << " " << status << std::endl;
234  */
235 
236  // Fill Format status digis per FED
237  // Remove examiner->errors() != 0 check if we need to put status digis for every event
238  if (useFormatStatus && (examiner->errors() !=0))
239  // formatStatusProduct->insertDigi(CSCDetId(1,1,1,1,1), CSCDCCFormatStatusDigi(id,examiner,dccBinCheckMask));
240  formatStatusProduct->insertDigi(CSCDetId(1,1,1,1,1),
241  CSCDCCFormatStatusDigi(id,dccBinCheckMask,
242  examiner->getMask(),
243  examiner->errors(),
244  examiner->errorsDetailedDDU(),
245  examiner->errorsDetailed(),
246  examiner->payloadDetailed(),
247  examiner->statusDetailed()));
248  }
249 
252  if (!goodEvent || formatedEventDump){
253  short unsigned * buf = (short unsigned int *)fedData.data();
254  visual_raw(length/2, id,(int)e.id().run(),(int)e.id().event(),
256  }
257  }
258 
259  if (goodEvent) {
261 
262 
263  CSCDCCExaminer * ptrExaminer = examiner;
264  if (!useSelectiveUnpacking) ptrExaminer = NULL;
265 
266  CSCDCCEventData dccData((short unsigned int *) fedData.data(), ptrExaminer);
267 
268  //std::cout << " DCC Size [UNPK] " << dccData.sizeInWords() << std::endl;
269 
270  if(instantiateDQM) monitor->process(examiner, &dccData);
271 
273  const std::vector<CSCDDUEventData> & dduData = dccData.dduData();
274 
276  CSCDetId layer(1, 1, 1, 1, 1);
277 
278  if (unpackStatusDigis) {
279 
281  short unsigned * bufForDcc = (short unsigned int *)fedData.data();
282 
283  //std::cout << "FED Length: " << std::dec << length/2 <<
284  //" Trailer 2: " << std::hex << bufForDcc[length/2-4] << std::endl;
285 
286  dccStatusProduct->insertDigi(layer, CSCDCCStatusDigi(dccData.dccHeader().data(),
287  dccData.dccTrailer().data(),
288  examiner->errors(),
289  bufForDcc[length/2-4]));
290 
291  }
292 
293  for (unsigned int iDDU=0; iDDU<dduData.size(); ++iDDU) { // loop over DDUs
296  if (dduData[iDDU].trailer().errorstat()&errorMask) {
297  LogTrace("CSCDCCUnpacker|CSCRawToDigi") << "DDU# " << iDDU << " has serious error - no digis unpacked! " <<
298  std::hex << dduData[iDDU].trailer().errorstat();
299  continue; // to next iteration of DDU loop
300  }
301 
302  if (unpackStatusDigis) dduStatusProduct->
303  insertDigi(layer, CSCDDUStatusDigi(dduData[iDDU].header().data(),
304  dduData[iDDU].trailer().data(),
306  dduData[iDDU].trailer0()));
307 
309  const std::vector<CSCEventData> & cscData = dduData[iDDU].cscData();
310 
311 
312  for (unsigned int iCSC=0; iCSC<cscData.size(); ++iCSC) { // loop over CSCs
313 
315  int vmecrate = cscData[iCSC].dmbHeader()->crateID();
316  int dmb = cscData[iCSC].dmbHeader()->dmbID();
317 
318  int icfeb = 0;
319  int ilayer = 0;
320 
321  if (debug)
322  LogTrace ("CSCDCCUnpacker|CSCRawToDigi") << "crate = " << vmecrate << "; dmb = " << dmb;
323 
324  if ((vmecrate>=1)&&(vmecrate<=60) && (dmb>=1)&&(dmb<=10)&&(dmb!=6)) {
325  layer = pcrate->detId(vmecrate, dmb,icfeb,ilayer );
326  }
327  else{
328  LogTrace ("CSCDCCUnpacker|CSCRawToDigi") << " detID input out of range!!! ";
329  LogTrace ("CSCDCCUnpacker|CSCRawToDigi")
330  << " skipping chamber vme= " << vmecrate << " dmb= " << dmb;
331  continue; // to next iteration of iCSC loop
332  }
333 
334 
336  int nalct = cscData[iCSC].dmbHeader()->nalct();
337  bool goodALCT=false;
338  //if (nalct&&(cscData[iCSC].dataPresent>>6&0x1)==1) {
339  if (nalct&&cscData[iCSC].alctHeader()) {
340  if (cscData[iCSC].alctHeader()->check()){
341  goodALCT=true;
342  }
343  else {
344  LogTrace ("CSCDCCUnpacker|CSCRawToDigi") <<
345  "not storing ALCT digis; alct is bad or not present";
346  }
347  } else {
348  if (debug) LogTrace ("CSCDCCUnpacker|CSCRawToDigi") << "nALCT==0 !!!";
349  }
350 
352  if (goodALCT){
353  std::vector <CSCALCTDigi> alctDigis =
354  cscData[iCSC].alctHeader()->ALCTDigis();
355  if(SuppressZeroLCT){
356  std::vector<CSCALCTDigi> alctDigis_0;
357  for (int unsigned i=0; i<alctDigis.size(); ++i){
358  if(alctDigis[i].isValid())
359  alctDigis_0.push_back(alctDigis[i]);
360  }
361  alctProduct->put(std::make_pair(alctDigis_0.begin(), alctDigis_0.end()),layer);
362  }
363  else
364  alctProduct->put(std::make_pair(alctDigis.begin(), alctDigis.end()),layer);
365  }
366 
367 
369  int nclct = cscData[iCSC].dmbHeader()->nclct();
370  bool goodTMB=false;
371  // if (nclct&&(cscData[iCSC].dataPresent>>5&0x1)==1) {
372  if (nclct&&cscData[iCSC].tmbData()) {
373  if (cscData[iCSC].tmbHeader()->check()){
374  if (cscData[iCSC].clctData()->check()) goodTMB=true;
375  }
376  else {
377  LogTrace ("CSCDCCUnpacker|CSCRawToDigi") <<
378  "one of TMB checks failed! not storing TMB digis ";
379  }
380  }
381  else {
382  if (debug) LogTrace ("CSCDCCUnpacker|CSCRawToDigi") << "nCLCT==0 !!!";
383  }
384 
386  if (goodTMB) {
387  std::vector <CSCCorrelatedLCTDigi> correlatedlctDigis =
388  cscData[iCSC].tmbHeader()->CorrelatedLCTDigis(layer.rawId());
389  if(SuppressZeroLCT){
390  std::vector<CSCCorrelatedLCTDigi> correlatedlctDigis_0;
391  for (int unsigned i=0; i<correlatedlctDigis.size(); ++i){
392  if(correlatedlctDigis[i].isValid())
393  correlatedlctDigis_0.push_back(correlatedlctDigis[i]);
394  }
395  corrlctProduct->put(std::make_pair(correlatedlctDigis_0.begin(),
396  correlatedlctDigis_0.end()),layer);
397  }
398  else
399  corrlctProduct->put(std::make_pair(correlatedlctDigis.begin(),
400  correlatedlctDigis.end()),layer);
401 
402  std::vector <CSCCLCTDigi> clctDigis =
403  cscData[iCSC].tmbHeader()->CLCTDigis(layer.rawId());
404  if(SuppressZeroLCT){
405  std::vector<CSCCLCTDigi> clctDigis_0;
406  for (int unsigned i=0; i<clctDigis.size(); ++i){
407  if(clctDigis[i].isValid())
408  clctDigis_0.push_back(clctDigis[i]);
409  }
410  clctProduct->put(std::make_pair(clctDigis_0.begin(), clctDigis_0.end()),layer);
411  }
412  else
413  clctProduct->put(std::make_pair(clctDigis.begin(), clctDigis.end()),layer);
414 
416  if (cscData[iCSC].tmbData()->checkSize()) {
417  if (cscData[iCSC].tmbData()->hasRPC()) {
418  std::vector <CSCRPCDigi> rpcDigis =
419  cscData[iCSC].tmbData()->rpcData()->digis();
420  rpcProduct->put(std::make_pair(rpcDigis.begin(), rpcDigis.end()),layer);
421  }
422  }
423  else LogTrace("CSCDCCUnpacker|CSCRawToDigi") <<" TMBData check size failed!";
424  }
425 
426 
428  if (unpackStatusDigis) {
429  for ( icfeb = 0; icfeb < 5; ++icfeb ) {
430  if ( cscData[iCSC].cfebData(icfeb) != NULL )
431  cfebStatusProduct->
432  insertDigi(layer, cscData[iCSC].cfebData(icfeb)->statusDigi());
433  }
435  dmbStatusProduct->insertDigi(layer, CSCDMBStatusDigi(cscData[iCSC].dmbHeader()->data(),
436  cscData[iCSC].dmbTrailer()->data()));
437  if (goodTMB) tmbStatusProduct->
438  insertDigi(layer, CSCTMBStatusDigi(cscData[iCSC].tmbHeader()->data(),
439  cscData[iCSC].tmbData()->tmbTrailer()->data()));
440  if (goodALCT) alctStatusProduct->
441  insertDigi(layer, CSCALCTStatusDigi(cscData[iCSC].alctHeader()->data(),
442  cscData[iCSC].alctTrailer()->data()));
443  }
444 
445 
447  for (int ilayer = 1; ilayer <= 6; ++ilayer) {
449  // (You have to be kidding. Line 240 in whose universe?)
450 
451  // Allocate all ME1/1 wire digis to ring 1
452  layer = pcrate->detId( vmecrate, dmb, 0, ilayer );
453 
454  std::vector <CSCWireDigi> wireDigis = cscData[iCSC].wireDigis(ilayer);
455 
456  wireProduct->put(std::make_pair(wireDigis.begin(), wireDigis.end()),layer);
457 
458  for ( icfeb = 0; icfeb < 5; ++icfeb ) {
459  layer = pcrate->detId( vmecrate, dmb, icfeb,ilayer );
460  if (cscData[iCSC].cfebData(icfeb)) {
461  std::vector<CSCStripDigi> stripDigis;
462  cscData[iCSC].cfebData(icfeb)->digis(layer.rawId(),stripDigis);
463  stripProduct->put(std::make_pair(stripDigis.begin(),
464  stripDigis.end()),layer);
465  }
466 
467  if (goodTMB){
468  std::vector <CSCComparatorDigi> comparatorDigis =
469  cscData[iCSC].clctData()->comparatorDigis(layer.rawId(), icfeb);
470  // Set cfeb=0, so that ME1/a and ME1/b comparators go to
471  // ring 1.
472  layer = pcrate->detId( vmecrate, dmb, 0, ilayer );
473  comparatorProduct->put(std::make_pair(comparatorDigis.begin(),
474  comparatorDigis.end()),layer);
475  }
476  } // end of loop over cfebs
477  } // end of loop over layers
478  } // end of loop over chambers
479  } // endof loop over DDUs
480  } // end of good event
481  else {
482  LogTrace("CSCDCCUnpacker|CSCRawToDigi") <<
483  "ERROR! Examiner rejected FED #" << id;
484  if (examiner) {
485  for (int i=0; i<examiner->nERRORS; ++i) {
486  if (((examinerMask&examiner->errors())>>i)&0x1)
487  LogTrace("CSCDCCUnpacker|CSCRawToDigi")<<examiner->errName(i);
488  }
489  if (debug) {
490  LogTrace("CSCDCCUnpacker|CSCRawToDigi")
491  << " Examiner errors:0x" << std::hex << examiner->errors()
492  << " & 0x" << examinerMask
493  << " = " << (examiner->errors()&examinerMask);
494  if (examinerMask&examiner->errors()) {
495  LogTrace("CSCDCCUnpacker|CSCRawToDigi")
496  << "Examiner output: " << examiner_out.str();
497  LogTrace("CSCDCCUnpacker|CSCRawToDigi")
498  << "Examiner errors: " << examiner_err.str();
499  }
500  }
501  }
502 
503  // dccStatusProduct->insertDigi(CSCDetId(1,1,1,1,1), CSCDCCStatusDigi(examiner->errors()));
504  // if(instantiateDQM) monitor->process(examiner, NULL);
505  }
506  if (examiner!=NULL) delete examiner;
507  } // end of if fed has data
508  } // end of loop over DCCs
509  // put into the event
510  e.put(wireProduct, "MuonCSCWireDigi");
511  e.put(stripProduct, "MuonCSCStripDigi");
512  e.put(alctProduct, "MuonCSCALCTDigi");
513  e.put(clctProduct, "MuonCSCCLCTDigi");
514  e.put(comparatorProduct, "MuonCSCComparatorDigi");
515  e.put(rpcProduct, "MuonCSCRPCDigi");
516  e.put(corrlctProduct, "MuonCSCCorrelatedLCTDigi");
517 
518  if (useFormatStatus) e.put(formatStatusProduct, "MuonCSCDCCFormatStatusDigi");
519 
520  if (unpackStatusDigis)
521  {
522  e.put(cfebStatusProduct, "MuonCSCCFEBStatusDigi");
523  e.put(dmbStatusProduct, "MuonCSCDMBStatusDigi");
524  e.put(tmbStatusProduct, "MuonCSCTMBStatusDigi");
525  e.put(dduStatusProduct, "MuonCSCDDUStatusDigi");
526  e.put(dccStatusProduct, "MuonCSCDCCStatusDigi");
527  e.put(alctStatusProduct, "MuonCSCALCTStatusDigi");
528  }
529  if (printEventNumber) LogTrace("CSCDCCUnpacker|CSCRawToDigi")
530  <<"[CSCDCCUnpacker]: " << numOfEvents << " events processed ";
531 }
532 
533 
535 
536 void CSCDCCUnpacker::visual_raw(int hl,int id, int run, int event,bool fedshort,
537  bool fDump, short unsigned int *buf) const {
538 
539  std::cout << std::endl << std::endl << std::endl;
540  std::cout << "Run: "<< run << " Event: " << event << std::endl;
541  std::cout << std::endl << std::endl;
543  std::cout << "FED-" << id << " " << "(scroll down to see summary)" << std::endl;
544  else
545  std::cout << "Problem seems in FED-" << id << " " << "(scroll down to see summary)" << std::endl;
546  std::cout <<"********************************************************************************" << std::endl;
547  std::cout << hl <<" words of data:" << std::endl;
548 
549  //================================================
550  // FED codes in DCC
551  std::vector<int> dcc_id;
552  int dcc_h1_id=0;
553  // Current codes
554  for (int i=750;i<758;i++)
555  dcc_id.push_back(i);
556  // Codes for upgrade
557  for (int i=830;i<838;i++)
558  dcc_id.push_back(i);
559 
560  char dcc_common[]="DCC-";
561 
562  //================================================
563  // DDU codes per FED
564  std::vector<int> ddu_id;
565  int ddu_h1_12_13=0;
566  for (int i=1;i<37;i++)
567  ddu_id.push_back(i);
568  // For DDU Headers and tarailers
569  char ddu_common[]="DDU-";
570  char ddu_header1[]="Header 1";
571  char ddu_header2[]="Header 2";
572  char ddu_header3[]="Header 3";
573  char ddu_trail1[]="Trailer 1", ddu_trail2[]="Trailer 2", ddu_trail3[]="Trailer 3";
574  // For Header 2
575  char ddu_trailer1_bit[]={'8','0','0','0','f','f','f','f','8','0','0','0','8','0','0','0'};
576  char ddu_trailer3_bit[]={'a'};
577  // Corrupted Trailers
578  char ddu_tr1_err_common[]="Incomplet";
579  //====================================================
580 
581  //DMB
582  char dmb_common[]="DMB", dmb_header1[]="Header 1", dmb_header2[]="Header 2";
583  char dmb_common_crate[]="crate:", dmb_common_slot[]="slot:";
584  char dmb_common_l1a[]="L1A:";
585  char dmb_header1_bit[]={'9','9','9','9'};
586  char dmb_header2_bit[]={'a','a','a','a'};
587  char dmb_tr1[]="Trailer 1", dmb_tr2[]="Trailer 2";
588  char dmb_tr1_bit[]={'f','f','f','f'}, dmb_tr2_bit[]={'e','e','e','e'};
589 
590 
591  //=====================================================
592 
593  // ALCT
594  char alct_common[]="ALCT", alct_header1[]="Header 1", alct_header2[]="Header 2";
595  char alct_common_bxn[]="BXN:";
596  char alct_common_wcnt2[]="| Actual word count:";
597  char alct_common_wcnt1[]="Expected word count:";
598  char alct_header1_bit[]={'d','d','d','d','b','0','a'};
599  char alct_header2_bit[]={'0','0','0','0'};
600  char alct_tr1[]="Trailer 1";
601 
602  //======================================================
603 
604  //TMB
605  char tmb_common[]="TMB", tmb_header1[]="Header", tmb_tr1[]="Trailer";
606  char tmb_header1_bit[]={'d','d','d','d','b','0','c'};
607  char tmb_tr1_bit[]={'d','d','d','d','e','0','f'};
608 
609  //======================================================
610 
611  //CFEB
612  char cfeb_common[]="CFEB", cfeb_tr1[]="Trailer", cfeb_b[]="B-word";
613  char cfeb_common_sample[]="sample:";
614 
615  //======================================================
616 
617  //Auxiliary variables
618 
619  // Bufers
620  int word_lines=hl/4;
621  char tempbuf[80];
622  char tempbuf1[80];
623  char tempbuf_short[17];
624  char sign1[]=" --->| ";
625 
626  // Counters
627  int word_numbering=0;
628  int ddu_inst_i=0, ddu_inst_n=0, ddu_inst_l1a=0;
629  int ddu_inst_bxn=0;
630  int dmb_inst_crate=0, dmb_inst_slot=0, dmb_inst_l1a=0;
631  int cfeb_sample=0;
632  int alct_inst_l1a=0;
633  int alct_inst_bxn=0;
634  int alct_inst_wcnt1=0;
635  int alct_inst_wcnt2=0;
636  int alct_start=0;
637  int alct_stop=0;
638  int tmb_inst_l1a=0;
639  int tmb_inst_wcnt1=0;
640  int tmb_inst_wcnt2=0;
641  int tmb_start=0;
642  int tmb_stop=0;
643  int dcc_h1_check=0;
644 
645  //Flags
646  int ddu_h2_found=0; //DDU Header 2 found
647  int w=0;
648 
649  //Logic variables
650  const int sz1=5;
651  bool dcc_check=false;
652  bool ddu_h2_check[sz1]={false};
653  bool ddu_h1_check=false;
654  bool dmb_h1_check[sz1]={false};
655  bool dmb_h2_check[sz1]={false};
656  bool ddu_h2_h1=false;
657  bool ddu_tr1_check[sz1]={false};
658  bool alct_h1_check[sz1]={false};
659  bool alct_h2_check[sz1]={false};
660  bool alct_tr1_check[sz1]={false};
661  bool dmb_tr1_check[sz1]={false};
662  bool dmb_tr2_check[sz1]={false};
663  bool tmb_h1_check[sz1]={false};
664  bool tmb_tr1_check[sz1]={false};
665  bool cfeb_tr1_check[sz1]={false};
666  bool cfeb_b_check[sz1]={false};
667  bool ddu_tr1_bad_check[sz1]={false};
668  bool extraction=fedshort;
669 
670  //Summary vectors
671  //DDU
672  std::vector<int> ddu_h1_coll;
673  std::vector<int> ddu_h1_n_coll;
674  std::vector<int> ddu_h2_coll;
675  std::vector<int> ddu_h3_coll;
676  std::vector<int> ddu_t1_coll;
677  std::vector<int> ddu_t2_coll;
678  std::vector<int> ddu_t3_coll;
679  std::vector<int> ddu_l1a_coll;
680  std::vector<int> ddu_bxn_coll;
681  //DMB
682  std::vector<int> dmb_h1_coll;
683  std::vector<int> dmb_h2_coll;
684  std::vector<int> dmb_t1_coll;
685  std::vector<int> dmb_t2_coll;
686  std::vector<int> dmb_crate_coll;
687  std::vector<int> dmb_slot_coll;
688  std::vector<int> dmb_l1a_coll;
689  //ALCT
690  std::vector<int> alct_h1_coll;
691  std::vector<int> alct_h2_coll;
692  std::vector<int> alct_t1_coll;
693  std::vector<int> alct_l1a_coll;
694  std::vector<int> alct_bxn_coll;
695  std::vector<int> alct_wcnt1_coll;
696  std::vector<int> alct_wcnt2_coll;
697  std::vector<int> alct_wcnt2_id_coll;
698  //TMB
699  std::vector<int> tmb_h1_coll;
700  std::vector<int> tmb_t1_coll;
701  std::vector<int> tmb_l1a_coll;
702  std::vector<int> tmb_wcnt1_coll;
703  std::vector<int> tmb_wcnt2_coll;
704  //CFEB
705  std::vector<int> cfeb_t1_coll;
706 
707  //========================================================
708 
709  // DCC Header and Ttrailer information
710  char dcc_header1[]="DCC Header 1";
711  char dcc_header2[]="DCC Header 2";
712  char dcc_trail1[]="DCC Trailer 1", dcc_trail1_bit[]={'e'};
713  char dcc_trail2[]="DCC Trailer 2", dcc_trail2_bit[]={'a'};
714  //=========================================================
715 
716  for (int i=0;i < hl; i++) {
717  ++word_numbering;
718  for(int j=-1; j<4; j++){
719 
720  sprintf(tempbuf_short,"%04x%04x%04x%04x",buf[i+4*(j-1)+3],buf[i+4*(j-1)+2],buf[i+4*(j-1)+1],buf[i+4*(j-1)]);
721 
722  // WARNING in 5_0_X for time being
723  ddu_h2_found++; ddu_h2_found--;
724 
725  ddu_h2_check[j]=((buf[i+4*(j-1)+1]==0x8000)&&
726  (buf[i+4*(j-1)+2]==0x0001)&&(buf[i+4*(j-1)+3]==0x8000));
727 
728  ddu_tr1_check[j]=((tempbuf_short[0]==ddu_trailer1_bit[0])&&(tempbuf_short[1]==ddu_trailer1_bit[1])&&
729  (tempbuf_short[2]==ddu_trailer1_bit[2])&&(tempbuf_short[3]==ddu_trailer1_bit[3])&&
730  (tempbuf_short[4]==ddu_trailer1_bit[4])&&(tempbuf_short[5]==ddu_trailer1_bit[5])&&
731  (tempbuf_short[6]==ddu_trailer1_bit[6])&&(tempbuf_short[7]==ddu_trailer1_bit[7])&&
732  (tempbuf_short[8]==ddu_trailer1_bit[8])&&(tempbuf_short[9]==ddu_trailer1_bit[9])&&
733  (tempbuf_short[10]==ddu_trailer1_bit[10])&&(tempbuf_short[11]==ddu_trailer1_bit[11])&&
734  (tempbuf_short[12]==ddu_trailer1_bit[12])&&(tempbuf_short[13]==ddu_trailer1_bit[13])&&
735  (tempbuf_short[14]==ddu_trailer1_bit[14])&&(tempbuf_short[15]==ddu_trailer1_bit[15]));
736 
737  dmb_h1_check[j]=((tempbuf_short[0]==dmb_header1_bit[0])&&(tempbuf_short[4]==dmb_header1_bit[1])&&
738  (tempbuf_short[8]==dmb_header1_bit[2])&&(tempbuf_short[12]==dmb_header1_bit[3]));
739 
740  dmb_h2_check[j]=((tempbuf_short[0]==dmb_header2_bit[0])&&(tempbuf_short[4]==dmb_header2_bit[1])&&
741  (tempbuf_short[8]==dmb_header2_bit[2])&&(tempbuf_short[12]==dmb_header2_bit[3]));
742  alct_h1_check[j]=((tempbuf_short[0]==alct_header1_bit[0])&&(tempbuf_short[4]==alct_header1_bit[1])&&
743  (tempbuf_short[8]==alct_header1_bit[2])&&(tempbuf_short[12]==alct_header1_bit[3])&&
744  (tempbuf_short[13]==alct_header1_bit[4])&&(tempbuf_short[14]==alct_header1_bit[5])&&
745  (tempbuf_short[15]==alct_header1_bit[6]));
746  alct_h2_check[j]=(((tempbuf_short[0]==alct_header2_bit[0])&&(tempbuf_short[1]==alct_header2_bit[1])&&
747  (tempbuf_short[2]==alct_header2_bit[2])&&(tempbuf_short[3]==alct_header2_bit[3]))||
748  ((tempbuf_short[4]==alct_header2_bit[0])&&(tempbuf_short[5]==alct_header2_bit[1])&&
749  (tempbuf_short[6]==alct_header2_bit[2])&&(tempbuf_short[7]==alct_header2_bit[3]))||
750  ((tempbuf_short[8]==alct_header2_bit[0])&&(tempbuf_short[9]==alct_header2_bit[1])&&
751  (tempbuf_short[10]==alct_header2_bit[2])&&(tempbuf_short[11]==alct_header2_bit[3]))||
752  ((tempbuf_short[12]==alct_header2_bit[0])&&(tempbuf_short[13]==alct_header2_bit[1])&&
753  (tempbuf_short[14]==alct_header2_bit[2])&&(tempbuf_short[15]==alct_header2_bit[3]))
754  //(tempbuf_short[4]==alct_header2_bit[4])&&(tempbuf_short[5]==alct_header2_bit[5])
755  );
756  // ALCT Trailers
757  alct_tr1_check[j]=(((buf[i+4*(j-1)]&0xFFFF)==0xDE0D)&&((buf[i+4*(j-1)+1]&0xF800)==0xD000)&&
758  ((buf[i+4*(j-1)+2]&0xF800)==0xD000)&&((buf[i+4*(j-1)+3]&0xF000)==0xD000));
759  // DMB Trailers
760  dmb_tr1_check[j]=((tempbuf_short[0]==dmb_tr1_bit[0])&&(tempbuf_short[4]==dmb_tr1_bit[1])&&
761  (tempbuf_short[8]==dmb_tr1_bit[2])&&(tempbuf_short[12]==dmb_tr1_bit[3]));
762  dmb_tr2_check[j]=((tempbuf_short[0]==dmb_tr2_bit[0])&&(tempbuf_short[4]==dmb_tr2_bit[1])&&
763  (tempbuf_short[8]==dmb_tr2_bit[2])&&(tempbuf_short[12]==dmb_tr2_bit[3]));
764  // TMB
765  tmb_h1_check[j]=((tempbuf_short[0]==tmb_header1_bit[0])&&(tempbuf_short[4]==tmb_header1_bit[1])&&
766  (tempbuf_short[8]==tmb_header1_bit[2])&&(tempbuf_short[12]==tmb_header1_bit[3])&&
767  (tempbuf_short[13]==tmb_header1_bit[4])&&(tempbuf_short[14]==tmb_header1_bit[5])&&
768  (tempbuf_short[15]==tmb_header1_bit[6]));
769  tmb_tr1_check[j]=((tempbuf_short[0]==tmb_tr1_bit[0])&&(tempbuf_short[4]==tmb_tr1_bit[1])&&
770  (tempbuf_short[8]==tmb_tr1_bit[2])&&(tempbuf_short[12]==tmb_tr1_bit[3])&&
771  (tempbuf_short[13]==tmb_tr1_bit[4])&&(tempbuf_short[14]==tmb_tr1_bit[5])&&
772  (tempbuf_short[15]==tmb_tr1_bit[6]));
773  // CFEB
774  cfeb_tr1_check[j]=(((buf[i+4*(j-1)+1]&0xF000)==0x7000) &&
775  ((buf[i+4*(j-1)+2]&0xF000)==0x7000) &&
776  (( buf[i+4*(j-1)+1]!= 0x7FFF) || (buf[i+4*(j-1)+2] != 0x7FFF)) &&
777  ((buf[i+4*(j-1)+3] == 0x7FFF) ||
778  ((buf[i+4*(j-1)+3]&buf[i+4*(j-1)]) == 0x0&&(buf[i+4*(j-1)+3] + buf[i+4*(j-1)] == 0x7FFF ))) );
779  cfeb_b_check[j]=(((buf[i+4*(j-1)+3]&0xF000)==0xB000)&&((buf[i+4*(j-1)+2]&0xF000)==0xB000) &&
780  ((buf[i+4*(j-1)+1]&0xF000)==0xB000)&&((buf[i+4*(j-1)]=3&0xF000)==0xB000) );
781  // DDU Trailers with errors
782  ddu_tr1_bad_check[j]=((tempbuf_short[0]!=ddu_trailer1_bit[0])&&
783  //(tempbuf_short[1]!=ddu_trailer1_bit[1])&&(tempbuf_short[2]!=ddu_trailer1_bit[2])&&
784  //(tempbuf_short[3]==ddu_trailer1_bit[3])&&
785  (tempbuf_short[4]!=ddu_trailer1_bit[4])&&
786  //(tempbuf_short[5]==ddu_trailer1_bit[5])&&
787  //(tempbuf_short[6]==ddu_trailer1_bit[6])&&(tempbuf_short[7]==ddu_trailer1_bit[7])&&
788  (tempbuf_short[8]==ddu_trailer1_bit[8])&&(tempbuf_short[9]==ddu_trailer1_bit[9])&&
789  (tempbuf_short[10]==ddu_trailer1_bit[10])&&(tempbuf_short[11]==ddu_trailer1_bit[11])&&
790  (tempbuf_short[12]==ddu_trailer1_bit[12])&&(tempbuf_short[13]==ddu_trailer1_bit[13])&&
791  (tempbuf_short[14]==ddu_trailer1_bit[14])&&(tempbuf_short[15]==ddu_trailer1_bit[15]));
792  }
793 
794  // DDU Header 2 next to Header 1
795  ddu_h2_h1=ddu_h2_check[2];
796 
797  sprintf(tempbuf_short,"%04x%04x%04x%04x",buf[i+3],buf[i+2],buf[i+1],buf[i]);
798 
799  // Looking for DDU Header 1
800  ddu_h1_12_13=(buf[i]>>8);
801  for (int kk=0; kk<36; kk++){
802  if(((buf[i+3]&0xF000)==0x5000)&&(ddu_h1_12_13==ddu_id[kk])&&ddu_h2_h1){
803  ddu_h1_coll.push_back(word_numbering); ddu_h1_n_coll.push_back(ddu_id[kk]);
804  ddu_inst_l1a=((buf[i+2]&0xFFFF)+((buf[i+3]&0x00FF)<<16));
805  ddu_l1a_coll.push_back(ddu_inst_l1a);
806  ddu_inst_bxn=(buf[i+1]&0xFFF0)>>4;
807  ddu_bxn_coll.push_back(ddu_inst_bxn);
808  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s%i %s%s %s %i %s %i",
809  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],
810  sign1,ddu_common,ddu_id[kk],ddu_header1,sign1,dmb_common_l1a,ddu_inst_l1a,alct_common_bxn,ddu_inst_bxn);
811  std::cout << tempbuf1 << std::endl; w=0; ddu_h1_check=true; ddu_inst_l1a=0;
812  cfeb_sample=0;
813  }
814  }
815 
816 
817 
818  // Looking for DCC Header 1
819  dcc_h1_id=(((buf[i+1]<<12)&0xF000)>>4)+(buf[i]>>8);
820  for(int dcci=0;dcci<16;dcci++){
821  if((dcc_id[dcci]==dcc_h1_id)&&(((buf[i+3]&0xF000)==0x5000)&&(!ddu_h1_check))){
822  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s%i %s",word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],
823  sign1,dcc_common,dcc_h1_id,dcc_header1); dcc_h1_check=word_numbering; w=0;
824  dcc_check=true;
825  std::cout << tempbuf1 << std::endl;
826  }
827  }
828 
829  // Looking for DCC Header 2 and trailers
830  if(((word_numbering-1)==dcc_h1_check)&&((buf[i+3]&0xFF00)==0xD900)) {
831  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s",word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],
832  sign1,dcc_header2);
833  std::cout << tempbuf1 << std::endl; w=0;
834  }
835  else if((word_numbering==word_lines-1)&&(tempbuf_short[0]==dcc_trail1_bit[0])){
836  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s",word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],
837  sign1,dcc_trail1);
838  std::cout << tempbuf1 << std::endl; w=0;
839  }
840  else if((word_numbering==word_lines)&&(tempbuf_short[0]==dcc_trail2_bit[0])){
841  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s",word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],
842  sign1,dcc_trail2);
843  std::cout << tempbuf1 << std::endl; w=0;
844  }
845 
846  // DDU Header 2
847  else if(ddu_h2_check[1]){
848  ddu_inst_i = ddu_h1_n_coll.size(); //ddu_inst_n=ddu_h1_n_coll[0];
849  if(ddu_inst_i>0){
850  ddu_inst_n=ddu_h1_n_coll[ddu_inst_i-1];
851  }
852  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s%i %s",
853  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],sign1,ddu_common,
854  ddu_inst_n, ddu_header2);
855  ddu_h2_coll.push_back(word_numbering);
856  std::cout << tempbuf1 << std::endl; w=0;
857  ddu_h2_found=1;
858  }
859 
860  // DDU Header 3 (either between DDU Header 2 DMB Header or DDU Header 2 DDU Trailer1)
861  else if((ddu_h2_check[0]&&dmb_h1_check[2])||(ddu_h2_check[0]&&ddu_tr1_check[2])){
862  ddu_inst_i = ddu_h1_n_coll.size();
863  if(ddu_inst_i>0){
864  ddu_inst_n=ddu_h1_n_coll[ddu_inst_i-1];
865  }
866  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s%i %s",word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],
867  sign1,ddu_common,ddu_inst_n,ddu_header3);
868  ddu_h3_coll.push_back(word_numbering);
869  std::cout << tempbuf1 << std::endl; w=0;
870  ddu_h2_found=0;
871  }
872 
873  // DMB Header 1,2
874 
875  else if(dmb_h1_check[1]){
876  dmb_inst_crate=0; dmb_inst_slot=0; dmb_inst_l1a=0;
877  dmb_inst_l1a=((buf[i]&0x0FFF)+((buf[i+1]&0xFFF)<<12));
878  dmb_l1a_coll.push_back(dmb_inst_l1a);
879  if(dmb_h2_check[2]){
880  dmb_inst_crate=((buf[i+4+1]>>4)&0xFF); dmb_inst_slot=(buf[i+4+1]&0xF);
881  dmb_crate_coll.push_back(dmb_inst_crate); dmb_slot_coll.push_back(dmb_inst_slot);
882  }
883  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i %s %i",
884  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],
885  sign1,dmb_common,dmb_header1,sign1,dmb_common_crate,dmb_inst_crate,
886  dmb_common_slot,dmb_inst_slot,dmb_common_l1a,dmb_inst_l1a);
887  dmb_h1_coll.push_back(word_numbering);
888  std::cout << tempbuf1 << std::endl; w=0;
889  ddu_h2_found=1;
890  }
891 
892  else if(dmb_h2_check[1]){
893  dmb_inst_crate=((buf[i+1]>>4)&0xFF); dmb_inst_slot=(buf[i+1]&0xF);
894  dmb_h2_coll.push_back(word_numbering);
895  if(dmb_h1_check[0])
896  dmb_inst_l1a=((buf[i-4]&0x0FFF)+((buf[i-4+1]&0xFFF)<<12));
897  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i %s %i",
898  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],
899  sign1,dmb_common,dmb_header2,sign1,dmb_common_crate,dmb_inst_crate,
900  dmb_common_slot,dmb_inst_slot,dmb_common_l1a,dmb_inst_l1a);
901  std::cout << tempbuf1 << std::endl; w=0;
902  ddu_h2_found=1;
903  }
904 
905  //DDU Trailer 1
906 
907  else if(ddu_tr1_check[1]){
908  ddu_inst_i = ddu_h1_n_coll.size();
909  if(ddu_inst_i>0){
910  ddu_inst_n=ddu_h1_n_coll[ddu_inst_i-1];
911  }
912  //ddu_inst_n=ddu_h1_n_coll[ddu_inst_i-1];
913  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s%i %s",
914  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],sign1,ddu_common,ddu_inst_n,ddu_trail1);
915  ddu_t1_coll.push_back(word_numbering);
916  std::cout << tempbuf1 << std::endl; w=0;
917  }
918 
920  else if(alct_h1_check[1]){
921  alct_start=word_numbering;
922  alct_inst_l1a=(buf[i+2]&0x0FFF);
923  alct_l1a_coll.push_back(alct_inst_l1a);
924  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s %s%s %s %i",
925  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],
926  sign1,alct_common,alct_header1,sign1,dmb_common_l1a,alct_inst_l1a);
927  alct_h1_coll.push_back(word_numbering);
928  std::cout << tempbuf1 << std::endl; w=0; alct_inst_l1a=0;
929  }
930 
931  else if((alct_h1_check[0])&&(alct_h2_check[2])) {
932  alct_inst_bxn=(buf[i]&0x0FFF);
933  alct_bxn_coll.push_back(alct_inst_bxn);
934  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s %s%s%s %i",
935  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],
936  sign1,alct_common,alct_header2,sign1,alct_common_bxn,alct_inst_bxn);
937  alct_h2_coll.push_back(word_numbering);
938  std::cout << tempbuf1 << std::endl; w=0; alct_inst_bxn=0;
939  }
940 
941  //ALCT Trailer 1
942  else if(alct_tr1_check[1]){
943  alct_stop=word_numbering;
944  if((alct_start!=0)&&(alct_stop!=0)&&(alct_stop>alct_start)) {
945  alct_inst_wcnt2=4*(alct_stop-alct_start+1);
946  alct_wcnt2_coll.push_back(alct_inst_wcnt2);
947  alct_wcnt2_id_coll.push_back(alct_start);
948  }
949  alct_inst_wcnt1=(buf[i+3]&0x7FF);
950  alct_wcnt1_coll.push_back(alct_inst_wcnt1);
951  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i",
952  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],
953  sign1,alct_common,alct_tr1,sign1,alct_common_wcnt1,alct_inst_wcnt1,
954  alct_common_wcnt2,alct_inst_wcnt2);
955  alct_t1_coll.push_back(word_numbering);
956  std::cout << tempbuf1 << std::endl; w=0; alct_inst_wcnt1=0;
957  alct_inst_wcnt2=0;
958  }
959 
960  //DDU Trailer 3
961  else if((ddu_tr1_check[-1])&&(tempbuf_short[0]==ddu_trailer3_bit[0])){
962  //&&(tempbuf_short[0]==ddu_trailer3_bit[0])){
963  ddu_inst_i = ddu_h1_n_coll.size();
964  if(ddu_inst_i>0){
965  ddu_inst_n=ddu_h1_n_coll[ddu_inst_i-1];
966  }
967  //ddu_inst_n=ddu_h1_n_coll[ddu_inst_i-1];
968  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s%i %s",
969  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],sign1,ddu_common,ddu_inst_n,ddu_trail3);
970  ddu_t3_coll.push_back(word_numbering);
971  std::cout << tempbuf1 << std::endl; w=0;
972  }
973  //DDU Trailer 2
974  else if((ddu_tr1_check[0])&&(tempbuf_short[0]!=ddu_trailer3_bit[0])){
975  //&&(tempbuf_short[0]==ddu_trailer3_bit[0])){
976  ddu_inst_i = ddu_h1_n_coll.size();
977  if(ddu_inst_i>0){
978  ddu_inst_n=ddu_h1_n_coll[ddu_inst_i-1];
979  }
980  //ddu_inst_n=ddu_h1_n_coll[ddu_inst_i-1];
981  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s%i %s",
982  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],sign1,ddu_common,ddu_inst_n,ddu_trail2);
983  ddu_t2_coll.push_back(word_numbering);
984  std::cout << tempbuf1 << std::endl; w=0;
985  }
986 
987  //DMB Trailer 1,2
988  else if(dmb_tr1_check[1]){
989  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s %s",
990  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],sign1,dmb_common,dmb_tr1);
991  dmb_t1_coll.push_back(word_numbering);
992  std::cout << tempbuf1 << std::endl; w=0;
993  cfeb_sample=0;
994  }
995 
996  else if(dmb_tr2_check[1]){
997  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s %s",
998  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],sign1,dmb_common,dmb_tr2);
999  dmb_t2_coll.push_back(word_numbering);
1000  std::cout << tempbuf1 << std::endl; w=0;
1001  }
1002  // TMB
1003  else if(tmb_h1_check[1]){
1004  tmb_start=word_numbering;
1005  tmb_inst_l1a=(buf[i+2]&0x000F);
1006  tmb_l1a_coll.push_back(tmb_inst_l1a);
1007  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s %s%s%s %i",
1008  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],sign1,tmb_common,tmb_header1,
1009  sign1,dmb_common_l1a,tmb_inst_l1a);
1010  tmb_h1_coll.push_back(word_numbering);
1011  std::cout << tempbuf1 << std::endl; w=0; tmb_inst_l1a=0;
1012  }
1013  else if(tmb_tr1_check[1]){
1014  tmb_stop=word_numbering;
1015  if((tmb_start!=0)&&(tmb_stop!=0)&&(tmb_stop>tmb_start)) {
1016  tmb_inst_wcnt2=4*(tmb_stop-tmb_start+1);
1017  tmb_wcnt2_coll.push_back(tmb_inst_wcnt2);
1018  }
1019  tmb_inst_wcnt1=(buf[i+3]&0x7FF);
1020  tmb_wcnt1_coll.push_back(tmb_inst_wcnt1);
1021  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i",
1022  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],
1023  sign1,tmb_common,tmb_tr1,sign1,alct_common_wcnt1,tmb_inst_wcnt1,
1024  alct_common_wcnt2,tmb_inst_wcnt2);
1025  tmb_t1_coll.push_back(word_numbering);
1026  std::cout << tempbuf1 << std::endl; w=0;
1027  tmb_inst_wcnt2=0;
1028  }
1029  // CFEB
1030  else if(cfeb_tr1_check[1]){
1031  ++cfeb_sample;
1032  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s %s%s %s %i",
1033  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],
1034  sign1,cfeb_common,cfeb_tr1,sign1,cfeb_common_sample,cfeb_sample);
1035  cfeb_t1_coll.push_back(word_numbering); w=0;
1036  std::cout << tempbuf1 << std::endl; w=0;
1037  }
1038  else if(cfeb_b_check[1]){
1039  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s %s",
1040  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],sign1,cfeb_common,cfeb_b);
1041  std::cout << tempbuf1 << std::endl; w=0;
1042  }
1043 
1044  //ERRORS ddu_tr1_bad_check
1045 
1046  else if(ddu_tr1_bad_check[1]){
1047  ddu_inst_i = ddu_h1_n_coll.size(); ddu_inst_n=ddu_h1_n_coll[ddu_inst_i-1];
1048  sprintf(tempbuf1,"%6i %04x %04x %04x %04x%s%s%i %s %s",
1049  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i],sign1,ddu_common,ddu_inst_n,
1050  ddu_trail1,ddu_tr1_err_common);
1051  std::cout << tempbuf1 << std::endl; w=0;
1052  }
1053 
1054  else if(extraction&&(!ddu_h1_check)&&(!dcc_check)){
1055  if(w<3){
1056  sprintf(tempbuf,"%6i %04x %04x %04x %04x",
1057  word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i]);
1058  std::cout << tempbuf << std::endl; w++;}
1059  if(w==3){
1060  std::cout << "..................................................." << std::endl; w++;}
1061  }
1062 
1063  else if((!ddu_h1_check)&&(!dcc_check)){
1064  sprintf(tempbuf,"%6i %04x %04x %04x %04x",word_numbering,buf[i+3],buf[i+2],buf[i+1],buf[i]);
1065  std::cout << tempbuf << std::endl;
1066  }
1067 
1068  i+=3; ddu_h1_check=false; dcc_check=false;
1069  }
1070  //char sign[30]; //WARNING 5_0_X
1071  std::cout <<"********************************************************************************" <<
1072  std::endl << std::endl;
1073  if(fedshort)
1074  std::cout << "For complete output turn off VisualFEDShort in muonCSCDigis configuration file." << std::endl;
1075  std::cout <<"********************************************************************************" <<
1076  std::endl << std::endl;
1077  std::cout << std::endl << std::endl;
1078  std::cout <<" Summary " << std::endl;
1079  std::cout << std::endl << std::endl;
1080  std::cout << ddu_h1_coll.size() <<" "<< ddu_common << " "<<ddu_header1 << " "<< "found" << std::endl;
1081  /*
1082  std::cout << ddu_h1_coll.size() << " " << ddu_h1_n_coll.size() << " " << ddu_l1a_coll.size() <<
1083  " " << ddu_bxn_coll.size() << std::endl;
1084  */
1085  for(unsigned int k=0; k<ddu_h1_coll.size();++k){
1086  /*
1087  sprintf(sign,"%s%6i%5s %s%i %s %i %s %i","Line: ",
1088  ddu_h1_coll[k],sign1,ddu_common,ddu_h1_n_coll[k],dmb_common_l1a,ddu_l1a_coll[k],
1089  alct_common_bxn,ddu_bxn_coll[k]);
1090  */
1091  std::cout << "Line: " << " " << ddu_h1_coll[k] << " " << sign1 << " " <<
1092  ddu_common << " " << ddu_h1_n_coll[k] << " " << dmb_common_l1a << " " << ddu_l1a_coll[k] << " " <<
1093  alct_common_bxn << " " << ddu_bxn_coll[k] << std::endl;
1094  }
1095 
1096 
1097  std::cout << std::endl << std::endl;
1098  std::cout << "||||||||||||||||||||" << std::endl;
1099  std::cout << std::endl << std::endl;
1100  std::cout << ddu_h2_coll.size() <<" "<< ddu_common << " "<<ddu_header2 << " "<< "found" << std::endl;
1101  for(unsigned int k=0; k<ddu_h2_coll.size();++k)
1102  std::cout << "Line: " << ddu_h2_coll[k] << std::endl;
1103  std::cout << std::endl << std::endl;
1104  std::cout << "||||||||||||||||||||" << std::endl;
1105  std::cout << std::endl << std::endl;
1106  std::cout << ddu_h3_coll.size() <<" "<< ddu_common << " "<<ddu_header3 << " "<< "found" << std::endl;
1107  for(unsigned int k=0; k<ddu_h3_coll.size();++k)
1108  std::cout << "Line: " << ddu_h3_coll[k] << std::endl;
1109  std::cout << std::endl << std::endl;
1110  std::cout << "||||||||||||||||||||" << std::endl;
1111  std::cout << std::endl << std::endl;
1112  std::cout << ddu_t1_coll.size() <<" "<< ddu_common << " "<<ddu_trail1 << " "<< "found" << std::endl;
1113  for(unsigned int k=0; k<ddu_t1_coll.size();++k)
1114  std::cout << "Line: " << ddu_t1_coll[k] << std::endl;
1115  std::cout << std::endl << std::endl;
1116  std::cout << "||||||||||||||||||||" << std::endl;
1117  std::cout << std::endl << std::endl;
1118  std::cout << ddu_t2_coll.size() <<" "<< ddu_common << " "<<ddu_trail2 << " "<< "found" << std::endl;
1119  for(unsigned int k=0; k<ddu_t2_coll.size();++k)
1120  std::cout << "Line: " << ddu_t2_coll[k] << std::endl;
1121  std::cout << std::endl << std::endl;
1122  std::cout << "||||||||||||||||||||" << std::endl;
1123  std::cout << std::endl << std::endl;
1124  std::cout << ddu_t3_coll.size() <<" "<< ddu_common << " "<<ddu_trail3 << " "<< "found" << std::endl;
1125  for(unsigned int k=0; k<ddu_t3_coll.size();++k)
1126  std::cout << "Line: " << ddu_t3_coll[k] << std::endl;
1127  std::cout << std::endl << std::endl;
1128  std::cout << "||||||||||||||||||||" << std::endl;
1129  std::cout << std::endl << std::endl;
1130  std::cout << dmb_h1_coll.size() <<" "<< dmb_common << " "<<dmb_header1 << " "<< "found" << std::endl;
1131 
1132  for(unsigned int k=0; k<dmb_h1_coll.size();++k){
1133  /*
1134  sprintf(sign,"%s%6i%5s %s %s %i %s %i %s %i","Line: ",
1135  dmb_h1_coll[k],sign1,dmb_common,dmb_common_crate,dmb_crate_coll[k],dmb_common_slot,
1136  dmb_slot_coll[k],dmb_common_l1a,dmb_l1a_coll[k]);
1137  */
1138  std::cout << "Line: " << " " << dmb_h1_coll[k] << " " << sign1 << dmb_common
1139  << " " << dmb_common_crate << " " << dmb_crate_coll[k] << " " << dmb_common_slot << " " <<
1140  dmb_slot_coll[k] << " " << dmb_common_l1a << " " << dmb_l1a_coll[k] << std::endl;
1141  }
1142  std::cout << std::endl << std::endl;
1143  std::cout << "||||||||||||||||||||" << std::endl;
1144  std::cout << std::endl << std::endl;
1145  std::cout << dmb_h2_coll.size() <<" "<< dmb_common << " "<<dmb_header2 << " "<< "found" << std::endl;
1146  for(unsigned int k=0; k<dmb_h2_coll.size();++k)
1147  std::cout << "Line: " << dmb_h2_coll[k] << std::endl;
1148  std::cout << std::endl << std::endl;
1149  std::cout << "||||||||||||||||||||" << std::endl;
1150  std::cout << std::endl << std::endl;
1151  std::cout << dmb_t1_coll.size() <<" "<< dmb_common << " "<<dmb_tr1 << " "<< "found" << std::endl;
1152  for(unsigned int k=0; k<dmb_t1_coll.size();++k)
1153  std::cout << "Line: " << dmb_t1_coll[k] << std::endl;
1154  std::cout << std::endl << std::endl;
1155  std::cout << "||||||||||||||||||||" << std::endl;
1156  std::cout << std::endl << std::endl;
1157  std::cout << dmb_t2_coll.size() <<" "<< dmb_common << " "<<dmb_tr2 << " "<< "found" << std::endl;
1158  for(unsigned int k=0; k<dmb_t2_coll.size();++k)
1159  std::cout << "Line: " << dmb_t2_coll[k] << std::endl;
1160  std::cout << std::endl << std::endl;
1161  std::cout << "||||||||||||||||||||" << std::endl;
1162  std::cout << std::endl << std::endl;
1163  std::cout << alct_h1_coll.size() <<" "<< alct_common << " "<<alct_header1 << " "<< "found" << std::endl;
1164  for(unsigned int k=0; k<alct_h1_coll.size();++k){
1165  /*
1166  sprintf(sign,"%s%6i%5s %s %s %i","Line: ",
1167  alct_h1_coll[k],sign1,alct_common,
1168  dmb_common_l1a,alct_l1a_coll[k]);
1169  std::cout << sign << std::endl;
1170  */
1171  std::cout << "Line: " << " " <<
1172  alct_h1_coll[k] << " " << sign1 << " " << alct_common << " " <<
1173  dmb_common_l1a << " " << alct_l1a_coll[k] << std::endl;
1174  }
1175 
1176  std::cout << std::endl << std::endl;
1177  std::cout << "||||||||||||||||||||" << std::endl;
1178  std::cout << std::endl << std::endl;
1179  std::cout << alct_h2_coll.size() <<" "<< alct_common << " "<<alct_header2 << " "<< "found" << std::endl;
1180  for(unsigned int k=0; k<alct_h2_coll.size();++k){
1181  /*
1182  sprintf(sign,"%s%6i%5s %s %s %i","Line: ",
1183  alct_h1_coll[k],sign1,alct_common,
1184  alct_common_bxn,alct_bxn_coll[k]);
1185  std::cout << sign << std::endl;
1186  */
1187  std::cout << "Line: " << " " <<
1188  alct_h1_coll[k] << " " << sign1 << " " << alct_common << " " <<
1189  alct_common_bxn << " " << alct_bxn_coll[k] << std::endl;
1190  }
1191 
1192  std::cout << std::endl << std::endl;
1193  std::cout << "||||||||||||||||||||" << std::endl;
1194  std::cout << std::endl << std::endl;
1195  std::cout << alct_t1_coll.size() <<" "<< alct_common << " "<<alct_tr1 << " "<< "found" << std::endl;
1196  for(unsigned int k=0; k<alct_t1_coll.size();++k){
1197  /*
1198  sprintf(sign,"%s%6i%5s %s %s %i %s %i","Line: ",
1199  alct_t1_coll[k],sign1,alct_common,
1200  alct_common_wcnt1,alct_wcnt1_coll[k],alct_common_wcnt2,alct_wcnt2_coll[k]);
1201  std::cout << sign << std::endl;
1202  */
1203  std::cout << "Line: " << " " << alct_t1_coll[k] << " " << sign1 << " " << alct_common << " " <<
1204  alct_common_wcnt1 << " " << alct_wcnt1_coll[k] << " " << alct_common_wcnt2 << " ";
1205  if(alct_wcnt2_coll.size()>0){
1206  std::cout << alct_wcnt2_coll[k] << std::endl;}
1207  else {
1208  std::cout << "Undefined (ALCT Header is not found) " << std::endl;}
1209  }
1210 
1211  std::cout << std::endl << std::endl;
1212  std::cout << "||||||||||||||||||||" << std::endl;
1213  std::cout << std::endl << std::endl;
1214  std::cout << tmb_h1_coll.size() <<" "<< tmb_common << " "<<tmb_header1 << " "<< "found" << std::endl;
1215  for(unsigned int k=0; k<tmb_h1_coll.size();++k){
1216  /*
1217  sprintf(sign,"%s%6i%5s %s %s %i","Line: ",
1218  tmb_h1_coll[k],sign1,tmb_common,
1219  dmb_common_l1a,tmb_l1a_coll[k]);
1220  std::cout << sign << std::endl;
1221  */
1222  std::cout << "Line: " << " " << tmb_h1_coll[k] << " " << sign1 << " " << tmb_common << " " <<
1223  dmb_common_l1a << " " << tmb_l1a_coll[k] << std::endl;
1224  }
1225 
1226  std::cout << std::endl << std::endl;
1227  std::cout << "||||||||||||||||||||" << std::endl;
1228  std::cout << std::endl << std::endl;
1229  std::cout << tmb_t1_coll.size() <<" "<< tmb_common << " "<<tmb_tr1 << " "<< "found" << std::endl;
1230  for(unsigned int k=0; k<tmb_t1_coll.size();++k){
1231  /*
1232  sprintf(sign,"%s%6i%5s %s %s %i %s %i","Line: ",
1233  tmb_t1_coll[k],sign1,tmb_common,
1234  alct_common_wcnt1,tmb_wcnt1_coll[k],alct_common_wcnt2,tmb_wcnt2_coll[k]);
1235  std::cout << sign << std::endl;
1236  */
1237  std::cout << "Line: " << " " << tmb_t1_coll[k] << " " << sign1 << " " << tmb_common << " " <<
1238  alct_common_wcnt1 << " " << tmb_wcnt1_coll[k] << " " << alct_common_wcnt2 << " " << tmb_wcnt2_coll[k]
1239  << std::endl;
1240  }
1241 
1242 
1243  std::cout << std::endl << std::endl;
1244  std::cout << "||||||||||||||||||||" << std::endl;
1245  std::cout << std::endl << std::endl;
1246  std::cout << cfeb_t1_coll.size() <<" "<< cfeb_common << " "<<cfeb_tr1 << " "<< "found" << std::endl;
1247  for(unsigned int k=0; k<cfeb_t1_coll.size();++k)
1248  std::cout << "Line: " << cfeb_t1_coll[k] << std::endl;
1249  std::cout <<"********************************************************************************" << std::endl;
1250 
1251 }
RunNumber_t run() const
Definition: EventID.h:42
01/20/05 A.Tumanov
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
void crcCFEB(bool enable)
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
bool SuppressZeroLCT
Suppress zeros LCTs.
OStream & output1(void)
static void setDebug(bool value)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
CSCDetId detId(int vme, int dmb, int cfeb, int layer=0) const
Definition: CSCCrateMap.cc:11
const uint16_t nERRORS
CSCMonitorInterface * monitor
#define NULL
Definition: scimark2.h:8
void redirect(std::ostream &str)
ExaminerStatusType errors(void) const
void crcALCT(bool enable)
OStream & output2(void)
const char * errName(int num) const
bool visualFEDInspect
Visualization of raw data.
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
void produce(edm::Event &e, const edm::EventSetup &c)
Produce digis out of raw data.
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
virtual void process(CSCDCCExaminer *examiner, CSCDCCEventData *dccData)=0
static void setDebug(const bool value)
Definition: CSCTMBHeader.h:104
static void setDebug(const bool value)
Definition: CSCTMBData.h:33
void visual_raw(int hl, int id, int run, int event, bool fedshort, bool fDump, short unsigned int *buf) const
Visualization of raw data in FED-less events (Robert Harr and Alexander Sakharov) ...
std::map< CSCIdType, ExaminerStatusType > errorsDetailed(void) const
static void setErrorMask(unsigned int value)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
static void setDebug(bool value)
void crcTMB(bool enable)
int j
Definition: DBlmapReader.cc:9
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::map< CSCIdType, ExaminerStatusType > statusDetailed(void) const
#define LogTrace(id)
int k[5][pyjets_maxn]
static void setDebug(const bool value)
Definition: CSCCLCTData.h:29
ExaminerMaskType getMask() const
edm::EDGetTokenT< FEDRawDataCollection > i_token
Token for consumes interface &amp; access to data.
unsigned int errorMask
unsigned int examinerMask
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
static void setDebug(bool value)
to access data by via status digis
Definition: CSCALCTHeader.h:27
bool useSelectiveUnpacking
int32_t check(const uint16_t *&buffer, int32_t length)
std::map< CSCIdType, ExaminerStatusType > payloadDetailed(void) const
edm::EventID id() const
Definition: EventBase.h:56
CSC Format Status Object.
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
CSCDCCUnpacker(const edm::ParameterSet &pset)
Constructor.
tuple cout
Definition: gather_cfg.py:121
std::map< DDUIdType, ExaminerStatusType > errorsDetailedDDU(void) const
T w() const
dictionary rawdata
Definition: lumiPlot.py:393
virtual ~CSCDCCUnpacker()
Destructor.
void setMask(ExaminerMaskType mask)
static void setDebug(const bool value)
Definition: CSCEventData.h:52
static void setDebug(bool debugValue)
Definition: CSCRPCData.h:24