ATLAS Offline Software
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 
18 #include "ByteStreamData/RawEvent.h"
19 
21 
23 #include "AthenaKernel/CLASS_DEF.h"
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 
41 }
42 
45 }
46 
47 
50 {
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 
66 LArDigitContByteStreamCnv::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 
137 StatusCode
138 LArDigitContByteStreamCnv::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 }
LArDigitContByteStreamCnv::classID
static const CLID & classID()
Definition: LArDigitContByteStreamCnv.cxx:43
LArDigitContByteStreamCnv.h
LArDigitContByteStreamCnv::~LArDigitContByteStreamCnv
virtual ~LArDigitContByteStreamCnv()
Definition: LArDigitContByteStreamCnv.cxx:40
LArDigitContByteStreamCnv::m_byteStreamCnvSvc
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
Definition: LArDigitContByteStreamCnv.h:57
LATOMEMapping.h
Tool to get LATOME SC and SCID mapping file and fill std::map variable with it.
LArDigitContByteStreamCnv::m_tool
ToolHandle< BYTESTREAMTOOL > m_tool
Definition: LArDigitContByteStreamCnv.h:54
FullEventAssembler
Template class for assembling a full atlas raw event from subfragments.
Definition: FullEventAssembler.h:40
LArDigitContByteStreamCnv::LArDigitContByteStreamCnv
LArDigitContByteStreamCnv(ISvcLocator *svcloc)
Definition: LArDigitContByteStreamCnv.cxx:32
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
LArRawSCContainer
Container class for LArRawSC.
Definition: LArRawSCContainer.h:17
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.
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
LArDigitContByteStreamCnv::initialize
virtual StatusCode initialize() override
Definition: LArDigitContByteStreamCnv.cxx:49
LArLATOMEHeaderContainer
Container class for LArLATOMEHeader.
Definition: LArLATOMEHeaderContainer.h:19
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
LArLATOMEROBIDs.h
python.LArBadChannel2Ascii.isSC
isSC
Definition: LArBadChannel2Ascii.py:94
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
Mon.h
Tool to store LATOME mon header and footer data.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArDigitContByteStreamCnv::createObjConst
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
Definition: LArDigitContByteStreamCnv.cxx:66
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
LArDigitContByteStreamCnv::createRepConst
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Convert the transient object to the requested representation.
Definition: LArDigitContByteStreamCnv.cxx:138
ByteStreamAddress.h
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
LArDigitContByteStreamCnv::m_scTool
ToolHandle< LArLATOMEDecoder > m_scTool
Definition: LArDigitContByteStreamCnv.h:55
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
LArDigitContainer.h
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
LArDigitContByteStreamCnv::m_rdpSvc
ServiceHandle< IROBDataProviderSvc > m_rdpSvc
Definition: LArDigitContByteStreamCnv.h:56
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)
LArDigitContainer
Container class for LArDigit.
Definition: LArDigitContainer.h:24
ByteStreamCnvSvcBase.h
LArLATOMEDecoder.h
Byte stream converter of LATOME.
CaloGain::LARLOWGAIN
@ LARLOWGAIN
Definition: CaloGain.h:18
IByteStreamCnvSvc.h
CaloGain.h
CLASS_DEF.h
macros to associate a CLID to a type
IROBDataProviderSvc.h
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37