ATLAS Offline Software
CmxCpHitsByteStreamAuxCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // ============================================================================
6 // Includes
7 // ============================================================================
8 // STD
9 // ============================================================================
10 #include <vector>
11 #include <cstdint>
12 #include <memory>
13 #include <algorithm>
14 // ============================================================================
15 // Athena
16 // ============================================================================
20 
22 #include "ByteStreamData/ROBData.h"
23 
25 #include "GaudiKernel/DataObject.h"
26 #include "GaudiKernel/IOpaqueAddress.h"
27 #include "GaudiKernel/IRegistry.h"
28 #include "GaudiKernel/ISvcLocator.h"
29 #include "GaudiKernel/StatusCode.h"
30 
33 #include "StoreGate/StoreGateSvc.h"
34 
35 // ============================================================================
36 // TrigT1
37 // ============================================================================
39 // ============================================================================
40 // xAOD
41 // ============================================================================
45 // ============================================================================
46 // Local
47 // ============================================================================
49 #include "../CpByteStreamV2Tool.h"
50 #include "../ToString.h"
51 // ============================================================================
52 
53 namespace LVL1BS {
55  Converter(storageType(), classID(), svcloc),
56  AthMessaging(svcloc != 0 ? msgSvc() : 0, "CmxCpHitsByteStreamAuxCnv"),
57  m_name("CmxCpHitsByteStreamAuxCnv"),
58  m_readTool("LVL1BS::CpByteStreamV2Tool/CpByteStreamV2Tool")
59 {
60 }
61 
64 }
65 
67 {
69 }
70 
71 // Init method gets all necessary services etc.
72 
74  ATH_MSG_DEBUG("Initializing " << m_name);
75 
77  CHECK(m_readTool.retrieve());
78 
79  return StatusCode::SUCCESS;
80 }
81 
82 // createObj should create the RDO from bytestream.
84  DataObject*& pObj) {
85  ATH_MSG_DEBUG("createObj() called");
86  // -------------------------------------------------------------------------
87  ByteStreamAddress *pBS_Addr = dynamic_cast<ByteStreamAddress *>(pAddr);
88  CHECK(pBS_Addr != nullptr);
89  // -------------------------------------------------------------------------
90  const std::string nm = *(pBS_Addr->par());
91  ATH_MSG_DEBUG("Creating Objects " << nm);
92 
93  auto aux = new xAOD::CMXCPHitsAuxContainer;
94  xAOD::CMXCPHitsContainer cmxCpHitsContainer;
95  cmxCpHitsContainer.setStore(aux);
96  // -------------------------------------------------------------------------
97  DataVector<LVL1::CMXCPHits> cmxCpHitsVector;
98  StatusCode sc = m_readTool->convert(nm, &cmxCpHitsVector);
99  if (sc.isFailure()) {
100  ATH_MSG_ERROR("Failed to create objects");
101  delete aux;
102  return sc;
103  }
104 
105  for (auto ch : cmxCpHitsVector) {
107  cmxCpHitsContainer.push_back(item);
108  std::vector<uint32_t> hitsVec0(ch->hitsVec0().begin(), ch->hitsVec0().end());
109  std::vector<uint32_t> hitsVec1(ch->hitsVec1().begin(), ch->hitsVec1().end());
110  std::vector<uint32_t> errorVec0(ch->errorVec0().begin(), ch->errorVec0().end());
111  std::vector<uint32_t> errorVec1(ch->errorVec1().begin(), ch->errorVec1().end());
112 
113  item->initialize(ch->crate(), ch->cmx(), ch->source(),
114  hitsVec0, hitsVec1, errorVec0, errorVec1, ch->peak());
115  }
116 
117  // -------------------------------------------------------------------------
118  //ATH_MSG_VERBOSE(ToString(cpmCollection));
119  ATH_MSG_DEBUG("Number of readed CMXCPHits: " << aux->size());
120  // -------------------------------------------------------------------------
121  pObj = SG::asStorable(aux);
122  return StatusCode::SUCCESS;
123 }
124 
125 // createRep should create the bytestream from RDOs.
127  IOpaqueAddress*& /*pAddr*/) {
128  return StatusCode::FAILURE;
129 }
130 
131 } // end namespace
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
CMXCPHits.h
StorableConversions.h
convert to and from a SG storable
LVL1BS::CmxCpHitsByteStreamAuxCnv::m_name
std::string m_name
Converter name.
Definition: CmxCpHitsByteStreamAuxCnv.h:57
ROBData.h
Defines the ROB data entity. The ROB data is an abstract entity that is used to discase the raw event...
initialize
void initialize()
Definition: run_EoverP.cxx:894
LVL1BS::CmxCpHitsByteStreamAuxCnv::initialize
virtual StatusCode initialize()
Definition: CmxCpHitsByteStreamAuxCnv.cxx:73
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
IByteStreamEventAccess.h
LVL1BS::CmxCpHitsByteStreamAuxCnv::CmxCpHitsByteStreamAuxCnv
CmxCpHitsByteStreamAuxCnv(ISvcLocator *svcloc)
Definition: CmxCpHitsByteStreamAuxCnv.cxx:54
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
xAOD::CMXCPHits
CMXCPHits_v1 CMXCPHits
Define the latest version of the CMMCPHits class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/CMXCPHits.h:17
CMXCPHitsContainer.h
LVL1BS::CmxCpHitsByteStreamAuxCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Create TriggerTowers from ByteStream.
Definition: CmxCpHitsByteStreamAuxCnv.cxx:83
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
LVL1BS::CmxCpHitsByteStreamAuxCnv::storageType
static long storageType()
Definition: CmxCpHitsByteStreamAuxCnv.cxx:66
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LVL1BS::CmxCpHitsByteStreamAuxCnv::classID
static const CLID & classID()
Definition: CmxCpHitsByteStreamAuxCnv.cxx:62
xAOD::CMXCPHitsAuxContainer
CMXCPHitsAuxContainer_v1 CMXCPHitsAuxContainer
Define the latest version of the CMMCPHits class.
Definition: CMXCPHitsAuxContainer.h:17
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
LVL1BS::CmxCpHitsByteStreamAuxCnv::createRep
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
Create ByteStream from TriggerTowers.
Definition: CmxCpHitsByteStreamAuxCnv.cxx:126
ClassID_traits.h
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
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
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
ByteStreamAddress.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
CMXCPHitsAuxContainer.h
CmxCpHitsByteStreamAuxCnv.h
ByteStreamAddress::storageType
static constexpr long storageType()
Definition: ByteStreamAddress.h:51
Converter
Definition: Converter.h:27
errorcheck.h
Helpers for checking error return status codes and reporting errors.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
item
Definition: ItemListSvc.h:43
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
LVL1BS
Definition: ZdcByteStreamReadV1V2Tool.h:47
CMXCPHits.h
xAOD::CMXCPHits_v1
Description of CMXCPHits_v1.
Definition: CMXCPHits_v1.h:27
StoreGateSvc.h
LVL1BS::CmxCpHitsByteStreamAuxCnv::m_readTool
ToolHandle< CpByteStreamV2Tool > m_readTool
Do the main job - retrieve xAOD TriggerTowers from robs.
Definition: CmxCpHitsByteStreamAuxCnv.h:60
IROBDataProviderSvc.h