CMS 3D CMS Logo

JsonWritingTimeoutPoolOutputModule.cc
Go to the documentation of this file.
2 
6 
7 #include <filesystem>
8 
9 #include <boost/property_tree/json_parser.hpp>
10 
11 #include <fmt/printf.h>
12 
13 namespace dqmservices {
14 
17  edm::TimeoutPoolOutputModule(ps),
18  runNumber_(ps.getUntrackedParameter<uint32_t>("runNumber")),
19  streamLabel_(ps.getUntrackedParameter<std::string>("streamLabel")),
20  outputPath_(ps.getUntrackedParameter<std::string>("outputPath")),
21  sequence_(0) {}
22 
24  sequence_++;
25 
26  std::string base = fmt::sprintf("run%06d_ls%04d_%s", runNumber_, sequence_, streamLabel_);
27 
29 
30  currentFileName_ = (p / base).string() + ".root";
31  currentJsonName_ = (p / base).string() + ".jsn";
32 
33  return std::make_pair(currentFileName_, currentFileName_);
34  }
35 
37  std::string json_tmp_ = currentJsonName_ + ".open";
38  std::string transferDest = "";
39  std::string mergeType = "ROOT";
40  auto pt = dqmfilesaver::fillJson(runNumber_, sequence_, currentFileName_, transferDest, mergeType, nullptr);
41  write_json(json_tmp_, pt);
42  rename(json_tmp_.c_str(), currentJsonName_.c_str());
43  }
44 
47  TimeoutPoolOutputModule::fillDescription(desc);
48 
49  desc.setComment(
50  "Almost same as TimeoutPoolOutputModule, but the output files names "
51  "follow the FFF naming convention. Additionally a json 'description' "
52  "file is emitted for every .root file written.");
53 
54  desc.addUntracked<uint32_t>("runNumber", 0)
55  ->setComment(
56  "The run number, only used for file prefix: "
57  "'run000001_lumi0000_...'.");
58 
59  desc.addUntracked<std::string>("outputPath", "./")
60  ->setComment(
61  "Output path for the root and json files, usually the run "
62  "directory.");
63 
64  desc.addUntracked<std::string>("streamLabel", "streamEvDOutput")->setComment("Stream label, used for file suffix.");
65 
66  descriptions.add("jsonWriting", desc);
67  }
68 
69 } // namespace dqmservices
70 
static const char runNumber_[]
Definition: rename.py:1
base
Main Program
Definition: newFWLiteAna.py:92
static void fillDescriptions(edm::ConfigurationDescriptions &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
std::pair< std::string, std::string > physicalAndLogicalNameForNewFile() override
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:29