CMS 3D CMS Logo

JsonWritingTimeoutPoolOutputModule.cc
Go to the documentation of this file.
2 
5 
6 #include <boost/format.hpp>
7 #include <boost/filesystem.hpp>
8 #include <boost/property_tree/json_parser.hpp>
9 #include <boost/property_tree/ptree.hpp>
10 
11 namespace dqmservices {
12 
14  edm::ParameterSet const& ps)
16  edm::TimeoutPoolOutputModule(ps) {
17  runNumber_ = ps.getUntrackedParameter<uint32_t>("runNumber");
18  outputPath_ = ps.getUntrackedParameter<std::string>("outputPath");
19  streamLabel_ = ps.getUntrackedParameter<std::string>("streamLabel");
20 
21  sequence_ = 0;
22 }
23 
24 std::pair<std::string, std::string>
26  sequence_++;
27 
28  std::string base = str(boost::format("run%06d_ls%04d_%s") % runNumber_ %
30 
32 
33  currentFileName_ = (p / base).string() + ".root";
34  currentJsonName_ = (p / base).string() + ".jsn";
35 
36  return std::make_pair(currentFileName_, currentFileName_);
37 }
38 
40  std::string json_tmp_ = currentJsonName_ + ".open";
41  std::string transferDest = "";
42  std::string mergeType = "ROOT";
44  transferDest, mergeType, nullptr);
45  write_json(json_tmp_, pt);
46  rename(json_tmp_.c_str(), currentJsonName_.c_str());
47 }
48 
50  edm::ConfigurationDescriptions& descriptions) {
52  TimeoutPoolOutputModule::fillDescription(desc);
53 
54  desc.setComment(
55  "Almost same as TimeoutPoolOutputModule, but the output files names "
56  "follow the FFF naming convention. Additionally a json 'description' "
57  "file is emitted for every .root file written.");
58 
59  desc.addUntracked<uint32_t>("runNumber", 0)
60  ->setComment(
61  "The run number, only used for file prefix: "
62  "'run000001_lumi0000_...'.");
63 
64  desc.addUntracked<std::string>("outputPath", "./")
65  ->setComment(
66  "Output path for the root and json files, usually the run "
67  "directory.");
68 
69  desc.addUntracked<std::string>("streamLabel", "streamEvDOutput")
70  ->setComment("Stream label, used for file suffix.");
71 
72  descriptions.add("jsonWriting", desc);
73 }
74 
75 } // end of namespace
76 
T getUntrackedParameter(std::string const &, T const &) const
Definition: rename.py:1
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &)
void setComment(std::string const &value)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
format
Some error handling for the usage.
base
Make Sure CMSSW is Setup ##.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
std::pair< std::string, std::string > physicalAndLogicalNameForNewFile() override
#define str(s)
boost::property_tree::ptree fillJson(int run, int lumi, const std::string &dataFilePathName, const std::string &transferDestinationStr, const std::string &mergeTypeStr, evf::FastMonitoringService *fms)
Definition: fillJson.cc:30