ATLAS Offline Software
LArRawScContByteStreamCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 
10 
15 #include "ByteStreamData/RawEvent.h"
16 
17 #include "GaudiKernel/MsgStream.h"
18 #include "GaudiKernel/StatusCode.h"
19 #include "GaudiKernel/DataObject.h"
20 #include "GaudiKernel/IRegistry.h"
21 
23 
24 #include "StoreGate/StoreGateSvc.h"
25 #include "AthenaKernel/CLASS_DEF.h"
26 // For LATOME while no Condition alg exists
27 #include "LArLATOMEROBIDs.h"
28 
29 // Tool
30 #include "GaudiKernel/IToolSvc.h"
31 
32 //STL-Stuff
33 #include <map>
34 #include <iostream>
35 
36 
38  Converter(storageType(), classID(),svcloc), m_log(NULL),m_ByteStreamEventAccess(NULL),m_rdpSvc(NULL),m_storeGate(NULL){}
39 
41  if (m_log)
42  delete m_log;
43 }
44 
47 }
48 
49 
52 {
54  if(StatusCode::SUCCESS!=sc)
55  {
56  return sc;
57  }
58  m_log = new MsgStream(msgSvc(),"LArLATOMEHeaderBSCnv");
59  (*m_log) << MSG::DEBUG<< " initialize " <<endmsg;
60  IService* svc;
61  //Get ByteStreamCnvSvc
62  if(StatusCode::SUCCESS != serviceLocator()->getService("ByteStreamCnvSvc",svc)){
63  (*m_log) << MSG::ERROR << " Can't get ByteStreamEventAccess interface " << endmsg;
64  return StatusCode::FAILURE;
65  }
67  if (m_ByteStreamEventAccess==NULL)
68  {
69  (*m_log) <<MSG::ERROR<< " LArRawScContByteStreamCnv: Can't cast to ByteStreamCnvSvc " <<endmsg;
70  return StatusCode::FAILURE ;
71  }
72 
73  //Get ByteStreamInputSvc (only necessary for reading of digits, not for writing and for channels)
74 
75  if(StatusCode::SUCCESS != serviceLocator()->getService("ROBDataProviderSvc",svc)){
76  (*m_log) << MSG::WARNING << " Can't get ByteStreamInputSvc interface Reading of ByteStream Data not possible. " << endmsg;
77  m_rdpSvc=0;
78  }
79  else {
80  m_rdpSvc=dynamic_cast<IROBDataProviderSvc*>(svc);
81  if(m_rdpSvc == 0 ) {
82  (*m_log) <<MSG::ERROR<< " LArRawScContByteStreamCnv: Can't cast to ByteStreamInputSvc " <<endmsg;
83  return StatusCode::FAILURE;
84  }
85  }
86 
87  // retrieve ToolSvc
88  IToolSvc* toolSvc;
89 
90  if(StatusCode::SUCCESS != service("ToolSvc",toolSvc)){
91  (*m_log) << MSG::ERROR << " Can't get ToolSvc " << endmsg;
92  return StatusCode::FAILURE;
93  }
94 
95  //Get SuperCellTool
96  sc=toolSvc->retrieveTool("LArLATOMEDecoder",m_scTool);
97  if (sc.isFailure()) {
98  (*m_log) << MSG::ERROR << "Can't get LArLATOMEDecoder Tool" << endmsg;
99  return sc;
100  } else {
101  (*m_log) << MSG::INFO << "Retrieved LArLATOMEDecoder Tool" << endmsg;
102  }
103 
104  //Get StoreGateSvc
105  return service("StoreGateSvc", m_storeGate);
106 
107 }
108 
110 LArRawScContByteStreamCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
111 {//Convert Digits from ByteStream to StoreGate
112  (*m_log) << MSG::VERBOSE << "Executing CreateObj method for LArLATOMEHeaderContainer" << endmsg;
113 
114  if (!m_rdpSvc)
115  {(*m_log) << MSG::ERROR << " ROBDataProviderSvc not loaded. Can't read ByteStream." << endmsg;
116  return StatusCode::FAILURE;
117  }
118  ByteStreamAddress *pRE_Addr;
119  pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr); //Cast from OpaqueAddress to ByteStreamAddress
120  if (!pRE_Addr)
121  {(*m_log) << MSG::ERROR << "dynamic_cast of OpaqueAdress to ByteStreamAddress failed!" << endmsg;
122  return StatusCode::FAILURE;
123  }
124 
125  // patch for the HLT usage
126  std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags;
127  m_rdpSvc->getROBData( LArByteStream::s_allROBIDs_LATOME, robFrags );
128  const RawEvent* re = m_rdpSvc->getEvent();
129  if (!re)
130  {(*m_log) << MSG::ERROR << "Could not get raw event from ByteStreamInputSvc" << endmsg;
131  return StatusCode::FAILURE;
132  }
133  const std::string& key = *(pAddr->par()); // Get key used in the StoreGateSvc::retrieve function
134  // get gain and pass to convert function.
135  LArDigitContainer* adc_coll=0;
136  LArDigitContainer* adc_bas_coll=0;
137  LArRawSCContainer* et_coll=0;
138  LArRawSCContainer* et_id_coll=0;
139  LArLATOMEHeaderContainer* header_coll=0;
140 
141  if(key=="SC_ET"){
142  et_coll=new LArRawSCContainer();
143  }
144  else if(key=="SC_ET_ID"){
145  et_id_coll=new LArRawSCContainer();
146  }
147 
148  (*m_log) << MSG::DEBUG << "Converting LArRawSCContainer (from ByteStream). key=" << key << endmsg;
149  StatusCode sc;
150 
151  //Supercell readout
152  sc=m_scTool->convert(robFrags,nullptr,adc_coll, adc_bas_coll, et_coll, et_id_coll, header_coll);
153  if (sc!=StatusCode::SUCCESS)
154  (*m_log) << MSG::WARNING << "Conversion tool returned an error. LAr SC containers might be empty." << endmsg;
155 
156  if(key=="SC_ET"){
157  pObj = SG::asStorable(et_coll);
158  }
159  else if(key=="SC_ET_ID"){
160  pObj = SG::asStorable(et_id_coll);
161  }
162 
163 
164  return StatusCode::SUCCESS;
165 
166 }
167 
168  StatusCode
169 LArRawScContByteStreamCnv::createRep(DataObject* , IOpaqueAddress*& )
170 {
171  return StatusCode::SUCCESS;
172 }
LArLATOMEDecoder::convert
StatusCode convert(const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &robFrags, const LArLATOMEMapping *map, LArDigitContainer *adc_coll, LArDigitContainer *adc_bas_coll, LArRawSCContainer *et_coll, LArRawSCContainer *et_id_coll, LArLATOMEHeaderContainer *header_coll) const
Converter.
Definition: LArLATOMEDecoder.cxx:94
LArRawScContByteStreamCnv::m_storeGate
StoreGateSvc * m_storeGate
Definition: LArRawScContByteStreamCnv.h:53
LArRawSCContainer
Container class for LArRawSC.
Definition: LArRawSCContainer.h:17
initialize
void initialize()
Definition: run_EoverP.cxx:894
RawEvent
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition: RawEvent.h:37
LArRawScContByteStreamCnv::m_scTool
LArLATOMEDecoder * m_scTool
Definition: LArRawScContByteStreamCnv.h:50
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
LArRawScContByteStreamCnv.h
LArLATOMEHeaderContainer
Container class for LArLATOMEHeader.
Definition: LArLATOMEHeaderContainer.h:19
LArLATOMEROBIDs.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
IROBDataProviderSvc
Interface class for managing ROB for both online and offline.
Definition: IROBDataProviderSvc.h:25
ByteStreamCnvSvc
Gaudi Conversion Service class for ByteStream Persistency.
Definition: ByteStreamCnvSvc.h:34
IROBDataProviderSvc::getROBData
virtual void getROBData(const std::vector< uint32_t > &robIds, VROBFRAG &robFragments, const std::string_view callerName="UNKNOWN")=0
Retrieve ROBFragments for given ROB ids from cache.
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
RawEvent.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ByteStreamAddress
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Definition: ByteStreamAddress.h:28
ByteStreamAddress.h
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
ByteStreamCnvSvc.h
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
LArRawScContByteStreamCnv::m_rdpSvc
IROBDataProviderSvc * m_rdpSvc
Definition: LArRawScContByteStreamCnv.h:52
IROBDataProviderSvc::getEvent
virtual const RawEvent * getEvent()=0
Retrieve the whole event.
Converter
Definition: Converter.h:27
LArDigitContainer.h
LArRawScContByteStreamCnv::initialize
virtual StatusCode initialize()
Definition: LArRawScContByteStreamCnv.cxx:51
LArRawScContByteStreamCnv::classID
static const CLID & classID()
Definition: LArRawScContByteStreamCnv.cxx:45
LArRawScContByteStreamCnv::~LArRawScContByteStreamCnv
virtual ~LArRawScContByteStreamCnv()
Definition: LArRawScContByteStreamCnv.cxx:40
re
const boost::regex re(r_e)
DEBUG
#define DEBUG
Definition: page_access.h:11
LArDigitContainer
Container class for LArDigit.
Definition: LArDigitContainer.h:24
ByteStreamCnvSvcBase.h
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
LArLATOMEDecoder.h
Byte stream converter of LATOME.
LArRawScContByteStreamCnv::m_ByteStreamEventAccess
ByteStreamCnvSvc * m_ByteStreamEventAccess
Definition: LArRawScContByteStreamCnv.h:51
CaloGain.h
StoreGateSvc.h
LArRawScContByteStreamCnv::LArRawScContByteStreamCnv
LArRawScContByteStreamCnv(ISvcLocator *svcloc)
Definition: LArRawScContByteStreamCnv.cxx:37
CLASS_DEF.h
macros to associate a CLID to a type
LArRawScContByteStreamCnv::m_log
MsgStream * m_log
Definition: LArRawScContByteStreamCnv.h:49
LArRawScContByteStreamCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Definition: LArRawScContByteStreamCnv.cxx:110
IROBDataProviderSvc.h
LArRawScContByteStreamCnv::createRep
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
Definition: LArRawScContByteStreamCnv.cxx:169
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37