Skip to content

Commit

Permalink
Reorganize DQMServices/StreamerIO/test
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitrijus Bugelskis committed Mar 17, 2017
1 parent aca3bcc commit 630b4ed
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 87 deletions.
42 changes: 0 additions & 42 deletions DQMServices/StreamerIO/test/DQMStreamReader_replay_cfg.py

This file was deleted.

2 changes: 1 addition & 1 deletion DQMServices/StreamerIO/test/DQMStreamWriter.py
Expand Up @@ -42,7 +42,7 @@
)

# define the PoolOutputModule
process.poolOutput = cms.OutputModule('DQMStreamerOutputModule',
process.poolOutput = cms.OutputModule('DQMStreamerOutputModuleTest',
runInputDir = cms.untracked.string(options.runInputDir),
streamLabel = cms.untracked.string("_streamA"),
)
Expand Down
Expand Up @@ -20,10 +20,10 @@

namespace edm {

class DQMStreamerOutputModule : public edm::StreamerOutputModuleBase {
class DQMStreamerOutputModuleTest : public edm::StreamerOutputModuleBase {
public:
explicit DQMStreamerOutputModule(edm::ParameterSet const& ps);
virtual ~DQMStreamerOutputModule();
explicit DQMStreamerOutputModuleTest(edm::ParameterSet const& ps);
virtual ~DQMStreamerOutputModuleTest();
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
Expand Down Expand Up @@ -57,7 +57,7 @@ class DQMStreamerOutputModule : public edm::StreamerOutputModuleBase {
mutable boost::shared_ptr<InitMsgView> init_message_cache_;
}; //end-of-class-def

DQMStreamerOutputModule::DQMStreamerOutputModule(edm::ParameterSet const& ps)
DQMStreamerOutputModuleTest::DQMStreamerOutputModuleTest(edm::ParameterSet const& ps)
: edm::one::OutputModuleBase::OutputModuleBase(ps),
edm::StreamerOutputModuleBase(ps),
streamLabel_(ps.getUntrackedParameter<std::string>("streamLabel")),
Expand All @@ -67,7 +67,7 @@ DQMStreamerOutputModule::DQMStreamerOutputModule(edm::ParameterSet const& ps)
currentLumi_(0),
currentRun_(0) {

edm::LogInfo("DQMStreamerOutputModule") << "Writing .dat files to "
edm::LogInfo("DQMStreamerOutputModuleTest") << "Writing .dat files to "
<< runInputDir_;

if (!boost::filesystem::is_directory(runInputDir_)) {
Expand All @@ -76,26 +76,26 @@ DQMStreamerOutputModule::DQMStreamerOutputModule(edm::ParameterSet const& ps)
}
}

DQMStreamerOutputModule::~DQMStreamerOutputModule() {}
DQMStreamerOutputModuleTest::~DQMStreamerOutputModuleTest() {}

void DQMStreamerOutputModule::doOutputHeader(InitMsgBuilder const& i) {
void DQMStreamerOutputModuleTest::doOutputHeader(InitMsgBuilder const& i) {

init_message_cache_.reset(new InitMsgView(i.startAddress()));
}

void DQMStreamerOutputModule::doOutputEvent(EventMsgBuilder const& msg) {
void DQMStreamerOutputModuleTest::doOutputEvent(EventMsgBuilder const& msg) {

++processed_;

EventMsgView eview(msg.startAddress());
stream_writer_events_->write(eview);
// You can't use msg in DQMStreamerOutputModule after this point
// You can't use msg in DQMStreamerOutputModuleTest after this point
}

void DQMStreamerOutputModule::beginLuminosityBlock(
void DQMStreamerOutputModuleTest::beginLuminosityBlock(
edm::LuminosityBlockForOutput const& ls) {

std::cout << "DQMStreamerOutputModule : begin lumi." << std::endl;
std::cout << "DQMStreamerOutputModuleTest : begin lumi." << std::endl;

if (flagLumiRemap_) {
currentLumi_++;
Expand All @@ -113,31 +113,31 @@ void DQMStreamerOutputModule::beginLuminosityBlock(
p = p.parent_path();

if (!boost::filesystem::is_directory(p)) {
std::cout << "DQMStreamerOutputModule : creating run directory: " << p
std::cout << "DQMStreamerOutputModuleTest : creating run directory: " << p
<< std::endl;
boost::filesystem::create_directories(p);
}

stream_writer_events_.reset(new StreamerOutputFile(path));
eventsFile_ = path;

std::cout << "DQMStreamerOutputModule : writing init message." << std::endl;
std::cout << "DQMStreamerOutputModuleTest : writing init message." << std::endl;
stream_writer_events_->write(*init_message_cache_);

processed_ = 0;
}

void DQMStreamerOutputModule::endLuminosityBlock(
void DQMStreamerOutputModuleTest::endLuminosityBlock(
edm::LuminosityBlockForOutput const& ls) {

std::cout << "DQMStreamerOutputModule : end lumi " << std::endl;
std::cout << "DQMStreamerOutputModuleTest : end lumi " << std::endl;
stream_writer_events_.reset();

// output jsn file
std::string path =
str(boost::format("%s/run%06d/run%06d_ls%04d%s.jsn") % runInputDir_ %
currentRun_ % currentRun_ % currentLumi_ % streamLabel_);
std::cout << "DQMStreamerOutputModule : writing json: " << path << std::endl;
std::cout << "DQMStreamerOutputModuleTest : writing json: " << path << std::endl;

using namespace boost::property_tree;
ptree pt;
Expand All @@ -162,16 +162,16 @@ void DQMStreamerOutputModule::endLuminosityBlock(
file.close();
}

void DQMStreamerOutputModule::start() {}
void DQMStreamerOutputModuleTest::start() {}

void DQMStreamerOutputModule::stop() {
std::cout << "DQMStreamerOutputModule : end run" << std::endl;
void DQMStreamerOutputModuleTest::stop() {
std::cout << "DQMStreamerOutputModuleTest : end run" << std::endl;
stream_writer_events_.reset();

// output jsn file
std::string path = str(boost::format("%s/run%06d/run%06d_ls%04d_EoR.jsn") %
runInputDir_ % currentRun_ % currentRun_ % 0);
std::cout << "DQMStreamerOutputModule : writing json: " << path << std::endl;
std::cout << "DQMStreamerOutputModuleTest : writing json: " << path << std::endl;

using namespace boost::property_tree;
ptree pt;
Expand All @@ -198,7 +198,7 @@ void DQMStreamerOutputModule::stop() {
file.close();
}

void DQMStreamerOutputModule::fillDescriptions(
void DQMStreamerOutputModuleTest::fillDescriptions(
edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
edm::StreamerOutputModuleBase::fillDescription(desc);
Expand All @@ -218,5 +218,5 @@ void DQMStreamerOutputModule::fillDescriptions(
#include "FWCore/Framework/interface/MakerMacros.h"
#include "EventFilter/Utilities/plugins/RecoEventWriterForFU.h"

typedef edm::DQMStreamerOutputModule DQMStreamerOutputModule;
DEFINE_FWK_MODULE(DQMStreamerOutputModule);
typedef edm::DQMStreamerOutputModuleTest DQMStreamerOutputModuleTest;
DEFINE_FWK_MODULE(DQMStreamerOutputModuleTest);
Expand Up @@ -32,10 +32,10 @@

namespace dqmservices {

class DQMStreamerOutputRepacker : public edm::StreamerOutputModuleBase {
class DQMStreamerOutputRepackerTest : public edm::StreamerOutputModuleBase {
public:
explicit DQMStreamerOutputRepacker(edm::ParameterSet const& ps);
virtual ~DQMStreamerOutputRepacker();
explicit DQMStreamerOutputRepackerTest(edm::ParameterSet const& ps);
virtual ~DQMStreamerOutputRepackerTest();
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
Expand Down Expand Up @@ -73,7 +73,7 @@ class DQMStreamerOutputRepacker : public edm::StreamerOutputModuleBase {
std::string currentJsonPath_;
}; // end-of-class-def

DQMStreamerOutputRepacker::DQMStreamerOutputRepacker(
DQMStreamerOutputRepackerTest::DQMStreamerOutputRepackerTest(
edm::ParameterSet const& ps)
: edm::one::OutputModuleBase::OutputModuleBase(ps),
edm::StreamerOutputModuleBase(ps) {
Expand All @@ -87,9 +87,9 @@ DQMStreamerOutputRepacker::DQMStreamerOutputRepacker(
currentFileIndex_ = 0;
}

DQMStreamerOutputRepacker::~DQMStreamerOutputRepacker() {}
DQMStreamerOutputRepackerTest::~DQMStreamerOutputRepackerTest() {}

void DQMStreamerOutputRepacker::openFile() {
void DQMStreamerOutputRepackerTest::openFile() {
if (stream_writer_events_) {
closeFile();
}
Expand All @@ -108,7 +108,7 @@ void DQMStreamerOutputRepacker::openFile() {
currentFilePath_ = (p / currentFileBase_).string() + ".dat";
currentJsonPath_ = (p / currentFileBase_).string() + ".jsn";

edm::LogAbsolute("DQMStreamerOutputRepacker") << "Writing file: "
edm::LogAbsolute("DQMStreamerOutputRepackerTest") << "Writing file: "
<< currentFilePath_;

stream_writer_events_.reset(new StreamerOutputFile(currentFilePath_));
Expand All @@ -117,13 +117,13 @@ void DQMStreamerOutputRepacker::openFile() {
InitMsgView iview(init_message_cache_.get());
stream_writer_events_->write(iview);
} else {
edm::LogWarning("DQMStreamerOutputRepacker")
edm::LogWarning("DQMStreamerOutputRepackerTest")
<< "Open file called before init message.";
}
}

void DQMStreamerOutputRepacker::closeFile() {
edm::LogAbsolute("DQMStreamerOutputRepacker") << "Writing json: "
void DQMStreamerOutputRepackerTest::closeFile() {
edm::LogAbsolute("DQMStreamerOutputRepackerTest") << "Writing json: "
<< currentJsonPath_;
size_t fsize = boost::filesystem::file_size(currentFilePath_);

Expand Down Expand Up @@ -155,13 +155,13 @@ void DQMStreamerOutputRepacker::closeFile() {
stream_writer_events_.reset();
}

void DQMStreamerOutputRepacker::start() {}
void DQMStreamerOutputRepackerTest::start() {}

void DQMStreamerOutputRepacker::stop() { closeFile(); }
void DQMStreamerOutputRepackerTest::stop() { closeFile(); }

void DQMStreamerOutputRepacker::doOutputHeader(
void DQMStreamerOutputRepackerTest::doOutputHeader(
InitMsgBuilder const& init_message_bldr) {
edm::LogWarning("DQMStreamerOutputRepacker")
edm::LogWarning("DQMStreamerOutputRepackerTest")
<< "doOutputHeader() method, initializing streams.";

uint8_t* x = new uint8_t[init_message_bldr.size()];
Expand All @@ -170,22 +170,22 @@ void DQMStreamerOutputRepacker::doOutputHeader(
openFile();
}

void DQMStreamerOutputRepacker::doOutputEvent(EventMsgBuilder const& msg_bldr) {
void DQMStreamerOutputRepackerTest::doOutputEvent(EventMsgBuilder const& msg_bldr) {
if (eventsProcessedFile_ >= eventsPerFile_) {
openFile();
}

eventsProcessedTotal_ += 1;
eventsProcessedFile_ += 1;

edm::LogAbsolute("DQMStreamerOutputRepacker") << "Writing event: "
edm::LogAbsolute("DQMStreamerOutputRepackerTest") << "Writing event: "
<< eventsProcessedTotal_;

EventMsgView view(msg_bldr.startAddress());
stream_writer_events_->write(view);
}

void DQMStreamerOutputRepacker::fillDescriptions(
void DQMStreamerOutputRepackerTest::fillDescriptions(
edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
edm::StreamerOutputModuleBase::fillDescription(desc);
Expand All @@ -201,13 +201,13 @@ void DQMStreamerOutputRepacker::fillDescriptions(
desc.addUntracked<unsigned int>("eventsPerFile")
->setComment("Number of events per file.");

descriptions.add("DQMStreamerOutputRepacker", desc);
descriptions.add("DQMStreamerOutputRepackerTest", desc);
}

} // end of namespace

#include "EventFilter/Utilities/plugins/RecoEventWriterForFU.h"
#include "FWCore/Framework/interface/MakerMacros.h"

typedef dqmservices::DQMStreamerOutputRepacker DQMStreamerOutputRepacker;
DEFINE_FWK_MODULE(DQMStreamerOutputRepacker);
typedef dqmservices::DQMStreamerOutputRepackerTest DQMStreamerOutputRepackerTest;
DEFINE_FWK_MODULE(DQMStreamerOutputRepackerTest);
Expand Up @@ -30,7 +30,7 @@
secondaryFileNames = secFiles,
)

process.poolOutput = cms.OutputModule('DQMStreamerOutputRepacker',
process.poolOutput = cms.OutputModule('DQMStreamerOutputRepackerTest',
outputPath = cms.untracked.string("./output/"),
streamLabel = cms.untracked.string("DQM"),
runNumber = cms.untracked.uint32(15),
Expand Down

0 comments on commit 630b4ed

Please sign in to comment.