Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
ByteStreamCnvSvc Class Reference

Gaudi Conversion Service class for ByteStream Persistency. More...

#include <ByteStreamCnvSvc.h>

Inheritance diagram for ByteStreamCnvSvc:
Collaboration diagram for ByteStreamCnvSvc:

Classes

struct  SlotData
 Slot-specific state. More...
 

Public Member Functions

 ByteStreamCnvSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor. More...
 
virtual ~ByteStreamCnvSvc ()
 Standard Destructor. More...
 
virtual StatusCode initialize () override
 Gaudi Service Interface method implementations: More...
 
virtual StatusCode finalize () override
 
virtual StatusCode connectOutput (const std::string &t, const std::string &mode) override
 Implements ConversionSvc's connectOutput. More...
 
virtual StatusCode connectOutput (const std::string &t) override
 
virtual StatusCode commitOutput (const std::string &outputConnection, bool b) override
 Implements ConversionSvc's commitOutput. More...
 
virtual RawEventWritegetRawEvent () override
 Implementation of IByteStreamEventAccess: Get RawEvent. More...
 

Protected Member Functions

RawEventWritesetRawEvent (std::unique_ptr< RawEventWrite > rawEventWrite)
 
virtual FullEventAssemblerBasefindFullEventAssembler (const std::string &name) const override
 Implementation of IByteStreamCnvSvc interface. More...
 
virtual StatusCode storeFullEventAssembler (std::unique_ptr< FullEventAssemblerBase > fea, const std::string &name) override
 

Private Member Functions

void writeFEA (SlotData &slot)
 Write the FEA to RawEvent. More...
 

Private Attributes

std::string m_ioSvcName
 name of the service More...
 
Gaudi::Property< std::vector< std::string > > m_ioSvcNameList { this, "ByteStreamOutputSvcList", {}, "", "OrderedSet<T>"}
 list of service names More...
 
Gaudi::Property< bool > m_fillTriggerBits {this, "FillTriggerBits", true, "Read in xTrigDecision and use it to fill Trigger bits in event header"}
 fill trigger bits More...
 
std::map< std::string, IByteStreamOutputSvc * > m_ioSvcMap
 Services for writing output. More...
 
ServiceHandle< StoreGateSvcm_evtStore
 Event store. More...
 
std::string m_userType
 user type More...
 
SG::SlotSpecificObj< SlotDatam_slots
 

Detailed Description

Gaudi Conversion Service class for ByteStream Persistency.

This class is responsible for converting data object to and from BS format It inherits from ByteStreamCnvSvcBase, which is used by HLT in online.

When reading the ByteStream data, the ByteStream converters are called, which in turn call IRODDataProviderSvc to retrieve the raw data.

When writing the object data to ByteStream, an FullEventFragment is assembled from lower level fragments using FullEventAssembler, and written out to BS in commitOutput method through IByteStreamOutputSvc.

Definition at line 36 of file ByteStreamCnvSvc.h.

Constructor & Destructor Documentation

◆ ByteStreamCnvSvc()

ByteStreamCnvSvc::ByteStreamCnvSvc ( const std::string &  name,
ISvcLocator *  svc 
)

Standard Constructor.

Standard constructor.

Definition at line 34 of file ByteStreamCnvSvc.cxx.

35  : base_class(name, pSvcLocator),
36  m_evtStore ("StoreGateSvc", name)
37 {
38  declareProperty("ByteStreamOutputSvc", m_ioSvcName);
39  declareProperty("UserType", m_userType = "RawEvent");
40  declareProperty("EventStore", m_evtStore);
41 }

◆ ~ByteStreamCnvSvc()

ByteStreamCnvSvc::~ByteStreamCnvSvc ( )
virtual

Standard Destructor.

Definition at line 44 of file ByteStreamCnvSvc.cxx.

44  {
45 }

Member Function Documentation

◆ commitOutput()

StatusCode ByteStreamCnvSvc::commitOutput ( const std::string &  outputConnection,
bool  b 
)
overridevirtual

Implements ConversionSvc's commitOutput.

