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