test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
SummaryOutputProducer Class Reference

Classes

struct  Event
 
struct  GenericSummary
 
struct  Pair
 
struct  TriggerSummary
 

Public Member Functions

 SummaryOutputProducer (const JsonOutputProducer &_json, bool _storeROOT, bool _storeCSV=true)
 
void write ()
 

Public Attributes

bool storeCSV
 
bool storeROOT
 

Private Member Functions

void prepareSummaries (const int _run, const std::vector< JsonOutputProducer::JsonEvent > &_events)
 
std::string writeCSV_module () const
 
std::string writeCSV_trigger () const
 
std::string writeHistograms () const
 

Private Attributes

const JsonOutputProducerjson
 
std::map< int, GenericSummarym_moduleSummary
 
std::map< int, TriggerSummarym_triggerSummary
 
int run
 

Detailed Description

Definition at line 811 of file hltDiff.cc.

Constructor & Destructor Documentation

SummaryOutputProducer::SummaryOutputProducer ( const JsonOutputProducer _json,
bool  _storeROOT,
bool  _storeCSV = true 
)
inline

Definition at line 1134 of file hltDiff.cc.

1134  :
1135  json(_json),
1136  run(-1),
1137  storeROOT(_storeROOT),
1138  storeCSV(_storeCSV) {}
const JsonOutputProducer & json
Definition: hltDiff.cc:814

Member Function Documentation

void SummaryOutputProducer::prepareSummaries ( const int  _run,
const std::vector< JsonOutputProducer::JsonEvent > &  _events 
)
inlineprivate

Definition at line 942 of file hltDiff.cc.

References event(), Fail, i, L1Trigger_dataformats::json, JsonOutputProducer::JsonEventState::l, JsonOutputProducer::JsonTriggerEventState::n, JsonOutputProducer::JsonTriggerEventState::o, DTTTrigCorrFirst::run, JsonOutputProducer::JsonEventState::s, and JsonOutputProducer::JsonTriggerEventState::tr.

942  {
943  this->run = _run;
944  // Initialising the summary objects for trigger/module
945  m_triggerSummary.clear();
946  m_moduleSummary.clear();
947  const size_t nTriggers( json.vars.trigger.size() );
948  const size_t nModules( json.vars.label.size() );
949  for (size_t i=0; i<nTriggers; ++i)
950  m_triggerSummary.emplace(i, TriggerSummary(i, json) );
951  for (size_t i=0; i<nModules; ++i)
952  m_moduleSummary.emplace(i, GenericSummary(i, json, json.vars.label) );
953 
954  // Add each affected trigger in each event to the trigger/module summary objects
955  for (const JsonOutputProducer::JsonEvent& event : _events) {
956  for (size_t iTrigger = 0; iTrigger < event.triggerStates.size(); ++iTrigger) {
957  const JsonOutputProducer::JsonTriggerEventState& state = event.triggerStates.at(iTrigger);
958  m_triggerSummary.at(state.tr).addEntry(event, iTrigger, json.vars.label);
959  const int moduleId = state.o.s == State::Fail ? state.o.l : state.n.l;
960  m_moduleSummary.at(moduleId).addEntry(event, iTrigger);
961  }
962  }
963  }
int i
Definition: DBlmapReader.cc:9
const JsonOutputProducer & json
Definition: hltDiff.cc:814
std::vector< std::string > label
Definition: hltDiff.cc:615
std::map< int, GenericSummary > m_moduleSummary
Definition: hltDiff.cc:940
std::map< int, TriggerSummary > m_triggerSummary
Definition: hltDiff.cc:939
std::vector< std::string > trigger
Definition: hltDiff.cc:613
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
Definition: hltDiff.cc:289
void SummaryOutputProducer::write ( )
inline

Definition at line 1140 of file hltDiff.cc.

References lut2db_cfg::filename, L1Trigger_dataformats::json, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by HltDiff::compare().

1140  {
1141  std::vector<std::string> filesCreated;
1142  // Processing every run from the JSON producer
1143  for (const auto& runEvents : json.m_run_events) {
1144  prepareSummaries(runEvents.first, runEvents.second);
1145  if (storeROOT)
1146  filesCreated.push_back(writeHistograms());
1147  if (storeCSV) {
1148  filesCreated.push_back(writeCSV_trigger());
1149  filesCreated.push_back(writeCSV_module());
1150  }
1151  }
1152 
1153  printf("Created the following summary files:\n");
1154  for (const std::string& filename : filesCreated)
1155  printf(" %s\n", filename.c_str());
1156  }
std::map< int, std::vector< JsonEvent > > m_run_events
Definition: hltDiff.cc:740
const JsonOutputProducer & json
Definition: hltDiff.cc:814
std::string writeCSV_module() const
Definition: hltDiff.cc:1114
void prepareSummaries(const int _run, const std::vector< JsonOutputProducer::JsonEvent > &_events)
Definition: hltDiff.cc:942
std::string writeHistograms() const
Definition: hltDiff.cc:965
tuple filename
Definition: lut2db_cfg.py:20
std::string writeCSV_trigger() const
Definition: hltDiff.cc:1098
std::string SummaryOutputProducer::writeCSV_module ( ) const
inlineprivate