Definition at line 194 of file ByteStreamCnvSvc.cxx.

194  {
195  ATH_MSG_DEBUG("In flushOutput " << outputConnection);
196 
197  const EventContext& ctx = Gaudi::Hive::currentContext();
198  SlotData& slot = *m_slots.get(ctx);
199 
200  if (m_ioSvcMap.size() == 0) {
201  ATH_MSG_ERROR("ByteStreamCnvSvc not configure for output");
202  return(StatusCode::FAILURE);
203  }
204 
205  writeFEA (slot);
206 
207  // convert RawEventWrite to RawEvent
208  RawEventWrite* re = slot.m_rawEventWrite.get();
209  uint32_t rawSize = re->size_word();
210  std::vector<uint32_t> buffer (rawSize);
211  uint32_t count = eformat::write::copy(*(re->bind()), buffer.data(), rawSize);
212  if (count != rawSize) {
213  ATH_MSG_ERROR("Memcopy failed");
214  return(StatusCode::FAILURE);
215  }
216  RawEvent rawEvent(buffer.data());
217  // check validity
218  try {
219  rawEvent.check_tree();
220  } catch (...) {
221  ATH_MSG_ERROR("commitOutput failed, because FullEventFragment invalid");
222  return(StatusCode::FAILURE);
223  }
224  ATH_MSG_DEBUG("commitOutput: Size of Event (words) = " << rawEvent.fragment_size_word());
225  // put event to OutputSvc
226  if ((m_ioSvcMap.size() == 1) or (m_ioSvcMap.count(outputConnection) > 0)) {
228  // for backward compatibility
229  if (itSvc == m_ioSvcMap.end()) {
230  itSvc = m_ioSvcMap.begin();
231  }
232  // put
233  if (!itSvc->second->putEvent(&rawEvent)) {
234  ATH_MSG_ERROR("commitOutput failed to send output");
235  return(StatusCode::FAILURE);
236  }
237  }
238  // Clear slot-specific data.
239  slot.clear();
240  return(StatusCode::SUCCESS);
241 }

◆ connectOutput() [1/2]

StatusCode ByteStreamCnvSvc::connectOutput ( const std::string &  t)
overridevirtual

Definition at line 108 of file ByteStreamCnvSvc.cxx.

