14#include "eformat/SourceIdentifier.h"
15#include "eformat/StreamTag.h"
17#include "GaudiKernel/IClassIDSvc.h"
25 std::set<eformat::SubDetector> detsOnline(
const std::set<uint32_t>& detsOffline) {
26 std::set<eformat::SubDetector>
out;
27 for (
const uint32_t detid : detsOffline)
28 out.insert(
static_cast<eformat::SubDetector
>(detid));
35 : base_class(name, pSvcLocator)
41 const EventContext& ctx = Gaudi::Hive::currentContext();
42 const auto& feaMap =
m_slots.get(ctx)->m_feaMap;
43 const auto& fea = feaMap.find(name);
44 return fea!=feaMap.end() ? fea->second.get() :
nullptr;
49 const EventContext& ctx = Gaudi::Hive::currentContext();
50 m_slots.get(ctx)->m_feaMap[name] = std::move(fea);
51 return StatusCode::SUCCESS;
65 if (it == ioSvcNames.end()) {
69 if (!ioSvcNames.empty()) {
71 for (
const std::string& svcName : ioSvcNames) {
74 SmartIF<IByteStreamOutputSvc> ioSvc{service(svcName)};
78 std::string bsOutputStreamName;
79 SimpleProperty<std::string> propBSO(
"BSOutputStreamName", bsOutputStreamName);
80 ATH_CHECK(ioSvc.as<IProperty>()->getProperty(&propBSO));
81 bsOutputStreamName = propBSO.value();
86 return StatusCode::SUCCESS;
90 return ByteStreamCnvSvcBase::finalize();
100 const EventContext& ctx = Gaudi::Hive::currentContext();
108 uint32_t bc_time_sec = evtInfo->
timeStamp();
110 uint32_t run_type = 0;
116 uint64_t global_id = event;
117 uint16_t lumi_block = evtInfo->
lumiBlock();
118 uint16_t bc_id = evtInfo->
bcid();
121 eformat::helper::SourceIdentifier sid = eformat::helper::SourceIdentifier(eformat::FULL_SD_EVENT, nevt);
122 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));
125 std::vector<eformat::helper::StreamTag> on_streamTags;
126 for (
const auto& sTag : evtInfo->
streamTags()) {
127 on_streamTags.emplace_back(sTag.name(), sTag.type(), sTag.obeysLumiblock(), sTag.robs(), detsOnline(sTag.dets()));
129 uint32_t nStreamTagWords = eformat::helper::size_word(on_streamTags);
131 eformat::helper::encode(on_streamTags, nStreamTagWords, slot.
m_tagBuff.data());
132 re->stream_tag(nStreamTagWords, slot.
m_tagBuff.data());
136 return StatusCode::SUCCESS;
141 if (
m_evtStore->retrieve(trigDecision,
"xTrigDecision") != StatusCode::SUCCESS) {
142 ATH_MSG_WARNING(
"Property " <<
m_fillTriggerBits.name() <<
" set to True but failed to retrieve xAOD::TrigDecision. Leaving empty trigger bits in the event header.");
143 return StatusCode::SUCCESS;
147 const std::vector<uint32_t> &tbp = trigDecision->
tbp();
148 const std::vector<uint32_t> &tap = trigDecision->
tap();
149 const std::vector<uint32_t> &tav = trigDecision->
tav();
150 const size_t l1TotSize = tbp.size() + tap.size() + tav.size();
154 for (
const uint32_t tb : tbp) {
157 for (
const uint32_t tb : tap) {
160 for (
const uint32_t tb : tav) {
163 re->lvl1_trigger_info(l1TotSize, slot.
m_l1Buff.data());
168 if (lvl2PP.size() > 0) {
170 re->lvl2_trigger_info(lvl2PP.size(), slot.
m_l2Buff.data());
175 if (efPP.size() > 0) {
177 re->event_filter_info(efPP.size(), slot.
m_efBuff.data());
180 return StatusCode::SUCCESS;
186 const EventContext& ctx = Gaudi::Hive::currentContext();
191 return StatusCode::FAILURE;
198 uint32_t rawSize =
re->size_word();
199 std::vector<uint32_t> buffer (rawSize);
200 uint32_t
count = eformat::write::copy(*(
re->bind()), buffer.data(), rawSize);
201 if (
count != rawSize) {
203 return StatusCode::FAILURE;
208 rawEvent.check_tree();
210 ATH_MSG_ERROR(
"commitOutput failed, because FullEventFragment invalid");
211 return StatusCode::FAILURE;
213 ATH_MSG_DEBUG(
"commitOutput: Size of Event (words) = " << rawEvent.fragment_size_word());
216 std::map<std::string, IByteStreamOutputSvc*>::iterator itSvc =
m_ioSvcMap.find(outputConnection);
222 if (!itSvc->second->putEvent(&rawEvent)) {
224 return StatusCode::FAILURE;
229 return StatusCode::SUCCESS;
236 for (
auto& p : feaMap) {
237 MsgStream log(msgSvc(), name());
247 m_slots->m_rawEventWrite = std::move (rawEventWrite);
const boost::regex re(r_e)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
This file contains the interface for the ByteStreamOutputSvc classes.
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
virtual StatusCode initialize() override
Required of all Gaudi Services.
void writeFEA(SlotData &slot)
Write the FEA to RawEvent.
virtual StatusCode commitOutput(const std::string &outputConnection, bool b) override
Implements ConversionSvc's commitOutput.
Gaudi::Property< std::string > m_ioSvcName
name of the service
virtual StatusCode storeFullEventAssembler(std::unique_ptr< FullEventAssemblerBase > fea, const std::string &name) override
ByteStreamCnvSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
Gaudi::Property< std::vector< std::string > > m_ioSvcNameList
list of service names
std::map< std::string, IByteStreamOutputSvc * > m_ioSvcMap
Services for writing output.
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
virtual StatusCode connectOutput(const std::string &t, const std::string &mode) override
Implements ConversionSvc's connectOutput.
SG::SlotSpecificObj< SlotData > m_slots
virtual FullEventAssemblerBase * findFullEventAssembler(const std::string &name) const override
Implementation of IByteStreamCnvSvc interface.
Gaudi::Property< bool > m_fillTriggerBits
fill trigger bits
ServiceHandle< StoreGateSvc > m_evtStore
Event store.
RawEventWrite * setRawEvent(std::unique_ptr< RawEventWrite > rawEventWrite)
virtual StatusCode finalize() override
base class for assembling a full atlas raw event from subfragments
uint32_t lumiBlock() const
The current event's luminosity block number.
uint32_t bcid() const
The bunch crossing ID of the event.
uint16_t level1TriggerType() const
The Level-1 trigger type.
uint32_t timeStamp() const
POSIX time in seconds from 1970. January 1st.
const std::vector< StreamTag > & streamTags() const
Get the streams that the event was put in.
uint32_t runNumber() const
The current event's run number.
uint32_t timeStampNSOffset() const
Nanosecond time offset wrt. the time stamp.
uint64_t eventNumber() const
The current event's event number.
uint32_t extendedLevel1ID() const
The extended Level-1 identifier.
const std::vector< uint32_t > & tav() const
Get the Trigger After Veto bits.
const std::vector< uint32_t > & lvl2PassedPhysics() const
Get the LVL2 physics decision bits.
const std::vector< uint32_t > & efPassedPhysics() const
Get the EF physics decision bits.
const std::vector< uint32_t > & tap() const
Get the Trigger After Prescale bits.
const std::vector< uint32_t > & tbp() const
Get the Trigger Before Prescale bits.
std::string find(const std::string &s)
return a remapped string
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
EventInfo_v1 EventInfo
Definition of the latest event info version.
TrigDecision_v1 TrigDecision
Define the latest version of the trigger decision class.
std::vector< uint32_t > m_l2Buff
std::map< std::string, std::unique_ptr< FullEventAssemblerBase > > m_feaMap
std::vector< uint32_t > m_l1Buff
std::vector< uint32_t > m_tagBuff
std::vector< uint32_t > m_efBuff
std::unique_ptr< RawEventWrite > m_rawEventWrite