diff --git a/TestBeam/TBCnv/TBCnv/TBByteStreamCnvTool.h b/TestBeam/TBCnv/TBCnv/TBByteStreamCnvTool.h index d798912bc2d37022ea00eb9f4e22f34596a0aeb5..4ce1056c61a08ff5eb758aa5bb4a697b92ff44ba 100644 --- a/TestBeam/TBCnv/TBCnv/TBByteStreamCnvTool.h +++ b/TestBeam/TBCnv/TBCnv/TBByteStreamCnvTool.h @@ -1,7 +1,7 @@ //Dear emacs, this is -*- c++ -*- /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef TESTBEAM_BYTESTREAMTOOL_H @@ -61,17 +61,17 @@ public: StatusCode WriteFragment(); StatusCode ReadFragment(int unrec_code); - StatusCode ReadFragment(TBTDC*& tdc,std::string key); - StatusCode ReadFragment(TBTDCRawCont*& tdcrawCont,std::string key); - StatusCode ReadFragment(TBADCRawCont*& adcrawCont,std::string key); - StatusCode ReadFragment(TBBPCRawCont*& bpcrawCont,std::string key); - StatusCode ReadFragment(TBMWPCRawCont*& mwpcrawCont,std::string key); - StatusCode ReadFragment(TBTriggerPatternUnit*& trigpat,std::string key); - StatusCode ReadFragment(TBScintillatorRawCont*& scintrawCont,std::string key); - StatusCode ReadFragment(TBTailCatcherRaw*& tailcatchraw,std::string key); - StatusCode ReadFragment(TBEventInfo*& tbeventinfo,std::string key); - StatusCode ReadFragment(TBLArDigitContainer*& tblardigitcont,std::string key); - StatusCode ReadFragment(TBLArCalibDigitContainer*& tblarcalibdigitcont,std::string key); + StatusCode ReadFragment(TBTDC*& tdc,const std::string& key); + StatusCode ReadFragment(TBTDCRawCont*& tdcrawCont,const std::string& key); + StatusCode ReadFragment(TBADCRawCont*& adcrawCont,const std::string& key); + StatusCode ReadFragment(TBBPCRawCont*& bpcrawCont,const std::string& key); + StatusCode ReadFragment(TBMWPCRawCont*& mwpcrawCont,const std::string& key); + StatusCode ReadFragment(TBTriggerPatternUnit*& trigpat,const std::string& key); + StatusCode ReadFragment(TBScintillatorRawCont*& scintrawCont,const std::string& key); + StatusCode ReadFragment(TBTailCatcherRaw*& tailcatchraw,const std::string& key); + StatusCode ReadFragment(TBEventInfo*& tbeventinfo,const std::string& key); + StatusCode ReadFragment(TBLArDigitContainer*& tblardigitcont,const std::string& key); + StatusCode ReadFragment(TBLArCalibDigitContainer*& tblarcalibdigitcont,const std::string& key); StatusCode BuildRODBlock(std::vector<uint32_t>* theRODBlock); StatusCode GetRODBlock(eformat::SubDetector subdet_id, diff --git a/TestBeam/TBCnv/src/ReadTBLArCalibDigits.cxx b/TestBeam/TBCnv/src/ReadTBLArCalibDigits.cxx index 4c95ddc9461fe6b15900b73741bd7b93a3266a3d..6a7e2e72dbf9b3bf531c32a374d76433e7a8dcc5 100644 --- a/TestBeam/TBCnv/src/ReadTBLArCalibDigits.cxx +++ b/TestBeam/TBCnv/src/ReadTBLArCalibDigits.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "TBCnv/ReadTBLArCalibDigits.h" @@ -59,20 +59,17 @@ StatusCode ReadTBLArCalibDigits::execute() { return StatusCode::FAILURE; } - TBLArCalibDigitContainer::const_iterator it=larCalibDigitCont->begin(); - TBLArCalibDigitContainer::const_iterator it_end=larCalibDigitCont->end(); - log << MSG::VERBOSE << "Now loop over container " << endmsg; - - for (;it!=it_end;it++) { + + for (const LArCalibDigit* digit : *larCalibDigitCont) { log << MSG::VERBOSE << " Get hardware ID " << endmsg; - HWIdentifier chid=(*it)->hardwareID(); + HWIdentifier chid=digit->hardwareID(); log << MSG::VERBOSE << " chid = " << chid << endmsg; - const std::vector<short>& vSamples=(*it)->samples(); + const std::vector<short>& vSamples=digit->samples(); int nSamples=vSamples.size(); log << MSG::VERBOSE << " nSamples = " << nSamples << endmsg; @@ -84,7 +81,7 @@ StatusCode ReadTBLArCalibDigits::execute() { for(int i=0; i<nSamples; i++) { m_outfile << " " << vSamples[i]; } - m_outfile << " G=" << (*it)->gain() << std::endl; + m_outfile << " G=" << digit->gain() << std::endl; } cellCounter++; diff --git a/TestBeam/TBCnv/src/ReadTBLArDigits.cxx b/TestBeam/TBCnv/src/ReadTBLArDigits.cxx index 551d6f9935ac79e07dcb0b561009a6bb340fff3e..f595e2e4b9d165d1fb9ab3a4ce22b0b840879428 100644 --- a/TestBeam/TBCnv/src/ReadTBLArDigits.cxx +++ b/TestBeam/TBCnv/src/ReadTBLArDigits.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "TBCnv/ReadTBLArDigits.h" @@ -112,18 +112,16 @@ StatusCode ReadTBLArDigits::execute() log << MSG::DEBUG << "Finished sorting" << endmsg; unsigned cellCounter=0; - TBLArDigitContainer::const_iterator it=larDigitCont->begin(); - TBLArDigitContainer::const_iterator it_end=larDigitCont->end(); if (larDigitCont->size()>0) - m_Nsamples=(*it)->samples().size(); + m_Nsamples=larDigitCont->front()->samples().size(); else m_Nsamples=0; - log << MSG::DEBUG << "Now loop over digits" << endmsg; - for (;it!=it_end;it++) { - HWIdentifier chid=(*it)->hardwareID(); + log << MSG::DEBUG << "Now loop over digits" << endmsg; + for (const LArDigit* digit : *larDigitCont) { + HWIdentifier chid=digit->hardwareID(); log << MSG::DEBUG << "Get offline ID" << endmsg; const Identifier id=m_larCablingSvc->cnvToIdentifier(chid); - const std::vector<short>& vSamples=(*it)->samples(); + const std::vector<short>& vSamples=digit->samples(); m_cellIndex=cellCounter; log << MSG::DEBUG << "Now find eta/phi (EM only right now)" << endmsg; if (m_emId->is_lar_em(id)) { @@ -149,7 +147,7 @@ StatusCode ReadTBLArDigits::execute() m_FT[m_cellIndex] = m_onlineHelper->feedthrough(chid); m_slot[m_cellIndex] = m_onlineHelper->slot(chid); m_channel[m_cellIndex] = m_onlineHelper->channel(chid); - m_gain[m_cellIndex]=(*it)->gain(); + m_gain[m_cellIndex]=digit->gain(); log << MSG::DEBUG << "Loop over samples" << endmsg; int nSamples=vSamples.size(); diff --git a/TestBeam/TBCnv/src/TBByteStreamCnvTool.cxx b/TestBeam/TBCnv/src/TBByteStreamCnvTool.cxx index fa1ab72feded07f8f4a77fdd9245a26993c6b8a5..00caac7be9740d8f0e776371eaec0a2d0e50d4cb 100644 --- a/TestBeam/TBCnv/src/TBByteStreamCnvTool.cxx +++ b/TestBeam/TBCnv/src/TBByteStreamCnvTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "TBCnv/TBByteStreamCnvTool.h" @@ -299,7 +299,7 @@ StatusCode TBByteStreamCnvTool::ReadFragment(int unrec_code){ return sc; } -StatusCode TBByteStreamCnvTool::ReadFragment(TBTDC*& tbtdc,std::string key) +StatusCode TBByteStreamCnvTool::ReadFragment(TBTDC*& tbtdc,const std::string& key) { /** This method is used only for testing **/ MsgStream logstr(msgSvc(), name()); @@ -321,7 +321,7 @@ StatusCode TBByteStreamCnvTool::ReadFragment(TBTDC*& tbtdc,std::string key) // return sc; } -StatusCode TBByteStreamCnvTool::ReadFragment(TBBPCRawCont*& bpcrawCont,std::string key) +StatusCode TBByteStreamCnvTool::ReadFragment(TBBPCRawCont*& bpcrawCont,const std::string& key) {MsgStream logstr(msgSvc(), name()); logstr << MSG::DEBUG <<" in ReadFragment (TBBPCRawCont) key="<<key<<endmsg; StatusCode sc=ReadFragment(5); @@ -330,7 +330,7 @@ StatusCode TBByteStreamCnvTool::ReadFragment(TBBPCRawCont*& bpcrawCont,std::stri return sc; } -StatusCode TBByteStreamCnvTool::ReadFragment(TBMWPCRawCont*& mwpcrawCont,std::string key) +StatusCode TBByteStreamCnvTool::ReadFragment(TBMWPCRawCont*& mwpcrawCont,const std::string& key) {MsgStream logstr(msgSvc(), name()); logstr << MSG::DEBUG <<" in ReadFragment (TBMWPCRawCont) key="<<key<<endmsg; StatusCode sc=ReadFragment(7); @@ -338,14 +338,14 @@ StatusCode TBByteStreamCnvTool::ReadFragment(TBMWPCRawCont*& mwpcrawCont,std::st return sc; } -StatusCode TBByteStreamCnvTool::ReadFragment(TBADCRawCont*& adcrawCont,std::string key) +StatusCode TBByteStreamCnvTool::ReadFragment(TBADCRawCont*& adcrawCont,const std::string& key) {MsgStream logstr(msgSvc(), name()); logstr << MSG::DEBUG <<" in ReadFragment (TBADCRawCont) key="<<key<<endmsg; StatusCode sc=ReadFragment(3); if(sc) adcrawCont = m_adcrawCont; return sc; } -StatusCode TBByteStreamCnvTool::ReadFragment(TBTDCRawCont*& tdcrawCont,std::string key) +StatusCode TBByteStreamCnvTool::ReadFragment(TBTDCRawCont*& tdcrawCont,const std::string& key) {MsgStream logstr(msgSvc(), name()); logstr << MSG::DEBUG <<" in ReadFragment (TBTDCRawCont) key="<<key<<endmsg; StatusCode sc=ReadFragment(2); @@ -353,7 +353,7 @@ StatusCode TBByteStreamCnvTool::ReadFragment(TBTDCRawCont*& tdcrawCont,std::stri return sc; } -StatusCode TBByteStreamCnvTool::ReadFragment(TBTriggerPatternUnit*& trigpat,std::string key) +StatusCode TBByteStreamCnvTool::ReadFragment(TBTriggerPatternUnit*& trigpat,const std::string& key) {MsgStream logstr(msgSvc(), name()); logstr << MSG::DEBUG <<" in ReadFragment (TBTriggerPatternUnit) key="<<key<<endmsg; StatusCode sc=ReadFragment(1); @@ -361,7 +361,7 @@ StatusCode TBByteStreamCnvTool::ReadFragment(TBTriggerPatternUnit*& trigpat,std: return sc; } -StatusCode TBByteStreamCnvTool::ReadFragment(TBScintillatorRawCont*& scintrawCont,std::string key) +StatusCode TBByteStreamCnvTool::ReadFragment(TBScintillatorRawCont*& scintrawCont,const std::string& key) {MsgStream logstr(msgSvc(), name()); logstr << MSG::DEBUG <<" in ReadFragment (TBScintrawcont) key="<<key<<endmsg; StatusCode sc=ReadFragment(6); @@ -369,14 +369,14 @@ StatusCode TBByteStreamCnvTool::ReadFragment(TBScintillatorRawCont*& scintrawCon return sc; } -StatusCode TBByteStreamCnvTool::ReadFragment(TBTailCatcherRaw*& tailcatchraw,std::string key) +StatusCode TBByteStreamCnvTool::ReadFragment(TBTailCatcherRaw*& tailcatchraw,const std::string& key) {MsgStream logstr(msgSvc(), name()); logstr << MSG::DEBUG <<" in ReadFragment (TBTailCatcherRaw) key="<<key<<endmsg; StatusCode sc=ReadFragment(4); if(sc) tailcatchraw = m_tailcatchraw; return sc; } -StatusCode TBByteStreamCnvTool::ReadFragment(TBEventInfo*& tbeventinfo,std::string key) +StatusCode TBByteStreamCnvTool::ReadFragment(TBEventInfo*& tbeventinfo,const std::string& key) {MsgStream logstr(msgSvc(), name()); logstr << MSG::DEBUG <<" in ReadFragment (TBEventInfo) key="<<key<<endmsg; StatusCode sc=ReadFragment(30); @@ -384,7 +384,7 @@ StatusCode TBByteStreamCnvTool::ReadFragment(TBEventInfo*& tbeventinfo,std::stri return sc; } -StatusCode TBByteStreamCnvTool::ReadFragment(TBLArDigitContainer*& tblardigitcont,std::string key) +StatusCode TBByteStreamCnvTool::ReadFragment(TBLArDigitContainer*& tblardigitcont,const std::string& key) {MsgStream logstr(msgSvc(), name()); logstr << MSG::DEBUG <<" in ReadFragment (TBLArDigitContainer) key="<<key<<endmsg; int code=0; @@ -403,7 +403,7 @@ StatusCode TBByteStreamCnvTool::ReadFragment(TBLArDigitContainer*& tblardigitcon } } -StatusCode TBByteStreamCnvTool::ReadFragment(TBLArCalibDigitContainer*& tblarcalibdigitcont,std::string key) +StatusCode TBByteStreamCnvTool::ReadFragment(TBLArCalibDigitContainer*& tblarcalibdigitcont,const std::string& key) {MsgStream logstr(msgSvc(), name()); logstr << MSG::DEBUG <<" in ReadFragment (TBLArCalibDigitContainer) key="<<key<<endmsg; int code=0; @@ -718,10 +718,7 @@ StatusCode TBByteStreamCnvTool::H6BuildObjects(int unrec_code) // Now figure out if any calibration line connected to this channel is pulsed. // I'm going to cheat and use the fact that we only pulsed one board at a time // and only wrote the corresponding digits (EMEC/HEC/FCAL) - std::vector<HWIdentifier>::const_iterator csl_it=calibChannelIDs.begin(); - std::vector<HWIdentifier>::const_iterator csl_it_e=calibChannelIDs.end(); - for(;csl_it!=csl_it_e;csl_it++) { - HWIdentifier calChan = *csl_it; + for (HWIdentifier calChan : calibChannelIDs) { int chan = m_onlineHelper->channel(calChan); int bit = chan%8; int byte = chan/8; @@ -1275,23 +1272,13 @@ StatusCode TBByteStreamCnvTool::H6BuildObjects(int unrec_code) } logstr << MSG::DEBUG << endmsg; } - - char dac[4]; - unsigned long* tmp; - - int first16 = firstword(m_rodBlock[pos+4]); - int second16 = secondword(m_rodBlock[pos+4]); - - dac[0] = 255 & first16; - dac[1] = first16 >> 8; - dac[2] = 255 & second16; - dac[3] = second16 >> 8; - // this code is copied from Petr Gorbunov H6 doc. - tmp = (unsigned long*) dac; - m_calib_dac = (uint16_t) *tmp; + // See http://cern.ch/atlas-fcaltb/Memos/DAQ/DataFormat.general.pdf + // http://cern.ch/atlas-fcaltb/Data-taking/CBT2/Beam_fragment_format.sxw.pdf + // (Petr Gorbunov H6 FCAL documentation.) + m_calib_dac = firstword(m_rodBlock[pos+4]); - first16 = firstword(m_rodBlock[pos+5]); + unsigned first16 = firstword(m_rodBlock[pos+5]); m_calib_delay = 255 & first16; m_calib_error = ((first16 >> 8) != 0);