108  {
109  ATH_MSG_DEBUG("In connectOutput");
110 
111  const EventContext& ctx = Gaudi::Hive::currentContext();
112  SlotData& slot = *m_slots.get(ctx);
113 
114  // Get the EventInfo obj for run/event number
115  const xAOD::EventInfo* evtInfo{nullptr};
116  ATH_CHECK( m_evtStore->retrieve(evtInfo) );
117  uint64_t event = evtInfo->eventNumber();
118  uint32_t run_no = evtInfo->runNumber();
119  uint32_t bc_time_sec = evtInfo->timeStamp();
120  uint32_t bc_time_ns = evtInfo->timeStampNSOffset();
121  uint32_t run_type = 0;
122  uint32_t lvl1_id = evtInfo->extendedLevel1ID();
123  if (lvl1_id == 0) {
124  lvl1_id = event;
125  }
126  uint8_t lvl1_type = evtInfo->level1TriggerType();
127  uint64_t global_id = event;
128  uint16_t lumi_block = evtInfo->lumiBlock();
129  uint16_t bc_id = evtInfo->bcid();
130  uint8_t nevt = 0;
131  // create an empty RawEvent
132  eformat::helper::SourceIdentifier sid = eformat::helper::SourceIdentifier(eformat::FULL_SD_EVENT, nevt);
133  RawEventWrite* re = setRawEvent (std::make_unique<RawEventWrite>(sid.code(), bc_time_sec, bc_time_ns, global_id, run_type, run_no, lumi_block, lvl1_id, bc_id, lvl1_type));
134 
135  // set stream tags
136  std::vector<eformat::helper::StreamTag> on_streamTags;
137  for (const auto& sTag : evtInfo->streamTags()) {
138  on_streamTags.emplace_back(sTag.name(), sTag.type(), sTag.obeysLumiblock(), sTag.robs(), detsOnline(sTag.dets()));
139  }
140  uint32_t nStreamTagWords = eformat::helper::size_word(on_streamTags);
141  slot.m_tagBuff.resize (nStreamTagWords);
142  eformat::helper::encode(on_streamTags, nStreamTagWords, slot.m_tagBuff.data());
143  re->stream_tag(nStreamTagWords, slot.m_tagBuff.data());
144 
145  // Nothing left to do, unless processing trigger bits
146  if (!m_fillTriggerBits.value()) {
147  return StatusCode::SUCCESS;
148  }
149 
150  // try to get TrigDecision
151  const xAOD::TrigDecision *trigDecision{nullptr};
152  if (m_evtStore->retrieve(trigDecision, "xTrigDecision") != StatusCode::SUCCESS) {
153  ATH_MSG_WARNING("Property " << m_fillTriggerBits.name() << " set to True but failed to retrieve xAOD::TrigDecision. Leaving empty trigger bits in the event header.");
154  return StatusCode::SUCCESS;
155  }
156 
157  // LVL1 info
158  const std::vector<uint32_t> &tbp = trigDecision->tbp();
159  const std::vector<uint32_t> &tap = trigDecision->tap();
160  const std::vector<uint32_t> &tav = trigDecision->tav();
161  const size_t l1TotSize = tbp.size() + tap.size() + tav.size();
162  if (l1TotSize > 0) {
163  slot.m_l1Buff.resize (l1TotSize);
164  size_t l1Size{0};
165  for (const uint32_t tb : tbp) {
166  slot.m_l1Buff[l1Size++] = tb;
167  }
168  for (const uint32_t tb : tap) {
169  slot.m_l1Buff[l1Size++] = tb;
170  }
171  for (const uint32_t tb : tav) {
172  slot.m_l1Buff[l1Size++] = tb;
173  }
174  re->lvl1_trigger_info(l1TotSize, slot.m_l1Buff.data());
175  }
176 
177  // LVL2 info
178  const std::vector<uint32_t>& lvl2PP = trigDecision->lvl2PassedPhysics();
179  if (lvl2PP.size() > 0) {
180  slot.m_l2Buff = lvl2PP;
181  re->lvl2_trigger_info(lvl2PP.size(), slot.m_l2Buff.data());
182  }
183 
184  // EF info
185  const std::vector<uint32_t>& efPP = trigDecision->efPassedPhysics();
186  if (efPP.size() > 0) {
187  slot.m_efBuff = efPP;
188  re->event_filter_info(efPP.size(), slot.m_efBuff.data());
189  }
190 
191  return(StatusCode::SUCCESS);
192 }

◆ connectOutput() [2/2]

StatusCode ByteStreamCnvSvc::connectOutput ( const std::string &  t,
const std::string &  mode 
)
overridevirtual

Implements ConversionSvc's connectOutput.

Definition at line 104 of file ByteStreamCnvSvc.cxx.

104  {
105  return(connectOutput(t));
106 }

◆ finalize()

StatusCode ByteStreamCnvSvc::finalize ( )
overridevirtual

Definition at line 100 of file ByteStreamCnvSvc.cxx.

100  {
102 }

◆ findFullEventAssembler()

FullEventAssemblerBase * ByteStreamCnvSvc::findFullEventAssembler ( const std::string &  name) const
overrideprotectedvirtual

Implementation of IByteStreamCnvSvc interface.

Definition at line 47 of file ByteStreamCnvSvc.cxx.

48 {
49  const EventContext& ctx = Gaudi::Hive::currentContext();
50  const auto& feaMap = m_slots.get(ctx)->m_feaMap;
51  const auto& fea = feaMap.find(name);
52  return fea!=feaMap.end() ? fea->second.get() : nullptr;
53 }

◆ getRawEvent()

virtual RawEventWrite* ByteStreamCnvSvc::getRawEvent ( )
inlineoverridevirtual

Implementation of IByteStreamEventAccess: Get RawEvent.

Definition at line 57 of file ByteStreamCnvSvc.h.

