Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6637 from dmitrijus/eventdisplay_json_hax2
Add JsonWritingTimeoutPoolOutputModule.
- Loading branch information
Showing
8 changed files
with
156 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
DQMServices/StreamerIO/plugins/JsonWritingTimeoutPoolOutputModule.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include "JsonWritingTimeoutPoolOutputModule.h" | ||
|
||
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
#include "DQMServices/Components/src/DQMFileSaver.h" | ||
|
||
#include <boost/format.hpp> | ||
#include <boost/filesystem.hpp> | ||
#include <boost/property_tree/json_parser.hpp> | ||
#include <boost/property_tree/ptree.hpp> | ||
|
||
namespace dqmservices { | ||
|
||
JsonWritingTimeoutPoolOutputModule::JsonWritingTimeoutPoolOutputModule( | ||
edm::ParameterSet const& ps) | ||
: edm::one::OutputModuleBase::OutputModuleBase(ps), | ||
edm::TimeoutPoolOutputModule(ps) { | ||
runNumber_ = ps.getUntrackedParameter<uint32_t>("runNumber"); | ||
outputPath_ = ps.getUntrackedParameter<std::string>("outputPath"); | ||
streamLabel_ = ps.getUntrackedParameter<std::string>("streamLabel"); | ||
|
||
sequence_ = 0; | ||
} | ||
|
||
std::pair<std::string, std::string> | ||
JsonWritingTimeoutPoolOutputModule::physicalAndLogicalNameForNewFile() { | ||
sequence_++; | ||
|
||
std::string base = str(boost::format("run%06d_ls%04d_%s") % runNumber_ % | ||
sequence_ % streamLabel_); | ||
|
||
boost::filesystem::path p(outputPath_); | ||
|
||
currentFileName_ = (p / base).string() + ".root"; | ||
currentJsonName_ = (p / base).string() + ".jsn"; | ||
|
||
return std::make_pair(currentFileName_, currentFileName_); | ||
} | ||
|
||
void JsonWritingTimeoutPoolOutputModule::doExtrasAfterCloseFile() { | ||
std::string json_tmp_ = currentJsonName_ + ".open"; | ||
auto pt = | ||
DQMFileSaver::fillJson(runNumber_, sequence_, currentFileName_, nullptr); | ||
write_json(json_tmp_, pt); | ||
rename(json_tmp_.c_str(), currentJsonName_.c_str()); | ||
} | ||
|
||
void JsonWritingTimeoutPoolOutputModule::fillDescriptions( | ||
edm::ConfigurationDescriptions& descriptions) { | ||
edm::ParameterSetDescription desc; | ||
TimeoutPoolOutputModule::fillDescription(desc); | ||
|
||
desc.setComment( | ||
"Almost same as TimeoutPoolOutputModule, but the output files names " | ||
"follow the FFF naming convention. Additionally a json 'description' " | ||
"file is emitted for every .root file written."); | ||
|
||
desc.addUntracked<uint32_t>("runNumber", 0)->setComment( | ||
"The run number, only used for file prefix: 'run000001_lumi0000_...'."); | ||
|
||
desc.addUntracked<std::string>("outputPath", "./")->setComment( | ||
"Output path for the root and json files, usually the run directory."); | ||
|
||
desc.addUntracked<std::string>("streamLabel", "streamEvDOutput") | ||
->setComment("Stream label, used for file suffix."); | ||
|
||
descriptions.add("jsonWriting", desc); | ||
} | ||
|
||
} // end of namespace | ||
|
||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
using dqmservices::JsonWritingTimeoutPoolOutputModule; | ||
DEFINE_FWK_MODULE(JsonWritingTimeoutPoolOutputModule); |
35 changes: 35 additions & 0 deletions
35
DQMServices/StreamerIO/plugins/JsonWritingTimeoutPoolOutputModule.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#ifndef DQMServices_StreamerIO_JsonWritingTimeoutPoolOutputModule_h | ||
#define DQMServices_StreamerIO_JsonWritingTimeoutPoolOutputModule_h | ||
|
||
#include "IOPool/Output/interface/TimeoutPoolOutputModule.h" | ||
|
||
namespace dqmservices { | ||
|
||
class ModuleCallingContext; | ||
class ParameterSet; | ||
|
||
class JsonWritingTimeoutPoolOutputModule : public edm::TimeoutPoolOutputModule { | ||
public: | ||
explicit JsonWritingTimeoutPoolOutputModule(edm::ParameterSet const& ps); | ||
virtual ~JsonWritingTimeoutPoolOutputModule(){}; | ||
|
||
static void fillDescriptions(edm::ConfigurationDescriptions&); | ||
|
||
protected: | ||
virtual std::pair<std::string, std::string> physicalAndLogicalNameForNewFile() | ||
override; | ||
virtual void doExtrasAfterCloseFile() override; | ||
|
||
protected: | ||
uint32_t sequence_; | ||
uint32_t runNumber_; | ||
std::string streamLabel_; | ||
std::string outputPath_; | ||
|
||
std::string currentFileName_; | ||
std::string currentJsonName_; | ||
}; | ||
|
||
} // end of namespace | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters