ATLAS Offline Software
LArRawDataContByteStreamTool.icc
Go to the documentation of this file.
1 //Dear emacs, this is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef LARBYTESTREAM_LARRAWDATACONTBYTESTREAMTOOL_ICC
8 #define LARBYTESTREAM_LARRAWDATACONTBYTESTREAMTOOL_ICC
9 
10 //#include "LArRawEvent/LArRawChannelCollection.h"
11 //#include "LArRecEvent/LArCellCollection.h"
12 //#include "LArRawEvent/LArDigitContainer.h"
13 
14 
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
21  return true;
22  int fixgain=(*it)->gain();
23  for (;it!=it_e;++it)
24  if (fixgain!=(*it)->gain())
25  return false;
26  return true;
27 }
28 
29 
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,
37  COLLECTION* coll,
38  CaloGain::CaloGain gain,
39  ARGS&&... args) const
40 {
41  RobIndex_t robIndex;
42  if (prepareRobIndex(re, robIndex).isFailure()){
43  ATH_MSG_ERROR ( "Error in prepareRobIndex " );
44  return StatusCode::FAILURE;
45  }
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){
51  try {
52  OFFLINE_FRAGMENTS_NAMESPACE::PointerType p;
53  OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment robFrag(*rob_add);
54  uint32_t fragSourceID = robFrag.rod_source_id();
55 
56  if( fragSourceID & 0x1000 ){
57  ATH_MSG_DEBUG(" skip Latome fragment with source ID "<< std::hex << fragSourceID);
58  continue;
59  }
60 
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;
65  }
66  uint32_t n = robFrag.rod_ndata() ;
67  robFrag.rod_data(p);
68  if (n < 3) {
69  ATH_MSG_WARNING ( "Error reading bytestream event: "
70  << "Empty ROD block (less than 3 words) for source ID " << robFrag.rod_source_id() );
71  continue;
72  //return StatusCode::FAILURE;
73  }
74  ATH_MSG_DEBUG ( "Format Version Number of ROD-Data Block: "
75  << MSG::hex << robFrag.rod_version()
76  << MSG::dec);
77  ATH_MSG_VERBOSE ( "Calling RodDecoder for source ID " << MSG::hex
78  << robFrag.rod_source_id() << MSG::dec );
79  m_decoder->fillCollection(robFrag,
80  p,n,*coll,gain,
81  std::forward<ARGS>(args)...); // ..and decode them.
82  }
83  catch (eformat::Issue& ex) {
84  ATH_MSG_WARNING ( " exception thrown by ROBFragment, badly corrupted event. Abort decoding " );
85  coll->clear();
86  break;
87  }
88  }//end if LAr SubDet or ROS event building
89  }//end of if empty
90  ATH_MSG_VERBOSE ( "End of LArDigitCnvTool. Container size=" << coll->size() );
91  return StatusCode::SUCCESS;
92 }
93 
94 #endif