58  {
59  return m_slots->m_rawEventWrite.get();
60  }

◆ initialize()

StatusCode ByteStreamCnvSvc::initialize ( )
overridevirtual

Gaudi Service Interface method implementations:

Initialize the service.

Definition at line 63 of file ByteStreamCnvSvc.cxx.

63  {
64  if (!ByteStreamCnvSvcBase::initialize().isSuccess()) {
65  ATH_MSG_FATAL("ByteStreamCnvSvcBase::initialize() failed");
66  return(StatusCode::FAILURE);
67  }
68 
69  ATH_CHECK( m_evtStore.retrieve() );
70 
71  // get ready for output
72  std::vector<std::string> ioSvcNames = m_ioSvcNameList.value();
73  if (!m_ioSvcName.empty()) {
74  // add ioSvcName if ioSvcNameList is missing it
75  std::vector<std::string>::iterator it = find(ioSvcNames.begin(), ioSvcNames.end(), m_ioSvcName);
76  if (it == ioSvcNames.end()) {
77  ioSvcNames.push_back(m_ioSvcName);
78  }
79  }
80  if (!ioSvcNames.empty()) {
81  // Check ByteStreamCnvSvc
82  for (const std::string& svcName : ioSvcNames) {
83  ATH_MSG_DEBUG("Retrieving " << svcName);
84  // get service
85  SmartIF<IByteStreamOutputSvc> ioSvc{service(svcName)};
86  ATH_CHECK( ioSvc.isValid() );
87 
88  // get stream name
89  std::string bsOutputStreamName;
90  SimpleProperty<std::string> propBSO("BSOutputStreamName", bsOutputStreamName);
91  ATH_CHECK(ioSvc.as<IProperty>()->getProperty(&propBSO));
92  bsOutputStreamName = propBSO.value();
93  // append
94  m_ioSvcMap[bsOutputStreamName] = ioSvc;
95  }
96  }
97  return(StatusCode::SUCCESS);
98 }

◆ setRawEvent()

RawEventWrite * ByteStreamCnvSvc::setRawEvent ( std::unique_ptr< RawEventWrite rawEventWrite)
protected

Definition at line 255 of file ByteStreamCnvSvc.cxx.

256 {
257  RawEventWrite* ptr = rawEventWrite.get();
258  m_slots->m_rawEventWrite = std::move (rawEventWrite);
259  // cppcheck-suppress returnDanglingLifetime
260  return ptr;
261 }

◆ storeFullEventAssembler()

StatusCode ByteStreamCnvSvc::storeFullEventAssembler ( std::unique_ptr< FullEventAssemblerBase fea,
const std::string &  name 
)
overrideprotectedvirtual

Definition at line 55 of file ByteStreamCnvSvc.cxx.

56 {
57  const EventContext& ctx = Gaudi::Hive::currentContext();
58  m_slots.get(ctx)->m_feaMap[name] = std::move(fea);
59  return StatusCode::SUCCESS;
60 }

◆ writeFEA()

void ByteStreamCnvSvc::writeFEA ( SlotData slot)
private

Write the FEA to RawEvent.

Definition at line 243 of file ByteStreamCnvSvc.cxx.

244 {
245  const auto& feaMap = slot.m_feaMap;
246  ATH_MSG_DEBUG("before FEAMAP size = " << feaMap.size());
247  for (auto& p : feaMap) {
248  MsgStream log(msgSvc(), name());
249  p.second->fill(slot.m_rawEventWrite.get(), log);
250  }
251  ATH_MSG_DEBUG("after FEAMAP size = " << feaMap.size());
252 }

Member Data Documentation

◆ m_evtStore

ServiceHandle<StoreGateSvc> ByteStreamCnvSvc::m_evtStore
private

Event store.

Definition at line 83 of file ByteStreamCnvSvc.h.

◆ m_fillTriggerBits

Gaudi::Property<bool> ByteStreamCnvSvc::m_fillTriggerBits {this, "FillTriggerBits", true, "Read in xTrigDecision and use it to fill Trigger bits in event header"}
private

fill trigger bits

