ATLAS Offline Software
TileTBDump.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //*****************************************************************************
6 // Filename : TileTBDump.cxx
7 // Author : Alexander Solodkov
8 // Created : May, 2004
9 //
10 // DESCRIPTION:
11 // Implement the algorithm to dump TB ByteStream file
12 //
13 // HISTORY:
14 //
15 // BUGS:
16 //
17 //*****************************************************************************
18 
19 //Gaudi Includes
20 
21 //Atlas include
22 #include "eformat/FullEventFragment.h"
25 
26 //TileCalo include
30 #include "TileTBRec/TileTBDump.h"
31 #include "TileByteStream/TileOFC.h"
35 
36 #include "boost/io/ios_state.hpp"
37 #include "boost/date_time/local_time/local_time.hpp"
38 #include "boost/date_time/posix_time/posix_time.hpp"
39 
40 #include <iostream>
41 #include <sstream>
42 #include <iomanip>
43 #include <bitset>
44 #include <string>
45 #include <ctime>
46 #include <arpa/inet.h>
47 
48 std::string cern_local_time(time_t unix_time)
49 {
50  using namespace boost::local_time;
51  using namespace boost::posix_time;
52 
53  char dateTime[32];
54 
55 /*
56  // just an example how to read file with time zones
57  tz_database tz_db;
58  try {
59  tz_db.load_from_file("../data/date_time_zonespec.csv");
60  time_zone_ptr gva_tz = tz_db.time_zone_from_region("Europe/Zurich");
61  }catch(data_not_accessible dna) {
62  std::cerr << "Error with time zone data file: " << dna.what() << std::endl;
63  //exit(EXIT_FAILURE);
64  }catch(bad_field_count bfc) {
65  std::cerr << "Error with time zone data file: " << bfc.what() << std::endl;
66  //exit(EXIT_FAILURE);
67  }
68 */
69  //"Europe/Zurich","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
70  static const time_zone_ptr gva_tz(new posix_time_zone((std::string)"CET+01CEST01:00:00,M3.5.0/02:00:00,M10.5.0/03:00:00"));
71  local_date_time gva_time(from_time_t(unix_time),gva_tz);
72 
73  //std::ostringstream otime;
74  //otime << gva_time; // time in the format YYYY-MMM-DD HH:MM:SS TZ
75  //strncpy(dateTime,otime.str().c_str(),31);
76 
77  //time_duration hms(gva_time.time_of_day()); - will give time of the day in GMT
78  //int HHMMSS = hms.hours()*10000+hms.minutes()*100+hms.seconds();
79 
80  struct tm gva_tm(to_tm(gva_time));
81  strftime(dateTime, 32, "%Y-%b-%d %H:%M:%S %Z", &gva_tm);
82  //HHMMSS = gva_tm.tm_hour*10000+gva_tm.tm_min*100+gva_tm.tm_sec;
83 
84  // the code below is only valid when running at CERN (in Geneva time zone)
85  //struct tm *time = localtime((time_t*)(&m_evTime));
86  //HHMMSS = time->tm_hour*10000+time->tm_min*100+time->tm_sec;
87  //strftime(dateTime, 32, "%Y-%m-%d %H:%M:%S %Z", time);
88 
89  return dateTime;
90 }
91 
92 // Constructor & deconstructor
93 
102 
106 TileTBDump::TileTBDump(const std::string& name, ISvcLocator* pSvcLocator)
107  : AthAlgorithm(name, pSvcLocator)
108  , m_RobSvc("ROBDataProviderSvc", name)
109  , m_cabling(nullptr)
110  , m_runPeriod(0)
111  , m_tileToolTiming("TileCondToolTiming")
112  , m_tileCondToolOfcCool("TileCondToolOfcCool")
113  , m_tileToolEmscale("TileCondToolEmscale")
114 {
115  m_drawerList.resize(9); m_drawerType.resize(9);
116  m_drawerList[0] = "0x200"; m_drawerType[0] = 2; // barrel neg
117  m_drawerList[1] = "0x201"; m_drawerType[1] = 2; // barrel neg
118  m_drawerList[2] = "0x202"; m_drawerType[2] = 2; // barrel neg
119  m_drawerList[3] = "0x100"; m_drawerType[3] = 1; // barrel pos
120  m_drawerList[4] = "0x101"; m_drawerType[4] = 1; // barrel pos
121  m_drawerList[5] = "0x102"; m_drawerType[5] = 1; // barrel pos
122  m_drawerList[6] = "0x400"; m_drawerType[6] = 4; // ext. barrel neg
123  m_drawerList[7] = "0x401"; m_drawerType[7] = 4; // ext. barrel neg
124  m_drawerList[8] = "0x402"; m_drawerType[8] = 4; // ext. barrel neg
125 
126  declareProperty("drawerList", m_drawerList);
127  declareProperty("drawerType", m_drawerType);
128 
129  declareProperty("dumpHeader", m_dumpHeader = true);
130  declareProperty("dumpData", m_dumpData = true);
131  declareProperty("dumpStatus", m_dumpStatus = true);
132  declareProperty("dumpOnce", m_dumpOnce = false);
133  declareProperty("dumpUnknown", m_dumpUnknown = false);
134  declareProperty("showUnknown", m_showUnknown = true);
135 
136  declareProperty("TileCondToolTiming", m_tileToolTiming);
137  declareProperty("TileCondToolOfcCool", m_tileCondToolOfcCool, "TileCondToolOfcCool");
138  declareProperty("TileCondToolEmscale", m_tileToolEmscale);
139 
140  declareProperty("bc_time_seconds", m_bc_time_seconds = -1);
141  declareProperty("bc_time_nanoseconds", m_bc_time_nanoseconds = -1);
142  declareProperty("global_id", m_global_id = -1);
143  declareProperty("run_type", m_run_type = -1);
144  declareProperty("run_no", m_run_no = -1);
145  declareProperty("lumi_block", m_lumi_block = -1);
146  declareProperty("lvl1_id", m_lvl1_id = -1);
147  declareProperty("bc_id", m_bc_id = -1);
148  declareProperty("lvl1_trigger_type", m_lvl1_trigger_type = -1);
149  declareProperty("nlvl1_trigger_info", m_nlvl1_trigger_info = -1);
150 
151  m_v3Format = true;
152  m_frag5found = false;
153  m_sizeOverhead = 3;
154  m_unit = -1;
155  m_digi_mode = 0;
156 
157 }
158 
159 
161 }
162 
163 // Alg standard interface function
165 
166  memset(m_statFrag5, 0, sizeof(m_statFrag5));
167 
168  CHECK( m_RobSvc.retrieve() );
169 
170  //=== get TileCondToolOfcCool
171  CHECK( m_tileCondToolOfcCool.retrieve() );
172 
173  //=== get TileToolTiming
174  CHECK( m_tileToolTiming.retrieve() );
175 
176  //=== get TileCondToolEmscale
177  CHECK( m_tileToolEmscale.retrieve() );
178 
179  // find TileCablingService
182 
183  int size = m_drawerList.size();
184  for (int dr = 0; dr < size; ++dr) {
185  unsigned int frag = strtol(m_drawerList[dr].data(), NULL, 0);
186  m_drawerMap[frag] = m_drawerType[dr];
187  }
188 
189  ATH_MSG_INFO( "initialization completed" );
190 
191  return StatusCode::SUCCESS;
192 }
193 
194 
196 
197  std::string unitName[5]={"ADC counts","pCb","CspCb","MeV", "unknown"};
198 
199  if (m_unit < 0) {
200  std::cout << std::endl << "DSP reco fragments not found" << std::endl;
201  m_unit = 4;
202  }
203  std::cout << std::endl << "Units in DSP reco fragments are " << unitName[std::min(m_unit,4)] << std::endl;
204 
205  if (m_frag5found) {
206  std::cout << std::endl << "StatFrag5[40..129]";
207  for (int i = 40; i < 130; i++) {
208  if (i % 10 == 0) std::cout << std::endl << " [" << std::setw(3) << i << "] : ";
209  std::cout << std::setw(9) << m_statFrag5[i];
210  }
211  std::cout << std::endl;
212  }
213 
214  ATH_MSG_INFO( "finalize() successfully" );
215 
216  return StatusCode::SUCCESS;
217 }
218 
220 
221  static std::atomic<bool> notFirst = false;
222 
223  ATH_MSG_DEBUG( "execute()" );
224 
225  const EventContext &ctx = Gaudi::Hive::currentContext();
226 
227  // take full event
228  const eformat::FullEventFragment<const uint32_t*> * event = m_RobSvc->getEvent(ctx);
229 
230  if (m_dumpOnce) {
231  if (m_lvl1_trigger_type<0) {
232  // dump once all Level1 trigger types found in data
233  int lvl1tt = event->lvl1_trigger_type();
235  return StatusCode::SUCCESS;
236  } else {
237  m_all_lvl1_trigger_types.push_back(lvl1tt);
238  notFirst = false;
239  }
240  }
241  }
242 
243  if (m_bc_time_seconds >=0 && m_bc_time_seconds != (int32_t)event->bc_time_seconds()) return StatusCode::SUCCESS;
244  if (m_bc_time_nanoseconds >=0 && m_bc_time_nanoseconds != (int32_t)event->bc_time_nanoseconds()) return StatusCode::SUCCESS;
245  if (m_global_id >=0 && m_global_id != (int32_t)event->global_id()) return StatusCode::SUCCESS;
246  if (m_run_type >=0 && m_run_type != (int32_t)event->run_type()) return StatusCode::SUCCESS;
247  if (m_run_no >=0 && m_run_no != (int32_t)event->run_no()) return StatusCode::SUCCESS;
248  if (m_lumi_block >=0 && m_lumi_block != (int32_t)event->lumi_block()) return StatusCode::SUCCESS;
249  if (m_lvl1_id >=0 && m_lvl1_id != (int32_t)event->lvl1_id()) return StatusCode::SUCCESS;
250  if (m_bc_id >=0 && m_bc_id != (int32_t)event->bc_id()) return StatusCode::SUCCESS;
251  if (m_lvl1_trigger_type >=0 && m_lvl1_trigger_type != (int32_t)event->lvl1_trigger_type()) return StatusCode::SUCCESS;
252  if (m_nlvl1_trigger_info >=0 && m_nlvl1_trigger_info != (int32_t)event->nlvl1_trigger_info()) return StatusCode::SUCCESS;
253 
254  if (m_dumpOnce && notFirst) return StatusCode::SUCCESS;
255  notFirst = true;
256 
257  int verbosity = 0;
258  if ( msgLvl(MSG::NIL) ) {
259  verbosity = 7;
260  } else if ( msgLvl(MSG::VERBOSE) ) {
261  verbosity = 2;
262  } else if ( msgLvl(MSG::DEBUG) ) {
263  verbosity = 1;
264  }
265 
266  boost::io::ios_base_all_saver coutsave(std::cout);
267  std::cout << std::fixed;
268 
269  std::cout << "============================" << std::endl;
270  std::cout << "Event time (sec): " << (uint32_t)event->bc_time_seconds() << std::endl;
271  std::cout << "Event time (ns): " << (uint32_t)event->bc_time_nanoseconds() << std::endl;
272  std::cout << "Global ID: " << (uint32_t)event->global_id() << std::endl;
273  std::cout << "Run Type: " << (uint32_t)event->run_type() << std::endl;
274  std::cout << "Run Number: " << (uint32_t)event->run_no() << std::endl;
275  std::cout << "Lumi Block: " << (uint32_t)event->lumi_block() << std::endl;
276  std::cout << "Level1 ID: " << (uint32_t)event->lvl1_id() << std::endl;
277  std::cout << "BCID: " << (uint32_t)event->bc_id() << std::endl;
278  std::cout << "Level1 trig type: " << (uint32_t)event->lvl1_trigger_type() << std::endl;
279  std::cout << "Level1 Nwords: " << (uint32_t)event->nlvl1_trigger_info() << std::endl;
280  std::cout << "============================" << std::endl;
281 
282  try {
283  event->check_tree();
284  } catch (...) {
285  std::cout << " Invalid event, some ROB fragments might be truncated" << std::endl << std::endl;
286  }
287 
288  /*
289  unpacking the event down to ROD fragments
290  */
291 
292  uint32_t nrob = event->nchildren();
293 
294  for (size_t irob = 0; irob < nrob; ++irob) {
295  const uint32_t* fprob;
296  event->child(fprob, irob);
297  const eformat::ROBFragment<const uint32_t*> robf(fprob);
298 
299  //
300  // get info on ROD
301  //
302  unsigned int version = robf.rod_version();
303  unsigned int source_id = robf.rod_source_id();
304  eformat::helper::SourceIdentifier id = eformat::helper::SourceIdentifier(source_id);
305  unsigned int subdet_id = id.subdetector_id();
306  unsigned int module_id = id.module_id();
307  int robsourceid = robf.source_id();
308 
309  bool known = m_dumpUnknown || subdet_id == 0x70 // COMMON BEAM ROD in CTB2004
310  || (subdet_id >= 0x50 && subdet_id < 0x60) // TileCal IDs
311  || (robsourceid >= 0x510000 && robsourceid < 0x550000); // TileCal ROBs
312 
313  if (!(known || m_showUnknown)) {
314  continue;
315  }
316 
317  std::cout << " ROB frag ID " << std::hex << "0x" << robf.source_id() << std::dec
318  << " size " << robf.fragment_size_word() << std::endl;
319 
320  // Here we should unpack the fragment.
321  std::cout << " ROD frag ID " << std::hex << "0x" << robf.rod_source_id() << std::dec
322  << " size " << robf.rod_fragment_size_word() << std::endl;
323 
324  if (!known) {
325  std::cout << std::endl;
326  continue;
327  }
328 
329  if ( m_dumpHeader ) {
330 
331  std::cout << " Format Vers. " << std::hex << "0x" << robf.rod_version() << std::dec << std::endl;
332  std::cout << " Source ID " << std::hex << "0x" << robf.rod_source_id() << std::dec << std::endl;
333  std::cout << " Source ID str " << eformat::helper::SourceIdentifier(robf.source_id()).human().c_str() << std::endl;
334  std::cout << " SubDetect ID " << std::hex << "0x" << subdet_id << std::dec << std::endl;
335  std::cout << " Module ID " << std::hex << "0x" << module_id << std::dec << std::endl;
336  std::cout << " Run number " << (int) robf.rod_run_no() << std::endl;
337  std::cout << " Level1 ID " << robf.rod_lvl1_id() << std::endl;
338  std::cout << " BCID " << robf.rod_bc_id() << std::endl;
339  std::cout << " Lvl1 TrigType " << robf.rod_lvl1_trigger_type() << std::endl;
340  std::cout << " Event Type " << robf.rod_detev_type() << std::endl;
341  std::cout << " Fragment size " << robf.rod_fragment_size_word() << std::endl;
342  std::cout << " Header size " << robf.rod_header_size_word() << std::endl;
343  std::cout << " Trailer size " << robf.rod_trailer_size_word() << std::endl;
344  std::cout << " N data " << robf.rod_ndata() << std::endl;
345  std::cout << " N status " << robf.rod_nstatus() << std::endl;
346  std::cout << " Status pos " << robf.rod_status_position() << std::endl;
347  }
348 
349  unsigned int max_allowed_size = robf.rod_fragment_size_word();
350  unsigned int delta = robf.rod_header_size_word() + robf.rod_trailer_size_word();
351  if (max_allowed_size >= delta) {
352  max_allowed_size -= delta;
353  } else {
354  std::cout << " Problem with ROD data: total length " << max_allowed_size
355  << " is less than " << delta << " - size of header+trailer" << std::endl;
356  max_allowed_size = 0;
357  }
358 
359  unsigned int size = robf.rod_nstatus();
360  bool bad_status = (robf.rod_status_position()==0 && size > max_allowed_size);
361 
362  if (robf.rod_status_position() > 1
363  || robf.rod_ndata() > max_allowed_size
364  || size > max_allowed_size - robf.rod_ndata()
365  || bad_status ) {
366  std::cout << " Problem with status words - assuming no status words" << std::endl;
367 
368  } else if (m_dumpStatus) {
369 
370  if (size > 0) {
371  const uint32_t * stat;
372  robf.rod_status(stat);
373  std::cout.unsetf(std::ios::fixed);
374  for (unsigned int ind = 0; ind < size; ++ind) {
375  std::cout << " Status[" << ind << "] = " << stat[ind] << "\t\t" << stat[ind] / 1000000. - 1. << std::endl;
376  }
377  std::cout << std::fixed;
378  } else {
379  std::cout << " No status words" << std::endl;
380  }
381  }
382 
383  if ( m_dumpData ) {
384 
385  unsigned int size = robf.rod_ndata();
386  if (size > max_allowed_size) {
387  if (size - robf.rod_trailer_size_word() < max_allowed_size) {
388  std::cout<<" Problem with data size - assuming that trailer size is " << robf.rod_trailer_size_word()-(size-max_allowed_size)
389  <<" words instead of " << robf.rod_trailer_size_word() << " and data size is " << size << " words " << std::endl;
390  max_allowed_size = size;
391  } else if (size - robf.rod_trailer_size_word() == max_allowed_size) {
392  std::cout<<" Problem with data size - assuming that trailer is absent "
393  << " ROD size " << robf.rod_fragment_size_word()
394  << " header size " << robf.rod_header_size_word()
395  << " data size " << size << std::endl;
396  max_allowed_size = size;
397  } else {
398  max_allowed_size += robf.rod_trailer_size_word();
399  size = max_allowed_size;
400  std::cout<<" Problem with data size - assuming " << size << " words and no trailer at all"<<std::endl;
401  }
402  std::cout << std::endl << "Dump of whole ROB fragment 0x" << std::hex << robf.rod_source_id() << std::dec
403  << " (" << robf.rod_fragment_size_word()+robf.header_size_word() << " words)" << std::endl;
404  dump_data(fprob, robf.rod_fragment_size_word()+robf.header_size_word(), version, verbosity);
405  }
406 
407  if ( size > 0 ) {
408 
409  const uint32_t * data;
410  if (bad_status) {
411  robf.rod_status(data);
412  } else {
413  robf.rod_data(data);
414  }
415 
416  if (subdet_id == 0) {
417  std::cout<<" Problem with ROD frag - SubDetector ID is 0" <<std::endl;
418  if (source_id >= 0x5100 && source_id < 0x5500 && robsourceid >= 0x510000 && robsourceid < 0x550000) { // buggy ROD fragment
419  std::cout<<" Looks like ROD frag is in old format, ROD Source ID is 0x" << std::hex << source_id
420  <<" assuming that ROD Source ID is 0x" << robsourceid << std::dec << std::endl;
421  source_id = robsourceid;
422  subdet_id = robsourceid>>16;
424  }
425  }
426  if ((subdet_id >= 0x50 && subdet_id < 0x60) || // TileCal IDs
427  subdet_id == 0x63 || // wrong id in first testbeam test runs
428  subdet_id == 0x70) { // COMMON BEAM ROD in CTB2004
429  dump_digi(subdet_id,data, size, version, verbosity, source_id, ctx);
430  } else if ( m_dumpUnknown ) {
431  if (!(subdet_id == 0 || size < 13
432  || data[5] == 0x12345678 || data[size-1] == 0x87654321
433  || data[5] == 0x34127856 || data[size-1] == 0x65872143)) {
435  }
436  if (subdet_id == 0) { // try also to find normal fragments
437  dump_digi(subdet_id,data, size, version, verbosity, source_id, ctx);
438  }
439  }
440  } else {
441  std::cout << std::endl << std::hex << "NO DATA in ROB fragment 0x" << robf.rod_source_id() << std::dec << std::endl << std::endl;
442  }
443  std::cout << std::endl;
444  }
445  }
446 
447  if (msgLvl(MSG::DEBUG)) {
448  /* end of unpacking */
449  msg(MSG::DEBUG) << "Found " << nrob << " ROB fragments, " << endmsg;
450 
451  // Execution completed.
452  msg(MSG::DEBUG) << "execute() completed successfully" << endmsg;
453  }
454 
455  return StatusCode::SUCCESS;
456 }
457 
458 //stream manipulators
459 std::ostream &setup0x4 (std::ostream &stream){
460  stream << "0x" << std::setw(4);
461  return stream;
462 }
463 std::ostream &setupMod (std::ostream &stream){
464  stream << "\n mod" << std::setw(2);
465  return stream;
466 }
467 std::ostream &setup0 (std::ostream &stream){
468  stream << std::hex << std::setfill('0') << std::setw(8);
469  return stream;
470 }
471 std::ostream &setupDec (std::ostream &stream){
472  stream << std::setfill(' ') << std::dec;
473  return stream;
474 }
475 std::ostream &setupPr1 (std::ostream &stream){
476  stream << std::setw(5) << std::setprecision(1);
477  return stream;
478 }
479 std::ostream &setupPr2 (std::ostream &stream){
480  stream << std::setw(5) << std::setprecision(2);
481  return stream;
482 }
483 std::ostream &setupPr3 (std::ostream &stream){
484  stream << std::setw(4) << std::setprecision(1);
485  return stream;
486 }
487 std::ostream &setupPr4 (std::ostream &stream){
488  stream << std::setw(4) << std::setprecision(1);
489  return stream;
490 }
491 
492 void TileTBDump::dump_data(const uint32_t * data, unsigned int size, unsigned int /* version */, int /* verbosity */) {
493 
494  boost::io::ios_base_all_saver coutsave(std::cout);
495  std::cout << std::endl << " Fragment data as 4 byte words:" << std::hex << std::setfill('0') ;
496 
497  for (unsigned int cnter = 0; cnter < size; ++cnter) {
498  if (!(cnter % 8)) std::cout << std::endl;
499  std::cout << std::setw(8) << (*data++) << " ";
500  }
501 
502  std::cout <<std::setfill(' ') << std::dec << std::endl << std::endl;
503 
504 }
505 
506 void TileTBDump::dump_digi(unsigned int subdet_id, const uint32_t* roddata, unsigned int rodsize
507  , unsigned int version, int verbosity, unsigned int robsourceid
508  , const EventContext& ctx) {
509 
510  int s, c, f, nfrag, ngain, nchan, nsamp, size, ch, extra = 0, pmt, fragType, nhits = 0;
511  int id, type, rflag, unit, pulse, nsmpl, algor, niter;
512  const unsigned int* data;
513  unsigned short time, flag, prev, edge, chan, bad/*, res1,last,res2*/;
514  char fr[2] = { 'F', 'R' };
515  char gb[2] = { 'G', 'B' };
516  std::string unitName[4] = { "ADC count", "pCb", "Cs pCb", "MeV" };
517  std::string shapeName[4] = { "Phys", "Laser", "CIS", "Simul" };
518  std::string algName[8] = { "Unknown", "OF1", "OF2", "Fit", "ManyAmps", "Flat", "Alg6", "Alg7" };
519  boost::io::ios_base_all_saver coutsave(std::cout);
520 
521  const T_RodDataFrag* frag[MAX_ROD_FRAG];
522  T_TileRawComp rawcomp[MAX_DIGI_CHAN];
525  T_TileRecoCalib recocalib[MAX_DIGI_CHAN];
526  T_TileRecoQuality DQword;
527 
528  bool isFrag5 = false;
529  uint32_t* ofw = 0;
530  std::vector<unsigned int> OFC;
531 
533 
534  bool beamROD = (subdet_id == 0x50 || subdet_id >= 0x60);
535  if (subdet_id >= 0x60) {
536  version = 0; // reset version in COMMON BEAM ROD
537  // don't expect different versions there
538  } else {
539  version &= 0xFFFF; // keep just minor version number
540  }
541 
542  find_frag(roddata, rodsize, version, verbosity, frag, nfrag);
543 
544  if (verbosity > 9) return;
545 
546  for (f = 0; f < nfrag; ++f) {
547 
548  id = frag[f]->id & 0xFFFF;
549  type = (frag[f]->id >> 16) & 0xFF;
550  rflag = (frag[f]->id) >> 24;
551  unit = (rflag & 0xC0) >> 6;
552  pulse = (rflag & 0x30) >> 4;
553  nsmpl = (rflag & 0x08) >> 3;
554  algor = (rflag & 0x04) >> 2;
555  niter = (rflag & 0x03);
556  size = frag[f]->size - m_sizeOverhead;
557  data = frag[f]->data;
558 
559  if (type==0x40 || type==0x41 || type==0x42){
560 
561  const unsigned char * adc;
562  const unsigned short * result;
563  int tmdb_ch1 = std::min(5U,((robsourceid)>>16)&0xF);
564  bool EB = (tmdb_ch1>2);
565  int nmod = (EB)?8:4; // we have 8 modules per fragment in ext.barrel, 4 modules in barrel
566  int tmdb_ch2 = (((robsourceid))&0xF)*nmod;
567  const char * dr56EB[10] = { "D5-L","D5-R","D6-L","D6-R","D4-L","D4-R","XX-X","XX-X","XX-X","XX-X" };
568  const char * dr56LB[10] = { "D0-x","D1-L","D1-R","D2-L","D2-R","D3-L","D3-R","B8-L","B8-R","XX-X" };
569  const char ** dr56rl = (EB) ? dr56EB : dr56LB;
570  const char * ch11[6] = { "AUX","LBA","LBC","EBA","EBC","UNK" };
571  const char * ch12[6] = { "aux","lba","lbc","eba","ebc","unk" };
572  const char * dr56hlEB[4] = {" D6L "," D6H "," D56L"," D56H"};
573  const char * dr56hlLB[4] = {" DxL "," DxH "," DxxL"," DxxH"};
574 
575  const char * dr56thEB[4] = {" D5 "," D6 "," D56 ", "BCID "};
576  const char * dr56thLB[4] = {" Dx "," Dy "," Dxy ", "BCID "};
577  const char ** dr56th = (m_runPeriod < 3) ? (EB ? dr56hlEB : dr56hlLB)
578  : (EB ? dr56thEB : dr56thLB);
579 
580  const char * tit[4] = {"TMDB digits","TMDB energy","TMDB decision","Unknown"};
581 
582  std::cout << std::hex << std::endl << tit[type&3] <<" fragment 0x" << type << " vers 0x"<< id << ", "
583  << std::dec << size << " words found"<< std::endl << std::endl;
584 
585  int nchmod = 4;
586  int nsamp = 7;
587  int nch = 32;
588  int ntd = (EB) ? 3 : 1;
589  int ntdl = (EB) ? 9 : 5;
590  int count = 1;
591  switch (type) {
592 
593  case 0x40:
594  //nsamp=4*size/nch; // here we assume that number of channels is fixed - doesn't work for simulated data
595  nch=4*size/nsamp; // instead of assuming fixed number of channels assume fixed number of samples
596  nchmod = nch/nmod;
597  std::cout << "ch cell ";
598  for (int ind=nsamp; ind>0; --ind) {
599  std::cout << " S"<<ind;
600  }
601  std::cout << std::endl;
602  adc = reinterpret_cast<const unsigned char *>(data);
603  for (int pword=0;pword<nch;++pword) {
604  int pword1=pword%nchmod;
605  if (!EB && nchmod==8) {
606  if (count&1) {
607  if (pword1==0) pword1=9;
608  else pword1 -= 1;
609  } else {
610  if (pword1>6) pword1=9;
611  }
612  } else {
613  if (pword1>9) pword1=9;
614  }
615  std::cout << std::setw(2) << pword << " | " << ch11[tmdb_ch1] <<std::setfill('0')<<std::setw(2) <<tmdb_ch2+count
616  << "-" <<std::setfill(' ')<<std::setw(4)<<dr56rl[pword1];
617  for (int ind=nsamp-1; ind>-1; --ind) {
618  std::cout << " | " << std::setw(3) << ( static_cast<unsigned>(adc[pword+nch*ind]) );
619  }
620  std::cout << std::endl;
621  if ((pword+1)%nchmod==0) count+=1;
622  }
623  break;
624 
625  case 0x41:
626  nch = size; // one word per channel
627  nchmod = nch/nmod;
628  std::cout << "ch cell energy" << std::endl;
629  for (int pword=0;pword<size;++pword) {
630  int pword1=pword%nchmod;
631  if (!EB && nchmod==8) {
632  if (count&1) {
633  if (pword1==0) pword1=9;
634  else pword1 -= 1;
635  } else {
636  if (pword1>6) pword1=9;
637  }
638  } else {
639  if (pword1>9) pword1=9;
640  }
641  std::cout << std::setw(2) << pword<< " | " << ch11[tmdb_ch1] <<std::setfill('0')<<std::setw(2) <<tmdb_ch2+count
642  << "-" <<std::setfill(' ')<<std::setw(4)<<dr56rl[pword1]
643  << " | "<< std::setw(6) << static_cast<int>(data[pword])
644  << std::endl;
645  if ((pword+1)%nchmod==0) count+=1;
646  }
647  break;
648 
649  case 0x42:
650  {
651  std::cout << "nn name TMDB SL_Board SL_Trigger_Sector "
652  << dr56th[3] << dr56th[2] << dr56th[1] << dr56th[0] << std::endl;
653  result = reinterpret_cast<const unsigned short *>(data);
654  if (size != 2) ntd = size * 2;
655  int nbits = m_runPeriod < 3 ? 4 : 3;
656  int tmdb = (tmdb_ch2) / 8 + 1;
657  int slb = tmdb * 3 - 1;
658  std::string tmdb_name = "TM0" + (EB ? std::to_string(tmdb) : "X");
659  for (int pword = 0; pword < ntd; ++pword) {
660  count = (EB) ? pword * 3 : pword * 4 + 1;
661  unsigned short r = result[pword];
662  int bcid = (m_runPeriod < 3) ? 0 : (r >> 12);
663  int slts1 = slb * 2 - 2;
664  int slts2 = slts1 + 1;
665  std::string slt_sectors = " - ";
666  if (EB) {
667  std::stringstream slts12;
668  slts12 << std::setfill(' ') << std::setw(2) << slts1 << "-"
669  << std::setfill(' ') << std::setw(2) << std::left << slts2;
670  slt_sectors = slts12.str();
671  }
672  std::stringstream slb_name;
673  slb_name << "SL_E" << std::setfill('0') << std::setw(2) << (EB ? std::to_string(slb) : "XX");
674  for(int pqword = 0; pqword < 4; ++pqword){
675  std::cout << std::setw(2) << pqword + pword * 4 << " | "
676  << ((count > 0 && count < ntdl) ? ch11[tmdb_ch1] : ch12[tmdb_ch1])
677  << std::setfill('0') << std::setw(2) << tmdb_ch2 + count
678  << std::setfill(' ') << std::setw(6) << tmdb_name
679  << std::setfill(' ') << std::setw(10) << slb_name.str()
680  << std::setfill(' ') << std::setw(15) << slt_sectors
681  << std::setfill(' ') << std::setw(11) << ((m_runPeriod < 3) ? ((r >> 3) & 1) : bcid)
682  << std::setw(5) << ((r >> 2) & 1) << std::setw(5) << ((r >> 1) & 1) << std::setw(5) << (r & 1) << std::endl;
683  r >>= nbits;
684  ++count;
685  }
686  ++slb;
687  if (slb > 24) slb = 1;
688  }
689  }
690  break;
691  default:
693  }
694 
695  } else if (id < 0x100 || beamROD) { // BEAM fragments
696  id &= 0xFF; // set proper frag ID in Beam frag for old data
697 
698  switch (id) {
699 
700  case COMMON_TOF_FRAG:
701  case COMMON_TDC1_FRAG:
702  case COMMON_TDC2_FRAG: {
703  if ((type == 0x1) || (type == 0x2)) {
704  bool isLastChannelEOB = ((data[size - 1] >> 24) & 0x7) == 0x4;
705  if (id == COMMON_TOF_FRAG) {
706  std::cout << "\nBeam ToF TDC, ";
707  } else {
708  std::cout << "\nBeam TDC 0x" << std::setfill('0') << std::hex << std::setw(2) << id << setupDec << ", ";
709  }
710  std::cout << (isLastChannelEOB ? size - 1 : size) << " hits found";
711  prev = 0xFF;
712  for (c = 0; c < size; ++c) {
713  time = data[c] & 0x1FFF;
714  unsigned short res1 = (data[c] >> 13) & 0x1;
715 
716  chan = (type == 0x1) ? (data[c] >> 17) & 0x3FF // take 10 bits, but 6 upper bits should be 0
717  : (data[c] >> 16) & 0x7FF; // take 11 bits, but 6 upper bits should be 0
718 
719  if (chan > 31) {
720  int wordType = (data[c] >> 24) & 0x7;
721  if (wordType == 0x2) {
722  std::cout << "\n header, " << ((data[c] >> 8) & 0x3F) << " channels";
723  } else if (wordType == 0x4) {
724  std::cout << "\n end of block, event counter: " << (data[c] & 0xFFFFFF) << std::endl;
725  } else {
726  std::cout << "\n unknown word: 0x" << std::hex << data[c] << std::dec << std::endl;
727  }
728  continue;
729  }
730  if (prev != chan) {
731  std::cout << "\n ch" << std::setw(3) << chan << ":";
732  nhits = 0;
733  prev = chan;
734  } else if (nhits % 8 == 0) {
735  std::cout << "\n ";
736  }
737  ++nhits;
738  if (res1) {
739  std::cout << " U" << std::setw(4) << time;
740  } else {
741  std::cout << " " << std::setw(4) << time;
742  }
743  }
744  std::cout << std::endl;
745 
746  break;
747  } else {
748  // Fall through to BEAM_TDC_FRAG
749  [[fallthrough]]; // silent the warning on fall through
750  }
751  }
752 
753  case BEAM_TDC_FRAG:
754  std::cout << "\nBeam TDC 0x" << std::setfill('0') << std::hex << std::setw(2) << id << setupDec << ", " << size << " hits found";
755  prev = 0xFF;
756  for (c = 0; c < size; ++c) {
757  time = data[c] & 0xFFFF;
758  flag = data[c] >> 16;
759  edge = flag & 0x01;
760  chan = (flag >> 1) & 0x0F;
761  bad = (flag >> 5) & 0x01;
762  //res1 = (flag >> 6) & 0x01;
763  //last = (flag >> 7) & 0x01;
764  //res2 = (flag >> 8) & 0x0F;
765  if (prev != chan) {
766  std::cout << "\n ch" << std::setw(3) << chan << ":";
767  nhits = 0;
768  prev = chan;
769  } else if (nhits % 8 == 0) {
770  std::cout << "\n ";
771  }
772  ++nhits;
773  if (bad) {
774  std::cout << " " << gb[bad] << fr[edge] << std::setw(6) << time;
775  } else {
776  std::cout << " " << fr[edge] << std::setw(6) << time;
777  }
778  }
779  std::cout << std::endl;
780  break;
781 
782  case COMMON_ADC1_FRAG:
783  case COMMON_ADC2_FRAG: {
784  if ((type == 0x1) || (type == 0x2)) { // CAEN V792N or V792
785  bool isLastChannelEOB = ((data[size - 1] >> 24) & 0x7) == 0x4;
786  std::cout << "\nBeam ADC, " << (isLastChannelEOB ? size - 1 : size) << " hits found";
787  prev = 0xFF;
788  for (c = 0; c < size; ++c) {
789  time = data[c] & 0x1FFF;
790  unsigned short res1 = (data[c] >> 13) & 0x1;
791  chan = (type == 0x1) ? (data[c] >> 17) & 0x3FF // take 10 bits, but 6 upper bits should be 0
792  : (data[c] >> 16) & 0x7FF; // take 11 bits, but 6 upper bits should be 0
793 
794  if (chan > 31) {
795  int wordType = (data[c] >> 24) & 0x7;
796  if (wordType == 0x2) {
797  std::cout << "\n header, " << ((data[c] >> 8) & 0x3F) << " channels";
798  } else if (wordType == 0x4) {
799  std::cout << "\n end of block, event counter: " << (data[c] & 0xFFFFFF) << std::endl;
800  } else {
801  std::cout << "\n unknown word: 0x" << std::hex << data[c] << std::dec << std::endl;
802  }
803  continue;
804  }
805  if (prev != chan) {
806  std::cout << "\n ch" << std::setw(3) << chan << ":";
807  nhits = 0;
808  prev = chan;
809  } else if (nhits % 8 == 0) {
810  std::cout << "\n ";
811  }
812  ++nhits;
813  if (res1) {
814  std::cout << " U" << std::setw(4) << time;
815  } else {
816  std::cout << " " << std::setw(4) << time;
817  }
818  }
819  std::cout << std::endl;
820  break;
821  } else {
822  // Fall through to BEAM_ADC_FRAG
823  [[fallthrough]]; // silent the warning on fall through
824  }
825  }
826 
827  case BEAM_ADC_FRAG:
828  if (BEAM_ADC_FRAG == id) {
829  std::cout << "\nTile Beam ADC, " << size << " channels found";
830  } else {
831  std::cout << "\nBeam ADC 0x" << std::hex << std::setfill('0') << std::setw(2) << id << setupDec << ", " << size << " channels found";
832  }
833  for (c = 0; c < size; ++c) {
834  if (c % 8 == 0) std::cout << setupMod << c / 8 << ":";
835  std::cout << std::setw(9) << data[c];
836  }
837  std::cout << std::endl;
838  break;
839 
840  case MUON_ADC_FRAG:
841  std::cout << "\nMuon ADC, " << size << " channels found";
842  for (c = 0; c < size; ++c) {
843  if (c % 8 == 0) std::cout << setupMod << c / 8 << ":";
844  std::cout << std::setw(9) << data[c];
845  }
846  std::cout << std::endl;
847  break;
848 
849  case ADDR_ADC_FRAG:
850  std::cout << "\nMuon2 ADC, " << size << " channels found";
851  for (c = 0; c < size; ++c) {
852  if (c % 8 == 0) std::cout << setupMod << c / 8 << ":";
853  std::cout << std::setw(9) << data[c];
854  }
855  std::cout << std::endl;
856  break;
857 
858  case LASE_PTN_FRAG:
859  case COMMON_PTN_FRAG:
860  if (LASE_PTN_FRAG == id) {
861  std::cout<<"\nLaser Pattern Unit, " << size << " words found (hex)";
862  } else {
863  std::cout<<"\nCommon Pattern Unit, " << size << " words found (hex)";
864  }
865  for (c = 0; c < size; ++c) {
866  if (c % 8 == 0) std::cout << setupMod << c/8 << ":";
867  std::cout << " 0x" << setup0 << data[c] << setupDec << std::endl;
868  }
869  std::cout << std::endl;
870  break;
871 
872  case LASER_OBJ_FRAG:
873 
874  if (size !=25 && size != 26) {
875  std::cout<<"\nLASTROD Laser Object, " << size << " words found (hex)";
876  for (c = 0; c < size; ++c) {
877  if (c % 8 == 0) std::cout << setupMod << c/8 << ":";
878  std::cout << " 0x" << setup0 << data[c] << setupDec;
879  }
880  std::cout<<std::endl<<std::endl;
881 
882  if (size != 31) {
883  std::cout<<"CRITICAL ERROR! Unknown format!"<<std::endl;
884  } else {
885  const unsigned int * p;
886  int Counter = 0;
887  int Filter = 0, ReqAmp = 0, MeasAmp = 0, Delay = 0, TDC1 = 0, TDC2 = 0;
888  p = data;
889  Counter = *p;
890  p++;
891  std::cout << " Laser Counter: " << std::setw(5) << Counter << std::endl;
892 
893  if ((*p & 0xFF000000) == 0x20000000) {
894  ReqAmp = *p & 0xFFFF;
895  if (version > 1) {
896  Filter = (((*p >> 16) & 7) ^ 7) + 2;
897  if (Filter > 8) Filter -= 8;
898  std::cout << " Filter Wheel: " << std::setw(5) << Filter << std::endl;
899  }
900  std::cout << " Required Amp: " << std::setw(5) << ReqAmp << std::endl;
901  } else {
902  std::cout << "ERROR in Laser Fragment: decoding word 14." << std::endl;
903  }
904  p++;
905 
906  if ((*p & 0xFF000000) == 0x21000000) {
907  Delay = (*p >> 12) & 0xFFF;
908  MeasAmp = *p & 0xFFF;
909  std::cout << " Measured Amp: " << std::setw(5) << MeasAmp << std::endl;
910  std::cout << " Delay: " << std::setw(5) << Delay << std::endl;
911  } else {
912  std::cout << "ERROR in Laser Fragment: decoding word 15." << std::endl;
913  }
914  p++;
915 
916  bool TDCPrint = true;
917 
918  if ((*p & 0xFF000000) == 0x22000000) {
919  if (version == 1) {
920  TDC1 = (*p >> 16) & 0xF;
921  TDC2 = (*p >> 20) & 0xF;
922  } else {
923  TDC1 = *p & 0xFFFF;
924  }
925  } else {
926  std::cout << "ERROR in Laser Fragment: decoding word 16." << std::endl;
927  TDCPrint = false;
928  }
929  p++;
930  if ((*p & 0xFF000000) == 0x23000000) {
931  if (version == 1) {
932  TDC1 = (TDC1 << 12) + (*p & 0xFFF);
933  TDC2 = (TDC2 << 12) + ((*p >> 12) & 0xFFF);
934  } else {
935  TDC2 = *p & 0xFFFF;
936  }
937  } else {
938  std::cout << "ERROR in Laser Fragment: decoding word 17." << std::endl;
939  TDCPrint = false;
940  }
941  p++;
942  if (TDCPrint) {
943  std::cout << " TDC1 data: " << std::setw(5) << TDC1 << std::endl;
944  std::cout << " TDC2 data: " << std::setw(5) << TDC2 << std::endl;
945  }
946 
947  int chan0 = 0, chan1 = 0, chan2 = 0, chan3 = 0, chan4 = 0, chan5 = 0, chan6 = 0, chan7 = 0;
948 
949  if ((*p & 0xFF000000) == 0x44000000) {
950  chan0 = (*p & 0xFFF) ^ 0xFFF;
951  chan1 = ((*p >> 12) & 0xFFF) ^ 0xFFF;
952  } else {
953  std::cout << "ERROR in Laser Fragment: decoding word 18." << std::endl;
954  }
955  p++;
956 
957  if ((*p & 0xFF000000) == 0x45000000) {
958  chan2 = (*p & 0xFFF) ^ 0xFFF;
959  chan3 = ((*p >> 12) & 0xFFF) ^ 0xFFF;
960  } else {
961  std::cout << "ERROR in Laser Fragment: decoding word 19." << std::endl;
962  }
963  p++;
964 
965  if ((*p & 0xFF000000) == 0x46000000) {
966  chan4 = (*p & 0xFFF) ^ 0xFFF;
967  chan5 = ((*p >> 12) & 0xFFF) ^ 0xFFF;
968  } else {
969  std::cout << "ERROR in Laser Fragment: decoding word 20." << std::endl;
970  }
971  p++;
972 
973  if ((*p & 0xFF000000) == 0x47000000) {
974  chan6 = (*p & 0xFFF) ^ 0xFFF;
975  chan7 = ((*p >> 12) & 0xFFF) ^ 0xFFF;
976  } else {
977  std::cout << "ERROR in Laser Fragment: decoding word 21." << std::endl;
978  }
979  p++;
980 
981  int diode1_Ped = 0, diode1_PedRMS = 0
982  , diode2_Ped = 0, diode2_PedRMS = 0
983  , diode3_Ped = 0, diode3_PedRMS = 0
984  , diode4_Ped = 0, diode4_PedRMS = 0
985  , PMT1_Ped = 0, PMT1_PedRMS = 0
986  , PMT2_Ped = 0, PMT2_PedRMS = 0;
987 
988  diode1_Ped = (*p >> 16) & 0xFFFF;
989  diode1_PedRMS = *p & 0xFFFF;
990  p++;
991 
992  diode2_Ped = (*p >> 16) & 0xFFFF;
993  diode2_PedRMS = *p & 0xFFFF;
994  p++;
995 
996  diode3_Ped = (*p >> 16) & 0xFFFF;
997  diode3_PedRMS = *p & 0xFFFF;
998  p++;
999 
1000  diode4_Ped = (*p >> 16) & 0xFFFF;
1001  diode4_PedRMS = *p & 0xFFFF;
1002  p++;
1003 
1004  PMT1_Ped = (*p >> 16) & 0xFFFF;
1005  PMT1_PedRMS = *p & 0xFFFF;
1006  p++;
1007 
1008  PMT2_Ped = (*p >> 16) & 0xFFFF;
1009  PMT2_PedRMS = *p & 0xFFFF;
1010  p++;
1011 
1012  time_t Ped_Last_Run = *p;
1013  p++;
1014 
1015  int diode1_alpha = 0, diode1_alphaRMS = 0
1016  , diode2_alpha = 0, diode2_alphaRMS = 0
1017  , diode3_alpha = 0, diode3_alphaRMS = 0
1018  , diode4_alpha = 0, diode4_alphaRMS = 0;
1019 
1020  diode1_alpha = (*p >> 16) & 0xFFFF;
1021  diode1_alphaRMS = *p & 0xFFFF;
1022  p++;
1023 
1024  diode2_alpha = (*p >> 16) & 0xFFFF;
1025  diode2_alphaRMS = *p & 0xFFFF;
1026  p++;
1027 
1028  diode3_alpha = (*p >> 16) & 0xFFFF;
1029  diode3_alphaRMS = *p & 0xFFFF;
1030  p++;
1031 
1032  diode4_alpha = (*p >> 16) & 0xFFFF;
1033  diode4_alphaRMS = *p & 0xFFFF;
1034  p++;
1035 
1036  time_t Alpha_Last_Run = *p;
1037  p++;
1038 
1039  time_t PedAlpha_Last_Run(0);
1040 
1041  int diode1_PedAlpha = 0, diode1_PedAlphaRMS = 0
1042  , diode2_PedAlpha = 0, diode2_PedAlphaRMS = 0
1043  , diode3_PedAlpha = 0, diode3_PedAlphaRMS = 0
1044  , diode4_PedAlpha = 0, diode4_PedAlphaRMS = 0;
1045 
1046  if (version > 1) {
1047  diode1_PedAlpha = (*p >> 16) & 0xFFFF;
1048  diode1_PedAlphaRMS = *p & 0xFFFF;
1049  p++;
1050 
1051  diode2_PedAlpha = (*p >> 16) & 0xFFFF;
1052  diode2_PedAlphaRMS = *p & 0xFFFF;
1053  p++;
1054 
1055  diode3_PedAlpha = (*p >> 16) & 0xFFFF;
1056  diode3_PedAlphaRMS = *p & 0xFFFF;
1057  p++;
1058 
1059  diode4_PedAlpha = (*p >> 16) & 0xFFFF;
1060  diode4_PedAlphaRMS = *p & 0xFFFF;
1061  p++;
1062 
1063  PedAlpha_Last_Run = *p;
1064  p++;
1065  }
1066 
1067  std::cout << std::endl << " | ADC | Pedestal(RMS) | Alpha (RMS) | PedAlpha(RMS) |" << std::endl;
1068  if (version == 1){
1069  std::cout << " Diode 1 | " << std::setw(5) << chan0 << " | " << setupPr1 << diode1_Ped / 10.0 << " (" << setupPr2 << diode1_PedRMS / 100.0 << ") | " << setupPr1 << diode1_alpha / 10.0 << " (" << setupPr2 << diode1_alphaRMS / 100.0 << ") |" << std::endl;
1070  std::cout << " Diode 2 | " << std::setw(5) << chan1 << " | " << setupPr1 << diode2_Ped / 10.0 << " (" << setupPr2 << diode2_PedRMS / 100.0 << ") | " << setupPr1 << diode2_alpha / 10.0 << " (" << setupPr2 << diode2_alphaRMS / 100.0 << ") |" << std::endl;
1071  std::cout << " Diode 3 | " << std::setw(5) << chan2 << " | " << setupPr1 << diode3_Ped / 10.0 << " (" << setupPr2 << diode3_PedRMS / 100.0 << ") | " << setupPr1 << diode3_alpha / 10.0 << " (" << setupPr2 << diode3_alphaRMS / 100.0 << ") |" << std::endl;
1072  std::cout << " Diode 4 | " << std::setw(5) << chan3 << " | " << setupPr1 << diode4_Ped / 10.0 << " (" << setupPr2 << diode4_PedRMS / 100.0 << ") | " << setupPr1 << diode4_alpha / 10.0 << " (" << setupPr2 << diode4_alphaRMS / 100.0 << ") |" << std::endl;
1073  } else {
1074  std::cout << " Diode 1 | " << std::setw(5) << chan0 << " | " << setupPr1 << diode1_Ped / 10.0 << " (" << setupPr2 << diode1_PedRMS / 100.0 << ") | " << setupPr1 << diode1_alpha / 10.0 << " (" << setupPr2 << diode1_alphaRMS / 100.0 << ") | " << setupPr1 << diode1_PedAlpha / 10.0 << " (" << setupPr2 << diode1_PedAlphaRMS / 100.0 << ") |" << std::endl;
1075  std::cout << " Diode 2 | " << std::setw(5) << chan1 << " | " << setupPr1 << diode2_Ped / 10.0 << " (" << setupPr2 << diode2_PedRMS / 100.0 << ") | " << setupPr1 << diode2_alpha / 10.0 << " (" << setupPr2 << diode2_alphaRMS / 100.0 << ") | " << setupPr1 << diode2_PedAlpha / 10.0 << " (" << setupPr2 << diode2_PedAlphaRMS / 100.0 << ") |" << std::endl;
1076  std::cout << " Diode 3 | " << std::setw(5) << chan2 << " | " << setupPr1 << diode3_Ped / 10.0 << " (" << setupPr2 << diode3_PedRMS / 100.0 << ") | " << setupPr1 << diode3_alpha / 10.0 << " (" << setupPr2 << diode3_alphaRMS / 100.0 << ") | " << setupPr1 << diode3_PedAlpha / 10.0 << " (" << setupPr2 << diode3_PedAlphaRMS / 100.0 << ") |" << std::endl;
1077  std::cout << " Diode 4 | " << std::setw(5) << chan3 << " | " << setupPr1 << diode4_Ped / 10.0 << " (" << setupPr2 << diode4_PedRMS / 100.0 << ") | " << setupPr1 << diode4_alpha / 10.0 << " (" << setupPr2 << diode4_alphaRMS / 100.0 << ") | " << setupPr1 << diode4_PedAlpha / 10.0 << " (" << setupPr2 << diode4_PedAlphaRMS / 100.0 << ") |" << std::endl;
1078  }
1079 
1080  std::cout << " PMT 1 | " << std::setw(5) << chan4 << " | " << setupPr1 << PMT1_Ped / 10.0 <<" (" << setupPr2 << PMT1_PedRMS / 100.0 << ") | x | x |" << std::endl;
1081  std::cout << " PMT 2 | " << std::setw(5) << chan5 << " | " << setupPr1 << PMT2_Ped / 10.0 <<" (" << setupPr2 << PMT2_PedRMS / 100.0 << ") | x | x |" << std::endl;
1082  std::cout << " InjChrg | " << std::setw(5) << chan6 << " | x | x | x |" << std::endl;
1083  std::cout << " Spare | " << std::setw(5) << chan7 << " | x | x | x |" << std::endl;
1084 
1085  std::cout << std::endl << " | Date & Time (GMT) | Date & Time (CERN)" << std::endl;
1086 
1087  struct tm TimeInfo;
1088  char buf[80];
1089  gmtime_r(&Ped_Last_Run, &TimeInfo);
1090  strftime(buf, 80, "%d.%m.%Y %H:%M:%S", &TimeInfo);
1091 
1092  std::cout << " Pedestal | " << buf << " | " << cern_local_time(Ped_Last_Run) << std::endl;
1093 
1094  gmtime_r(&Alpha_Last_Run, &TimeInfo);
1095  strftime(buf, 80, "%d.%m.%Y %H:%M:%S", &TimeInfo);
1096 
1097  std::cout << " Alpha | " << buf << " | " << cern_local_time(Alpha_Last_Run) << std::endl;
1098 
1099  gmtime_r(&PedAlpha_Last_Run, &TimeInfo);
1100  strftime(buf, 80, "%d.%m.%Y %H:%M:%S", &TimeInfo);
1101 
1102  std::cout << " PedAlpha | " << buf << " | " << cern_local_time(PedAlpha_Last_Run) << std::endl;
1103 
1104  int diodeTemp = 0, secsDiodeT = 0
1105  , boxTemp = 0, secsBoxT = 0
1106  , boxHum = 0, secsBoxH = 0
1107  , gasFlow = 0, secsGasF = 0;
1108 
1109  diodeTemp = *p & 0xFFF;
1110  secsDiodeT = (*p >> 12) & 0xFFFFF;
1111  p++;
1112  boxTemp = *p & 0xFFF;
1113  secsBoxT = (*p >> 12) & 0xFFFFF;
1114  p++;
1115  boxHum = *p & 0xFFF;
1116  secsBoxH = (*p >> 12) & 0xFFFFF;
1117  p++;
1118  gasFlow = *p & 0xFFF;
1119  secsGasF = (*p >> 12) & 0xFFFFF;
1120  p++;
1121 
1122  std::cout << std::endl << " | Time | Value |" << std::endl;
1123  std::cout << " Laser diode temp | " << std::setw(7) << secsDiodeT << " | " << setupPr3 << diodeTemp / 10.0 << " |" << std::endl;
1124  std::cout << " Laser box temp | " << std::setw(7) << secsBoxT << " | " << setupPr3 << boxTemp / 10.0 << " |" << std::endl;
1125  std::cout << " Laser box humidity | " << std::setw(7) << secsBoxH << " | " << setupPr3 << boxHum / 10.0 << " |" << std::endl;
1126  std::cout << " Laser box gas flow | " << std::setw(7) << secsGasF << " | " << setupPr3 << gasFlow / 10.0 << " |" << std::endl;
1127 
1128  std::bitset<32> PLCstatus = *p;
1129  int PLCtime = (*p >> 12) & 0xFFFFF;
1130  p++;
1131 
1132  int Alpha0 = PLCstatus[0];
1133  int Alpha1 = PLCstatus[1];
1134  int Alpha2 = PLCstatus[2];
1135  int LV = PLCstatus[3];
1136  int HV1 = PLCstatus[4];
1137  int HV2 = PLCstatus[5];
1138  int ShOpen = PLCstatus[6];
1139  int ShClose = PLCstatus[7];
1140  int Ilock = PLCstatus[8];
1141  int Alarm = PLCstatus[9];
1142  int Err = PLCstatus[11];
1143 
1144  const char *YesNo[2] = {" No","Yes"};
1145  const char *OnOff[2] = {"Off"," On"};
1146 
1147  std::cout << std::endl << " Time | Err | Alarm | Ilock | ShClose | ShOpen | HV2 | HV1 | LV | Alpha2 | Alpha1 | Alpha0 |"
1148  << std::endl << " " << std::setw(7) << PLCtime
1149  << " | " << YesNo[Err] << " | " << OnOff[Alarm] << " | " << OnOff[Ilock] << " | " << YesNo[ShClose]
1150  << " | " << YesNo[ShOpen] << " | " << OnOff[HV2] << " | " << OnOff[HV1] << " | " << OnOff[LV]
1151  << " | " << OnOff[Alpha2] << " | " << OnOff[Alpha1] << " | " << OnOff[Alpha0] << " |" << std::endl;
1152 
1153  if (p != &data[size]) {
1154  std::cout << "CRITICAL ERROR! Wrong size" << std::endl;
1155  }
1156  }
1157  break;
1158  }
1159  /* FALLTHROUGH */
1160 
1161  case LASERII_OBJ_FRAG:
1162 
1163  {
1164  std::cout<<"\nLASTROD New Laser Object, " << size << " words found" << std::endl;
1165 
1166  bool first_half_present = (size == 25 || size == 26 || size == 128 || size == 129);
1167  bool second_half_present = (size == 99 || size == 100 || size == 128 || size == 129);
1168 
1169  if ( ! (first_half_present || second_half_present) ) {
1170  std::cout << "CRITICAL ERROR! Unknown format!" << std::endl;
1171  } else {
1172 
1173  const char *name[17] = {" PhotoDiode 0",
1174  " PhotoDiode 1",
1175  " PhotoDiode 2",
1176  " PhotoDiode 3",
1177  " PhotoDiode 4",
1178  " PhotoDiode 5",
1179  " PhotoDiode 6",
1180  " PhotoDiode 7",
1181  " PhotoDiode 8",
1182  " PhotoDiode 9",
1183  " External CIS 0",
1184  " Internal CIS",
1185  " Diode Phocal",
1186  " External CIS 1",
1187  " PMT 0",
1188  " PMT 1",
1189  " TDC 1 & 0"
1190  };
1191 
1192  time_t tim;
1193  struct tm TimeInfo;
1194  char buf[80];
1195 
1196  const unsigned int * p = data;
1197 
1198  if (first_half_present) {
1199 
1200  // p[0] 00 00 00 tt Daq Type
1201  // p[1] nn nn nn nn Laser Count
1202  // p[2] rr rr mm mm rrrr = Requested Intensity mmmm = measured intensity
1203  // p[3] 00 0f dd dd f = filter dddd = Delay Slama
1204  // p[4] 00 00 ll ll Linearity DAC Value
1205 
1206  std::cout << std::endl << " DAQ type: " << std::setw(5) << (data[0]%0xFF) << std::endl;
1207  std::cout << " Laser Counter: " << std::setw(5) << data[1] << std::endl;
1208  std::cout << " Required Amp: " << std::setw(5) << (data[2]>>16) << std::endl;
1209  std::cout << " Measured Amp: " << std::setw(5) << (data[2]&0xFFFF) << std::endl;
1210  std::cout << " Filter Wheel: " << std::setw(5) << (data[3]>>16 & 0x000F) << std::endl;
1211  std::cout << " Delay: " << std::setw(5) << (data[3]&0xFFFF) << std::endl;
1212  std::cout << " Linearity DAC: " << std::setw(5) << (data[4]&0xFFFF) << std::endl;
1213  std::cout << std::endl;
1214 
1215  p = data+5;
1216  // decode 32 ADC half-words (16 low & high channels)
1217  std::cout << " HG LG" << std::endl;
1218  for (int n=0; n<17; ++n) {
1219  // ll ll hh hh ADC Channel 0 & 1 (Low & High Gain)
1220  std::cout << name[n] << ": " << std::setw(5) << ((*p)&0xFFFF) << std::setw(6) << ((*p)>>16) << " => " << std::setw(5) << (8500-((*p)&0xFFFF)) << std::setw(6) << (8500-((*p)>>16))<< std::endl;
1221  ++p;
1222  }
1223 
1224  // status word
1225  // 27: 1 if HOLA link not full
1226  // 26: 1 if HOLA link not down
1227  // 24: 1 if bad clock from VME (16MHz)
1228  // 22: 1 if bad clock from TTC (40MHz)
1229  // 20: 1 if TTC double error
1230  // 19: 1 if TTC single error
1231  // 16: 1 if PLL locked for VME clock (16MHz)
1232  // 15: 1 if PLL locked for TTC clock (40MHz)
1233  // 10: 1 if fault from laser temperature sensor
1234  // 9: 1 if laser diode off
1235  // 8: 1 if interlock closed
1236  // 6: 1 if combined run finished
1237  // 1: 1 if busy
1238  // 0: 1 if busy for longer than 5s
1239 
1240 
1241  std::bitset<32> status = *(p++);
1242  const char *YesNo[2] = {" No","Yes"};
1243  std::cout << std::endl;
1244  std::cout << "| Link| Link| Bad | Bad | TTC | TTC | PLL | PLL |Laser|Laser|Inter| Comb| Busy| Long|" << std::endl;
1245  std::cout << "| not | not | VME | TTC |doubl|singl| lock| lock| temp| diod| lock| run | | busy|" << std::endl;
1246  std::cout << "| full| down|clock|clock|error|error| VME | TTC |fault| off |close| fini| |>5sec|" << std::endl;
1247  std::cout << "|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|" << std::endl;
1248  std::cout << "| " << YesNo[status[27]] << " | " << YesNo[status[26]] << " | " << YesNo[status[24]] << " | " << YesNo[status[22]] << " | " << YesNo[status[20]] << " | " << YesNo[status[19]] << " | " << YesNo[status[16]] << " | " << YesNo[status[15]] << " | " << YesNo[status[10]] << " | " << YesNo[status[9]] << " | " << YesNo[status[8]] << " | " << YesNo[status[6]] << " | " << YesNo[status[1]] << " | " << YesNo[status[0]] << " |" << std::endl;
1249 
1250  std::cout << std::endl << " FPGA Global Status: 0x" << std::hex
1251  << status.to_ulong() << " => " << status.to_string() << std::dec << std::endl;
1252  tim = *(p++);
1253  gmtime_r(&tim, &TimeInfo);
1254  strftime(buf, 80, "%d.%m.%Y %H:%M:%S", &TimeInfo);
1255  std::cout << "DCS Time Stamp (GMT): " << buf << " => " << cern_local_time(tim) << std::endl;
1256  std::cout << " PhotoDiode Polarity: " << std::setw(5) << (*p++) << std::endl;
1257  p+=4; // skip 4 free words
1258  }
1259 
1260  if (second_half_present) {
1261  std::cout << " Calibration Type: " << std::setw(5) << (*p++) << std::endl;
1262  tim = p[97];
1263  gmtime_r(&tim, &TimeInfo);
1264  strftime(buf, 80, "%d.%m.%Y %H:%M:%S", &TimeInfo);
1265  std::cout << " Time Stamp (GMT): " << buf << " => " << cern_local_time(tim) << std::endl;
1266 
1267  double nevt = double(p[96]);
1268  if (p[96]==0 || (p[96]==3072 && (*p)<21504000)) {
1269  std::cout << " Number of events: " << p[96] << " => assuming 1024" << std::endl << std::endl;
1270  nevt=1024.;
1271  } else {
1272  std::cout << " Number of events: " << std::setw(5) << p[96] << std::endl << std::endl;
1273  }
1274  std::cout << " pedHG rmsHG pedLG rmsLG" << std::endl;
1275  for (int n=0; n<16; ++n) {
1276 
1277  uint32_t sum0 = *(p++);
1278  uint32_t sum1 = *(p++);
1279 
1280  uint32_t lsb0 = *(p++);
1281  uint32_t msb0 = *(p++);
1282  uint32_t lsb1 = *(p++);
1283  uint32_t msb1 = *(p++);
1284  uint64_t ssq0 = ((uint64_t) msb0 << 32) | ((uint64_t) lsb0);
1285  uint64_t ssq1 = ((uint64_t) msb1 << 32) | ((uint64_t) lsb1);
1286 
1287  // COMPUTE MEAN AND STANDARD DEVIATION
1288  double ped0 = double(sum0)/nevt;
1289  double ped1 = double(sum1)/nevt;
1290 
1291  double rms0 = double(ssq0)/nevt - ped0*ped0;
1292  double rms1 = double(ssq1)/nevt - ped1*ped1;
1293  if (rms0>0.0) rms0 = sqrt(rms0);
1294  if (rms1>0.0) rms1 = sqrt(rms1);
1295 
1296  std::cout << name[n] << ":" << std::setw(11) << sum0 << std::setw(11) << sum1 << std::setw(11) << msb0 << std::setw(11) << lsb0 << std::setw(11) << msb1 << std::setw(11) << lsb1 << " => " << std::setw(7) << std::setprecision(1) << 8500.-ped0 << " +/- " << std::setw(7) << std::setprecision(1) << rms0 << " " << std::setw(7) << std::setprecision(1) << 8500.-ped1 << " +/- " << std::setw(7) << std::setprecision(1) << rms1 << std::endl;
1297  }
1298  }
1299  }
1300  break;
1301  }
1302 
1303  case LASE_ADC_FRAG:
1304  std::cout << "\nLaser ADC, " << size << " channels found";
1305  for (c = 0; c < size; ++c) {
1306  if (c % 8 == 0) std::cout << setupMod << c/8<< ":";
1307  std::cout << std::setw(9) << data[c];
1308  }
1309  std::cout << std::endl;
1310  break;
1311 
1312  case ECAL_ADC_FRAG:
1313  std::cout << "\nECAL ADC, " << size << " channels found";
1314  for (c = 0; c < size; ++c) {
1315  if (c % 8 == 0) std::cout << setupMod << c/8<< ":";
1316  std::cout << std::setw(9) << data[c];
1317  }
1318  std::cout << std::endl;
1319  break;
1320 
1321  case DIGI_PAR_FRAG:
1322  std::cout << "\nDigi parameters, " << size << " words found";
1323  for (c = 0; c < size; ++c) {
1324  if (c % 8 == 0) std::cout << setupMod << c/8<< ":";
1325  std::cout << std::setw(11) << data[c];
1326  }
1327  std::cout << std::endl;
1328 
1329  if (size == 4 || size == 16 || size == 110) {
1330  const unsigned int *p = data;
1331  int Counter = 0, Mode = 0, Samples = 0, Pipeline = 0, I3Delay = 0, Event = 0, Phase = 0,
1332  DAC = 0, Capacity = 0, Card = 0, RunType = 0, microsec = 0;
1333  time_t Time;
1334  bool DefFormat = true;
1335  if (size == 4) DefFormat = false;
1336  if (!DefFormat) {
1337  Counter = *(p++);
1338  Samples = *(p++);
1339  Pipeline = *(p++);
1340  RunType = *(p++);
1341  } else {
1342  Mode = *(p++);
1343  Samples = *(p++);
1344  Pipeline = *(p++);
1345  I3Delay = *(p++);
1346  Event = *(p++);
1347  Phase = *(p++);
1348  DAC = *(p++);
1349  Capacity = *(p++);
1350  Card = *(p++);
1351  p++; //Reserved
1352  Time = *(p++);
1353  microsec = *(p++);
1354  RunType = *(p++);
1355  p++; //Reserved
1356  p++; //Reserved
1357  Counter = *(p++);
1358  }
1359  const char *RunTypeText;
1360  switch (RunType) {
1361  case 1: RunTypeText = "Physics"; break;
1362  case 2: RunTypeText = "Laser"; break;
1363  case 4: RunTypeText = "Pedestals"; break;
1364  case 8: RunTypeText = "CIS mono"; break;
1365  case 16: RunTypeText = "CIS scan"; break;
1366  default: RunTypeText = "Unknown"; break;
1367  }
1368 
1369  std::cout << "\n CIS Counter: " << std::setw(3) << Counter<< std::endl;
1370  std::cout << "\n Run Type: " << std::setw(3) << RunType << " (" << RunTypeText << ")";
1371  if (!DefFormat) {
1372  std::cout << "\n Samples: " << std::setw(3) << Samples;
1373  std::cout << "\n Pipeline: " << std::setw(3) << Pipeline << std::endl;
1374  } else {
1375  const char* ModeText;
1376  switch (Mode) {
1377  case 0:
1378  ModeText = "Normal";
1379  break;
1380  case 1: ModeText = "Calibration"; break;
1381  default: ModeText = "Unknown"; break;
1382  }
1383 
1384  struct tm TimeInfo;
1385  char buf[80];
1386  gmtime_r(&Time, &TimeInfo);
1387  strftime(buf, 80, "%d.%m.%Y %H:%M:%S", &TimeInfo);
1388  std::cout << std::endl;
1389  std::cout << " Time (GMT): " << buf << " => " << cern_local_time(Time) << std::endl;
1390  std::cout << " Microsec.: " << microsec << std::endl << std::endl;
1391  std::cout << " Mode: " << std::setw(3) << Mode << " (" << ModeText << ")" << std::endl;
1392  std::cout << " Samples: " << std::setw(3) << Samples << std::endl;
1393  std::cout << " Pipeline: " << std::setw(3) << Pipeline << std::endl;
1394  std::cout << " I3Delay: " << std::setw(3) << I3Delay << std::endl;
1395  std::cout << " Event: " << std::setw(3) << Event << std::endl;
1396  std::cout << " Phase: " << std::setw(3) << Phase << std::endl;
1397  std::cout << " DAC: " << std::setw(3) << DAC << std::endl;
1398  std::cout << " Capacity: " << std::setw(3) << Capacity << " pF" << std::endl;
1399  std::cout << " Card: " << std::setw(3) << Card << std::endl;
1400 
1401  if (size > 16) {
1402  int last = size - 1;
1403  for (; last > 15; --last) {
1404  if (data[last] != 0) break;
1405  }
1406  if (last > 15) {
1407  std::cout << "\n Remaing " << last - 15 << " non-zero words (hex):";
1408  for (c = 16; c <= last; ++c) {
1409  if (c % 8 == 0) std::cout << setupMod << c/8<< ":";
1410  std::cout << std::hex << std::setw(11) << data[c] << std::dec;
1411  }
1412  std::cout << std:: endl;
1413  }
1414  }
1415  }
1416  } else {
1417  std::cout << "CRITICAL ERROR! Unknown format!" << std::endl;
1418  }
1419  break;
1420 
1421  case ADD_FADC_FRAG:
1422  std::cout << "\nAdder FADC, " << size << " words found (hex)" ;
1423  for (c = 0; c < size; ++c) {
1424  if (c % 8 == 0) std::cout << setupMod << c/8<< ":";
1425  std::cout << std::hex << std::setw(9) << data[c] << std::dec;
1426  }
1427  std::cout << std::endl;
1428  break;
1429 
1430  case COIN_TRIG1_FRAG:
1431  case COIN_TRIG2_FRAG:
1432  case COIN_TRIG3_FRAG:
1433  case COIN_TRIG4_FRAG:
1434  case COIN_TRIG5_FRAG:
1435  case COIN_TRIG6_FRAG:
1436  case COIN_TRIG7_FRAG:
1437  case COIN_TRIG8_FRAG:
1438  std::cout << "\nCoincidence trigger frag " << id - COIN_TRIG1_FRAG + 1 << ", " << size << " words found (hex)";
1439  for (c = 0; c < size; ++c) {
1440  if (c % 8 == 0) std::cout << setupMod << c/8<< ":";
1441  std::cout << std::hex << std::setw(11) << data[c] << std::dec;
1442  }
1443  std::cout << std::endl;
1444  break;
1445 
1446  default:
1447  std::cout << "\nUnknown fragment [0x" << std::hex << id << std::dec << "], " << size << " words found" << std::endl;
1448  break;
1449  }
1450  } else { // normal ROD fragments
1451 
1452  drawerMap_iterator itr = m_drawerMap.find(id);
1453  if (itr != m_drawerMap.end()) {
1454  fragType = (*itr).second;
1455  } else {
1456  fragType = (id >> 8);
1457  if (fragType > 4 || fragType < 1) fragType = 2; // assume barrel negative for unknown types
1458  }
1459 
1460  /* check for empty fragments */
1461  if (size > 0) {
1462 
1463  int DQstat;
1464 
1465  switch (type) {
1466  case 0: // digitizer fragment
1468  std::cout << "\nDigitizer fragment 0x" << std::hex << id << std::dec << ", " << size << " words found:"
1469  << "\t" << nchan / 3 << " chips, " << nsamp << "+2 samples" << std::endl;
1470 
1471  if (ngain == 1) {
1472  extra = size - nchan * (nsamp + 2) / 3;
1473  } else if (ngain == 2) {
1474  extra = size - nchan / 2 * (2 * nsamp + 3) / 3;
1475  } else {
1476  extra = 0;
1477  }
1478 
1479  if (version == 0x1 || version == 0x2) {
1480  std::cout << "\nfirst data word:" << std::setw(12) << data[0] << " (0x"<< setup0 << data[0] << setupDec << ")";
1481  --extra;
1482  }
1483 
1484  if (extra > 0) {
1485  std::cout << "\n" << std::setw(3) << extra << " extra words:";
1486  for (c = size - extra; c < size; ++c) {
1487  std::cout << std::setw(12) << data[c] << " (0x"<< setup0 << data[c] << setupDec << ")";
1488  if ((c - size + extra) % 2 == 1 && c!=size-1) std::cout << "\n ";
1489  }
1490  std::cout << std::endl;
1491  }
1492 
1493  std::cout << "\nPMT Ch | BCID M G";
1494  for (s = 0; s < nsamp; ++s) {
1495  std::cout << std::setw(4) << s << " ";
1496  }
1497 
1498  std::cout << " Head/Data/CRC\n---|---|-------------------------";
1499  for (s = 0; s < nsamp; ++s) {
1500  std::cout << "-----";
1501  }
1502 
1503  {
1504  bool OK = true;
1505  for (ch = 0; ch < nchan; ++ch) {
1506  pmt = m_cabling->channel2hole(fragType, ch % 48);
1507  if (extra == 0 && pmt < 0) pmt = -pmt;
1508 
1509  if (pmt > 0) {
1510  std::cout << "\n" << std::setw(3) << pmt << std::setw(3) << ch << " |";
1511  } else {
1512  std::cout << "\n -- " << std::setw(2) << ch << " |";
1513  }
1514 
1515  if (ch % 3 == 0) {
1516  std::cout << std::setw(5) << (channel[ch].bcid) << std::setw(2) << ((channel[ch].flag >> 3) & 3);
1517  } else {
1518  std::cout << " ";
1519  }
1520 
1521  std::cout << std::setw(2) << (channel[ch].gain);
1522 
1523  for (s = 0; s < nsamp; ++s) {
1524  std::cout << std::setw(5) << (channel[ch].sample[s]);
1525  }
1526 
1527  if (ch % 3 == 0) {
1528  if (channel[ch].head != 0) {
1529  std::cout << " 0x" << setup0 << channel[ch].head << setupDec << " Head";
1530  } else {
1531  std::cout << " " << setup0 << channel[ch].head << setupDec << " Head";
1532  }
1533  }
1534 
1535  if (ch % 3 == 1) {
1536  if (channel[ch].first != 0) {
1537  std::cout << " 0x" << setup0 << channel[ch].first << setupDec << " Data";
1538  } else {
1539  std::cout << " " << setup0 << channel[ch].first << setupDec << " Data";
1540  }
1541  }
1542 
1543  if (ch % 3 == 2) {
1544  if (channel[ch].crc != 0) {
1545  std::cout << " 0x" << setup0 << channel[ch].crc << setupDec << " CRC ";
1546  } else {
1547  std::cout << " " << setup0 << channel[ch].crc << setupDec << " CRC ";
1548  }
1549  }
1550 
1551  /*
1552  if (ch < 48) {
1553  int s[7];
1554  for (int i = 0; i < 7; i++) {
1555  s[i] = channel[ch].sample[i];
1556  }
1557  int gain = channel[ch].gain;
1558  int ene_ctrl = m_rc2bytes5.amplitude(ofw, unit, ch, gain, s);
1559  if (ene_ctrl < 0) ene_ctrl = 0;
1560  if (ene_ctrl > 0x7FFF) ene_ctrl = 0x7FFF;
1561  std::cout << " | " << std::setw(5) << ene_ctrl << std::setw(6) << recocalib[ch].amp);
1562  if (recocalib[ch].amp != ene_ctrl) { OK = false; std::cout << ": ERROR"; }
1563  }
1564  */
1565  if (isFrag5) {
1566  bool chOK = true;
1567  for (int i = 0; i < 7; i++) {
1568  if (Frag5Data[ch].s[i] != channel[ch].sample[i]) chOK = false;
1569  }
1570  if (!chOK) {
1571  std::cout << " RawERR ";
1572  m_rc2bytes5.print_code(Frag5Data[ch].code);
1573  std::cout << " | ";
1574  for (int i = 0; i < 7; i++) {
1575  std::cout << std::setw(5) << Frag5Data[ch].s[i] ;
1576  }
1577  }
1578  }
1579  }
1580  if (!OK) std::cout << "\nOF weights: ERROR";
1581  }
1582 
1583  if (isFrag5) {
1584  std::cout << std::endl;
1585  bool OK = true;
1586  for (int ch = 0; ch < 48; ch++) {
1587  bool chOK = true;
1588  for (int i = 0; i < 7; i++) {
1589  if (Frag5Data[ch].s[i] != channel[ch].sample[i]) chOK = false;
1590  }
1591  //uint32_t* ofc = ofw + (ch*2 + channel[ch].gain)*22;
1592  //int16_t a4 = ofc[2] & 0xFFFF;
1593  //if (abs(a4) < 16000) chOK = true;
1594  //if (!chOK) {
1595  // OK = false;
1596  // std::cout <<" " << ch << std::hex << std::setfill('0');
1597  // for (int i = 0; i < 22; i++) {
1598  // std::cout << " 0x" << std::setw(8) << ofc[i] << ",";
1599  // }
1600  // std::cout << std::dec << std::setfill(' ') << std::endl;
1601  //}
1602  if (Frag5Data[ch].gain != (int) channel[ch].gain) chOK = false;
1603  if (!chOK) {
1604  OK = false;
1605  std::cout << " " << ch << ",";
1606  }
1607  }
1608  std::cout << "\nCompare Raw <=> Frag5: ";
1609  if (OK) {
1610  std::cout << "OK" << std::endl;
1611  } else {
1612  std::cout << "ERROR" << std::endl;
1613  }
1614  isFrag5 = false;
1615  }
1616  break;
1617 
1618  case 1:
1619  if (tile_unpack_raw_comp(frag[f], rawcomp, MAX_DIGI_CHAN, version, verbosity, &ngain, &nchan, &nsamp)) {
1620  std::cout << "\nRaw data compressed fragment 0x" << std::hex << id << std::dec << ", " << size << " words found" << std::endl;
1622  break;
1623  }
1624 
1625  std::cout << "\nRaw data compressed fragment 0x" << std::hex << id << std::dec << ", " << size << " words found:"
1626  << "\t" << ngain << " gain, " << nchan << " channels in total" << std::endl;
1627 
1628  std::cout << "\nPMT Ch |";
1629  for (int j = 1; j <= ((nsamp / 2) + 1); j++) {
1630  std::cout << " HexWord" << j << " ";
1631  }
1632 
1633  std::cout << "| G";
1634  for (int l = 1; l <= nsamp; l++) {
1635  std::cout << " Smp" << l;
1636  }
1637 
1638  for (int i = 0; i < nchan && i < MAX_DIGI_CHAN; i++) {
1639  int ch = rawcomp[i].chan;
1640  pmt = m_cabling->channel2hole(fragType, ch % 48);
1641  if (pmt > 0) {
1642  std::cout << "\n" << std::setw(3) << pmt << std::setw(3) << ch << " |";
1643  } else {
1644  std::cout << "\n -- " << std::setw(2) << ch << " |";
1645  }
1646  std::cout << std::hex << std::setfill('0');
1647  for (int j = 0; j < ((nsamp / 2) + 1); j++) {
1648  std::cout << " " << std::setw(8) << rawcomp[i].words[j] << " ";
1649  }
1650  std::cout << setupDec << "| " << rawcomp[i].gain;
1651  for (int l = 0; l < nsamp; l++) {
1652  std::cout << std::setw(6) << rawcomp[i].samples[l];
1653  }
1654  if (!rawcomp[i].verif) std::cout << " Wrong Data";
1655  }
1656  break;
1657 
1658  case 2: // fragment with gain/amp/time/quality in 32 bit words
1659  tile_unpack_reco(frag[f], recochan, MAX_DIGI_CHAN, version, verbosity, &ngain, &nchan);
1660 
1661  std::cout << "\nReco non calibrated energy fragment 0x" << std::hex << id << std::dec << ", " << size << " words found:"
1662  << "\t" << ngain << " gain, " << nchan << " channels in total" << std::endl
1663  << "\tATTENTION: HIGH gain amplitude is divided by 64" << std::endl;
1664 
1665  std::cout << "\nPMT Ch | full word | G amp time q amp time qual";
1666  for (ch = 0; ch < nchan; ++ch) {
1667  pmt = m_cabling->channel2hole(fragType, ch % 48);
1668  if (pmt > 0) {
1669  std::cout << "\n" << std::setw(3) << pmt << std::setw(3) << ch << " |";
1670  } else {
1671  std::cout << "\n -- " << std::setw(2) << ch << " |";
1672  }
1673  std::cout << " 0x" << setup0 << recochan[ch].word << setupDec << " | "
1674  << std::setw(1) << recochan[ch].gain << std::setw(6) << recochan[ch].amp << std::setw(5) << recochan[ch].time
1675  << std::setw(3) << recochan[ch].quality << std::setw(10) << std::setprecision(1) << float (recochan[ch].gain ? recochan[ch].d_amp / 64. : recochan[ch].d_amp)
1676  << std::setw(11) << std::setprecision(4) << (float) recochan[ch].d_time << std::setw(8) << std::setprecision(1) << (float) recochan[ch].d_quality;
1677  }
1678 
1679  break;
1680 
1681  case 4: // fragment with gain/amp/time/bad/quality in 32 bit words
1682  m_unit = unit;
1684  &nchan);
1685 
1686  std::cout << "\nReco calibrated energy fragment 0x" << std::hex << id << std::dec << ", " << size << " words found:"
1687  << "\t" << ((nchan > 48 && nchan < 96) ? 1 : ngain) << " gain, " << unitName[unit].c_str() << " units, " << nchan << " channels in total" << std::endl;
1688 
1689  if (pulse < 3) {
1690  std::cout << "Reco flags: 0x" << std::hex << std::setfill('0') << rflag << setupDec << " units: " << unitName[unit].c_str() << " pulse_shape: " << shapeName[pulse].c_str() << " nsamples: " << 7 + 2 * nsmpl << " algorithm: " << algName[algor + 1].c_str() << " niterations: " << niter << std::endl;
1691  } else {
1692  std::cout << "Reco flags: 0x" << std::hex << std::setfill('0') << rflag << setupDec << " units: " << unitName[unit].c_str() << " pulse_shape: " << shapeName[pulse].c_str() << " nsamples: " << 7 + 2 * nsmpl << " algorithm: " << algName[algor * 4 + niter].c_str() << std::endl;
1693  }
1694 
1695  std::cout << "\nPMT Ch | full word | G amp time b q amp time qual";
1696  for (ch = 0; ch < nchan; ++ch) {
1697  pmt = m_cabling->channel2hole(fragType, ch % 48);
1698  if (pmt > 0) {
1699  std::cout << "\n" << std::setw(3) << pmt << std::setw(3) << ch << " |";
1700  } else {
1701  std::cout << "\n -- " << std::setw(2) << ch << " |";
1702  }
1703 
1704  if (ch >= 48 && nchan < 96) { // sumE words
1705  std::cout << " 0x" << setup0 << recocalib[ch].word << setupDec << " | " << std::setw(11) << std::setprecision(4) << Frag5_unpack_bin2sum(unit, (int )recocalib[ch].word);
1706  } else {
1707  std::cout << " 0x" << setup0 << recocalib[ch].word << setupDec << " | " << std::setw(1) << recocalib[ch].gain << std::setw(6) << recocalib[ch].amp << std::setw(5) << recocalib[ch].time << std::setw(2) << recocalib[ch].bad << std::setw(3) << recocalib[ch].quality << std::setw(10) << std::setprecision(1) << recocalib[ch].d_amp << std::setw(11) << std::setprecision(4) << recocalib[ch].d_time << std::setw(8) << std::setprecision(1) << recocalib[ch].d_quality;
1708 
1709  if (recocalib[ch].bad != 0) {
1710  std::cout << " Bad channel";
1711  }
1712  }
1713  }
1714 
1715  break;
1716 
1717  case 5: // compressed fragment
1718  {
1719  isFrag5 = true;
1720  m_frag5found = true;
1721  m_unit = unit;
1722  nchan = 48;
1723  OFC.clear();
1724 
1725  std::cout << "\nFrag5 Compressed fragment 0x" << std::hex << id << std::dec << ", " << size << " words found:"
1726  << "\t" << 1 << " gain, " << unitName[unit].c_str() << " units, " << nchan << " channels in total" << std::endl;
1727 
1729 
1730  { // fill OFC
1732  unsigned int drawerIdx = TileCalibUtils::getDrawerIdxFromFragId(id);
1733 
1734  bool of2 = true;
1735  std::vector<double> a(7), b(7), c(7), g(7), dg(7);
1736 
1737  for (ch = 0; ch < nchan; ++ch) {
1738  for (int gain = 0; gain < 2; ++gain) {
1739  float phase = -m_tileToolTiming->getSignalPhase(drawerIdx, ch, gain);
1741  if (m_tileCondToolOfcCool->getOfcWeights(drawerIdx, ch, gain, phase, of2, weights, ctx).isFailure())
1742  {
1743  ATH_MSG_ERROR( "getOfcWeights failed.");
1744  continue;
1745  }
1746 
1747  double calib = m_tileToolEmscale->channelCalibOnl(drawerIdx, ch, gain, 1.0, chan_unit);
1748 
1749  if (unit != 0 && gain) calib = calib * 64.0;
1750 
1751  for (int i = 0; i < 7; ++i) {
1752  a[i] = weights.w_a[i];
1753  b[i] = weights.w_b[i];
1754  c[i] = weights.w_c[i];
1755  g[i] = weights.g[i];
1756  dg[i] = weights.dg[i];
1757  }
1758 
1759  Format6(a, b, c, g, dg, ch // channel
1760  , 0 // phase = 0 poskol'ku ne ponyal kak okruglyat'
1761  , calib // calibration
1762  , OFC, false );// verbose
1763 
1764  } // gain
1765  } // ch
1766 
1767  } // fill OFC
1768  ofw = &(OFC[0]);
1769 
1770  int size_L2 = (*((const uint32_t*) data - 3 + 2) >> (32 - 2 - 3)) & 0x7;
1771  std::cout << "size_L2: " << size_L2 << " |";
1772  if (size_L2 == 3) {
1773  double SumEt = m_rc2bytes5.getSumEt((const uint32_t*) data - 3);
1774  double SumEz = m_rc2bytes5.getSumEz((const uint32_t*) data - 3);
1775  double SumE = m_rc2bytes5.getSumE((const uint32_t*) data - 3);
1776  std::cout << " SumEt: " << SumEt << ", SumEz: " << SumEz << ", SumE: " << SumE << std::endl;
1777  }
1778  std::cout << std::endl;
1779 
1780  m_rc2bytes5.unpack(ofw, (uint32_t*) data - 3, Frag5Data);
1781 
1782 #define code_ped4 TileRawChannel2Bytes5::code_ped4
1783 #define code_ped5 TileRawChannel2Bytes5::code_ped5
1784 #define code_amp5 TileRawChannel2Bytes5::code_amp5
1785 #define code_amp6 TileRawChannel2Bytes5::code_amp6
1786 #define code_raws TileRawChannel2Bytes5::code_raws
1787 #define code_rawf TileRawChannel2Bytes5::code_rawf
1788 #define code_full TileRawChannel2Bytes5::code_full
1789 #define code_dump TileRawChannel2Bytes5::code_dump
1790 #define code_null TileRawChannel2Bytes5::code_null
1791 
1792  int cnt_ped4, cnt_ped5, cnt_amp5, cnt_amp6, cnt_raws, cnt_rawf, cnt_full, cnt_dump, cnt_null;
1793  cnt_ped4 = cnt_ped5 = cnt_amp5 = cnt_amp6 = cnt_raws = cnt_rawf = cnt_full = cnt_dump = cnt_null = 0;
1794  std::cout << "PMT Ch | full word | Type G B ectrl ereco ebin ene time | s1 s2 s3 s4 s5 s6 s7";
1795 
1796  const char *strcode_empty = "----";
1797  const char *strcode_ped4 = "ped4";
1798  const char *strcode_ped5 = "ped5";
1799  const char *strcode_amp5 = "amp5";
1800  const char *strcode_amp6 = "amp6";
1801  const char *strcode_raws = "raws";
1802  const char *strcode_rawf = "rawf";
1803  const char *strcode_full = "full";
1804  const char *strcode_dump = "dump";
1805  const char *strcode_null = "null";
1806  const char *strcode_error = "ERR ";
1807 
1808  bool OK = true;
1809  for (ch = 0; ch < nchan; ++ch) {
1810  pmt = m_cabling->channel2hole(fragType, ch % 48);
1811  if (pmt > 0) {
1812  std::cout << "\n" << std::setw(3) << pmt << std::setw(3) << ch << " |";
1813  } else {
1814  std::cout << "\n -- " << std::setw(2) << ch << " |";
1815  }
1816 
1817  uint32_t reco = data[ch];
1818  const char *scode = strcode_empty;
1819  int code = Frag5Data[ch].code;
1820  int gain = Frag5Data[ch].gain;
1821  int bad = Frag5Data[ch].bad;
1822  int ene_bin = Frag5Data[ch].ene_bin;
1823  float ene = Frag5Data[ch].ene;
1824  float time = Frag5Data[ch].time;
1825  int s[7];
1826  for (int i = 0; i < 7; i++) {
1827  s[i] = Frag5Data[ch].s[i];
1828  }
1829 
1830  switch (code) {
1831  case code_ped4: scode = strcode_ped4; cnt_ped4++; break;
1832  case code_ped5: scode = strcode_ped5; cnt_ped5++; break;
1833  case code_amp5: scode = strcode_amp5; cnt_amp5++; break;
1834  case code_amp6: scode = strcode_amp6; cnt_amp6++; break;
1835  case code_raws: scode = strcode_raws; cnt_raws++; break;
1836  case code_rawf: scode = strcode_rawf; cnt_rawf++; break;
1837  case code_full: scode = strcode_full; cnt_full++; break;
1838  case code_dump: scode = strcode_dump; cnt_dump++; break;
1839  case code_null: scode = strcode_null; cnt_null++; break;
1840  default: scode = strcode_error; break;
1841  }
1842 
1843  int ene_recobin = ene_bin + (gain == 0 ? 512 : 2048);
1844  switch (code) {
1845  case code_ped4:
1846  case code_ped5:
1847  ene_bin += 256;
1848  break;
1849  case code_amp5:
1850  case code_amp6:
1851  case code_raws:
1852  case code_rawf:
1853  ene_bin += (gain == 0 ? 512 : 2048);
1854  break;
1855  }
1856 
1857  int ene_ctrl = m_rc2bytes5.amplitude(ofw, unit, ch, gain, s);
1858  if (ene_ctrl < 0) {
1859  ene_ctrl = 0;
1860  } else if (ene_ctrl > 0x7FFF) {
1861  ene_ctrl = 0x7FFF;
1862  }
1863 
1864  std::cout << " 0x" << setup0 << reco << setupDec << " | " << std::setw(4) << scode << " " << gain << " " << bad;
1865 
1866  switch (code) {
1867  case code_ped4:
1868  case code_ped5:
1869  case code_raws:
1870  case code_rawf:
1871  case code_dump:
1872  std::cout << std::setw(7) << ene_ctrl << std::setw(7) << ene_recobin << std::setw(6) << ene_bin << std::setw(10) << std::setprecision(4) << ene << " -- ";
1873  break;
1874  case code_amp5:
1875  case code_amp6:
1876  std::cout << std::setw(7) << ene_ctrl << std::setw(7) << ene_recobin << std::setw(6) << ene_bin << std::setw(10) << std::setprecision(4) << ene << std::setw(6) << std::setprecision(1) << time << " ";
1877  break;
1878  case code_full:
1879  case code_null:
1880  std::cout << " ----- ----- ---- --- -- ";
1881  break;
1882  default:;
1883  }
1884 
1885  std::cout << "| " << std::setw(4) << s[0] << std::setw(5) << s[1] << std::setw(5) << s[2] << std::setw(5) << s[3] << std::setw(5) << s[4] << std::setw(5) << s[5] << std::setw(5) << s[6] << " " ;
1886  if (ene_ctrl != ene_recobin) {
1887  OK = false;
1888  std::cout << " ERR";
1889  }
1890  }
1891 
1892  std::cout << "\n\nFrag5 Self-Consistency: ";
1893  if (OK) {
1894  std::cout << "OK" << std::endl;
1895  } else {
1896  std::cout << "ERROR" << std::endl;
1897  }
1898 
1899  std::cout << "\nped4" << cnt_ped4 << ", ped5 " << cnt_ped5 << ", amp5 " << cnt_amp5 << ", amp6 " << cnt_amp6 << ", raws " << cnt_raws << ", rawf " << cnt_rawf << ", full " << cnt_full << ", dump " << cnt_dump << ", null " << cnt_null << std::endl;
1900 
1901  break;
1902  }
1903 
1904  case 6:
1905  {
1906  std::cout << "\nFELIX fragment 0x" << std::hex << id << std::dec << ", " << size << " words found" << std::endl;
1907  std::vector<uint32_t> correct_data = get_correct_data(data, size);
1908  // dump first few words of the first MD fragment
1909  int head = 9;
1910  std::cout << std::hex << std::endl;
1911  bool phase2format = (size>head && correct_data[2] == 0x12345678 && correct_data[size-1] == 0x87654321);
1912  if (phase2format) {
1913  int thisVersion = (((correct_data[3] >> 16) & 0xFFFF) == 0) ? 1 : 0;
1914  const char * namesV0[] = { "size_packet", "elink", "SOP", "runParam1", "runParam2", "runParam3", "runParam4", "BC_MD_ID", "L1ID" };
1915  const char * namesV1[] = { "size_packet", "elink", "SOP", "version", "MODULE_BC_MD", "L1ID", "BCR" , "runParam1", "runParam2", "runParam3"};
1916  const char ** names = (thisVersion) ? namesV1 : namesV0;
1917  if (thisVersion) head = 10;
1918  for (int i=0; i<head; ++i) {
1919  std::cout << std::setw(13) << names[i] << std::setw(10) << correct_data[i] << std::endl;
1920  }
1921  } else {
1922  if (head>size) head=size;
1923  for (int i=0; i<head; ++i) {
1924  std::cout << " Word" << std::setw(3) << i << std::setw(10) << correct_data[i] << std::endl;
1925  }
1926  }
1927  std::cout << std::dec << std::endl;
1928  FelixData_t digitsHighGain, digitsLowGain, digitsMetaData;
1929  unpack_frag6(correct_data.data(), size, digitsHighGain, digitsLowGain, digitsMetaData);
1930 
1931  std::cout << " MD1 MD2 MD3 MD4" << std::endl;
1932  std::cout << "-----------------------------------------------------";
1933  const char * metaNamesV0[] = { "BCID", "L1ID", "ModuleID", "RunType", "RunNumber", "PedHi", "PedLo", "ChargeInj", "TimeInj", "Capacitor", "ECR" };
1934  const char * metaNamesV1[] = { "BCID", "L1ID", "ModuleID", "RunType", "RunNumber", "PedHi", "PedLo", "ChargeInj", "TimeInj", "Capacitor", "ECR", "BCR", "Version", "FragID" };
1935  const char ** metaNames = (version) ? metaNamesV1 : metaNamesV0;
1936  for (size_t i = 0; i < digitsMetaData.size(); ++i) {
1937  std::cout << std::endl << std::setw(13) << metaNames[i];
1938  for (size_t j = 0; j<digitsMetaData[i].size(); ++j) {
1939  std::cout << std::setw(10) << digitsMetaData[i][j];
1940  }
1941  }
1942  std::cout << std::endl << std::endl;
1943 
1944  size_t nsamp = 7;
1945  if (digitsLowGain[0].size()>0)
1946  nsamp = std::max(nsamp,digitsLowGain[0].size());
1947  if (digitsHighGain[0].size()>0)
1948  nsamp =std::max(nsamp,digitsHighGain[0].size());
1949 
1950  std::cout << " ch G ";
1951  for (size_t s = 0; s < nsamp; ++s) {
1952  std::cout << std::setw(5) << s;
1953  }
1954  std::string a(8+nsamp*5,'-');
1955  std::cout << std::endl << a;
1956 
1957  for (size_t ch = 0; ch < digitsHighGain.size() ; ++ch) {
1958  std::cout << std::endl << std::setw(3) << ch << " HG ";
1959  for (size_t s = 0; s < digitsHighGain[ch].size(); ++s) {
1960  std::cout << std::setw(5) << (digitsHighGain[ch][s]);
1961  }
1962  }
1963 
1964  for (size_t ch = 0; ch < digitsLowGain.size() ; ++ch) {
1965  std::cout << std::endl << std::setw(3) << ch << " LG ";
1966  for (size_t s = 0; s < digitsLowGain[ch].size(); ++s) {
1967  std::cout << std::setw(5) << (digitsLowGain[ch][s]);
1968  }
1969  }
1970  std::cout << std::endl << std::endl;
1971 
1972  break;
1973  }
1974 
1975  case 0xA: // fragment with data quality words
1976  DQstat = tile_unpack_quality(frag[f], DQword);
1977 
1978  std::cout << "\nQuality fragment 0x" << std::hex << id << ", " << std::dec << size << " words found:" << std::endl;
1979 
1980  if (DQstat) {
1981  std::cout << " ATTENTION: Error bits found in the Data Quality fragment 0xA" << std::endl;
1982  }
1983 
1984  std::cout << " --------------------------------------" << std::endl;
1985  std::cout << " | Quality Block | Word (16bit)" << std::endl;
1986  if (DQword.dspbcid >> 15) {
1987  std::cout << " | DSP BCID | " << std::dec << (DQword.dspbcid & 0x7FFF) << std::endl;
1988  } else {
1989  std::cout << " | DSP BCID | not filled (" << std::dec << DQword.dspbcid << ")" << std::endl;
1990  }
1991  std::cout << " | Global CRC | " << std::hex << "0x" << std::setw(1) << DQword.global_crc << std::setfill('0') << std::endl;
1992  std::cout << " | BCID checks | " << setup0x4 << DQword.bcid << std::endl;
1993  std::cout << " | Mem parity err | " << setup0x4 << DQword.memory << std::endl;
1994  std::cout << " | Single strobe err | " << setup0x4 << DQword.Sstrobe << std::endl;
1995  std::cout << " | Double strobe err | " << setup0x4 << DQword.Dstrobe << std::endl;
1996  std::cout << " | Head format err | " << setup0x4 << DQword.headformat << std::endl;
1997  std::cout << " | Head parity err | " << setup0x4 << DQword.headparity << std::endl;
1998  std::cout << " | Sample format err | " << setup0x4 << DQword.sampleformat << std::endl;
1999  std::cout << " | Sample parity err | " << setup0x4 << DQword.sampleparity << std::endl;
2000  std::cout << " | FE chip mask err | " << setup0x4 << DQword.fe_chip_mask << std::endl;
2001  std::cout << " | ROD chip mask err | " << setup0x4 << DQword.rod_chip_mask << std::endl;
2002  std::cout << " --------------------------------------" << std::setfill(' ') << std::dec << std::endl;
2003  break;
2004 
2005  default:
2006  std::cout << "\nUnknown (type " << type << ") fragment 0x" << std::hex << id << ", " << std::dec << size << " words found" << std::endl;
2007  dump_data((uint32_t*) data, size, version, verbosity); // Salukvadze
2008  }
2009  std::cout << std::endl;
2010  } else { /* empty fragment */
2011  std::cout << "\nType " << type << " fragment 0x" << std::hex << id << ", " << std::dec << size << " words found" << std::endl;
2012  std::cout << "\nEmpty Event" << std::endl;
2013  }
2014  }
2015  }
2016 }
2017 
2018 void dump_it(unsigned int nw, unsigned int * data) {
2019 
2020  unsigned int i;
2021 
2022  std::cout << "size of data block: " << nw << std::endl;
2023  for (i = 0; i < nw; i++, data++) {
2024  std::cout << std::setw(4) << i << ": 0x" << std::hex << std::setw(8) << *data << "\t" << std::dec << std::setw(10) << *data << std::endl;
2025  }
2026 }
2027 
2028 /* ------------------------------------------------------------------------ */
2029 
2030 void TileTBDump::find_frag(const uint32_t* data, unsigned int size, unsigned int version
2031  , int verbosity, const T_RodDataFrag* frag[], int& nfrag) {
2032  unsigned int offset = 0;
2033  nfrag = 0;
2034  m_v3Format = (*(data) == 0xff1234ff); // additional frag marker since Sep 2005
2035  m_v3Format |= (*(data) == 0x00123400); // another possible frag marker (can appear in buggy ROD frags)
2036  if (m_v3Format || (version > 0xff)) {
2037  m_sizeOverhead = 3;
2038  ++offset; // skip frag marker
2039  std::cout << " *(p) = 0x" << std::hex << (*(data)) << std::dec << ((m_v3Format)?"":" => ERROR Corrupted frag separator") << std::endl;
2040  std::cout << " v3Format = true" << std::endl;
2041  if (!m_v3Format) {
2042  m_v3Format = true;
2043  std::cout << std::endl << "Dump of whole data fragment ("
2044  << size << " words)" << std::endl;
2046  }
2047  } else {
2048  m_sizeOverhead = 2;
2049  }
2050 
2051  while (offset < size && nfrag < MAX_ROD_FRAG) {
2052  //std::cout << "nfrag="<<(nfrag) << " offset="<<offset<<" data[offset]="<<data[offset]<<std::endl;
2053  frag[nfrag] = (const T_RodDataFrag *) (data + offset);
2054 
2055  if (frag[nfrag]->size < m_sizeOverhead
2056  || frag[nfrag]->size > size - offset + m_sizeOverhead - 2) {
2057 
2058  std::cout << "\nWarning: garbage in frag " << nfrag << " of current ROD -> ignore it" << std::endl;
2059  std::cout << "Size: \t" << std::setw(10) << (frag[nfrag]->size) << "\tMin/Max Size: \t" << std::setw(10) << m_sizeOverhead << "\t" << std::setw(10) << size - offset + m_sizeOverhead - 2 << std::endl;
2060  std::cout << "Id: \t" << std::setw(10) << (frag[nfrag]->id) << std::endl;
2061  std::cout << "Bad data:" << std::endl;
2062  std::cout << "Before:\t" << offset-1 << "\t" << data[offset-1] << "\t0x" << std::hex << data[offset-1] << std::dec << std::endl;
2063 
2064  for (; offset < size; ++offset) {
2065  std::cout << "\t" << offset << "\t" << data[offset] << "\t0x" << std::hex << data[offset] << std::dec << std::endl;
2066  if (data[offset] == 0xff1234ff || data[offset] == 0x00123400) break;
2067  }
2068  if (offset == size) {
2069  std::cout << "After:\t" << offset << "\t" << data[offset] << "\t0x" << std::hex << data[offset] << std::dec << std::endl;
2070  }
2071  if (m_v3Format) {
2072  ++offset; // go to next good frag or jump outside ROD, if at the end
2073  }
2074 
2075  } else if (frag[nfrag]->size < size - offset && m_v3Format && data[offset + frag[nfrag]->size - 1] != 0xff1234ff && data[offset + frag[nfrag]->size - 1] != 0x00123400) {
2076 
2077  std::cout << "\nWarning: frag " << nfrag << " of current ROD is damaged" << std::endl;
2078  std::cout << "Size: \t" << std::setw(10) << (frag[nfrag]->size) << "\tMin/Max Size: \t" << std::setw(10) << m_sizeOverhead << "\t" << std::setw(10) << size - offset + m_sizeOverhead - 2 << std::endl;
2079  std::cout << "Id: \t" << std::setw(10) << (frag[nfrag]->id) << std::endl;
2080  std::cout << "Bad data:" << std::endl;
2081  unsigned int newsize = 0;
2082  std::cout << "Before:\t" << offset-1 << "\t" << data[offset-1] << "\t0x" << std::hex << data[offset-1] << std::dec << std::endl;
2083  for (; offset < size; ++offset, ++newsize) {
2084  std::cout << "\t" << offset << "\t" << data[offset] << "\t0x" << std::hex << data[offset] << std::dec << std::endl;
2085  if (data[offset] == 0xff1234ff || data[offset] == 0x00123400) break;
2086  }
2087  if (offset == size) {
2088  std::cout << "After:\t" << offset << "\t" << data[offset] << "\t0x" << std::hex << data[offset] << std::dec << std::endl;
2089  }
2090  if (m_v3Format) {
2091  ++newsize;
2092  ++offset; // go to next good frag or jump outside ROD, if at the end
2093  }
2094  std::cout << "Correct size is:\t" << std::setw(10) << newsize << std::endl;
2095 
2096  } else {
2097  offset += frag[nfrag]->size;
2098  // if (version == 0x1 && offset < size) offset += 7; // skip extra header - was needed for 2001-2003 TB data only
2099  ++nfrag;
2100  }
2101  }
2102 
2103  if (m_v3Format) {
2104  --offset; // set offset back to correct value
2105  }
2106 
2107  if (offset > size) {
2108  --nfrag;
2109  std::cout << "\nWarning: last fragment in current ROD is garbage -> ignore it" << std::endl;
2110  std::cout << "N good frag: \t" << std::setw(10) << nfrag << std::endl;
2111  std::cout << "Last frag:" << std::endl;
2112  for (unsigned int i = offset - frag[nfrag]->size; i < size; ++i) {
2113  std::cout << "\t" << i << "\t" << data[i] << "\t0x" << std::hex << data[i] << std::dec << std::endl;
2114  }
2115  }
2116 }
2117 
2118 /* ------------------------------------------------------------------------ */
2119 void TileTBDump::unpack_frag6(const uint32_t* data, unsigned int size,
2120  FelixData_t & digitsHighGain,
2121  FelixData_t & digitsLowGain,
2122  FelixData_t & digitsMetaData) const
2123 {
2124 
2125  using Tile = TileCalibUtils;
2126  std::vector<unsigned int> bcid(Tile::MAX_MINIDRAWER);
2127  std::vector<unsigned int> l1id(Tile::MAX_MINIDRAWER);
2128  std::vector<unsigned int> moduleID(Tile::MAX_MINIDRAWER);
2129  std::vector<unsigned int> runType (Tile::MAX_MINIDRAWER);
2130  std::vector<unsigned int> runNumber(Tile::MAX_MINIDRAWER);
2131  std::vector<unsigned int> pedestalHi(Tile::MAX_MINIDRAWER);
2132  std::vector<unsigned int> pedestalLo(Tile::MAX_MINIDRAWER);
2133  std::vector<unsigned int> chargeInjected(Tile::MAX_MINIDRAWER);
2134  std::vector<unsigned int> timeInjected(Tile::MAX_MINIDRAWER);
2135  std::vector<unsigned int> capacitor(Tile::MAX_MINIDRAWER);
2136  std::vector<unsigned int> ecr(Tile::MAX_MINIDRAWER);
2137  std::vector<unsigned int> bcr(Tile::MAX_MINIDRAWER);
2138  std::vector<unsigned int> packetVersion(Tile::MAX_MINIDRAWER);
2139  std::vector<unsigned int> fragmentID(Tile::MAX_MINIDRAWER);
2140 
2141  digitsHighGain.clear();
2142  digitsLowGain.clear();
2143  digitsMetaData.clear();
2144 
2145  int version = 0;
2146  int mdFragmentSize = (*data) & 0xFFFF;
2147  int sampleNumber = mdFragmentSize / Tile::MAX_MINIDRAWER_CHAN;
2148 
2149  const uint32_t* const end_data = data + size;
2150  while (data < end_data) {
2151  if (*data == 0x12345678 ) {
2152  mdFragmentSize = (*(data - 2)) & 0xFFFF;
2153 
2154  if ((++data < end_data)) {
2155  version = (((*data >> 16) & 0xFFFF) == 0) ? 1 : 0;
2156 
2157  int mdSizeOverhead = (version == 0) ? 10 : 11;
2158  int delta = mdFragmentSize - (sampleNumber * Tile::MAX_MINIDRAWER_CHAN + mdSizeOverhead);
2159  if (delta != 0) {
2160  ATH_MSG_WARNING( "FRAG6: Unexpected MD fragment size " << mdFragmentSize << " => "
2161  << sampleNumber << " samples will be unpacked and last "
2162  << delta << " words will be ignored ");
2163  }
2164  unsigned int miniDrawer = -1;
2165 
2166  // find MD trailer
2167  const uint32_t* trailer = data + mdFragmentSize - 4;
2168  if (trailer < end_data && *trailer == 0x87654321) {
2169  unsigned int paramsSize = 3;
2170 
2171  if (version == 0) {
2172  unsigned int fragSize = *data & 0xFF;
2173  paramsSize = (*data >> 8 ) & 0xFF;
2174 
2175  miniDrawer = *(data + 4) & 0xFF;
2176  moduleID[miniDrawer ] = (*data >> 16) & 0xFF;
2177  runType[miniDrawer] = (*data >> 24) & 0xFF;
2178 
2179  if (fragSize != sampleNumber * Tile::MAX_MINIDRAWER_CHAN) {
2180  std::cout << "Minidrawer [" << miniDrawer
2181  << "] has unexpected fragment size: " << fragSize
2182  << " correct value for " << sampleNumber
2183  << " samples is " << sampleNumber * Tile::MAX_MINIDRAWER_CHAN << std::endl;
2184  }
2185 
2186  if (paramsSize == 3){
2187  runNumber[miniDrawer] = *(++data);
2188 
2189  pedestalLo[miniDrawer] = *(++data) & 0xFFF;
2190  pedestalHi[miniDrawer] = (*data >> 12 ) & 0xFFF;
2191 
2192  chargeInjected[miniDrawer] = *(++data) & 0xFFF;
2193  timeInjected[miniDrawer] = (*data >> 12) & 0xFF;
2194  capacitor[miniDrawer] = (*data >> 20) & 0x1;
2195  } else {
2196 
2197  std::cout << "Minidrawer [" << miniDrawer
2198  << "] has unexpected number of parameter words: " << paramsSize
2199  << " => ignore them !!!" << std::endl;
2200  data += paramsSize;
2201  }
2202 
2203  bcid[miniDrawer] = (*(++data) >> 16) & 0xFFFF;
2204  l1id[miniDrawer] = *(++data) & 0xFFFFFF;
2205  ecr[miniDrawer] = (*data >> 24) & 0xFF;
2206  } else {
2207  miniDrawer = *(data + 1) & 0xFF;
2208 
2209  packetVersion[miniDrawer] = (*data) & 0xFF;
2210  fragmentID[miniDrawer] = (*data >> 8) & 0xFF;
2211 
2212  bcid[miniDrawer] = (*(++data) >> 8) & 0xFFF;
2213  moduleID[miniDrawer] = (*data >> 20) & 0xFFF;
2214 
2215  l1id[miniDrawer] = *(++data) & 0xFFFFFF;
2216  ecr[miniDrawer] = (*data >> 24) & 0xFF;
2217 
2218  bcr[miniDrawer] = *(++data);
2219 
2220  if (packetVersion[miniDrawer] == 1) {
2221  pedestalLo[miniDrawer] = *(++data) & 0xFFF;
2222  pedestalHi[miniDrawer] = (*data >> 12 ) & 0xFFF;
2223  runType[miniDrawer] = (*data >> 24) & 0xFF;
2224 
2225  runNumber[miniDrawer] = *(++data);
2226  } else {
2227  runNumber[miniDrawer] = *(++data);
2228 
2229  pedestalLo[miniDrawer] = *(++data) & 0xFFF;
2230  pedestalHi[miniDrawer] = (*data >> 12 ) & 0xFFF;
2231  runType[miniDrawer] = (*data >> 24) & 0xFF;
2232  }
2233 
2234  chargeInjected[miniDrawer] = *(++data) & 0xFFF;
2235  timeInjected[miniDrawer] = (*data >> 12) & 0xFF;
2236  capacitor[miniDrawer] = (*data >> 20) & 0x1;
2237  }
2238 
2239 
2240 
2241  const uint16_t* sample = (const uint16_t *) (++data);
2242 
2243  size_t start_channel(miniDrawer * Tile::MAX_MINIDRAWER_CHAN);
2244  size_t end_channel(start_channel + Tile::MAX_MINIDRAWER_CHAN);
2245 
2246  if (end_channel > digitsHighGain.size()) digitsHighGain.resize(end_channel);
2247  for (size_t channel = start_channel; channel < end_channel; ++channel) {
2248  digitsHighGain[channel].resize(sampleNumber);
2249  for (int samplesIdx = 0; samplesIdx<sampleNumber; ++samplesIdx) {
2250  digitsHighGain[channel][samplesIdx] = (*sample & 0x0FFF);
2251  ++sample;
2252  }
2253  }
2254 
2255  if (end_channel > digitsLowGain.size()) digitsLowGain.resize(end_channel);
2256  for (size_t channel = start_channel; channel < end_channel; ++channel) {
2257  digitsLowGain[channel].resize(sampleNumber);
2258  for (int samplesIdx = 0; samplesIdx<sampleNumber; ++samplesIdx) {
2259  digitsLowGain[channel][samplesIdx] = (*sample & 0x0FFF);
2260  ++sample;
2261  }
2262  }
2263 
2264  data = ++trailer;
2265 
2266  } else {
2267  std::cout << "Wrong trailer for MD[" << miniDrawer << "] => skip MD fragment !!!" << std::endl;
2268  }
2269  }
2270  } else {
2271  ++data;
2272  }
2273  }
2274 
2275  digitsMetaData.push_back(bcid);
2276  digitsMetaData.push_back(l1id);
2277  digitsMetaData.push_back(moduleID);
2278  digitsMetaData.push_back(runType);
2279  digitsMetaData.push_back(runNumber);
2280  digitsMetaData.push_back(pedestalHi);
2281  digitsMetaData.push_back(pedestalLo);
2282  digitsMetaData.push_back(chargeInjected);
2283  digitsMetaData.push_back(timeInjected);
2284  digitsMetaData.push_back(capacitor);
2285  digitsMetaData.push_back(ecr);
2286  if (version) {
2287  digitsMetaData.push_back(bcr);
2288  digitsMetaData.push_back(packetVersion);
2289  digitsMetaData.push_back(fragmentID);
2290  }
2291 }
2292 
2293 
2294 /*--------------------------------------------------------------------------*/
2296  /*--------------------------------------------------------------------------*/
2297 // Errors are defined by a bit value of 1, while 0 means OK
2298  unsigned int status = 0;
2299 
2300  //int size = frag->size - m_sizeOverhead; /* size of the data part in the fragment */
2301  const unsigned int *data = frag->data; /* first word of data */
2302 
2303  unsigned int w;
2304  w = (*data);
2305  // std::cout << " word is 0x" << std::hex << std::setw(8)<< std::setfill('0') << w << std::endl;
2306  DQword.dspbcid = w >> 16; /* if upper bit is set, remaining bits are BCID set by DSP */
2307  DQword.global_crc = w & 0x1;
2308  status = status + DQword.global_crc;
2309 
2310  ++data;
2311  w = (*data);
2312 
2313  // std::cout << " word is 0x" << std::hex << std::setw(8)<< std::setfill('0') << w << std::endl;
2314 
2315  DQword.bcid = w & 0xFFFF; // least sign. bit means DMU00 versus TTC. The other 15 bits mean DMUXX versus DMU00
2316  DQword.memory = (w >> 16) & 0xFFFF;
2317 
2318  /* std::cout << " bcid is 0x" << std::hex << std::setw(8)<< std::setfill('0') << DQword.bcid << std::endl;
2319  std::cout << " memory is 0x" << std::hex << std::setw(8)<< std::setfill('0') << DQword.memory << std::endl;
2320  */
2321  status = status + DQword.memory;
2322 
2323  ++data;
2324  w = (*data);
2325  // std::cout << " word is 0x" << std::hex << std::setw(8)<< std::setfill('0') << w << std::endl;
2326  DQword.Sstrobe = w & 0xFFFF;
2327  DQword.Dstrobe = (w >> 16) & 0xFFFF;
2328  status = status + DQword.Dstrobe;
2329  /*
2330  std::cout << " Sstrobe is 0x" << std::hex << std::setw(8)<< std::setfill('0') << DQword.Sstrobe << std::endl;
2331  std::cout << " Dstrobe is 0x" << std::hex << std::setw(8)<< std::setfill('0') << DQword.Dstrobe << std::endl;
2332  */
2333 
2334  ++data;
2335  w = (*data);
2336  // std::cout << " word is 0x" << std::hex << std::setw(8)<< std::setfill('0') << w << std::endl;
2337  DQword.headformat = w & 0xFFFF; //bit 31
2338  DQword.headparity = (w >> 16) & 0xFFFF; // bit30, parity must be odd
2339 
2340  /*
2341  std::cout << " Head format is 0x" << std::hex << std::setw(8)<< std::setfill('0') << DQword.headformat << std::endl;
2342  std::cout << " Head parity is 0x" << std::hex << std::setw(8)<< std::setfill('0') << DQword.headparity << std::endl;
2343  */
2344 
2345  ++data;
2346  w = (*data);
2347  // std::cout << " word is 0x" << std::hex << std::setw(8)<< std::setfill('0') << w << std::endl;
2348  DQword.sampleformat = w & 0xFFFF;
2349  DQword.sampleparity = (w >> 16) & 0xFFFF;
2350 
2351  /*
2352  std::cout << " Sample format is 0x" << std::hex << std::setw(8)<< std::setfill('0') << DQword.sampleformat << std::endl;
2353  std::cout << " Sample parity is 0x" << std::hex << std::setw(8)<< std::setfill('0') << DQword.sampleparity << std::endl;
2354  */
2355 
2356  ++data;
2357  w = (*data);
2358  DQword.fe_chip_mask = (w & 0xFFFF); //do not invert to get the error mask
2359  DQword.rod_chip_mask = (w >> 16) & 0xFFFF; //do not invert to get the error mask
2360 
2361  /*
2362  std::cout << " fe mask is 0x" << std::hex << std::setw(8)<< std::setfill('0') << DQword.fe_chip_mask << std::endl;
2363  std::cout << " rod mask is 0x" << std::hex << std::setw(8)<< std::setfill('0') << DQword.rod_chip_mask << std::endl;
2364  */
2365 
2366  return status;
2367 }
2368 
2369 
2370 /*--------------------------------------------------------------------------*/
2372  , int nchannel_max, unsigned int /* version */
2373  , int /* verbosity */, int *ngain, int *nchannel) {
2374 /*--------------------------------------------------------------------------*/
2375 
2376  int status = 0;
2377 
2378  int size = frag->size - m_sizeOverhead; /* size of the data part in the fragment */
2379  const unsigned int *data = frag->data; /* first word of data */
2380 
2381  int ch = 0;
2382  for (; ch < size && ch < nchannel_max; ++ch) {
2383  unsigned int w = data[ch];
2384  channel[ch].chan = ch % 48;
2385  channel[ch].word = w;
2386  channel[ch].gain = (w >> GAIN_SHIFT2) & GAIN_RANGE2;
2388  channel[ch].time = (w >> TIME_SHIFT2) & TIME_RANGE2;
2389  channel[ch].quality = (w >> QUALITY_SHIFT2) & QUALITY_RANGE2;
2390  channel[ch].d_amp = m_rc2bytes2.amplitude(w);
2391  channel[ch].d_time = m_rc2bytes2.time(w);
2392  channel[ch].d_quality = m_rc2bytes2.quality(w);
2393  }
2394 
2395  *ngain = (size - 1) / 48 + 1;
2396  *nchannel = ch;
2397 
2398  return status;
2399 }
2400 
2401 
2402 
2403 /*--------------------------------------------------------------------------*/
2405  , int nchannel_max, unsigned int /* version */
2406  , unsigned int unit
2407  , int /* verbosity */, int *ngain, int *nchannel) {// Baxo
2408  /*--------------------------------------------------------------------------*/
2409 
2410  int status = 0;
2411 
2412  int size = frag->size - m_sizeOverhead; // size of the data part in the fragment
2413  const unsigned int *data = frag->data; // first word of data
2414 
2415  int ch = 0;
2416  for (; ch < size && ch < nchannel_max; ++ch) {
2417  unsigned int w = data[ch];
2418  recocalib[ch].chan = ch % 48;
2419  recocalib[ch].word = w;
2420  recocalib[ch].gain = (w >> GAIN_SHIFT4) & GAIN_RANGE4;
2421  recocalib[ch].amp = (w >> AMPLITUDE_SHIFT4) & AMPLITUDE_RANGE4;
2422  recocalib[ch].time = (w >> TIME_SHIFT4) & TIME_RANGE4;
2423  recocalib[ch].bad = ((w >> QUALITY_SHIFT4) & QUALITY_RANGE4 & 0x10) >> 4;
2424  recocalib[ch].quality = ((w >> QUALITY_SHIFT4) & QUALITY_RANGE4 & 0xF);
2425  recocalib[ch].d_amp = m_rc2bytes4.amplitude(w, unit);
2426  recocalib[ch].d_time = m_rc2bytes4.time(w);
2427  recocalib[ch].d_quality = m_rc2bytes4.quality(w);
2428  }
2429 
2430  *ngain = (size - 1) / 48 + 1;
2431  *nchannel = ch;
2432 
2433  return status;
2434 }
2435 
2436 
2437 /*--------------------------------------------------------------------------*/
2439  , int nchannel_max, unsigned int /* version */, int /* verbosity */
2440  , int* ngain, int* nchannel, int* nsample) {
2441 /*--------------------------------------------------------------------------*/
2442 
2443  int status = 0;
2444 
2445  int size = frag->size - m_sizeOverhead; // size of the data part in the fragment
2446  unsigned int id = frag->id;
2447  int frag1version = (id >> 31) & 0x1;
2448  int nbchanformat1 = (id >> 24) & 0x3F;
2449 
2450  if (frag1version == 0) { //Old version
2451 
2452  if ((size % 4) != 0) {
2453  std::cout << " Format Type 1: Raw compressed : Wrong Size = " << size << std::endl;
2454  status = 1;
2455  return status;
2456  }
2457 
2458  int nsamp = 7;
2459  int nchan = size / 4;
2460 
2461  *ngain = 1;
2462  *nchannel = nchan;
2463  *nsample = nsamp;
2464 
2465  const unsigned int *data = frag->data;
2466  int i = 0;
2467 
2468  if (data != 0) {
2469  for (int ch = 0; ch < nchan && ch < nchannel_max; ch++) {
2470  unsigned int w = data[i++];
2471  rawcomp[ch].words[0] = w;
2472  nsamp = ((w >> 8) & 0x0F);
2473  rawcomp[ch].chan = (w & 0xFF);
2474  rawcomp[ch].gain = (w >> 15) & 0x1;
2475  rawcomp[ch].samples[0] = (w >> 16);
2476  for (int j = 1; j < ((nsamp / 2) + 1); j++) {
2477  rawcomp[ch].words[j] = w = data[i++];
2478  for (int l = 1; l < nsamp; l += 2) {
2479  rawcomp[ch].samples[l] = (w & 0xFFFF);
2480  rawcomp[ch].samples[l + 1] = (w >> 16);
2481  }
2482  }
2483  rawcomp[ch].verif = (((*nsample) == nsamp) && (rawcomp[ch].chan < 48));
2484  if (!rawcomp[ch].verif) {
2485  status = 1;
2486  std::cout << " Verification ERROR for channel # " << ch << " (ch=" << rawcomp[ch].chan << " g=" << rawcomp[ch].gain << " ns=" << nsamp << " 0x" << std::hex << (rawcomp[ch].words[0] & 0xFFFF) << std::dec << ")!" << std::endl;
2487  } else {
2488  unsigned short v = 0;
2489  for (int k = 0; k < nsamp; k++) {
2490  v |= rawcomp[ch].samples[k];
2491  }
2492  rawcomp[ch].verif = !(v & 0xFC00);
2493  }
2494  }
2495  }
2496 
2497  } else if (frag1version == 1) { //New version
2498 
2499  int nsamp = 7; // New frag1 only for 7 samples
2500  int SizeOfFrag1 = size * 2; // Number of 16 bit words
2501  int nbchanformat2 = (SizeOfFrag1 - (3 * nbchanformat1)) / 5;
2502 
2503  int nchan = nbchanformat1 + nbchanformat2;
2504 
2505  *ngain = 1;
2506  *nchannel = nchan;
2507  *nsample = nsamp;
2508  const unsigned int *p = frag->data;
2509 
2510  if ((nchan) > 48 || ((nbchanformat1 * 3) + (nbchanformat2 * 5) > SizeOfFrag1)) {
2511  std::cout << " Format Type 1: Raw compressed : ERROR" << " fragId=0x" << std::hex
2512  << (id & 0xFFFF) << std::dec << " frag1Version=" << frag1version << " Nsamp=" << nsamp
2513  << " NchanFormat1=" << nbchanformat1 << " NchanFormat2=" << nbchanformat2
2514  << " Wrong Size=" << size << std::endl;
2515  status = 1;
2516 
2517  } else {
2518 
2519  int ptr16index = 1;
2520  int channel = 0;
2521  uint16_t word1 = 0;
2522  uint16_t word2 = 0;
2523  uint16_t word3 = 0;
2524  uint16_t word4 = 0;
2525  uint16_t word5 = 0;
2526  int ch = 0;
2527 
2528  for (int chf1 = 0; chf1 < nbchanformat1; ++chf1) {
2529 
2530  if (ptr16index) {
2531 
2532  channel = ((*p >> 26) & 0x3F);
2533  word1 = (uint16_t) ((*p >> 16) & 0xFFFF);
2534  word2 = (uint16_t) (*p & 0xFFFF);
2535  word3 = (uint16_t) ((*(p + 1) >> 16) & 0xFFFF);
2536  ptr16index = 0;
2537 
2538  rawcomp[ch].words[0] = (*p);
2539  rawcomp[ch].words[1] = (*p + 1) & 0xFFFF0000;
2540  rawcomp[ch].words[2] = 0;
2541  rawcomp[ch].words[3] = 0;
2542 
2543  } else {
2544 
2545  channel = ((*p >> 10) & 0x3F);
2546  word1 = (uint16_t) (*p & 0xFFFF);
2547  word2 = (uint16_t) ((*(p + 1) >> 16) & 0xFFFF);
2548  word3 = (uint16_t) (*(p + 1) & 0xFFFF);
2549  ptr16index = 1;
2550 
2551  rawcomp[ch].words[0] = (*p) & 0xFFFF;
2552  rawcomp[ch].words[1] = (*p + 1);
2553  rawcomp[ch].words[2] = 0;
2554  rawcomp[ch].words[3] = 0;
2555 
2556  }
2557 
2558  int gain = 1;
2559  uint16_t Smin = (word1 & 0x3FF);
2560 
2561  rawcomp[ch].samples[0] = ((word3 >> 4) & 0xF) + Smin;
2562  rawcomp[ch].samples[1] = ((word3 >> 0) & 0xF) + Smin;
2563  rawcomp[ch].samples[2] = ((word3 >> 8) & 0xF) + Smin;
2564  rawcomp[ch].samples[3] = ((word3 >> 12) & 0xF) + Smin;
2565  rawcomp[ch].samples[4] = ((word2 >> 4) & 0xF) + Smin;
2566  rawcomp[ch].samples[5] = ((word2 >> 0) & 0xF) + Smin;
2567  rawcomp[ch].samples[6] = ((word2 >> 8) & 0xF) + Smin;
2568 
2569  rawcomp[ch].chan = channel;
2570  rawcomp[ch].gain = gain;
2571  rawcomp[ch].verif = true;
2572 
2573  p += 1 + ptr16index;
2574  ++ch;
2575  }
2576 
2577  for (int chf2 = 0; chf2 < nbchanformat2; ++chf2) {
2578 
2579  if (ptr16index) {
2580 
2581  channel = ((*p) & 0x3F);
2582  word1 = (uint16_t) ((*p >> 16) & 0xFFFF);
2583  word2 = (uint16_t) ((*p) & 0xFFFF);
2584  word3 = (uint16_t) ((*(p + 1) >> 16) & 0xFFFF);
2585  word4 = (uint16_t) (*(p + 1) & 0xFFFF);
2586  word5 = (uint16_t) ((*(p + 2) >> 16) & 0xFFFF);
2587  ptr16index = 0;
2588 
2589  rawcomp[ch].words[0] = (*p);
2590  rawcomp[ch].words[1] = (*p + 1);
2591  rawcomp[ch].words[2] = (*p + 2) & 0xFFFF0000;
2592  rawcomp[ch].words[3] = 0;
2593 
2594  } else {
2595 
2596  channel = ((*(p + 1) >> 16) & 0x3F);
2597  word1 = (uint16_t) ((*p) & 0xFFFF);
2598  word2 = (uint16_t) ((*(p + 1) >> 16) & 0xFFFF);
2599  word3 = (uint16_t) (*(p + 1) & 0xFFFF);
2600  word4 = (uint16_t) ((*(p + 2) >> 16) & 0xFFFF);
2601  word5 = (uint16_t) (*(p + 2) & 0xFFFF);
2602  ptr16index = 1;
2603 
2604  rawcomp[ch].words[0] = (*p) & 0xFFFF;
2605  rawcomp[ch].words[1] = (*p + 1);
2606  rawcomp[ch].words[2] = (*p + 2);
2607  rawcomp[ch].words[3] = 0;
2608 
2609  }
2610 
2611  int gain = ((word2 >> 6) & 0x1);
2612 
2613  rawcomp[ch].samples[0] = ((word1 << 9) & 0x200) + ((word2 >> 7) & 0x1FF);
2614  rawcomp[ch].samples[1] = (word1 >> 1) & 0x3FF;
2615  rawcomp[ch].samples[2] = (word4 << 5 & 0x3E0) + ((word1 >> 11) & 0x1F);
2616  rawcomp[ch].samples[3] = (word4 >> 5) & 0x3FF;
2617  rawcomp[ch].samples[4] = ((word3 << 1) & 0x3FE) + ((word4 >> 15) & 0x1);
2618  rawcomp[ch].samples[5] = ((word5 << 7) & 0x380) + ((word3 >> 9) & 0x7F);
2619  rawcomp[ch].samples[6] = (word5 >> 3) & 0x3FF;
2620 
2621  rawcomp[ch].chan = channel;
2622  rawcomp[ch].gain = gain;
2623  rawcomp[ch].verif = true;
2624 
2625  p += (2 + ptr16index);
2626  ++ch;
2627  }
2628  }
2629 //} else {
2630 // status = 1; // Logically dead code
2631  }
2632  return status;
2633 }
2634 
2635 
2636 
2637 /*--------------------------------------------------------------------------*/
2639  , int nchannel_max, unsigned int version, int verbosity
2640  , int* ngain, int* nchannel, int* nsample) {
2641 /*--------------------------------------------------------------------------*/
2642 
2643  static std::atomic<bool> first = true;
2644  int m, c, s/*,id*/, size, ch, dm, dgm = 0, digim[5], digm[4] = { 0, 0, 0, 0 }, status = 0;
2645  int nchip, nchip2, nchan, nchan2, nsamp, nsamp1, nsamp2, gain_offs;
2646  const unsigned int *data;
2647  unsigned int val, headword, firstword, crcword;
2648  unsigned int hlflags, word1, word2, word3, word4, word5;
2649  unsigned short samp[3][MAX_CHAN_SAMP], smin, smax;
2650 
2651  //id = frag->id & 0xFFFF; /* fragment ID in the range 0x000 - 0x3FF */
2652  size = frag->size - m_sizeOverhead; /* size of the data part in the fragment */
2653  data = frag->data; /* first word of data */
2654 
2655  int dataoffset = 0;
2656  if (version == 0x2 || version == 0x1) { /* can not guess number of samples from size */
2657  if (size > 176 && size < 205) {
2658  size = 179; /* we expect this number (9+2)*16+1+2 */
2659  } else if (size > 272 && size < 405) {
2660  size = 275; /* we expect this number (7*2+3)*16+1+2 */
2661  }
2662  dataoffset = 1; // ignore first word
2663  }
2664 
2665  nchip = 16; /* number of chips in the data, only 16 is expected */
2666  nchan = nchip*3; /* one chip contains 3 channles */
2667  nsamp2 = size/nchip; /* calculate number of data words per chip */
2668 
2669 
2670 
2671  /* find digitizers mode (calibration or normal) */
2672  /* do not do this if fragment has bad length */
2673 
2674  if (first || status == 0) {
2675  data = frag->data + dataoffset;
2676  dm = 0;
2677  for (m = 0; m < nchip; m++) {
2678  if (tile_check_parity(data, 1) == 0) { /* check parity to be sure */
2679  dgm = ((*data) >> 15) & 3; /* that mode is correct */
2680  if (verbosity > 3) {
2681  std::cout << "Good parity, chip" << std::setw(3) << m << ", mode" << std::setw(2) << (int) dgm << ", head 0x" << setup0 << data[0] << ", data 0x" << std::setw(8) << data[1] << setupDec << std::endl;
2682  }
2683 
2684  if (((data[0] >> 31) == 1) && ((data[1] >> 31) == 0)) {
2685  digim[dm++] = dgm;
2686  if (dm == 5) break;
2687  }
2688  }
2689  data += nsamp2;
2690  }
2691 
2692  if (m == nchip && dm == 0) { /* the same check, but ignore parity now */
2693  data = frag->data + dataoffset;
2694  for (m = 0; m < nchip; m++) {
2695  dgm = ((*data) >> 15) & 3;
2696  if (verbosity > 3) {
2697  std::cout << "Chip" << std::setw(3) << m << ", mode" << std::setw(2) << (int) dgm << ", head 0x" << setup0 << data[0] << ", data 0x" << std::setw(8) << data[1] << setupDec << std::endl;
2698  }
2699  if (((data[0] >> 31) == 1) && ((data[1] >> 31) == 0)) {
2700  digim[dm++] = dgm;
2701  if (dm == 5) break;
2702  }
2703  data += nsamp2;
2704  }
2705  }
2706 
2707  if (m == nchip && dm == 0) {
2708  if (first) {
2709  first = false;
2710  if (nsamp2 == 17) {
2711  m_digi_mode = 1;
2712  std::cout << "Warning: No valid header found, calibration running mode(=1) assumed" << std::endl;
2713  } else {
2714  m_digi_mode = 0;
2715  std::cout << "Warning: No valid header found, normal running mode(=0) assumed" << std::endl;
2716  }
2717  } else {
2718  if (verbosity > 3) {
2719  std::cout << "Warning: No valid header found, keeping previous running mode(=" << (int) m_digi_mode << ")" << std::endl;
2720  }
2721  }
2722  status |= 2;
2723  } else {
2724  m_digi_mode = dgm; /* last found digi mode */
2725  if (dm > 2) { /* more than 2 good headers found */
2726  for (c = 0; c < dm; ++c) {
2727  ++digm[digim[c]]; /* count different digi_modes */
2728  }
2729  for (c = 0; c < 4; ++c) {
2730  if (digm[c] > digm[m_digi_mode]) {/* find most frequent digi_mode */
2731  m_digi_mode = c;
2732  }
2733  }
2734  }
2735  if (first) {
2736  first = false;
2737  if (m_digi_mode > 0) m <<= 1;
2738  if (tile_check_parity(data, 1) == 0) {
2739  std::cout << "\nMode=" << m_digi_mode << " found in header of chip " << m << std::endl;
2740  } else {
2741  std::cout << "\nMode=" << m_digi_mode << " found in header of chip " << m << " with bad parity" << std::endl;
2742  }
2743  if (m_digi_mode > 0) {
2744  std::cout << "\nCalibration mode selected, effective number of chips is twice bigger" << std::endl;
2745  }
2746  }
2747  }
2748  }
2749 
2750  /* put offset in the gain_offs variable */
2751  if (m_digi_mode > 0) {
2752  nchip *= 2; /* number of chips is twice bigger in calib mode*/
2753  nchan = nchip * 3;
2754  nchan2 = nchan / 2; /* real number of channels is one half of total */
2755  nchip2 = nchip / 2; /* real number of chips is one half of total */
2756 
2757  if (nsamp2 % 2 == 0) {
2758  /* old mode, all low gain channels and then all high gain channels
2759  CRC word is duplicated */
2760 
2761  nsamp2 = size / nchip;
2762  nsamp1 = nsamp2 - 1; /* length of data with header and without CRC word */
2763  nsamp = nsamp1 - 1; /* length of data without header and without CRC word */
2764  gain_offs = size / 2; /* first header of high gain in the second half of the data */
2765 
2766  } else {
2767  /* new mode, low gain + high gain + CRC word for one channel, then
2768  next channel etc */
2769 
2770  nsamp1 = (nsamp2 - 1) / 2; /* length of data with header and without CRC word */
2771  nsamp = nsamp1 - 1; /* length of data without header and without CRC word */
2772  gain_offs = nsamp1; /* first header of high gain just after first low gain */
2773  }
2774  } else {
2775  nsamp1 = nsamp2 - 1; /* length of data with header and without CRC word */
2776  nsamp = nsamp1 - 1; /* length of data without header and without CRC word */
2777 
2778  nchan2 = nchan;
2779  gain_offs = 0; /* only one low or high gain value from chip */
2780  nchip2 = nchip; /* all the chips are independent */
2781  }
2782 
2783  data = frag->data + dataoffset;
2784  for (m = 0; m < nchip; m++) {
2785  if (m == nchip2) { /* another gain */
2786  data = frag->data + dataoffset;
2787  data += gain_offs;
2788  gain_offs *= -1;
2789  }
2790 
2791  /* extract all samples for 3 channels in the chip */
2792  for (s = nsamp; s > 0;) { /* shifted by 1 due to header word */
2793  val = data[s--]; /* decrement s to be real sample number */
2794  for (c = 0; c < 3; c++) {
2795  samp[c][s] = val & 0x3FF;
2796  val = val >> 10;
2797  }
2798  }
2799 
2800  headword = data[0];
2801  firstword = data[1];
2802  if (gain_offs > 0) {
2803  crcword = data[nsamp1 + gain_offs]; /* first gain */
2804  } else {
2805  crcword = data[nsamp1]; /* second gain */
2806  }
2807  hlflags = ((headword) >> 12) & 7;
2808 
2809  /* check parity of all datawords in the frame, header and CRC */
2810  word5 = tile_check_parity(data + 1, nsamp); /* data parity (one bit per sample) */
2811  word4 = (word5 != 0) ? 32 : 0; /* just one bit (bad/good) for all data words */
2812  word4 |= (tile_check_parity(data, 1) << 4); /* header word parity */
2813  word4 |= (tile_check_startbit(data + 1, nsamp, 0) << 7); /* data words startbits */
2814  word4 |= (tile_check_startbit(data, 1, 1) << 6); /* header word startbit */
2815  word4 |= tile_check_CRC(data, nsamp1, gain_offs); /* bad/good CRC flag */
2816 
2817  word3 = (headword) & 0xFFF; /* bunch crossing ID */
2818  word2 = (headword >> 12) & 0x3FFF; /* parity, mode, gain */
2819  word1 = (headword >> 26) & 0xF; /* derandomizer length */
2820  word1 = (word1 << 8) | (m << 2); /* insert chip number */
2821 
2822  for (c = 0; c < 3; c++) {
2823  ch = m * 3 + c;
2824  if (ch < nchannel_max) {
2825  tile_min_max(samp[c], nsamp, &smin, &smax); /* find min and max sample */
2826  channel[ch].chan = ch % nchan2; /* the same for low gain and high gain */
2827  channel[ch].head = headword;
2828  channel[ch].first = firstword;
2829  channel[ch].crc = crcword;
2830  channel[ch].id = word1 | c; /* insert channel number */
2831  channel[ch].gain = (hlflags >> c) & 1;
2832  channel[ch].flag = word2;
2833  channel[ch].bcid = word3;
2834  channel[ch].err = word4 | ((smax == 1023) ? 256 : 0) /* overflow flag */
2835  | ((smin == 0) ? 512 : 0); /* underflow flag */
2836  channel[ch].par = word5;
2837  memcpy(channel[ch].sample, samp[c], nsamp * sizeof(short));
2838  }
2839  }
2840 
2841  data += nsamp2;
2842  }
2843 
2844  *ngain = (gain_offs != 0) ? 2 : 1;
2845  *nchannel = nchan;
2846  *nsample = nsamp;
2847 
2848  return status;
2849 }
2850 
2851 unsigned int TileTBDump::tile_check_parity(const unsigned int *frame, int length) {
2852 /*--------------------------------------------------------------------------*/
2853 /* Name: tile_check_parity */
2854 /* */
2855 /* Author: Magnus Ramstedt Date: 10/09/99 */
2856 /* */
2857 /* Description: */
2858 /* Checks the even parity on all data words for one channel */
2859 /* data bits= |xp<---ch3--><---ch2--><---ch1-->| */
2860 /* where x is any bit, */
2861 /* where p is the parity bit, */
2862 /* where ch1,ch2,ch3 - three channels, 10 bits each */
2863 /* returns word with "length" status bits, one status bit per every word */
2864 /* (0 - if OK else 1) */
2865 /* */
2866 /* Input arguments: array of data words and its length */
2867 /* */
2868 /* Output arguments: */
2869 /* */
2870 /* Libraries used: */
2871 /* */
2872 /* Routines called: */
2873 /* */
2874 /* Return Value: word with "length" status bits (0 if OK else 1) */
2875 /* */
2876 /*--------------------------------------------------------------------------*/
2877 
2878  int i, j;
2879  unsigned int parity, data_word, answer = 0;
2880 
2881  for (i = 0; i < length; ++i) {
2882 
2883  data_word = *frame++;
2884 
2885  parity = 0;
2886  for (j = 0; j < 32; j++) {
2887  parity ^= data_word;
2888  data_word >>= 1;
2889  }
2890 
2891  if ((parity &= 1) == 0) answer |= 1 << i;
2892  }
2893 
2894  return answer;
2895 }
2896 
2897 /*--------------------------------------------------------------------------*/
2898 unsigned int TileTBDump::tile_check_startbit(const unsigned int* frame, int length, unsigned int startbit) {
2899 /*--------------------------------------------------------------------------*/
2900 /* Name: tile_check_startbit */
2901 /* */
2902 /* Author: Alexandre Solodkov Date: 06/08/01 */
2903 /* */
2904 /* Description: */
2905 /* Checks that first bit in all "length" words of "*frame" */
2906 /* is equal to "startbit" */
2907 /* where p is the parity bit, */
2908 /* returns (0 - if OK else 1) */
2909 /* */
2910 /* Input arguments: array of data words, its length and startbit to compare */
2911 /* */
2912 /* Output arguments: */
2913 /* */
2914 /* Libraries used: */
2915 /* */
2916 /* Routines called: */
2917 /* */
2918 /* Return Value: 0 if OK else 1 */
2919 /* */
2920 /*--------------------------------------------------------------------------*/
2921 
2922  int i;
2923  unsigned int data_word, answer = 0;
2924 
2925  for (i = 0; i < length; ++i) {
2926 
2927  data_word = *frame++;
2928 
2929  if ((data_word >> 31) != startbit) {
2930  answer = 1;
2931  break;
2932  }
2933  }
2934 
2935  return answer;
2936 }
2937 
2938 /*--------------------------------------------------------------------------*/
2939 unsigned int TileTBDump::tile_check_CRC(const unsigned int *frame, int framelen, int delta) {
2940 /*--------------------------------------------------------------------------*/
2941 /* Name: tile_check_CRC */
2942 /* */
2943 /* Author: Magnus Ramstedt Date: 04/10/99 */
2944 /* */
2945 /* Description: */
2946 /* Calculate CRC and compare with input value */
2947 /* return 0 if OK else 1,2,3 or 4 depending on the type of error */
2948 /* */
2949 /* Input arguments: array of data words its length and delta for the */
2950 /* address af the second half of the data */
2951 /* */
2952 /* Output arguments: */
2953 /* */
2954 /* Libraries used: */
2955 /* */
2956 /* Routines called: */
2957 /* */
2958 /* Return Value: 0 if OK else 1,2,3 or 4 depending on the type of error */
2959 /* */
2960 /*--------------------------------------------------------------------------*/
2961 
2962 #define CRC_ok 0
2963 #define CRC_error_0 1
2964 #define CRC_error_1 2
2965 #define CRC_do_not_match 4
2966 #ifndef CRC_POLY
2967 #define CRC_POLY 0x8005
2968 #endif
2969 
2970  unsigned int CRC_error = CRC_ok;
2971  static const unsigned int error[3] = { CRC_error_0, CRC_error_1, CRC_do_not_match };
2972 
2973  int i, j, k, length;
2974  unsigned int *data, word, CRC_word;
2975  unsigned short bit_in, bit_out, reg, reg1, reg2;
2976 
2977  /* put all the data in one array with empty word at the end */
2978 
2979  if (delta != 0) { /* low gain and high gain in different places */
2980  length = 2 * framelen + 1;
2981  data = (unsigned int *) malloc(length * sizeof(int));
2982  if (delta > 0) {
2983  memcpy(data, frame, framelen * sizeof(int));
2984  memcpy(data + framelen, frame + delta, framelen * sizeof(int));
2985  CRC_word = frame[framelen + delta]; /* after second part of the data */
2986  } else {
2987  memcpy(data, frame + delta, framelen * sizeof(int));
2988  memcpy(data + framelen, frame, framelen * sizeof(int));
2989  CRC_word = frame[framelen]; /* just after the data */
2990  }
2991  } else {
2992  length = framelen + 1;
2993  data = (unsigned int *) malloc(length * sizeof(int));
2994  memcpy(data, frame, framelen * sizeof(int));
2995  CRC_word = frame[framelen]; /* just after the data */
2996  }
2997 
2998  data[length - 1] = 0;
2999 
3000  /* Calculates the CRC16 from *data */
3001 
3002  for (i = 0; i < 2; i++) { /* odd and even bits separately */
3003 
3004  reg = 0;
3005  for (j = 0; j < length; j++) { /* all datawords */
3006 
3007  word = data[j];
3008  for (k = i; k < 32; k += 2) { /* 16 bits (odd or even) from one word */
3009 
3010  bit_in = (word >> k) & 1; /* This is the incomming bit */
3011  bit_out = reg & 0x8000; /* Saving the kicked out bit */
3012  reg = ((reg << 1) | bit_in); /* Filling 'reg' with 'bit_in' */
3013 
3014  if (bit_out) reg ^= CRC_POLY; /* xor reg with poly if bit_out!=0 */
3015  }
3016  }
3017 
3018  /* there were a bus swaped */
3019 
3020  reg1 = 0;
3021  for (k = 16; reg != 0; reg >>= 1) {
3022  reg1 |= (reg & 1) << (--k);
3023  }
3024 
3025  /* reading the recived CRC (16 bit long) */
3026 
3027  reg2 = 0;
3028  for (k = i; k < 32; k += 2) { /* 16 bits (odd or even) from one word */
3029 
3030  bit_in = (CRC_word >> k) & 1; /* This is the incomming bit */
3031  reg2 = ((reg2 << 1) | bit_in); /* Filling 'reg2' with 'bit_in' */
3032  }
3033 
3034  if (reg1 != reg2) CRC_error |= error[i];
3035  }
3036 
3037  free(data);
3038  return CRC_error;
3039 }
3040 
3041 /*--------------------------------------------------------------------------*/
3042 void TileTBDump::tile_min_max ( const unsigned short *frame, int frame_length, unsigned short *smin, unsigned short *smax ) {
3043 /*--------------------------------------------------------------------------*/
3044 /* Name: tile_min_max */
3045 /* */
3046 /* Author: Alexandre Solodkov Date: 12/07/01 */
3047 /* */
3048 /* Description: Tries to determine if there is some signal in the frame */
3049 /* */
3050 /* Input arguments: array of samples */
3051 /* */
3052 /* Output arguments: max and min sample */
3053 /* */
3054 /* Libraries used: */
3055 /* */
3056 /* Routines called: */
3057 /* */
3058 /* Return Value: */
3059 /* */
3060 /*--------------------------------------------------------------------------*/
3061 
3062  int t;
3063  unsigned short val, Min = 0xFFFF, Max = 0;
3064 
3065  for (t = 0; t < frame_length; ++t) {
3066  val = frame[t];
3067 
3068  if (val < Min) {
3069  Min = val;
3070  }
3071  if (val > Max) {
3072  Max = val;
3073  }
3074  }
3075 
3076  *smin = Min;
3077  *smax = Max;
3078 }
3079 
3080 std::vector<uint32_t> TileTBDump::get_correct_data(const uint32_t* p, unsigned int size) const {
3081 
3082  std::vector<uint32_t> data;
3083  data.reserve(size);
3084  const uint32_t* data_end = p + size;
3085 
3086  while (p < data_end) {
3087  uint32_t ppr_size = (*p) - 2; // The size of PPr packet
3088  // The first 2 words (FELIX header) of each MD fragment are correct (just copy)
3089  data.push_back(*(p));
3090  data.push_back(*(++p));
3091 
3092  ++p;
3093 
3094  std::for_each(p, p + ppr_size, [&data] (uint32_t v) {
3095  data.push_back((ntohs(v >> 16) << 16) | (ntohs(v & 0xFFFF)));
3096  });
3097 
3098  p += ppr_size;
3099  }
3100 
3101  return data;
3102 }
code_amp5
#define code_amp5
bad
@ bad
Definition: SUSYToolsTester.cxx:100
TileTBDump::T_TileRecoQuality::sampleparity
uint16_t sampleparity
Definition: TileTBDump.h:151
QUALITY_RANGE4
const int QUALITY_RANGE4
Definition: TileRawChannel2Bytes4.h:58
COIN_TRIG7_FRAG
#define COIN_TRIG7_FRAG
Definition: TileTBFrag.h:38
beamspotman.r
def r
Definition: beamspotman.py:676
TileTBDump::m_lvl1_id
int m_lvl1_id
Definition: TileTBDump.h:108
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
TIME_SHIFT2
const int TIME_SHIFT2
Definition: TileRawChannel2Bytes2.h:47
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
TileTBDump::T_TileRecoQuality::memory
uint16_t memory
Definition: TileTBDump.h:145
ReadOfcFromCool.phase
phase
Definition: ReadOfcFromCool.py:127
code_null
#define code_null
TIME_RANGE4
const int TIME_RANGE4
Definition: TileRawChannel2Bytes4.h:50
COMMON_TDC2_FRAG
#define COMMON_TDC2_FRAG
Definition: TileTBFrag.h:47
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
TileTBDump::m_tileToolEmscale
ToolHandle< TileCondToolEmscale > m_tileToolEmscale
Definition: TileTBDump.h:89
COMMON_PTN_FRAG
#define COMMON_PTN_FRAG
Definition: TileTBFrag.h:48
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
StateLessPT_NewConfig.RunType
int RunType
Definition: StateLessPT_NewConfig.py:96
get_generator_info.result
result
Definition: get_generator_info.py:21
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
TileTBDump::T_TileRawComp::gain
unsigned short gain
Definition: TileTBDump.h:172
xAOD::word1
word1
Definition: eFexEMRoI_v1.cxx:87
checkCoolLatestUpdate.dg
dg
Definition: checkCoolLatestUpdate.py:9
TileTBDump::tile_unpack_quality
int tile_unpack_quality(const T_RodDataFrag *frag, T_TileRecoQuality &DQword)
Definition: TileTBDump.cxx:2295
code_full
#define code_full
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
setupPr1
std::ostream & setupPr1(std::ostream &stream)
Definition: TileTBDump.cxx:475
ADD_FADC_FRAG
#define ADD_FADC_FRAG
Definition: TileTBFrag.h:29
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TileTBDump::tile_check_CRC
unsigned int tile_check_CRC(const unsigned int *frame, int framelen, int delta)
Definition: TileTBDump.cxx:2939
TileTBDump::T_TileRecoCalib::chan
int chan
Definition: TileTBDump.h:177
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
AMPLITUDE_SHIFT2
const int AMPLITUDE_SHIFT2
Definition: TileRawChannel2Bytes2.h:39
TileCablingService::getInstance
static const TileCablingService * getInstance()
get pointer to service instance
Definition: TileCablingService.cxx:24
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
setupPr4
std::ostream & setupPr4(std::ostream &stream)
Definition: TileTBDump.cxx:487
TileTBDump::T_TileRecoQuality::global_crc
uint16_t global_crc
Definition: TileTBDump.h:143
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
dump_it
void dump_it(unsigned int nw, unsigned int *data)
Definition: TileTBDump.cxx:2018
TileTBDump::T_TileRecoCalib::amp
unsigned short amp
Definition: TileTBDump.h:180
TileRawChannel2Bytes5::unpack
void unpack(const uint32_t *ofw, const uint32_t *ptr_frag, TileChanData *ChanData) const
Definition: TileRawChannel2Bytes5.cxx:672
TileRawChannel2Bytes5::print_code
static void print_code(uint32_t code)
Definition: TileRawChannel2Bytes5.h:124
TileRawChannel2Bytes5::TileChanData::time
float time
Definition: TileRawChannel2Bytes5.h:65
TileRawChannel2Bytes5::TileChanData::gain
int gain
Definition: TileRawChannel2Bytes5.h:61
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TileTBDump::T_TileRecoQuality::rod_chip_mask
uint16_t rod_chip_mask
Definition: TileTBDump.h:153
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
Frag5_unpack_bin2sum
#define Frag5_unpack_bin2sum(unit, amp_bin)
unpack_bin2sum
Definition: TileRawChannel2Bytes5.h:240
TileTBDump::tile_min_max
void tile_min_max(const unsigned short *frame, int frame_length, unsigned short *smin, unsigned short *smax)
Definition: TileTBDump.cxx:3042
TileRawChannel2Bytes5::TileChanData
Definition: TileRawChannel2Bytes5.h:58
TileRawChannel2Bytes4::quality
float quality(unsigned int w) const
Returns the quality factor unpacked from the single 32-bit word w.
Definition: TileRawChannel2Bytes4.h:115
TileTBDump::m_statFrag5
int m_statFrag5[200]
Definition: TileTBDump.h:74
TileTBDump::m_global_id
int m_global_id
Definition: TileTBDump.h:104
ReadBchFromCool.pmt
pmt
Definition: ReadBchFromCool.py:62
xAOD::JetAlgorithmType::algName
const std::string & algName(ID id)
Converts a JetAlgorithmType::ID into a string.
Definition: JetContainerInfo.cxx:67
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
TileTBDump::m_v3Format
bool m_v3Format
Definition: TileTBDump.h:97
Event
Definition: trigbs_orderedMerge.cxx:42
QUALITY_SHIFT2
const int QUALITY_SHIFT2
Definition: TileRawChannel2Bytes2.h:54
TileTBDump.h
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
TileTBDump::T_TileRecoCalib::word
unsigned int word
Definition: TileTBDump.h:178
TileTBDump::dump_digi
void dump_digi(unsigned int subdet_id, const uint32_t *data, unsigned int size, unsigned int version, int verbosity, unsigned int robsourceid, const EventContext &ctx)
Definition: TileTBDump.cxx:506
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
TIME_SHIFT4
const int TIME_SHIFT4
Definition: TileRawChannel2Bytes4.h:51
TileTBDump::m_dumpStatus
bool m_dumpStatus
Definition: TileTBDump.h:93
TileTBDump::m_lvl1_trigger_type
int m_lvl1_trigger_type
Definition: TileTBDump.h:110
GAIN_RANGE4
const unsigned int GAIN_RANGE4
Definition: TileRawChannel2Bytes4.h:31
code_amp6
#define code_amp6
TileTBDump::initialize
StatusCode initialize()
Definition: TileTBDump.cxx:164
RunTileCalibRec.tmdb
tmdb
Definition: RunTileCalibRec.py:234
AMPLITUDE_RANGE2
const int AMPLITUDE_RANGE2
Definition: TileRawChannel2Bytes2.h:38
TileTBDump::T_TileRecoCalib::d_amp
double d_amp
Definition: TileTBDump.h:184
MAX_CHAN_SAMP
#define MAX_CHAN_SAMP
Definition: TileTBFrag.h:54
TileRawChannel2Bytes5::getSumEt
double getSumEt(const uint32_t *ptr_frag) const
Definition: TileRawChannel2Bytes5.h:278
TileTBDump::m_showUnknown
bool m_showUnknown
Definition: TileTBDump.h:96
PlotCalibFromCool.nchan
nchan
Definition: PlotCalibFromCool.py:564
AthCommonMsg< Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
TileTBDump::m_drawerMap
std::map< unsigned int, unsigned int, std::less< unsigned int > > m_drawerMap
Definition: TileTBDump.h:83
DIGI_PAR_FRAG
#define DIGI_PAR_FRAG
Definition: TileTBFrag.h:41
COIN_TRIG8_FRAG
#define COIN_TRIG8_FRAG
Definition: TileTBFrag.h:39
ADDR_ADC_FRAG
#define ADDR_ADC_FRAG
Definition: TileTBFrag.h:26
TileRawChannel2Bytes5::TileChanData::bad
int bad
Definition: TileRawChannel2Bytes5.h:60
COMMON_TOF_FRAG
#define COMMON_TOF_FRAG
Definition: TileTBFrag.h:45
ROBDataProviderSvc.h
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
TileTBDump::T_TileRecoCalib::time
unsigned short time
Definition: TileTBDump.h:181
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:112
LASERII_OBJ_FRAG
#define LASERII_OBJ_FRAG
Definition: TileTBFrag.h:50
COMMON_ADC1_FRAG
#define COMMON_ADC1_FRAG
Definition: TileTBFrag.h:43
LASE_ADC_FRAG
#define LASE_ADC_FRAG
Definition: TileTBFrag.h:28
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
GAIN_SHIFT2
const int GAIN_SHIFT2
Definition: TileRawChannel2Bytes2.h:28
AMPLITUDE_RANGE4
const int AMPLITUDE_RANGE4
Definition: TileRawChannel2Bytes4.h:42
TileCondToolTiming.h
TileTBDump::T_TileRecoChannel::time
unsigned short time
Definition: TileTBDump.h:161
TileTBDump::drawerMap_iterator
std::map< unsigned int, unsigned int, std::less< unsigned int > >::iterator drawerMap_iterator
Definition: TileTBDump.h:84
TileTBDump::TileTBDump
TileTBDump(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TileTBDump.cxx:106
TileTBDump::m_run_no
int m_run_no
Definition: TileTBDump.h:106
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
TileTBDump::m_bc_time_seconds
int m_bc_time_seconds
Definition: TileTBDump.h:102
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
TileRawChannel2Bytes2::time
float time(unsigned int w) const
Returns the phase of the pulse in ns, unpacked from the single 32-bit word w.
Definition: TileRawChannel2Bytes2.h:104
BEAM_ADC_FRAG
#define BEAM_ADC_FRAG
Definition: TileTBFrag.h:24
TileTBDump::m_runPeriod
int m_runPeriod
Definition: TileTBDump.h:79
TileTBDump::execute
StatusCode execute()
Definition: TileTBDump.cxx:219
AthExHiveOpts.Time
Time
Definition: AthExHiveOpts.py:63
COMMON_TDC1_FRAG
#define COMMON_TDC1_FRAG
Definition: TileTBFrag.h:46
TileTBDump::T_RodDataFrag::id
unsigned int id
Definition: TileTBDump.h:119
TileRawChannel2Bytes4::amplitude
float amplitude(unsigned int w, unsigned int unit) const
Returns the amplitude in the corresponding units, unpacked from the single 32-bit word w.
Definition: TileRawChannel2Bytes4.h:102
TileTBDump::T_RodDataFrag::size
unsigned int size
Definition: TileTBDump.h:118
TileCondToolOfcCool.h
TileTBDump::m_frag5found
bool m_frag5found
Definition: TileTBDump.h:98
TileTBDump::m_rc2bytes2
TileRawChannel2Bytes2 m_rc2bytes2
Definition: TileTBDump.h:229
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
TileTBDump::tile_check_parity
unsigned int tile_check_parity(const unsigned int *frame, int length)
Definition: TileTBDump.cxx:2851
TileTBDump::T_TileRecoCalib::gain
unsigned short gain
Definition: TileTBDump.h:179
TileTBDump::T_TileRecoQuality::headformat
uint16_t headformat
Definition: TileTBDump.h:148
TileDCSDataPlotter.tit
tit
Definition: TileDCSDataPlotter.py:890
histSizes.code
code
Definition: histSizes.py:129
Tile
Definition: TileVolumeBuilder.h:43
TileTBDump::T_TileRecoCalib::d_quality
double d_quality
Definition: TileTBDump.h:186
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
code_rawf
#define code_rawf
TileTBDump::T_TileRecoQuality::Dstrobe
uint16_t Dstrobe
Definition: TileTBDump.h:147
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TileTBDump::tile_unpack_reco
int tile_unpack_reco(const T_RodDataFrag *frag, T_TileRecoChannel *channel, int nchannel_max, unsigned int version, int verbosity, int *ngain, int *nchannel)
Definition: TileTBDump.cxx:2371
MAX_DIGI_CHAN
#define MAX_DIGI_CHAN
Definition: TileTBFrag.h:53
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:113
TileCablingService.h
TileRawChannel2Bytes4::time
float time(unsigned int w) const
Returns the phase of the pulse in ns, unpacked from the single 32-bit word w.
Definition: TileRawChannel2Bytes4.h:110
COIN_TRIG6_FRAG
#define COIN_TRIG6_FRAG
Definition: TileTBFrag.h:37
GAIN_RANGE2
const unsigned int GAIN_RANGE2
Definition: TileRawChannel2Bytes2.h:27
eformat::ROBFragment< const uint32_t * >
lumiFormat.i
int i
Definition: lumiFormat.py:85
setup0
std::ostream & setup0(std::ostream &stream)
Definition: TileTBDump.cxx:467
COIN_TRIG1_FRAG
#define COIN_TRIG1_FRAG
Definition: TileTBFrag.h:32
TileOFC.h
TileCondToolEmscale.h
ReadCellNoiseFromCool.chan
chan
Definition: ReadCellNoiseFromCool.py:52
code_ped4
#define code_ped4
Format6
bool Format6(const std::vector< double > &a, const std::vector< double > &b, const std::vector< double > &c, const std::vector< double > &g, const std::vector< double > &h, unsigned int channel_index, int phase, double calibration, std::vector< unsigned int > &OFC, bool verbose)
Format6.
Definition: TileOFC.cxx:270
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
beamspotman.n
n
Definition: beamspotman.py:731
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
python.subdetectors.mmg.names
names
Definition: mmg.py:8
TileRawChannelUnit::OnlineOffset
@ OnlineOffset
Definition: TileRawChannelUnit.h:25
TileTBDump::FelixData_t
std::vector< std::vector< unsigned int > > FelixData_t
Definition: TileTBDump.h:85
master.flag
bool flag
Definition: master.py:29
TileOfcWeightsStruct
Definition: ITileCondToolOfc.h:13
TileTBDump::T_TileRecoChannel::gain
unsigned short gain
Definition: TileTBDump.h:159
TileTBDump::T_TileRecoQuality::bcid
uint16_t bcid
Definition: TileTBDump.h:144
TileTBDump::m_tileCondToolOfcCool
ToolHandle< TileCondToolOfcCool > m_tileCondToolOfcCool
Definition: TileTBDump.h:88
TileTBDump::tile_check_startbit
unsigned int tile_check_startbit(const unsigned int *frame, int length, unsigned int startbit)
Definition: TileTBDump.cxx:2898
cern_local_time
std::string cern_local_time(time_t unix_time)
Definition: TileTBDump.cxx:48
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
BEAM_TDC_FRAG
#define BEAM_TDC_FRAG
Definition: TileTBFrag.h:23
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
python.LArCondContChannels.chan1
chan1
Definition: LArCondContChannels.py:666
hist_file_dump.f
f
Definition: hist_file_dump.py:135
TileTBDump::T_TileRecoCalib::bad
unsigned short bad
Definition: TileTBDump.h:182
TrigInDetValidation_Base.malloc
malloc
Definition: TrigInDetValidation_Base.py:132
TileTBDump::T_TileRecoQuality::fe_chip_mask
uint16_t fe_chip_mask
Definition: TileTBDump.h:152
TileTBDump::T_TileRecoQuality::headparity
uint16_t headparity
Definition: TileTBDump.h:149
code_dump
#define code_dump
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
setup0x4
std::ostream & setup0x4(std::ostream &stream)
Definition: TileTBDump.cxx:459
TileTBDump::m_drawerType
std::vector< int > m_drawerType
Definition: TileTBDump.h:82
TileRawChannelUnit::UNIT
UNIT
Definition: TileRawChannelUnit.h:16
AMPLITUDE_SHIFT4
const int AMPLITUDE_SHIFT4
Definition: TileRawChannel2Bytes4.h:43
TileTBDump::finalize
StatusCode finalize()
Definition: TileTBDump.cxx:195
beamspotman.stat
stat
Definition: beamspotman.py:266
python.OnlineISConfiguration.runType
def runType
Definition: OnlineISConfiguration.py:112
AthAlgorithm
Definition: AthAlgorithm.h:47
TileTBDump::~TileTBDump
virtual ~TileTBDump()
Definition: TileTBDump.cxx:160
ReadCellNoiseFromCool.dm
dm
Definition: ReadCellNoiseFromCool.py:235
TileTBDump::T_TileDigiChannel
Definition: TileTBDump.h:127
TileTBDump::T_TileRecoQuality
Definition: TileTBDump.h:141
TileRawChannel2Bytes2::amplitude
float amplitude(unsigned int w) const
Returns the non calibrated amplitude unpacked from the single 32-bit word w.
Definition: TileRawChannel2Bytes2.h:98
TileTBDump::unpack_frag6
void unpack_frag6(const uint32_t *data, unsigned int size, FelixData_t &digitsHighGain, FelixData_t &digitsLowGain, FelixData_t &digitsMetaData) const
Definition: TileTBDump.cxx:2119
TileTBDump::m_all_lvl1_trigger_types
std::vector< int > m_all_lvl1_trigger_types
Definition: TileTBDump.h:114
TileTBDump::T_TileRecoChannel::amp
unsigned short amp
Definition: TileTBDump.h:160
setupPr3
std::ostream & setupPr3(std::ostream &stream)
Definition: TileTBDump.cxx:483
python.handimod.extra
int extra
Definition: handimod.py:522
SCT_Cabling::dateTime
std::string dateTime()
Definition: SCT_CablingXmlTags.h:55
setupPr2
std::ostream & setupPr2(std::ostream &stream)
Definition: TileTBDump.cxx:479
TileTBDump::T_RodDataFrag::data
unsigned int data[1]
Definition: TileTBDump.h:120
LASE_PTN_FRAG
#define LASE_PTN_FRAG
Definition: TileTBFrag.h:27
TileTBDump::m_cabling
const TileCablingService * m_cabling
Definition: TileTBDump.h:78
head
std::string head(std::string s, const std::string &pattern)
head of a string
Definition: computils.cxx:311
TileTBDump::m_lumi_block
int m_lumi_block
Definition: TileTBDump.h:107
TileTBDump::m_RobSvc
ServiceHandle< IROBDataProviderSvc > m_RobSvc
Definition: TileTBDump.h:76
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LASER_OBJ_FRAG
#define LASER_OBJ_FRAG
Definition: TileTBFrag.h:49
setupMod
std::ostream & setupMod(std::ostream &stream)
Definition: TileTBDump.cxx:463
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
TileTBDump::m_tileToolTiming
ToolHandle< TileCondToolTiming > m_tileToolTiming
Definition: TileTBDump.h:87
errorcheck.h
Helpers for checking error return status codes and reporting errors.
EventContainers::Mode
Mode
Definition: IdentifiableContainerBase.h:13
TileTBDump::T_TileRecoQuality::sampleformat
uint16_t sampleformat
Definition: TileTBDump.h:150
code_raws
#define code_raws
TileTBDump::T_TileRecoCalib::quality
unsigned short quality
Definition: TileTBDump.h:183
TileTBDump::m_unit
int m_unit
Definition: TileTBDump.h:100
covarianceTool.verbosity
verbosity
Definition: covarianceTool.py:513
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
weights
Definition: herwig7_interface.h:38
TileTBFrag.h
TileTBDump::m_dumpHeader
bool m_dumpHeader
Definition: TileTBDump.h:91
code_ped5
#define code_ped5
TileRawChannel2Bytes2::quality
float quality(unsigned int w) const
Returns the quality factor unpacked from the single 32-bit word w.
Definition: TileRawChannel2Bytes2.h:109
TileTBDump::m_drawerList
std::vector< std::string > m_drawerList
Definition: TileTBDump.h:81
TileRawChannelUnit.h
TileTBDump::T_TileRawComp::words
unsigned int words[4]
Definition: TileTBDump.h:169
PlotSFuncertainty.calib
calib
Definition: PlotSFuncertainty.py:110
MUON_ADC_FRAG
#define MUON_ADC_FRAG
Definition: TileTBFrag.h:25
TileTBDump::find_frag
void find_frag(const uint32_t *rod, unsigned int size, unsigned int version, int verbosity, const T_RodDataFrag *frag[], int &nfrag)
Definition: TileTBDump.cxx:2030
python.PyAthena.v
v
Definition: PyAthena.py:154
TileTBDump::m_dumpData
bool m_dumpData
Definition: TileTBDump.h:92
get_generator_info.version
version
Definition: get_generator_info.py:33
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
COIN_TRIG3_FRAG
#define COIN_TRIG3_FRAG
Definition: TileTBFrag.h:34
MAX_ROD_FRAG
#define MAX_ROD_FRAG
Definition: TileTBFrag.h:21
TileTBDump::m_nlvl1_trigger_info
int m_nlvl1_trigger_info
Definition: TileTBDump.h:111
TileRawChannel2Bytes5::getSumE
double getSumE(const uint32_t *ptr_frag) const
Definition: TileRawChannel2Bytes5.h:280
TileTBDump::T_TileRecoQuality::dspbcid
uint16_t dspbcid
Definition: TileTBDump.h:142
CRC_error_0
#define CRC_error_0
TileRawChannel2Bytes5::amplitude
int amplitude(const uint32_t *ofw, int unit, int chan, int gain, int s[]) const
Definition: TileRawChannel2Bytes5.cxx:624
a
TList * a
Definition: liststreamerinfos.cxx:10
CRC_ok
#define CRC_ok
TileTBDump::T_TileRecoCalib::d_time
double d_time
Definition: TileTBDump.h:185
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
TileTBDump::tile_unpack_raw_comp
int tile_unpack_raw_comp(const T_RodDataFrag *frag, T_TileRawComp *rawcomp, int nchannel_max, unsigned int version, int verbosity, int *ngain, int *nchannel, int *nsample)
Definition: TileTBDump.cxx:2438
CRC_POLY
#define CRC_POLY
setupDec
std::ostream & setupDec(std::ostream &stream)
Definition: TileTBDump.cxx:471
COIN_TRIG2_FRAG
#define COIN_TRIG2_FRAG
Definition: TileTBFrag.h:33
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
TileTBDump::get_correct_data
std::vector< uint32_t > get_correct_data(const uint32_t *p, unsigned int size) const
Definition: TileTBDump.cxx:3080
known
Definition: TrigBStoxAODTool.cxx:107
TileTBDump::T_TileRecoChannel::word
unsigned int word
Definition: TileTBDump.h:158
TileTBDump::T_TileRawComp
Definition: TileTBDump.h:168
unit
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
Definition: AmgMatrixBasePlugin.h:21
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TileCablingService::channel2hole
static int channel2hole(int ros, int channel)
Definition: TileCablingService.cxx:1946
DeMoScan.first
bool first
Definition: DeMoScan.py:536
DEBUG
#define DEBUG
Definition: page_access.h:11
python.Classes.TileCalibUtils
TileCalibUtils
Definition: TileCalib/TileCalibBlobObjs/python/Classes.py:5
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
TileRawChannel2Bytes5::TileChanData::ene
float ene
Definition: TileRawChannel2Bytes5.h:64
TileRawChannel2Bytes5::TileChanData::ene_bin
int ene_bin
Definition: TileRawChannel2Bytes5.h:62
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
CRC_do_not_match
#define CRC_do_not_match
TileTBDump::m_digi_mode
int m_digi_mode
Definition: TileTBDump.h:112
TileRawChannel2Bytes5::TileChanData::s
int s[7]
Definition: TileRawChannel2Bytes5.h:66
TileTBDump::T_RodDataFrag
Definition: TileTBDump.h:117
TileTBDump::m_run_type
int m_run_type
Definition: TileTBDump.h:105
TileTBDump::m_dumpOnce
bool m_dumpOnce
Definition: TileTBDump.h:94
TileTBDump::m_rc2bytes5
TileRawChannel2Bytes5 m_rc2bytes5
Definition: TileTBDump.h:231
TileTBDump::m_rc2bytes4
TileRawChannel2Bytes4 m_rc2bytes4
Definition: TileTBDump.h:230
PlotCalibFromCool.ngain
ngain
Definition: PlotCalibFromCool.py:565
TileTBDump::m_bc_id
int m_bc_id
Definition: TileTBDump.h:109
COMMON_ADC2_FRAG
#define COMMON_ADC2_FRAG
Definition: TileTBFrag.h:44
merge.status
status
Definition: merge.py:17
QUALITY_SHIFT4
const int QUALITY_SHIFT4
Definition: TileRawChannel2Bytes4.h:62
TileTBDump::m_sizeOverhead
unsigned int m_sizeOverhead
Definition: TileTBDump.h:99
TileTBDump::tile_unpack_reco_calib
int tile_unpack_reco_calib(const T_RodDataFrag *frag, T_TileRecoCalib *recocalib, int nchannel_max, unsigned int version, unsigned int unit, int verbosity, int *ngain, int *nchannel)
Definition: TileTBDump.cxx:2404
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
TrigConf::MSGTC::NIL
@ NIL
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:22
python.StandardJetMods.Filter
Filter
Definition: StandardJetMods.py:34
TileTBDump::tile_unpack_digi
int tile_unpack_digi(const T_RodDataFrag *frag, T_TileDigiChannel *channel, int nchannel_max, unsigned int version, int verbosity, int *ngain, int *nchannel, int *nsample)
Definition: TileTBDump.cxx:2638
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
TileTBDump::T_TileRecoChannel::quality
unsigned short quality
Definition: TileTBDump.h:162
TileRawChannel2Bytes5::getSumEz
double getSumEz(const uint32_t *ptr_frag) const
Definition: TileRawChannel2Bytes5.h:279
GAIN_SHIFT4
const int GAIN_SHIFT4
Definition: TileRawChannel2Bytes4.h:32
TileTBDump::T_TileRawComp::samples
unsigned short samples[7]
Definition: TileTBDump.h:173
TileTBDump::m_bc_time_nanoseconds
int m_bc_time_nanoseconds
Definition: TileTBDump.h:103
TileCablingService::runPeriod
int runPeriod() const
Definition: TileCablingService.h:280
grepfile.fr
fr
Definition: grepfile.py:32
ECAL_ADC_FRAG
#define ECAL_ADC_FRAG
Definition: TileTBFrag.h:30
TileTBDump::T_TileRecoQuality::Sstrobe
uint16_t Sstrobe
Definition: TileTBDump.h:146
error
Definition: IImpactPoint3dEstimator.h:70
TileCalibUtils::getDrawerIdxFromFragId
static unsigned int getDrawerIdxFromFragId(unsigned int fragId)
Returns a drawer hash from fragId This function assumes drawer context (i.e.
Definition: TileCalibUtils.cxx:71
TileTBDump::dump_data
void dump_data(const uint32_t *data, unsigned int size, unsigned int version, int verbosity)
Definition: TileTBDump.cxx:492
python.compressB64.c
def c
Definition: compressB64.py:93
TileTBDump::T_TileRecoCalib
Definition: TileTBDump.h:176
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
COIN_TRIG5_FRAG
#define COIN_TRIG5_FRAG
Definition: TileTBFrag.h:36
CRC_error_1
#define CRC_error_1
TileRawChannel2Bytes5::TileChanData::code
int code
Definition: TileRawChannel2Bytes5.h:59
TileTBDump::T_TileRawComp::verif
bool verif
Definition: TileTBDump.h:170
readCCLHist.float
float
Definition: readCCLHist.py:83
TileTBDump::T_TileRawComp::chan
int chan
Definition: TileTBDump.h:171
MuonSegmentReaderConfig.reco
reco
Definition: MuonSegmentReaderConfig.py:133
COIN_TRIG4_FRAG
#define COIN_TRIG4_FRAG
Definition: TileTBFrag.h:35
checkFileSG.ind
list ind
Definition: checkFileSG.py:118
fitman.k
k
Definition: fitman.py:528
QUALITY_RANGE2
const int QUALITY_RANGE2
Definition: TileRawChannel2Bytes2.h:53
TileTBDump::T_TileRecoChannel
Definition: TileTBDump.h:156
TileTBDump::m_dumpUnknown
bool m_dumpUnknown
Definition: TileTBDump.h:95
TIME_RANGE2
const int TIME_RANGE2
Definition: TileRawChannel2Bytes2.h:46