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