Definition at line 1114 of file hltDiff.cc.

References SummaryOutputProducer::GenericSummary::changed(), cmsHarvester::file_name, SummaryOutputProducer::GenericSummary::gained(), L1Trigger_dataformats::json, SummaryOutputProducer::GenericSummary::lost(), SummaryOutputProducer::GenericSummary::name, DTTTrigCorrFirst::run, S(), AlCaHLTBitMon_QueryRunRegistry::string, and SummaryOutputProducer::Pair::v.

1114  {
1115  std::string file_name = json.output_filename_base(this->run)+="_module.csv";
1116  FILE* out_file = fopen((file_name).c_str(), "w");
1117 
1118  fprintf(out_file,"Total,Gained,Lost,Changed,module\n");
1119  for (const auto& idSummary : m_moduleSummary) {
1120  const SummaryOutputProducer::GenericSummary& S = idSummary.second;
1121  fprintf(out_file, "%d,+%.f,-%.f,~%.f,%s\n",
1122  this->json.configuration.events, S.gained().v, S.lost().v, S.changed().v, S.name.c_str());
1123  }
1124 
1125  fclose(out_file);
1126 
1127  return file_name;
1128  }
const JsonOutputProducer & json
Definition: hltDiff.cc:814
std::map< int, GenericSummary > m_moduleSummary
Definition: hltDiff.cc:940
std::string output_filename_base(int _run) const
Definition: hltDiff.cc:768
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
JsonConfiguration configuration
Definition: hltDiff.cc:641
std::string SummaryOutputProducer::writeCSV_trigger ( ) const
inlineprivate

Definition at line 1098 of file hltDiff.cc.

References SummaryOutputProducer::TriggerSummary::accepted_n, SummaryOutputProducer::TriggerSummary::accepted_o, SummaryOutputProducer::TriggerSummary::changed(), SummaryOutputProducer::Pair::e, cmsHarvester::file_name, SummaryOutputProducer::TriggerSummary::gained(), L1Trigger_dataformats::json, SummaryOutputProducer::TriggerSummary::lost(), SummaryOutputProducer::GenericSummary::name, DTTTrigCorrFirst::run, S(), AlCaHLTBitMon_QueryRunRegistry::string, and SummaryOutputProducer::Pair::v.

1098  {
1099  std::string file_name = json.output_filename_base(this->run)+="_trigger.csv";
1100  FILE* out_file = fopen((file_name).c_str(), "w");
1101 
1102  fprintf(out_file,"Total,Accepted OLD,Accepted NEW,Gained,Lost,|G|/A_N + |L|/AO,sigma(AN)+sigma(AO),Changed,C/(T-AO),sigma(T-AO),trigger\n");
1103  for (const auto& idSummary : m_triggerSummary) {
1104  const SummaryOutputProducer::TriggerSummary& S = idSummary.second;
1105  fprintf(out_file, "%d,%d,%d,%+.f,%+.f,%.2f%%,%.2f%%,~%.f,~%.2f%%,%.2f%%,%s\n",
1106  this->json.configuration.events, S.accepted_o, S.accepted_n, S.gained().v, -1.0*S.lost().v, (S.gained(1).v+S.lost(1).v)*100.0, (S.gained(1).e+S.lost(1).e)*100.0, S.changed().v, S.changed(1).v*100.0, S.changed(1).e*100.0, S.name.c_str());
1107  }
1108 
1109  fclose(out_file);
1110 
1111  return file_name;
1112  }
Pair gained(int type=0) const
Definition: hltDiff.cc:907
const JsonOutputProducer & json
Definition: hltDiff.cc:814
Pair changed(int type=0) const
Definition: hltDiff.cc:927
std::string output_filename_base(int _run) const
Definition: hltDiff.cc:768
std::map< int, TriggerSummary > m_triggerSummary
Definition: hltDiff.cc:939
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
Pair lost(int type=0) const
Definition: hltDiff.cc:917
JsonConfiguration configuration
Definition: hltDiff.cc:641
std::string SummaryOutputProducer::writeHistograms ( ) const
inlineprivate

Definition at line 965 of file hltDiff.cc.

