1 //Dear emacs, this is -*- c++ -*-
4 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
7 #ifndef LARBYTESTREAM_LARRAWDATACONTBYTESTREAMTOOL_ICC
8 #define LARBYTESTREAM_LARRAWDATACONTBYTESTREAMTOOL_ICC
10 //#include "LArRawEvent/LArRawChannelCollection.h"
11 //#include "LArRecEvent/LArCellCollection.h"
12 //#include "LArRawEvent/LArDigitContainer.h"
15 template <class COLLECTION >
16 bool LArRawDataContByteStreamTool::checkGainConsistency(const COLLECTION* coll) const
17 {typedef typename COLLECTION::const_iterator contIter;
18 contIter it=coll->begin();
19 contIter it_e=coll->end();
20 if (it==it_e) //empty container
22 int fixgain=(*it)->gain();
24 if (fixgain!=(*it)->gain())
30 // We read all avaliable data => Loop over all LAr-Subdetectors and all RODs
31 // All the methods derivated from the template should be there
32 // The Following collection types are included :
33 // LArAccumulatedCalibDigit, LArAccumulatedDigit, LArCalibDigit, LArDigit,
34 // LArFebHeader and LArRawChannel
35 template <class COLLECTION, typename ...ARGS >
36 StatusCode LArRawDataContByteStreamTool::convert(const RawEvent* re,
38 CaloGain::CaloGain gain,
42 if (prepareRobIndex(re, robIndex).isFailure()){
43 ATH_MSG_ERROR ( "Error in prepareRobIndex " );
44 return StatusCode::FAILURE;
46 RobIndex_t::const_iterator it = robIndex.find(eformat::LAR);
47 if ( it != robIndex.end() ) {
48 const std::vector<const uint32_t*>& robs = (*it).second;
49 std::vector<const uint32_t*>::const_iterator rob_add;
50 for(rob_add = robs.begin(); rob_add!=robs.end();++rob_add){
52 OFFLINE_FRAGMENTS_NAMESPACE::PointerType p;
53 OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment robFrag(*rob_add);
54 uint32_t fragSourceID = robFrag.rod_source_id();
56 if( fragSourceID & 0x1000 ){
57 ATH_MSG_DEBUG(" skip Latome fragment with source ID "<< std::hex << fragSourceID);
61 if (!m_decoder->check_valid (&robFrag, msg())) {
62 ATH_MSG_WARNING ( "Error reading bytestream event: "
63 << "Invalid ROB fragment for source ID " << robFrag.rod_source_id() );
64 continue; //return StatusCode::FAILURE;
66 uint32_t n = robFrag.rod_ndata() ;
69 ATH_MSG_WARNING ( "Error reading bytestream event: "
70 << "Empty ROD block (less than 3 words) for source ID " << robFrag.rod_source_id() );
72 //return StatusCode::FAILURE;
74 ATH_MSG_DEBUG ( "Format Version Number of ROD-Data Block: "
75 << MSG::hex << robFrag.rod_version()
77 ATH_MSG_VERBOSE ( "Calling RodDecoder for source ID " << MSG::hex
78 << robFrag.rod_source_id() << MSG::dec );
79 m_decoder->fillCollection(robFrag,
81 std::forward<ARGS>(args)...); // ..and decode them.
83 catch (eformat::Issue& ex) {
84 ATH_MSG_WARNING ( " exception thrown by ROBFragment, badly corrupted event. Abort decoding " );
88 }//end if LAr SubDet or ROS event building
90 ATH_MSG_VERBOSE ( "End of LArDigitCnvTool. Container size=" << coll->size() );
91 return StatusCode::SUCCESS;