ATLAS Offline Software
LArAccumulatedDigitContByteStreamCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
9 
14 #include "ByteStreamData/RawEvent.h"
15 
16 #include "GaudiKernel/MsgStream.h"
17 #include "GaudiKernel/StatusCode.h"
18 #include "GaudiKernel/DataObject.h"
19 #include "GaudiKernel/IRegistry.h"
20 
22 
23 #include "StoreGate/StoreGateSvc.h"
24 #include "AthenaKernel/CLASS_DEF.h"
25 
26 // Tool
27 #include "GaudiKernel/IToolSvc.h"
28 
29 //STL-Stuff
30 #include <map>
31 #include <iostream>
32 
33 
35  AthConstConverter(storageType(), classID(),svcloc,"LArAccumulatedDigitContByteStreamCnv"),
36  m_tool("LArRawDataContByteStreamTool"),
37  m_rdpSvc("ROBDataProviderSvc", name())
38 {}
39 
42 }
43 
45 }
46 
47 
50 {
52 
53  if ( m_rdpSvc.retrieve().isFailure()) {
54  ATH_MSG_WARNING( " Can't get ByteStreamInputSvc interface Reading of ByteStream Data not possible. " );
55  }
56 
57  ATH_CHECK( m_tool.retrieve() );
58 
59  return StatusCode::SUCCESS;
60 
61 }
62 
64 LArAccumulatedDigitContByteStreamCnv::createObjConst(IOpaqueAddress* pAddr, DataObject*& pObj) const
65 {//Convert Accumulated Digits from ByteStream to StoreGate
66  ATH_MSG_VERBOSE( "Executing CreateObj method for LArAccumulatedDigitContainer ");
67 
68  if (!m_rdpSvc) {
69  ATH_MSG_ERROR( " ROBDataProviderSvc not loaded. Can't read ByteStream." );
70  return StatusCode::FAILURE;
71  }
72  ByteStreamAddress *pRE_Addr;
73  pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr); //Cast from OpaqueAddress to ByteStreamAddress
74  if (!pRE_Addr) {
75  ATH_MSG_ERROR( "dynamic_cast of OpaqueAdress to ByteStreamAddress failed!" );
76  return StatusCode::FAILURE;
77  }
78 
79  const RawEvent* re = m_rdpSvc->getEvent(Gaudi::Hive::currentContext());
80  if (!re) {
81  ATH_MSG_ERROR( "Could not get raw event from ByteStreamInputSvc" );
82  return StatusCode::FAILURE;
83  }
84  const std::string& key = *(pAddr->par()); // Get key used in the StoreGateSvc::retrieve function
85  // get gain and pass to convert function.
86  CaloGain::CaloGain gain=CaloGain::LARNGAIN; //At this place, LARNGAINS means Automatic gain.
87  if (key=="HIGH")
89  else if (key=="MEDIUM")
91  else if (key=="LOW")
93 
94  // Convert the RawEvent to LArAccumulatedDigitContainer
95  ATH_MSG_DEBUG( "Converting LArAccumulatedDigits (from ByteStream). key=" << key << " ,gain=" << gain );
97  StatusCode sc=m_tool->convert(re,DigitContainer,gain);
98  if (sc!=StatusCode::SUCCESS) {
99  ATH_MSG_WARNING( "Conversion tool returned an error. LArAccumulatedDigitContainer might be empty." );
100  }
101  pObj = SG::asStorable(DigitContainer) ;
102 
103  return StatusCode::SUCCESS;
104 }
105 // IWS 19.07.2005
106  StatusCode
107  LArAccumulatedDigitContByteStreamCnv::createRepConst(DataObject* /*pObj*/, IOpaqueAddress*& /*pAddr*/) const
108 {// convert LArAccumulatedDigits from StoreGate into ByteStream
109  ATH_MSG_ERROR( "CreateRep method of LArAccumulatedDigitContainer not implemented" );
110  return StatusCode::SUCCESS;
111 }
112 
LArAccumulatedDigitContainer
Container class for LArAccumulatedDigit.
Definition: LArAccumulatedDigitContainer.h:22
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
LArAccumulatedDigitContainer.h
initialize
void initialize()
Definition: run_EoverP.cxx:894
LArAccumulatedDigitContByteStreamCnv::initialize
virtual StatusCode initialize() override
Definition: LArAccumulatedDigitContByteStreamCnv.cxx:49
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
RawEvent
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition: RawEvent.h:37
LArRawDataContByteStreamTool.h
Helper tool for conversion of raw data classes to/from LArByteStream.
LArAccumulatedDigitContByteStreamCnv.h
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AthConstConverter
Gaudi converter base class with const interfaces.
Definition: AthConstConverter.h:33
CaloGain::LARNGAIN
@ LARNGAIN
Definition: CaloGain.h:19
LArAccumulatedDigitContByteStreamCnv::~LArAccumulatedDigitContByteStreamCnv
virtual ~LArAccumulatedDigitContByteStreamCnv()
Definition: LArAccumulatedDigitContByteStreamCnv.cxx:44
LArAccumulatedDigitContByteStreamCnv::m_rdpSvc
ServiceHandle< IROBDataProviderSvc > m_rdpSvc
Definition: LArAccumulatedDigitContByteStreamCnv.h:55
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::asStorable
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Definition: DataObjectSharedPtr.h:65
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
LArAccumulatedDigitContByteStreamCnv::createObjConst
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
Definition: LArAccumulatedDigitContByteStreamCnv.cxx:64
LArAccumulatedDigitContByteStreamCnv::classID
static const CLID & classID()
Definition: LArAccumulatedDigitContByteStreamCnv.cxx:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
RawEvent.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ByteStreamAddress
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Definition: ByteStreamAddress.h:28
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ByteStreamAddress.h
LArAccumulatedDigitContByteStreamCnv::m_tool
ToolHandle< BYTESTREAMTOOL > m_tool
Definition: LArAccumulatedDigitContByteStreamCnv.h:54
LArAccumulatedDigitContByteStreamCnv::createRepConst
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Convert the transient object to the requested representation.
Definition: LArAccumulatedDigitContByteStreamCnv.cxx:107
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
CaloGain::LARMEDIUMGAIN
@ LARMEDIUMGAIN
Definition: CaloGain.h:18
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
re
const boost::regex re(r_e)
ByteStreamCnvSvcBase.h
LArAccumulatedDigitContByteStreamCnv::LArAccumulatedDigitContByteStreamCnv
LArAccumulatedDigitContByteStreamCnv(ISvcLocator *svcloc)
Definition: LArAccumulatedDigitContByteStreamCnv.cxx:34
CaloGain::LARLOWGAIN
@ LARLOWGAIN
Definition: CaloGain.h:18
IByteStreamCnvSvc.h
CaloGain.h
StoreGateSvc.h
CLASS_DEF.h
macros to associate a CLID to a type
IROBDataProviderSvc.h
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37