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 }
HLTScalers::dqmBeginRun
void dqmBeginRun(const edm::Run &run, const edm::EventSetup &c) override
Definition: HLTScalers.cc:101
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
trigNames
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:57
HLTScalers::hltCorrelations_
MonitorElement * hltCorrelations_
Definition: HLTScalers.h:89
TriggerResults.h
PDWG_DiJetAODSkim_cff.hltResults
hltResults
Definition: PDWG_DiJetAODSkim_cff.py:7
HLTScalers::scalersException_
MonitorElement * scalersException_
Definition: HLTScalers.h:88
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
HLTScalers::hltConfig_
HLTConfigProvider hltConfig_
Definition: HLTScalers.h:79
LuminosityBlock.h
edm
HLT enums.
Definition: AlignableModifier.h:19
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
HLTScalers::nLumiBlock_
MonitorElement * nLumiBlock_
Definition: HLTScalers.h:92
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
DQMStore.h
HLTScalers::beginLuminosityBlock
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
Definition: HLTScalers.cc:171
HLTScalers::hltOverallScalerN_
MonitorElement * hltOverallScalerN_
Definition: HLTScalers.h:95
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
HLTScalers.h
edm::Handle
Definition: AssociativeIterator.h:50
HLTScalers::folderName_
std::string folderName_
Definition: HLTScalers.h:80
HLTScalers::hltBx_
MonitorElement * hltBx_
Definition: HLTScalers.h:93
HLTScalers::sentPaths_
bool sentPaths_
Definition: HLTScalers.h:98
accept
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
Service.h
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
HLTScalers::nProc_
MonitorElement * nProc_
Definition: HLTScalers.h:91
dqm::impl::MonitorElement::Reset
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
Definition: MonitorElement.cc:354
Run.h
Pass
Definition: hltDiff.cc:243
HLTScalers::trigResultsSource_
edm::EDGetTokenT< edm::TriggerResults > trigResultsSource_
Definition: HLTScalers.h:83
HLTScalers::scalersPD_
MonitorElement * scalersPD_
Definition: HLTScalers.h:85
HLTScalers::pairPDPaths_
std::vector< std::pair< std::string, std::vector< std::string > > > pairPDPaths_
Definition: HLTScalers.h:82
b
double b
Definition: hdecay.h:118
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
dqm::impl::MonitorElement::getTH1
virtual TH1 * getTH1()
Definition: MonitorElement.cc:981
HLTScalers::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: HLTScalers.cc:180
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLTScalers::dqmEndRun
void dqmEndRun(const edm::Run &run, const edm::EventSetup &c) override
Definition: HLTScalers.cc:295
HLTConfigProvider::size
unsigned int size() const
number of trigger paths in trigger table
Definition: HLTConfigProvider.h:63
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
HLTScalers::nev_
int nev_
Definition: HLTScalers.h:100
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
dqm::implementation::IBooker::bookInt
MonitorElement * bookInt(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:73
HLTScalers::processname_
std::string processname_
Definition: HLTScalers.h:81
TriggerNames.h
edm::LuminosityBlockID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockID.h:42
HLTScalers::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: HLTScalers.cc:135
edm::LuminosityBlockBase::id
LuminosityBlockID id() const
Definition: LuminosityBlockBase.h:44
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
HLTConfigProvider::streamNames
const std::vector< std::string > & streamNames() const
Definition: HLTConfigProvider.h:149
HLTScalers::hltOverallScaler_
MonitorElement * hltOverallScaler_
Definition: HLTScalers.h:94
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
HLTScalers::scalersN_
MonitorElement * scalersN_
Definition: HLTScalers.h:87
HLTConfigProvider::streamContent
const std::vector< std::string > & streamContent(unsigned int stream) const
names of datasets in stream with index i
Definition: HLTConfigProvider.h:157
HLTScalers::HLTScalers
HLTScalers(const edm::ParameterSet &ps)
Definition: HLTScalers.cc:78
HLTScalers::detailedScalers_
MonitorElement * detailedScalers_
Definition: HLTScalers.h:90
edm::EDConsumerBase::labelsForToken
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
Definition: EDConsumerBase.cc:338
HLTScalers::scalers_
MonitorElement * scalers_
Definition: HLTScalers.h:86
dqm::impl::MonitorElement::setBinContent
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
Definition: MonitorElement.cc:691
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
HLTScalers::endLuminosityBlock
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
DQM Client Diagnostic should be performed here:
Definition: HLTScalers.cc:287
HLTConfigProvider::init
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
Definition: HLTConfigProvider.cc:36
dqm::implementation::IBooker::book2D
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:177
Exception
Definition: hltDiff.cc:245
edm::TriggerNames
Definition: TriggerNames.h:55
HLTConfigProvider::streamIndex
unsigned int streamIndex(const std::string &stream) const
index of stream with name
Definition: HLTConfigProvider.h:153
HLTConfigProvider::datasetContent
const std::vector< std::string > & datasetContent(unsigned int dataset) const
names of trigger paths in dataset with index i
Definition: HLTConfigProvider.h:175
dqm::implementation::IBooker
Definition: DQMStore.h:43
HLTenums.h
HLTScalers::diagnostic_
MonitorElement * diagnostic_
Definition: HLTScalers.h:96
ParameterSet.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
HLTScalers::hltBxVsPath_
MonitorElement * hltBxVsPath_
Definition: HLTScalers.h:93
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
edm::TriggerResults
Definition: TriggerResults.h:35
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
edm::ProductLabels
Definition: ProductLabels.h:4
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37