CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
JsonWritingTimeoutPoolOutputModule.cc
Go to the documentation of this file.
1 #include <filesystem>
2 
3 #include <fmt/printf.h>
4 #include <boost/property_tree/json_parser.hpp>
5 #include <boost/property_tree/ptree.hpp>
6 
10 
11 namespace dqmservices {
12 
14  : edm::one::OutputModuleBase::OutputModuleBase(ps), edm::TimeoutPoolOutputModule(ps) {
15  runNumber_ = ps.getUntrackedParameter<uint32_t>("runNumber");
16  outputPath_ = ps.getUntrackedParameter<std::string>("outputPath");
17  streamLabel_ = ps.getUntrackedParameter<std::string>("streamLabel");
18 
19  sequence_ = 0;
20  }
21 
23  sequence_++;
24 
25  std::string base = fmt::sprintf("run%06d_ls%04d_%s", runNumber_, sequence_, streamLabel_);
26 
28 
29  currentFileName_ = (p / base).string() + ".root";
30  currentJsonName_ = (p / base).string() + ".jsn";
31 
32  return std::make_pair(currentFileName_, currentFileName_);
33  }
34 
36  std::string json_tmp_ = currentJsonName_ + ".open";
37  std::string transferDest = "";
38  std::string mergeType = "ROOT";
39  auto pt = dqmfilesaver::fillJson(runNumber_, sequence_, currentFileName_, transferDest, mergeType, nullptr);
40  write_json(json_tmp_, pt);
41  rename(json_tmp_.c_str(), currentJsonName_.c_str());
42  }
43 
46  TimeoutPoolOutputModule::fillDescription(desc);
47 
48  desc.setComment(
49  "Almost same as TimeoutPoolOutputModule, but the output files names "
50  "follow the FFF naming convention. Additionally a json 'description' "
51  "file is emitted for every .root file written.");
52 
53  desc.addUntracked<uint32_t>("runNumber", 0)
54  ->setComment(
55  "The run number, only used for file prefix: "
56  "'run000001_lumi0000_...'.");
57 
58  desc.addUntracked<std::string>("outputPath", "./")
59  ->setComment(
60  "Output path for the root and json files, usually the run "
61  "directory.");
62 
63  desc.addUntracked<std::string>("streamLabel", "streamEvDOutput")->setComment("Stream label, used for file suffix.");
64 
65  descriptions.add("jsonWriting", desc);
66  }
67 
68 } // namespace dqmservices
69 
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:16
static void fillDescriptions(edm::ConfigurationDescriptions &)
void setComment(std::string const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
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