test
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 
21 
22 #include <fstream>
23 using namespace jsoncollector;
24 
26  triggerResults_(ps.getParameter<edm::InputTag>("triggerResults")),
27  triggerResultsToken_(consumes<edm::TriggerResults>(triggerResults_)),
28  level1Results_(ps.getParameter<edm::InputTag>("L1Results")),
29  m_l1t_results(consumes<GlobalAlgBlkBxCollection>(level1Results_))
30 {
31 
32 
33 }
34 
36 {
37 }
38 
39 void
42  desc.add<edm::InputTag>("triggerResults",edm::InputTag("TriggerResults","","HLT"));
43  desc.add<edm::InputTag>("L1Results",edm::InputTag("hltGtStage2Digis"));
44  descriptions.add("triggerJSONMonitoring", desc);
45 }
46 
47 void
49 {
50 
51  using namespace std;
52  using namespace edm;
53 
54  processed_++;
55 
56  int ex = iEvent.experimentType();
57  if (ex == 1) L1Global_[0]++;
58  else if (ex == 2) L1Global_[1]++;
59  else if (ex == 3) L1Global_[2]++;
60  else{
61  LogDebug("TriggerJSONMonitoring") << "Not Physics, Calibration or Random. experimentType = " << ex << std::endl;
62  }
63 
64  //Temporarily removing L1 monitoring while we adapt for Stage 2
65  //Get hold of L1TResults
66  // edm::Handle<L1GlobalTriggerReadoutRecord> l1tResults;
67  // iEvent.getByToken(m_l1t_results, 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]){
75  // L1AlgoAccept_[i]++;
76  // if (ex == 1) L1AlgoAcceptPhysics_[i]++;
77  // if (ex == 2) L1AlgoAcceptCalibration_[i]++;
78  // if (ex == 3) L1AlgoAcceptRandom_[i]++;
79  // }
80  // }
81  // }
82  // else {
83  // LogWarning("TriggerJSONMonitoring")<<"L1 Algo Trigger Mask size does not match number of L1 Algo Triggers!";
84  // }
85 
86  // const std::vector<bool> & techword = L1TResults.technicalTriggerWord();
87  // if (techword.size() == L1TechAccept_.size()){
88  // for (unsigned int i = 0; i < techword.size(); i++){
89  // if (techword[i]){
90  // L1TechAccept_[i]++;
91  // if (ex == 1) L1TechAcceptPhysics_[i]++;
92  // if (ex == 2) L1TechAcceptCalibration_[i]++;
93  // if (ex == 3) L1TechAcceptRandom_[i]++;
94  // }
95  // }
96  // }
97  // else{
98  // LogWarning("TriggerJSONMonitoring")<<"L1 Tech Trigger Mask size does not match number of L1 Tech Triggers!";
99  // }
100 
101  //Get hold of TriggerResults
103  iEvent.getByToken(triggerResultsToken_, HLTR);
104  if (!HLTR.isValid()) {
105  LogDebug("TriggerJSONMonitoring") << "HLT TriggerResults with label ["+triggerResults_.encode()+"] not found!" << std::endl;
106  return;
107  }
108 
109  //Decision for each HLT path
110  const unsigned int n(hltNames_.size());
111  for (unsigned int i=0; i<n; i++) {
112  if (HLTR->wasrun(i)) hltWasRun_[i]++;
113  if (HLTR->accept(i)) hltAccept_[i]++;
114  if (HLTR->wasrun(i) && !HLTR->accept(i)) hltReject_[i]++;
115  if (HLTR->error(i)) hltErrors_[i]++;
116  //Count L1 seeds and Prescales
117  const int index(static_cast<int>(HLTR->index(i)));
118  if (HLTR->accept(i)) {
119  if (index >= posL1s_[i]) hltL1s_[i]++;
120  if (index >= posPre_[i]) hltPre_[i]++;
121  } else {
122  if (index > posL1s_[i]) hltL1s_[i]++;
123  if (index > posPre_[i]) hltPre_[i]++;
124  }
125  }
126 
127  //Decision for each HLT dataset
128  std::vector<bool> acceptedByDS(hltIndex_.size(), false);
129  for (unsigned int ds=0; ds < hltIndex_.size(); ds++) { // ds = index of dataset
130  for (unsigned int p=0; p<hltIndex_[ds].size(); p++) { // p = index of path with dataset ds
131  if (acceptedByDS[ds]>0 || HLTR->accept(hltIndex_[ds][p]) ) {
132  acceptedByDS[ds] = true;
133  }
134  }
135  if (acceptedByDS[ds]) hltDatasets_[ds]++;
136  }
137 
138  //Prescale index
140  if (iEvent.getByToken(m_l1t_results, l1tResults) and not (l1tResults->begin(0) == l1tResults->end(0)))
141  prescaleIndex_ = static_cast<unsigned int>(l1tResults->begin(0)->getPreScColumn());
142 
143  //Check that the prescale index hasn't changed inside a lumi section
144  unsigned int newLumi = (unsigned int) iEvent.eventAuxiliary().luminosityBlock();
145  if (oldLumi == newLumi and prescaleIndex_ != oldPrescaleIndex){
146  LogWarning("TriggerJSONMonitoring")<<"Prescale index has changed from "<<oldPrescaleIndex<<" to "<<prescaleIndex_<<" inside lumi section "<<newLumi;
147  }
148  oldLumi = newLumi;
150 
151 }//End analyze function
152 
153 void
155 
156  //Update trigger and dataset names, clear L1 names and counters
157  if (changed){
161 
162  L1AlgoNames_.resize(m_l1tAlgoMask->gtTriggerMask().size());
163  for (unsigned int i = 0; i < L1AlgoNames_.size(); i++) {
164  L1AlgoNames_.at(i) = "";
165  }
166  //Get L1 algorithm trigger names -
167  for (CItAlgo itAlgo = algorithmMap.begin(); itAlgo != algorithmMap.end(); itAlgo++) {
168  int bitNumber = (itAlgo->second).algoBitNumber();
169  L1AlgoNames_.at(bitNumber) = itAlgo->first;
170  }
171 
172  L1TechNames_.resize(m_l1tTechMask->gtTriggerMask().size());
173  for (unsigned int i = 0; i < L1TechNames_.size(); i++) {
174  L1TechNames_.at(i) = "";
175  }
176  //Get L1 technical trigger names -
177  for (CItAlgo itAlgo = technicalMap.begin(); itAlgo != technicalMap.end(); itAlgo++) {
178  int bitNumber = (itAlgo->second).algoBitNumber();
179  L1TechNames_.at(bitNumber) = itAlgo->first;
180  }
181 
182  L1GlobalType_.clear();
183  L1Global_.clear();
184 
185  //Set the experimentType -
186  L1GlobalType_.push_back( "Physics" );
187  L1GlobalType_.push_back( "Calibration" );
188  L1GlobalType_.push_back( "Random" );
189  }
190 
191  const unsigned int n = hltNames_.size();
192  const unsigned int d = datasetNames_.size();
193  const unsigned int la = L1AlgoNames_.size();
194  const unsigned int lt = L1TechNames_.size();
195  const unsigned int lg = L1GlobalType_.size();
196 
197  if (changed) {
198  //Resize per-path counters
199  hltWasRun_.resize(n);
200  hltL1s_.resize(n);
201  hltPre_.resize(n);
202  hltAccept_.resize(n);
203  hltReject_.resize(n);
204  hltErrors_.resize(n);
205 
206  L1AlgoAccept_.resize(la);
207  L1AlgoAcceptPhysics_.resize(la);
208  L1AlgoAcceptCalibration_.resize(la);
209  L1AlgoAcceptRandom_.resize(la);
210 
211  L1TechAccept_.resize(lt);
212  L1TechAcceptPhysics_.resize(lt);
213  L1TechAcceptCalibration_.resize(lt);
214  L1TechAcceptRandom_.resize(lt);
215 
216  L1Global_.resize(lg);
217  //Resize per-dataset counter
218  hltDatasets_.resize(d);
219  //Resize htlIndex
220  hltIndex_.resize(d);
221  //Set-up hltIndex
222  for (unsigned int ds = 0; ds < d; ds++) {
223  unsigned int size = datasetContents_[ds].size();
224  hltIndex_[ds].reserve(size);
225  for (unsigned int p = 0; p < size; p++) {
226  unsigned int i = hltConfig_.triggerIndex(datasetContents_[ds][p]);
227  if (i<n) {
228  hltIndex_[ds].push_back(i);
229  }
230  }
231  }
232  //Find the positions of seeding and prescaler modules
233  posL1s_.resize(n);
234  posPre_.resize(n);
235  for (unsigned int i = 0; i < n; ++i) {
236  posL1s_[i] = -1;
237  posPre_[i] = -1;
238  const std::vector<std::string> & moduleLabels(hltConfig_.moduleLabels(i));
239  for (unsigned int j = 0; j < moduleLabels.size(); ++j) {
240  const std::string & label = hltConfig_.moduleType(moduleLabels[j]);
241  if (label == "HLTLevel1GTSeed")
242  posL1s_[i] = j;
243  else if (label == "HLTPrescaler")
244  posPre_[i] = j;
245  }
246  }
247  }
248  resetLumi();
249 }//End resetRun function
250 
251 void
253  //Reset total number of events
254  processed_ = 0;
255 
256  //Reset per-path counters
257  for (unsigned int i = 0; i < hltWasRun_.size(); i++) {
258  hltWasRun_[i] = 0;
259  hltL1s_[i] = 0;
260  hltPre_[i] = 0;
261  hltAccept_[i] = 0;
262  hltReject_[i] = 0;
263  hltErrors_[i] = 0;
264  }
265  //Reset per-dataset counter
266  for (unsigned int i = 0; i < hltDatasets_.size(); i++) {
267  hltDatasets_[i] = 0;
268  }
269  //Reset L1 per-algo counters -
270  for (unsigned int i = 0; i < L1AlgoAccept_.size(); i++) {
271  L1AlgoAccept_[i] = 0;
272  L1AlgoAcceptPhysics_[i] = 0;
274  L1AlgoAcceptRandom_[i] = 0;
275  }
276  //Reset L1 per-tech counters -
277  for (unsigned int i = 0; i < L1TechAccept_.size(); i++) {
278  L1TechAccept_[i] = 0;
279  L1TechAcceptPhysics_[i] = 0;
281  L1TechAcceptRandom_[i] = 0;
282  }
283  //Reset L1 global counters -
284  for (unsigned int i = 0; i < L1GlobalType_.size(); i++) {
285  L1Global_[i] = 0;
286  }
287 
288  //Luminosity and prescale index
289  prescaleIndex_ = 0;
290 
291 }//End resetLumi function
292 
293 void
295 {
296  //Get the run directory from the EvFDaqDirector
298  else baseRunDir_ = ".";
299 
300  std::string monPath = baseRunDir_ + "/";
301 
302  //Get/update the L1 trigger menu from the EventSetup
304  iSetup.get<L1GtTriggerMenuRcd>().get(l1GtMenu);
305  m_l1GtMenu = l1GtMenu.product();
308 
309  //Get masks (for now, only use them to find the number of triggers)
310  edm::ESHandle<L1GtTriggerMask> l1GtAlgoMask;
311  iSetup.get<L1GtTriggerMaskAlgoTrigRcd>().get(l1GtAlgoMask);
312  m_l1tAlgoMask = l1GtAlgoMask.product();
313 
314  edm::ESHandle<L1GtTriggerMask> l1GtTechMask;
315  iSetup.get<L1GtTriggerMaskTechTrigRcd>().get(l1GtTechMask);
316  m_l1tTechMask = l1GtTechMask.product();
317 
318  //Initialize hltConfig_
319  bool changed = true;
320  if (hltConfig_.init(iRun, iSetup, triggerResults_.process(), changed)) resetRun(changed);
321  else{
322  LogDebug("TriggerJSONMonitoring") << "HLTConfigProvider initialization failed!" << std::endl;
323  return;
324  }
325 
326  //Write the once-per-run files if not already written
327  //Eventually must rewrite this with proper multithreading (i.e. globalBeginRun)
328  bool expected = false;
329  if( runCache()->wroteFiles.compare_exchange_strong(expected, true) ){
330  runCache()->wroteFiles = true;
331 
332  unsigned int nRun = iRun.run();
333 
334  //Create definition file for HLT Rates
335  std::stringstream ssHltJsd;
336  ssHltJsd << "run" << std::setfill('0') << std::setw(6) << nRun << "_ls0000";
337  ssHltJsd << "_streamHLTRates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsd";
338  stHltJsd_ = ssHltJsd.str();
339 
341 
342  //Create definition file for L1 Rates -
343  std::stringstream ssL1Jsd;
344  ssL1Jsd << "run" << std::setfill('0') << std::setw(6) << nRun << "_ls0000";
345  ssL1Jsd << "_streamL1Rates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsd";
346  stL1Jsd_ = ssL1Jsd.str();
347 
349 
350  //Write ini files
351  //HLT
352  Json::Value hltIni;
353  Json::StyledWriter writer;
354 
355  Json::Value hltNamesVal(Json::arrayValue);
356  for (unsigned int ui = 0; ui < hltNames_.size(); ui++){
357  hltNamesVal.append(hltNames_.at(ui));
358  }
359 
360  Json::Value datasetNamesVal(Json::arrayValue);
361  for (unsigned int ui = 0; ui < datasetNames_.size(); ui++){
362  datasetNamesVal.append(datasetNames_.at(ui));
363  }
364 
365  hltIni["Path-Names"] = hltNamesVal;
366  hltIni["Dataset-Names"] = datasetNamesVal;
367 
368  std::string && result = writer.write(hltIni);
369 
370  std::stringstream ssHltIni;
371  ssHltIni << "run" << std::setfill('0') << std::setw(6) << nRun << "_ls0000_streamHLTRates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".ini";
372 
373  std::ofstream outHltIni( monPath + ssHltIni.str() );
374  outHltIni<<result;
375  outHltIni.close();
376 
377  //L1
378  Json::Value l1Ini;
379 
380  Json::Value l1AlgoNamesVal(Json::arrayValue);
381  for (unsigned int ui = 0; ui < L1AlgoNames_.size(); ui++){
382  l1AlgoNamesVal.append(L1AlgoNames_.at(ui));
383  }
384 
385  Json::Value l1TechNamesVal(Json::arrayValue);
386  for (unsigned int ui = 0; ui < L1TechNames_.size(); ui++){
387  l1TechNamesVal.append(L1TechNames_.at(ui));
388  }
389 
390  Json::Value eventTypeVal(Json::arrayValue);
391  for (unsigned int ui = 0; ui < L1GlobalType_.size(); ui++){
392  eventTypeVal.append(L1GlobalType_.at(ui));
393  }
394 
395  l1Ini["L1-Algo-Names"] = l1AlgoNamesVal;
396  l1Ini["L1-Tech-Names"] = l1TechNamesVal;
397  l1Ini["Event-Type"] = eventTypeVal;
398 
399  result = writer.write(l1Ini);
400 
401  std::stringstream ssL1Ini;
402  ssL1Ini << "run" << std::setfill('0') << std::setw(6) << nRun << "_ls0000_streamL1Rates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".ini";
403 
404  std::ofstream outL1Ini( monPath + ssL1Ini.str() );
405  outL1Ini<<result;
406  outL1Ini.close();
407  }
408 
409  //Initialize variables for verification of prescaleIndex
410  oldLumi = 0;
411  oldPrescaleIndex = 0;
412 
413 }//End beginRun function
414 
416 
417 std::shared_ptr<trigJson::lumiVars>
419 {
420  std::shared_ptr<trigJson::lumiVars> iSummary(new trigJson::lumiVars);
421 
422  unsigned int MAXPATHS = 1000;
423 
424  iSummary->processed = new HistoJ<unsigned int>(1, 1);
425 
426  iSummary->hltWasRun = new HistoJ<unsigned int>(1, MAXPATHS);
427  iSummary->hltL1s = new HistoJ<unsigned int>(1, MAXPATHS);
428  iSummary->hltPre = new HistoJ<unsigned int>(1, MAXPATHS);
429  iSummary->hltAccept = new HistoJ<unsigned int>(1, MAXPATHS);
430  iSummary->hltReject = new HistoJ<unsigned int>(1, MAXPATHS);
431  iSummary->hltErrors = new HistoJ<unsigned int>(1, MAXPATHS);
432 
433  iSummary->hltDatasets = new HistoJ<unsigned int>(1, MAXPATHS);
434 
435  iSummary->prescaleIndex = 100;
436 
437  iSummary->L1AlgoAccept = new HistoJ<unsigned int>(1, MAXPATHS);
438  iSummary->L1TechAccept = new HistoJ<unsigned int>(1, MAXPATHS);
439  iSummary->L1AlgoAcceptPhysics = new HistoJ<unsigned int>(1, MAXPATHS);
440  iSummary->L1TechAcceptPhysics = new HistoJ<unsigned int>(1, MAXPATHS);
441  iSummary->L1AlgoAcceptCalibration = new HistoJ<unsigned int>(1, MAXPATHS);
442  iSummary->L1TechAcceptCalibration = new HistoJ<unsigned int>(1, MAXPATHS);
443  iSummary->L1AlgoAcceptRandom = new HistoJ<unsigned int>(1, MAXPATHS);
444  iSummary->L1TechAcceptRandom = new HistoJ<unsigned int>(1, MAXPATHS);
445  iSummary->L1Global = new HistoJ<unsigned int>(1, MAXPATHS);
446 
447  iSummary->baseRunDir = "";
448  iSummary->stHltJsd = "";
449  iSummary->stL1Jsd = "";
450  iSummary->streamL1Destination = "";
451  iSummary->streamHLTDestination = "";
452  iSummary->streamL1MergeType = "";
453  iSummary->streamHLTMergeType = "";
454 
455  return iSummary;
456 }//End globalBeginLuminosityBlockSummary function
457 
458 void
460 
461  //Whichever stream gets there first does the initialiazation
462  if (iSummary->hltWasRun->value().size() == 0){
463  iSummary->processed->update(processed_);
464 
465  for (unsigned int ui = 0; ui < hltWasRun_.size(); ui++){
466  iSummary->hltWasRun->update(hltWasRun_.at(ui));
467  iSummary->hltL1s ->update(hltL1s_ .at(ui));
468  iSummary->hltPre ->update(hltPre_ .at(ui));
469  iSummary->hltAccept->update(hltAccept_.at(ui));
470  iSummary->hltReject->update(hltReject_.at(ui));
471  iSummary->hltErrors->update(hltErrors_.at(ui));
472  }
473  for (unsigned int ui = 0; ui < hltDatasets_.size(); ui++){
474  iSummary->hltDatasets->update(hltDatasets_.at(ui));
475  }
476  iSummary->prescaleIndex = prescaleIndex_;
477 
478  iSummary->stHltJsd = stHltJsd_;
479  iSummary->baseRunDir = baseRunDir_;
480 
481  for (unsigned int ui = 0; ui < L1AlgoAccept_.size(); ui++){
482  iSummary->L1AlgoAccept ->update(L1AlgoAccept_.at(ui));
486  }
487  for (unsigned int ui = 0; ui < L1TechAccept_.size(); ui++){
488  iSummary->L1TechAccept ->update(L1TechAccept_.at(ui));
492  }
493  for (unsigned int ui = 0; ui < L1GlobalType_.size(); ui++){
494  iSummary->L1Global ->update(L1Global_.at(ui));
495  }
496  iSummary->stL1Jsd = stL1Jsd_;
497 
498  iSummary->streamHLTDestination = runCache()->streamHLTDestination;
499  iSummary->streamL1Destination = runCache()->streamL1Destination;
500  iSummary->streamHLTMergeType = runCache()->streamHLTMergeType;
501  iSummary->streamL1MergeType = runCache()->streamL1MergeType;
502  }
503 
504  else{
505  iSummary->processed->value().at(0) += processed_;
506 
507  for (unsigned int ui = 0; ui < hltWasRun_.size(); ui++){
508  iSummary->hltWasRun->value().at(ui) += hltWasRun_.at(ui);
509  iSummary->hltL1s ->value().at(ui) += hltL1s_ .at(ui);
510  iSummary->hltPre ->value().at(ui) += hltPre_ .at(ui);
511  iSummary->hltAccept->value().at(ui) += hltAccept_.at(ui);
512  iSummary->hltReject->value().at(ui) += hltReject_.at(ui);
513  iSummary->hltErrors->value().at(ui) += hltErrors_.at(ui);
514  }
515  for (unsigned int ui = 0; ui < hltDatasets_.size(); ui++){
516  iSummary->hltDatasets->value().at(ui) += hltDatasets_.at(ui);
517  }
518  for (unsigned int ui = 0; ui < L1AlgoAccept_.size(); ui++){
519  iSummary->L1AlgoAccept->value().at(ui) += L1AlgoAccept_.at(ui);
520  iSummary->L1AlgoAcceptPhysics->value().at(ui) += L1AlgoAcceptPhysics_.at(ui);
522  iSummary->L1AlgoAcceptRandom->value().at(ui) += L1AlgoAcceptRandom_.at(ui);
523  }
524  for (unsigned int ui = 0; ui < L1TechAccept_.size(); ui++){
525  iSummary->L1TechAccept->value().at(ui) += L1TechAccept_.at(ui);
526  iSummary->L1TechAcceptPhysics->value().at(ui) += L1TechAcceptPhysics_.at(ui);
528  iSummary->L1TechAcceptRandom->value().at(ui) += L1TechAcceptRandom_.at(ui);
529  }
530  for (unsigned int ui = 0; ui < L1Global_.size(); ui++){
531  iSummary->L1Global->value().at(ui) += L1Global_.at(ui);
532  }
533 
534  }
535 
536 }//End endLuminosityBlockSummary function
537 
538 
539 void
541 {
542 
543  unsigned int iLs = iLumi.luminosityBlock();
544  unsigned int iRun = iLumi.run();
545 
546  bool writeFiles=true;
547  if (edm::Service<evf::MicroStateService>().isAvailable()) {
549  if (fms) {
550  writeFiles = fms->shouldWriteFiles(iLumi.luminosityBlock());
551  }
552  }
553 
554  if (writeFiles) {
555  Json::StyledWriter writer;
556 
557  char hostname[33];
558  gethostname(hostname,32);
559  std::string sourceHost(hostname);
560 
561  //Get the output directory
562  std::string monPath = iSummary->baseRunDir + "/";
563 
564  std::stringstream sOutDef;
565  sOutDef << monPath << "output_" << getpid() << ".jsd";
566 
567  //Write the .jsndata files which contain the actual rates
568  //HLT .jsndata file
569  Json::Value hltJsnData;
570  hltJsnData[DataPoint::SOURCE] = sourceHost;
571  hltJsnData[DataPoint::DEFINITION] = iSummary->stHltJsd;
572 
573  hltJsnData[DataPoint::DATA].append(iSummary->processed->toJsonValue());
574  hltJsnData[DataPoint::DATA].append(iSummary->hltWasRun->toJsonValue());
575  hltJsnData[DataPoint::DATA].append(iSummary->hltL1s ->toJsonValue());
576  hltJsnData[DataPoint::DATA].append(iSummary->hltPre ->toJsonValue());
577  hltJsnData[DataPoint::DATA].append(iSummary->hltAccept->toJsonValue());
578  hltJsnData[DataPoint::DATA].append(iSummary->hltReject->toJsonValue());
579  hltJsnData[DataPoint::DATA].append(iSummary->hltErrors->toJsonValue());
580 
581  hltJsnData[DataPoint::DATA].append(iSummary->hltDatasets->toJsonValue());
582 
583  hltJsnData[DataPoint::DATA].append(iSummary->prescaleIndex);
584 
585  std::string && result = writer.write(hltJsnData);
586 
587  std::stringstream ssHltJsnData;
588  ssHltJsnData << "run" << std::setfill('0') << std::setw(6) << iRun << "_ls" << std::setfill('0') << std::setw(4) << iLs;
589  ssHltJsnData << "_streamHLTRates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsndata";
590 
591  if (iSummary->processed->value().at(0)!=0) {
592  std::ofstream outHltJsnData( monPath + ssHltJsnData.str() );
593  outHltJsnData<<result;
594  outHltJsnData.close();
595  }
596 
597  //HLT jsn entries
598  StringJ hltJsnFilelist;
599  IntJ hltJsnFilesize = 0;
600  unsigned int hltJsnFileAdler32 = 1;
601  if (iSummary->processed->value().at(0)!=0) {
602  hltJsnFilelist.update(ssHltJsnData.str());
603  hltJsnFilesize = result.size();
604  hltJsnFileAdler32 = cms::Adler32(result.c_str(),result.size());
605  }
606  StringJ hltJsnInputFiles;
607  hltJsnInputFiles.update("");
608 
609  //L1 .jsndata file
610  Json::Value l1JsnData;
611  l1JsnData[DataPoint::SOURCE] = sourceHost;
612  l1JsnData[DataPoint::DEFINITION] = iSummary->stL1Jsd;
613 
614  l1JsnData[DataPoint::DATA].append(iSummary->processed->toJsonValue());
615  l1JsnData[DataPoint::DATA].append(iSummary->L1AlgoAccept ->toJsonValue());
616  l1JsnData[DataPoint::DATA].append(iSummary->L1TechAccept ->toJsonValue());
617  l1JsnData[DataPoint::DATA].append(iSummary->L1AlgoAcceptPhysics ->toJsonValue());
618  l1JsnData[DataPoint::DATA].append(iSummary->L1TechAcceptPhysics ->toJsonValue());
620  l1JsnData[DataPoint::DATA].append(iSummary->L1TechAcceptCalibration->toJsonValue());
621  l1JsnData[DataPoint::DATA].append(iSummary->L1AlgoAcceptRandom ->toJsonValue());
622  l1JsnData[DataPoint::DATA].append(iSummary->L1TechAcceptRandom ->toJsonValue());
623  l1JsnData[DataPoint::DATA].append(iSummary->L1Global ->toJsonValue());
624  result = writer.write(l1JsnData);
625 
626  std::stringstream ssL1JsnData;
627  ssL1JsnData << "run" << std::setfill('0') << std::setw(6) << iRun << "_ls" << std::setfill('0') << std::setw(4) << iLs;
628  ssL1JsnData << "_streamL1Rates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsndata";
629 
630  if (iSummary->processed->value().at(0)!=0) {
631  std::ofstream outL1JsnData( monPath + "/" + ssL1JsnData.str() );
632  outL1JsnData<<result;
633  outL1JsnData.close();
634  }
635 
636  //L1 jsn entries
637  StringJ l1JsnFilelist;
638  IntJ l1JsnFilesize = 0;
639  unsigned int l1JsnFileAdler32 = 1;
640  if (iSummary->processed->value().at(0)!=0) {
641  l1JsnFilelist.update(ssL1JsnData.str());
642  l1JsnFilesize = result.size();
643  l1JsnFileAdler32 = cms::Adler32(result.c_str(),result.size());
644  }
645  StringJ l1JsnInputFiles;
646  l1JsnInputFiles.update("");
647 
648 
649  //Create special DAQ JSON file for L1 and HLT rates pseudo-streams
650  //Only three variables are different between the files:
651  //the file list, the file size and the Adler32 value
652  IntJ daqJsnProcessed = iSummary->processed->value().at(0);
653  IntJ daqJsnAccepted = daqJsnProcessed;
654  IntJ daqJsnErrorEvents = 0;
655  IntJ daqJsnRetCodeMask = 0;
656  IntJ daqJsnHLTErrorEvents = 0;
657 
658  //write out HLT metadata jsn
659  Json::Value hltDaqJsn;
660  hltDaqJsn[DataPoint::SOURCE] = sourceHost;
661  hltDaqJsn[DataPoint::DEFINITION] = sOutDef.str();
662 
663  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnProcessed.value());
664  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnAccepted.value());
665  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnErrorEvents.value());
666  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnRetCodeMask.value());
667  hltDaqJsn[DataPoint::DATA].append(hltJsnFilelist.value());
668  hltDaqJsn[DataPoint::DATA].append((unsigned int)hltJsnFilesize.value());
669  hltDaqJsn[DataPoint::DATA].append(hltJsnInputFiles.value());
670  hltDaqJsn[DataPoint::DATA].append(hltJsnFileAdler32);
671  hltDaqJsn[DataPoint::DATA].append(iSummary->streamHLTDestination);
672  hltDaqJsn[DataPoint::DATA].append(iSummary->streamHLTMergeType);
673  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnHLTErrorEvents.value());
674 
675  result = writer.write(hltDaqJsn);
676 
677  std::stringstream ssHltDaqJsn;
678  ssHltDaqJsn << "run" << std::setfill('0') << std::setw(6) << iRun << "_ls" << std::setfill('0') << std::setw(4) << iLs;
679  ssHltDaqJsn << "_streamHLTRates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsn";
680 
681  std::ofstream outHltDaqJsn( monPath + ssHltDaqJsn.str() );
682  outHltDaqJsn<<result;
683  outHltDaqJsn.close();
684 
685  //write out L1 metadata jsn
686  Json::Value l1DaqJsn;
687  l1DaqJsn[DataPoint::SOURCE] = sourceHost;
688  l1DaqJsn[DataPoint::DEFINITION] = sOutDef.str();
689 
690  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnProcessed.value());
691  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnAccepted.value());
692  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnErrorEvents.value());
693  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnRetCodeMask.value());
694  l1DaqJsn[DataPoint::DATA].append(l1JsnFilelist.value());
695  l1DaqJsn[DataPoint::DATA].append((unsigned int)l1JsnFilesize.value());
696  l1DaqJsn[DataPoint::DATA].append(l1JsnInputFiles.value());
697  l1DaqJsn[DataPoint::DATA].append(l1JsnFileAdler32);
698  l1DaqJsn[DataPoint::DATA].append(iSummary->streamL1Destination);
699  l1DaqJsn[DataPoint::DATA].append(iSummary->streamL1MergeType);
700  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnHLTErrorEvents.value());
701 
702  result = writer.write(l1DaqJsn);
703 
704  std::stringstream ssL1DaqJsn;
705  ssL1DaqJsn << "run" << std::setfill('0') << std::setw(6) << iRun << "_ls" << std::setfill('0') << std::setw(4) << iLs;
706  ssL1DaqJsn << "_streamL1Rates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsn";
707 
708  std::ofstream outL1DaqJsn( monPath + ssL1DaqJsn.str() );
709  outL1DaqJsn<<result;
710  outL1DaqJsn.close();
711  }
712 
713  //Delete the individual HistoJ pointers
714  delete iSummary->processed;
715 
716  delete iSummary->hltWasRun;
717  delete iSummary->hltL1s ;
718  delete iSummary->hltPre ;
719  delete iSummary->hltAccept;
720  delete iSummary->hltReject;
721  delete iSummary->hltErrors;
722 
723  delete iSummary->hltDatasets;
724 
725  delete iSummary->L1AlgoAccept;
726  delete iSummary->L1TechAccept;
727  delete iSummary->L1AlgoAcceptPhysics;
728  delete iSummary->L1TechAcceptPhysics;
729  delete iSummary->L1AlgoAcceptCalibration;
730  delete iSummary->L1TechAcceptCalibration;
731  delete iSummary->L1AlgoAcceptRandom;
732  delete iSummary->L1TechAcceptRandom;
733  delete iSummary->L1Global;
734 
735  //Note: Do not delete the iSummary pointer. The framework does something with it later on
736  // and deleting it results in a segmentation fault.
737 
738 }//End globalEndLuminosityBlockSummary function
739 
740 
741 void
743 
744  std::ofstream outfile( path );
745  outfile << "{" << std::endl;
746  outfile << " \"data\" : [" << std::endl;
747  outfile << " {" ;
748  outfile << " \"name\" : \"Processed\"," ; //***
749  outfile << " \"type\" : \"integer\"," ;
750  outfile << " \"operation\" : \"histo\"}," << std::endl;
751 
752  outfile << " {" ;
753  outfile << " \"name\" : \"Path-WasRun\"," ;
754  outfile << " \"type\" : \"integer\"," ;
755  outfile << " \"operation\" : \"histo\"}," << std::endl;
756 
757  outfile << " {" ;
758  outfile << " \"name\" : \"Path-AfterL1Seed\"," ;
759  outfile << " \"type\" : \"integer\"," ;
760  outfile << " \"operation\" : \"histo\"}," << std::endl;
761 
762  outfile << " {" ;
763  outfile << " \"name\" : \"Path-AfterPrescale\"," ;
764  outfile << " \"type\" : \"integer\"," ;
765  outfile << " \"operation\" : \"histo\"}," << std::endl;
766 
767  outfile << " {" ;
768  outfile << " \"name\" : \"Path-Accepted\"," ;
769  outfile << " \"type\" : \"integer\"," ;
770  outfile << " \"operation\" : \"histo\"}," << std::endl;
771 
772  outfile << " {" ;
773  outfile << " \"name\" : \"Path-Rejected\"," ;
774  outfile << " \"type\" : \"integer\"," ;
775  outfile << " \"operation\" : \"histo\"}," << std::endl;
776 
777  outfile << " {" ;
778  outfile << " \"name\" : \"Path-Errors\"," ;
779  outfile << " \"type\" : \"integer\"," ;
780  outfile << " \"operation\" : \"histo\"}," << std::endl;
781 
782  outfile << " {" ;
783  outfile << " \"name\" : \"Dataset-Accepted\"," ;
784  outfile << " \"type\" : \"integer\"," ;
785  outfile << " \"operation\" : \"histo\"}," << std::endl;
786 
787  outfile << " {" ;
788  outfile << " \"name\" : \"Prescale-Index\"," ;
789  outfile << " \"type\" : \"integer\"," ;
790  outfile << " \"operation\" : \"sample\"}" << std::endl;
791 
792  outfile << " ]" << std::endl;
793  outfile << "}" << std::endl;
794 
795  outfile.close();
796 }//End writeDefJson function
797 
798 
799 void
801 
802  std::ofstream outfile( path );
803  outfile << "{" << std::endl;
804  outfile << " \"data\" : [" << std::endl;
805  outfile << " {" ;
806  outfile << " \"name\" : \"Processed\"," ;
807  outfile << " \"type\" : \"integer\"," ;
808  outfile << " \"operation\" : \"histo\"}," << std::endl;
809 
810  outfile << " {" ;
811  outfile << " \"name\" : \"L1-AlgoAccepted\"," ;
812  outfile << " \"type\" : \"integer\"," ;
813  outfile << " \"operation\" : \"histo\"}," << std::endl;
814 
815  outfile << " {" ;
816  outfile << " \"name\" : \"L1-TechAccepted\"," ;
817  outfile << " \"type\" : \"integer\"," ;
818  outfile << " \"operation\" : \"histo\"}," << std::endl;
819 
820  outfile << " {" ;
821  outfile << " \"name\" : \"L1-AlgoAccepted-Physics\"," ;
822  outfile << " \"type\" : \"integer\"," ;
823  outfile << " \"operation\" : \"histo\"}," << std::endl;
824 
825  outfile << " {" ;
826  outfile << " \"name\" : \"L1-TechAccepted-Physics\"," ;
827  outfile << " \"type\" : \"integer\"," ;
828  outfile << " \"operation\" : \"histo\"}," << std::endl;
829 
830  outfile << " {" ;
831  outfile << " \"name\" : \"L1-AlgoAccepted-Calibration\"," ;
832  outfile << " \"type\" : \"integer\"," ;
833  outfile << " \"operation\" : \"histo\"}," << std::endl;
834 
835  outfile << " {" ;
836  outfile << " \"name\" : \"L1-TechAccepted-Calibration\"," ;
837  outfile << " \"type\" : \"integer\"," ;
838  outfile << " \"operation\" : \"histo\"}," << std::endl;
839 
840  outfile << " {" ;
841  outfile << " \"name\" : \"L1-AlgoAccepted-Random\"," ;
842  outfile << " \"type\" : \"integer\"," ;
843  outfile << " \"operation\" : \"histo\"}," << std::endl;
844 
845  outfile << " {" ;
846  outfile << " \"name\" : \"L1-TechAccepted-Random\"," ;
847  outfile << " \"type\" : \"integer\"," ;
848  outfile << " \"operation\" : \"histo\"}," << std::endl;
849 
850  outfile << " {" ;
851  outfile << " \"name\" : \"L1-Global\"," ;
852  outfile << " \"type\" : \"integer\"," ;
853  outfile << " \"operation\" : \"histo\"}" << std::endl;
854 
855  outfile << " ]" << std::endl;
856  outfile << "}" << std::endl;
857 
858  outfile.close();
859 }//End writeL1DefJson function
860 
#define LogDebug(id)
TriggerJSONMonitoring(const edm::ParameterSet &)
int i
Definition: DBlmapReader.cc:9
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
jsoncollector::HistoJ< unsigned int > * hltPre
const std::string moduleType(const std::string &module) const
C++ class name of module.
RunNumber_t run() const
Definition: RunBase.h:40
static std::shared_ptr< trigJson::lumiVars > globalBeginLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
jsoncollector::HistoJ< unsigned int > * processed
jsoncollector::HistoJ< unsigned int > * hltDatasets
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
std::vector< unsigned int > hltDatasets_
jsoncollector::HistoJ< unsigned int > * L1TechAccept
std::vector< unsigned int > L1AlgoAccept_
static void globalEndLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, trigJson::lumiVars *)
const std::vector< std::string > & triggerNames() const
names of trigger paths
std::vector< unsigned int > L1AlgoAcceptPhysics_
bool shouldWriteFiles(unsigned int lumi, unsigned int *proc=0)
jsoncollector::HistoJ< unsigned int > * L1Global
Value & append(const Value &value)
Append value to array at the end.
void update(std::string const &newStr)
std::vector< unsigned int > hltErrors_
std::vector< unsigned int > L1TechAcceptRandom_
void beginRun(edm::Run const &, edm::EventSetup const &)
Represents a JSON value.
Definition: value.h:111
jsoncollector::HistoJ< unsigned int > * L1TechAcceptCalibration
edm::EDGetTokenT< GlobalAlgBlkBxCollection > m_l1t_results
std::vector< unsigned int > hltL1s_
std::vector< unsigned int > L1TechAcceptCalibration_
const L1GtTriggerMenu * m_l1GtMenu
std::vector< unsigned int > L1AlgoAcceptRandom_
virtual Json::Value toJsonValue() const
std::string encode() const
Definition: InputTag.cc:164
std::vector< std::vector< unsigned int > > hltIndex_
LuminosityBlockNumber_t luminosityBlock() const
std::vector< T > & value()
tuple result
Definition: mps_fire.py:84
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
jsoncollector::HistoJ< unsigned int > * L1AlgoAccept
triggerResultsToken_(consumes< edm::TriggerResults >(edm::InputTag("TriggerResults")))
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)
tuple d
Definition: ztail.py:151
int iEvent
Definition: GenABIO.cc:230
jsoncollector::HistoJ< unsigned int > * L1AlgoAcceptRandom
const std::vector< unsigned int > & gtTriggerMask() const
get the trigger mask
std::vector< std::string > hltNames_
HLTConfigProvider hltConfig_
jsoncollector::HistoJ< unsigned int > * L1AlgoAcceptPhysics
std::string streamHLTDestination
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_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
jsoncollector::HistoJ< unsigned int > * L1TechAcceptRandom
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
jsoncollector::HistoJ< unsigned int > * hltWasRun
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
EventAuxiliary const & eventAuxiliary() const
Definition: Event.h:77
jsoncollector::HistoJ< unsigned int > * hltErrors
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:56
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:40
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_
jsoncollector::HistoJ< unsigned int > * hltL1s
jsoncollector::HistoJ< unsigned int > * hltReject
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:64
const AlgorithmMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
std::vector< unsigned int > L1TechAcceptPhysics_
jsoncollector::HistoJ< unsigned int > * hltAccept
std::vector< std::string > L1TechNames_
std::vector< unsigned int > L1AlgoAcceptCalibration_
const AlgorithmMap & gtTechnicalTriggerMap() const
get / set the technical trigger map
void analyze(edm::Event const &, edm::EventSetup const &)
jsoncollector::HistoJ< unsigned int > * L1TechAcceptPhysics
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:65
void writeL1DefJson(std::string path)
tuple size
Write out results.
Definition: Run.h:43
const std::vector< std::string > & datasetNames() const
std::vector< unsigned int > hltPre_
string SOURCE
Definition: runonSM.py:23
jsoncollector::HistoJ< unsigned int > * L1AlgoAcceptCalibration
array value (ordered list)
Definition: value.h:31
void endLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, trigJson::lumiVars *) const