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  std::string transferDest = "";
42  auto pt =
44  write_json(json_tmp_, pt);
45  rename(json_tmp_.c_str(), currentJsonName_.c_str());
46 }
47 
49  edm::ConfigurationDescriptions& descriptions) {
51  TimeoutPoolOutputModule::fillDescription(desc);
52 
53  desc.setComment(
54  "Almost same as TimeoutPoolOutputModule, but the output files names "
55  "follow the FFF naming convention. Additionally a json 'description' "
56  "file is emitted for every .root file written.");
57 
58  desc.addUntracked<uint32_t>("runNumber", 0)->setComment(
59  "The run number, only used for file prefix: 'run000001_lumi0000_...'.");
60 
61  desc.addUntracked<std::string>("outputPath", "./")->setComment(
62  "Output path for the root and json files, usually the run directory.");
63 
64  desc.addUntracked<std::string>("streamLabel", "streamEvDOutput")
65  ->setComment("Stream label, used for file suffix.");
66 
67  descriptions.add("jsonWriting", desc);
68 }
69 
70 } // end of namespace
71 
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
static boost::property_tree::ptree fillJson(int run, int lumi, const std::string &dataFilePathName, const std::string transferDestinationStr, evf::FastMonitoringService *fms)
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.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual std::pair< std::string, std::string > physicalAndLogicalNameForNewFile() override