CMS 3D CMS Logo

Functions
dqmfilesaver Namespace Reference

Functions

boost::property_tree::ptree fillJson (int run, int lumi, const std::string &dataFilePathName, const std::string &transferDestinationStr, const std::string &mergeTypeStr, evf::FastMonitoringService *fms)
 

Function Documentation

◆ fillJson()

boost::property_tree::ptree dqmfilesaver::fillJson ( int  run,
int  lumi,
const std::string &  dataFilePathName,
const std::string &  transferDestinationStr,
const std::string &  mergeTypeStr,
evf::FastMonitoringService fms 
)

Definition at line 29 of file fillJson.cc.

References data, Exception, evf::FastMonitoringService::getEventsProcessedForLumi(), query::host, crabTemplate::inputFiles, EnsembleCalibrationLA_cfg::path, DiDispStaMuonMonitor_cfi::pt, edm_modernize_messagelogger::stat, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by dqmservices::JsonWritingTimeoutPoolOutputModule::doExtrasAfterCloseFile().

34  {
35  namespace bpt = boost::property_tree;
36 
37  bpt::ptree pt;
38 
39  int hostnameReturn;
40  char host[32];
41  hostnameReturn = gethostname(host, sizeof(host));
42  if (hostnameReturn == -1)
43  throw cms::Exception("fillJson") << "Internal error, cannot get host name";
44 
45  int pid = getpid();
46  std::ostringstream oss_pid;
47  oss_pid << pid;
48 
49  int nProcessed = fms ? (fms->getEventsProcessedForLumi(lumi)) : -1;
50 
51  // Stat the data file: if not there, throw
52  std::string dataFileName;
53  struct stat dataFileStat;
54  dataFileStat.st_size = 0;
55  if (nProcessed) {
56  if (stat(dataFilePathName.c_str(), &dataFileStat) != 0)
57  throw cms::Exception("fillJson") << "Internal error, cannot get data file: " << dataFilePathName;
58  // Extract only the data file name from the full path
59  dataFileName = std::filesystem::path(dataFilePathName).filename().string();
60  }
61  // The availability test of the FastMonitoringService was done in the ctor.
62  bpt::ptree data;
63  bpt::ptree processedEvents, acceptedEvents, errorEvents, bitmask, fileList, fileSize, inputFiles, fileAdler32,
64  transferDestination, mergeType, hltErrorEvents;
65 
66  processedEvents.put("", nProcessed); // Processed events
67  acceptedEvents.put("", nProcessed); // Accepted events, same as processed for our purposes
68 
69  errorEvents.put("", 0); // Error events
70  bitmask.put("", 0); // Bitmask of abs of CMSSW return code
71  fileList.put("", dataFileName); // Data file the information refers to
72  fileSize.put("", dataFileStat.st_size); // Size in bytes of the data file
73  inputFiles.put("", ""); // We do not care about input files!
74  fileAdler32.put("", -1); // placeholder to match output json definition
75  transferDestination.put("", transferDestinationStr); // SM Transfer destination field
76  mergeType.put("", mergeTypeStr); // Merging type for merger and transfer services
77  hltErrorEvents.put("", 0); // Error events
78 
79  data.push_back(std::make_pair("", processedEvents));
80  data.push_back(std::make_pair("", acceptedEvents));
81  data.push_back(std::make_pair("", errorEvents));
82  data.push_back(std::make_pair("", bitmask));
83  data.push_back(std::make_pair("", fileList));
84  data.push_back(std::make_pair("", fileSize));
85  data.push_back(std::make_pair("", inputFiles));
86  data.push_back(std::make_pair("", fileAdler32));
87  data.push_back(std::make_pair("", transferDestination));
88  data.push_back(std::make_pair("", mergeType));
89  data.push_back(std::make_pair("", hltErrorEvents));
90 
91  pt.add_child("data", data);
92 
93  if (fms == nullptr) {
94  pt.put("definition", "/fakeDefinition.jsn");
95  } else {
96  // The availability test of the EvFDaqDirector Service was done in the ctor.
97  std::filesystem::path outJsonDefName{
98  edm::Service<evf::EvFDaqDirector>()->baseRunDir()}; //we assume this file is written bu the EvF Output module
99  outJsonDefName /= (std::string("output_") + oss_pid.str() + std::string(".jsd"));
100  pt.put("definition", outJsonDefName.string());
101  }
102 
103  char sourceInfo[64]; //host and pid information
104  sprintf(sourceInfo, "%s_%d", host, pid);
105  pt.put("source", sourceInfo);
106 
107  return pt;
108 }
string host
Definition: query.py:115
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
unsigned int getEventsProcessedForLumi(unsigned int lumi, bool *abortFlag=nullptr)