ATLAS Offline Software
Loading...
Searching...
No Matches
LArAccumulatedCalibDigitContByteStreamCnv.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
9
15
16#include "GaudiKernel/MsgStream.h"
17#include "GaudiKernel/StatusCode.h"
18#include "GaudiKernel/DataObject.h"
19#include "GaudiKernel/IRegistry.h"
20
23
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
46
49
50
51StatusCode
53{
54 ATH_CHECK( AthConstConverter::initialize() );
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() );
61 ATH_CHECK( m_calibLineMappingKey.initialize() );
62
63 return StatusCode::SUCCESS;
64}
65
66StatusCode
67LArAccumulatedCalibDigitContByteStreamCnv::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 if (not *calibLineMapping){
103 delete DigitContainer;
104 ATH_MSG_ERROR("LArAccumulatedCalibDigitContByteStreamCnv::createObjConst: nullptr.");
105 return StatusCode::FAILURE;
106 }
107 StatusCode sc=m_tool->convert(re,DigitContainer,gain,
108 **calibLineMapping);
109 if (sc!=StatusCode::SUCCESS) {
110 ATH_MSG_WARNING( "Conversion tool returned an error. LArAccumulatedCalibDigitContainer might be empty." );
111 }
112 DigitContainer->setDelayScale(25./240.); //FIXME should not be hardcoded!
113 pObj = SG::asStorable(DigitContainer) ;
114
115 return StatusCode::SUCCESS;
116}
117
118// IWS 19.07.2005
119 StatusCode
120 LArAccumulatedCalibDigitContByteStreamCnv::createRepConst(DataObject* /*pObj*/, IOpaqueAddress*& /*pAddr*/) const
121{// convert LArAccumulatedCalibDigits from StoreGate into ByteStream
122 ATH_MSG_ERROR( "CreateRep method of LArAccumulatedCalibDigitContainer not implemented" );
123 return StatusCode::SUCCESS;
124}
125
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)
macros to associate a CLID to a type
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
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.
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Convert the transient object to the requested representation.
SG::ReadCondHandleKey< LArCalibLineMapping > m_calibLineMappingKey
Container class for LArAccumulatedCalibDigit.
void setDelayScale(const double scale)
set the delay Scale
@ LARMEDIUMGAIN
Definition CaloGain.h:18
@ LARLOWGAIN
Definition CaloGain.h:18
@ LARNGAIN
Definition CaloGain.h:19
@ LARHIGHGAIN
Definition CaloGain.h:18
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)