Definition at line 77 of file ByteStreamCnvSvc.h.

◆ m_ioSvcMap

std::map<std::string, IByteStreamOutputSvc*> ByteStreamCnvSvc::m_ioSvcMap
private

Services for writing output.

Definition at line 80 of file ByteStreamCnvSvc.h.

◆ m_ioSvcName

std::string ByteStreamCnvSvc::m_ioSvcName
private

name of the service

Definition at line 71 of file ByteStreamCnvSvc.h.

◆ m_ioSvcNameList

Gaudi::Property<std::vector<std::string> > ByteStreamCnvSvc::m_ioSvcNameList { this, "ByteStreamOutputSvcList", {}, "", "OrderedSet<T>"}
private

list of service names

Definition at line 74 of file ByteStreamCnvSvc.h.

◆ m_slots

SG::SlotSpecificObj<SlotData> ByteStreamCnvSvc::m_slots
private

Definition at line 108 of file ByteStreamCnvSvc.h.

◆ m_userType

std::string ByteStreamCnvSvc::m_userType
private

user type

Definition at line 86 of file ByteStreamCnvSvc.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
RawEventWrite
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
Definition: RawEvent.h:39
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
RawEvent
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition: RawEvent.h:37
skel.it
it
Definition: skel.GENtoEVGEN.py:407
ByteStreamCnvSvc::m_evtStore
ServiceHandle< StoreGateSvc > m_evtStore
Event store.
Definition: ByteStreamCnvSvc.h:83
ByteStreamCnvSvc::m_slots
SG::SlotSpecificObj< SlotData > m_slots
Definition: ByteStreamCnvSvc.h:108
RunTileTBRec.run_type
run_type
Definition: RunTileTBRec.py:65
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
xAOD::tap
setBGCode tap
Definition: TrigDecision_v1.cxx:43
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
ByteStreamCnvSvc::m_ioSvcName
std::string m_ioSvcName
name of the service
Definition: ByteStreamCnvSvc.h:71
Execution.tb
tb
Definition: Execution.py:15
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
AtlasMcWeight::encode
number_type encode(double weight)
Definition: AtlasMcWeight.cxx:65
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ByteStreamCnvSvc::m_userType
std::string m_userType
user type
Definition: ByteStreamCnvSvc.h:86
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
ActsGeantFollowing_jobOptions_ITk.svcName
svcName
Definition: ActsGeantFollowing_jobOptions_ITk.py:196
ByteStreamCnvSvc::writeFEA
void writeFEA(SlotData &slot)
Write the FEA to RawEvent.
Definition: ByteStreamCnvSvc.cxx:243
ByteStreamCnvSvc::m_fillTriggerBits
Gaudi::Property< bool > m_fillTriggerBits
fill trigger bits
Definition: ByteStreamCnvSvc.h:77
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
re
const boost::regex re(r_e)
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
calibdata.copy
bool copy
Definition: calibdata.py:27
ByteStreamCnvSvc::setRawEvent
RawEventWrite * setRawEvent(std::unique_ptr< RawEventWrite > rawEventWrite)
Definition: ByteStreamCnvSvc.cxx:255
ByteStreamCnvSvc::connectOutput
virtual StatusCode connectOutput(const std::string &t, const std::string &mode) override
Implements ConversionSvc's connectOutput.
Definition: ByteStreamCnvSvc.cxx:104
ByteStreamCnvSvc::m_ioSvcNameList
Gaudi::Property< std::vector< std::string > > m_ioSvcNameList
list of service names
Definition: ByteStreamCnvSvc.h:74
ByteStreamCnvSvc::m_ioSvcMap
std::map< std::string, IByteStreamOutputSvc * > m_ioSvcMap
Services for writing output.
Definition: ByteStreamCnvSvc.h:80
xAOD::TrigDecision_v1
Interface to the raw trigger decision information of the event.
Definition: TrigDecision_v1.h:44
ByteStreamCnvSvcBase::initialize
virtual StatusCode initialize() override
Required of all Gaudi Services.
Definition: ByteStreamCnvSvcBase.cxx:27