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