ATLAS Offline Software
Loading...
Searching...
No Matches
TBByteStreamCnvTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "GaudiKernel/MsgStream.h"
7#include "Gaudi/Property.h"
9
10#include "eformat/Status.h"
11
12#include "GaudiKernel/TypeNameString.h"
13
18#include "GaudiKernel/ThreadLocalContext.h"
19
20#include <list>
21
22#include <iostream>
23#include <fstream>
24#include <sstream>
25#include <string>
26
27const eformat::SubDetector TBByteStreamCnvTool::m_DontCheckRodSubDetID=(eformat::SubDetector)0xff;
28
29
31{
32 static const InterfaceID IID_ITBByteStreamCnvTool
33 ("TBByteStreamCnvTool", 1, 0);
34 return IID_ITBByteStreamCnvTool;
35}
36
37// default contructor
38
40( const std::string& type, const std::string& name,const IInterface* parent )
41 : AthAlgTool(type,name,parent),
42 m_ByteStreamEventAccess("ByteStreamCnvSvc", name),
43 m_rdpSvc("ROBDataProviderSvc", name),
44 m_lastEventID(0, UINT_MAX), m_subdet_id(eformat::TDAQ_BEAM_CRATE),
46{
47 declareInterface< TBByteStreamCnvTool >( this );
48 m_tbtdc=0;
49 declareProperty("ForceHchoice",m_force_Hchoice=false);
50 declareProperty("Dump",m_dump=false);
51 declareProperty("isH6Run",m_H6run=true);
52 declareProperty("isH8Run",m_H8run=false);
53 declareProperty("Keys",m_keys);
54 declareProperty("SubDetID",m_subdet_key);
55 declareProperty("SummaryPath",m_summary_path);
56
57}
58
60{StatusCode sc=AthAlgTool::initialize();
61 if (sc!=StatusCode::SUCCESS)
62 return sc;
63 MsgStream logstr(msgSvc(), name());
64 logstr << MSG::DEBUG << "Initialize" << endmsg;
65
66 const LArOnlineID* online_id;
67 sc = detStore()->retrieve(online_id, "LArOnlineID");
68 if (sc.isFailure()) {
69 logstr << MSG::FATAL << "Could not get LArOnlineID helper !" << endmsg;
70 return StatusCode::FAILURE;
71 }
72 else {
73 m_onlineHelper=online_id;
74 logstr << MSG::DEBUG << " Found the LArOnlineID helper. " << endmsg;
75 }
76
78 ATH_CHECK( m_rdpSvc.retrieve() );
79
80 std::vector<std::string>::const_iterator it = m_keys.begin();
81 std::vector<std::string>::const_iterator it_e = m_keys.end();
82 std::vector<std::string> keys;
83 keys.resize(24);
84 for(; it!=it_e;++it) {
85 const Gaudi::Utils::TypeNameString &item(*it);
86 const std::string &t = item.type();
87 const std::string &nm = item.name();
88 logstr << MSG::DEBUG << " type "<<t<<" name="<<nm<<endmsg;
89 if(t=="TBTDC") keys[0]=nm;
90 if(t=="TBTriggerPatternUnit") keys[1]=nm;
91 if(t=="TBTDCRawCont") keys[2]=nm;
92 if(t=="TBADCRawCont") keys[3]=nm;
93 if(t=="TBTailCatcherRaw") keys[4]=nm;
94 if(t=="TBBPCRawCont") keys[5]=nm;
95 if(t=="TBScintillatorRawCont") keys[6]=nm;
96 if(t=="TBMWPCRawCont") keys[7]=nm;
97 }
98 // Fixed name.
99 keys[10]="FREE";
100 keys[11]="LOW";
101 keys[12]="MEDIUM";
102 keys[13]="HIGH";
103 // name for Calib Digits
104 keys[20]="FREE";
105 keys[21]="LOW";
106 keys[22]="MEDIUM";
107 keys[23]="HIGH";
108
109
110 m_keys=std::move(keys);
111 m_subdet_id=(eformat::SubDetector)m_subdet_key;
112
113 m_isCalib = false;
114
115 m_febgain.clear();
116
117 ATH_CHECK( m_CLKey.initialize() );
118
119 return StatusCode::SUCCESS;
120}
121
123{
124 return StatusCode::SUCCESS;
125}
126
127/* ----------------------------------------------------------------------
128
129 Write ByteStream Methods
130
131------------------------------------------------------------------------*/
132
134{
137
138 MsgStream logstr(msgSvc(), name());
139 logstr << MSG::DEBUG << "WriteFragment" << endmsg;
140 //Check if Fragment is already written
141 const EventInfo* thisEventInfo;
142 StatusCode sc=evtStore()->retrieve(thisEventInfo);
143 if (sc!=StatusCode::SUCCESS)
144 {logstr << MSG::WARNING << "No EventInfo object found!" << endmsg;
145 return sc;
146 }
147 const EventID* thisEvent=thisEventInfo->event_ID();
148 if (m_lastEventID==*thisEvent)
149 {logstr << MSG::WARNING << "LArByteStrem persistency representation for Event #"<<thisEvent->event_number()
150 << " already created!" << endmsg;
151 return StatusCode::SUCCESS;
152 }
153 else //New event ID
154 m_lastEventID=*thisEvent;
155
156 // Get the already existing part of the RawEvent
157 RawEventWrite* re = m_ByteStreamEventAccess->getRawEvent();
158
159 // delete previous fragments
160 if (m_theRodBlock) delete m_theRodBlock;
161 if (m_theROB) delete m_theROB;
162
163 //Make a new ROD-Fragment
164 m_theRodBlock=new std::vector<uint32_t>;
165
167
168 if (sc!=StatusCode::SUCCESS)
169 return sc;
170
171 //Header elements for new Fragments
172 const uint8_t module_id=0;
173 const uint32_t lvl1_id=re->lvl1_id();
174 const uint32_t bc_id=0;
175 const uint32_t lvl1_type = 0;
176 const uint32_t detev_type=0;
177 const bool status_place=eformat::STATUS_BACK;
178 const uint32_t run_no=re->run_no();
179
180 //Make a new ROB-Fragment...
181 eformat::helper::SourceIdentifier robsid(m_subdet_id, module_id);
183 (robsid.code(),run_no,lvl1_id,bc_id,lvl1_type,detev_type,m_theRodBlock->size(),
184 &(*m_theRodBlock)[0],status_place);
185
186 re->append(m_theROB); //Append the newly created Subdetector-Fragment to the full event
187 logstr << MSG::DEBUG << "Appended TestBeam fragment to ByteStream" << endmsg;
188 return StatusCode::SUCCESS;
189}
190
191StatusCode TBByteStreamCnvTool::BuildRODBlock(std::vector<uint32_t> *theRodBlock)
192{
195
196 MsgStream logstr(msgSvc(), name());
197 //Get necessary Data objects
198 StatusCode sc;
199
200 // TBTDCRaw part of the block :
201 const TBTDC* tbtdc = nullptr;
202 std::string tbtdc_Key("TBTDC");
203 sc=evtStore()->retrieve(tbtdc,tbtdc_Key);
204 if (sc!=StatusCode::SUCCESS)
205 {logstr << MSG::ERROR << "Can't retrieve TBTDC with key "<< tbtdc_Key << " from StoreGate" << endmsg;
206 return sc;
207 }
208 else {
209 theRodBlock->push_back(4); // TIME_SIZE
210 theRodBlock->push_back(0x03); // TIME_ID
211 theRodBlock->push_back(tbtdc->tdc());
212 theRodBlock->push_back(tbtdc->tdcmin());
213 }
214
215
216 // TBBPCRaw :
217// TBBPCRawCont * bpcrawCont;
218// sc = m_storeGate->retrieve(bpcrawCont, "BPCRawCont");
219// if (sc.isFailure()){
220// logstr << MSG::DEBUG << "BeamDetectorMonitoring: Retrieval of BPCRaw failed" << endmsg;
221// }else {
222// TBBPCRawCont::const_iterator it_bc = bpcrawCont->begin();
223// TBBPCRawCont::const_iterator last_bc = bpcrawCont->end();
224// // theRodBlock->push_back(2+bpcrawCont->size()*6); // BPC_SIZE
225// // theRodBlock->push_back(0x05); // BPC_ID (BPCRaw)
226
227// for(it_bc= bpcrawCont->begin();it_bc!=last_bc;it_bc++){
228// // theRodBlock->push_back((*it_bc)->getSignal((int) TBBPCRaw::tdcLeft));
229// // theRodBlock->push_back((*it_bc)->getSignal((int) TBBPCRaw::tdcRight));
230// // theRodBlock->push_back((*it_bc)->getSignal((int) TBBPCRaw::tdcUp));
231// // theRodBlock->push_back((*it_bc)->getSignal((int) TBBPCRaw::tdcDown));
232// // theRodBlock->push_back((*it_bc)->getSignal((int) TBBPCRaw::adcHorizontal));
233// // theRodBlock->push_back((*it_bc)->getSignal((int) TBBPCRaw::adcVertical));
234// }
235// }
236
237 // Trigger Pattern :
238// TBTriggerPatternUnit *trigpat;
239// sc = m_storeGate->retrieve(trigpat, "TBTrigPat");
240// if (sc.isFailure()){
241// logstr << MSG::DEBUG << "BeamDetectorMonitoring: Retrieval of TrigPat failed" << endmsg;
242
243// }else {
244// theRodBlock->push_back(3); // TrigPat_SIZE
245// theRodBlock->push_back(0x01); // TrigPat_ID (TrigPatRaw)
246// theRodBlock->push_back(trigpat->getTriggerWord());
247// }
248
249
250 return StatusCode::SUCCESS;
251}
252
253
254
255
256/* ----------------------------------------------------------------------
257
258 Read ByteStream Methods
259
260------------------------------------------------------------------------*/
261
262StatusCode TBByteStreamCnvTool::ReadFragment(int unrec_code){
263
264 StatusCode sc;
265 if(m_H6run) sc=H6BuildObjects(unrec_code); // build all objects, do not record object unrec_code
266 if(m_H8run) sc=H8BuildObjects(unrec_code); // build all objects, do not record object unrec_code
267 return sc;
268}
269
270StatusCode TBByteStreamCnvTool::ReadFragment(TBTDC*& tbtdc,const std::string& key)
271{
273 MsgStream logstr(msgSvc(), name());
274 logstr << MSG::DEBUG <<" in ReadFragment (TBTDC) key="<<key<<endmsg;
275 StatusCode sc=GetRODBlock(m_subdet_id); //Possible improvement: Check if vector is already valid.
276 if (sc!=StatusCode::SUCCESS)
277 return sc;
278 if (m_rodBlock.size()<2)
279 {
280 logstr << "ReadRodBlock: RodBlock too small!" << endmsg;
281 return StatusCode::FAILURE;
282 }
283 int tdc=m_rodBlock[0];
284 int tdcmin=m_rodBlock[1];
285 logstr << MSG::DEBUG <<" tdc = "<< tdc <<endmsg;
286 logstr << MSG::DEBUG <<" tdcmin = "<< tdcmin <<endmsg;
287 tbtdc=new TBTDC(tdc,tdcmin);
288 return StatusCode::SUCCESS;
289 // return sc;
290}
291
292StatusCode TBByteStreamCnvTool::ReadFragment(TBBPCRawCont*& bpcrawCont,const std::string& key)
293{MsgStream logstr(msgSvc(), name());
294 logstr << MSG::DEBUG <<" in ReadFragment (TBBPCRawCont) key="<<key<<endmsg;
295 StatusCode sc=ReadFragment(5);
296 if(sc) bpcrawCont = m_bpcrawCont;
297 logstr << MSG::DEBUG <<" End ReadFragment (TBBPCRawCont) key="<<key<<endmsg;
298 return sc;
299}
300
301StatusCode TBByteStreamCnvTool::ReadFragment(TBMWPCRawCont*& mwpcrawCont,const std::string& key)
302{MsgStream logstr(msgSvc(), name());
303 logstr << MSG::DEBUG <<" in ReadFragment (TBMWPCRawCont) key="<<key<<endmsg;
304 StatusCode sc=ReadFragment(7);
305 if(sc) mwpcrawCont = m_mwpcrawCont;
306 return sc;
307}
308
309StatusCode TBByteStreamCnvTool::ReadFragment(TBADCRawCont*& adcrawCont,const std::string& key)
310{MsgStream logstr(msgSvc(), name());
311 logstr << MSG::DEBUG <<" in ReadFragment (TBADCRawCont) key="<<key<<endmsg;
312 StatusCode sc=ReadFragment(3);
313 if(sc) adcrawCont = m_adcrawCont;
314 return sc;
315}
316StatusCode TBByteStreamCnvTool::ReadFragment(TBTDCRawCont*& tdcrawCont,const std::string& key)
317{MsgStream logstr(msgSvc(), name());
318 logstr << MSG::DEBUG <<" in ReadFragment (TBTDCRawCont) key="<<key<<endmsg;
319 StatusCode sc=ReadFragment(2);
320 if(sc) tdcrawCont = m_tdcrawCont;
321 return sc;
322}
323
324StatusCode TBByteStreamCnvTool::ReadFragment(TBTriggerPatternUnit*& trigpat,const std::string& key)
325{MsgStream logstr(msgSvc(), name());
326 logstr << MSG::DEBUG <<" in ReadFragment (TBTriggerPatternUnit) key="<<key<<endmsg;
327 StatusCode sc=ReadFragment(1);
328 if(sc) trigpat = m_trigpat;
329 return sc;
330}
331
332StatusCode TBByteStreamCnvTool::ReadFragment(TBScintillatorRawCont*& scintrawCont,const std::string& key)
333{MsgStream logstr(msgSvc(), name());
334 logstr << MSG::DEBUG <<" in ReadFragment (TBScintrawcont) key="<<key<<endmsg;
335 StatusCode sc=ReadFragment(6);
336 if(sc) scintrawCont = m_scintrawCont;
337 return sc;
338}
339
340StatusCode TBByteStreamCnvTool::ReadFragment(TBTailCatcherRaw*& tailcatchraw,const std::string& key)
341{MsgStream logstr(msgSvc(), name());
342 logstr << MSG::DEBUG <<" in ReadFragment (TBTailCatcherRaw) key="<<key<<endmsg;
343 StatusCode sc=ReadFragment(4);
344 if(sc) tailcatchraw = m_tailcatchraw;
345 return sc;
346}
347StatusCode TBByteStreamCnvTool::ReadFragment(TBEventInfo*& tbeventinfo,const std::string& key)
348{MsgStream logstr(msgSvc(), name());
349 logstr << MSG::DEBUG <<" in ReadFragment (TBEventInfo) key="<<key<<endmsg;
350 StatusCode sc=ReadFragment(30);
351 if(sc) tbeventinfo = m_eventinfo;
352 return sc;
353}
354
355StatusCode TBByteStreamCnvTool::ReadFragment(TBLArDigitContainer*& tblardigitcont,const std::string& key)
356{MsgStream logstr(msgSvc(), name());
357 logstr << MSG::DEBUG <<" in ReadFragment (TBLArDigitContainer) key="<<key<<endmsg;
358 int code=0;
359 if(key=="FREE") code = 10;
360 if(key=="LOW") code = 11;
361 if(key=="HIGH") code = 12;
362 if(key=="MEDIUM") code = 13;
363 if(code){
364 StatusCode sc=ReadFragment(code);
365 if(sc) tblardigitcont = m_tblardigitcont[code-10];
366 return sc;
367 }else{
368 logstr << MSG::ERROR <<" Can not create a LArDigitContainer with key="<<key<<endmsg;
369 tblardigitcont =0;
370 return StatusCode::FAILURE;
371 }
372}
373
374StatusCode TBByteStreamCnvTool::ReadFragment(TBLArCalibDigitContainer*& tblarcalibdigitcont,const std::string& key)
375{MsgStream logstr(msgSvc(), name());
376 logstr << MSG::DEBUG <<" in ReadFragment (TBLArCalibDigitContainer) key="<<key<<endmsg;
377 int code=0;
378 if(key=="FREE") code = 20;
379 if(key=="LOW") code = 21;
380 if(key=="HIGH") code = 22;
381 if(key=="MEDIUM") code = 23;
382 if(code){
383 StatusCode sc=ReadFragment(code);
384 if(sc) tblarcalibdigitcont = m_tblarcalibdigitcont[code-20];
385 return sc;
386 }else{
387 logstr << MSG::ERROR <<" Can not create a LArCalibDigitContainer with key="<<key<<endmsg;
388 tblarcalibdigitcont =0;
389 return StatusCode::FAILURE;
390 }
391}
392
393
394
395StatusCode TBByteStreamCnvTool::GetRODBlock(eformat::SubDetector subdet_id,
396 eformat::SubDetector subdet_rod_id)//=m_DontCheckRodSubDetID)
397
398{MsgStream logstr(msgSvc(), name());
399 logstr << MSG::DEBUG << "GetRODBlock" << endmsg;
400 if (!m_rdpSvc)
401 {logstr << MSG::ERROR << "ROBDataProviderSvc not loaded. Can't read ByteStream" << endmsg;
402 return StatusCode::FAILURE;
403 }
404
405 const RawEvent* re = m_rdpSvc->getEvent(Gaudi::Hive::currentContext());
406
407 if (!re)
408 {logstr <<MSG::FATAL << "Can't get RawEvent!" << endmsg;
409 return StatusCode::FAILURE;
410 }
411
412 const size_t MAX_ROBFRAGMENTS = 2048*1024;
413 std::vector<OFFLINE_FRAGMENTS_NAMESPACE::PointerType> robF(MAX_ROBFRAGMENTS);
414 size_t robcount = re->children(robF.data(),MAX_ROBFRAGMENTS);
415 // re->start(robF);
416 if (robcount == MAX_ROBFRAGMENTS)
417 {
418 logstr <<MSG::FATAL << "ROB buffer overflow" << endmsg;
419 return StatusCode::FAILURE;
420 }
421
422 for (size_t irob=0; irob<robcount; ++irob) //Loop over all ROB-Fragments
423 {
425
426 logstr << MSG::DEBUG << "ROB Frag *****************************" << endmsg;
427 MSG::hex(logstr) << MSG::DEBUG <<"Marker : " << rob.marker() << endmsg;
428 MSG::hex(logstr) << MSG::DEBUG <<"Frag Size : " << rob.fragment_size_word() << endmsg;
429 MSG::hex(logstr) << MSG::DEBUG <<"Header Size: " << rob.header_size_word() << endmsg;
430 MSG::hex(logstr) << MSG::DEBUG <<"Source ID : " << rob.source_id() << endmsg;
431 MSG::hex(logstr) << MSG::DEBUG <<"Version : " << rob.version() << endmsg;
432 try
433 {
434 rob.check();
435 }
436 catch (...)
437 {
438 logstr << MSG::ERROR << "Got invalid ROB fragment!" << endmsg;
439 return StatusCode::FAILURE;
440 }
441
442 logstr << MSG::DEBUG << "ROD Frag *****************************" << endmsg;
443 MSG::hex(logstr) << MSG::DEBUG <<"Frag Size : " << rob.rod_fragment_size_word() << endmsg;
444 MSG::hex(logstr) << MSG::DEBUG <<"Header Size: " << rob.rod_header_size_word() << endmsg;
445 MSG::hex(logstr) << MSG::DEBUG <<"Source ID : " << rob.rod_source_id() << endmsg;
446 MSG::hex(logstr) << MSG::DEBUG <<"Run num : " << rob.rod_run_no() << endmsg;
447 MSG::hex(logstr) << MSG::DEBUG <<"Version : " << rob.rod_version() << endmsg;
448
449 eformat::helper::SourceIdentifier rod_sid(rob.rod_source_id());
450 if (subdet_rod_id==m_DontCheckRodSubDetID || rod_sid.subdetector_id()==subdet_rod_id)
451 {
452 MSG::hex(logstr) << MSG::DEBUG << "Found requested ROD (id="
453 << rod_sid.subdetector_id() << ")" << endmsg;
454 // Set H6 or H8 mode :
455 if (!m_force_Hchoice)
456 {
457 logstr<< MSG::INFO << "Guessing from ROD header -> " ;
458 if (rob.rod_detev_type()&1)
459 {
460 logstr<< " H6 !" << endmsg;
461 m_H6run = true;
462 m_H8run = false;
463 }
464 else
465 {
466 logstr<< " H8 !" << endmsg;
467 m_H6run = false;
468 m_H8run = true;
469 }
470 }
471 m_h8_triggword = rob.rod_lvl1_trigger_type();
472 // Event number ?
473 m_ev_number = rob.rod_lvl1_id();
474 if(m_dump) MSG::dec(logstr) << MSG::INFO << " Ev. number(header)=" << m_ev_number <<endmsg;
475
477 rob.rod_data(rodPointer);
478 m_rodBlock.clear();
479 for(size_t i=0; i<rob.rod_ndata(); ++i)
480 {
481 m_rodBlock.push_back(*rodPointer);
482 ++rodPointer;
483 }
484
485 if (m_rodBlock.size()==0)
486 {
487 logstr << MSG::FATAL << "Error reading bytestream event: "
488 << "Empty ROD block" << endmsg;
489 return StatusCode::FAILURE;
490 }
491 logstr << MSG::DEBUG << "Got Rod Block for Test Beam Instrumentation data from ByteStream" << endmsg;
492 return StatusCode::SUCCESS;
493 }// end if requested ROD
494 }//end loop over ROBs
495
496 MSG::hex(logstr) << MSG::WARNING << " Didn't find SubDet ID for Beam Instruments. Should be "<< subdet_id<<endmsg;
497 return StatusCode::FAILURE;
498}
499
500/*---------------------------------------------------------------------------*/
501
502StatusCode TBByteStreamCnvTool::H6BuildObjects(int unrec_code)
503
504/*---------------------------------------------------------------------------*/
505{
512
513 MsgStream logstr(msgSvc(), name());
514 logstr << MSG::DEBUG << "H6BuildObject called for " << unrec_code<< endmsg;
515
516 const EventContext& ctx = Gaudi::Hive::currentContext();
517
518 StatusCode sc=StatusCode::FAILURE;
519 //bool gotobject=false;
520 //bool recordfailure=false;
521
522 // for string conversion
523 std::ostringstream os;
524
525 // Get ROD block.
526 sc=GetRODBlock(m_subdet_id); //Possible improvement: Check if vector is already valid.
527 if (sc!=StatusCode::SUCCESS)
528 return sc;
529 if (m_rodBlock.size()<2)
530 {MsgStream logstr(msgSvc(), name());
531 logstr << MSG::ERROR << "ReadRodBlock: RodBlock too small!" << endmsg;
532 return StatusCode::FAILURE;
533 }
534
535
536
537
539 m_tailcatchraw = 0;
543
544 for(int i=0;i<4;i++) m_tblardigitcont[i] = new TBLArDigitContainer();
545 for(int i=0;i<4;i++) m_tblarcalibdigitcont[i] = new TBLArCalibDigitContainer();
546
547 std::string name1,name2;
549 TBTDCRaw* dummytdc = new TBTDCRaw("dummy",true,0,true);
550 m_tdcrawCont->push_back(dummytdc);
551
553 TBADCRaw* dummyadc = new TBADCRaw("dummy",true,0);
554 m_adcrawCont->push_back(dummyadc);
555
557
558
559 // with this initialisation, first call of NextSubFrag will initialise correctly the index :
560 m_subfrag_id=0;
563 while(NextSubFrag()){
564 MSG::dec(logstr) << MSG::DEBUG << "size "<<m_subfrag_size<<endmsg;
565 MSG::hex(logstr) << MSG::DEBUG << "ID "<< m_subfrag_id<<endmsg;
566 switch(m_subfrag_id){
567 case 0x01: // HEADER_ID -----------------------------------------
568 {
569 logstr << MSG::DEBUG << "H6BuildObject : HEADER_ID "<< m_subfrag_size << endmsg;
570 //m_trigpat = new TBTriggerPatternUnit();
571 m_trigpat->setTriggerWord(m_rodBlock[m_subfrag_firstdata+3]);
572 MSG::hex(logstr) << MSG::DEBUG << "Header "<<m_rodBlock[m_subfrag_firstdata];
573 MSG::hex(logstr) <<" "<<m_rodBlock[m_subfrag_firstdata+1];
574 MSG::hex(logstr) <<" "<<m_rodBlock[m_subfrag_firstdata+2];
575 MSG::hex(logstr) <<" "<<m_rodBlock[m_subfrag_firstdata+3]<<endmsg;
576 // if(unrec_code == 30 ) gotobject=true;
577 if(m_dump) MSG::dec(logstr) << MSG::INFO << " Ev. number(0x01)="<< m_rodBlock[m_subfrag_firstdata] <<endmsg;
581 m_run_num,
584 m_cryoX,
586 m_tableY);
587 }
588 break;
589
590 case 0x02: // MINI-ROD Data Fragment ... oh what fun ... ------------
591 {
592 logstr << MSG::DEBUG << " Found mini-ROD data in beam crate fragment, size " << m_subfrag_size << endmsg;
593
594 // bool calibdigit_requested = (unrec_code==20)||(unrec_code==21)||(unrec_code==22)||(unrec_code==23);
595 //
596 short m_feedthrough[8] = {0,0,0,0,1,1,1,1};
597 int m_sampleOrder[32] = {
598 0,1,2,3,4,5,6,7,8,9,10,
599 11,12,13,14,15,16,17,18,19,20,
600 21,22,23,24,25,26,27,28,29,30,
601 31};
602 int m_sort[64] = { 55, 39, 23, 7, 119, 103, 87, 71,
603 54, 38, 22, 6, 118, 102, 86, 70,
604 53, 37, 21, 5, 117, 101, 85, 69,
605 52, 36, 20, 4, 116, 100, 84, 68,
606 51, 35, 19, 3, 115, 99, 83, 67,
607 50, 34, 18, 2, 114, 98, 82, 66,
608 49, 33, 17, 1, 113, 97, 81, 65,
609 48, 32, 16, 0, 112, 96, 80, 64
610 } ;
611
612
613 constexpr short m_slot[8]={5,7,9,11,3,4,5,6};
614
615 constexpr int NWREC = 8;
616 int pos=m_subfrag_firstdata;
617 for(unsigned int nfeb=0;nfeb<m_boards.size();nfeb++){ // FEB loop ----------------------------------
618 pos += NWREC*3; // skip FEB header
619 if(m_dump) logstr << MSG::DEBUG << " Board "<< nfeb << endmsg;
620 for(int s=0;s<m_samples[0];s++){ // sample loop ----------------------------------
621 pos +=NWREC;
622 int samp;
623 for(unsigned int g=0;g<m_gains.size();g++){ // gain loop ----------------------------------
624 int gainmode;
625
626 // According to 'FebAuto' keys, sort sample (cf Petr G. doc)
627 if(m_febgain[nfeb]==0){ // Default behavior
628 gainmode=m_gains[g];
629 if((gainmode==0)&&((m_sampleOrder[0]=m_firstsamples[0])!=0))
630 {
631 for(int j=0;j<m_firstsamples[0];j++) {m_sampleOrder[j+1]=j;}
632 }
633 }
634 else { // this FEB is AutoGain and first sample given in m_febgain
635 gainmode=0;
636 if((m_sampleOrder[0]=m_febgain[nfeb])!=0){
637 for(int j=0;j<m_febgain[nfeb];j++) {m_sampleOrder[j+1]=j;}
638 }
639 }
640 samp=m_sampleOrder[s];
641
642 if(m_dump&&(gainmode==2)) logstr << MSG::DEBUG << " channels ";
643 for( int i= 0 ;i<64; i++){ // channel loop ----------------------------------
644 int chan= m_sort[i];
645
646 unsigned short tmp1 = firstword(m_rodBlock[pos]);
647 unsigned short gain1 = ((tmp1>>12)&3) - 1;
648 m_arrayofsample[chan+8][gainmode][samp]=firstnbit(12,tmp1);
649
650 unsigned short tmp2 = secondword(m_rodBlock[pos]);
651 unsigned short gain2 = ((tmp2>>12)&3) - 1;
652 m_arrayofsample[chan][gainmode][samp]=firstnbit(12,tmp2);
653
654 m_arrayofgain[chan+8][gainmode] = getCaloGain(gain1);
655 m_arrayofgain[chan][gainmode] = getCaloGain(gain2);
656
657
658 // if(m_dump&(gainmode==2)) logstr << MSG::INFO << " " <<firstnbit(12,tmp1);
659 if(m_dump&&(gainmode==2)) logstr << MSG::DEBUG << " (," << chan << ","<< gainmode <<"," << samp <<","<< m_arrayofsample[chan+8][gainmode][samp]<<")";
660 pos++;
661 } // end channel loop
662
663 if(m_dump&&(gainmode==2)) logstr << MSG::DEBUG <<endmsg;
664 } // end gain loop
665 }// end sample loop
666 pos+= NWREC*2;
667 logstr << MSG::DEBUG << " Creating LArDigit for board "<< nfeb << ". m_febgain=" << m_febgain[nfeb] <<endmsg;
668 // create and store LArDigit.
669 for(unsigned int g=0;g<m_gains.size();g++){ // loop on reqested gains
670 int gainmode;
671 if(m_febgain[nfeb]==0){ // Default behavior
672 gainmode= m_gains[g];
673 } else { // this FEB is AutoGain and first sample given in m_febgain
674 gainmode=0;
675 }
676
677 logstr << MSG::DEBUG << "Gain mode="<< gainmode <<endmsg;
678 for(int i=0;i<128;i++) { // loop on channels
679
680 std::vector<short> samplevec(m_arrayofsample[i][gainmode]);
681 samplevec.resize(m_samples[0]);
682 CaloGain::CaloGain gain= m_arrayofgain[i][gainmode];
683 HWIdentifier hwid=m_onlineHelper->channel_Id(1,1,m_feedthrough[m_boards[nfeb]-1],m_slot[m_boards[nfeb]-1],i);
684 LArDigit * lardig= new LArDigit(hwid,gain,samplevec);
685 m_tblardigitcont[gainmode]->push_back(lardig);
686 if(m_isCalib) {
687 bool isPulsed=false;
688 const std::vector<HWIdentifier>& calibChannelIDs=calibLine->calibSlotLine(hwid);
689 if (calibChannelIDs.size() != 0) {
690 // Now figure out if any calibration line connected to this channel is pulsed.
691 // I'm going to cheat and use the fact that we only pulsed one board at a time
692 // and only wrote the corresponding digits (EMEC/HEC/FCAL)
693 for (HWIdentifier calChan : calibChannelIDs) {
694 int chan = m_onlineHelper->channel(calChan);
695 int bit = chan%8;
696 int byte = chan/8;
697 // if( 1<<bit & m_calib_pattern[byte] ) {
698 if( 128>>bit & m_calib_pattern[byte] ) {
699 isPulsed = true;
700 }
701 }
702 }
703 LArCalibDigit * larcalibdig= new LArCalibDigit(hwid,gain,samplevec,m_calib_dac,m_calib_delay,isPulsed);
704 m_tblarcalibdigitcont[gainmode]->push_back(larcalibdig);
705 }
706 }
707 if(m_febgain[nfeb]!=0){ // this FEB is AutoGain ignore every gain in FebGain
708 break;
709 }
710 }
711 }// FEB loop
712
713 }
714 break;
715
716 case 0x03: // TIME_ID -----------------------------------------
717 {
718 logstr << MSG::DEBUG << "H6BuildObject : TIME_ID "<< m_subfrag_size << endmsg;
719 name1="word1frag0x03chan";
720 name2="word2frag0x03chan";
721
722
723 if(m_subfrag_size!=5) {
724 logstr<<MSG::ERROR<< "Beam counter subfrag (0x03) has not expected size" <<endmsg;
725 sc=StatusCode::FAILURE;
726 break;
727 }
728 int pos=m_subfrag_firstdata;
729 int tmp1,tmp2;
730
731 tmp1 = firstword(m_rodBlock[pos]);
732 tmp2 = secondword(m_rodBlock[pos]);
733
734 if(m_dump) logstr << MSG::INFO << " sub frag 0x03 : word1="<<tmp1<<" word2="<< tmp2 <<endmsg;
735
736 TBTDCRaw * clocktdc = new TBTDCRaw(name1+'0',false,tmp1,false);
737 TBTDCRaw * clock_deltdc = new TBTDCRaw(name2+'0',false,tmp2,false);
738 m_tdcrawCont->push_back(clocktdc);
739 m_tdcrawCont->push_back(clock_deltdc);
740
741 tmp1 = firstword(m_rodBlock[pos+1]);
742 tmp2 = secondword(m_rodBlock[pos+1]);
743
744 if(m_dump) logstr << MSG::INFO << " sub frag 0x03 : word1="<<tmp1<<" word2="<< tmp2 <<endmsg;
745
746 TBTDCRaw * scale1 = new TBTDCRaw(name1+'1',false,tmp1,false);
747 TBTDCRaw * scale1bis = new TBTDCRaw(name2+'1',false,tmp2,false);
748 m_tdcrawCont->push_back(scale1);
749 m_tdcrawCont->push_back(scale1bis);
750
751 tmp1 = firstword(m_rodBlock[pos+2]);
752 tmp2 = secondword(m_rodBlock[pos+2]);
753
754 if(m_dump) logstr << MSG::INFO << " sub frag 0x03 : word1="<<tmp1<<" word2="<< tmp2 <<endmsg;
755
756 TBTDCRaw * scale2 = new TBTDCRaw(name1+'2',false,tmp1,false);
757 TBTDCRaw * scale2bis = new TBTDCRaw(name2+'2',false,tmp2,false);
758 m_tdcrawCont->push_back(scale2);
759 m_tdcrawCont->push_back(scale2bis);
760
761 }
762 break;
763 case 0x04: // TAIL_ID -----------------------------------------
764 {
765 name1="word1frag0x06chan";
766 name2="word2frag0x06chan";
767 std::string tcname="tc";
768 std::vector<TBScintillatorRaw *> theScints;
769 if(m_subfrag_size!=26) {
770 logstr<<MSG::ERROR<< "Beam counter subfrag (0x04) has not expected size" <<endmsg;
771 sc=StatusCode::FAILURE;
772 break;
773 }
774 logstr << MSG::DEBUG << "H6BuildObject : building tailcatcher " << endmsg;
775 for(unsigned int i=0;i<24;i++){
776 int tmp1,tmp2;
777 int pos=m_subfrag_firstdata+i;
778 unsigned short word1=firstword(m_rodBlock[pos]);
779 unsigned short word2=secondword(m_rodBlock[pos]);
780
781 tmp1 = firstnbit(10,word1);
782 tmp2 = firstnbit(10,word2);
783
784 os.str("");
785 os << name1 << i;
786 TBADCRaw* adc1 = new TBADCRaw(os.str(),false,abs(tmp1));
787 os.str("");
788 os << name2 << i;
789 TBADCRaw* adc2 = new TBADCRaw(os.str(),false,abs(tmp2));
790 if(testbit(10,word1)) adc1->setOverflow(); // if bit10=0 -> Overflow
791 if(testbit(10,word2)) adc2->setOverflow(); // if bit10=0 -> Overflow
792 m_adcrawCont->push_back(adc1);
793 m_adcrawCont->push_back(adc2);
794 os.str("");
795 os << tcname << 2*i;
796 TBScintillatorRaw* s1 = new TBScintillatorRaw(os.str(),m_tdcrawCont,dummytdc,m_adcrawCont,adc1);
797 os.str("");
798 os << tcname << 2*i+1;
799 TBScintillatorRaw* s2 = new TBScintillatorRaw(os.str(),m_tdcrawCont,dummytdc,m_adcrawCont,adc2);
800 theScints.push_back(s1);
801 theScints.push_back(s2);
802 }
803
804 m_tailcatchraw = new TBTailCatcherRaw("TailCatherRaw",false,theScints);
805 //if(unrec_code == 4 ) gotobject=true;
806 }
807 break;
808
809 case 0x05: // BPC_ID -----------------------------------------
810 {
811 name1="word1frag0x05chan";
812 name2="word2frag0x05chan";
813 //m_bpcrawCont = new TBBPCRawCont();
814 int bpcnum = (m_subfrag_size - 2) / 3; // cause we store 6 tdc/adc in 16bits word
815 logstr << MSG::DEBUG << "H6BuildObject : number of BPCRaw "<< bpcnum << endmsg;
816 // get bpc raw information for each chamber:
817 for(int i=0;i<bpcnum;i++){
818 std::string bpcname = "BPC";
819 os.str("");
820 os << bpcname << i;
821 bpcname= os.str();
822 std::vector<const TBTDCRaw*> theTDCs;
823 std::vector<const TBADCRaw*> theADCs;
824 int pos=m_subfrag_firstdata;
825
826 unsigned int tmp1,tmp2;
827 tmp1=firstword(m_rodBlock[pos+i*3]);
828 tmp2=secondword(m_rodBlock[pos+i*3]);
829 os.str("");
830 os << name1 << (i*3);
831 TBADCRaw* tbadcH = new TBADCRaw(os.str(),(tmp1>1023),tmp1);
832 os.str("");
833 os << name2 << (i*3);
834 TBADCRaw* tbadcV = new TBADCRaw(os.str(),(tmp1>1023),tmp2);
835 m_adcrawCont->push_back(tbadcH);
836 m_adcrawCont->push_back(tbadcV);
837
838 // first word is right :
839 tmp1=firstword(m_rodBlock[pos+i*3+1]);
840 tmp2=secondword(m_rodBlock[pos+i*3+1]);
841 os.str("");
842 os << name2 << (i*3+1);
843 TBTDCRaw * tbtdcL = new TBTDCRaw(os.str(),(tmp2>2047),tmp2,0);
844 os.str("");
845 os << name1 << (i*3+1);
846 TBTDCRaw * tbtdcR = new TBTDCRaw(os.str(),(tmp1>2047),tmp1,0);
847 // no under threshold ??
848 m_tdcrawCont->push_back(tbtdcR);
849 m_tdcrawCont->push_back(tbtdcL);
850 MSG::hex(logstr) << MSG::DEBUG << bpcname<< " "<< tmp1;
851 MSG::hex(logstr) << " "<< tmp2<<" ";
852
853 tmp1=firstword(m_rodBlock[pos+i*3+2]);
854 tmp2=secondword(m_rodBlock[pos+i*3+2]);
855 os.str("");
856 os << name1 << (i*3+2);
857 TBTDCRaw * tbtdcU = new TBTDCRaw(os.str(),(tmp1>2047),tmp1,0);
858 os.str("");
859 os << name2 << (i*3+2);
860 TBTDCRaw * tbtdcD = new TBTDCRaw(os.str(),(tmp2>2047),tmp2,0);
861 // no under threshold ??
862 m_tdcrawCont->push_back(tbtdcU);
863 m_tdcrawCont->push_back(tbtdcD);
864 MSG::hex(logstr) << MSG::DEBUG << bpcname<< " "<< tmp1;
865 MSG::hex(logstr) << " "<< tmp2<<endmsg;
866
867
868 theTDCs.push_back(tbtdcL);
869 theTDCs.push_back(tbtdcR); // Fill the tdc/adc list
870 theTDCs.push_back(tbtdcU); // for this BPC
871 theTDCs.push_back(tbtdcD); // !! THE ORDER MATTERS !!
872 theADCs.push_back(tbadcH);
873 theADCs.push_back(tbadcV);
874 TBBPCRaw *bpcraw = new TBBPCRaw(bpcname,m_tdcrawCont,theTDCs,m_adcrawCont,theADCs);
875 m_bpcrawCont->push_back(bpcraw);
876 }
877 //if( unrec_code == 5 ) gotobject=true;
878
879 }
880 break;
881
882 case 0x06: // SCINTILLATOR_ID -----------------------------------------
883 {
884 name1="word1frag0x06chan";
885 name2="word2frag0x06chan";
886 if(m_subfrag_size!=11) {
887 logstr<<MSG::ERROR<< "Beam counter subfrag (0x06) has not expected size" <<endmsg;
888 sc=StatusCode::FAILURE;
889 break;
890 }
891
892 logstr << MSG::DEBUG << " Building TBScintillatorRawCont with key " << m_keys[6] << endmsg;
893
899 TBScintillatorRaw * Halo = new TBScintillatorRaw("Halo");
900 TBScintillatorRaw * muon[8];
901
902 logstr << MSG::DEBUG << " building muon counters:";
903 for(int i=0;i<8;i++) {
904 std::string scintname="muon";
905 os.str("");
906 os << scintname << (i+1);
907 scintname=os.str();
908 logstr << MSG::DEBUG << " " << scintname;
909 muon[i] = new TBScintillatorRaw(scintname);
910 }
911 logstr << endmsg;
912
913 int tmp1,tmp2;
914 int pos=m_subfrag_firstdata;
915 unsigned short word1=firstword(m_rodBlock[pos]);
916 unsigned short word2=secondword(m_rodBlock[pos]);
917
918 tmp1 = firstnbit(10,word1);
919 tmp2 = firstnbit(10,word2);
920
921 TBADCRaw* Badc = new TBADCRaw(name1+'0',false,abs(tmp1));
922 TBADCRaw* Haloadc = new TBADCRaw(name2+'0',false,abs(tmp2));
923 if(testbit(10,word1)) Badc->setOverflow(); // if bit10=0 -> Overflow
924 if(testbit(10,word2)) Haloadc->setOverflow(); // if bit10=0 -> Overflow
925 m_adcrawCont->push_back(Badc);
926 m_adcrawCont->push_back(Haloadc);
927
928 tmp1 = firstnbit(10,firstword(m_rodBlock[pos+1]));
929 tmp2 = firstnbit(10,secondword(m_rodBlock[pos+1]));
930 TBADCRaw* S3adc = new TBADCRaw(name1+'1',false,abs(tmp1));
931 TBADCRaw* S2adc = new TBADCRaw(name2+'1',false,abs(tmp2));
932 if(testbit(10,word1)) S3adc->setOverflow(); // if bit10=0 -> Overflow
933 if(testbit(10,word2)) S2adc->setOverflow(); // if bit10=0 -> Overflow
934 m_adcrawCont->push_back(S3adc);
935 m_adcrawCont->push_back(S2adc);
936
937 tmp1 = firstnbit(10,firstword(m_rodBlock[pos+2]));
938 TBADCRaw* S1adc = new TBADCRaw(name1+'2',false,abs(tmp1));
939 if(testbit(10,word1)) S1adc->setOverflow(); // if bit10=0 -> Overflow
940 m_adcrawCont->push_back(S1adc);
941
942 for(int i=0;i<4;i++) {
943 tmp1 = firstnbit(10,secondword(m_rodBlock[pos+2+i]));
944 tmp2 = firstnbit(10,firstword(m_rodBlock[pos+3+i]));
945 os.str("");
946 os << name1 << (0+2+i);
947 TBADCRaw* adc1 = new TBADCRaw(os.str(),false,abs(tmp1));
948 os.str("");
949 os << name2 << (0+3+i);
950 TBADCRaw* adc2 = new TBADCRaw(os.str(),false,abs(tmp2));
951 // muon[i]
952 // muon[i+1]->setSignal(abs(tmp2));
953 if(testbit(10,word1)) adc1->setOverflow(); // if bit10=0 -> Overflow
954 if(testbit(10,word2)) adc2->setOverflow(); // if bit10=0 -> Overflow
955 m_adcrawCont->push_back(adc1);
956 m_adcrawCont->push_back(adc2);
957 muon[2*i]->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,adc1);
958 muon[2*i+1]->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,adc2);
959 }
960
961
962 tmp1 = firstnbit(11,secondword(m_rodBlock[pos+6]));
963 TBTDCRaw* S2tdc = new TBTDCRaw(name2+'6',false,abs(tmp1),0);
964 m_tdcrawCont->push_back(S2tdc);
965
966 // Overflows ?? underthreshold ??
967 tmp1 = firstnbit(11,firstword(m_rodBlock[pos+7]));
968 tmp2 = firstnbit(11,secondword(m_rodBlock[pos+7]));
969 TBTDCRaw* S3tdc = new TBTDCRaw(name1+'7',false,abs(tmp1),0);
970 TBTDCRaw* Btdc = new TBTDCRaw(name2+'7',false,abs(tmp2),0);
971 m_tdcrawCont->push_back(S3tdc);
972 m_tdcrawCont->push_back(Btdc);
973
974 tmp1 = firstnbit(11,firstword(m_rodBlock[pos+8]));
975 tmp2 = firstnbit(11,secondword(m_rodBlock[pos+8]));
976 TBTDCRaw* Halotdc = new TBTDCRaw(name1+'8',false,abs(tmp1),0);
977 TBTDCRaw* VetoORtdc = new TBTDCRaw(name2+'8',false,abs(tmp2),0);
978 m_tdcrawCont->push_back(Halotdc);
979 m_tdcrawCont->push_back(VetoORtdc);
980
981
982 // Fill container
983 S1->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,S1adc);
984 S2->setSignals(m_tdcrawCont,S2tdc,m_adcrawCont,S2adc);
985
986
987 // logstr << MSG::INFO << "S1 adc ovf = "<< S1->isADCOverflow() << " // S1adc = "<< S1adc->isOverflow() <<endmsg;
988 // logstr << MSG::INFO << "S2 adc ovf = "<< S2->isADCOverflow() << " // S2adc = "<< S2adc->isOverflow() <<endmsg;
989
990 S3->setSignals(m_tdcrawCont,S3tdc,m_adcrawCont,S3adc);
991 Veto->setSignals(m_tdcrawCont,VetoORtdc,m_adcrawCont,dummyadc);
992 Halo->setSignals(m_tdcrawCont,Halotdc,m_adcrawCont,Haloadc);
993 B->setSignals(m_tdcrawCont,Btdc,m_adcrawCont,Badc);
994
995 m_scintrawCont->push_back(S1);
996 m_scintrawCont->push_back(S2);
997 m_scintrawCont->push_back(S3);
998 m_scintrawCont->push_back(Veto);
999 m_scintrawCont->push_back(Halo);
1000 m_scintrawCont->push_back(B);
1001 for(int i=0;i<8;i++) {
1002 m_scintrawCont->push_back(muon[i]);
1003 }
1004
1005 logstr << MSG::DEBUG << " Should I record TBScintillatorRawCont with key " << m_keys[6] << " ? " << endmsg;
1006 //if(unrec_code == 6 ) gotobject=true;
1007 }
1008 break;
1009
1010 case 0x07: // MWPC_ID -----------------------------------------
1011 {
1012 int pos=m_subfrag_firstdata;
1013 int nword = m_subfrag_size - 2;
1014 logstr << MSG::DEBUG << " Found MWPC subfragment. Nword= "<<nword << endmsg;
1015
1016 std::string mwpcnames[8]= {"X2","Y2","X3","Y3","X4","Y4","X5","Y5"};
1017 bool isX[9]={true,false,true,false,true,false,true,false};
1018 TBMWPCRaw * mwpcraw[8];
1019 for( int i=0;i<8;i++){
1020 mwpcraw[i] = new TBMWPCRaw(mwpcnames[i]);
1021 }
1022
1023 unsigned short status= secondword(m_rodBlock[pos+nword-1]);
1024 //bool error = false ;
1025 if(status==0) status= firstword(m_rodBlock[pos+nword-1]);
1026 else { // first 16 bit word is data
1027 unsigned short word1=firstword(m_rodBlock[pos+nword-1]);
1028 int w; // cluster width
1029 int c; // the starting channel of a cluster (0<start<4096)
1030 int chamber; // 0=X2, 1=Y2, 2=X3, 3=Y3, 4=X4, 5=Y4, 6=X5, 7=Y5
1031 int wire; // wire number
1032
1033 w = (int) (word1>>12); c = (int) ((0xfff & word1) - w/2 + !(w&1));
1034 if( c < 768 ) {chamber = c/128; wire=c-chamber*128;}
1035 else {chamber=6+(c-768)/64; wire=c-768-(chamber-6)*64;}
1036
1037 if(chamber>7){logstr << MSG::DEBUG << "Wrong MWPC chamber number : "<< chamber <<endmsg;}
1038 else{
1039 mwpcraw[chamber]->addCwireno(wire);
1040 mwpcraw[chamber]->addNwires(w);
1041 mwpcraw[chamber]->setXchambers(isX[chamber]);
1042 logstr << MSG::DEBUG << " MWPC chamber="<< chamber<< " wire=" << wire << " (w="<<w<<")" << " c="<<c<< endmsg;
1043 }
1044 }
1045
1046 if(status != 0x1000) {MSG::hex(logstr)<< MSG::DEBUG << "MWPC status word error =" << status <<endmsg; /*error=true;*/}
1047
1048 for( int i=0;i<m_subfrag_size-2;i++){ // "-2" because last full word contains status word (see above)
1049 unsigned short word1=firstword(m_rodBlock[pos+i]);
1050 unsigned short word2=secondword(m_rodBlock[pos+i]);
1051 int w; // cluster width
1052 int c; // the starting channel of a cluster (0<start<4096)
1053 int chamber; // 0=X2, 1=Y2, 2=X3, 3=Y3, 4=X4, 5=Y4, 6=X5, 7=Y5
1054 int wire; // wire number
1055
1056 w = (int) (word1>>12); c = (int) ((0xfff & word1) - w/2 + !(w&1));
1057 if( c < 768 ) {chamber = c/128; wire=c-chamber*128;}
1058 else {chamber=6+(c-768)/64; wire=c-768-(chamber-6)*64;}
1059
1060 if(chamber>7){logstr << MSG::DEBUG << "Wrong MWPC chamber number : "<< chamber <<endmsg;}
1061 else{
1062 mwpcraw[chamber]->addCwireno(wire);
1063 mwpcraw[chamber]->addNwires(w);
1064 mwpcraw[chamber]->setXchambers(isX[chamber]);
1065 logstr << MSG::DEBUG << " MWPC chamber="<< chamber<< " wire=" << wire << " (w="<<w<<")" << " c="<<c<< endmsg;
1066 }
1067
1068 w = (int) (word2>>12); c = (int) ((0xfff & word2) - w/2 + !(w&1));
1069 if( c < 768 ) {chamber = c/128; wire=c-chamber*128;}
1070 else {chamber=6+(c-768)/64; wire=c-768-(chamber-6)*64;}
1071
1072
1073 if(chamber>7){logstr << MSG::INFO << "Wrong MWPC chamber number : "<< chamber <<endmsg;}
1074 else{
1075 mwpcraw[chamber]->addCwireno(wire);
1076 mwpcraw[chamber]->addNwires(w);
1077 mwpcraw[chamber]->setXchambers(isX[chamber]);
1078 logstr << MSG::DEBUG << " MWPC chamber="<< chamber<< " wire=" << wire << " (w="<<w<<")" << " c="<<c<< endmsg;
1079 }
1080
1081 }
1082
1083 for( int i=0;i<8;i++){
1084 m_mwpcrawCont->push_back(mwpcraw[i]);
1085 }
1086
1087 logstr << MSG::DEBUG << " End of MWPC subfragment " << endmsg;
1088 //if(unrec_code == 7 ) gotobject=true;
1089
1090 }
1091 break;
1092 case 0xf1: // Run header -----------------------------------------
1093 {
1094 int pos=m_subfrag_firstdata;
1095 char *strw;
1096 int nword = m_subfrag_size - 2;
1097 if(nword%16){
1098 logstr << MSG::ERROR << "bad number of lines. nwords=" << nword <<endmsg;
1099 break;
1100 }
1101 int nline= nword / 16;
1102 strw = reinterpret_cast<char*>(&m_rodBlock[pos]);
1103 for(int i=0;i<nline;i++){
1104 // strw = (char*) &m_rodBlock[pos+i*64];
1105 std::string sline="";
1106 std::string skey="";
1107 for(int j=0;j<63;j++) {
1108 if(strw[i*64+j]==0) break;
1109 sline+=strw[i*64+j];
1110 }
1111 //logstr << MSG::INFO << sline << endmsg;
1112 std::istringstream iss (sline);
1113 iss >> skey;
1114 if(skey=="RunNumber") {
1115 MSG::dec(logstr) << MSG::DEBUG << sline << endmsg;
1116 iss >> m_run_num;
1117 }
1118 if(skey=="BeamMomentum") {
1119 MSG::dec(logstr) << MSG::DEBUG << sline << endmsg;
1120 iss >> m_beam_moment;
1121 }
1122 if(skey=="BeamParticle") {
1123 MSG::dec(logstr) << MSG::DEBUG << sline << endmsg;
1124 iss >> m_beam_part;
1125 }
1126 if(skey=="CryoX") {
1127 MSG::dec(logstr) << MSG::DEBUG << sline << endmsg;
1128 iss >> m_cryoX;
1129 }
1130 if(skey=="CryoAngle") {
1131 MSG::dec(logstr) << MSG::DEBUG << sline << endmsg;
1132 iss >> m_cryoAngle;
1133 }
1134 if(skey=="TableY") {
1135 MSG::dec(logstr) << MSG::DEBUG << sline << endmsg;
1136 iss >> m_tableY;
1137 }
1138 if(skey=="miniROD") {
1139 logstr << MSG::DEBUG << sline << endmsg;
1140 m_boards.clear();
1141 int board;
1142 // iss>>board;
1143 while(iss.good()) {iss>>board;m_boards.push_back(board);}
1144 logstr << MSG::DEBUG << "Found nboards="<< m_boards.size() << endmsg;
1145 for(unsigned i=0;i<m_boards.size();i++)logstr << MSG::DEBUG << m_boards[i]<<" ";
1146 logstr << MSG::DEBUG<<endmsg;
1147 }
1148 if(skey=="FebSamples") {
1149 MSG::dec(logstr) << MSG::DEBUG << sline << endmsg;
1150 m_samples.clear();
1151 int sample;
1152 // iss>>sample;
1153 while(iss.good()) {iss>>sample;m_samples.push_back(sample);}
1154 MSG::dec(logstr) << MSG::DEBUG << "nsample="<< m_samples.size() << endmsg;
1155 for(unsigned i=0;i<m_samples.size();i++)logstr << MSG::DEBUG << m_samples[i]<<" ";
1156 logstr << MSG::DEBUG<<endmsg;
1157 }
1158 if(skey=="FebGains") {
1159 MSG::dec(logstr) << MSG::DEBUG << sline << endmsg;
1160 m_gains.clear();
1161 int gain;
1162 // iss>>gain;
1163 while(iss.good()) {iss>>gain;m_gains.push_back(gain);}
1164 int gs=m_gains.size() ;
1165 if(gs>1) if(m_gains[gs-1]==m_gains[gs-2])m_gains.resize(gs-1);
1166 MSG::dec(logstr) << MSG::DEBUG << "numb of gains="<< m_gains.size() << endmsg;
1167 for(unsigned i=0;i<m_gains.size();i++)logstr << MSG::DEBUG << m_gains[i]<<" ";
1168 logstr << MSG::DEBUG<<endmsg;
1169 }
1170 if(skey=="FebAuto") {
1171 MSG::dec(logstr) << MSG::DEBUG << sline << endmsg;
1172 m_febgain.clear();
1173 int gain;
1174 // iss>>gain;
1175 while(iss.good()) {iss>>gain;m_febgain.push_back(gain);}
1176 MSG::dec(logstr) << MSG::DEBUG << "n febauto="<< m_febgain.size() << " " << endmsg;
1177 for(unsigned i=0;i<m_febgain.size();i++)logstr << MSG::DEBUG << m_febgain[i]<<" ";
1178 logstr << MSG::DEBUG<<endmsg;
1179 }
1180 if(skey=="FebFirstSample") {
1181 MSG::dec(logstr) << MSG::DEBUG << sline << endmsg;
1182 m_firstsamples.clear();
1183 int firstsample;
1184 // iss>>firstsample;
1185 while(iss.good()) {iss>>firstsample;m_firstsamples.push_back(firstsample);}
1186 MSG::dec(logstr) << MSG::DEBUG << "firstsample="<< m_firstsamples.size() << endmsg;
1187 }
1188 }
1189
1190 // If there was no febgain initialise to 0 :
1191 if(m_febgain.size()==0) m_febgain.resize(8,0);
1192 // now initialize every vector :
1193 for(int i=0;i<128;i++) {for(int j=0;j<4;j++) {m_arrayofsample[i][j].clear();m_arrayofsample[i][j].resize(32,0);}}
1194
1195 // m_summary_path = m_summary_path+"/run";
1196// m_summary_path = m_summary_path+m_run_num;
1197// m_summary_path = m_summary_path+".summary";
1198 std::ofstream outfile(m_summary_path.c_str());
1199
1200 outfile << "Run number " << m_run_num << std::endl;
1201 outfile << std::endl;
1202 outfile << "Beam Type \t " << m_beam_part << std::endl;
1203 outfile << "Beam Momentum \t " << m_beam_moment << std::endl;
1204 outfile << std::endl;
1205 outfile << "Cryostat X pos \t " << m_cryoX << std::endl;
1206 outfile << "Cryostat Angle \t " << m_cryoAngle << std::endl;
1207 outfile << "Table Y pos \t " << m_tableY << std::endl;
1208
1209
1210
1211 }
1212 break;
1213 case 0xff : // Calib_ID ------------------------------------
1214 {
1215 int pos=m_subfrag_firstdata;
1216 int nword = m_subfrag_size - 2;
1217 logstr << MSG::DEBUG << " Found Calib_ID subfragment. Nword= "<<nword << endmsg;
1218 if(nword!=6) { // expect 6 words (to hold 22 bytes)
1219 logstr<<MSG::ERROR<< "Calibration subfrag (0xff) has not expected size" <<endmsg;
1220 sc=StatusCode::FAILURE;
1221 break;
1222 }
1223
1224 m_isCalib = true;
1225
1226 for(int i=0;i<4;i++){ // get channel pattern
1227 int first16 = firstword(m_rodBlock[pos+i]);
1228 int second16 = secondword(m_rodBlock[pos+i]);
1229
1230 m_calib_pattern[4*i] = 255 & first16;
1231 m_calib_pattern[4*i+1] = first16 >> 8;
1232 m_calib_pattern[4*i+2] = 255 & second16;
1233 m_calib_pattern[4*i+3] = second16 >> 8;
1234 }
1235
1236 logstr << MSG::DEBUG << "Found calibration header information " << endmsg;
1237 logstr << MSG::DEBUG << " Calib pattern: " << endmsg;
1238 for(int byte=0; byte<16; byte++) {
1239 logstr << MSG::DEBUG << " byte " << byte << " : " ;
1240 for(int bit=0; bit<8; bit++) {
1241 // bool onoff = 1<<bit & m_calib_pattern[byte];
1242 bool onoff = 128>>bit & m_calib_pattern[byte];
1243 logstr << MSG::DEBUG << onoff << "/" ;
1244 }
1245 logstr << MSG::DEBUG << endmsg;
1246 }
1247
1248 // See http://cern.ch/atlas-fcaltb/Memos/DAQ/DataFormat.general.pdf
1249 // http://cern.ch/atlas-fcaltb/Data-taking/CBT2/Beam_fragment_format.sxw.pdf
1250 // (Petr Gorbunov H6 FCAL documentation.)
1252
1253 unsigned first16 = firstword(m_rodBlock[pos+5]);
1254 m_calib_delay = 255 & first16;
1255 m_calib_error = ((first16 >> 8) != 0);
1256
1257 // logstr << MSG::DEBUG << " Pattern 0/1/2/3 = " << m_calib_pattern[0]
1258 // << "/" << m_calib_pattern[1]
1259 // << "/" << m_calib_pattern[2]
1260 // << "/" << m_calib_pattern[3] << endmsg;
1261 logstr << MSG::DEBUG << " DAC = " << m_calib_dac << endmsg;
1262 logstr << MSG::DEBUG << " DELAY = " << m_calib_delay << endmsg;
1263 }
1264 break;
1265 default : // -----------------------------------------
1266 logstr << MSG::DEBUG << "Found undefined subfragment id= "<< m_subfrag_id << endmsg;
1267 break;
1268 }
1269 }
1270
1271 sc = H6RecordObjects(unrec_code);
1272 return sc;
1273
1274
1275}
1276
1277/*---------------------------------------------------------------------------*/
1278
1279StatusCode TBByteStreamCnvTool::H8BuildObjects(int unrec_code)
1280
1281/*---------------------------------------------------------------------------*/
1282{
1289
1290
1291 MsgStream logstr(msgSvc(), name());
1292 logstr << MSG::DEBUG << "H8BuildObject invoked for code " << unrec_code<< endmsg;
1293
1294 StatusCode sc=StatusCode::FAILURE;
1295 bool gotobject=false;
1296 bool recordfailure=false;
1297
1298 bool goodRodBlock=true; // This is a hack to avoid runtime exceptions
1299
1300 std::string name;
1301
1302
1303 // Get ROD block.
1304 sc=GetRODBlock(m_subdet_id,eformat::TDAQ_BEAM_CRATE); //Possible improvement: Check if vector is already valid.
1305 //sc=GetRODBlock(EventFormat::TDAQ_BEAM_CRATE);
1306
1307 if (sc!=StatusCode::SUCCESS) {
1308 // return sc;
1309 logstr << MSG::ERROR << "ReadRodBlock: RodBlock error! Will try to fill SG with empty objects." << endmsg;
1310 goodRodBlock=false;
1311 }
1312 if (m_rodBlock.size()<2) {
1313 logstr << MSG::ERROR << "ReadRodBlock: RodBlock too small! Will try to fill SG with empty objects." << endmsg;
1314 // return StatusCode::FAILURE;
1315 goodRodBlock=false;
1316 }
1317
1318 m_tdcrawCont = new TBTDCRawCont();
1319 m_adcrawCont = new TBADCRawCont();
1320
1321 // Define some dummy ADC & TDC :
1322 TBADCRaw* dummyadc = new TBADCRaw("dummy",true,0);
1323 TBTDCRaw* dummytdc = new TBTDCRaw("dummy",true,0,true);
1324 m_tdcrawCont->push_back(dummytdc);
1325 m_adcrawCont->push_back(dummyadc);
1326
1327
1328 // Scintillator init :
1329 TBScintillatorRaw * S0 = new TBScintillatorRaw("S0");
1331 TBScintillatorRaw * S2up = new TBScintillatorRaw("S2-Up");
1332 TBScintillatorRaw * S2down = new TBScintillatorRaw("S2-Down");
1333 TBScintillatorRaw * S3left = new TBScintillatorRaw("S3-Left");
1334 TBScintillatorRaw * S3right = new TBScintillatorRaw("S3-Right");
1335 TBScintillatorRaw * C1 = new TBScintillatorRaw("C1");
1336 TBScintillatorRaw * C2 = new TBScintillatorRaw("C2");
1337 TBScintillatorRaw * muTag = new TBScintillatorRaw("muTag");
1338 TBScintillatorRaw * muHalo = new TBScintillatorRaw("muHalo");
1339 TBScintillatorRaw * muVeto = new TBScintillatorRaw("muVeto");
1340 TBScintillatorRaw * sTRT = new TBScintillatorRaw("TRTSci");
1341
1342 // S0 has only TDC
1343 TBTDCRaw* S0tdc =dummytdc;
1344 // S1,S2,S3 have 1 TDC +1 ADC
1345 TBADCRaw * S1adc=dummyadc;
1346 TBTDCRaw * S1tdc=dummytdc;
1347
1348 TBADCRaw * S2upadc=dummyadc;
1349 TBTDCRaw * S2uptdc=dummytdc;
1350 TBADCRaw * S2downadc=dummyadc;
1351 TBTDCRaw * S2downtdc=dummytdc;
1352
1353 TBADCRaw * S3leftadc=dummyadc;
1354 TBTDCRaw * S3lefttdc=dummytdc;
1355 TBADCRaw * S3rightadc=dummyadc;
1356 TBTDCRaw * S3righttdc=dummytdc;
1357 //Clock phase
1358 TBTDCRaw * ClockPhasetdc=dummytdc;
1359
1360 //The following Scintillators have only ADC
1361 TBADCRaw * muTagadc=dummyadc;
1362 TBADCRaw * C1adc=dummyadc;
1363 TBADCRaw * C2adc=dummyadc;
1364 TBADCRaw * muHaloadc=dummyadc;
1365 TBADCRaw * muVetoadc=dummyadc;
1366 TBADCRaw * sTRTadc=dummyadc;
1367
1368 // Define BPCs
1369 // Some data words for tdc channels may be absent and if not they arrive in a
1370 // different order than the one we need to store in TBBPCRaw. So we need all this stuff to get
1371 // everything done :
1372 int BPCNum=5;
1373 TBBPCRaw* bpcraw[5];
1374 TBTDCRaw * BPCtdc[5][4];
1375 short tdc_order[4] = {2,3,0,1}; // bytestream : udlr - TBBPCRaw lrud
1376 for(int i=0;i<BPCNum;i++){
1377 bpcraw[i] = new TBBPCRaw("BPC");
1378 for(int j=0;j<4;j++) BPCtdc[i][j]=0;
1379 }
1380 bpcraw[0]->setDetectorName("BPC-2");
1381 bpcraw[1]->setDetectorName("BPC-1");
1382 bpcraw[2]->setDetectorName("BPC0");
1383 bpcraw[3]->setDetectorName("BPC1");
1384 bpcraw[4]->setDetectorName("BPC2");
1385
1386 // for string conversion
1387 std::ostringstream os;
1388
1389 // Now loop through fragment
1390
1391 // with this initialisation, first call of NextSubFrag will initialise correctly the index :
1392 m_subfrag_id=0;
1393 m_subfrag_size=2;
1395 // while(NextSubFrag()){
1396 while(NextSubFrag() and goodRodBlock){ // Hack for bad ROD block
1397 switch(m_subfrag_id){
1398 case 0x10: // ADC1 block --------------------------------------
1399 {
1400 name="frag0x10chan";
1401 logstr << MSG::DEBUG << "Got SubFragment " << MSG::hex << m_subfrag_id << " name=" << name
1402 << " Data words = " << MSG::dec << m_subfrag_size-2<<endmsg;
1403
1404 int pos=m_subfrag_firstdata;
1405
1406 // Overflows ??
1407
1408 S1adc = new TBADCRaw(name+"0",false,m_rodBlock[pos] & 0xfff);
1409 // do not set signal here cause we also need TDC (in 0x11)
1410 logstr << MSG::DEBUG << "S1adc: 0x" << MSG::hex << (int)(m_rodBlock[pos] & 0xfff) << " [0x" << m_rodBlock[pos] << "]"
1411 << MSG::dec << endmsg;
1412 m_adcrawCont->push_back(S1adc);
1413
1414 pos++; // 2
1415 S2upadc = new TBADCRaw(name+"1",false,m_rodBlock[pos] & 0xfff);
1416 logstr << MSG::DEBUG << "S2 :" << MSG::hex << (m_rodBlock[pos] & 0xfff) << " [0x" << m_rodBlock[pos] << "]"
1417 << MSG::dec << endmsg;
1418 m_adcrawCont->push_back(S2upadc);
1419
1420
1421 pos++; // 2
1422 S3rightadc = new TBADCRaw(name+"2",false,m_rodBlock[pos] & 0xfff);
1423 logstr << MSG::DEBUG << "S3 :" << MSG::hex << (m_rodBlock[pos] & 0xfff) << " [0x" << m_rodBlock[pos] << "]"
1424 << MSG::dec << endmsg;
1425 m_adcrawCont->push_back(S3rightadc);
1426
1427
1428 pos++; // 2
1429 muTagadc = new TBADCRaw(name+"3",false,m_rodBlock[pos] & 0xfff);
1430 logstr << MSG::DEBUG << "muTag :" << MSG::hex << (m_rodBlock[pos] & 0xfff) << " [0x" << m_rodBlock[pos] << "]"
1431 << MSG::dec << endmsg;
1432 m_adcrawCont->push_back(muTagadc);
1433 //muTag->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,muTagadc);
1434
1435 pos++; // 2
1436 C1adc = new TBADCRaw(name+"4",false,m_rodBlock[pos] & 0xfff);
1437 logstr << MSG::DEBUG << "C1 :" << MSG::hex << (m_rodBlock[pos] & 0xfff) << " [0x" << m_rodBlock[pos] << "]"
1438 << MSG::dec << endmsg;
1439 m_adcrawCont->push_back(C1adc);
1440 //C1->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,C1adc);
1441
1442 pos++; // 2
1443 C2adc = new TBADCRaw(name+"5",false,m_rodBlock[pos] & 0xfff);
1444 logstr << MSG::DEBUG << "C2 :" << MSG::hex << (m_rodBlock[pos] & 0xfff) << " [0x" << m_rodBlock[pos] << "]"
1445 << MSG::dec << endmsg;
1446 m_adcrawCont->push_back(C2adc);
1447 //C2->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,C2adc);
1448
1449
1450 pos++; // 2
1451 muHaloadc = new TBADCRaw(name+"6",false,m_rodBlock[pos] & 0xfff);
1452 logstr << MSG::DEBUG << "muHalo :" << MSG::hex << (m_rodBlock[pos] & 0xfff) << " [0x" << m_rodBlock[pos] << "]"
1453 << MSG::dec << endmsg;
1454 m_adcrawCont->push_back(muHaloadc);
1455 //muHalo->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,muHaloadc);
1456
1457 pos++; // 2
1458 muVetoadc = new TBADCRaw(name+"7",false,m_rodBlock[pos] & 0xfff);
1459 logstr << MSG::DEBUG << "muVeto :" << MSG::hex << (m_rodBlock[pos] & 0xfff) << " [0x" << m_rodBlock[pos] << "]"
1460 << MSG::dec << endmsg;
1461 m_adcrawCont->push_back(muVetoadc);
1462 //muVeto->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,muVetoadc);
1463
1464 if(m_dump){
1465 logstr << MSG::INFO << " DUMP : ";
1466 logstr << name << " "<< m_subfrag_size-2 <<" words - " << S1adc->getADC() << " " << S2upadc->getADC();
1467 logstr << " " << S3rightadc->getADC()<< " " << muTagadc->getADC() << " " << C1adc->getADC();
1468 logstr << " " << C2adc->getADC() << " " << muHaloadc->getADC() << " "<< muVetoadc->getADC() <<endmsg ;
1469
1470 }
1471
1472 }
1473 break;
1474 case 0x11: // ADC2 segment ----------------------------------
1475 {
1476 name="frag0x11chan";
1477 logstr << MSG::DEBUG << "Got SubFragment " << MSG::hex << m_subfrag_id << " name=" << name
1478 << " Data words = " << MSG::dec << m_subfrag_size-2<<endmsg;
1479
1480 int pos=m_subfrag_firstdata;
1481
1482 // channel 0 not used
1483 // Modification: 2005/01/27 W.L. channel 0 used by TRT Scintillator
1484 sTRTadc = new TBADCRaw(name+"0",false,m_rodBlock[pos] & 0xfff);
1485 logstr << MSG::DEBUG << "sTRT:" << MSG::hex << (m_rodBlock[pos] & 0xfff) << " [0x" << m_rodBlock[pos] << "]"
1486 << MSG::dec << endmsg;
1487 m_adcrawCont->push_back(sTRTadc);
1488 pos++; //1
1489 S2downadc = new TBADCRaw(name+"1",false,m_rodBlock[pos] & 0xfff);
1490 logstr << MSG::DEBUG << "S2 :" << MSG::hex << (m_rodBlock[pos] & 0xfff) << " [0x" << m_rodBlock[pos] << "]"
1491 << MSG::dec << endmsg;
1492 m_adcrawCont->push_back(S2downadc);
1493
1494 pos++; // 2
1495 S3leftadc = new TBADCRaw(name+"2",false,m_rodBlock[pos] & 0xfff);
1496 logstr << MSG::DEBUG << "S3 :" << MSG::hex << (m_rodBlock[pos] & 0xfff) << " [0x" << m_rodBlock[pos] << "]"
1497 << MSG::dec << endmsg;
1498 m_adcrawCont->push_back(S3leftadc);
1499
1500 if(m_dump){
1501 logstr << MSG::INFO << " DUMP : ";
1502 logstr << name << " "<< m_subfrag_size-2 <<" words - " << S2downadc->getADC() << " " << S3leftadc->getADC()<<endmsg;
1503 }
1504
1505 }
1506 break;
1507 case 0x12: // ps TDC --------------------------------------
1508 {
1509 name="frag0x12chan";
1510 logstr << MSG::DEBUG << "Got SubFragment " << MSG::hex << m_subfrag_id << " name=" << name
1511 << " Data words = " << MSG::dec << m_subfrag_size-2<<endmsg;
1512 int pos=m_subfrag_firstdata;
1513 if(m_dump) logstr << MSG::INFO << " DUMP : "<< name<< " "<< m_subfrag_size-2 <<" words - " ;
1514
1515 for( int i=0;i<m_subfrag_size-2;i++){
1516 pos=m_subfrag_firstdata+i;
1517 // get channel number
1518 const int chan= (m_rodBlock[pos] >> 16) & 0x1F;
1519 const unsigned int tdc = m_rodBlock[pos] & 0xfff; // 12 first bits (0-11)
1520 const int corrup = (m_rodBlock[pos]>>21)&0x3f; // test bits 21-26
1521 const bool endofdata=(((m_rodBlock[pos] >> 24)&0x7)==0x4);
1522 // from doc it appears that endofdata <=> corrup==32
1523 const bool overflow=(m_rodBlock[pos]>>12)&1;
1524 const bool underthresh=(m_rodBlock[pos]>>13)&1;
1525 logstr << MSG::DEBUG << MSG::dec << "Pos=" << pos <<" Chan "<< chan << "=" << tdc << ", OV=" << overflow
1526 << ", UN=" <<underthresh << " EOD="<< endofdata << ", corrupt=" << corrup
1527 << " [0x" << MSG::hex << m_rodBlock[pos] << "]" << MSG::dec <<endmsg;
1528 if(m_dump)
1529 MSG::dec(logstr) << " "<< (m_rodBlock[pos] & 0xfff);
1530
1531
1532 if (!endofdata && !corrup) {
1533 os.str("");
1534 os << name << chan;
1535 switch(chan){
1536 case 0:
1537 ClockPhasetdc = new TBTDCRaw(os.str(),overflow,tdc,underthresh);
1538 m_tdcrawCont->push_back(ClockPhasetdc);
1539 break;
1540 case 1:
1541 S1tdc = new TBTDCRaw(os.str(),overflow,tdc,underthresh);
1542 m_tdcrawCont->push_back(S1tdc);
1543 break;
1544 case 2:
1545 S2downtdc = new TBTDCRaw(os.str(),overflow,tdc,underthresh);
1546 m_tdcrawCont->push_back(S2downtdc);
1547 break;
1548 case 3:
1549 S3lefttdc = new TBTDCRaw(os.str(),overflow,tdc,underthresh);
1550 m_tdcrawCont->push_back(S3lefttdc);
1551 break;
1552 case 4:
1553 S2uptdc = new TBTDCRaw(os.str(),overflow,tdc,underthresh);
1554 m_tdcrawCont->push_back(S2uptdc);
1555 break;
1556 case 5:
1557 S3righttdc = new TBTDCRaw(os.str(),overflow,tdc,underthresh);
1558 m_tdcrawCont->push_back(S3righttdc);
1559 break;
1560 case 6:
1561 S0tdc = new TBTDCRaw(os.str(),overflow,tdc,underthresh);
1562 m_tdcrawCont->push_back(S0tdc);
1563 break;
1564 default:
1565 break;
1566 } // end switch
1567 }//end if not corrupted and not end of data
1568 else
1569
1570 if (endofdata) {
1571 if (i==m_subfrag_size-3)
1572 logstr << MSG::DEBUG << " End of data word found at pos " << pos <<endmsg;
1573 else
1574 logstr << MSG::ERROR << " Unexpected end-of-data word found at pos " << pos <<endmsg;
1575 }
1576 else // corrupt
1577 logstr<< MSG::ERROR << "Corrupted data in SubFragment 0x12 pos=" << pos << "channel=" <<chan << " [0x" <<
1578 MSG::hex << m_rodBlock[pos] << "]" << MSG::dec<<endmsg;
1579 } //end loop over subfrags
1580 if(m_dump) logstr << endmsg;
1581 }
1582 break;
1583 case 0x13: // ns TDC (for BPC) --------------------------------------
1584 {
1585 name="frag0x13chan";
1586 logstr << MSG::DEBUG << "Got SubFragment " << MSG::hex << m_subfrag_id << " name=" << name
1587 << " Data words = " << MSG::dec << m_subfrag_size-2<<endmsg;
1588 if(m_dump) logstr << MSG::INFO << " DUMP : "<< name<< " "<< m_subfrag_size-2 <<" words - " << endmsg;
1589 for( int i=0;i<m_subfrag_size-2;i++){
1590 int pos=m_subfrag_firstdata+i;
1591 // get channel number
1592 const int chan= (m_rodBlock[pos] >> 17) & 0xF; // bits 17-20
1593 const unsigned int tdc = m_rodBlock[pos] & 0xffff; // 16 first bits (0-15)
1594 const bool corrup = (m_rodBlock[pos]>>21)&0x1; // test bit 21
1595 const bool endofdata=!((m_rodBlock[pos] >> 23)&0x1); // test bit 23
1596 logstr << MSG::DEBUG << MSG::dec <<"Pos=" << pos << " Chan "<< chan << "=" << tdc
1597 << " EOD="<< endofdata << ", corrupt=" << corrup
1598 << " [0x" << MSG::hex << m_rodBlock[pos] << "]" << MSG::dec <<endmsg;
1599 if (!endofdata && !corrup) {
1600 os.str("");
1601 os << name << chan;
1602 TBTDCRaw * tbtdc = new TBTDCRaw(os.str(),false,tdc,false);
1603 m_tdcrawCont->push_back(tbtdc);
1604 const short bpc_ind = chan / 4 ;
1605 if(bpc_ind>4) {
1606 logstr<< MSG::DEBUG << "Error in 0x13 : found chan="<<chan<<" corresponding to bpc "<<bpc_ind<<endmsg;
1607 continue;
1608 }
1609 const short signaltype = tdc_order[chan % 4];
1610 if (BPCtdc[bpc_ind][signaltype]==NULL)
1611 BPCtdc[bpc_ind][signaltype] = tbtdc;
1612 }
1613 else
1614 if (endofdata) {
1615 if (i==m_subfrag_size-3)
1616 logstr << MSG::DEBUG << " End of data word found at pos " << pos <<endmsg;
1617 else
1618 logstr << MSG::ERROR << " Unexpected end-of-data word found at pos " << pos <<endmsg;
1619 }
1620 else // corrupt
1621 logstr<< MSG::ERROR << "Corrupted data in SubFragment 0x13 pos=" << pos << "channel=" <<chan << " [0x" <<
1622 MSG::hex << m_rodBlock[pos] << "]" << MSG::dec<<endmsg;
1623 } // end for loop
1624
1625 }
1626 break;
1627 case 0x14: // ns TDC (for BPC) --------------------------------------
1628 {
1629 name="frag0x14chan";
1630 logstr << MSG::DEBUG << "Got SubFragment " << MSG::hex << m_subfrag_id << " name=" << name
1631 << " Data words = " << MSG::dec << m_subfrag_size-2<<endmsg;
1632
1633
1634 if(m_dump) logstr << MSG::INFO << " DUMP : "<< name<< " "<< m_subfrag_size-2 <<" words - " << endmsg;
1635
1636
1637 for( int i=0;i<m_subfrag_size-2;i++){
1638 int pos=m_subfrag_firstdata+i;
1639
1640 // get channel number
1641 const int chan= (m_rodBlock[pos] >> 17) & 0xF; // bits 17-20
1642 const unsigned int tdc = m_rodBlock[pos] & 0xffff; // 16 first bits (0-15)
1643 const bool corrup = (m_rodBlock[pos]>>21)&0x1; // test bit 21
1644 const bool endofdata=!((m_rodBlock[pos] >> 23)&0x1); // test bit 23
1645 //const bool overflow=(m_rodBlock[pos]>>12)&1;
1646 //const bool underthresh=(m_rodBlock[pos]>>13)&1;
1647 logstr << MSG::DEBUG << MSG::dec << "Pos=" << pos << " Chan "<< chan << "=" << tdc
1648 << " EOD="<< endofdata << ", corrupt=" << corrup
1649 << " [0x" << MSG::hex << m_rodBlock[pos] << "]" << MSG::dec <<endmsg;
1650
1651 if (!endofdata && !corrup) {
1652 os.str("");
1653 os << name << chan;
1654 TBTDCRaw * tbtdc = new TBTDCRaw(os.str(),false,tdc,false);
1655 m_tdcrawCont->push_back(tbtdc);
1656 const short bpc_ind = chan / 4 + 3;
1657 if(bpc_ind>4) { logstr<< MSG::DEBUG << "Error in 0x14 : found chan="<<chan<<" corresponding to bpc "<<bpc_ind<<endmsg;continue;}
1658 const short signaltype = tdc_order[chan % 4];
1659 if (BPCtdc[bpc_ind][signaltype]==NULL)
1660 BPCtdc[bpc_ind][signaltype] = tbtdc;
1661 }
1662 else
1663 if (endofdata) {
1664 if (i==m_subfrag_size-3)
1665 logstr << MSG::DEBUG << " End of data word found at pos " << pos <<endmsg;
1666 else
1667 logstr << MSG::ERROR << " Unexpected end-of-data word found at pos " << pos <<endmsg;
1668 }
1669 else // corrupt
1670 logstr<< MSG::ERROR << "Corrupted data in SubFragment 0x14 pos=" << pos << "channel=" <<chan << " [0x" <<
1671 MSG::hex << m_rodBlock[pos] << "]" << MSG::dec<<endmsg;
1672 } // end for loop
1673 }
1674 break;
1675 case 0x15: // trigger word --------------------------------------
1676 {
1677 logstr << MSG::INFO << "Found trigger word fragment" << endmsg;
1678 }
1679 break;
1680 default :
1681 logstr << MSG::DEBUG << "Found undefined subfragment id= "<< m_subfrag_id << endmsg;
1682 break;
1683
1684 }
1685 }
1686
1687
1688
1689 logstr << MSG::DEBUG << "Filling Scint" << endmsg;
1690
1691 // fill scint container
1693 //m_scintrawCont->push_back(S0);
1694 //logstr << MSG::DEBUG << "S1 " << endmsg
1695
1696 // Here some tdc maybe missing, so test for them :
1697 if(S0tdc) S0->setSignals(m_tdcrawCont,S0tdc,m_adcrawCont,dummyadc); //Scintillator 0 has only TDC
1698 else S0->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,dummyadc);
1699 m_scintrawCont->push_back(S0);
1700
1701 if(S1tdc && S1adc) S1->setSignals(m_tdcrawCont,S1tdc,m_adcrawCont,S1adc);
1702 else S1->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,S1adc);
1703 m_scintrawCont->push_back(S1);
1704
1705 if(S2uptdc) S2up->setSignals(m_tdcrawCont,S2uptdc,m_adcrawCont,S2upadc);
1706 else S2up->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,S2upadc);
1707 m_scintrawCont->push_back(S2up);
1708
1709 if(S2downtdc) S2down->setSignals(m_tdcrawCont,S2downtdc,m_adcrawCont,S2downadc);
1710 else S2down->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,S2downadc);
1711 m_scintrawCont->push_back(S2down);
1712
1713 if(S3lefttdc) S3left->setSignals(m_tdcrawCont,S3lefttdc,m_adcrawCont,S3leftadc);
1714 else S3left->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,S3leftadc);
1715 m_scintrawCont->push_back(S3left);
1716
1717 if(S3righttdc) S3right->setSignals(m_tdcrawCont,S3righttdc,m_adcrawCont,S3rightadc);
1718 else S3right->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,S3rightadc);
1719 m_scintrawCont->push_back(S3right);
1720
1721 C1->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,C1adc);
1722 m_scintrawCont->push_back(C1);
1723 C2->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,C2adc);
1724 m_scintrawCont->push_back(C2);
1725 muTag->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,muTagadc);
1726 m_scintrawCont->push_back(muTag);
1727 muHalo->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,muHaloadc);
1728 m_scintrawCont->push_back(muHalo);
1729 muVeto->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,muVetoadc);
1730 m_scintrawCont->push_back(muVeto);
1731 sTRT->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,sTRTadc);
1732 m_scintrawCont->push_back(sTRT);
1733
1734
1735 // fill bpc container
1736 logstr << MSG::DEBUG << "Filling BPC" << endmsg;
1737 m_bpcrawCont = new TBBPCRawCont();
1738
1739 for(int i=0;i<BPCNum;i++){
1740 std::vector<const TBTDCRaw*> listtdc;
1741 std::vector<const TBADCRaw*> listadc;
1742 for(int j=0;j<4;j++){
1743 if(BPCtdc[i][j]==0) listtdc.push_back(dummytdc);
1744 else listtdc.push_back(BPCtdc[i][j]);
1745 }
1746 listadc.push_back(dummyadc); listadc.push_back(dummyadc);
1747 bpcraw[i]->setSignals(m_tdcrawCont,listtdc,m_adcrawCont,listadc);
1748 m_bpcrawCont->push_back(bpcraw[i]);
1749 }
1750
1751
1752
1753 // -----------------------------------------------------------------------------------------------
1754
1755 // Now Get info from TileAux RodBlock subdet ID = 0x70
1756 //sc=GetRODBlock((EventFormat::SubDetector) 0x70); //Possible improvement: Check if vector is already valid.
1757 sc=GetRODBlock(m_subdet_id,eformat::TILECAL_LASER_CRATE);
1758 if (sc!=StatusCode::SUCCESS) {
1759 // return sc;
1760 goodRodBlock = false;
1761 logstr << MSG::ERROR << "Tile laser crate ROD block error! Nothing valid in SG." << endmsg;
1762 }
1763 if (m_rodBlock.size()<2) {
1764 logstr << MSG::ERROR << "Tile laser crate ROD block too small! Nothing valid in SG" << endmsg;
1765 // return StatusCode::FAILURE;
1766 goodRodBlock = false;
1767 }
1768
1769 // with this initialisation, first call of NextSubFrag will initialise correctly the index :
1770 m_subfrag_id=0;
1771 m_subfrag_size=2;
1773 // while(NextSubFrag()){
1774 while(NextSubFrag() and goodRodBlock ){
1775 switch(m_subfrag_id){
1776 case 0x1: // ADC1 block --------------------------------------
1777 {
1778 name="frag0x1chan";
1779 int pos=m_subfrag_firstdata;
1780 TBScintillatorRaw * SC1 = new TBScintillatorRaw("SC1");
1781 TBADCRaw* SC1adc = new TBADCRaw(name+"0",false,m_rodBlock[pos] & 0xfff);
1782 m_adcrawCont->push_back(SC1adc);
1783 SC1->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,SC1adc);
1784 m_scintrawCont->push_back(SC1);
1785
1786 pos++;
1787 TBScintillatorRaw * SC2 = new TBScintillatorRaw("SC2");
1788 TBADCRaw* SC2adc = new TBADCRaw(name+"1",false,m_rodBlock[pos] & 0xfff);
1789 m_adcrawCont->push_back(SC2adc);
1790 SC2->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,SC2adc);
1791 m_scintrawCont->push_back(SC2);
1792 logstr << MSG::DEBUG << "Found Scintillator SC1 and SC2" << endmsg;
1793 break;
1794 }
1795 case 0x2: // ADC2 block --------------------------------------
1796 {
1797
1798 int pos=m_subfrag_firstdata;
1799 for(int i=0;i<8;i++){
1800 pos=pos+i;
1801 std::stringstream RawName;
1802 RawName << "frag0x1chan"<<i;
1803 TBADCRaw* MuWalladc = new TBADCRaw(RawName.str(),false,m_rodBlock[pos] & 0xfff);
1804 m_adcrawCont->push_back(MuWalladc);
1805
1806 std::stringstream MuWallName;
1807 MuWallName << "MuWall"<<i;
1808 TBScintillatorRaw* MuWallScint = new TBScintillatorRaw(MuWallName.str());
1809 MuWallScint->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,MuWalladc);
1810 m_scintrawCont->push_back(MuWallScint);
1811 }
1812 logstr << MSG::DEBUG << "Found first muWall block" << endmsg;
1813 break;
1814 }
1815 case 0x3: // ADC3 block --------------------------------------
1816 {
1817
1818 int pos=m_subfrag_firstdata;
1819
1820 for(int i=0;i<4;i++){
1821 pos=pos+i;
1822 std::stringstream RawName;
1823 RawName << "frag0x1chan"<<(i+8);
1824 TBADCRaw* MuWalladc = new TBADCRaw(name,false,m_rodBlock[pos] & 0xfff);
1825 m_adcrawCont->push_back(MuWalladc);
1826
1827 std::stringstream MuWallName;
1828 MuWallName << "MuWall"<<i+8;
1829 TBScintillatorRaw* MuWallScint = new TBScintillatorRaw(MuWallName.str());
1830 MuWallScint->setSignals(m_tdcrawCont,dummytdc,m_adcrawCont,MuWalladc);
1831 m_scintrawCont->push_back(MuWallScint);
1832 }
1833 logstr << MSG::DEBUG << "Found second muWall block" << endmsg;
1834 break;
1835 }
1836 default :
1837 if (m_subfrag_id!=3 && m_subfrag_id!=5 && m_subfrag_id!=7)
1838 logstr << MSG::DEBUG << "Found undefined subfragment id= "<< m_subfrag_id << endmsg;
1839 break;
1840
1841 }
1842 }
1843
1844
1845
1846
1847 // -----------------------------------------------------------------------------------------------
1848
1849 // Now record object if they have not been invoked from converter
1850
1851// if(unrec_code!=1){ // If object was not requested by the converter, store it in SG
1852// sc = m_storeGate->record(m_trigpat,m_keys[1]);
1853// if ( sc.isFailure( ) ) {recordfailure=true;
1854// logstr << MSG::FATAL << "Cannot record TBTrigPat " << endmsg;
1855// }
1856// }else {sc=StatusCode::SUCCESS; gotobject=true;} // else return success to converter
1857
1858
1859 if(unrec_code!=5){ // If object was not requested by the converter, store it in SG
1860 sc = evtStore()->record(m_bpcrawCont,m_keys[5]);
1861 if ( sc.isFailure( ) ) {recordfailure=true;
1862 logstr << MSG::FATAL << "Cannot record BPCRawCont" << endmsg;
1863 }
1864 }else {sc=StatusCode::SUCCESS; gotobject=true;} // else return success to converter
1865
1866
1867 if(unrec_code!=6){ // If object was not requested by the converter, store it in SG
1868 sc = evtStore()->record(m_scintrawCont,m_keys[6]);
1869 if ( sc.isFailure( ) ) {recordfailure=true;
1870 logstr << MSG::FATAL << "Cannot record ScintRawCont " << endmsg;
1871 }
1872 } else {sc=StatusCode::SUCCESS; gotobject=true;} // else return success to converter
1873
1874
1875 if(unrec_code!=2){ // If object was not requested by the converter, store it in SG
1876 sc = evtStore()->record(m_tdcrawCont,m_keys[2]);
1877 if ( sc.isFailure( ) ) {recordfailure=true;
1878 logstr << MSG::FATAL << "Cannot record TDCCont " << endmsg;
1879 }
1880 }else {sc=StatusCode::SUCCESS; gotobject=true;} // else return success to converter
1881
1882 if(unrec_code!=3){ // If object was not requested by the converter, store it in SG
1883 sc = evtStore()->record(m_adcrawCont,m_keys[3]);
1884 if ( sc.isFailure( ) ) {recordfailure=true;
1885 logstr << MSG::FATAL << "Cannot record ADCCont " << endmsg;
1886 }
1887 }else {sc=StatusCode::SUCCESS; gotobject=true;} // else return success to converter
1888
1889
1891 m_trigpat->setTriggerWord(m_h8_triggword);
1892 if(unrec_code!=1) { // If object was not requested by the converter, store it in SG
1893 logstr << MSG::DEBUG << "Recording TBTriggerPatternUnit with key " << m_keys[1] << endmsg;
1894 // if(! evtStore()->contains<TBTriggerPatternUnit>(m_keys[1])) {
1895 sc = evtStore()->record(m_trigpat,m_keys[1]);
1896 if ( sc.isFailure( ) ) {
1897 logstr << MSG::ERROR << "Cannot record TBTrigPat " << endmsg;
1898 }
1899 } else {
1900 sc=StatusCode::SUCCESS;
1901 gotobject=true;
1902 } // else return success to converter
1903
1904
1905 logstr << MSG::DEBUG << " End of H8 Build " << endmsg;
1906 if(!gotobject) {logstr<< MSG::ERROR<< " Could not find object of type "<<unrec_code << endmsg; sc=StatusCode::FAILURE;}
1907 if(recordfailure) {logstr<< MSG::ERROR<< " One object could not be recorded "<< endmsg; sc=StatusCode::FAILURE;}
1908
1909
1910 return sc;
1911}
1912
1914{
1915
1916 StatusCode sc;
1917 MsgStream logstr(msgSvc(), name());
1918 logstr << MSG::DEBUG << "About to try recording. unrec_code = " << unrec_code << endmsg;
1919
1920 if( !m_tailcatchraw) {
1921 logstr << MSG::DEBUG << " WARNING! Did not find TailCatcher. Returning an empty one : this may crash every attempt to use it" << endmsg;
1923 }
1924
1925 if(unrec_code!=1) { // If object was not requested by the converter, store it in SG
1926 logstr << MSG::DEBUG << "Recording TBTriggerPatternUnit with key " << m_keys[1] << endmsg;
1927 sc = evtStore()->record(m_trigpat,m_keys[1]);
1928 if ( sc.isFailure( ) ) {
1929 logstr << MSG::ERROR << "Cannot record TBTrigPat " << endmsg;
1930 }
1931 }
1932
1933 if(unrec_code!=4){ // If object was not requested by the converter, store it in SG
1934 logstr << MSG::DEBUG << "Recording TBTailCatcherRaw with key " << m_keys[4] << endmsg;
1935 sc = evtStore()->record(m_tailcatchraw,m_keys[4]);
1936 if ( sc.isFailure( ) ) {
1937 logstr << MSG::ERROR << "Cannot record TailCatcherRaw " << endmsg;
1938 }
1939 }
1940
1941 if(unrec_code!=5) { // If object was not requested by the converter, store it in SG
1942 logstr << MSG::DEBUG << "Recording TBBPCRawCont with key " << m_keys[5] << endmsg;
1943 // if(! evtStore()->contains<TBBPCRawCont>(m_keys[5])) {
1944 sc = evtStore()->record(m_bpcrawCont,m_keys[5]);
1945 if ( sc.isFailure( ) ) {
1946 logstr << MSG::ERROR << "Cannot record BPCRawCont" << endmsg;
1947 }
1948 // } else {
1949 // logstr << MSG::ERROR << " Object TBBPCRawCont already in SG (memory leak!)" << endmsg;
1950 // }
1951 }
1952
1953 if(unrec_code!=6){ // If object was not requested by the converter, store it in SG
1954 logstr << MSG::DEBUG << "Recording TBScintillatorRawCont with key " << m_keys[6] << endmsg;
1955 // if(! evtStore()->contains<TBScintillatorRawCont>(m_keys[6])) {
1956 sc = evtStore()->record(m_scintrawCont,m_keys[6]);
1957 if ( sc.isFailure( ) ) {
1958 logstr << MSG::ERROR << "Cannot record ScintRawCont " << endmsg;
1959 }
1960 // } else {
1961 // logstr << MSG::ERROR << " Object TBScintillatorRawCont already in SG (memory leak!)" << endmsg;
1962 // }
1963 }
1964
1965 if(unrec_code!=7){ // If object was not requested by the converter, store it in SG
1966 // if(! evtStore()->contains<TBMWPCRawCont>(m_keys[7])) {
1967 logstr << MSG::DEBUG << "record TBMWPCRawCont with key " << m_keys[7] <<endmsg;
1968 sc = evtStore()->record(m_mwpcrawCont,m_keys[7]);
1969 if ( sc.isFailure( ) ) {
1970 logstr << MSG::ERROR << "Cannot record MWPCRawCont " << endmsg;
1971 }
1972 // } else {
1973 // logstr << MSG::ERROR << " Object TBMWPCRawCont already in SG (memory leak!)" << endmsg;
1974 // }
1975 }
1976
1977 // TDCRaw and ADCRaw are special since they are build from all
1978 // subfragments in H6. Record them slightly differently.
1979
1980 if(unrec_code!=2){ // If object was not requested by the converter, store it in SG
1981 logstr << MSG::DEBUG << "record TDC cont with key " << m_keys[2] << endmsg;
1982 // if(! evtStore()->contains<TBTDCRawCont>(m_keys[2])) {
1983 sc = evtStore()->record(m_tdcrawCont,m_keys[2]);
1984 if ( sc.isFailure( ) ) {
1985 logstr << MSG::ERROR << "Cannot record TDCCont " << endmsg;
1986 }
1987 }
1988 // } else {
1989 // logstr << MSG::ERROR << " Object TBTDCRawCont already in SG (memory leak!)" << endmsg;
1990 // }
1991
1992
1993 if(unrec_code!=3){ // If object was not requested by the converter, store it in SG
1994 logstr << MSG::DEBUG << "record ADC cont with key " << m_keys[3] << endmsg;
1995 // if(! evtStore()->contains<TBADCRawCont>(m_keys[3])) {
1996 sc = evtStore()->record(m_adcrawCont,m_keys[3]);
1997 if ( sc.isFailure( ) ) {
1998 logstr << MSG::FATAL << "Cannot record ADCCont " << endmsg;
1999 }
2000 }
2001 // } else {
2002 // logstr << MSG::ERROR << " Object TBADCRawCont already in SG (memory leak!)" << endmsg;
2003 // }
2004
2005 for(int c=10;c<14;c++){
2006 if(unrec_code!=c){ // If object was not requested by the converter, store it in SG
2007
2008 logstr << MSG::DEBUG << "record TBLArDigitContainer with key " << m_keys[c] << " and size " << m_tblardigitcont[c-10]->size() << endmsg;
2009 sc = evtStore()->record(m_tblardigitcont[c-10],m_keys[c]);
2010 if ( sc.isFailure( ) ) {
2011 logstr << MSG::FATAL << "Cannot record " <<m_keys[c-10]<< endmsg;
2012 }
2013 }
2014 }
2015
2016 for(int c=10;c<14;c++){
2017 if(unrec_code!=c){ // If object was not requested by the converter, store it in SG
2018
2019 logstr << MSG::DEBUG << "record TBLArCalibDigitContainer with key " << m_keys[c] << " and size " << m_tblarcalibdigitcont[c-10]->size() << endmsg;
2020 sc = evtStore()->record(m_tblarcalibdigitcont[c-10],m_keys[c]);
2021 if ( sc.isFailure( ) ) {
2022 logstr << MSG::FATAL << "Cannot record " <<m_keys[c-10]<< endmsg;
2023 }
2024 }
2025 }
2026
2027 if(unrec_code!=30){ // If object was not requested by the converter, store it in SG
2028 sc = evtStore()->record(m_eventinfo,"TBEventInfo");
2029 if ( sc.isFailure( ) ) {
2030 logstr << MSG::FATAL << "Cannot record TBEventInfo "<< endmsg;
2031 }
2032 }
2033 // } else {
2034 // logstr << MSG::ERROR << " Object TBADCRawCont already in SG (memory leak!)" << endmsg;
2035 // }
2036
2037 logstr << MSG::DEBUG << " End of H6 Record " << endmsg;
2038
2039 // Print run summary in text file
2040
2041 return sc;
2042
2043}
const boost::regex re(r_e)
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
static const size_t MAX_ROBFRAGMENTS
#define scale2
#define scale1
static Double_t sc
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
Definition RawEvent.h:39
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition RawEvent.h:37
struct TBPatternUnitContext Veto
struct TBPatternUnitContext S2
struct TBPatternUnitContext S3
struct TBPatternUnitContext S1
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
const ServiceHandle< StoreGateSvc > & detStore() const
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition EventID.h:35
EventID * event_ID()
the unique identification of the event.
Base class for LArDigits taken during calibration runs.
Liquid Argon digit base class.
Definition LArDigit.h:25
"TBEvent/TBADCRawCont.h"
Data object holding adc measurement.
Definition TBADCRaw.h:21
signal_type getADC() const
Definition TBADCRaw.h:35
"TBEvent/TBBPCRawCont.h"
raw data class for BPC measurement
Definition TBBPCRaw.h:33
void setSignals(const TBTDCRawCont *theTDCCont, const std::vector< const TBTDCRaw * > &theTDCs, const TBADCRawCont *theADCCont, const std::vector< const TBADCRaw * > &theADCs)
Definition TBBPCRaw.cxx:35
virtual void setDetectorName(const std::string &tbBeamDetectorName)
virtual void setOverflow()
unsigned short secondword(unsigned int w)
CaloGain::CaloGain m_arrayofgain[128][4]
bool testbit(int n, unsigned short w)
const LArOnlineID * m_onlineHelper
std::vector< uint32_t > m_rodBlock
unsigned short firstword(unsigned int w)
std::vector< int > m_boards
StatusCode H6BuildObjects(int unrec_code)
std::vector< int > m_firstsamples
std::vector< uint32_t > * m_theRodBlock
SG::ReadCondHandleKey< LArCalibLineMapping > m_CLKey
ServiceHandle< IByteStreamEventAccess > m_ByteStreamEventAccess
StatusCode H8BuildObjects(int unrec_code)
TBMWPCRawCont * m_mwpcrawCont
TBByteStreamCnvTool(const std::string &type, const std::string &name, const IInterface *parent)
constructor
eformat::SubDetector m_subdet_id
ServiceHandle< IROBDataProviderSvc > m_rdpSvc
StatusCode BuildRODBlock(std::vector< uint32_t > *theRODBlock)
TBTailCatcherRaw * m_tailcatchraw
TBScintillatorRawCont * m_scintrawCont
std::vector< int > m_gains
CaloGain::CaloGain getCaloGain(int gain)
std::vector< int > m_febgain
std::vector< std::string > m_keys
static const eformat::SubDetector m_DontCheckRodSubDetID
TBLArCalibDigitContainer * m_tblarcalibdigitcont[4]
unsigned short firstnbit(int n, unsigned short w)
virtual StatusCode finalize()
unsigned char m_calib_pattern[16]
std::vector< short > m_arrayofsample[128][4]
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * m_theROB
std::vector< int > m_samples
static const InterfaceID & interfaceID()
StatusCode ReadFragment(int unrec_code)
TBTriggerPatternUnit * m_trigpat
virtual StatusCode initialize()
StatusCode GetRODBlock(eformat::SubDetector subdet_id, eformat::SubDetector subdet_rod_id=m_DontCheckRodSubDetID)
TBLArDigitContainer * m_tblardigitcont[4]
StatusCode H6RecordObjects(int unrec_code)
Liquid Argon Calibration Digit Container
"TBEvent/TBMWPCRawCont.h"
void setXchambers(bool isX)
Definition TBMWPCRaw.h:72
void addNwires(int nwire)
Definition TBMWPCRaw.h:67
void addCwireno(int cwire)
Definition TBMWPCRaw.h:59
"TBEvent/TBScintillatorRawCont.h"
void setSignals(const TBTDCRawCont *tdcCont, TBTDCRaw *tbtdc, const TBADCRawCont *adcCont, TBADCRaw *tbadc)
"TBEvent/TBTDCRawCont.h"
Data object holding tdc measurement.
Definition TBTDCRaw.h:21
Definition TBTDC.h:17
int tdcmin() const
Definition TBTDC.h:31
int tdc() const
Definition TBTDC.h:28
eformat::write::ROBFragment ROBFragment
Definition RawEvent.h:33
const DataType * PointerType
Definition RawEvent.h:25
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27