References SummaryOutputProducer::TriggerSummary::accepted_o, newFWLiteAna::bin, SummaryOutputProducer::GenericSummary::changed(), SummaryOutputProducer::TriggerSummary::changed(), SummaryOutputProducer::Pair::e, cmsHarvester::file_name, SummaryOutputProducer::GenericSummary::gained(), SummaryOutputProducer::TriggerSummary::gained(), timingPdfMaker::histo, L1Trigger_dataformats::json, SummaryOutputProducer::GenericSummary::keepForC(), SummaryOutputProducer::GenericSummary::keepForGL(), SummaryOutputProducer::GenericSummary::lost(), SummaryOutputProducer::TriggerSummary::lost(), mergeVDriftHistosByStation::name, SummaryOutputProducer::GenericSummary::name, DTTTrigCorrFirst::run, AlCaHLTBitMon_QueryRunRegistry::string, edmLumisInFiles::summary, and SummaryOutputProducer::Pair::v.

965  {
966  std::map<std::string, TH1*> m_histo;
967  // Counting the numbers of bins for different types of histograms
968  // *_c - changed; *_gl - gained or lost
969  int nTriggers(0), nTriggers_c(0), nTriggers_gl(0), nModules_c(0), nModules_gl(0);
970 
971  for (const auto& idSummary : m_triggerSummary) {
972  if (idSummary.second.accepted_o > 0) ++nTriggers;
973  if (idSummary.second.keepForGL()) ++nTriggers_gl;
974  if (idSummary.second.keepForC()) ++nTriggers_c;
975  }
976  for (const auto& idSummary : m_moduleSummary) {
977  if (idSummary.second.keepForGL()) ++nModules_gl;
978  if (idSummary.second.keepForC()) ++nModules_c;
979  }
980 
981  // Initialising overview histograms
982  std::string name = "trigger_accepted";
983  m_histo.emplace(name, new TH1F(name.c_str(), ";;Events accepted^{OLD}", nTriggers, 0, nTriggers));
984  name = "trigger_gained";
985  m_histo.emplace(name, new TH1F(name.c_str(), ";;Events gained", nTriggers_gl, 0, nTriggers_gl));
986  name = "trigger_lost";
987  m_histo.emplace(name, new TH1F(name.c_str(), ";;Events lost", nTriggers_gl, 0, nTriggers_gl));
988  name = "trigger_changed";
989  m_histo.emplace(name, new TH1F(name.c_str(), ";;Events changed", nTriggers_c, 0, nTriggers_c));
990  name = "trigger_gained_frac";
991  m_histo.emplace(name, new TH1F(name.c_str(), ";;#frac{gained}{accepted}", nTriggers_gl, 0, nTriggers_gl));
992  name = "trigger_lost_frac";
993  m_histo.emplace(name, new TH1F(name.c_str(), ";;#frac{lost}{accepted}", nTriggers_gl, 0, nTriggers_gl));
994  name = "trigger_changed_frac";
995  m_histo.emplace(name, new TH1F(name.c_str(), ";;#frac{changed}{all - accepted}", nTriggers_c, 0, nTriggers_c));
996  name = "module_changed";
997  m_histo.emplace(name, new TH1F(name.c_str(), ";;Events changed", nModules_c, 0, nModules_c));
998  name = "module_gained";
999  m_histo.emplace(name, new TH1F(name.c_str(), ";;Events gained", nModules_gl, 0, nModules_gl));
1000  name = "module_lost";
1001  m_histo.emplace(name, new TH1F(name.c_str(), ";;Events lost", nModules_gl, 0, nModules_gl));
1002 
1003  // Filling the per-trigger bins in the summary histograms
1004  size_t bin(0), bin_c(0), bin_gl(0);
1005  for (const auto& idSummary : m_triggerSummary) {
1006  const TriggerSummary& summary = idSummary.second;
1007  if (summary.accepted_o > 0) {
1008  ++bin;
1009  // Setting bin contents
1010  m_histo.at("trigger_accepted")->SetBinContent(bin, summary.accepted_o);
1011  // Setting bin labels
1012  m_histo.at("trigger_accepted")->GetXaxis()->SetBinLabel(bin, summary.name.c_str());
1013  }
1014  if (summary.keepForGL()) {
1015  ++bin_gl;
1016  // Setting bin contents
1017  m_histo.at("trigger_gained")->SetBinContent(bin_gl, summary.gained().v);
1018  m_histo.at("trigger_lost")->SetBinContent(bin_gl, -summary.lost().v);
1019  m_histo.at("trigger_gained_frac")->SetBinContent(bin_gl, summary.gained(1).v);
1020  m_histo.at("trigger_lost_frac")->SetBinContent(bin_gl, -summary.lost(1).v);
1021  // Setting bin errors
1022  m_histo.at("trigger_gained_frac")->SetBinError(bin_gl, summary.gained(1).e);
1023  m_histo.at("trigger_lost_frac")->SetBinError(bin_gl, -summary.lost(1).e);
1024  // Setting bin labels
1025  m_histo.at("trigger_gained")->GetXaxis()->SetBinLabel(bin_gl, summary.name.c_str());
1026  m_histo.at("trigger_lost")->GetXaxis()->SetBinLabel(bin_gl, summary.name.c_str());
1027  m_histo.at("trigger_gained_frac")->GetXaxis()->SetBinLabel(bin_gl, summary.name.c_str());
1028  m_histo.at("trigger_lost_frac")->GetXaxis()->SetBinLabel(bin_gl, summary.name.c_str());
1029  }
1030  if (summary.keepForC()) {
1031  ++bin_c;
1032  // Setting bin contents
1033  m_histo.at("trigger_changed")->SetBinContent(bin_c, summary.changed().v);
1034  m_histo.at("trigger_changed_frac")->SetBinContent(bin_c, summary.changed(1).v);
1035  // Setting bin errors
1036  m_histo.at("trigger_changed_frac")->SetBinError(bin_c, summary.changed(1).e);
1037  // Setting bin labels
1038  m_histo.at("trigger_changed")->GetXaxis()->SetBinLabel(bin_c, summary.name.c_str());
1039  m_histo.at("trigger_changed_frac")->GetXaxis()->SetBinLabel(bin_c, summary.name.c_str());
1040  }
1041  }
1042 
1043  // Filling the per-module bins in the summary histograms
1044  bin = 0;
1045  bin_c = 0;
1046  bin_gl = 0;
1047  for (const auto& idSummary : m_moduleSummary) {
1048  ++bin;
1049  const GenericSummary& summary = idSummary.second;
1050  if (summary.keepForGL()) {
1051  ++bin_gl;
1052  // Setting bin contents
1053  m_histo.at("module_gained")->SetBinContent(bin_gl, summary.gained().v);
1054  m_histo.at("module_lost")->SetBinContent(bin_gl, -summary.lost().v);
1055  // Setting bin labels
1056  m_histo.at("module_gained")->GetXaxis()->SetBinLabel(bin_gl, summary.name.c_str());
1057  m_histo.at("module_lost")->GetXaxis()->SetBinLabel(bin_gl, summary.name.c_str());
1058  }
1059  if (summary.keepForC()) {
1060  ++bin_c;
1061  // Setting bin contents
1062  m_histo.at("module_changed")->SetBinContent(bin_c, summary.changed().v);
1063  // Setting bin labels
1064  m_histo.at("module_changed")->GetXaxis()->SetBinLabel(bin_c, summary.name.c_str());
1065  }
1066  }
1067 
1068  // Styling the histograms
1069  for (const auto& nameHisto : m_histo) {
1070  const std::string name = nameHisto.first;
1071  TH1* histo = nameHisto.second;
1072  if (name.find("gained") != std::string::npos || name.find("changed") != std::string::npos) {
1073  if (name.find("frac") != std::string::npos)
1074  histo->GetYaxis()->SetRangeUser(0.0, 1.0);
1075  }
1076  if (name.find("lost") != std::string::npos) {
1077  if (name.find("frac") != std::string::npos)
1078  histo->GetYaxis()->SetRangeUser(-1.0, 0.0);
1079  }
1080  }
1081 
1082  // Storing histograms to a ROOT file
1084  TFile* out_file = new TFile(file_name.c_str(), "RECREATE");
1085  // Storing the histograms is a proper folder according to the DQM convention
1086  char savePath[1000];
1087  sprintf(savePath, "DQMData/Run %d/HLT/Run summary/EventByEvent/", this->run);
1088  out_file->mkdir(savePath);
1089  gDirectory->cd(savePath);
1090  gDirectory->Write();
1091  for (const auto& nameHisto : m_histo)
1092  nameHisto.second->Write(nameHisto.first.c_str());
1093  out_file->Close();
1094 
1095  return file_name;
1096  }
const JsonOutputProducer & json
Definition: hltDiff.cc:814
std::map< int, GenericSummary > m_moduleSummary
Definition: hltDiff.cc:940
std::string output_filename_base(int _run) const
Definition: hltDiff.cc:768
std::map< int, TriggerSummary > m_triggerSummary
Definition: hltDiff.cc:939

Member Data Documentation

const JsonOutputProducer& SummaryOutputProducer::json
private

Definition at line 814 of file hltDiff.cc.

std::map<int, GenericSummary> SummaryOutputProducer::m_moduleSummary
private

Definition at line 940 of file hltDiff.cc.

std::map<int, TriggerSummary> SummaryOutputProducer::m_triggerSummary
private

Definition at line 939 of file hltDiff.cc.

int SummaryOutputProducer::run
private
bool SummaryOutputProducer::storeCSV

Definition at line 1132 of file hltDiff.cc.

bool SummaryOutputProducer::storeROOT

Definition at line 1131 of file hltDiff.cc.