|
ATLAS Offline Software
|
Go to the documentation of this file.
8 #include <boost/shared_ptr.hpp>
17 #include "EventStorage/EventStorageRecords.h"
18 #include "EventStorage/RawFileName.h"
19 #include "EventStorage/SimpleFileName.h"
23 #include "GaudiKernel/ServiceHandle.h"
24 #include "GaudiKernel/IIoComponentMgr.h"
30 const std::string&
name, ISvcLocator* pSvcLocator)
31 : base_class(
name, pSvcLocator) {
57 const std::vector< std::string > choices_ef{
"current",
"v40",
"run1"};
59 == choices_ef.end()) {
60 ATH_MSG_FATAL(
"Unexpected value for EformatVersion property: "
62 return StatusCode::FAILURE;
67 const std::vector< std::string > choices_es{
"current",
"v5",
"run1"};
69 == choices_es.end()) {
70 ATH_MSG_FATAL(
"Unexpected value for EventStorageVersion property: "
72 return StatusCode::FAILURE;
81 return StatusCode::SUCCESS;
88 return StatusCode::SUCCESS;
101 if (!dWok)
ATH_MSG_WARNING(
"Could not write Metadata for eventless file");
104 return StatusCode::SUCCESS;
114 return StatusCode::SUCCESS;
124 if (eventInfo ==
nullptr)
ATH_MSG_WARNING(
"failed to retrieve EventInfo");
127 if (metaData ==
nullptr)
140 if (evtInfo or metaData)
143 throw std::runtime_error(
"Cannot write data without run parameters");
174 return putEvent(
re, Gaudi::Hive::currentContext());
180 const RawEvent*
re,
const EventContext& ctx) {
189 cache->
size =
re->fragment_size_word();
198 cache->
buffer = std::make_unique< DataType[] >(cache->
size);
200 << std::hex << cache->
buffer.get() << std::dec);
208 if (cache->
size == 0) {
210 ATH_MSG_ERROR(
"Failed to convert event, buffer is too small");
215 <<
" version = " << cache->
buffer.get()[3]);
218 cache->
buffer = std::make_unique< DataType[] >(cache->
size);
236 EventStorage::DWError write_result =
m_dataWriter->putData(
238 reinterpret_cast< void*
>(cache->
buffer.get()));
241 if (write_result != EventStorage::DWOK) {
256 if (!
m_ioMgr->io_hasitem(
this)) {
257 ATH_MSG_FATAL(
"IoComponentMgr does not know about myself !");
258 return StatusCode::FAILURE;
267 return(StatusCode::FAILURE);
271 return(StatusCode::FAILURE);
286 return StatusCode::SUCCESS;
295 if (!metaDataCont.
isValid())
return nullptr;
297 if (metaDataCont->
size() > 1)
299 "Bytestream format only supports one. Arbitrarily "
302 return metaDataCont->
front();
308 const EventContext& ctx)
312 if (!metaDataCont.
isValid())
return nullptr;
314 if (metaDataCont->
size() > 1)
316 "Bytestream format only supports one. Arbitrarily "
319 return metaDataCont->
front();
342 if (
params.streamType.empty())
params.streamType =
"Single";
343 if (
params.streamName.empty())
params.streamName =
"Stream";
353 boost::shared_ptr<EventStorage::SimpleFileName> simple_file_name(
355 params.theFNCB = simple_file_name;
358 daq::RawFileName fileNameObj(
365 params.fileNameCore = fileNameObj.fileNameCore();
370 : EventStorage::NONE;
380 ATH_MSG_DEBUG(
"Parsing run parameters from EventInfo" << eventInfo);
386 if(!
tag.type().empty()) {
392 if (!
tag.name().empty()) {
398 params.fmdStrings.push_back(
tag.first +
' ' +
tag.second);
404 std::string event_type =
"Event type: sim/data - ";
405 if (eventInfo.
eventType(xAOD::EventInfo::EventType::IS_SIMULATION))
406 event_type +=
"is sim";
407 else event_type +=
"is data";
409 event_type +=
" , testbeam/atlas - ";
410 if (eventInfo.
eventType(xAOD::EventInfo::EventType::IS_TESTBEAM))
411 event_type +=
"is testbeam";
412 else event_type +=
"is atlas";
414 event_type +=
" , calibration/physics - ";
415 if (eventInfo.
eventType(xAOD::EventInfo::EventType::IS_CALIBRATION))
416 event_type +=
"is calibration";
417 else event_type +=
"is physics";
419 params.fmdStrings.push_back(event_type);
426 ATH_MSG_DEBUG(
"Parsing run parameters from metadata:\n" << metaData);
432 const std::string::size_type
split =
stream.find(
'_');
434 if (
split != std::string::npos and
params.streamType.empty())
437 if (
split != std::string::npos and
params.streamName.empty())
453 params.fmdStrings.push_back(fmd);
460 const InterfaceID& riid,
void** ppvInterface) {
462 if ( !ppvInterface )
return StatusCode::FAILURE;
467 }
else if (base_class::queryInterface(riid, ppvInterface).isSuccess()) {
468 return StatusCode::SUCCESS;
471 return ::AthService::queryInterface(riid, ppvInterface);
474 return StatusCode::SUCCESS;
bool initDataWriter(const EventContext *ctx=nullptr)
initialize EventStorage's DataWriter
SG::ReadHandleKey< ByteStreamMetadataContainer > m_byteStreamMetadataKey
Gaudi::Property< bool > m_writeEventless
Compress events.
std::string find(const std::string &s)
return a remapped string
StatusCode io_reinit() override
SG::SlotSpecificObj< EventCache > m_eventCache
Cache of event data for each slot.
Gaudi::Property< std::string > m_streamType
stream name
uint64_t detectorMaskExt() const
Bit field indicating which TTC zones are present in the event.
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
This file contains the class definition for the ByteStreamEventStorageOutputSvc class.
int m_totalEventCounter
number of event counter
Gaudi::Property< int > m_lumiBlockNumber
run number
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Gaudi::Property< unsigned int > m_maxFileNE
#define ATH_MSG_VERBOSE(x)
Gaudi::Property< std::string > m_streamName
eformat event version to produce, "v40" for run1, or "current"
Gaudi::Property< std::string > m_inputDir
< directory for the data files
const ByteStreamMetadata * getByteStreamMetadata()
uint32_t runNumber() const
The current event's run number.
virtual bool putEvent(const RawEvent *re) override
Implementation of the ByteStreamOutputSvc interface method putEvent.
StatusCode reinit()
reinitialize the service when a fork() occurred/was-issued
This file contains the class definition for the ByteStreamDataWriter class.
Gaudi::Property< int > m_run
Dump fragments.
const DataType * PointerType
Gaudi::Property< std::string > m_eformatVersion
EventStorage BS version to produce, "v5" for run1, or "current".
std::unique_ptr< ByteStreamDataWriter > m_dataWriter
pointer to DataWriter
Gaudi::Property< std::string > m_simpleFileName
use this string for filename, not from the "AgreedFileName"
void updateDataWriterParameters(DataWriterParameters &) const
Create DataWriter parameters from job properties.
Gaudi::Property< std::string > m_appName
File Tag.
::StatusCode StatusCode
StatusCode definition for legacy code.
const T * front() const
Access the first element in the collection as an rvalue.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
std::mutex m_dataWriterMutex
mutex to lock data writer during initialization or writing
uint64_t detectorMask() const
Bit field indicating which TTC zones are present in the event.
uint32_t lumiBlock() const
The current event's luminosity block number.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Class containing parameters needed to initiate DataWriter.
ServiceHandle< IIoComponentMgr > m_ioMgr
ByteStreamEventStorageOutputSvc(const std::string &name, ISvcLocator *pSvcLocator)
Constructors:
StatusCode finalize() override
Gaudi::Property< std::string > m_eventStorageVersion
stream name for multiple output
StatusCode initialize() override
Required of all Gaudi Services.
static const InterfaceID & interfaceID()
Retrieve interface ID.
bool initDataWriterContents(const xAOD::EventInfo *, const ByteStreamMetadata *)
static std::unique_ptr< ByteStreamDataWriter > makeWriter(int version, const std::string &writingPath, const std::string &fileNameCore, const EventStorage::run_parameters_record &rPar, const std::vector< std::string > &fmdStrings, unsigned int maxFileNE=0, unsigned int maxFileMB=0, unsigned int startIndex=1, EventStorage::CompressionType compression=EventStorage::NONE, unsigned int compLevel=1)
Factory method returning data writer instance for specified version.
Gaudi::Property< bool > m_compressEvents
number of MB per file
Class describing the basic event information.
const std::vector< StreamTag > & streamTags() const
Get the streams that the event was put in.
const DetDescrTags_t & detDescrTags() const
The detector description tags.
#define ATH_MSG_WARNING(x)
StatusCode stop() override
const boost::regex re(r_e)
Gaudi::Property< unsigned int > m_maxFileMB
number of events per file
uint16_t level1TriggerType() const
The Level-1 trigger type.
This class provides the base class to services to write bytestream data. The concrete class can provi...
Handle class for reading from StoreGate.
StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
Gaudi::Property< std::string > m_projectTag
Application Name.
std::unique_ptr< uint32_t[] > buffer
Underlying data structure.
const T * get(const ReadHandleKey< T > &key)
Convenience function to retrieve an object given a ReadHandleKey.
Declarations of methods for working with old eformat versions.
size_type size() const noexcept
Returns the number of elements in the collection.
Class describing a stream tag on the event.
bool eventType(EventType type) const
Check for one particular bitmask value.