|
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) {
55 const std::vector< std::string > choices_ef{
"current",
"v40",
"run1"};
57 == choices_ef.end()) {
58 ATH_MSG_FATAL(
"Unexpected value for EformatVersion property: "
60 return StatusCode::FAILURE;
65 const std::vector< std::string > choices_es{
"current",
"v5",
"run1"};
67 == choices_es.end()) {
68 ATH_MSG_FATAL(
"Unexpected value for EventStorageVersion property: "
70 return StatusCode::FAILURE;
79 return StatusCode::SUCCESS;
86 return StatusCode::SUCCESS;
99 if (!dWok)
ATH_MSG_WARNING(
"Could not write Metadata for eventless file");
102 return StatusCode::SUCCESS;
112 return StatusCode::SUCCESS;
122 if (eventInfo ==
nullptr)
ATH_MSG_WARNING(
"failed to retrieve EventInfo");
125 if (metaData ==
nullptr)
138 if (evtInfo or metaData)
141 throw std::runtime_error(
"Cannot write data without run parameters");
172 return putEvent(
re, Gaudi::Hive::currentContext());
178 const RawEvent*
re,
const EventContext& ctx) {
187 cache->
size =
re->fragment_size_word();
196 cache->
buffer = std::make_unique< DataType[] >(cache->
size);
198 << std::hex << cache->
buffer.get() << std::dec);
206 if (cache->
size == 0) {
208 ATH_MSG_ERROR(
"Failed to convert event, buffer is too small");
213 <<
" version = " << cache->
buffer.get()[3]);
216 cache->
buffer = std::make_unique< DataType[] >(cache->
size);
234 EventStorage::DWError write_result =
m_dataWriter->putData(
236 reinterpret_cast< void*
>(cache->
buffer.get()));
239 if (write_result != EventStorage::DWOK) {
254 if (!
m_ioMgr->io_hasitem(
this)) {
255 ATH_MSG_FATAL(
"IoComponentMgr does not know about myself !");
256 return StatusCode::FAILURE;
265 return(StatusCode::FAILURE);
269 return(StatusCode::FAILURE);
284 return StatusCode::SUCCESS;
293 if (!metaDataCont.
isValid())
return nullptr;
295 if (metaDataCont->
size() > 1)
297 "Bytestream format only supports one. Arbitrarily "
300 return metaDataCont->
front();
306 const EventContext& ctx)
310 if (!metaDataCont.
isValid())
return nullptr;
312 if (metaDataCont->
size() > 1)
314 "Bytestream format only supports one. Arbitrarily "
317 return metaDataCont->
front();
340 if (
params.streamType.empty())
params.streamType =
"Single";
341 if (
params.streamName.empty())
params.streamName =
"Stream";
351 boost::shared_ptr<EventStorage::SimpleFileName> simple_file_name(
353 params.theFNCB = simple_file_name;
356 daq::RawFileName fileNameObj(
363 params.fileNameCore = fileNameObj.fileNameCore();
368 : EventStorage::NONE;
378 ATH_MSG_DEBUG(
"Parsing run parameters from EventInfo" << eventInfo);
384 if(!
tag.type().empty()) {
390 if (!
tag.name().empty()) {
396 params.fmdStrings.push_back(
tag.first +
' ' +
tag.second);
402 std::string event_type =
"Event type: sim/data - ";
403 if (eventInfo.
eventType(xAOD::EventInfo::EventType::IS_SIMULATION))
404 event_type +=
"is sim";
405 else event_type +=
"is data";
407 event_type +=
" , testbeam/atlas - ";
408 if (eventInfo.
eventType(xAOD::EventInfo::EventType::IS_TESTBEAM))
409 event_type +=
"is testbeam";
410 else event_type +=
"is atlas";
412 event_type +=
" , calibration/physics - ";
413 if (eventInfo.
eventType(xAOD::EventInfo::EventType::IS_CALIBRATION))
414 event_type +=
"is calibration";
415 else event_type +=
"is physics";
417 params.fmdStrings.push_back(event_type);
424 ATH_MSG_DEBUG(
"Parsing run parameters from metadata:\n" << metaData);
430 const std::string::size_type
split =
stream.find(
'_');
432 if (
split != std::string::npos and
params.streamType.empty())
435 if (
split != std::string::npos and
params.streamName.empty())
451 params.fmdStrings.push_back(fmd);
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 IByteStreamOutputSvc 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.
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.
Handle class for reading from StoreGate.
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.