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" << 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" << 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" << 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" << 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  }
428 
429  else{
430  iSummary->processed->value().at(0) += processed_;
431 
432  for (unsigned int ui = 0; ui < hltWasRun_.size(); ui++){
433  iSummary->hltWasRun->value().at(ui) += hltWasRun_.at(ui);
434  iSummary->hltL1s ->value().at(ui) += hltL1s_ .at(ui);
435  iSummary->hltPre ->value().at(ui) += hltPre_ .at(ui);
436  iSummary->hltAccept->value().at(ui) += hltAccept_.at(ui);
437  iSummary->hltReject->value().at(ui) += hltReject_.at(ui);
438  iSummary->hltErrors->value().at(ui) += hltErrors_.at(ui);
439  }
440  for (unsigned int ui = 0; ui < hltDatasets_.size(); ui++){
441  iSummary->hltDatasets->value().at(ui) += hltDatasets_.at(ui);
442  }
443  for (unsigned int ui = 0; ui < L1AlgoAccept_.size(); ui++){ //DS
444  iSummary->L1Accept->value().at(ui) += L1AlgoAccept_.at(ui);
445  }
446  for (unsigned int ui = 0; ui < L1TechAccept_.size(); ui++){ //DS
447  iSummary->L1TechAccept->value().at(ui) += L1TechAccept_.at(ui);
448  }
449  for (unsigned int ui = 0; ui < L1Global_.size(); ui++){ //DS
450  iSummary->L1Global->value().at(ui) += L1Global_.at(ui);
451  }
452 
453  }
454 
455 }//End endLuminosityBlockSummary function
456 
457 
458 void
460 {
461  if (iSummary->processed->value().at(0)!=0) {
462  Json::StyledWriter writer;
463 
464  char hostname[33];
465  gethostname(hostname,32);
466  std::string sourceHost(hostname);
467 
468  //Get the output directory
469  std::string monPath = iSummary->baseRunDir + "/";
470 
471  std::stringstream sOutDef;
472  sOutDef << monPath << "output_" << getpid() << ".jsd";
473 
474  unsigned int iLs = iLumi.luminosityBlock();
475  unsigned int iRun = iLumi.run();
476 
477  //Write the .jsndata files which contain the actual rates
478  //HLT .jsndata file
479  Json::Value hltJsnData;
480  hltJsnData[DataPoint::SOURCE] = sourceHost;
481  hltJsnData[DataPoint::DEFINITION] = iSummary->stHltJsd;
482 
483  hltJsnData[DataPoint::DATA].append(iSummary->processed->toJsonValue());
484  hltJsnData[DataPoint::DATA].append(iSummary->hltWasRun->toJsonValue());
485  hltJsnData[DataPoint::DATA].append(iSummary->hltL1s ->toJsonValue());
486  hltJsnData[DataPoint::DATA].append(iSummary->hltPre ->toJsonValue());
487  hltJsnData[DataPoint::DATA].append(iSummary->hltAccept->toJsonValue());
488  hltJsnData[DataPoint::DATA].append(iSummary->hltReject->toJsonValue());
489  hltJsnData[DataPoint::DATA].append(iSummary->hltErrors->toJsonValue());
490 
491  hltJsnData[DataPoint::DATA].append(iSummary->hltDatasets->toJsonValue());
492 
493  std::string && result = writer.write(hltJsnData);
494 
495  std::stringstream ssHltJsnData;
496  ssHltJsnData << "run" << iRun << "_ls" << std::setfill('0') << std::setw(4) << iLs;
497  ssHltJsnData << "_streamHLTRates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsndata";
498 
499  std::ofstream outHltJsnData( monPath + ssHltJsnData.str() );
500  outHltJsnData<<result;
501  outHltJsnData.close();
502 
503  //L1 .jsndata file
504  Json::Value l1JsnData;
505  l1JsnData[DataPoint::SOURCE] = sourceHost;
506  l1JsnData[DataPoint::DEFINITION] = iSummary->stL1Jsd;
507 
508  l1JsnData[DataPoint::DATA].append(iSummary->processed->toJsonValue());
509  l1JsnData[DataPoint::DATA].append(iSummary->L1Accept ->toJsonValue());
510  l1JsnData[DataPoint::DATA].append(iSummary->L1TechAccept ->toJsonValue()); //DS
511  l1JsnData[DataPoint::DATA].append(iSummary->L1Global ->toJsonValue()); //DS
512  result = writer.write(l1JsnData);
513 
514  std::stringstream ssL1JsnData;
515  ssL1JsnData << "run" << iRun << "_ls" << std::setfill('0') << std::setw(4) << iLs;
516  ssL1JsnData << "_streamL1Rates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsndata";
517 
518  std::ofstream outL1JsnData( monPath + "/" + ssL1JsnData.str() );
519  outL1JsnData<<result;
520  outL1JsnData.close();
521 
522  //Create special DAQ JSON file for L1 and HLT rates pseudo-streams
523  //Only three variables are different between the files:
524  //the file list, the file size and the Adler32 value
525  IntJ daqJsnProcessed_ = iSummary->processed->value().at(0);
526  IntJ daqJsnAccepted_ = daqJsnProcessed_;
527  IntJ daqJsnErrorEvents_ = 0;
528  IntJ daqJsnRetCodeMask_ = 0;
529 
530  struct stat st;
531 
532  //HLT
533  StringJ hltJsnFilelist_;
534  hltJsnFilelist_.update(ssHltJsnData.str());
535 
536  const char* cName = (monPath+ssHltJsnData.str()).c_str();
537  stat(cName, &st);
538 
539  IntJ hltJsnFilesize_ = st.st_size;
540  StringJ hltJsnInputFiles_;
541  hltJsnInputFiles_.update("");
542  IntJ hltJsnFileAdler32_ = cms::Adler32(cName, st.st_size);
543 
544  Json::Value hltDaqJsn;
545  hltDaqJsn[DataPoint::SOURCE] = sourceHost;
546  hltDaqJsn[DataPoint::DEFINITION] = sOutDef.str();
547 
548  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnProcessed_.value());
549  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnAccepted_.value());
550  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnErrorEvents_.value());
551  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnRetCodeMask_.value());
552  hltDaqJsn[DataPoint::DATA].append(hltJsnFilelist_.value());
553  hltDaqJsn[DataPoint::DATA].append((unsigned int)hltJsnFilesize_.value());
554  hltDaqJsn[DataPoint::DATA].append(hltJsnInputFiles_.value());
555  hltDaqJsn[DataPoint::DATA].append((unsigned int)hltJsnFileAdler32_.value());
556 
557  result = writer.write(hltDaqJsn);
558 
559  std::stringstream ssHltDaqJsn;
560  ssHltDaqJsn << "run" << iRun << "_ls" << std::setfill('0') << std::setw(4) << iLs;
561  ssHltDaqJsn << "_streamHLTRates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsn";
562 
563  std::ofstream outHltDaqJsn( monPath + ssHltDaqJsn.str() );
564  outHltDaqJsn<<result;
565  outHltDaqJsn.close();
566 
567  //L1
568  StringJ l1JsnFilelist_;
569  l1JsnFilelist_.update(ssL1JsnData.str());
570 
571  cName = (monPath+ssL1JsnData.str()).c_str();
572  stat(cName, &st);
573 
574  IntJ l1JsnFilesize_ = st.st_size;
575  StringJ l1JsnInputFiles_;
576  l1JsnInputFiles_.update("");
577  IntJ l1JsnFileAdler32_ = cms::Adler32(cName, st.st_size);
578 
579  Json::Value l1DaqJsn;
580  l1DaqJsn[DataPoint::SOURCE] = sourceHost;
581  l1DaqJsn[DataPoint::DEFINITION] = sOutDef.str();
582 
583  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnProcessed_.value());
584  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnAccepted_.value());
585  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnErrorEvents_.value());
586  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnRetCodeMask_.value());
587  l1DaqJsn[DataPoint::DATA].append(l1JsnFilelist_.value());
588  l1DaqJsn[DataPoint::DATA].append((unsigned int)l1JsnFilesize_.value());
589  l1DaqJsn[DataPoint::DATA].append(l1JsnInputFiles_.value());
590  l1DaqJsn[DataPoint::DATA].append((unsigned int)l1JsnFileAdler32_.value());
591 
592  result = writer.write(l1DaqJsn);
593 
594  std::stringstream ssL1DaqJsn;
595  ssL1DaqJsn << "run" << iRun << "_ls" << std::setfill('0') << std::setw(4) << iLs;
596  ssL1DaqJsn << "_streamL1Rates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsn";
597 
598  std::ofstream outL1DaqJsn( monPath + ssL1DaqJsn.str() );
599  outL1DaqJsn<<result;
600  outL1DaqJsn.close();
601  }
602 
603  //Delete the individual HistoJ pointers
604  delete iSummary->processed;
605 
606  delete iSummary->hltWasRun;
607  delete iSummary->hltL1s ;
608  delete iSummary->hltPre ;
609  delete iSummary->hltAccept;
610  delete iSummary->hltReject;
611  delete iSummary->hltErrors;
612 
613  delete iSummary->hltDatasets;
614 
615  delete iSummary->L1Accept; //DS
616  delete iSummary->L1TechAccept; //DS
617  delete iSummary->L1Global; //DS
618 
619  //Note: Do not delete the iSummary pointer. The framework does something with it later on
620  // and deleting it results in a segmentation fault.
621 
622 }//End globalEndLuminosityBlockSummary function
623 
624 
625 void
627 
628  std::ofstream outfile( path );
629  outfile << "{" << std::endl;
630  outfile << " \"data\" : [" << std::endl;
631  outfile << " {" ;
632  outfile << " \"name\" : \"Processed\"," ; //***
633  outfile << " \"type\" : \"integer\"," ;
634  outfile << " \"operation\" : \"histo\"}," << std::endl;
635 
636  outfile << " {" ;
637  outfile << " \"name\" : \"Path-WasRun\"," ;
638  outfile << " \"type\" : \"integer\"," ;
639  outfile << " \"operation\" : \"histo\"}," << std::endl;
640 
641  outfile << " {" ;
642  outfile << " \"name\" : \"Path-AfterL1Seed\"," ;
643  outfile << " \"type\" : \"integer\"," ;
644  outfile << " \"operation\" : \"histo\"}," << std::endl;
645 
646  outfile << " {" ;
647  outfile << " \"name\" : \"Path-AfterPrescale\"," ;
648  outfile << " \"type\" : \"integer\"," ;
649  outfile << " \"operation\" : \"histo\"}," << std::endl;
650 
651  outfile << " {" ;
652  outfile << " \"name\" : \"Path-Accepted\"," ;
653  outfile << " \"type\" : \"integer\"," ;
654  outfile << " \"operation\" : \"histo\"}," << std::endl;
655 
656  outfile << " {" ;
657  outfile << " \"name\" : \"Path-Rejected\"," ;
658  outfile << " \"type\" : \"integer\"," ;
659  outfile << " \"operation\" : \"histo\"}," << std::endl;
660 
661  outfile << " {" ;
662  outfile << " \"name\" : \"Path-Errors\"," ;
663  outfile << " \"type\" : \"integer\"," ;
664  outfile << " \"operation\" : \"histo\"}," << std::endl;
665 
666  outfile << " {" ;
667  outfile << " \"name\" : \"Dataset-Accepted\"," ;
668  outfile << " \"type\" : \"integer\"," ;
669  outfile << " \"operation\" : \"histo\"}" << std::endl;
670 
671  outfile << " ]" << std::endl;
672  outfile << "}" << std::endl;
673 
674  outfile.close();
675 }//End writeDefJson function
676 
677 
678 void
680 
681  std::ofstream outfile( path );
682  outfile << "{" << std::endl;
683  outfile << " \"data\" : [" << std::endl;
684  outfile << " {" ;
685  outfile << " \"name\" : \"Processed\"," ;
686  outfile << " \"type\" : \"integer\"," ;
687  outfile << " \"operation\" : \"histo\"}," << std::endl;
688 
689  outfile << " {" ;
690  outfile << " \"name\" : \"L1-Accepted\"," ;
691  outfile << " \"type\" : \"integer\"," ;
692  outfile << " \"operation\" : \"histo\"}," << std::endl;
693 
694  outfile << " {" ;
695  outfile << " \"name\" : \"L1-TechAccepted\"," ;
696  outfile << " \"type\" : \"integer\"," ;
697  outfile << " \"operation\" : \"histo\"}," << std::endl;
698 
699  outfile << " {" ;
700  outfile << " \"name\" : \"L1-Global\"," ;
701  outfile << " \"type\" : \"integer\"," ;
702  outfile << " \"operation\" : \"histo\"}" << std::endl;
703 
704  outfile << " ]" << std::endl;
705  outfile << "}" << std::endl;
706 
707  outfile.close();
708 }//End writeL1DefJson function
709 
#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:446
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)
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)
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:61
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