CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
15  : edm::one::OutputModuleBase::OutputModuleBase(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  auto pt =
43  write_json(json_tmp_, pt);
44  rename(json_tmp_.c_str(), currentJsonName_.c_str());
45 }
46 
48  edm::ConfigurationDescriptions& descriptions) {
50  TimeoutPoolOutputModule::fillDescription(desc);
51 
52  desc.setComment(
53  "Almost same as TimeoutPoolOutputModule, but the output files names "
54  "follow the FFF naming convention. Additionally a json 'description' "
55  "file is emitted for every .root file written.");
56 
57  desc.addUntracked<uint32_t>("runNumber", 0)->setComment(
58  "The run number, only used for file prefix: 'run000001_lumi0000_...'.");
59 
60  desc.addUntracked<std::string>("outputPath", "./")->setComment(
61  "Output path for the root and json files, usually the run directory.");
62 
63  desc.addUntracked<std::string>("streamLabel", "streamEvDOutput")
64  ->setComment("Stream label, used for file suffix.");
65 
66  descriptions.add("jsonWriting", desc);
67 }
68 
69 } // end of namespace
70 
tuple base
Main Program
Definition: newFWLiteAna.py:92
T getUntrackedParameter(std::string const &, T const &) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
string format
Some error handling for the usage.
static void fillDescriptions(edm::ConfigurationDescriptions &)
void setComment(std::string const &value)
tuple path
else: Piece not in the list, fine.
static boost::property_tree::ptree fillJson(int run, int lumi, const std::string &dataFilePathName, evf::FastMonitoringService *fms)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual std::pair< std::string, std::string > physicalAndLogicalNameForNewFile() override