ATLAS Offline Software
Loading...
Searching...
No Matches
LArCalibDigitContByteStreamCnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
7
13
17
20
21//STL-Stuff
22#include <map>
23#include <iostream>
24
25
27 AthConstConverter(storageType(), classID(),svcloc,"LArCalibDigitContByteStreamCnv"),
28 m_tool("LArRawDataContByteStreamTool"),
29 m_rdpSvc("ROBDataProviderSvc", name()),
30 m_byteStreamCnvSvc("ByteStreamCnvSvc", name()),
31 m_calibLineMappingKey ("LArCalibLineMap"),
32 m_onOffIdMappingKey ("LArOnOffIdMap")
33{}
34
37
41
42
43StatusCode
45{
46 ATH_CHECK( AthConstConverter::initialize() );
47
48 if ( m_rdpSvc.retrieve().isFailure()) {
49 ATH_MSG_WARNING( " Can't get ByteStreamInputSvc interface Reading of ByteStream Data not possible. " );
50 }
51
52 ATH_CHECK( m_byteStreamCnvSvc.retrieve() );
53
54 ATH_CHECK( m_tool.retrieve() );
55 ATH_CHECK( m_calibLineMappingKey.initialize() );
56 ATH_CHECK( m_onOffIdMappingKey.initialize() );
57
58 return StatusCode::SUCCESS;
59}
60
61StatusCode
62LArCalibDigitContByteStreamCnv::createObjConst(IOpaqueAddress* pAddr, DataObject*& pObj) const
63{//Convert Digits from ByteStream to StoreGate
64 ATH_MSG_VERBOSE( "Executing CreateObj method for LArCalibDigitContainer " );
65
66 if (!m_rdpSvc) {
67 ATH_MSG_ERROR( " ROBDataProviderSvc not loaded. Can't read ByteStream." );
68 return StatusCode::FAILURE;
69 }
70 ByteStreamAddress *pRE_Addr;
71 pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr); //Cast from OpaqueAddress to ByteStreamAddress
72 if (!pRE_Addr) {
73 ATH_MSG_ERROR( "dynamic_cast of OpaqueAdress to ByteStreamAddress failed!" );
74 return StatusCode::FAILURE;
75 }
76
77 const RawEvent* re = m_rdpSvc->getEvent(Gaudi::Hive::currentContext());
78 if (!re) {
79 ATH_MSG_ERROR( "Could not get raw event from ByteStreamInputSvc" );
80 return StatusCode::FAILURE;
81 }
82 const std::string& key = *(pAddr->par()); // Get key used in the StoreGateSvc::retrieve function
83 // get gain an pass to convert function.
84 // get gain and pass to convert function.
85 CaloGain::CaloGain gain=CaloGain::LARNGAIN; //At this place, LARNGAINS means Automatic gain.
86 if (key=="HIGH")
88 else if (key=="MEDIUM")
90 else if (key=="LOW")
92 // Convert the RawEvent to LArCalibDigitContainer
93 ATH_MSG_DEBUG( "Converting LArCalibDigits (from ByteStream). key=" << key << " ,gain=" << gain );
94
97 if (!*calibLineMapping || !*onOffIdMapping) {
98 ATH_MSG_ERROR ("Cannot access mappings");
99 return StatusCode::FAILURE;
100 }
101
102 LArCalibDigitContainer *CalibDigitContainer=new LArCalibDigitContainer;
103 StatusCode sc=m_tool->convert(re,CalibDigitContainer,gain,
104 **calibLineMapping,
105 **onOffIdMapping);
106 if (sc!=StatusCode::SUCCESS) {
107 ATH_MSG_WARNING( "Conversion tool returned an error. LArCalibDigitContainer might be empty." );
108 }
109
110 pObj = SG::asStorable(CalibDigitContainer) ;
111 return StatusCode::SUCCESS;
112}
113
114StatusCode
115LArCalibDigitContByteStreamCnv::createRepConst(DataObject* pObj, IOpaqueAddress*& pAddr) const
116{// convert LArDigits from StoreGate into ByteStream
117 ATH_MSG_VERBOSE( "Execute CreateRep method of LArCalibDigitContainer " );
118 // Get Full Event Assembler
120 ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler(fea,"LAr") );
121
122 LArCalibDigitContainer* CalibDigitContainer=0;
123 if (!SG::fromStorable (pObj, CalibDigitContainer) || !CalibDigitContainer) {
124 ATH_MSG_ERROR( "Cannot get LArCalibDigitContainer for DataObject. Key=" << pObj->registry()->name() );
125 return StatusCode::FAILURE;
126 }
127
128 std::string nm = pObj->registry()->name();
129 pAddr = new ByteStreamAddress(classID(),nm,"");
130
131 ATH_CHECK( m_tool->WriteLArCalibDigits(CalibDigitContainer, *fea) );
132
133 return StatusCode::SUCCESS;
134}
const boost::regex re(r_e)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
uint32_t CLID
The Class ID type.
static Double_t sc
Helper tool for conversion of raw data classes to/from LArByteStream.
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition RawEvent.h:37
convert to and from a SG storable
AthConstConverter(long storage_type, const CLID &class_type, ISvcLocator *svc, const std::string &name)
const std::string & name() const
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Template class for assembling a full atlas raw event from subfragments.
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Convert the transient object to the requested representation.
SG::ReadCondHandleKey< LArOnOffIdMapping > m_onOffIdMappingKey
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
SG::ReadCondHandleKey< LArCalibLineMapping > m_calibLineMappingKey
ServiceHandle< IROBDataProviderSvc > m_rdpSvc
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
Container class for LArCalibDigit.
@ LARMEDIUMGAIN
Definition CaloGain.h:18
@ LARLOWGAIN
Definition CaloGain.h:18
@ LARNGAIN
Definition CaloGain.h:19
@ LARHIGHGAIN
Definition CaloGain.h:18
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)