ATLAS Offline Software
LArAccumulatedCalibDigitContByteStreamCnv.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 
23 
24 #include "StoreGate/StoreGateSvc.h"
26 #include "AthenaKernel/CLASS_DEF.h"
27 
28 // Tool
29 #include "GaudiKernel/IToolSvc.h"
30 
31 //STL-Stuff
32 #include <map>
33 #include <iostream>
34 
35 
37  AthConstConverter(storageType(), classID(),svcloc,"LArAccumulatedCalibDigitContByteStreamCnv"),
38  m_tool("LArRawDataContByteStreamTool"),
39  m_rdpSvc("ROBDataProviderSvc", name()),
40  m_calibLineMappingKey ("LArCalibLineMap")
41 {}
42 
45 }
46 
48 }
49 
50 
53 {
55 
56  if ( m_rdpSvc.retrieve().isFailure()) {
57  ATH_MSG_WARNING( " Can't get ByteStreamInputSvc interface Reading of ByteStream Data not possible. " );
58  }
59 
60  ATH_CHECK( m_tool.retrieve() );
62 
63  return StatusCode::SUCCESS;
64 }
65 
67 LArAccumulatedCalibDigitContByteStreamCnv::createObjConst(IOpaqueAddress* pAddr, DataObject*& pObj) const
68 {//Convert Accumulated Calib Digits from ByteStream to StoreGate
69  ATH_MSG_VERBOSE( "Executing CreateObj method for LArAccumulatedCalibDigitContainer " );
70 
71 
72  if (!m_rdpSvc) {
73  ATH_MSG_ERROR( " ROBDataProviderSvc not loaded. Can't read ByteStream." );
74  return StatusCode::FAILURE;
75  }
76  ByteStreamAddress *pRE_Addr;
77  pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr); //Cast from OpaqueAddress to ByteStreamAddress
78  if (!pRE_Addr) {
79  ATH_MSG_ERROR( "dynamic_cast of OpaqueAdress to ByteStreamAddress failed!" );
80  return StatusCode::FAILURE;
81  }
82 
83  const RawEvent* re = m_rdpSvc->getEvent(Gaudi::Hive::currentContext());
84  if (!re) {
85  ATH_MSG_ERROR( "Could not get raw event from ByteStreamInputSvc" );
86  }
87  const std::string& key = *(pAddr->par()); // Get key used in the StoreGateSvc::retrieve function
88  // get gain and pass to convert function.
89  CaloGain::CaloGain gain=CaloGain::LARNGAIN; //At this place, LARNGAINS means Automatic gain.
90  if (key=="HIGH")
92  else if (key=="MEDIUM")
94  else if (key=="LOW")
96 
98 
99  // Convert the RawEvent to LArAccumulatedCalibDigitContainer
100  ATH_MSG_DEBUG( "Converting LArAccumulatedCalibDigits (from ByteStream). key=" << key << " ,gain=" << gain );
102  StatusCode sc=m_tool->convert(re,DigitContainer,gain,
103  **calibLineMapping);
104  if (sc!=StatusCode::SUCCESS) {
105  ATH_MSG_WARNING( "Conversion tool returned an error. LArAccumulatedCalibDigitContainer might be empty." );
106  }
107  DigitContainer->setDelayScale(25./240.); //FIXME should not be hardcoded!
108  pObj = SG::asStorable(DigitContainer) ;
109 
110  return StatusCode::SUCCESS;
111 }
112 
113 // IWS 19.07.2005
114  StatusCode
115  LArAccumulatedCalibDigitContByteStreamCnv::createRepConst(DataObject* /*pObj*/, IOpaqueAddress*& /*pAddr*/) const
116 {// convert LArAccumulatedCalibDigits from StoreGate into ByteStream
117  ATH_MSG_ERROR( "CreateRep method of LArAccumulatedCalibDigitContainer not implemented" );
118  return StatusCode::SUCCESS;
119 }
120 
LArAccumulatedCalibDigitContByteStreamCnv::m_calibLineMappingKey
SG::ReadCondHandleKey< LArCalibLineMapping > m_calibLineMappingKey
Definition: LArAccumulatedCalibDigitContByteStreamCnv.h:57
LArAccumulatedCalibDigitContainer::setDelayScale
void setDelayScale(const double scale)
set the delay Scale
Definition: LArAccumulatedCalibDigitContainer.h:35
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
LArAccumulatedCalibDigitContByteStreamCnv::classID
static const CLID & classID()
Definition: LArAccumulatedCalibDigitContByteStreamCnv.cxx:43
LArAccumulatedCalibDigitContByteStreamCnv::initialize
virtual StatusCode initialize() override
Definition: LArAccumulatedCalibDigitContByteStreamCnv.cxx:52
initialize
void initialize()
Definition: run_EoverP.cxx:894
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.
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
LArAccumulatedCalibDigitContByteStreamCnv::LArAccumulatedCalibDigitContByteStreamCnv
LArAccumulatedCalibDigitContByteStreamCnv(ISvcLocator *svcloc)
Definition: LArAccumulatedCalibDigitContByteStreamCnv.cxx:36
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
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
LArAccumulatedCalibDigitContByteStreamCnv::createRepConst
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Convert the transient object to the requested representation.
Definition: LArAccumulatedCalibDigitContByteStreamCnv.cxx:115
ByteStreamAddress
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Definition: ByteStreamAddress.h:28
LArAccumulatedCalibDigitContainer.h
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
LArAccumulatedCalibDigitContByteStreamCnv::~LArAccumulatedCalibDigitContByteStreamCnv
virtual ~LArAccumulatedCalibDigitContByteStreamCnv()
Definition: LArAccumulatedCalibDigitContByteStreamCnv.cxx:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
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
LArAccumulatedCalibDigitContByteStreamCnv::createObjConst
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
Definition: LArAccumulatedCalibDigitContByteStreamCnv.cxx:67
LArAccumulatedCalibDigitContByteStreamCnv.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
re
const boost::regex re(r_e)
ByteStreamCnvSvcBase.h
LArAccumulatedCalibDigitContByteStreamCnv::m_rdpSvc
ServiceHandle< IROBDataProviderSvc > m_rdpSvc
Definition: LArAccumulatedCalibDigitContByteStreamCnv.h:56
CaloGain::LARLOWGAIN
@ LARLOWGAIN
Definition: CaloGain.h:18
IByteStreamCnvSvc.h
CaloGain.h
LArCalibLineMapping.h
LArAccumulatedCalibDigitContainer
Container class for LArAccumulatedCalibDigit.
Definition: LArAccumulatedCalibDigitContainer.h:25
StoreGateSvc.h
CLASS_DEF.h
macros to associate a CLID to a type
IROBDataProviderSvc.h
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
LArAccumulatedCalibDigitContByteStreamCnv::m_tool
ToolHandle< BYTESTREAMTOOL > m_tool
Definition: LArAccumulatedCalibDigitContByteStreamCnv.h:55