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