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