CMS 3D CMS Logo

CSCDCCUnpacker.cc
Go to the documentation of this file.
1 
7 //Framework stuff
21 
26 
27 //FEDRawData
30 
31 //Digi stuff
32 
51 
58 
59 #include <iostream>
60 #include <sstream>
61 #include <string>
62 #include <iomanip>
63 #include <cstdio>
64 
66 
68 public:
71 
73  ~CSCDCCUnpacker() override;
74 
75  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
76 
78  void produce(edm::Event& e, const edm::EventSetup& c) override;
79 
81  void visual_raw(int hl, int id, int run, int event, bool fedshort, bool fDump, short unsigned int* buf) const;
82 
83 private:
86 
88  bool useRPCs_;
89 
91  bool useGEMs_;
92 
95 
100 
102  unsigned int errorMask, examinerMask;
104 
107 
109 
114 };
115 
117  // Tracked
118  i_token = consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("InputObjects"));
119  crateToken = esConsumes<CSCCrateMap, CSCCrateMapRcd>();
120  cscmapToken = esConsumes<CSCChamberMap, CSCChamberMapRcd>();
121 
122  useExaminer = pset.getParameter<bool>("UseExaminer");
123  examinerMask = pset.getParameter<unsigned int>("ExaminerMask");
125  useSelectiveUnpacking = pset.getParameter<bool>("UseSelectiveUnpacking");
126  errorMask = pset.getParameter<unsigned int>("ErrorMask");
127  unpackStatusDigis = pset.getParameter<bool>("UnpackStatusDigis");
129  useFormatStatus = pset.getParameter<bool>("UseFormatStatus");
130 
131  useRPCs_ = pset.getParameter<bool>("useRPCs");
132  useGEMs_ = pset.getParameter<bool>("useGEMs");
133  useCSCShowers_ = pset.getParameter<bool>("useCSCShowers");
134 
135  // Untracked
136  printEventNumber = pset.getUntrackedParameter<bool>("PrintEventNumber", true);
137  debug = pset.getUntrackedParameter<bool>("Debug", false);
138  instantiateDQM = pset.getUntrackedParameter<bool>("runDQM", false);
139 
140  // Disable FED/DDU to chamber mapping inconsistency check
141  disableMappingCheck = pset.getUntrackedParameter<bool>("DisableMappingCheck", false);
142  // Make aware the unpacker that B904 test setup is used (disable mapping inconsistency check)
143  b904Setup = pset.getUntrackedParameter<bool>("B904Setup", false);
144  b904vmecrate = pset.getUntrackedParameter<int>("B904vmecrate", 1);
145  b904dmb = pset.getUntrackedParameter<int>("B904dmb", 3);
146 
148  visualFEDInspect = pset.getUntrackedParameter<bool>("VisualFEDInspect", false);
149  visualFEDShort = pset.getUntrackedParameter<bool>("VisualFEDShort", false);
150  formatedEventDump = pset.getUntrackedParameter<bool>("FormatedEventDump", false);
151 
153  SuppressZeroLCT = pset.getUntrackedParameter<bool>("SuppressZeroLCT", true);
154 
155  if (instantiateDQM) {
157  }
158 
159  produces<CSCWireDigiCollection>("MuonCSCWireDigi");
160  produces<CSCStripDigiCollection>("MuonCSCStripDigi");
161  produces<CSCComparatorDigiCollection>("MuonCSCComparatorDigi");
162  produces<CSCALCTDigiCollection>("MuonCSCALCTDigi");
163  produces<CSCCLCTDigiCollection>("MuonCSCCLCTDigi");
164  produces<CSCCorrelatedLCTDigiCollection>("MuonCSCCorrelatedLCTDigi");
165 
166  if (unpackStatusDigis) {
167  produces<CSCCFEBStatusDigiCollection>("MuonCSCCFEBStatusDigi");
168  produces<CSCTMBStatusDigiCollection>("MuonCSCTMBStatusDigi");
169  produces<CSCDMBStatusDigiCollection>("MuonCSCDMBStatusDigi");
170  produces<CSCALCTStatusDigiCollection>("MuonCSCALCTStatusDigi");
171  produces<CSCDDUStatusDigiCollection>("MuonCSCDDUStatusDigi");
172  produces<CSCDCCStatusDigiCollection>("MuonCSCDCCStatusDigi");
173  }
174 
175  if (useFormatStatus) {
176  produces<CSCDCCFormatStatusDigiCollection>("MuonCSCDCCFormatStatusDigi");
177  }
178 
179  if (useRPCs_) {
180  produces<CSCRPCDigiCollection>("MuonCSCRPCDigi");
181  }
182 
183  if (useGEMs_) {
184  produces<GEMPadDigiClusterCollection>("MuonGEMPadDigiCluster");
185  }
186 
187  if (useCSCShowers_) {
188  produces<CSCShowerDigiCollection>("MuonCSCShowerDigi");
189  produces<CSCShowerDigiCollection>("MuonCSCShowerDigiAnode");
190  produces<CSCShowerDigiCollection>("MuonCSCShowerDigiCathode");
191  produces<CSCShowerDigiCollection>("MuonCSCShowerDigiAnodeALCT");
192  }
193 
194  //CSCAnodeData::setDebug(debug);
204 }
205 
207  //fill destructor here
208 }
209 
212  desc.add<edm::InputTag>("InputObjects", edm::InputTag("rawDataCollector"))
213  ->setComment("# Define input to the unpacker");
214  desc.add<bool>("UseExaminer", true)
215  ->setComment("# Use CSC examiner to check for corrupt or semi-corrupt data & avoid unpacker crashes");
216  desc.add<unsigned int>("ExaminerMask", 535557110)->setComment("# This mask is needed by the examiner");
217  desc.add<bool>("UseSelectiveUnpacking", true)
218  ->setComment("# Use Examiner to unpack good chambers and skip only bad ones");
219  desc.add<unsigned int>("ErrorMask", 0)->setComment("# This mask simply reduces error reporting");
220  desc.add<bool>("UnpackStatusDigis", false)->setComment("# Unpack general status digis?");
221  desc.add<bool>("UseFormatStatus", true)->setComment("# Unpack FormatStatus digi?");
222  desc.add<bool>("useRPCs", false)->setComment("Unpack RPC data");
223  desc.add<bool>("useGEMs", true)->setComment("Unpack GEM trigger data");
224  desc.add<bool>("useCSCShowers", true)->setComment("Unpack CSCShower trigger data");
225  desc.addUntracked<bool>("Debug", false)->setComment("# Turn on lots of output");
226  desc.addUntracked<bool>("PrintEventNumber", false);
227  desc.addUntracked<bool>("runDQM", false);
228  desc.addUntracked<bool>("VisualFEDInspect", false)->setComment("# Visualization of raw data in corrupted events");
229  desc.addUntracked<bool>("VisualFEDShort", false)->setComment("# Visualization of raw data in corrupted events");
230  desc.addUntracked<bool>("FormatedEventDump", false);
231  desc.addUntracked<bool>("SuppressZeroLCT", true);
232  desc.addUntracked<bool>("DisableMappingCheck", false)
233  ->setComment("# Disable FED/DDU to chamber mapping inconsistency check");
234  desc.addUntracked<bool>("B904Setup", false)->setComment("# Make the unpacker aware of B904 test setup configuration");
235  desc.addUntracked<int>("B904vmecrate", 1)->setComment("# Set vmecrate number for chamber used in B904 test setup");
236  desc.addUntracked<int>("B904dmb", 3)->setComment("# Set dmb slot for chamber used in B904 test setup");
237  descriptions.add("muonCSCDCCUnpacker", desc);
238  descriptions.setComment(" This is the generic cfi file for CSC unpacking");
239 }
240 
243  // Do we really have to do this every event???
244  // ... Yes, because framework is more efficient than you are at caching :)
245  // (But if you want to actually DO something specific WHEN the mapping changes, check out ESWatcher)
246  edm::ESHandle<CSCCrateMap> hcrate = c.getHandle(crateToken);
247  const CSCCrateMap* pcrate = hcrate.product();
248 
249  // Need access to CSCChamberMap for chamber<->FED/DDU mapping consistency checks
251  const CSCChamberMap* cscmapping = cscmap.product();
252 
253  if (printEventNumber)
254  ++numOfEvents;
255 
258  e.getByToken(i_token, rawdata);
259 
261  auto wireProduct = std::make_unique<CSCWireDigiCollection>();
262  auto stripProduct = std::make_unique<CSCStripDigiCollection>();
263  auto alctProduct = std::make_unique<CSCALCTDigiCollection>();
264  auto clctProduct = std::make_unique<CSCCLCTDigiCollection>();
265  auto comparatorProduct = std::make_unique<CSCComparatorDigiCollection>();
266  auto rpcProduct = std::make_unique<CSCRPCDigiCollection>();
267  auto corrlctProduct = std::make_unique<CSCCorrelatedLCTDigiCollection>();
268  auto cfebStatusProduct = std::make_unique<CSCCFEBStatusDigiCollection>();
269  auto dmbStatusProduct = std::make_unique<CSCDMBStatusDigiCollection>();
270  auto tmbStatusProduct = std::make_unique<CSCTMBStatusDigiCollection>();
271  auto dduStatusProduct = std::make_unique<CSCDDUStatusDigiCollection>();
272  auto dccStatusProduct = std::make_unique<CSCDCCStatusDigiCollection>();
273  auto alctStatusProduct = std::make_unique<CSCALCTStatusDigiCollection>();
274 
275  auto formatStatusProduct = std::make_unique<CSCDCCFormatStatusDigiCollection>();
276 
277  auto gemProduct = std::make_unique<GEMPadDigiClusterCollection>();
278 
279  auto lctShowerProduct =
280  std::make_unique<CSCShowerDigiCollection>(); // HMT shower objects from OTMB/MPC LCT trigger data frames
281  auto anodeShowerProductOTMB =
282  std::make_unique<CSCShowerDigiCollection>(); // anode HMT shower objects from (O)TMB header data (matched at OTMB)
283  auto cathodeShowerProductOTMB =
284  std::make_unique<CSCShowerDigiCollection>(); // cathode HMT shower objects from (O)TMB header data
285  auto anodeShowerProductALCT = std::make_unique<
286  CSCShowerDigiCollection>(); // anode HMT shower objects from ALCT data (vector of HMT shower objects per ALCT BX)
287 
288  // If set selective unpacking mode
289  // hardcoded examiner mask below to check for DCC and DDU level errors will be used first
290  // then examinerMask for CSC level errors will be used during unpacking of each CSC block
291  unsigned long dccBinCheckMask = 0x06080016;
292 
293  // Post-LS1 FED/DDU ID mapping fix
294  const unsigned postLS1_map[] = {841, 842, 843, 844, 845, 846, 847, 848, 849, 831, 832, 833,
295  834, 835, 836, 837, 838, 839, 861, 862, 863, 864, 865, 866,
296  867, 868, 869, 851, 852, 853, 854, 855, 856, 857, 858, 859};
297 
298  // For new CSC readout layout, which wont include DCCs need to loop over DDU FED IDs. DCC IDs are included for backward compatibility with old data
299  std::vector<unsigned int> cscFEDids;
300 
301  for (unsigned int id = FEDNumbering::MINCSCFEDID; id <= FEDNumbering::MAXCSCFEDID; ++id) // loop over DCCs
302  {
303  cscFEDids.push_back(id);
304  }
305 
306  for (unsigned int id = FEDNumbering::MINCSCDDUFEDID; id <= FEDNumbering::MAXCSCDDUFEDID; ++id) // loop over DDUs
307  {
308  cscFEDids.push_back(id);
309  }
310 
311  for (unsigned int i = 0; i < cscFEDids.size(); i++) // loop over all CSC FEDs (DCCs and DDUs)
312  {
313  unsigned int id = cscFEDids[i];
314  bool isDDU_FED = ((id >= FEDNumbering::MINCSCDDUFEDID) && (id <= FEDNumbering::MAXCSCDDUFEDID)) ? true : false;
315 
318 
320  const FEDRawData& fedData = rawdata->FEDData(id);
321  unsigned long length = fedData.size();
322 
323  if (length >= 32)
324  {
325  CSCDCCExaminer* examiner = nullptr;
326  goodEvent = true;
327  if (useExaminer)
328  {
329  // CSCDCCExaminer examiner;
330  examiner = new CSCDCCExaminer();
331  if (examinerMask & 0x40000)
332  examiner->crcCFEB(true);
333  if (examinerMask & 0x8000)
334  examiner->crcTMB(true);
335  if (examinerMask & 0x0400)
336  examiner->crcALCT(true);
337  examiner->setMask(examinerMask);
338 
340  if (isDDU_FED) {
341  if (examiner != nullptr)
342  examiner->modeDDU(true);
343  }
344 
345  const short unsigned int* data = (short unsigned int*)fedData.data();
346 
347  LogTrace("badData") << "Length: " << length / 2;
348  // Event data hex dump
349  /*
350  short unsigned * buf = (short unsigned int *)fedData.data();
351  std::cout <<std::endl<<length/2<<" words of data:"<<std::endl;
352  for (short unsigned int i=0;i<length/2;i++) {
353  printf("%04x %04x %04x %04x\n",buf[i+3],buf[i+2],buf[i+1],buf[i]);
354  i+=3;
355  }
356  */
357 
358  int res = examiner->check(data, long(fedData.size() / 2));
359  if (res < 0) {
360  goodEvent = false;
361  } else {
363  goodEvent = !(examiner->errors() & dccBinCheckMask);
364  else
365  goodEvent = !(examiner->errors() & examinerMask);
366  }
367 
368  /*
369  std::cout << "FED" << std::dec << id << " size:" << fedData.size() << " good:" << goodEvent << " errs 0x"
370  << std::hex << examiner->errors() << std::dec << std::endl;
371  */
372 
373  // Fill Format status digis per FED
374  // Remove examiner->errors() != 0 check if we need to put status digis for every event
375  if (useFormatStatus && (examiner->errors() != 0))
376  // formatStatusProduct->insertDigi(CSCDetId(1,1,1,1,1), CSCDCCFormatStatusDigi(id,examiner,dccBinCheckMask));
377  formatStatusProduct->insertDigi(CSCDetId(1, 1, 1, 1, 1),
379  dccBinCheckMask,
380  examiner->getMask(),
381  examiner->errors(),
382  examiner->errorsDetailedDDU(),
383  examiner->errorsDetailed(),
384  examiner->payloadDetailed(),
385  examiner->statusDetailed()));
386  }
387 
390  if (!goodEvent || formatedEventDump) {
391  short unsigned* buf = (short unsigned int*)fedData.data();
392  visual_raw(length / 2, id, (int)e.id().run(), (int)e.id().event(), visualFEDShort, formatedEventDump, buf);
393  }
394  }
395 
396  if (goodEvent) {
398 
399  CSCDCCExaminer* ptrExaminer = examiner;
401  ptrExaminer = nullptr;
402 
403  std::vector<CSCDDUEventData> fed_Data;
404  std::vector<CSCDDUEventData>* ptr_fedData = &fed_Data;
405 
407  CSCDetId layer(1, 1, 1, 1, 1);
408 
409  if (isDDU_FED) // Use new DDU FED readout mode
410  {
411  CSCDDUEventData single_dduData((short unsigned int*)fedData.data(), ptrExaminer);
412  fed_Data.push_back(single_dduData);
413 
414  // if(instantiateDQM) monitor->process(examiner, &single_dduData);
415 
416  } else // Use old DCC FED readout mode
417  {
418  CSCDCCEventData dccData((short unsigned int*)fedData.data(), ptrExaminer);
419 
420  //std::cout << " DCC Size [UNPK] " << dccData.sizeInWords() << std::endl;
421 
422  if (instantiateDQM)
423  monitor->process(examiner, &dccData);
424 
426  // const std::vector<CSCDDUEventData> & dduData = dccData.dduData();
427  // ptr_fedData = &(dccData.dduData());
428  fed_Data = dccData.dduData();
429 
430  if (unpackStatusDigis) {
432  short unsigned* bufForDcc = (short unsigned int*)fedData.data();
433 
434  //std::cout << "FED Length: " << std::dec << length/2 <<
435  //" Trailer 2: " << std::hex << bufForDcc[length/2-4] << std::endl;
436 
437  dccStatusProduct->insertDigi(layer,
438  CSCDCCStatusDigi(dccData.dccHeader().data(),
439  dccData.dccTrailer().data(),
440  examiner->errors(),
441  bufForDcc[length / 2 - 4]));
442  }
443  }
444 
445  const std::vector<CSCDDUEventData>& dduData = *ptr_fedData;
446 
447  for (unsigned int iDDU = 0; iDDU < dduData.size(); ++iDDU) // loop over DDUs
448  {
451  if (dduData[iDDU].trailer().errorstat() & errorMask) {
452  LogTrace("CSCDCCUnpacker|CSCRawToDigi")
453  << "FED ID" << id << " DDU# " << iDDU << " has serious error - no digis unpacked! " << std::hex
454  << dduData[iDDU].trailer().errorstat();
455  continue; // to next iteration of DDU loop
456  }
457 
458  if (unpackStatusDigis)
459  dduStatusProduct->insertDigi(
460  layer,
461  CSCDDUStatusDigi(dduData[iDDU].header().data(),
462  dduData[iDDU].trailer().data(),
464  dduData[iDDU].trailer0()));
465 
467  const std::vector<CSCEventData>& cscData = dduData[iDDU].cscData();
468 
469  // if (cscData.size() != 0) std::cout << "FED" << id << " DDU Source ID: " << dduData[iDDU].header().source_id() << " firmware version: " << dduData[iDDU].header().format_version() << std::endl;
470 
471  for (unsigned int iCSC = 0; iCSC < cscData.size(); ++iCSC) // loop over CSCs
472  {
474 
475  int vmecrate = b904Setup ? b904vmecrate : cscData[iCSC].dmbHeader()->crateID();
476  int dmb = b904Setup ? b904dmb : cscData[iCSC].dmbHeader()->dmbID();
477 
478  int icfeb = 0;
479  int ilayer = 0;
480 
481  if (debug)
482  LogTrace("CSCDCCUnpacker|CSCRawToDigi") << "crate = " << vmecrate << "; dmb = " << dmb;
483 
484  if ((vmecrate >= 1) && (vmecrate <= 60) && (dmb >= 1) && (dmb <= 10) && (dmb != 6)) {
485  layer = pcrate->detId(vmecrate, dmb, icfeb, ilayer);
486  } else {
487  LogTrace("CSCDCCUnpacker|CSCRawToDigi") << " detID input out of range!!! ";
488  LogTrace("CSCDCCUnpacker|CSCRawToDigi") << " skipping chamber vme= " << vmecrate << " dmb= " << dmb;
489  continue; // to next iteration of iCSC loop
490  }
491 
494  if (isDDU_FED) {
495  unsigned int dduid = cscmapping->ddu(layer);
496  if ((dduid >= 1) && (dduid <= 36)) {
497  dduid = postLS1_map[dduid - 1]; // Fix for Post-LS1 FED/DDU IDs mappings
498  // std::cout << "CSC " << layer << " -> " << id << ":" << dduid << ":" << vmecrate << ":" << dmb << std::endl;
499  }
500 
502  if ((!disableMappingCheck) && (!b904Setup) && (id != dduid)) {
503  LogTrace("CSCDDUUnpacker|CSCRawToDigi") << " CSC->FED/DDU mapping inconsistency!!! ";
504  LogTrace("CSCDCCUnpacker|CSCRawToDigi")
505  << "readout FED/DDU ID=" << id << " expected ID=" << dduid << ", skipping chamber " << layer
506  << " vme= " << vmecrate << " dmb= " << dmb;
507  continue;
508  }
509  }
510 
512  int nalct = cscData[iCSC].dmbHeader()->nalct();
513  bool goodALCT = false;
514  //if (nalct&&(cscData[iCSC].dataPresent>>6&0x1)==1) {
515  if (nalct && cscData[iCSC].alctHeader()) {
516  if (cscData[iCSC].alctHeader()->check()) {
517  goodALCT = true;
518  } else {
519  LogTrace("CSCDCCUnpacker|CSCRawToDigi") << "not storing ALCT digis; alct is bad or not present";
520  }
521  } else {
522  if (debug)
523  LogTrace("CSCDCCUnpacker|CSCRawToDigi") << "nALCT==0 !!!";
524  }
525 
527  if (goodALCT) {
528  std::vector<CSCALCTDigi> alctDigis = cscData[iCSC].alctHeader()->ALCTDigis();
529  if (SuppressZeroLCT) {
530  std::vector<CSCALCTDigi> alctDigis_0;
531  for (int unsigned i = 0; i < alctDigis.size(); ++i) {
532  if (alctDigis[i].isValid()) {
533  if (debug)
534  LogTrace("CSCDCCUnpacker|CSCRawToDigi") << alctDigis[i] << std::endl;
535  alctDigis_0.push_back(alctDigis[i]);
536  }
537  }
538  alctProduct->move(std::make_pair(alctDigis_0.begin(), alctDigis_0.end()), layer);
539  } else
540  alctProduct->move(std::make_pair(alctDigis.begin(), alctDigis.end()), layer);
541 
544  if (useCSCShowers_) {
545  std::vector<CSCShowerDigi> anodeShowerDigisALCT = cscData[iCSC].alctHeader()->alctShowerDigis();
546  anodeShowerProductALCT->move(std::make_pair(anodeShowerDigisALCT.begin(), anodeShowerDigisALCT.end()),
547  layer);
548  }
549  }
550 
552  int nclct = cscData[iCSC].dmbHeader()->nclct();
553  bool goodTMB = false;
554  // if (nclct&&(cscData[iCSC].dataPresent>>5&0x1)==1) {
555  if (nclct && cscData[iCSC].tmbData()) {
556  if (cscData[iCSC].tmbHeader()->check()) {
557  if (cscData[iCSC].comparatorData()->check())
558  goodTMB = true;
559  } else {
560  LogTrace("CSCDCCUnpacker|CSCRawToDigi") << "one of TMB checks failed! not storing TMB digis ";
561  }
562  } else {
563  if (debug)
564  LogTrace("CSCDCCUnpacker|CSCRawToDigi") << "nCLCT==0 !!!";
565  }
566 
568  if (goodTMB) {
569  std::vector<CSCCorrelatedLCTDigi> correlatedlctDigis =
570  cscData[iCSC].tmbHeader()->CorrelatedLCTDigis(layer.rawId());
571  if (SuppressZeroLCT) {
572  std::vector<CSCCorrelatedLCTDigi> correlatedlctDigis_0;
573  for (int unsigned i = 0; i < correlatedlctDigis.size(); ++i) {
574  if (correlatedlctDigis[i].isValid()) {
575  if (debug)
576  LogTrace("CSCDCCUnpacker|CSCRawToDigi") << correlatedlctDigis[i] << std::endl;
577  correlatedlctDigis_0.push_back(correlatedlctDigis[i]);
578  }
579  }
580  corrlctProduct->move(std::make_pair(correlatedlctDigis_0.begin(), correlatedlctDigis_0.end()), layer);
581  } else
582  corrlctProduct->move(std::make_pair(correlatedlctDigis.begin(), correlatedlctDigis.end()), layer);
583 
584  std::vector<CSCCLCTDigi> clctDigis = cscData[iCSC].tmbHeader()->CLCTDigis(layer.rawId());
585  if (SuppressZeroLCT) {
586  std::vector<CSCCLCTDigi> clctDigis_0;
587  for (int unsigned i = 0; i < clctDigis.size(); ++i) {
588  if (clctDigis[i].isValid()) {
589  if (debug)
590  LogTrace("CSCDCCUnpacker|CSCRawToDigi") << clctDigis[i] << std::endl;
591  clctDigis_0.push_back(clctDigis[i]);
592  }
593  }
594  clctProduct->move(std::make_pair(clctDigis_0.begin(), clctDigis_0.end()), layer);
595  } else
596  clctProduct->move(std::make_pair(clctDigis.begin(), clctDigis.end()), layer);
597 
599  if (useCSCShowers_) {
601  CSCShowerDigi lctShowerDigi = cscData[iCSC].tmbHeader()->showerDigi(layer.rawId());
602  if (lctShowerDigi.isValid()) {
603  std::vector<CSCShowerDigi> lctShowerDigis;
604  lctShowerDigis.push_back(lctShowerDigi);
605  lctShowerProduct->move(std::make_pair(lctShowerDigis.begin(), lctShowerDigis.end()), layer);
606  }
607 
609  CSCShowerDigi anodeShowerDigiOTMB = cscData[iCSC].tmbHeader()->anodeShowerDigi(layer.rawId());
610  if (anodeShowerDigiOTMB.isValid()) {
611  std::vector<CSCShowerDigi> anodeShowerDigis;
612  anodeShowerDigis.push_back(anodeShowerDigiOTMB);
613  anodeShowerProductOTMB->move(std::make_pair(anodeShowerDigis.begin(), anodeShowerDigis.end()), layer);
614  }
615 
617  CSCShowerDigi cathodeShowerDigiOTMB = cscData[iCSC].tmbHeader()->cathodeShowerDigi(layer.rawId());
618  if (cathodeShowerDigiOTMB.isValid()) {
619  std::vector<CSCShowerDigi> cathodeShowerDigis;
620  cathodeShowerDigis.push_back(cathodeShowerDigiOTMB);
621  cathodeShowerProductOTMB->move(std::make_pair(cathodeShowerDigis.begin(), cathodeShowerDigis.end()),
622  layer);
623  }
624  }
625 
627  if (cscData[iCSC].tmbData()->checkSize()) {
628  if (useRPCs_ && cscData[iCSC].tmbData()->hasRPC()) {
629  std::vector<CSCRPCDigi> rpcDigis = cscData[iCSC].tmbData()->rpcData()->digis();
630  rpcProduct->move(std::make_pair(rpcDigis.begin(), rpcDigis.end()), layer);
631  }
632 
634  if (useGEMs_ && cscData[iCSC].tmbData()->hasGEM()) {
635  for (int unsigned igem = 0; igem < (int unsigned)(cscData[iCSC].tmbData()->gemData()->numGEMs());
636  ++igem) {
637  int gem_chamber = layer.chamber();
638  int gem_region = (layer.endcap() == 1) ? 1 : -1;
639  // Loop over GEM layer eta/rolls
640  for (unsigned ieta = 0; ieta < 8; ieta++) {
641  // GE11 eta/roll collection addressing according to GEMDetID definition is 1-8 (eta 8 being closest to beampipe)
642  GEMDetId gemid(gem_region, layer.ring(), layer.station(), igem + 1, gem_chamber, ieta + 1);
643  // GE11 trigger data format reports eta/rolls in 0-7 range (eta 0 being closest to beampipe)
644  // mapping agreement is that real data eta needs to be reversed from 0-7 to 8-1 for GEMDetId collection convention
645  std::vector<GEMPadDigiCluster> gemDigis = cscData[iCSC].tmbData()->gemData()->etaDigis(
646  igem, 7 - ieta, cscData[iCSC].tmbHeader()->ALCTMatchTime());
647  if (!gemDigis.empty()) {
648  gemProduct->move(std::make_pair(gemDigis.begin(), gemDigis.end()), gemid);
649  }
650  }
651  }
652  }
653  } else
654  LogTrace("CSCDCCUnpacker|CSCRawToDigi") << " TMBData check size failed!";
655  }
656 
658  if (unpackStatusDigis) {
659  for (icfeb = 0; icfeb < CSCConstants::MAX_CFEBS_RUN2; ++icfeb)
660  {
661  if (cscData[iCSC].cfebData(icfeb) != nullptr)
662  cfebStatusProduct->insertDigi(layer, cscData[iCSC].cfebData(icfeb)->statusDigi());
663  }
665  dmbStatusProduct->insertDigi(
666  layer, CSCDMBStatusDigi(cscData[iCSC].dmbHeader()->data(), cscData[iCSC].dmbTrailer()->data()));
667  if (goodTMB)
668  tmbStatusProduct->insertDigi(
669  layer,
670  CSCTMBStatusDigi(cscData[iCSC].tmbHeader()->data(), cscData[iCSC].tmbData()->tmbTrailer()->data()));
671  if (goodALCT)
672  alctStatusProduct->insertDigi(
673  layer, CSCALCTStatusDigi(cscData[iCSC].alctHeader()->data(), cscData[iCSC].alctTrailer()->data()));
674  }
675 
677  for (int ilayer = CSCDetId::minLayerId(); ilayer <= CSCDetId::maxLayerId(); ++ilayer) {
679  // (You have to be kidding. Line 240 in whose universe?)
680 
681  // Allocate all ME1/1 wire digis to ring 1
682  layer = pcrate->detId(vmecrate, dmb, 0, ilayer);
683  {
684  std::vector<CSCWireDigi> wireDigis = cscData[iCSC].wireDigis(ilayer);
685  wireProduct->move(std::make_pair(wireDigis.begin(), wireDigis.end()), layer);
686  }
687 
688  for (icfeb = 0; icfeb < CSCConstants::MAX_CFEBS_RUN2; ++icfeb) {
689  layer = pcrate->detId(vmecrate, dmb, icfeb, ilayer);
690  if (cscData[iCSC].cfebData(icfeb) && cscData[iCSC].cfebData(icfeb)->check()) {
691  std::vector<CSCStripDigi> stripDigis;
692  cscData[iCSC].cfebData(icfeb)->digis(layer.rawId(), stripDigis);
693  stripProduct->move(std::make_pair(stripDigis.begin(), stripDigis.end()), layer);
694  }
695  }
696 
697  if (goodTMB && (cscData[iCSC].tmbHeader() != nullptr)) {
698  int nCFEBs = cscData[iCSC].tmbHeader()->NCFEBs();
699  for (icfeb = 0; icfeb < nCFEBs; ++icfeb) {
700  layer = pcrate->detId(vmecrate, dmb, icfeb, ilayer);
701  std::vector<CSCComparatorDigi> comparatorDigis =
702  cscData[iCSC].comparatorData()->comparatorDigis(layer.rawId(), icfeb);
703  // Set cfeb=0, so that ME1/a and ME1/b comparators go to
704  // ring 1.
705  layer = pcrate->detId(vmecrate, dmb, 0, ilayer);
706  comparatorProduct->move(std::make_pair(comparatorDigis.begin(), comparatorDigis.end()), layer);
707  }
708  } // end of loop over cfebs
709  } // end of loop over layers
710  } // end of loop over chambers
711  } // endof loop over DDUs
712  } // end of good event
713  else {
714  LogTrace("CSCDCCUnpacker|CSCRawToDigi") << "ERROR! Examiner rejected FED #" << id;
715  if (examiner) {
716  for (int i = 0; i < examiner->nERRORS; ++i) {
717  if (((examinerMask & examiner->errors()) >> i) & 0x1)
718  LogTrace("CSCDCCUnpacker|CSCRawToDigi") << examiner->errName(i);
719  }
720  if (debug) {
721  LogTrace("CSCDCCUnpacker|CSCRawToDigi")
722  << " Examiner errors:0x" << std::hex << examiner->errors() << " & 0x" << examinerMask << " = "
723  << (examiner->errors() & examinerMask);
724  }
725  }
726 
727  // dccStatusProduct->insertDigi(CSCDetId(1,1,1,1,1), CSCDCCStatusDigi(examiner->errors()));
728  // if(instantiateDQM) monitor->process(examiner, NULL);
729  }
730  if (examiner != nullptr)
731  delete examiner;
732  } // end of if fed has data
733  } // end of loop over DCCs
734  // put into the event
735  e.put(std::move(wireProduct), "MuonCSCWireDigi");
736  e.put(std::move(stripProduct), "MuonCSCStripDigi");
737  e.put(std::move(alctProduct), "MuonCSCALCTDigi");
738  e.put(std::move(clctProduct), "MuonCSCCLCTDigi");
739  e.put(std::move(comparatorProduct), "MuonCSCComparatorDigi");
740  e.put(std::move(corrlctProduct), "MuonCSCCorrelatedLCTDigi");
741 
742  if (useFormatStatus)
743  e.put(std::move(formatStatusProduct), "MuonCSCDCCFormatStatusDigi");
744 
745  if (unpackStatusDigis) {
746  e.put(std::move(cfebStatusProduct), "MuonCSCCFEBStatusDigi");
747  e.put(std::move(dmbStatusProduct), "MuonCSCDMBStatusDigi");
748  e.put(std::move(tmbStatusProduct), "MuonCSCTMBStatusDigi");
749  e.put(std::move(dduStatusProduct), "MuonCSCDDUStatusDigi");
750  e.put(std::move(dccStatusProduct), "MuonCSCDCCStatusDigi");
751  e.put(std::move(alctStatusProduct), "MuonCSCALCTStatusDigi");
752  }
753 
754  if (useRPCs_) {
755  e.put(std::move(rpcProduct), "MuonCSCRPCDigi");
756  }
757  if (useGEMs_) {
758  e.put(std::move(gemProduct), "MuonGEMPadDigiCluster");
759  }
760  if (useCSCShowers_) {
761  e.put(std::move(lctShowerProduct), "MuonCSCShowerDigi");
762  e.put(std::move(anodeShowerProductOTMB), "MuonCSCShowerDigiAnode");
763  e.put(std::move(cathodeShowerProductOTMB), "MuonCSCShowerDigiCathode");
764  e.put(std::move(anodeShowerProductALCT), "MuonCSCShowerDigiAnodeALCT");
765  }
766  if (printEventNumber)
767  LogTrace("CSCDCCUnpacker|CSCRawToDigi") << "[CSCDCCUnpacker]: " << numOfEvents << " events processed ";
768 }
769 
771 
773  int hl, int id, int run, int event, bool fedshort, bool fDump, short unsigned int* buf) const {
774  std::cout << std::endl << std::endl << std::endl;
775  std::cout << "Run: " << run << " Event: " << event << std::endl;
776  std::cout << std::endl << std::endl;
777  if (formatedEventDump)
778  std::cout << "FED-" << id << " "
779  << "(scroll down to see summary)" << std::endl;
780  else
781  std::cout << "Problem seems in FED-" << id << " "
782  << "(scroll down to see summary)" << std::endl;
783  std::cout << "********************************************************************************" << std::endl;
784  std::cout << hl << " words of data:" << std::endl;
785 
786  //================================================
787  // FED codes in DCC
788  std::vector<int> dcc_id;
789  int dcc_h1_id = 0;
790  // Current codes
791  for (int i = 750; i < 758; i++)
792  dcc_id.push_back(i);
793  // Codes for upgrade
794  for (int i = 830; i < 838; i++)
795  dcc_id.push_back(i);
796 
797  char dcc_common[] = "DCC-";
798 
799  //================================================
800  // DDU codes per FED
801  std::vector<int> ddu_id;
802  int ddu_h1_12_13 = 0;
803  for (int i = 1; i < 37; i++)
804  ddu_id.push_back(i);
805  // For DDU Headers and tarailers
806  char ddu_common[] = "DDU-";
807  char ddu_header1[] = "Header 1";
808  char ddu_header2[] = "Header 2";
809  char ddu_header3[] = "Header 3";
810  char ddu_trail1[] = "Trailer 1", ddu_trail2[] = "Trailer 2", ddu_trail3[] = "Trailer 3";
811  // For Header 2
812  char ddu_trailer1_bit[] = {'8', '0', '0', '0', 'f', 'f', 'f', 'f', '8', '0', '0', '0', '8', '0', '0', '0'};
813  char ddu_trailer3_bit[] = {'a'};
814  // Corrupted Trailers
815  char ddu_tr1_err_common[] = "Incomplet";
816  //====================================================
817 
818  //DMB
819  char dmb_common[] = "DMB", dmb_header1[] = "Header 1", dmb_header2[] = "Header 2";
820  char dmb_common_crate[] = "crate:", dmb_common_slot[] = "slot:";
821  char dmb_common_l1a[] = "L1A:";
822  char dmb_header1_bit[] = {'9', '9', '9', '9'};
823  char dmb_header2_bit[] = {'a', 'a', 'a', 'a'};
824  char dmb_tr1[] = "Trailer 1", dmb_tr2[] = "Trailer 2";
825  char dmb_tr1_bit[] = {'f', 'f', 'f', 'f'}, dmb_tr2_bit[] = {'e', 'e', 'e', 'e'};
826 
827  //=====================================================
828 
829  // ALCT
830  char alct_common[] = "ALCT", alct_header1[] = "Header 1", alct_header2[] = "Header 2";
831  char alct_common_bxn[] = "BXN:";
832  char alct_common_wcnt2[] = "| Actual word count:";
833  char alct_common_wcnt1[] = "Expected word count:";
834  char alct_header1_bit[] = {'d', 'd', 'd', 'd', 'b', '0', 'a'};
835  char alct_header2_bit[] = {'0', '0', '0', '0'};
836  char alct_tr1[] = "Trailer 1";
837 
838  //======================================================
839 
840  //TMB
841  char tmb_common[] = "TMB", tmb_header1[] = "Header", tmb_tr1[] = "Trailer";
842  char tmb_header1_bit[] = {'d', 'd', 'd', 'd', 'b', '0', 'c'};
843  char tmb_tr1_bit[] = {'d', 'd', 'd', 'd', 'e', '0', 'f'};
844 
845  //======================================================
846 
847  //CFEB
848  char cfeb_common[] = "CFEB", cfeb_tr1[] = "Trailer", cfeb_b[] = "B-word";
849  char cfeb_common_sample[] = "sample:";
850 
851  //======================================================
852 
853  //Auxiliary variables
854 
855  // Bufers
856  int word_lines = hl / 4;
857  char tempbuf[80];
858  char tempbuf1[130];
859  char tempbuf_short[17];
860  char sign1[] = " --->| ";
861 
862  // Counters
863  int word_numbering = 0;
864  int ddu_inst_i = 0, ddu_inst_n = 0, ddu_inst_l1a = 0;
865  int ddu_inst_bxn = 0;
866  int dmb_inst_crate = 0, dmb_inst_slot = 0, dmb_inst_l1a = 0;
867  int cfeb_sample = 0;
868  int alct_inst_l1a = 0;
869  int alct_inst_bxn = 0;
870  int alct_inst_wcnt1 = 0;
871  int alct_inst_wcnt2 = 0;
872  int alct_start = 0;
873  int alct_stop = 0;
874  int tmb_inst_l1a = 0;
875  int tmb_inst_wcnt1 = 0;
876  int tmb_inst_wcnt2 = 0;
877  int tmb_start = 0;
878  int tmb_stop = 0;
879  int dcc_h1_check = 0;
880 
881  //Flags
882  int w = 0;
883 
884  //Logic variables
885  const int sz1 = 5;
886  bool dcc_check = false;
887  bool ddu_h2_check[sz1] = {false};
888  bool ddu_h1_check = false;
889  bool dmb_h1_check[sz1] = {false};
890  bool dmb_h2_check[sz1] = {false};
891  bool ddu_h2_h1 = false;
892  bool ddu_tr1_check[sz1] = {false};
893  bool alct_h1_check[sz1] = {false};
894  bool alct_h2_check[sz1] = {false};
895  bool alct_tr1_check[sz1] = {false};
896  bool dmb_tr1_check[sz1] = {false};
897  bool dmb_tr2_check[sz1] = {false};
898  bool tmb_h1_check[sz1] = {false};
899  bool tmb_tr1_check[sz1] = {false};
900  bool cfeb_tr1_check[sz1] = {false};
901  bool cfeb_b_check[sz1] = {false};
902  bool ddu_tr1_bad_check[sz1] = {false};
903  bool extraction = fedshort;
904 
905  //Summary vectors
906  //DDU
907  std::vector<int> ddu_h1_coll;
908  std::vector<int> ddu_h1_n_coll;
909  std::vector<int> ddu_h2_coll;
910  std::vector<int> ddu_h3_coll;
911  std::vector<int> ddu_t1_coll;
912  std::vector<int> ddu_t2_coll;
913  std::vector<int> ddu_t3_coll;
914  std::vector<int> ddu_l1a_coll;
915  std::vector<int> ddu_bxn_coll;
916  //DMB
917  std::vector<int> dmb_h1_coll;
918  std::vector<int> dmb_h2_coll;
919  std::vector<int> dmb_t1_coll;
920  std::vector<int> dmb_t2_coll;
921  std::vector<int> dmb_crate_coll;
922  std::vector<int> dmb_slot_coll;
923  std::vector<int> dmb_l1a_coll;
924  //ALCT
925  std::vector<int> alct_h1_coll;
926  std::vector<int> alct_h2_coll;
927  std::vector<int> alct_t1_coll;
928  std::vector<int> alct_l1a_coll;
929  std::vector<int> alct_bxn_coll;
930  std::vector<int> alct_wcnt1_coll;
931  std::vector<int> alct_wcnt2_coll;
932  std::vector<int> alct_wcnt2_id_coll;
933  //TMB
934  std::vector<int> tmb_h1_coll;
935  std::vector<int> tmb_t1_coll;
936  std::vector<int> tmb_l1a_coll;
937  std::vector<int> tmb_wcnt1_coll;
938  std::vector<int> tmb_wcnt2_coll;
939  //CFEB
940  std::vector<int> cfeb_t1_coll;
941 
942  //========================================================
943 
944  // DCC Header and Ttrailer information
945  char dcc_header1[] = "DCC Header 1";
946  char dcc_header2[] = "DCC Header 2";
947  char dcc_trail1[] = "DCC Trailer 1", dcc_trail1_bit[] = {'e'};
948  char dcc_trail2[] = "DCC Trailer 2", dcc_trail2_bit[] = {'a'};
949  //=========================================================
950 
951  for (int i = 0; i < hl; i++) {
952  ++word_numbering;
953  for (int j = -1; j < 4; j++) {
954  sprintf(tempbuf_short,
955  "%04x%04x%04x%04x",
956  buf[i + 4 * (j - 1) + 3],
957  buf[i + 4 * (j - 1) + 2],
958  buf[i + 4 * (j - 1) + 1],
959  buf[i + 4 * (j - 1)]);
960 
961  // WARNING in 5_0_X for time being
962  ddu_h2_check[j] = ((buf[i + 4 * (j - 1) + 1] == 0x8000) && (buf[i + 4 * (j - 1) + 2] == 0x0001) &&
963  (buf[i + 4 * (j - 1) + 3] == 0x8000));
964 
965  ddu_tr1_check[j] = ((tempbuf_short[0] == ddu_trailer1_bit[0]) && (tempbuf_short[1] == ddu_trailer1_bit[1]) &&
966  (tempbuf_short[2] == ddu_trailer1_bit[2]) && (tempbuf_short[3] == ddu_trailer1_bit[3]) &&
967  (tempbuf_short[4] == ddu_trailer1_bit[4]) && (tempbuf_short[5] == ddu_trailer1_bit[5]) &&
968  (tempbuf_short[6] == ddu_trailer1_bit[6]) && (tempbuf_short[7] == ddu_trailer1_bit[7]) &&
969  (tempbuf_short[8] == ddu_trailer1_bit[8]) && (tempbuf_short[9] == ddu_trailer1_bit[9]) &&
970  (tempbuf_short[10] == ddu_trailer1_bit[10]) && (tempbuf_short[11] == ddu_trailer1_bit[11]) &&
971  (tempbuf_short[12] == ddu_trailer1_bit[12]) && (tempbuf_short[13] == ddu_trailer1_bit[13]) &&
972  (tempbuf_short[14] == ddu_trailer1_bit[14]) && (tempbuf_short[15] == ddu_trailer1_bit[15]));
973 
974  dmb_h1_check[j] = ((tempbuf_short[0] == dmb_header1_bit[0]) && (tempbuf_short[4] == dmb_header1_bit[1]) &&
975  (tempbuf_short[8] == dmb_header1_bit[2]) && (tempbuf_short[12] == dmb_header1_bit[3]));
976 
977  dmb_h2_check[j] = ((tempbuf_short[0] == dmb_header2_bit[0]) && (tempbuf_short[4] == dmb_header2_bit[1]) &&
978  (tempbuf_short[8] == dmb_header2_bit[2]) && (tempbuf_short[12] == dmb_header2_bit[3]));
979  alct_h1_check[j] = ((tempbuf_short[0] == alct_header1_bit[0]) && (tempbuf_short[4] == alct_header1_bit[1]) &&
980  (tempbuf_short[8] == alct_header1_bit[2]) && (tempbuf_short[12] == alct_header1_bit[3]) &&
981  (tempbuf_short[13] == alct_header1_bit[4]) && (tempbuf_short[14] == alct_header1_bit[5]) &&
982  (tempbuf_short[15] == alct_header1_bit[6]));
983  alct_h2_check[j] = (((tempbuf_short[0] == alct_header2_bit[0]) && (tempbuf_short[1] == alct_header2_bit[1]) &&
984  (tempbuf_short[2] == alct_header2_bit[2]) && (tempbuf_short[3] == alct_header2_bit[3])) ||
985  ((tempbuf_short[4] == alct_header2_bit[0]) && (tempbuf_short[5] == alct_header2_bit[1]) &&
986  (tempbuf_short[6] == alct_header2_bit[2]) && (tempbuf_short[7] == alct_header2_bit[3])) ||
987  ((tempbuf_short[8] == alct_header2_bit[0]) && (tempbuf_short[9] == alct_header2_bit[1]) &&
988  (tempbuf_short[10] == alct_header2_bit[2]) && (tempbuf_short[11] == alct_header2_bit[3])) ||
989  ((tempbuf_short[12] == alct_header2_bit[0]) && (tempbuf_short[13] == alct_header2_bit[1]) &&
990  (tempbuf_short[14] == alct_header2_bit[2]) && (tempbuf_short[15] == alct_header2_bit[3]))
991  //(tempbuf_short[4]==alct_header2_bit[4])&&(tempbuf_short[5]==alct_header2_bit[5])
992  );
993  // ALCT Trailers
994  alct_tr1_check[j] =
995  (((buf[i + 4 * (j - 1)] & 0xFFFF) == 0xDE0D) && ((buf[i + 4 * (j - 1) + 1] & 0xF800) == 0xD000) &&
996  ((buf[i + 4 * (j - 1) + 2] & 0xF800) == 0xD000) && ((buf[i + 4 * (j - 1) + 3] & 0xF000) == 0xD000));
997  // DMB Trailers
998  dmb_tr1_check[j] = ((tempbuf_short[0] == dmb_tr1_bit[0]) && (tempbuf_short[4] == dmb_tr1_bit[1]) &&
999  (tempbuf_short[8] == dmb_tr1_bit[2]) && (tempbuf_short[12] == dmb_tr1_bit[3]));
1000  dmb_tr2_check[j] = ((tempbuf_short[0] == dmb_tr2_bit[0]) && (tempbuf_short[4] == dmb_tr2_bit[1]) &&
1001  (tempbuf_short[8] == dmb_tr2_bit[2]) && (tempbuf_short[12] == dmb_tr2_bit[3]));
1002  // TMB
1003  tmb_h1_check[j] = ((tempbuf_short[0] == tmb_header1_bit[0]) && (tempbuf_short[4] == tmb_header1_bit[1]) &&
1004  (tempbuf_short[8] == tmb_header1_bit[2]) && (tempbuf_short[12] == tmb_header1_bit[3]) &&
1005  (tempbuf_short[13] == tmb_header1_bit[4]) && (tempbuf_short[14] == tmb_header1_bit[5]) &&
1006  (tempbuf_short[15] == tmb_header1_bit[6]));
1007  tmb_tr1_check[j] = ((tempbuf_short[0] == tmb_tr1_bit[0]) && (tempbuf_short[4] == tmb_tr1_bit[1]) &&
1008  (tempbuf_short[8] == tmb_tr1_bit[2]) && (tempbuf_short[12] == tmb_tr1_bit[3]) &&
1009  (tempbuf_short[13] == tmb_tr1_bit[4]) && (tempbuf_short[14] == tmb_tr1_bit[5]) &&
1010  (tempbuf_short[15] == tmb_tr1_bit[6]));
1011  // CFEB
1012  cfeb_tr1_check[j] =
1013  (((buf[i + 4 * (j - 1) + 1] & 0xF000) == 0x7000) && ((buf[i + 4 * (j - 1) + 2] & 0xF000) == 0x7000) &&
1014  ((buf[i + 4 * (j - 1) + 1] != 0x7FFF) || (buf[i + 4 * (j - 1) + 2] != 0x7FFF)) &&
1015  ((buf[i + 4 * (j - 1) + 3] == 0x7FFF) || ((buf[i + 4 * (j - 1) + 3] & buf[i + 4 * (j - 1)]) == 0x0 &&
1016  (buf[i + 4 * (j - 1) + 3] + buf[i + 4 * (j - 1)] == 0x7FFF))));
1017  cfeb_b_check[j] =
1018  (((buf[i + 4 * (j - 1) + 3] & 0xF000) == 0xB000) && ((buf[i + 4 * (j - 1) + 2] & 0xF000) == 0xB000) &&
1019  ((buf[i + 4 * (j - 1) + 1] & 0xF000) == 0xB000) && ((buf[i + 4 * (j - 1)] = 3 & 0xF000) == 0xB000));
1020  // DDU Trailers with errors
1021  ddu_tr1_bad_check[j] =
1022  ((tempbuf_short[0] != ddu_trailer1_bit[0]) &&
1023  //(tempbuf_short[1]!=ddu_trailer1_bit[1])&&(tempbuf_short[2]!=ddu_trailer1_bit[2])&&
1024  //(tempbuf_short[3]==ddu_trailer1_bit[3])&&
1025  (tempbuf_short[4] != ddu_trailer1_bit[4]) &&
1026  //(tempbuf_short[5]==ddu_trailer1_bit[5])&&
1027  //(tempbuf_short[6]==ddu_trailer1_bit[6])&&(tempbuf_short[7]==ddu_trailer1_bit[7])&&
1028  (tempbuf_short[8] == ddu_trailer1_bit[8]) && (tempbuf_short[9] == ddu_trailer1_bit[9]) &&
1029  (tempbuf_short[10] == ddu_trailer1_bit[10]) && (tempbuf_short[11] == ddu_trailer1_bit[11]) &&
1030  (tempbuf_short[12] == ddu_trailer1_bit[12]) && (tempbuf_short[13] == ddu_trailer1_bit[13]) &&
1031  (tempbuf_short[14] == ddu_trailer1_bit[14]) && (tempbuf_short[15] == ddu_trailer1_bit[15]));
1032  }
1033 
1034  // DDU Header 2 next to Header 1
1035  ddu_h2_h1 = ddu_h2_check[2];
1036 
1037  sprintf(tempbuf_short, "%04x%04x%04x%04x", buf[i + 3], buf[i + 2], buf[i + 1], buf[i]);
1038 
1039  // Looking for DDU Header 1
1040  ddu_h1_12_13 = (buf[i] >> 8);
1041  for (int kk = 0; kk < 36; kk++) {
1042  if (((buf[i + 3] & 0xF000) == 0x5000) && (ddu_h1_12_13 == ddu_id[kk]) && ddu_h2_h1) {
1043  ddu_h1_coll.push_back(word_numbering);
1044  ddu_h1_n_coll.push_back(ddu_id[kk]);
1045  ddu_inst_l1a = ((buf[i + 2] & 0xFFFF) + ((buf[i + 3] & 0x00FF) << 16));
1046  ddu_l1a_coll.push_back(ddu_inst_l1a);
1047  ddu_inst_bxn = (buf[i + 1] & 0xFFF0) >> 4;
1048  ddu_bxn_coll.push_back(ddu_inst_bxn);
1049  sprintf(tempbuf1,
1050  "%6i %04x %04x %04x %04x%s%s%i %s%s %s %i %s %i",
1051  word_numbering,
1052  buf[i + 3],
1053  buf[i + 2],
1054  buf[i + 1],
1055  buf[i],
1056  sign1,
1057  ddu_common,
1058  ddu_id[kk],
1059  ddu_header1,
1060  sign1,
1061  dmb_common_l1a,
1062  ddu_inst_l1a,
1063  alct_common_bxn,
1064  ddu_inst_bxn);
1065  std::cout << tempbuf1 << std::endl;
1066  w = 0;
1067  ddu_h1_check = true;
1068  cfeb_sample = 0;
1069  }
1070  }
1071 
1072  // Looking for DCC Header 1
1073  dcc_h1_id = (((buf[i + 1] << 12) & 0xF000) >> 4) + (buf[i] >> 8);
1074  for (int dcci = 0; dcci < 16; dcci++) {
1075  if ((dcc_id[dcci] == dcc_h1_id) && (((buf[i + 3] & 0xF000) == 0x5000) && (!ddu_h1_check))) {
1076  sprintf(tempbuf1,
1077  "%6i %04x %04x %04x %04x%s%s%i %s",
1078  word_numbering,
1079  buf[i + 3],
1080  buf[i + 2],
1081  buf[i + 1],
1082  buf[i],
1083  sign1,
1084  dcc_common,
1085  dcc_h1_id,
1086  dcc_header1);
1087  dcc_h1_check = word_numbering;
1088  w = 0;
1089  dcc_check = true;
1090  std::cout << tempbuf1 << std::endl;
1091  }
1092  }
1093 
1094  // Looking for DCC Header 2 and trailers
1095  if (((word_numbering - 1) == dcc_h1_check) && ((buf[i + 3] & 0xFF00) == 0xD900)) {
1096  sprintf(tempbuf1,
1097  "%6i %04x %04x %04x %04x%s%s",
1098  word_numbering,
1099  buf[i + 3],
1100  buf[i + 2],
1101  buf[i + 1],
1102  buf[i],
1103  sign1,
1104  dcc_header2);
1105  std::cout << tempbuf1 << std::endl;
1106  w = 0;
1107  } else if ((word_numbering == word_lines - 1) && (tempbuf_short[0] == dcc_trail1_bit[0])) {
1108  sprintf(tempbuf1,
1109  "%6i %04x %04x %04x %04x%s%s",
1110  word_numbering,
1111  buf[i + 3],
1112  buf[i + 2],
1113  buf[i + 1],
1114  buf[i],
1115  sign1,
1116  dcc_trail1);
1117  std::cout << tempbuf1 << std::endl;
1118  w = 0;
1119  } else if ((word_numbering == word_lines) && (tempbuf_short[0] == dcc_trail2_bit[0])) {
1120  sprintf(tempbuf1,
1121  "%6i %04x %04x %04x %04x%s%s",
1122  word_numbering,
1123  buf[i + 3],
1124  buf[i + 2],
1125  buf[i + 1],
1126  buf[i],
1127  sign1,
1128  dcc_trail2);
1129  std::cout << tempbuf1 << std::endl;
1130  w = 0;
1131  }
1132 
1133  // DDU Header 2
1134  else if (ddu_h2_check[1]) {
1135  ddu_inst_i = ddu_h1_n_coll.size(); //ddu_inst_n=ddu_h1_n_coll[0];
1136  if (ddu_inst_i > 0) {
1137  ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1138  }
1139  sprintf(tempbuf1,
1140  "%6i %04x %04x %04x %04x%s%s%i %s",
1141  word_numbering,
1142  buf[i + 3],
1143  buf[i + 2],
1144  buf[i + 1],
1145  buf[i],
1146  sign1,
1147  ddu_common,
1148  ddu_inst_n,
1149  ddu_header2);
1150  ddu_h2_coll.push_back(word_numbering);
1151  std::cout << tempbuf1 << std::endl;
1152  w = 0;
1153  }
1154 
1155  // DDU Header 3 (either between DDU Header 2 DMB Header or DDU Header 2 DDU Trailer1)
1156  else if ((ddu_h2_check[0] && dmb_h1_check[2]) || (ddu_h2_check[0] && ddu_tr1_check[2])) {
1157  ddu_inst_i = ddu_h1_n_coll.size();
1158  if (ddu_inst_i > 0) {
1159  ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1160  }
1161  sprintf(tempbuf1,
1162  "%6i %04x %04x %04x %04x%s%s%i %s",
1163  word_numbering,
1164  buf[i + 3],
1165  buf[i + 2],
1166  buf[i + 1],
1167  buf[i],
1168  sign1,
1169  ddu_common,
1170  ddu_inst_n,
1171  ddu_header3);
1172  ddu_h3_coll.push_back(word_numbering);
1173  std::cout << tempbuf1 << std::endl;
1174  w = 0;
1175  }
1176 
1177  // DMB Header 1,2
1178 
1179  else if (dmb_h1_check[1]) {
1180  dmb_inst_crate = 0;
1181  dmb_inst_slot = 0;
1182  dmb_inst_l1a = ((buf[i] & 0x0FFF) + ((buf[i + 1] & 0xFFF) << 12));
1183  dmb_l1a_coll.push_back(dmb_inst_l1a);
1184  if (dmb_h2_check[2]) {
1185  dmb_inst_crate = ((buf[i + 4 + 1] >> 4) & 0xFF);
1186  dmb_inst_slot = (buf[i + 4 + 1] & 0xF);
1187  dmb_crate_coll.push_back(dmb_inst_crate);
1188  dmb_slot_coll.push_back(dmb_inst_slot);
1189  }
1190  sprintf(tempbuf1,
1191  "%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i %s %i",
1192  word_numbering,
1193  buf[i + 3],
1194  buf[i + 2],
1195  buf[i + 1],
1196  buf[i],
1197  sign1,
1198  dmb_common,
1199  dmb_header1,
1200  sign1,
1201  dmb_common_crate,
1202  dmb_inst_crate,
1203  dmb_common_slot,
1204  dmb_inst_slot,
1205  dmb_common_l1a,
1206  dmb_inst_l1a);
1207  dmb_h1_coll.push_back(word_numbering);
1208  std::cout << tempbuf1 << std::endl;
1209  w = 0;
1210  }
1211 
1212  else if (dmb_h2_check[1]) {
1213  dmb_inst_crate = ((buf[i + 1] >> 4) & 0xFF);
1214  dmb_inst_slot = (buf[i + 1] & 0xF);
1215  dmb_h2_coll.push_back(word_numbering);
1216  if (dmb_h1_check[0])
1217  dmb_inst_l1a = ((buf[i - 4] & 0x0FFF) + ((buf[i - 4 + 1] & 0xFFF) << 12));
1218  sprintf(tempbuf1,
1219  "%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i %s %i",
1220  word_numbering,
1221  buf[i + 3],
1222  buf[i + 2],
1223  buf[i + 1],
1224  buf[i],
1225  sign1,
1226  dmb_common,
1227  dmb_header2,
1228  sign1,
1229  dmb_common_crate,
1230  dmb_inst_crate,
1231  dmb_common_slot,
1232  dmb_inst_slot,
1233  dmb_common_l1a,
1234  dmb_inst_l1a);
1235  std::cout << tempbuf1 << std::endl;
1236  w = 0;
1237  }
1238 
1239  //DDU Trailer 1
1240 
1241  else if (ddu_tr1_check[1]) {
1242  ddu_inst_i = ddu_h1_n_coll.size();
1243  if (ddu_inst_i > 0) {
1244  ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1245  }
1246  //ddu_inst_n=ddu_h1_n_coll[ddu_inst_i-1];
1247  sprintf(tempbuf1,
1248  "%6i %04x %04x %04x %04x%s%s%i %s",
1249  word_numbering,
1250  buf[i + 3],
1251  buf[i + 2],
1252  buf[i + 1],
1253  buf[i],
1254  sign1,
1255  ddu_common,
1256  ddu_inst_n,
1257  ddu_trail1);
1258  ddu_t1_coll.push_back(word_numbering);
1259  std::cout << tempbuf1 << std::endl;
1260  w = 0;
1261  }
1262 
1264  else if (alct_h1_check[1]) {
1265  alct_start = word_numbering;
1266  alct_inst_l1a = (buf[i + 2] & 0x0FFF);
1267  alct_l1a_coll.push_back(alct_inst_l1a);
1268  sprintf(tempbuf1,
1269  "%6i %04x %04x %04x %04x%s%s %s%s %s %i",
1270  word_numbering,
1271  buf[i + 3],
1272  buf[i + 2],
1273  buf[i + 1],
1274  buf[i],
1275  sign1,
1276  alct_common,
1277  alct_header1,
1278  sign1,
1279  dmb_common_l1a,
1280  alct_inst_l1a);
1281  alct_h1_coll.push_back(word_numbering);
1282  std::cout << tempbuf1 << std::endl;
1283  w = 0;
1284  }
1285 
1286  else if ((alct_h1_check[0]) && (alct_h2_check[2])) {
1287  alct_inst_bxn = (buf[i] & 0x0FFF);
1288  alct_bxn_coll.push_back(alct_inst_bxn);
1289  sprintf(tempbuf1,
1290  "%6i %04x %04x %04x %04x%s%s %s%s%s %i",
1291  word_numbering,
1292  buf[i + 3],
1293  buf[i + 2],
1294  buf[i + 1],
1295  buf[i],
1296  sign1,
1297  alct_common,
1298  alct_header2,
1299  sign1,
1300  alct_common_bxn,
1301  alct_inst_bxn);
1302  alct_h2_coll.push_back(word_numbering);
1303  std::cout << tempbuf1 << std::endl;
1304  w = 0;
1305  }
1306 
1307  //ALCT Trailer 1
1308  else if (alct_tr1_check[1]) {
1309  alct_stop = word_numbering;
1310  if ((alct_start != 0) && (alct_stop != 0) && (alct_stop > alct_start)) {
1311  alct_inst_wcnt2 = 4 * (alct_stop - alct_start + 1);
1312  alct_wcnt2_coll.push_back(alct_inst_wcnt2);
1313  alct_wcnt2_id_coll.push_back(alct_start);
1314  }
1315  alct_inst_wcnt1 = (buf[i + 3] & 0x7FF);
1316  alct_wcnt1_coll.push_back(alct_inst_wcnt1);
1317  sprintf(tempbuf1,
1318  "%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i",
1319  word_numbering,
1320  buf[i + 3],
1321  buf[i + 2],
1322  buf[i + 1],
1323  buf[i],
1324  sign1,
1325  alct_common,
1326  alct_tr1,
1327  sign1,
1328  alct_common_wcnt1,
1329  alct_inst_wcnt1,
1330  alct_common_wcnt2,
1331  alct_inst_wcnt2);
1332  alct_t1_coll.push_back(word_numbering);
1333  std::cout << tempbuf1 << std::endl;
1334  w = 0;
1335  alct_inst_wcnt2 = 0;
1336  }
1337 
1338  //DDU Trailer 3
1339 
1340  // else if ((ddu_tr1_check[-1])&&(tempbuf_short[0]==ddu_trailer3_bit[0])) { // !!! TO FIX: negative index
1341  else if ((ddu_h2_h1) && (tempbuf_short[0] == ddu_trailer3_bit[0])) {
1342  //&&(tempbuf_short[0]==ddu_trailer3_bit[0])){
1343  ddu_inst_i = ddu_h1_n_coll.size();
1344  if (ddu_inst_i > 0) {
1345  ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1346  }
1347  //ddu_inst_n=ddu_h1_n_coll[ddu_inst_i-1];
1348  sprintf(tempbuf1,
1349  "%6i %04x %04x %04x %04x%s%s%i %s",
1350  word_numbering,
1351  buf[i + 3],
1352  buf[i + 2],
1353  buf[i + 1],
1354  buf[i],
1355  sign1,
1356  ddu_common,
1357  ddu_inst_n,
1358  ddu_trail3);
1359  ddu_t3_coll.push_back(word_numbering);
1360  std::cout << tempbuf1 << std::endl;
1361  w = 0;
1362  }
1363  //DDU Trailer 2
1364  else if ((ddu_tr1_check[0]) && (tempbuf_short[0] != ddu_trailer3_bit[0])) {
1365  //&&(tempbuf_short[0]==ddu_trailer3_bit[0])){
1366  ddu_inst_i = ddu_h1_n_coll.size();
1367  if (ddu_inst_i > 0) {
1368  ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1369  }
1370  //ddu_inst_n=ddu_h1_n_coll[ddu_inst_i-1];
1371  sprintf(tempbuf1,
1372  "%6i %04x %04x %04x %04x%s%s%i %s",
1373  word_numbering,
1374  buf[i + 3],
1375  buf[i + 2],
1376  buf[i + 1],
1377  buf[i],
1378  sign1,
1379  ddu_common,
1380  ddu_inst_n,
1381  ddu_trail2);
1382  ddu_t2_coll.push_back(word_numbering);
1383  std::cout << tempbuf1 << std::endl;
1384  w = 0;
1385  }
1386 
1387  //DMB Trailer 1,2
1388  else if (dmb_tr1_check[1]) {
1389  sprintf(tempbuf1,
1390  "%6i %04x %04x %04x %04x%s%s %s",
1391  word_numbering,
1392  buf[i + 3],
1393  buf[i + 2],
1394  buf[i + 1],
1395  buf[i],
1396  sign1,
1397  dmb_common,
1398  dmb_tr1);
1399  dmb_t1_coll.push_back(word_numbering);
1400  std::cout << tempbuf1 << std::endl;
1401  w = 0;
1402  cfeb_sample = 0;
1403  }
1404 
1405  else if (dmb_tr2_check[1]) {
1406  sprintf(tempbuf1,
1407  "%6i %04x %04x %04x %04x%s%s %s",
1408  word_numbering,
1409  buf[i + 3],
1410  buf[i + 2],
1411  buf[i + 1],
1412  buf[i],
1413  sign1,
1414  dmb_common,
1415  dmb_tr2);
1416  dmb_t2_coll.push_back(word_numbering);
1417  std::cout << tempbuf1 << std::endl;
1418  w = 0;
1419  }
1420  // TMB
1421  else if (tmb_h1_check[1]) {
1422  tmb_start = word_numbering;
1423  tmb_inst_l1a = (buf[i + 2] & 0x000F);
1424  tmb_l1a_coll.push_back(tmb_inst_l1a);
1425  sprintf(tempbuf1,
1426  "%6i %04x %04x %04x %04x%s%s %s%s%s %i",
1427  word_numbering,
1428  buf[i + 3],
1429  buf[i + 2],
1430  buf[i + 1],
1431  buf[i],
1432  sign1,
1433  tmb_common,
1434  tmb_header1,
1435  sign1,
1436  dmb_common_l1a,
1437  tmb_inst_l1a);
1438  tmb_h1_coll.push_back(word_numbering);
1439  std::cout << tempbuf1 << std::endl;
1440  w = 0;
1441  } else if (tmb_tr1_check[1]) {
1442  tmb_stop = word_numbering;
1443  if ((tmb_start != 0) && (tmb_stop != 0) && (tmb_stop > tmb_start)) {
1444  tmb_inst_wcnt2 = 4 * (tmb_stop - tmb_start + 1);
1445  tmb_wcnt2_coll.push_back(tmb_inst_wcnt2);
1446  }
1447  tmb_inst_wcnt1 = (buf[i + 3] & 0x7FF);
1448  tmb_wcnt1_coll.push_back(tmb_inst_wcnt1);
1449  sprintf(tempbuf1,
1450  "%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i",
1451  word_numbering,
1452  buf[i + 3],
1453  buf[i + 2],
1454  buf[i + 1],
1455  buf[i],
1456  sign1,
1457  tmb_common,
1458  tmb_tr1,
1459  sign1,
1460  alct_common_wcnt1,
1461  tmb_inst_wcnt1,
1462  alct_common_wcnt2,
1463  tmb_inst_wcnt2);
1464  tmb_t1_coll.push_back(word_numbering);
1465  std::cout << tempbuf1 << std::endl;
1466  w = 0;
1467  tmb_inst_wcnt2 = 0;
1468  }
1469  // CFEB
1470  else if (cfeb_tr1_check[1]) {
1471  ++cfeb_sample;
1472  sprintf(tempbuf1,
1473  "%6i %04x %04x %04x %04x%s%s %s%s %s %i",
1474  word_numbering,
1475  buf[i + 3],
1476  buf[i + 2],
1477  buf[i + 1],
1478  buf[i],
1479  sign1,
1480  cfeb_common,
1481  cfeb_tr1,
1482  sign1,
1483  cfeb_common_sample,
1484  cfeb_sample);
1485  cfeb_t1_coll.push_back(word_numbering);
1486  std::cout << tempbuf1 << std::endl;
1487  w = 0;
1488  } else if (cfeb_b_check[1]) {
1489  sprintf(tempbuf1,
1490  "%6i %04x %04x %04x %04x%s%s %s",
1491  word_numbering,
1492  buf[i + 3],
1493  buf[i + 2],
1494  buf[i + 1],
1495  buf[i],
1496  sign1,
1497  cfeb_common,
1498  cfeb_b);
1499  std::cout << tempbuf1 << std::endl;
1500  w = 0;
1501  }
1502 
1503  //ERRORS ddu_tr1_bad_check
1504 
1505  else if (ddu_tr1_bad_check[1]) {
1506  ddu_inst_i = ddu_h1_n_coll.size();
1507  ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1508  sprintf(tempbuf1,
1509  "%6i %04x %04x %04x %04x%s%s%i %s %s",
1510  word_numbering,
1511  buf[i + 3],
1512  buf[i + 2],
1513  buf[i + 1],
1514  buf[i],
1515  sign1,
1516  ddu_common,
1517  ddu_inst_n,
1518  ddu_trail1,
1519  ddu_tr1_err_common);
1520  std::cout << tempbuf1 << std::endl;
1521  w = 0;
1522  }
1523 
1524  else if (extraction && (!ddu_h1_check) && (!dcc_check)) {
1525  if (w < 3) {
1526  sprintf(tempbuf, "%6i %04x %04x %04x %04x", word_numbering, buf[i + 3], buf[i + 2], buf[i + 1], buf[i]);
1527  std::cout << tempbuf << std::endl;
1528  w++;
1529  }
1530  if (w == 3) {
1531  std::cout << "..................................................." << std::endl;
1532  w++;
1533  }
1534  }
1535 
1536  else if ((!ddu_h1_check) && (!dcc_check)) {
1537  sprintf(tempbuf, "%6i %04x %04x %04x %04x", word_numbering, buf[i + 3], buf[i + 2], buf[i + 1], buf[i]);
1538  std::cout << tempbuf << std::endl;
1539  }
1540 
1541  i += 3;
1542  ddu_h1_check = false;
1543  dcc_check = false;
1544  }
1545  //char sign[30]; //WARNING 5_0_X
1546  std::cout << "********************************************************************************" << std::endl
1547  << std::endl;
1548  if (fedshort)
1549  std::cout << "For complete output turn off VisualFEDShort in muonCSCDigis configuration file." << std::endl;
1550  std::cout << "********************************************************************************" << std::endl
1551  << std::endl;
1552  std::cout << std::endl << std::endl;
1553  std::cout << " Summary " << std::endl;
1554  std::cout << std::endl << std::endl;
1555  std::cout << ddu_h1_coll.size() << " " << ddu_common << " " << ddu_header1 << " "
1556  << "found" << std::endl;
1557  /*
1558  std::cout << ddu_h1_coll.size() << " " << ddu_h1_n_coll.size() << " " << ddu_l1a_coll.size() <<
1559  " " << ddu_bxn_coll.size() << std::endl;
1560  */
1561  for (unsigned int k = 0; k < ddu_h1_coll.size(); ++k) {
1562  /*
1563  sprintf(sign,"%s%6i%5s %s%i %s %i %s %i","Line: ",
1564  ddu_h1_coll[k],sign1,ddu_common,ddu_h1_n_coll[k],dmb_common_l1a,ddu_l1a_coll[k],
1565  alct_common_bxn,ddu_bxn_coll[k]);
1566  */
1567  std::cout << "Line: "
1568  << " " << ddu_h1_coll[k] << " " << sign1 << " " << ddu_common << " " << ddu_h1_n_coll[k] << " "
1569  << dmb_common_l1a << " " << ddu_l1a_coll[k] << " " << alct_common_bxn << " " << ddu_bxn_coll[k]
1570  << std::endl;
1571  }
1572 
1573  std::cout << std::endl << std::endl;
1574  std::cout << "||||||||||||||||||||" << std::endl;
1575  std::cout << std::endl << std::endl;
1576  std::cout << ddu_h2_coll.size() << " " << ddu_common << " " << ddu_header2 << " "
1577  << "found" << std::endl;
1578  for (unsigned int k = 0; k < ddu_h2_coll.size(); ++k)
1579  std::cout << "Line: " << ddu_h2_coll[k] << std::endl;
1580  std::cout << std::endl << std::endl;
1581  std::cout << "||||||||||||||||||||" << std::endl;
1582  std::cout << std::endl << std::endl;
1583  std::cout << ddu_h3_coll.size() << " " << ddu_common << " " << ddu_header3 << " "
1584  << "found" << std::endl;
1585  for (unsigned int k = 0; k < ddu_h3_coll.size(); ++k)
1586  std::cout << "Line: " << ddu_h3_coll[k] << std::endl;
1587  std::cout << std::endl << std::endl;
1588  std::cout << "||||||||||||||||||||" << std::endl;
1589  std::cout << std::endl << std::endl;
1590  std::cout << ddu_t1_coll.size() << " " << ddu_common << " " << ddu_trail1 << " "
1591  << "found" << std::endl;
1592  for (unsigned int k = 0; k < ddu_t1_coll.size(); ++k)
1593  std::cout << "Line: " << ddu_t1_coll[k] << std::endl;
1594  std::cout << std::endl << std::endl;
1595  std::cout << "||||||||||||||||||||" << std::endl;
1596  std::cout << std::endl << std::endl;
1597  std::cout << ddu_t2_coll.size() << " " << ddu_common << " " << ddu_trail2 << " "
1598  << "found" << std::endl;
1599  for (unsigned int k = 0; k < ddu_t2_coll.size(); ++k)
1600  std::cout << "Line: " << ddu_t2_coll[k] << std::endl;
1601  std::cout << std::endl << std::endl;
1602  std::cout << "||||||||||||||||||||" << std::endl;
1603  std::cout << std::endl << std::endl;
1604  std::cout << ddu_t3_coll.size() << " " << ddu_common << " " << ddu_trail3 << " "
1605  << "found" << std::endl;
1606  for (unsigned int k = 0; k < ddu_t3_coll.size(); ++k)
1607  std::cout << "Line: " << ddu_t3_coll[k] << std::endl;
1608  std::cout << std::endl << std::endl;
1609  std::cout << "||||||||||||||||||||" << std::endl;
1610  std::cout << std::endl << std::endl;
1611  std::cout << dmb_h1_coll.size() << " " << dmb_common << " " << dmb_header1 << " "
1612  << "found" << std::endl;
1613 
1614  for (unsigned int k = 0; k < dmb_h1_coll.size(); ++k) {
1615  /*
1616  sprintf(sign,"%s%6i%5s %s %s %i %s %i %s %i","Line: ",
1617  dmb_h1_coll[k],sign1,dmb_common,dmb_common_crate,dmb_crate_coll[k],dmb_common_slot,
1618  dmb_slot_coll[k],dmb_common_l1a,dmb_l1a_coll[k]);
1619  */
1620  std::cout << "Line: "
1621  << " " << dmb_h1_coll[k] << " " << sign1 << dmb_common << " " << dmb_common_crate << " "
1622  << dmb_crate_coll[k] << " " << dmb_common_slot << " " << dmb_slot_coll[k] << " " << dmb_common_l1a << " "
1623  << dmb_l1a_coll[k] << std::endl;
1624  }
1625  std::cout << std::endl << std::endl;
1626  std::cout << "||||||||||||||||||||" << std::endl;
1627  std::cout << std::endl << std::endl;
1628  std::cout << dmb_h2_coll.size() << " " << dmb_common << " " << dmb_header2 << " "
1629  << "found" << std::endl;
1630  for (unsigned int k = 0; k < dmb_h2_coll.size(); ++k)
1631  std::cout << "Line: " << dmb_h2_coll[k] << std::endl;
1632  std::cout << std::endl << std::endl;
1633  std::cout << "||||||||||||||||||||" << std::endl;
1634  std::cout << std::endl << std::endl;
1635  std::cout << dmb_t1_coll.size() << " " << dmb_common << " " << dmb_tr1 << " "
1636  << "found" << std::endl;
1637  for (unsigned int k = 0; k < dmb_t1_coll.size(); ++k)
1638  std::cout << "Line: " << dmb_t1_coll[k] << std::endl;
1639  std::cout << std::endl << std::endl;
1640  std::cout << "||||||||||||||||||||" << std::endl;
1641  std::cout << std::endl << std::endl;
1642  std::cout << dmb_t2_coll.size() << " " << dmb_common << " " << dmb_tr2 << " "
1643  << "found" << std::endl;
1644  for (unsigned int k = 0; k < dmb_t2_coll.size(); ++k)
1645  std::cout << "Line: " << dmb_t2_coll[k] << std::endl;
1646  std::cout << std::endl << std::endl;
1647  std::cout << "||||||||||||||||||||" << std::endl;
1648  std::cout << std::endl << std::endl;
1649  std::cout << alct_h1_coll.size() << " " << alct_common << " " << alct_header1 << " "
1650  << "found" << std::endl;
1651  for (unsigned int k = 0; k < alct_h1_coll.size(); ++k) {
1652  /*
1653  sprintf(sign,"%s%6i%5s %s %s %i","Line: ",
1654  alct_h1_coll[k],sign1,alct_common,
1655  dmb_common_l1a,alct_l1a_coll[k]);
1656  std::cout << sign << std::endl;
1657  */
1658  std::cout << "Line: "
1659  << " " << alct_h1_coll[k] << " " << sign1 << " " << alct_common << " " << dmb_common_l1a << " "
1660  << alct_l1a_coll[k] << std::endl;
1661  }
1662 
1663  std::cout << std::endl << std::endl;
1664  std::cout << "||||||||||||||||||||" << std::endl;
1665  std::cout << std::endl << std::endl;
1666  std::cout << alct_h2_coll.size() << " " << alct_common << " " << alct_header2 << " "
1667  << "found" << std::endl;
1668  for (unsigned int k = 0; k < alct_h2_coll.size(); ++k) {
1669  /*
1670  sprintf(sign,"%s%6i%5s %s %s %i","Line: ",
1671  alct_h1_coll[k],sign1,alct_common,
1672  alct_common_bxn,alct_bxn_coll[k]);
1673  std::cout << sign << std::endl;
1674  */
1675  std::cout << "Line: "
1676  << " " << alct_h1_coll[k] << " " << sign1 << " " << alct_common << " " << alct_common_bxn << " "
1677  << alct_bxn_coll[k] << std::endl;
1678  }
1679 
1680  std::cout << std::endl << std::endl;
1681  std::cout << "||||||||||||||||||||" << std::endl;
1682  std::cout << std::endl << std::endl;
1683  std::cout << alct_t1_coll.size() << " " << alct_common << " " << alct_tr1 << " "
1684  << "found" << std::endl;
1685  for (unsigned int k = 0; k < alct_t1_coll.size(); ++k) {
1686  /*
1687  sprintf(sign,"%s%6i%5s %s %s %i %s %i","Line: ",
1688  alct_t1_coll[k],sign1,alct_common,
1689  alct_common_wcnt1,alct_wcnt1_coll[k],alct_common_wcnt2,alct_wcnt2_coll[k]);
1690  std::cout << sign << std::endl;
1691  */
1692  std::cout << "Line: "
1693  << " " << alct_t1_coll[k] << " " << sign1 << " " << alct_common << " " << alct_common_wcnt1 << " "
1694  << alct_wcnt1_coll[k] << " " << alct_common_wcnt2 << " ";
1695  if (!alct_wcnt2_coll.empty()) {
1696  std::cout << alct_wcnt2_coll[k] << std::endl;
1697  } else {
1698  std::cout << "Undefined (ALCT Header is not found) " << std::endl;
1699  }
1700  }
1701 
1702  std::cout << std::endl << std::endl;
1703  std::cout << "||||||||||||||||||||" << std::endl;
1704  std::cout << std::endl << std::endl;
1705  std::cout << tmb_h1_coll.size() << " " << tmb_common << " " << tmb_header1 << " "
1706  << "found" << std::endl;
1707  for (unsigned int k = 0; k < tmb_h1_coll.size(); ++k) {
1708  /*
1709  sprintf(sign,"%s%6i%5s %s %s %i","Line: ",
1710  tmb_h1_coll[k],sign1,tmb_common,
1711  dmb_common_l1a,tmb_l1a_coll[k]);
1712  std::cout << sign << std::endl;
1713  */
1714  std::cout << "Line: "
1715  << " " << tmb_h1_coll[k] << " " << sign1 << " " << tmb_common << " " << dmb_common_l1a << " "
1716  << tmb_l1a_coll[k] << std::endl;
1717  }
1718 
1719  std::cout << std::endl << std::endl;
1720  std::cout << "||||||||||||||||||||" << std::endl;
1721  std::cout << std::endl << std::endl;
1722  std::cout << tmb_t1_coll.size() << " " << tmb_common << " " << tmb_tr1 << " "
1723  << "found" << std::endl;
1724  for (unsigned int k = 0; k < tmb_t1_coll.size(); ++k) {
1725  /*
1726  sprintf(sign,"%s%6i%5s %s %s %i %s %i","Line: ",
1727  tmb_t1_coll[k],sign1,tmb_common,
1728  alct_common_wcnt1,tmb_wcnt1_coll[k],alct_common_wcnt2,tmb_wcnt2_coll[k]);
1729  std::cout << sign << std::endl;
1730  */
1731  std::cout << "Line: "
1732  << " " << tmb_t1_coll[k] << " " << sign1 << " " << tmb_common << " " << alct_common_wcnt1 << " "
1733  << tmb_wcnt1_coll[k] << " " << alct_common_wcnt2 << " " << tmb_wcnt2_coll[k] << std::endl;
1734  }
1735 
1736  std::cout << std::endl << std::endl;
1737  std::cout << "||||||||||||||||||||" << std::endl;
1738  std::cout << std::endl << std::endl;
1739  std::cout << cfeb_t1_coll.size() << " " << cfeb_common << " " << cfeb_tr1 << " "
1740  << "found" << std::endl;
1741  for (unsigned int k = 0; k < cfeb_t1_coll.size(); ++k)
1742  std::cout << "Line: " << cfeb_t1_coll[k] << std::endl;
1743  std::cout << "********************************************************************************" << std::endl;
1744 }
1745 
01/20/05 A.Tumanov
std::map< CSCIdType, ExaminerStatusType > statusDetailed(void) const
void crcCFEB(bool enable)
bool SuppressZeroLCT
Suppress zeros LCTs.
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
edm::ESGetToken< CSCChamberMap, CSCChamberMapRcd > cscmapToken
static void setDebug(bool value)
void modeDDU(bool enable)
T w() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool isValid() const
data
const uint16_t nERRORS
CSCMonitorInterface * monitor
ExaminerMaskType getMask() const
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:48
bool useRPCs_
option to unpack RPC data
void crcALCT(bool enable)
bool visualFEDInspect
Visualization of raw data.
Definition: Electron.h:6
#define LogTrace(id)
Definition: CSCMap.h:8
static void setDebug(const bool value)
virtual void process(CSCDCCExaminer *examiner, CSCDCCEventData *dccData)=0
edm::ESGetToken< CSCCrateMap, CSCCrateMapRcd > crateToken
static void setDebug(const bool value)
Definition: CSCTMBHeader.h:118
T const * product() const
Definition: ESHandle.h:86
static void setDebug(const bool value)
Definition: CSCTMBData.h:35
static void setErrorMask(unsigned int value)
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) ...
~CSCDCCUnpacker() override
Destructor.
static void setDebug(bool value)
std::map< CSCIdType, ExaminerStatusType > payloadDetailed(void) const
void crcTMB(bool enable)
const char * errName(int num) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool useCSCShowers_
option to unpack CSC shower data
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void setComment(std::string const &value)
edm::EDGetTokenT< FEDRawDataCollection > i_token
Token for consumes interface & access to data.
unsigned int errorMask
static int minLayerId()
Definition: CSCDetId.h:242
CSCDetId detId(int vme, int dmb, int cfeb, int layer=0) const
Definition: CSCCrateMap.cc:9
unsigned int examinerMask
std::map< CSCIdType, ExaminerStatusType > errorsDetailed(void) const
static void setDebug(bool value)
to access data by via status digis
Definition: CSCALCTHeader.h:31
bool useSelectiveUnpacking
bool useGEMs_
option to unpack GEM cluster data
void add(std::string const &label, ParameterSetDescription const &psetDescription)
int ddu(const CSCDetId &) const
ddu id for given DetId
int32_t check(const uint16_t *&buffer, int32_t length)
CSC Format Status Object.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
ExaminerStatusType errors(void) const
CSCDCCUnpacker(const edm::ParameterSet &pset)
Constructor.
std::map< DDUIdType, ExaminerStatusType > errorsDetailedDDU(void) const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
static int maxLayerId()
Definition: CSCDetId.h:243
void setMask(ExaminerMaskType mask)
static void setDebug(const bool value)
Definition: CSCEventData.h:42
def move(src, dest)
Definition: eostools.py:511
static void setDebug(bool debugValue)
Definition: CSCRPCData.h:26
void produce(edm::Event &e, const edm::EventSetup &c) override
Produce digis out of raw data.
Definition: event.py:1
A container for a generic type of digis indexed by some index, implemented with a map<IndexType...