Skip to content

Commit

Permalink
Moved code to edm::streamer namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr15Jones committed May 1, 2024
1 parent 63c8386 commit bcbcf69
Show file tree
Hide file tree
Showing 58 changed files with 1,283 additions and 1,212 deletions.
9 changes: 5 additions & 4 deletions DQMServices/StreamerIO/plugins/DQMStreamerReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <cctype>

namespace dqmservices {
using namespace edm::streamer;

DQMStreamerReader::DQMStreamerReader(edm::ParameterSet const& pset, edm::InputSourceDescription const& desc)
: StreamerInputSource(pset, desc),
Expand Down Expand Up @@ -87,7 +88,7 @@ namespace dqmservices {
std::string path = entry.get_data_path();

file_.lumi_ = entry;
file_.streamFile_ = std::make_unique<edm::StreamerInputFile>(path);
file_.streamFile_ = std::make_unique<StreamerInputFile>(path);

InitMsgView const* header = getHeaderMsg();
if (isFirstFile_) {
Expand Down Expand Up @@ -179,11 +180,11 @@ namespace dqmservices {

EventMsgView const* DQMStreamerReader::getEventMsg() {
auto next = file_.streamFile_->next();
if (edm::StreamerInputFile::Next::kFile == next) {
if (StreamerInputFile::Next::kFile == next) {
return nullptr;
}

if (edm::StreamerInputFile::Next::kStop == next) {
if (StreamerInputFile::Next::kStop == next) {
return nullptr;
}

Expand Down Expand Up @@ -437,7 +438,7 @@ namespace dqmservices {
desc.addUntracked<bool>("inputFileTransitionsEachEvent", false);

DQMFileIterator::fillDescription(desc);
edm::StreamerInputSource::fillDescription(desc);
StreamerInputSource::fillDescription(desc);
edm::EventSkipperByID::fillDescription(desc);

descriptions.add("source", desc);
Expand Down
12 changes: 6 additions & 6 deletions DQMServices/StreamerIO/plugins/DQMStreamerReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace dqmservices {

class DQMStreamerReader : public edm::StreamerInputSource {
class DQMStreamerReader : public edm::streamer::StreamerInputSource {
public:
DQMStreamerReader(edm::ParameterSet const& pset, edm::InputSourceDescription const& desc);
~DQMStreamerReader() override;
Expand All @@ -41,14 +41,14 @@ namespace dqmservices {

bool openNextFileImp_();

InitMsgView const* getHeaderMsg();
EventMsgView const* getEventMsg();
edm::streamer::InitMsgView const* getHeaderMsg();
edm::streamer::EventMsgView const* getEventMsg();

EventMsgView const* prepareNextEvent();
edm::streamer::EventMsgView const* prepareNextEvent();

bool isFirstFile_ = true;
bool prepareNextFile();
bool acceptEvent(const EventMsgView*);
bool acceptEvent(const edm::streamer::EventMsgView*);

DQMFileIterator fiterator_;
unsigned int processedEventPerLs_ = 0;
Expand All @@ -66,7 +66,7 @@ namespace dqmservices {
bool setMatchTriggerSel(std::vector<std::string> const& tnames);

struct OpenFile {
std::unique_ptr<edm::StreamerInputFile> streamFile_;
std::unique_ptr<edm::streamer::StreamerInputFile> streamFile_;
DQMFileIterator::LumiEntry lumi_;

bool open() { return (streamFile_.get() != nullptr); }
Expand Down
7 changes: 4 additions & 3 deletions DQMServices/StreamerIO/test/DQMStreamerOutputRepackerTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
#include "IOPool/Streamer/interface/StreamerOutputModuleBase.h"

namespace dqmservices {
using namespace edm::streamer;

class DQMStreamerOutputRepackerTest : public edm::StreamerOutputModuleBase {
class DQMStreamerOutputRepackerTest : public StreamerOutputModuleBase {
public:
explicit DQMStreamerOutputRepackerTest(edm::ParameterSet const& ps);
~DQMStreamerOutputRepackerTest() override;
Expand Down Expand Up @@ -64,7 +65,7 @@ namespace dqmservices {
}; // end-of-class-def

DQMStreamerOutputRepackerTest::DQMStreamerOutputRepackerTest(edm::ParameterSet const& ps)
: edm::one::OutputModuleBase::OutputModuleBase(ps), edm::StreamerOutputModuleBase(ps) {
: edm::one::OutputModuleBase::OutputModuleBase(ps), StreamerOutputModuleBase(ps) {
outputPath_ = ps.getUntrackedParameter<std::string>("outputPath");
streamLabel_ = ps.getUntrackedParameter<std::string>("streamLabel");

Expand Down Expand Up @@ -168,7 +169,7 @@ namespace dqmservices {

void DQMStreamerOutputRepackerTest::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
edm::StreamerOutputModuleBase::fillDescription(desc);
StreamerOutputModuleBase::fillDescription(desc);

desc.addUntracked<std::string>("outputPath", "./output/")->setComment("File output path.");

Expand Down
12 changes: 6 additions & 6 deletions EventFilter/Utilities/interface/DAQSourceModelsFRD.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class DataModeFRD : public DataMode {
detectedFRDversion_ = *((uint16_t*)(fileBuf + fileHeaderOffset));
}

uint32_t headerSize() const override { return FRDHeaderVersionSize[detectedFRDversion_]; }
uint32_t headerSize() const override { return edm::streamer::FRDHeaderVersionSize[detectedFRDversion_]; }

bool versionCheck() const override { return detectedFRDversion_ <= FRDHeaderMaxVersion; }
bool versionCheck() const override { return detectedFRDversion_ <= edm::streamer::FRDHeaderMaxVersion; }

uint64_t dataBlockSize() const override { return event_->size(); }

Expand Down Expand Up @@ -76,7 +76,7 @@ class DataModeFRD : public DataMode {
std::vector<std::shared_ptr<const edm::DaqProvenanceHelper>> daqProvenanceHelpers_;
uint16_t detectedFRDversion_ = 0;
size_t headerSize_ = 0;
std::unique_ptr<FRDEventMsgView> event_;
std::unique_ptr<edm::streamer::FRDEventMsgView> event_;
uint32_t crc_ = 0;
unsigned char* dataBlockAddr_ = nullptr;
size_t dataBlockMax_ = 0;
Expand Down Expand Up @@ -106,9 +106,9 @@ class DataModeFRDStriped : public DataMode {
detectedFRDversion_ = *((uint16_t*)(fileBuf + fileHeaderOffset));
}

uint32_t headerSize() const override { return FRDHeaderVersionSize[detectedFRDversion_]; }
uint32_t headerSize() const override { return edm::streamer::FRDHeaderVersionSize[detectedFRDversion_]; }

bool versionCheck() const override { return detectedFRDversion_ <= FRDHeaderMaxVersion; }
bool versionCheck() const override { return detectedFRDversion_ <= edm::streamer::FRDHeaderMaxVersion; }

uint64_t dataBlockSize() const override {
//just get first event size
Expand Down Expand Up @@ -186,7 +186,7 @@ class DataModeFRDStriped : public DataMode {
uint16_t detectedFRDversion_ = 0;
size_t fileHeaderSize_ = 0;
size_t headerSize_ = 0;
std::vector<std::unique_ptr<FRDEventMsgView>> events_;
std::vector<std::unique_ptr<edm::streamer::FRDEventMsgView>> events_;
std::string crcMsg_;
unsigned char* dataBlockAddr_ = nullptr;
std::vector<unsigned char*> dataBlockAddrs_;
Expand Down
6 changes: 3 additions & 3 deletions EventFilter/Utilities/interface/DAQSourceModelsScoutingRun3.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class DataModeScoutingRun3 : public DataMode {
void detectVersion(unsigned char* fileBuf, uint32_t fileHeaderOffset) override {
detectedFRDversion_ = *((uint16_t*)(fileBuf + fileHeaderOffset));
}
uint32_t headerSize() const override { return FRDHeaderVersionSize[detectedFRDversion_]; }
bool versionCheck() const override { return detectedFRDversion_ <= FRDHeaderMaxVersion; }
uint32_t headerSize() const override { return edm::streamer::FRDHeaderVersionSize[detectedFRDversion_]; }
bool versionCheck() const override { return detectedFRDversion_ <= edm::streamer::FRDHeaderMaxVersion; }

uint64_t dataBlockSize() const override {
// get event size from the first data source (main)
Expand Down Expand Up @@ -113,7 +113,7 @@ class DataModeScoutingRun3 : public DataMode {
uint16_t detectedFRDversion_ = 0;
size_t fileHeaderSize_ = 0;
size_t headerSize_ = 0;
std::vector<std::unique_ptr<FRDEventMsgView>> events_;
std::vector<std::unique_ptr<edm::streamer::FRDEventMsgView>> events_;
unsigned char* dataBlockAddr_ = nullptr;
std::vector<unsigned char*> dataBlockAddrs_;
std::vector<unsigned char*> dataBlockMaxAddrs_;
Expand Down
2 changes: 1 addition & 1 deletion EventFilter/Utilities/interface/FedRawDataInputSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class FedRawDataInputSource : public edm::RawInputSource {

const edm::DaqProvenanceHelper daqProvenanceHelper_;

std::unique_ptr<FRDEventMsgView> event_;
std::unique_ptr<edm::streamer::FRDEventMsgView> event_;

edm::EventID eventID_;
edm::ProcessHistoryID processHistoryID_;
Expand Down
2 changes: 2 additions & 0 deletions EventFilter/Utilities/plugins/FRDOutputModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "IOPool/Streamer/interface/FRDFileHeader.h"
#include "EventFilter/Utilities/interface/crc32c.h"

using namespace edm::streamer;

FRDOutputModule::FRDOutputModule(edm::ParameterSet const& ps)
: edm::one::OutputModuleBase::OutputModuleBase(ps),
edm::one::OutputModule<edm::one::WatchLuminosityBlocks>(ps),
Expand Down
2 changes: 2 additions & 0 deletions EventFilter/Utilities/plugins/FRDStreamSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "EventFilter/Utilities/plugins/FRDStreamSource.h"
#include "EventFilter/Utilities/interface/crc32c.h"

using namespace edm::streamer;

FRDStreamSource::FRDStreamSource(edm::ParameterSet const& pset, edm::InputSourceDescription const& desc)
: ProducerSourceFromFiles(pset, desc, true),
verifyAdler32_(pset.getUntrackedParameter<bool>("verifyAdler32", true)),
Expand Down
17 changes: 9 additions & 8 deletions EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
typedef edm::detail::TriggerResultsBasedEventSelector::handle_t Trig;

namespace evf {
using namespace edm::streamer;

class FastMonitoringService;

Expand Down Expand Up @@ -155,7 +156,7 @@ namespace evf {

typedef edm::global::OutputModule<edm::RunCache<GlobalEvFOutputJSONDef>,
edm::LuminosityBlockCache<evf::GlobalEvFOutputEventWriter>,
edm::StreamCache<edm::StreamerOutputModuleCommon>,
edm::StreamCache<StreamerOutputModuleCommon>,
edm::ExternalWork>
GlobalEvFOutputModuleType;

Expand All @@ -166,7 +167,7 @@ namespace evf {
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
std::unique_ptr<edm::StreamerOutputModuleCommon> beginStream(edm::StreamID) const final;
std::unique_ptr<StreamerOutputModuleCommon> beginStream(edm::StreamID) const final;

std::shared_ptr<GlobalEvFOutputJSONDef> globalBeginRun(edm::RunForOutput const& run) const final;

Expand All @@ -184,7 +185,7 @@ namespace evf {

Trig getTriggerResults(edm::EDGetTokenT<edm::TriggerResults> const& token, edm::EventForOutput const& e) const;

edm::StreamerOutputModuleCommon::Parameters commonParameters_;
StreamerOutputModuleCommon::Parameters commonParameters_;
std::string streamLabel_;
edm::EDGetTokenT<edm::TriggerResults> trToken_;
edm::EDGetTokenT<edm::SendJobHeader::ParameterSetMap> psetToken_;
Expand Down Expand Up @@ -286,7 +287,7 @@ namespace evf {
GlobalEvFOutputModule::GlobalEvFOutputModule(edm::ParameterSet const& ps)
: edm::global::OutputModuleBase(ps),
GlobalEvFOutputModuleType(ps),
commonParameters_(edm::StreamerOutputModuleCommon::parameters(ps)),
commonParameters_(StreamerOutputModuleCommon::parameters(ps)),
streamLabel_(ps.getParameter<std::string>("@module_label")),
trToken_(consumes<edm::TriggerResults>(edm::InputTag("TriggerResults"))),
psetToken_(consumes<edm::SendJobHeader::ParameterSetMap, edm::InRun>(
Expand Down Expand Up @@ -333,23 +334,23 @@ namespace evf {

void GlobalEvFOutputModule::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
edm::StreamerOutputModuleCommon::fillDescription(desc);
StreamerOutputModuleCommon::fillDescription(desc);
GlobalEvFOutputModuleType::fillDescription(desc);
desc.addUntracked<edm::InputTag>("psetMap", {"hltPSetMap"})
->setComment("Optionally allow the map of ParameterSets to be calculated externally.");
descriptions.add("globalEvfOutputModule", desc);
}

std::unique_ptr<edm::StreamerOutputModuleCommon> GlobalEvFOutputModule::beginStream(edm::StreamID) const {
return std::make_unique<edm::StreamerOutputModuleCommon>(
std::unique_ptr<StreamerOutputModuleCommon> GlobalEvFOutputModule::beginStream(edm::StreamID) const {
return std::make_unique<StreamerOutputModuleCommon>(
commonParameters_, &keptProducts()[edm::InEvent], description().moduleLabel());
}

std::shared_ptr<GlobalEvFOutputJSONDef> GlobalEvFOutputModule::globalBeginRun(edm::RunForOutput const& run) const {
//create run Cache holding JSON file writer and variables
auto jsonDef = std::make_unique<GlobalEvFOutputJSONDef>(streamLabel_, false);
jsonDef->updateDestination(streamLabel_);
edm::StreamerOutputModuleCommon streamerCommon(
StreamerOutputModuleCommon streamerCommon(
commonParameters_, &keptProducts()[edm::InEvent], description().moduleLabel());

//output INI file (non-const). This doesn't require globalBeginRun to be finished
Expand Down
1 change: 1 addition & 0 deletions EventFilter/Utilities/plugins/RawEventFileWriterForBU.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "IOPool/Streamer/interface/FRDFileHeader.h"

using namespace jsoncollector;
using namespace edm::streamer;

//TODO:get run directory information from DaqDirector

Expand Down
8 changes: 4 additions & 4 deletions EventFilter/Utilities/plugins/RawEventFileWriterForBU.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class RawEventFileWriterForBU {
explicit RawEventFileWriterForBU(std::string const& fileName);
~RawEventFileWriterForBU();

void doOutputEvent(FRDEventMsgView const& msg);
void doOutputEvent(edm::streamer::FRDEventMsgView const& msg);

uint32 adler32() const { return (adlerb_ << 16) | adlera_; }
edm::streamer::uint32 adler32() const { return (adlerb_ << 16) | adlera_; }

void start() {}
void stop();
Expand Down Expand Up @@ -82,8 +82,8 @@ class RawEventFileWriterForBU {
int microSleep_;
unsigned int frdFileVersion_;

uint32 adlera_;
uint32 adlerb_;
edm::streamer::uint32 adlera_;
edm::streamer::uint32 adlerb_;

unsigned int lumiOpen_ = 0;
unsigned int lumiClosed_ = 0;
Expand Down
8 changes: 5 additions & 3 deletions EventFilter/Utilities/plugins/RawEventOutputModuleForBU.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ RawEventOutputModuleForBU<Consumer>::~RawEventOutputModuleForBU() {}

template <class Consumer>
void RawEventOutputModuleForBU<Consumer>::write(edm::EventForOutput const& e) {
using namespace edm::streamer;

unsigned int ls = e.luminosityBlock();
if (totevents > 0 && totevents % numEventsPerFile_ == 0) {
index_++;
Expand All @@ -89,8 +91,8 @@ void RawEventOutputModuleForBU<Consumer>::write(edm::EventForOutput const& e) {
e.getByToken(token_, fedBuffers);

// determine the expected size of the FRDEvent IN BYTES !!!!!
assert(frdVersion_ <= FRDHeaderMaxVersion);
int headerSize = FRDHeaderVersionSize[frdVersion_];
assert(frdVersion_ <= edm::streamer::FRDHeaderMaxVersion);
int headerSize = edm::streamer::FRDHeaderVersionSize[frdVersion_];
int expectedSize = headerSize;
int nFeds = frdVersion_ < 3 ? 1024 : FEDNumbering::lastFEDId() + 1;

Expand Down Expand Up @@ -156,7 +158,7 @@ void RawEventOutputModuleForBU<Consumer>::write(edm::EventForOutput const& e) {
}

// create the FRDEventMsgView and use the template consumer to write it out
FRDEventMsgView msg(workBuffer.get()->data());
edm::streamer::FRDEventMsgView msg(workBuffer.get()->data());
writtensize += msg.size();

templateConsumer_->doOutputEvent(msg);
Expand Down
2 changes: 2 additions & 0 deletions EventFilter/Utilities/src/DAQSourceModelsFRD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "DataFormats/Provenance/interface/Timestamp.h"
#include "EventFilter/Utilities/interface/crc32c.h"

using namespace edm::streamer;

void DataModeFRD::readEvent(edm::EventPrincipal& eventPrincipal) {
std::unique_ptr<FEDRawDataCollection> rawData(new FEDRawDataCollection);
bool tcdsInRange;
Expand Down
2 changes: 2 additions & 0 deletions EventFilter/Utilities/src/DAQSourceModelsScoutingRun3.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "EventFilter//Utilities/interface/DAQSourceModelsScoutingRun3.h"

using namespace edm::streamer;

void DataModeScoutingRun3::makeDirectoryEntries(std::vector<std::string> const& baseDirs,
std::vector<int> const& numSources,
std::string const& runDir) {
Expand Down
1 change: 1 addition & 0 deletions EventFilter/Utilities/src/EvFDaqDirector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
//#define DEBUG

using namespace jsoncollector;
using namespace edm::streamer;

namespace evf {

Expand Down
1 change: 1 addition & 0 deletions EventFilter/Utilities/src/FedRawDataInputSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "EventFilter/Utilities/interface/reader.h"

using namespace evf::FastMonState;
using namespace edm::streamer;

FedRawDataInputSource::FedRawDataInputSource(edm::ParameterSet const& pset, edm::InputSourceDescription const& desc)
: edm::RawInputSource(pset, desc),
Expand Down
2 changes: 2 additions & 0 deletions IOPool/Streamer/bin/CalcAdler32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <cstdint>

int main(int argc, char* argv[]) {
using namespace edm::streamer;

if (argc < 2) {
std::cerr << "No command line argument given, expected path/filename.\n";
return 1;
Expand Down
5 changes: 3 additions & 2 deletions IOPool/Streamer/bin/CatStreamerFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// Utility to concatenate streamer files outside of the framework
// Mimics the behavior of DAQ
// Largely copied from DiagStreamerFile
using namespace edm::streamer;

void help();
void mergefile(StreamerOutputFile&, std::string const&, bool);
Expand Down Expand Up @@ -45,7 +46,7 @@ void mergefile(StreamerOutputFile& stream_output, std::string const& filename, b
uint32 num_events(0);

try {
edm::StreamerInputFile stream_reader(filename);
StreamerInputFile stream_reader(filename);

std::cout << "Trying to Read The Init message from Streamer File: " << std::endl << filename << std::endl;
InitMsgView const* init = stream_reader.startMessage();
Expand All @@ -56,7 +57,7 @@ void mergefile(StreamerOutputFile& stream_output, std::string const& filename, b

std::cout << "Trying to read the Event messages" << std::endl;
EventMsgView const* eview(nullptr);
while (edm::StreamerInputFile::Next::kEvent == stream_reader.next()) {
while (StreamerInputFile::Next::kEvent == stream_reader.next()) {
eview = stream_reader.currentRecord();
++num_events;
stream_output.write(*eview);
Expand Down
Loading

0 comments on commit bcbcf69

Please sign in to comment.