ATLAS Offline Software
LArCalibDigitContByteStreamCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
12 #include "ByteStreamData/RawEvent.h"
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 
36 }
37 
40 }
41 
42 
45 {
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() );
57 
58  return StatusCode::SUCCESS;
59 }
60 
62 LArCalibDigitContByteStreamCnv::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 
98  LArCalibDigitContainer *CalibDigitContainer=new LArCalibDigitContainer;
99  StatusCode sc=m_tool->convert(re,CalibDigitContainer,gain,
100  **calibLineMapping,
101  **onOffIdMapping);
102  if (sc!=StatusCode::SUCCESS) {
103  ATH_MSG_WARNING( "Conversion tool returned an error. LArCalibDigitContainer might be empty." );
104  }
105 
106  pObj = SG::asStorable(CalibDigitContainer) ;
107  return StatusCode::SUCCESS;
108 }
109 
110 StatusCode
111 LArCalibDigitContByteStreamCnv::createRepConst(DataObject* pObj, IOpaqueAddress*& pAddr) const
112 {// convert LArDigits from StoreGate into ByteStream
113  ATH_MSG_VERBOSE( "Execute CreateRep method of LArCalibDigitContainer " );
114  // Get Full Event Assembler
116  ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler(fea,"LAr") );
117 
118  LArCalibDigitContainer* CalibDigitContainer=0;
119  if (!SG::fromStorable (pObj, CalibDigitContainer) || !CalibDigitContainer) {
120  ATH_MSG_ERROR( "Cannot get LArCalibDigitContainer for DataObject. Key=" << pObj->registry()->name() );
121  return StatusCode::FAILURE;
122  }
123 
124  std::string nm = pObj->registry()->name();
125  pAddr = new ByteStreamAddress(classID(),nm,"");
126 
127  ATH_CHECK( m_tool->WriteLArCalibDigits(CalibDigitContainer, *fea) );
128 
129  return StatusCode::SUCCESS;
130 }
LArCalibDigitContByteStreamCnv::classID
static const CLID & classID()
Definition: LArCalibDigitContByteStreamCnv.cxx:38
LArCalibDigitContainer.h
LArCalibDigitContByteStreamCnv::initialize
virtual StatusCode initialize() override
Definition: LArCalibDigitContByteStreamCnv.cxx:44
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
FullEventAssembler
Template class for assembling a full atlas raw event from subfragments.
Definition: FullEventAssembler.h:40
SG::fromStorable
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
Definition: StorableConversions.h:180
StorableConversions.h
convert to and from a SG storable
LArCalibDigitContByteStreamCnv::createObjConst
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
Definition: LArCalibDigitContByteStreamCnv.cxx:62
initialize
void initialize()
Definition: run_EoverP.cxx:894
LArCalibDigitContByteStreamCnv::m_rdpSvc
ServiceHandle< IROBDataProviderSvc > m_rdpSvc
Definition: LArCalibDigitContByteStreamCnv.h:56
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.
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
LArCalibDigitContByteStreamCnv::m_calibLineMappingKey
SG::ReadCondHandleKey< LArCalibLineMapping > m_calibLineMappingKey
Definition: LArCalibDigitContByteStreamCnv.h:58
LArCalibDigitContByteStreamCnv::m_byteStreamCnvSvc
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
Definition: LArCalibDigitContByteStreamCnv.h:57
LArCalibDigitContByteStreamCnv.h
LArCalibDigitContByteStreamCnv::m_tool
ToolHandle< BYTESTREAMTOOL > m_tool
Definition: LArCalibDigitContByteStreamCnv.h:55
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
ReadCondHandle.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
LArCalibDigitContByteStreamCnv::createRepConst
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Convert the transient object to the requested representation.
Definition: LArCalibDigitContByteStreamCnv.cxx:111
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
LArCalibDigitContainer
Container class for LArCalibDigit.
Definition: LArCalibDigitContainer.h:19
LArOnOffIdMapping.h
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
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
LArCalibDigitContByteStreamCnv::LArCalibDigitContByteStreamCnv
LArCalibDigitContByteStreamCnv(ISvcLocator *svcloc)
Definition: LArCalibDigitContByteStreamCnv.cxx:26
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
CaloGain::LARMEDIUMGAIN
@ LARMEDIUMGAIN
Definition: CaloGain.h:18
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
re
const boost::regex re(r_e)
LArCalibDigitContByteStreamCnv::~LArCalibDigitContByteStreamCnv
virtual ~LArCalibDigitContByteStreamCnv()
Definition: LArCalibDigitContByteStreamCnv.cxx:35
ByteStreamCnvSvcBase.h
CaloGain::LARLOWGAIN
@ LARLOWGAIN
Definition: CaloGain.h:18
IByteStreamCnvSvc.h
LArCalibLineMapping.h
LArCalibDigitContByteStreamCnv::m_onOffIdMappingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_onOffIdMappingKey
Definition: LArCalibDigitContByteStreamCnv.h:59
IROBDataProviderSvc.h
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37