CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TriggerJSONMonitoring.cc
Go to the documentation of this file.
1 
12 
15 
19 
20 #include <fstream>
21 
23 {
24  if (ps.exists("triggerResults")) triggerResults_ = ps.getParameter<edm::InputTag> ("triggerResults");
25  else triggerResults_ = edm::InputTag("TriggerResults","","HLT");
26 
27  triggerResultsToken_ = consumes<edm::TriggerResults>(triggerResults_);
28 
29  if (ps.exists("L1Results")) level1Results_ = ps.getParameter<edm::InputTag>("L1Results"); //DS
30  else level1Results_ = edm::InputTag("hltGtDigis"); //DS
31 
32  m_l1t_results = consumes<L1GlobalTriggerReadoutRecord>(level1Results_); //DS
33 
34 }
35 
37 {
38 }
39 
40 void
43  desc.add<edm::InputTag>("triggerResults",edm::InputTag("TriggerResults","","HLT"));
44  desc.add<edm::InputTag>("L1Results",edm::InputTag("hltGtDigis")); //DS
45  descriptions.add("triggerJSONMonitoring", desc);
46 }
47 
48 void
50 {
51 
52  using namespace std;
53  using namespace edm;
54 
55  processed_++;
56 
57  int ex = iEvent.experimentType();
58  if (ex == 1) L1Global_[0]++;
59  else if (ex == 2) L1Global_[1]++;
60  else if (ex == 3) L1Global_[2]++;
61  else{
62  LogDebug("TriggerJSONMonitoring") << "Not Physics, Calibration or Random. experimentType = " << ex << std::endl;
63  }
64 
65  //Get hold of L1TResults
68 
69  L1GlobalTriggerReadoutRecord L1TResults = * l1tResults.product();
70 
71  const std::vector<bool> & algoword = L1TResults.decisionWord();
72  if (algoword.size() == L1AlgoAccept_.size()){
73  for (unsigned int i = 0; i < algoword.size(); i++){
74  if (algoword[i]) L1AlgoAccept_[i]++;
75  }
76  }
77  else {
78  LogWarning("TriggerJSONMonitoring")<<"L1 Algo Trigger Mask size does not match number of L1 Algo Triggers!";
79  }
80 
81  const std::vector<bool> & techword = L1TResults.technicalTriggerWord();
82  if (techword.size() == L1TechAccept_.size()){
83  for (unsigned int i = 0; i < techword.size(); i++){
84  if (techword[i]) L1TechAccept_[i]++;
85  }
86  }
87  else{
88  LogWarning("TriggerJSONMonitoring")<<"L1 Tech Trigger Mask size does not match number of L1 Tech Triggers!";
89  }
90 
91  //Get hold of TriggerResults
93  iEvent.getByToken(triggerResultsToken_, HLTR);
94  if (!HLTR.isValid()) {
95  LogDebug("TriggerJSONMonitoring") << "HLT TriggerResults with label ["+triggerResults_.encode()+"] not found!" << std::endl;
96  return;
97  }
98 
99  //Decision for each HLT path
100  const unsigned int n(hltNames_.size());
101  for (unsigned int i=0; i<n; i++) {
102  if (HLTR->wasrun(i)) hltWasRun_[i]++;
103  if (HLTR->accept(i)) hltAccept_[i]++;
104  if (HLTR->wasrun(i) && !HLTR->accept(i)) hltReject_[i]++;
105  if (HLTR->error(i)) hltErrors_[i]++;
106  //Count L1 seeds and Prescales
107  const int index(static_cast<int>(HLTR->index(i)));
108  if (HLTR->accept(i)) {
109  if (index >= posL1s_[i]) hltL1s_[i]++;
110  if (index >= posPre_[i]) hltPre_[i]++;
111  } else {
112  if (index > posL1s_[i]) hltL1s_[i]++;
113  if (index > posPre_[i]) hltPre_[i]++;
114  }
115  }
116 
117  //Decision for each HLT dataset
118  std::vector<bool> acceptedByDS(hltIndex_.size(), false);
119  for (unsigned int ds=0; ds < hltIndex_.size(); ds++) { // ds = index of dataset
120  for (unsigned int p=0; p<hltIndex_[ds].size(); p++) { // p = index of path with dataset ds
121  if (acceptedByDS[ds]>0 || HLTR->accept(hltIndex_[ds][p]) ) {
122  acceptedByDS[ds] = true;
123  }
124  }
125  if (acceptedByDS[ds]) hltDatasets_[ds]++;
126  }
127 }//End analyze function
128 
129 void
131 
132  //Update trigger and dataset names, clear L1 names and counters
133  if (changed){
137 
138  L1AlgoNames_.resize(m_l1tAlgoMask->gtTriggerMask().size());
139  for (unsigned int i = 0; i < L1AlgoNames_.size(); i++) {
140  L1AlgoNames_.at(i) = "";
141  }
142  //Get L1 algorithm trigger names - //DS
143  for (CItAlgo itAlgo = algorithmMap.begin(); itAlgo != algorithmMap.end(); itAlgo++) {
144  int bitNumber = (itAlgo->second).algoBitNumber();
145  L1AlgoNames_.at(bitNumber) = itAlgo->first;
146  }
147 
148  L1TechNames_.resize(m_l1tTechMask->gtTriggerMask().size());
149  for (unsigned int i = 0; i < L1TechNames_.size(); i++) {
150  L1TechNames_.at(i) = "";
151  }
152  //Get L1 technical trigger names - //DS
153  for (CItAlgo itAlgo = technicalMap.begin(); itAlgo != technicalMap.end(); itAlgo++) {
154  int bitNumber = (itAlgo->second).algoBitNumber();
155  L1TechNames_.at(bitNumber) = itAlgo->first;
156  }
157 
158  L1GlobalType_.clear(); //DS
159  L1Global_.clear(); //DS
160 
161  //Set the experimentType - //DS
162  L1GlobalType_.push_back( "Physics" );
163  L1GlobalType_.push_back( "Calibration" );
164  L1GlobalType_.push_back( "Random" );
165  }
166 
167  const unsigned int n = hltNames_.size();
168  const unsigned int d = datasetNames_.size();
169  const unsigned int la = L1AlgoNames_.size(); //DS
170  const unsigned int lt = L1TechNames_.size(); //DS
171  const unsigned int lg = L1GlobalType_.size(); //DS
172 
173  if (changed) {
174  //Resize per-path counters
175  hltWasRun_.resize(n);
176  hltL1s_.resize(n);
177  hltPre_.resize(n);
178  hltAccept_.resize(n);
179  hltReject_.resize(n);
180  hltErrors_.resize(n);
181  L1AlgoAccept_.resize(la);
182  L1TechAccept_.resize(lt);
183  L1Global_.resize(lg); //DS
184  //Resize per-dataset counter
185  hltDatasets_.resize(d);
186  //Resize htlIndex
187  hltIndex_.resize(d);
188  //Set-up hltIndex
189  for (unsigned int ds = 0; ds < d; ds++) {
190  unsigned int size = datasetContents_[ds].size();
191  hltIndex_[ds].reserve(size);
192  for (unsigned int p = 0; p < size; p++) {
193  unsigned int i = hltConfig_.triggerIndex(datasetContents_[ds][p]);
194  if (i<n) {
195  hltIndex_[ds].push_back(i);
196  }
197  }
198  }
199  //Find the positions of seeding and prescaler modules
200  posL1s_.resize(n);
201  posPre_.resize(n);
202  for (unsigned int i = 0; i < n; ++i) {
203  posL1s_[i] = -1;
204  posPre_[i] = -1;
205  const std::vector<std::string> & moduleLabels(hltConfig_.moduleLabels(i));
206  for (unsigned int j = 0; j < moduleLabels.size(); ++j) {
207  const std::string & label = hltConfig_.moduleType(moduleLabels[j]);
208  if (label == "HLTLevel1GTSeed")
209  posL1s_[i] = j;
210  else if (label == "HLTPrescaler")
211  posPre_[i] = j;
212  }
213  }
214  }
215  resetLumi();
216 }//End resetRun function
217 
218 void
220  //Reset total number of events
221  processed_ = 0;
222 
223  //Reset per-path counters
224  for (unsigned int i = 0; i < hltWasRun_.size(); i++) {
225  hltWasRun_[i] = 0;
226  hltL1s_[i] = 0;
227  hltPre_[i] = 0;
228  hltAccept_[i] = 0;
229  hltReject_[i] = 0;
230  hltErrors_[i] = 0;
231  }
232  //Reset per-dataset counter
233  for (unsigned int i = 0; i < hltDatasets_.size(); i++) {
234  hltDatasets_[i] = 0;
235  }
236  //Reset L1 per-algo counters - //DS
237  for (unsigned int i = 0; i < L1AlgoAccept_.size(); i++) {
238  L1AlgoAccept_[i] = 0;
239  }
240  //Reset L1 per-tech counters - //DS
241  for (unsigned int i = 0; i < L1TechAccept_.size(); i++) {
242  L1TechAccept_[i] = 0;
243  }
244  //Reset L1 global counters - //DS
245  for (unsigned int i = 0; i < L1GlobalType_.size(); i++) {
246  L1Global_[i] = 0;
247  }
248 
249 }//End resetLumi function
250 
251 void
253 {
254  //Get the run directory from the EvFDaqDirector
256  else baseRunDir_ = ".";
257 
258  std::string monPath = baseRunDir_ + "/";
259 
260  //Get/update the L1 trigger menu from the EventSetup
261  edm::ESHandle<L1GtTriggerMenu> l1GtMenu; //DS
262  iSetup.get<L1GtTriggerMenuRcd>().get(l1GtMenu); //DS
263  m_l1GtMenu = l1GtMenu.product(); //DS
266 
267  //Get masks (for now, only use them to find the number of triggers)
268  edm::ESHandle<L1GtTriggerMask> l1GtAlgoMask;
269  iSetup.get<L1GtTriggerMaskAlgoTrigRcd>().get(l1GtAlgoMask);
270  m_l1tAlgoMask = l1GtAlgoMask.product();
271 
272  edm::ESHandle<L1GtTriggerMask> l1GtTechMask;
273  iSetup.get<L1GtTriggerMaskTechTrigRcd>().get(l1GtTechMask);
274  m_l1tTechMask = l1GtTechMask.product();
275 
276  //Initialize hltConfig_
277  bool changed = true;
278  if (hltConfig_.init(iRun, iSetup, triggerResults_.process(), changed)) resetRun(changed);
279  else{
280  LogDebug("TriggerJSONMonitoring") << "HLTConfigProvider initialization failed!" << std::endl;
281  return;
282  }
283 
284  //Write the once-per-run files if not already written
285  //Eventually must rewrite this with proper multithreading (i.e. globalBeginRun)
286  bool expected = false;
287  if( runCache()->wroteFiles.compare_exchange_strong(expected, true) ){
288  runCache()->wroteFiles = true;
289 
290  unsigned int nRun = iRun.run();
291 
292  //Create definition file for HLT Rates
293  std::stringstream ssHltJsd;
294  ssHltJsd << "run" << std::setfill('0') << std::setw(6) << nRun << "_ls0000";
295  ssHltJsd << "_streamHLTRates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsd";
296  stHltJsd_ = ssHltJsd.str();
297 
299 
300  //Create definition file for L1 Rates - //DS
301  std::stringstream ssL1Jsd;
302  ssL1Jsd << "run" << std::setfill('0') << std::setw(6) << nRun << "_ls0000";
303  ssL1Jsd << "_streamL1Rates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsd";
304  stL1Jsd_ = ssL1Jsd.str();
305 
307 
308  //Write ini files
309  //HLT
310  Json::Value hltIni;
311  Json::StyledWriter writer;
312 
313  Json::Value hltNamesVal(Json::arrayValue);
314  for (unsigned int ui = 0; ui < hltNames_.size(); ui++){
315  hltNamesVal.append(hltNames_.at(ui));
316  }
317 
318  Json::Value datasetNamesVal(Json::arrayValue);
319  for (unsigned int ui = 0; ui < datasetNames_.size(); ui++){
320  datasetNamesVal.append(datasetNames_.at(ui));
321  }
322 
323  hltIni["Path-Names"] = hltNamesVal;
324  hltIni["Dataset-Names"] = datasetNamesVal;
325 
326  std::string && result = writer.write(hltIni);
327 
328  std::stringstream ssHltIni;
329  ssHltIni << "run" << std::setfill('0') << std::setw(6) << nRun << "_ls0000_streamHLTRates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".ini";
330 
331  std::ofstream outHltIni( monPath + ssHltIni.str() );
332  outHltIni<<result;
333  outHltIni.close();
334 
335  //L1
336  Json::Value l1Ini;
337 
338  Json::Value l1AlgoNamesVal(Json::arrayValue);
339  for (unsigned int ui = 0; ui < L1AlgoNames_.size(); ui++){
340  l1AlgoNamesVal.append(L1AlgoNames_.at(ui));
341  }
342 
343  Json::Value l1TechNamesVal(Json::arrayValue);
344  for (unsigned int ui = 0; ui < L1TechNames_.size(); ui++){
345  l1TechNamesVal.append(L1TechNames_.at(ui));
346  }
347 
348  Json::Value eventTypeVal(Json::arrayValue);
349  for (unsigned int ui = 0; ui < L1GlobalType_.size(); ui++){
350  eventTypeVal.append(L1GlobalType_.at(ui));
351  }
352 
353  l1Ini["L1-Algo-Names"] = l1AlgoNamesVal;
354  l1Ini["L1-Tech-Names"] = l1TechNamesVal;
355  l1Ini["Event-Type"] = eventTypeVal;
356 
357  result = writer.write(l1Ini);
358 
359  std::stringstream ssL1Ini;
360  ssL1Ini << "run" << std::setfill('0') << std::setw(6) << nRun << "_ls0000_streamL1Rates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".ini";
361 
362  std::ofstream outL1Ini( monPath + ssL1Ini.str() );
363  outL1Ini<<result;
364  outL1Ini.close();
365  }
366 
367 }//End beginRun function
368 
370 
371 std::shared_ptr<hltJson::lumiVars>
373 {
374  std::shared_ptr<hltJson::lumiVars> iSummary(new hltJson::lumiVars);
375 
376  unsigned int MAXPATHS = 500;
377 
378  iSummary->processed = new HistoJ<unsigned int>(1, 1);
379 
380  iSummary->hltWasRun = new HistoJ<unsigned int>(1, MAXPATHS);
381  iSummary->hltL1s = new HistoJ<unsigned int>(1, MAXPATHS);
382  iSummary->hltPre = new HistoJ<unsigned int>(1, MAXPATHS);
383  iSummary->hltAccept = new HistoJ<unsigned int>(1, MAXPATHS);
384  iSummary->hltReject = new HistoJ<unsigned int>(1, MAXPATHS);
385  iSummary->hltErrors = new HistoJ<unsigned int>(1, MAXPATHS);
386 
387  iSummary->hltDatasets = new HistoJ<unsigned int>(1, MAXPATHS);
388 
389  iSummary->L1Accept = new HistoJ<unsigned int>(1, MAXPATHS); //DS
390  iSummary->L1TechAccept = new HistoJ<unsigned int>(1, MAXPATHS); //DS
391  iSummary->L1Global = new HistoJ<unsigned int>(1, MAXPATHS); //DS
392 
393  return iSummary;
394 }//End globalBeginLuminosityBlockSummary function
395 
396 void
398 
399  //Whichever stream gets there first does the initialiazation
400  if (iSummary->hltWasRun->value().size() == 0){
401  iSummary->processed->update(processed_);
402 
403  for (unsigned int ui = 0; ui < hltWasRun_.size(); ui++){
404  iSummary->hltWasRun->update(hltWasRun_.at(ui));
405  iSummary->hltL1s ->update(hltL1s_ .at(ui));
406  iSummary->hltPre ->update(hltPre_ .at(ui));
407  iSummary->hltAccept->update(hltAccept_.at(ui));
408  iSummary->hltReject->update(hltReject_.at(ui));
409  iSummary->hltErrors->update(hltErrors_.at(ui));
410  }
411  for (unsigned int ui = 0; ui < hltDatasets_.size(); ui++){
412  iSummary->hltDatasets->update(hltDatasets_.at(ui));
413  }
414  iSummary->stHltJsd = stHltJsd_;
415  iSummary->baseRunDir = baseRunDir_;
416 
417  for (unsigned int ui = 0; ui < L1AlgoAccept_.size(); ui++){ //DS
418  iSummary->L1Accept->update(L1AlgoAccept_.at(ui));
419  }
420  for (unsigned int ui = 0; ui < L1TechAccept_.size(); ui++){ //DS
421  iSummary->L1TechAccept->update(L1TechAccept_.at(ui));
422  }
423  for (unsigned int ui = 0; ui < L1GlobalType_.size(); ui++){ //DS
424  iSummary->L1Global ->update(L1Global_.at(ui));
425  }
426  iSummary->stL1Jsd = stL1Jsd_; //DS
427  iSummary->streamHLTDestination = runCache()->streamHLTDestination;
428  iSummary->streamL1Destination = runCache()->streamL1Destination;
429  }
430 
431  else{
432  iSummary->processed->value().at(0) += processed_;
433 
434  for (unsigned int ui = 0; ui < hltWasRun_.size(); ui++){
435  iSummary->hltWasRun->value().at(ui) += hltWasRun_.at(ui);
436  iSummary->hltL1s ->value().at(ui) += hltL1s_ .at(ui);
437  iSummary->hltPre ->value().at(ui) += hltPre_ .at(ui);
438  iSummary->hltAccept->value().at(ui) += hltAccept_.at(ui);
439  iSummary->hltReject->value().at(ui) += hltReject_.at(ui);
440  iSummary->hltErrors->value().at(ui) += hltErrors_.at(ui);
441  }
442  for (unsigned int ui = 0; ui < hltDatasets_.size(); ui++){
443  iSummary->hltDatasets->value().at(ui) += hltDatasets_.at(ui);
444  }
445  for (unsigned int ui = 0; ui < L1AlgoAccept_.size(); ui++){ //DS
446  iSummary->L1Accept->value().at(ui) += L1AlgoAccept_.at(ui);
447  }
448  for (unsigned int ui = 0; ui < L1TechAccept_.size(); ui++){ //DS
449  iSummary->L1TechAccept->value().at(ui) += L1TechAccept_.at(ui);
450  }
451  for (unsigned int ui = 0; ui < L1Global_.size(); ui++){ //DS
452  iSummary->L1Global->value().at(ui) += L1Global_.at(ui);
453  }
454 
455  }
456 
457 }//End endLuminosityBlockSummary function
458 
459 
460 void
462 {
463  if (iSummary->processed->value().at(0)!=0) {
464  Json::StyledWriter writer;
465 
466  char hostname[33];
467  gethostname(hostname,32);
468  std::string sourceHost(hostname);
469 
470  //Get the output directory
471  std::string monPath = iSummary->baseRunDir + "/";
472 
473  std::stringstream sOutDef;
474  sOutDef << monPath << "output_" << getpid() << ".jsd";
475 
476  unsigned int iLs = iLumi.luminosityBlock();
477  unsigned int iRun = iLumi.run();
478 
479  //Write the .jsndata files which contain the actual rates
480  //HLT .jsndata file
481  Json::Value hltJsnData;
482  hltJsnData[DataPoint::SOURCE] = sourceHost;
483  hltJsnData[DataPoint::DEFINITION] = iSummary->stHltJsd;
484 
485  hltJsnData[DataPoint::DATA].append(iSummary->processed->toJsonValue());
486  hltJsnData[DataPoint::DATA].append(iSummary->hltWasRun->toJsonValue());
487  hltJsnData[DataPoint::DATA].append(iSummary->hltL1s ->toJsonValue());
488  hltJsnData[DataPoint::DATA].append(iSummary->hltPre ->toJsonValue());
489  hltJsnData[DataPoint::DATA].append(iSummary->hltAccept->toJsonValue());
490  hltJsnData[DataPoint::DATA].append(iSummary->hltReject->toJsonValue());
491  hltJsnData[DataPoint::DATA].append(iSummary->hltErrors->toJsonValue());
492 
493  hltJsnData[DataPoint::DATA].append(iSummary->hltDatasets->toJsonValue());
494 
495  std::string && result = writer.write(hltJsnData);
496 
497  std::stringstream ssHltJsnData;
498  ssHltJsnData << "run" << std::setfill('0') << std::setw(6) << iRun << "_ls" << std::setfill('0') << std::setw(4) << iLs;
499  ssHltJsnData << "_streamHLTRates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsndata";
500 
501  std::ofstream outHltJsnData( monPath + ssHltJsnData.str() );
502  outHltJsnData<<result;
503  outHltJsnData.close();
504 
505  //L1 .jsndata file
506  Json::Value l1JsnData;
507  l1JsnData[DataPoint::SOURCE] = sourceHost;
508  l1JsnData[DataPoint::DEFINITION] = iSummary->stL1Jsd;
509 
510  l1JsnData[DataPoint::DATA].append(iSummary->processed->toJsonValue());
511  l1JsnData[DataPoint::DATA].append(iSummary->L1Accept ->toJsonValue());
512  l1JsnData[DataPoint::DATA].append(iSummary->L1TechAccept ->toJsonValue()); //DS
513  l1JsnData[DataPoint::DATA].append(iSummary->L1Global ->toJsonValue()); //DS
514  result = writer.write(l1JsnData);
515 
516  std::stringstream ssL1JsnData;
517  ssL1JsnData << "run" << std::setfill('0') << std::setw(6) << iRun << "_ls" << std::setfill('0') << std::setw(4) << iLs;
518  ssL1JsnData << "_streamL1Rates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsndata";
519 
520  std::ofstream outL1JsnData( monPath + "/" + ssL1JsnData.str() );
521  outL1JsnData<<result;
522  outL1JsnData.close();
523 
524  //Create special DAQ JSON file for L1 and HLT rates pseudo-streams
525  //Only three variables are different between the files:
526  //the file list, the file size and the Adler32 value
527  IntJ daqJsnProcessed_ = iSummary->processed->value().at(0);
528  IntJ daqJsnAccepted_ = daqJsnProcessed_;
529  IntJ daqJsnErrorEvents_ = 0;
530  IntJ daqJsnRetCodeMask_ = 0;
531 
532  struct stat st;
533 
534  //HLT
535  StringJ hltJsnFilelist_;
536  hltJsnFilelist_.update(ssHltJsnData.str());
537 
538  const char* cName = (monPath+ssHltJsnData.str()).c_str();
539  stat(cName, &st);
540 
541  IntJ hltJsnFilesize_ = st.st_size;
542  StringJ hltJsnInputFiles_;
543  hltJsnInputFiles_.update("");
544  IntJ hltJsnFileAdler32_ = cms::Adler32(cName, st.st_size);
545 
546  Json::Value hltDaqJsn;
547  hltDaqJsn[DataPoint::SOURCE] = sourceHost;
548  hltDaqJsn[DataPoint::DEFINITION] = sOutDef.str();
549 
550  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnProcessed_.value());
551  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnAccepted_.value());
552  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnErrorEvents_.value());
553  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnRetCodeMask_.value());
554  hltDaqJsn[DataPoint::DATA].append(hltJsnFilelist_.value());
555  hltDaqJsn[DataPoint::DATA].append((unsigned int)hltJsnFilesize_.value());
556  hltDaqJsn[DataPoint::DATA].append(hltJsnInputFiles_.value());
557  hltDaqJsn[DataPoint::DATA].append((unsigned int)hltJsnFileAdler32_.value());
558  hltDaqJsn[DataPoint::DATA].append(iSummary->streamHLTDestination);
559 
560  result = writer.write(hltDaqJsn);
561 
562  std::stringstream ssHltDaqJsn;
563  ssHltDaqJsn << "run" << std::setfill('0') << std::setw(6) << iRun << "_ls" << std::setfill('0') << std::setw(4) << iLs;
564  ssHltDaqJsn << "_streamHLTRates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsn";
565 
566  std::ofstream outHltDaqJsn( monPath + ssHltDaqJsn.str() );
567  outHltDaqJsn<<result;
568  outHltDaqJsn.close();
569 
570  //L1
571  StringJ l1JsnFilelist_;
572  l1JsnFilelist_.update(ssL1JsnData.str());
573 
574  cName = (monPath+ssL1JsnData.str()).c_str();
575  stat(cName, &st);
576 
577  IntJ l1JsnFilesize_ = st.st_size;
578  StringJ l1JsnInputFiles_;
579  l1JsnInputFiles_.update("");
580  IntJ l1JsnFileAdler32_ = cms::Adler32(cName, st.st_size);
581 
582  Json::Value l1DaqJsn;
583  l1DaqJsn[DataPoint::SOURCE] = sourceHost;
584  l1DaqJsn[DataPoint::DEFINITION] = sOutDef.str();
585 
586  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnProcessed_.value());
587  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnAccepted_.value());
588  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnErrorEvents_.value());
589  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnRetCodeMask_.value());
590  l1DaqJsn[DataPoint::DATA].append(l1JsnFilelist_.value());
591  l1DaqJsn[DataPoint::DATA].append((unsigned int)l1JsnFilesize_.value());
592  l1DaqJsn[DataPoint::DATA].append(l1JsnInputFiles_.value());
593  l1DaqJsn[DataPoint::DATA].append((unsigned int)l1JsnFileAdler32_.value());
594  l1DaqJsn[DataPoint::DATA].append(iSummary->streamL1Destination);
595 
596  result = writer.write(l1DaqJsn);
597 
598  std::stringstream ssL1DaqJsn;
599  ssL1DaqJsn << "run" << std::setfill('0') << std::setw(6) << iRun << "_ls" << std::setfill('0') << std::setw(4) << iLs;
600  ssL1DaqJsn << "_streamL1Rates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsn";
601 
602  std::ofstream outL1DaqJsn( monPath + ssL1DaqJsn.str() );
603  outL1DaqJsn<<result;
604  outL1DaqJsn.close();
605  }
606 
607  //Delete the individual HistoJ pointers
608  delete iSummary->processed;
609 
610  delete iSummary->hltWasRun;
611  delete iSummary->hltL1s ;
612  delete iSummary->hltPre ;
613  delete iSummary->hltAccept;
614  delete iSummary->hltReject;
615  delete iSummary->hltErrors;
616 
617  delete iSummary->hltDatasets;
618 
619  delete iSummary->L1Accept; //DS
620  delete iSummary->L1TechAccept; //DS
621  delete iSummary->L1Global; //DS
622 
623  //Note: Do not delete the iSummary pointer. The framework does something with it later on
624  // and deleting it results in a segmentation fault.
625 
626 }//End globalEndLuminosityBlockSummary function
627 
628 
629 void
631 
632  std::ofstream outfile( path );
633  outfile << "{" << std::endl;
634  outfile << " \"data\" : [" << std::endl;
635  outfile << " {" ;
636  outfile << " \"name\" : \"Processed\"," ; //***
637  outfile << " \"type\" : \"integer\"," ;
638  outfile << " \"operation\" : \"histo\"}," << std::endl;
639 
640  outfile << " {" ;
641  outfile << " \"name\" : \"Path-WasRun\"," ;
642  outfile << " \"type\" : \"integer\"," ;
643  outfile << " \"operation\" : \"histo\"}," << std::endl;
644 
645  outfile << " {" ;
646  outfile << " \"name\" : \"Path-AfterL1Seed\"," ;
647  outfile << " \"type\" : \"integer\"," ;
648  outfile << " \"operation\" : \"histo\"}," << std::endl;
649 
650  outfile << " {" ;
651  outfile << " \"name\" : \"Path-AfterPrescale\"," ;
652  outfile << " \"type\" : \"integer\"," ;
653  outfile << " \"operation\" : \"histo\"}," << std::endl;
654 
655  outfile << " {" ;
656  outfile << " \"name\" : \"Path-Accepted\"," ;
657  outfile << " \"type\" : \"integer\"," ;
658  outfile << " \"operation\" : \"histo\"}," << std::endl;
659 
660  outfile << " {" ;
661  outfile << " \"name\" : \"Path-Rejected\"," ;
662  outfile << " \"type\" : \"integer\"," ;
663  outfile << " \"operation\" : \"histo\"}," << std::endl;
664 
665  outfile << " {" ;
666  outfile << " \"name\" : \"Path-Errors\"," ;
667  outfile << " \"type\" : \"integer\"," ;
668  outfile << " \"operation\" : \"histo\"}," << std::endl;
669 
670  outfile << " {" ;
671  outfile << " \"name\" : \"Dataset-Accepted\"," ;
672  outfile << " \"type\" : \"integer\"," ;
673  outfile << " \"operation\" : \"histo\"}" << std::endl;
674 
675  outfile << " ]" << std::endl;
676  outfile << "}" << std::endl;
677 
678  outfile.close();
679 }//End writeDefJson function
680 
681 
682 void
684 
685  std::ofstream outfile( path );
686  outfile << "{" << std::endl;
687  outfile << " \"data\" : [" << std::endl;
688  outfile << " {" ;
689  outfile << " \"name\" : \"Processed\"," ;
690  outfile << " \"type\" : \"integer\"," ;
691  outfile << " \"operation\" : \"histo\"}," << std::endl;
692 
693  outfile << " {" ;
694  outfile << " \"name\" : \"L1-Accepted\"," ;
695  outfile << " \"type\" : \"integer\"," ;
696  outfile << " \"operation\" : \"histo\"}," << std::endl;
697 
698  outfile << " {" ;
699  outfile << " \"name\" : \"L1-TechAccepted\"," ;
700  outfile << " \"type\" : \"integer\"," ;
701  outfile << " \"operation\" : \"histo\"}," << std::endl;
702 
703  outfile << " {" ;
704  outfile << " \"name\" : \"L1-Global\"," ;
705  outfile << " \"type\" : \"integer\"," ;
706  outfile << " \"operation\" : \"histo\"}" << std::endl;
707 
708  outfile << " ]" << std::endl;
709  outfile << "}" << std::endl;
710 
711  outfile.close();
712 }//End writeL1DefJson function
713 
#define LogDebug(id)
TriggerJSONMonitoring(const edm::ParameterSet &)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1t_results
HistoJ< unsigned int > * L1TechAccept
const std::string moduleType(const std::string &module) const
C++ class name of module.
RunNumber_t run() const
Definition: RunBase.h:42
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
HistoJ< unsigned int > * hltReject
std::vector< unsigned int > hltDatasets_
static std::shared_ptr< hltJson::lumiVars > globalBeginLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
std::vector< unsigned int > L1AlgoAccept_
const std::vector< std::string > & triggerNames() const
names of trigger paths
bool exists(std::string const &parameterName) const
checks if a parameter exists
HistoJ< unsigned int > * hltErrors
Value & append(const Value &value)
Append value to array at the end.
void update(std::string const &newStr)
std::vector< unsigned int > hltErrors_
static void globalEndLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, hltJson::lumiVars *)
void beginRun(edm::Run const &, edm::EventSetup const &)
Represents a JSON value.
Definition: value.h:111
HistoJ< unsigned int > * processed
std::vector< unsigned int > hltL1s_
const L1GtTriggerMenu * m_l1GtMenu
virtual Json::Value toJsonValue() const
std::string encode() const
Definition: InputTag.cc:164
std::vector< std::vector< unsigned int > > hltIndex_
std::vector< T > & value()
HistoJ< unsigned int > * hltAccept
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
std::vector< unsigned int > hltAccept_
LuminosityBlockNumber_t luminosityBlock() const
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
std::string streamL1Destination
int iEvent
Definition: GenABIO.cc:230
tuple path
else: Piece not in the list, fine.
HistoJ< unsigned int > * L1Accept
const std::vector< unsigned int > & gtTriggerMask() const
get the trigger mask
void endLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, hltJson::lumiVars *) const
std::vector< std::string > hltNames_
HLTConfigProvider hltConfig_
tuple result
Definition: query.py:137
const L1GtTriggerMask * m_l1tTechMask
std::vector< std::string > datasetNames_
int j
Definition: DBlmapReader.cc:9
RunNumber_t run() const
std::vector< std::string > L1GlobalType_
std::vector< unsigned int > hltReject_
HistoJ< unsigned int > * hltPre
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::string streamHLTDestination
virtual std::string write(const Value &root)
Serialize a Value in JSON format.
std::vector< int > posL1s_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
std::vector< std::string > L1AlgoNames_
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
HistoJ< unsigned int > * hltDatasets
std::vector< unsigned int > L1TechAccept_
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
const L1GtTriggerMask * m_l1tAlgoMask
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void writeDefJson(std::string path)
std::string const & process() const
Definition: InputTag.h:46
std::vector< unsigned int > L1Global_
const std::vector< std::vector< std::string > > & datasetContents() const
names of trigger paths for all datasets
std::vector< unsigned int > hltWasRun_
std::vector< std::vector< std::string > > datasetContents_
< trclass="colgroup">< tdclass="colgroup"colspan=5 > DT local reconstruction</td ></tr >< tr >< td >< ahref="classDTRecHit1DPair.html"> DTRecHit1DPair</a ></td >< td >< ahref="DataFormats_DTRecHit.html"> edm::RangeMap & lt
std::vector< int > posPre_
edm::EventAuxiliary::ExperimentType experimentType() const
Definition: EventBase.h:65
const AlgorithmMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
HistoJ< unsigned int > * hltL1s
std::vector< std::string > L1TechNames_
const AlgorithmMap & gtTechnicalTriggerMap() const
get / set the technical trigger map
void analyze(edm::Event const &, edm::EventSetup const &)
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:65
HistoJ< unsigned int > * L1Global
HistoJ< unsigned int > * hltWasRun
void writeL1DefJson(std::string path)
tuple size
Write out results.
Definition: Run.h:41
const std::vector< std::string > & datasetNames() const
std::vector< unsigned int > hltPre_
string SOURCE
Definition: runonSM.py:23
list at
Definition: asciidump.py:428
array value (ordered list)
Definition: value.h:31