ATLAS Offline Software
Loading...
Searching...
No Matches
LArDigitContByteStreamCnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
9#include "LArByteStream/Mon.h"
10
11
13
19
21
24// For LATOME while no Condition alg exists
25#include "LArLATOMEROBIDs.h"
26
27//STL-Stuff
28#include <map>
29#include <iostream>
30
31
33 AthConstConverter(storageType(), classID(),svcloc,"LArDigitContByteStreamCnv"),
34 m_tool("LArRawDataContByteStreamTool"),
35 m_scTool("LArLATOMEDecoder"),
36 m_rdpSvc("ROBDataProviderSvc", name()),
37 m_byteStreamCnvSvc("ByteStreamCnvSvc", name())
38{}
39
42
46
47
48StatusCode
50{
51 ATH_CHECK( AthConstConverter::initialize() );
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_byteStreamCnvSvc.retrieve() );
58
59 ATH_CHECK( m_tool.retrieve() );
60 ATH_CHECK( m_scTool.retrieve() );
61
62 return StatusCode::SUCCESS;
63}
64
65StatusCode
66LArDigitContByteStreamCnv::createObjConst(IOpaqueAddress* pAddr, DataObject*& pObj) const
67{//Convert Digits from ByteStream to StoreGate
68 ATH_MSG_VERBOSE( "Executing CreateObj method for LArDigitContainer " );
69
70 if (!m_rdpSvc) {
71 ATH_MSG_ERROR( " ROBDataProviderSvc not loaded. Can't read ByteStream." );
72 return StatusCode::FAILURE;
73 }
74 ByteStreamAddress *pRE_Addr;
75 pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr); //Cast from OpaqueAddress to ByteStreamAddress
76 if (!pRE_Addr) {
77 ATH_MSG_ERROR( "dynamic_cast of OpaqueAdress to ByteStreamAddress failed!" );
78 return StatusCode::FAILURE;
79 }
80
81 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags;
82 m_rdpSvc->getROBData(Gaudi::Hive::currentContext(), LArByteStream::s_allROBIDs_LATOME, robFrags );
83 const RawEvent* re = m_rdpSvc->getEvent(Gaudi::Hive::currentContext());
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 bool isSC=false;
88 LArDigitContainer* adc_coll=0;
89 LArDigitContainer* adc_bas_coll=0;
90 LArRawSCContainer* et_coll=0;
91 LArRawSCContainer* et_id_coll=0;
92 LArLATOMEHeaderContainer* header_coll=0;
93
94 if (key=="HIGH")
96 else if (key=="MEDIUM")
98 else if (key=="LOW")
100 else if (key=="SC"){
101 isSC=true;
102 adc_coll=new LArDigitContainer();
103 }
104 else if(key=="SC_ADC_BAS"){
105 isSC=true;
106 adc_bas_coll=new LArDigitContainer();
107 }
108
109 // Convert the RawEvent to LArDigitContainer
110 ATH_MSG_DEBUG( "Converting LArDigits (from ByteStream). key=" << key << " ,gain=" << gain );
111 StatusCode sc;
112 if (!isSC) {//Regular readout
113 LArDigitContainer *DigitContainer=new LArDigitContainer;
114 sc=m_tool->convert(re,DigitContainer,gain);
115 if (sc!=StatusCode::SUCCESS)
116 ATH_MSG_WARNING( "Conversion tool returned an error. LArDigitContainer might be empty." );
117 pObj = SG::asStorable(DigitContainer) ;
118 return StatusCode::SUCCESS;
119 }
120
121 //Supercell readout
122 sc=m_scTool->convert(robFrags,nullptr,adc_coll, adc_bas_coll, et_coll, et_id_coll, header_coll);
123 if (sc!=StatusCode::SUCCESS)
124 ATH_MSG_WARNING( "Conversion tool returned an error. LAr SC containers might be empty." );
125
126 if (key=="SC"){
127 pObj = SG::asStorable(adc_coll);
128 }
129 else if(key=="SC_ADC_BAS"){
130 pObj = SG::asStorable(adc_bas_coll);
131 }
132
133 return StatusCode::SUCCESS;
134
135}
136
137StatusCode
138LArDigitContByteStreamCnv::createRepConst(DataObject* pObj, IOpaqueAddress*& pAddr) const
139{// convert LArDigits from StoreGate into ByteStream
140 ATH_MSG_VERBOSE( "Execute CreateRep method of LArDigitContainer " );
141
142 // Get Full Event Assembler
144 ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler(fea,"LAr") );
145
146 LArDigitContainer* DigitContainer=0;
147 if (!SG::fromStorable (pObj, DigitContainer) || !DigitContainer) {
148 ATH_MSG_ERROR( "Cannot get LArDigitContainer for DataObject. Key=" << pObj->registry()->name() );
149 return StatusCode::FAILURE;
150 }
151
152 std::string nm = pObj->registry()->name();
153 pAddr = new ByteStreamAddress(classID(),nm,"");
154
155 ATH_CHECK( m_tool->WriteLArDigits(DigitContainer, *fea) );
156 return StatusCode::SUCCESS;
157}
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.
Tool to get LATOME SC and SCID mapping file and fill std::map variable with it.
Byte stream converter of LATOME.
static Double_t sc
Helper tool for conversion of raw data classes to/from LArByteStream.
Tool to store LATOME mon header and footer data.
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 createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
virtual StatusCode initialize() override
ToolHandle< LArLATOMEDecoder > m_scTool
ServiceHandle< IROBDataProviderSvc > m_rdpSvc
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Convert the transient object to the requested representation.
ToolHandle< BYTESTREAMTOOL > m_tool
LArDigitContByteStreamCnv(ISvcLocator *svcloc)
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
Container class for LArDigit.
Container class for LArLATOMEHeader.
Container class for LArRawSC.
@ LARMEDIUMGAIN
Definition CaloGain.h:18
@ LARLOWGAIN
Definition CaloGain.h:18
@ LARNGAIN
Definition CaloGain.h:19
@ LARHIGHGAIN
Definition CaloGain.h:18
static const std::vector< uint32_t > s_allROBIDs_LATOME
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)