CMS 3D CMS Logo

HLTScalers.cc
Go to the documentation of this file.
1 //
2 // Revision 1.30 2011/03/30 21:44:03 fwyzard
3 // make sure HLTConfigProvider is used only if succesfully initialized
4 //
5 // Revision 1.29 2011/03/30 21:35:40 fwyzard
6 // make sure all members are initialized
7 //
8 // Revision 1.28 2011/03/29 09:46:03 rekovic
9 // clean vector pairPDPaths in beginRun and tidy up
10 //
11 // Revision 1.27 2011/03/24 18:35:38 rekovic
12 // Change name for pd histo
13 //
14 // Revision 1.26 2011/03/24 18:25:45 rekovic
15 // Add single 1D plot of streamA content
16 //
17 // Revision 1.25 2010/07/20 02:58:27 wmtan
18 // Add missing #include files
19 //
20 // Revision 1.24 2010/03/17 20:54:51 wittich
21 // add scalers that I manually reset on beginLumi
22 //
23 // Revision 1.23 2010/02/25 17:34:01 wdd
24 // Central migration of TriggerNames class interface
25 //
26 // Revision 1.22 2010/02/24 17:43:47 wittich
27 // - keep trying to get path names if it doesn't work first time
28 // - move the Bx histograms out of raw to the toplevel directory.
29 //
30 // Revision 1.21 2010/02/11 23:54:28 wittich
31 // modify how the monitoring histo is filled
32 //
33 // Revision 1.20 2010/02/11 00:11:08 wmtan
34 // Adapt to moved framework header
35 //
36 // Revision 1.19 2010/02/02 13:53:05 wittich
37 // fix duplicate histogram name
38 //
39 // Revision 1.18 2010/02/02 11:42:53 wittich
40 // new diagnostic histograms
41 //
42 // Revision 1.17 2009/11/20 00:39:12 lorenzo
43 // fixes
44 //
45 // Revision 1.16 2008/09/03 13:59:06 wittich
46 // make HLT DQM path configurable via python parameter,
47 // which defaults to HLT/HLTScalers_EvF
48 //
49 // Revision 1.15 2008/09/03 02:13:47 wittich
50 // - bug fix in L1Scalers
51 // - configurable dqm directory in L1SCalers
52 // - other minor tweaks in HLTScalers
53 //
54 
55 #include <iostream>
56 
57 // FW
60 
63 
66 
67 // HLT
71 
75 
76 using namespace edm;
77 
79  : folderName_(ps.getUntrackedParameter<std::string>("dqmFolder", "HLT/HLTScalers_EvF")),
80  processname_(ps.getParameter<std::string>("processname")),
81  pairPDPaths_(),
82  trigResultsSource_(consumes<TriggerResults>(ps.getParameter<edm::InputTag>("triggerResults"))),
83  scalersN_(nullptr),
84  scalersException_(nullptr),
85  hltCorrelations_(nullptr),
86  detailedScalers_(nullptr),
87  nProc_(nullptr),
88  nLumiBlock_(nullptr),
89  hltBx_(nullptr),
90  hltBxVsPath_(nullptr),
91  hltOverallScaler_(nullptr),
92  hltOverallScalerN_(nullptr),
93  diagnostic_(nullptr),
94  sentPaths_(false),
95  monitorDaemon_(ps.getUntrackedParameter<bool>("MonitorDaemon", false)),
96  nev_(0),
97  nLumi_(0) {
98  LogDebug("HLTScalers") << "HLTScalers: constructor....";
99 }
100 
102  LogDebug("HLTScalers") << "HLTScalers::beginRun, run " << run.id();
103 
104  // HLT config does not change within runs!
105  bool changed = false;
106 
107  // clear vector pairPDPaths_
108  pairPDPaths_.clear();
109 
110  if (not hltConfig_.init(run, c, processname_, changed)) {
111  edm::LogError("TrigXMonitor") << "HLTConfigProvider failed to initialize.";
112  } else {
113  // check if trigger name in (new) config
114  // cout << "Available TriggerNames are: " << endl;
115  // hltConfig_.dump("Triggers");
116 
117  if (hltConfig_.streamIndex("A") < hltConfig_.streamNames().size()) {
118  // get hold of PD names and constituent path names
119  const std::vector<std::string>& PD = hltConfig_.streamContent("A");
120 
121  for (unsigned int i = 0; i < PD.size(); i++) {
122  const std::vector<std::string>& datasetPaths = hltConfig_.datasetContent(PD[i]);
123  pairPDPaths_.push_back(make_pair(PD[i], datasetPaths));
124  }
125 
126  // push stream A and its PDs
127  pairPDPaths_.push_back(make_pair("A", PD));
128 
129  } else {
130  LogDebug("HLTScalers") << "HLTScalers::beginRun, steamm A not in the HLT menu ";
131  }
132  }
133 }
134 
136  std::string rawdir(folderName_ + "/raw");
137  iBooker.setCurrentFolder(rawdir);
138 
139  nProc_ = iBooker.bookInt("nProcessed");
140  nLumiBlock_ = iBooker.bookInt("nLumiBlock");
141  diagnostic_ = iBooker.book1D("hltMerge", "HLT merging diagnostic", 1, 0.5, 1.5);
142  // fill for ever accepted event
143  hltOverallScaler_ = iBooker.book1D("hltOverallScaler", "HLT Overall Scaler", 1, 0.5, 1.5);
144  hltOverallScalerN_ = iBooker.book1D("hltOverallScalerN", "Reset HLT Overall Scaler", 1, 0.5, 1.5);
145 
146  // DQM: Previously the number of trigger paths was determined on the first
147  // event, by taking the size of the htlResults to book the histogram.
148  // Now we use the size of the hltConfig instead.
149  int npath = hltConfig_.size();
150  unsigned int nPD = pairPDPaths_.size();
151 
152  // need to get maxModules dynamically
153  int maxModules = 200;
154 
155  scalersPD_ = iBooker.book1D("pdScalers", "PD scalers (stream A)", nPD, -0.5, nPD - 0.5);
157  iBooker.book2D("detailedHltScalers", "HLT Scalers", npath, -0.5, npath - 0.5, maxModules, 0, maxModules - 1);
158  scalers_ = iBooker.book1D("hltScalers", "HLT scalers", npath, -0.5, npath - 0.5);
159  scalersN_ = iBooker.book1D("hltScalersN", "Reset HLT scalers", npath, -0.5, npath - 0.5);
160  scalersException_ = iBooker.book1D("hltExceptions", "HLT Exception scalers", npath, -0.5, npath - 0.5);
162  iBooker.book2D("hltCorrelations", "HLT Scalers", npath, -0.5, npath - 0.5, npath, -0.5, npath - 0.5);
163 
164  // these two belong in top-level
165  iBooker.setCurrentFolder(folderName_);
166  hltBxVsPath_ =
167  iBooker.book2D("hltBxVsPath", "HLT Accept vs Bunch Number", 3600, -0.5, 3599.5, npath, -0.5, npath - 0.5);
168  hltBx_ = iBooker.book1D("hltBx", "Bx of HLT Accepted Events ", 3600, -0.5, 3599.5);
169 }
170 
172  LogDebug("HLTScalers") << "Start of luminosity block.";
173  // reset the N guys
174  if (scalersN_)
175  scalersN_->Reset();
176  if (hltOverallScalerN_)
178 }
179 
181  nProc_->Fill(++nev_);
182  diagnostic_->setBinContent(1, 1); // this ME is never touched -
183  // it just tells you how the merging is doing.
184 
186  bool b = e.getByToken(trigResultsSource_, hltResults);
187  if (!b) {
188  Labels l;
190 
191  edm::LogInfo("HLTScalers") << "getByLabel for TriggerResults failed"
192  << " with label " << l.module;
193  return;
194  }
195  int npath = hltResults->size();
196  unsigned int nPD = pairPDPaths_.size();
198 
199  const edm::TriggerNames& trigNames = e.triggerNames(*hltResults);
200  // for some reason this doesn't appear to work on the first event sometimes
201  if (!sentPaths_) {
202  const edm::TriggerNames& names = e.triggerNames(*hltResults);
203 
204  // save path names in DQM-accessible format
205  int q = 0;
206  for (TriggerNames::Strings::const_iterator j = names.triggerNames().begin(); j != names.triggerNames().end(); ++j) {
207  LogDebug("HLTScalers") << q << ": " << *j;
208  ++q;
209  scalers_->getTH1()->GetXaxis()->SetBinLabel(q, j->c_str());
210  }
211 
212  for (unsigned int i = 0; i < nPD; i++) {
213  LogDebug("HLTScalers") << i << ": " << pairPDPaths_[i].first << std::endl;
214  scalersPD_->getTH1()->GetXaxis()->SetBinLabel(i + 1, pairPDPaths_[i].first.c_str());
215  }
216 
217  sentPaths_ = true;
218  }
219 
220  bool accept = false;
221  int bx = e.bunchCrossing();
222  for (int i = 0; i < npath; ++i) {
223  // state returns 0 on ready, 1 on accept, 2 on fail, 3 on exception.
224  // these are defined in HLTEnums.h
225  for (unsigned int j = 0; j < hltResults->index(i); ++j) {
227  }
228  if (hltResults->state(i) == hlt::Pass) {
229  scalers_->Fill(i);
230  scalersN_->Fill(i);
231  hltBxVsPath_->Fill(bx, i);
232  accept = true;
233  for (int j = i + 1; j < npath; ++j) {
234  if (hltResults->state(j) == hlt::Pass) {
235  hltCorrelations_->Fill(i, j); // fill
237  }
238  }
239  } else if (hltResults->state(i) == hlt::Exception) {
241  }
242  }
243  if (accept) {
244  hltOverallScaler_->Fill(1.0);
245  hltOverallScalerN_->Fill(1.0);
246  hltBx_->Fill(int(bx));
247  }
248 
249  bool anyGroupPassed = false;
250  for (unsigned int mi = 0; mi < pairPDPaths_.size(); mi++) {
251  bool groupPassed = false;
252 
253  for (unsigned int i = 0; i < pairPDPaths_[mi].second.size(); i++) {
254  // string hltPathName = hist_2d->GetXaxis()->GetBinLabel(i);
255  std::string hltPathName = pairPDPaths_[mi].second[i];
256 
257  // check if this is hlt path name
258  // unsigned int pathByIndex = triggerNames.triggerIndex(hltPathName);
259  unsigned int pathByIndex = trigNames.triggerIndex(pairPDPaths_[mi].second[i]);
260  if (pathByIndex >= hltResults->size())
261  continue;
262 
263  // check if its L1 passed
264  // comment out below but set groupL1Passed to true always
265  // if(hasL1Passed(hltPathName,triggerNames)) groupL1Passed = true;
266  // groupL1Passed = true;
267 
268  // Fill HLTPassed Matrix and HLTPassFail Matrix
269  // --------------------------------------------------------
270 
271  if (hltResults->accept(pathByIndex)) {
272  groupPassed = true;
273  break;
274  }
275  }
276 
277  if (groupPassed) {
278  scalersPD_->Fill(mi);
279  anyGroupPassed = true;
280  }
281  }
282 
283  if (anyGroupPassed)
284  scalersPD_->Fill(pairPDPaths_.size() - 1);
285 }
286 
288  // put this in as a first-pass for figuring out the rate
289  // each lumi block is 23 seconds in length
290  nLumiBlock_->Fill(lumiSeg.id().luminosityBlock());
291 
292  LogDebug("HLTScalers") << "End of luminosity block.";
293 }
294 
296  LogDebug("HLTScalers") << "HLTScalers::endRun , run " << run.id();
297 }
std::vector< std::pair< std::string, std::vector< std::string > > > pairPDPaths_
Definition: HLTScalers.h:82
LuminosityBlockNumber_t luminosityBlock() const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: HLTScalers.cc:135
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
Definition: hltDiff.cc:243
HLTScalers(const edm::ParameterSet &ps)
Definition: HLTScalers.cc:78
MonitorElement * scalersN_
Definition: HLTScalers.h:87
MonitorElement * detailedScalers_
Definition: HLTScalers.h:90
std::string processname_
Definition: HLTScalers.h:81
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
DQM Client Diagnostic should be performed here:
Definition: HLTScalers.cc:287
MonitorElement * hltOverallScaler_
Definition: HLTScalers.h:94
MonitorElement * scalers_
Definition: HLTScalers.h:86
Log< level::Error, false > LogError
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
MonitorElement * diagnostic_
Definition: HLTScalers.h:96
const std::string names[nVars_]
void Fill(long long x)
U second(std::pair< T, U > const &p)
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
MonitorElement * hltBxVsPath_
Definition: HLTScalers.h:93
unsigned int size() const
number of trigger paths in trigger table
void dqmBeginRun(const edm::Run &run, const edm::EventSetup &c) override
Definition: HLTScalers.cc:101
MonitorElement * hltCorrelations_
Definition: HLTScalers.h:89
HLTConfigProvider hltConfig_
Definition: HLTScalers.h:79
Log< level::Info, false > LogInfo
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:57
MonitorElement * scalersException_
Definition: HLTScalers.h:88
const std::vector< std::string > & streamContent(unsigned int stream) const
names of datasets in stream with index i
MonitorElement * nLumiBlock_
Definition: HLTScalers.h:92
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
LuminosityBlockID id() const
MonitorElement * hltOverallScalerN_
Definition: HLTScalers.h:95
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:221
MonitorElement * bookInt(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:73
double b
Definition: hdecay.h:120
const std::vector< std::string > & streamNames() const
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
Definition: HLTScalers.cc:171
unsigned int streamIndex(const std::string &stream) const
index of stream with name
bool sentPaths_
Definition: HLTScalers.h:98
HLT enums.
std::string folderName_
Definition: HLTScalers.h:80
MonitorElement * hltBx_
Definition: HLTScalers.h:93
MonitorElement * nProc_
Definition: HLTScalers.h:91
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MonitorElement * scalersPD_
Definition: HLTScalers.h:85
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: HLTScalers.cc:180
void dqmEndRun(const edm::Run &run, const edm::EventSetup &c) override
Definition: HLTScalers.cc:295
Definition: Run.h:45
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
#define LogDebug(id)
edm::EDGetTokenT< edm::TriggerResults > trigResultsSource_
Definition: HLTScalers.h:83
const std::vector< std::string > & datasetContent(unsigned int dataset) const
names of trigger paths in dataset with index i