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.

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

References data, Exception, evf::FastMonitoringService::getEventsProcessedForLumi(), query::host, varParsingExample::inputFiles, castor_dqm_sourceclient_file_cfg::path, DiDispStaMuonMonitor_cfi::pt, hgcalPlots::stat, and AlCaHLTBitMon_QueryRunRegistry::string.

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

evf::FastMonitoringService::getEventsProcessedForLumi
unsigned int getEventsProcessedForLumi(unsigned int lumi, bool *abortFlag=nullptr)
Definition: FastMonitoringService.cc:708
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
query.host
host
Definition: query.py:115
hgcalPlots.stat
stat
Definition: hgcalPlots.py:1111
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Service
Definition: Service.h:30
varParsingExample.inputFiles
inputFiles
Definition: varParsingExample.py:6
Exception
Definition: hltDiff.cc:246
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
lumi
Definition: LumiSectionData.h:20