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