ATLAS Offline Software
LArRawDataContByteStreamTool.icc
Go to the documentation of this file.
1 //Dear emacs, this is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef LARBYTESTREAM_LARRAWDATACONTBYTESTREAMTOOL_ICC
8 #define LARBYTESTREAM_LARRAWDATACONTBYTESTREAMTOOL_ICC
9 
10 
11 template <class COLLECTION >
12 bool LArRawDataContByteStreamTool::checkGainConsistency(const COLLECTION* coll) const
13 {typedef typename COLLECTION::const_iterator contIter;
14  contIter it=coll->begin();
15  contIter it_e=coll->end();
16  if (it==it_e) //empty container
17  return true;
18  int fixgain=(*it)->gain();
19  for (;it!=it_e;++it)
20  if (fixgain!=(*it)->gain())
21  return false;
22  return true;
23 }
24 
25 
26 // We read all avaliable data => Loop over all LAr-Subdetectors and all RODs
27 // All the methods derivated from the template should be there
28 // The Following collection types are included :
29 // LArAccumulatedCalibDigit, LArAccumulatedDigit, LArCalibDigit, LArDigit,
30 // LArFebHeader and LArRawChannel
31 template <class COLLECTION, typename ...ARGS >
32 StatusCode
33 LArRawDataContByteStreamTool::convert(const RawEvent* re, COLLECTION* coll,
34 CaloGain::CaloGain gain, ARGS&&... args) const {
35  RobIndex_t robIndex;
36  if (prepareRobIndex(re, robIndex).isFailure()){
37  ATH_MSG_ERROR ( "Error in prepareRobIndex " );
38  return StatusCode::FAILURE;
39  }
40  RobIndex_t::const_iterator it = robIndex.find(eformat::LAR);
41  if ( it != robIndex.end() ) {
42  const std::vector<const uint32_t*>& robs = (*it).second;
43  std::vector<const uint32_t*>::const_iterator rob_add;
44  for(rob_add = robs.begin(); rob_add!=robs.end();++rob_add){
45  try {
46  OFFLINE_FRAGMENTS_NAMESPACE::PointerType p;
47  OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment robFrag(*rob_add);
48  uint32_t fragSourceID = robFrag.rod_source_id();
49  if( fragSourceID & 0x1000 ){
50  ATH_MSG_DEBUG(" skip Latome fragment with source ID "<< std::hex << fragSourceID);
51  continue;
52  }
53  if (!m_decoder->check_valid (&robFrag, msg())) {
54  ATH_MSG_WARNING ( "Error reading bytestream event: " <<
55  "Invalid ROB fragment for source ID " << robFrag.rod_source_id() );
56  continue; //return StatusCode::FAILURE;
57  }
58  uint32_t n = robFrag.rod_ndata() ;
59  robFrag.rod_data(p);
60  if (n < 3) {
61  ATH_MSG_WARNING ( "Error reading bytestream event: " <<
62  "Empty ROD block (less than 3 words) for source ID " <<
63  robFrag.rod_source_id() );
64  continue;
65  }
66  ATH_MSG_DEBUG ( "Format Version Number of ROD-Data Block: " <<
67  MSG::hex << robFrag.rod_version() << MSG::dec);
68  ATH_MSG_VERBOSE ( "Calling RodDecoder for source ID " << MSG::hex
69  << robFrag.rod_source_id() << MSG::dec );
70  m_decoder->fillCollection(robFrag, p,n,*coll,gain, args...); // ..and decode them.
71  } catch (eformat::Issue& ex) {
72  ATH_MSG_WARNING ( " exception thrown by ROBFragment, badly corrupted event. Abort decoding " );
73  coll->clear();
74  break;
75  }
76  }//end if LAr SubDet or ROS event building
77  }//end of if empty
78  ATH_MSG_VERBOSE ( "End of LArDigitCnvTool. Container size=" << coll->size() );
79  return StatusCode::SUCCESS;
80 }
81 
82 #endif