CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
hltDiff.cc
Go to the documentation of this file.
1 /* hltDiff: compare TriggerResults event by event
2  *
3  * Compare two TriggerResults collections event by event.
4  * These can come from two collections in the same file(s), or from two different sets of files.
5  */
6 
7 #include <vector>
8 #include <string>
9 #include <sstream>
10 #include <iostream>
11 #include <iomanip>
12 #include <memory>
13 
14 #include <cstring>
15 #include <unistd.h>
16 #include <getopt.h>
17 
18 #include <boost/algorithm/string.hpp>
19 #include <boost/filesystem.hpp>
20 
21 #include <TFile.h>
22 
33 
34 
35 void usage(std::ostream & out) {
36  out << "\
37 usage: hltDiff -o|--old-files FILE1.ROOT [FILE2.ROOT ...] [-O|--old-process LABEL[:INSTANCE[:PROCESS]]]\n\
38  -n|--new-files FILE1.ROOT [FILE2.ROOT ...] [-N|--new-process LABEL[:INSTANCE[:PROCESS]]]\n\
39  [-m|--max-events MAXEVENTS] [-p|--prescales] [-q|--quiet] [-v|--verbose] [-h|--help]\n\
40 \n\
41  -o|--old-files FILE1.ROOT [FILE2.ROOT ...]\n\
42  input file(s) with the old (reference) trigger results.\n\
43 \n\
44  -O|--old-process PROCESS\n\
45  process name of the collection with the old (reference) trigger results;\n\
46  the default is to take the 'TriggerResults' from the last process.\n\
47 \n\
48  -n|--new-files FILE1.ROOT [FILE2.ROOT ...]\n\
49  input file(s) with the new trigger results to be compared with the reference;\n\
50  to read these from a different collection in the same files as\n\
51  the reference, use '-n -' and specify the collection with -N (see below).\n\
52 \n\
53  -N|--new-process PROCESS\n\
54  process name of the collection with the new (reference) trigger results;\n\
55  the default is to take the 'TriggerResults' from the last process.\n\
56 \n\
57  -m|--max-events MAXEVENTS\n\
58  compare only the first MAXEVENTS events;\n\
59  the default is to compare all the events in the original (reference) files.\n\
60 \n\
61  -p|--prescales\n\
62  do not ignore differences caused by HLTPrescaler modules.\n\
63 \n\
64  -q|--quiet\n\
65  suppress messages about missing events and collectiions.\n\
66 \n\
67  -v|--verbose\n\
68  be (more) verbose:\n\
69  use once to print event-by-event comparison results;\n\
70  use twice to print the trigger candidates of the affected filters;\n\
71  use three times to print all the trigger candidates for the affected events.\n\
72 \n\
73  -h|--help\n\
74  print this help message, and exit." << std::endl;
75 }
76 
77 void error(std::ostream & out) {
78  out << "Try 'hltDiff --help' for more information." << std::endl;
79 }
80 
81 void error(std::ostream & out, const char * message) {
82  out << message << std::endl;
83  error(out);
84 }
85 
86 void error(std::ostream & out, const std::string & message) {
87  out << message << std::endl;
88  error(out);
89 }
90 
91 
93 public:
94  virtual std::string const & processName() const = 0;
95  virtual unsigned int size() const = 0;
96  virtual unsigned int size(unsigned int trigger) const = 0;
97  virtual std::string const & triggerName(unsigned int trigger) const = 0;
98  virtual unsigned int triggerIndex(unsigned int trigger) const = 0;
99  virtual std::string const & moduleLabel(unsigned int trigger, unsigned int module) const = 0;
100  virtual std::string const & moduleType(unsigned int trigger, unsigned int module) const = 0;
101  virtual bool prescaler(unsigned int trigger, unsigned int module) const = 0;
102 };
103 
104 
106 public:
108  data_(data),
109  moduleTypes_(size()),
110  prescalers_(size())
111  {
112  for (unsigned int t = 0; t < data_.size(); ++t) {
113  prescalers_[t].resize(size(t));
114  moduleTypes_[t].resize(size(t));
115  for (unsigned int m = 0; m < data_.size(t); ++m) {
117  prescalers_[t][m] = (type == "HLTPrescaler");
118  moduleTypes_[t][m] = &* moduleTypeSet_.insert(std::move(type)).first;
119  }
120  }
121  }
122 
123  virtual std::string const & processName() const override {
124  return data_.processName();
125  }
126 
127  virtual unsigned int size() const override {
128  return data_.size();
129  }
130 
131  virtual unsigned int size(unsigned int trigger) const override {
132  return data_.size(trigger);
133  }
134 
135  virtual std::vector<std::string> const & triggerNames() const {
136  return data_.triggerNames();
137  }
138 
139  virtual std::string const & triggerName(unsigned int trigger) const override {
140  return data_.triggerName(trigger);
141  }
142 
143  virtual unsigned int triggerIndex(unsigned int trigger) const override {
144  return trigger;
145  }
146 
147  virtual std::string const & moduleLabel(unsigned int trigger, unsigned int module) const override {
148  return data_.moduleLabel(trigger, module);
149  }
150 
151  virtual std::string const & moduleType(unsigned int trigger, unsigned int module) const override {
152  return * moduleTypes_.at(trigger).at(module);
153  }
154 
155  virtual bool prescaler(unsigned int trigger, unsigned int module) const override {
156  return prescalers_.at(trigger).at(module);
157  }
158 
159 private:
161  std::set<std::string> moduleTypeSet_;
162  std::vector<std::vector<std::string const*>> moduleTypes_;
163  std::vector<std::vector<bool>> prescalers_;
164 };
165 
166 
167 const char * event_state(bool state) {
168  return state ? "accepted" : "rejected";
169 }
170 
171 
173 public:
174  enum class Index {
175  First = 0,
176  Second = 1
177  };
178 
179  class View : public HLTConfigInterface {
180  public:
182  config_(config),
183  index_(index)
184  { }
185 
186  virtual std::string const & processName() const override;
187  virtual unsigned int size() const override;
188  virtual unsigned int size(unsigned int trigger) const override;
189  virtual std::string const & triggerName(unsigned int trigger) const override;
190  virtual unsigned int triggerIndex(unsigned int trigger) const override;
191  virtual std::string const & moduleLabel(unsigned int trigger, unsigned int module) const override;
192  virtual std::string const & moduleType(unsigned int trigger, unsigned int module) const override;
193  virtual bool prescaler(unsigned int trigger, unsigned int module) const override;
194 
195  private:
198  };
199 
200 
202  first_(first),
203  second_(second),
204  firstView_(*this, Index::First),
205  secondView_(*this, Index::Second)
206  {
207  for (unsigned int f = 0; f < first.size(); ++f)
208  for (unsigned int s = 0; s < second.size(); ++s)
209  if (first.triggerName(f) == second.triggerName(s)) {
210  triggerIndices_.push_back(std::make_pair(f, s));
211  break;
212  }
213  }
214 
215  View const & getView(Index index) const {
216  if (index == Index::First)
217  return firstView_;
218  else
219  return secondView_;
220  }
221 
223  if (index == Index::First)
224  return first_.processName();
225  else
226  return second_.processName();
227  }
228 
229  unsigned int size(Index index) const {
230  return triggerIndices_.size();
231  }
232 
233  unsigned int size(Index index, unsigned int trigger) const {
234  if (index == Index::First)
235  return first_.size(trigger);
236  else
237  return second_.size(trigger);
238  }
239 
240  std::string const & triggerName(Index index, unsigned int trigger) const {
241  if (index == Index::First)
242  return first_.triggerName(triggerIndices_.at(trigger).first);
243  else
244  return second_.triggerName(triggerIndices_.at(trigger).second);
245  }
246 
247  unsigned int triggerIndex(Index index, unsigned int trigger) const {
248  if (index == Index::First)
249  return triggerIndices_.at(trigger).first;
250  else
251  return triggerIndices_.at(trigger).second;
252  }
253 
254  std::string const & moduleLabel(Index index, unsigned int trigger, unsigned int module) const {
255  if (index == Index::First)
256  return first_.moduleLabel(triggerIndices_.at(trigger).first, module);
257  else
258  return second_.moduleLabel(triggerIndices_.at(trigger).second, module);
259  }
260 
261  std::string const & moduleType(Index index, unsigned int trigger, unsigned int module) const {
262  if (index == Index::First)
263  return first_.moduleType(triggerIndices_.at(trigger).first, module);
264  else
265  return second_.moduleType(triggerIndices_.at(trigger).second, module);
266  }
267 
268  bool prescaler(Index index, unsigned int trigger, unsigned int module) const {
269  if (index == Index::First)
270  return first_.prescaler(triggerIndices_.at(trigger).first, module);
271  else
272  return second_.prescaler(triggerIndices_.at(trigger).second, module);
273  }
274 
275 private:
278 
281 
282  std::vector<std::pair<unsigned int, unsigned int>> triggerIndices_;
283 };
284 
285 
287  return config_.processName(index_);
288 }
289 
290 unsigned int HLTCommonConfig::View::size() const {
291  return config_.size(index_);
292 }
293 
294 unsigned int HLTCommonConfig::View::size(unsigned int trigger) const {
295  return config_.size(index_, trigger);
296 }
297 
298 std::string const & HLTCommonConfig::View::triggerName(unsigned int trigger) const {
299  return config_.triggerName(index_, trigger);
300 }
301 
302 unsigned int HLTCommonConfig::View::triggerIndex(unsigned int trigger) const {
303  return config_.triggerIndex(index_, trigger);
304 }
305 
306 std::string const & HLTCommonConfig::View::moduleLabel(unsigned int trigger, unsigned int module) const {
307  return config_.moduleLabel(index_, trigger, module);
308 }
309 
310 std::string const & HLTCommonConfig::View::moduleType(unsigned int trigger, unsigned int module) const {
311  return config_.moduleType(index_, trigger, module);
312 }
313 
314 bool HLTCommonConfig::View::prescaler(unsigned int trigger, unsigned int module) const {
315  return config_.prescaler(index_, trigger, module);
316 }
317 
318 
319 enum State {
326 };
327 
328 const char * path_state(State state) {
329  static const char * message[] = { "not run", "accepted", "rejected", "exception", "prescaled", "invalid" };
330 
331  if (state > 0 and state < Invalid)
332  return message[state];
333  else
334  return message[Invalid];
335 }
336 
337 inline
338 State prescaled_state(int state, int path, int module, HLTConfigInterface const & config) {
339  if (state == Fail and config.prescaler(path, module))
340  return Prescaled;
341  return (State) state;
342 }
343 
344 void print_detailed_path_state(std::ostream & out, State state, int path, int module, HLTConfigInterface const & config) {
345  auto const & label = config.moduleLabel(path, module);
346  auto const & type = config.moduleType(path, module);
347 
348  out << "'" << path_state(state) << "'";
349  if (state == Fail)
350  out << " by module " << module << " '" << label << "' [" << type << "]";
351  else if (state == Exception)
352  out << " at module " << module << " '" << label << "' [" << type << "]";
353 }
354 
356  // find the index of the collection of trigger candidates corresponding to the filter
357  unsigned int index = summary.filterIndex(filter);
358 
359  if (index >= summary.sizeFilters()) {
360  // the collection of trigger candidates corresponding to the filter could not be found
361  out << " not found\n";
362  return;
363  }
364 
365  if (summary.filterKeys(index).empty()) {
366  // the collection of trigger candidates corresponding to the filter is empty
367  out << " none\n";
368  return;
369  }
370 
371  for (unsigned int i = 0; i < summary.filterKeys(index).size(); ++i) {
372  auto key = summary.filterKeys(index)[i];
373  auto id = summary.filterIds(index)[i];
374  trigger::TriggerObject const & candidate = summary.getObjects().at(key);
375  out << " "
376  << "filter id: " << id << ", "
377  << "object id: " << candidate.id() << ", "
378  << "pT: " << candidate.pt() << ", "
379  << "eta: " << candidate.eta() << ", "
380  << "phi: " << candidate.phi() << ", "
381  << "mass: " << candidate.mass() << "\n";
382  }
383 }
384 
386  auto iterator = std::find(summary.collectionTags().begin(), summary.collectionTags().end(), tag);
387  if (iterator == summary.collectionTags().end()) {
388  // the collection of trigger candidates could not be found
389  out << " not found\n";
390  return;
391  }
392 
393  unsigned int index = iterator - summary.collectionTags().begin();
394  unsigned int begin = (index == 0) ? 0 : summary.collectionKey(index - 1);
395  unsigned int end = summary.collectionKey(index);
396 
397  if (end == begin) {
398  // the collection of trigger candidates is empty
399  out << " none\n";
400  return;
401  }
402 
403  for (unsigned int key = begin; key < end; ++key) {
404  trigger::TriggerObject const & candidate = summary.getObjects().at(key);
405  out << " "
406  << "object id: " << candidate.id() << ", "
407  << "pT: " << candidate.pt() << ", "
408  << "eta: " << candidate.eta() << ", "
409  << "phi: " << candidate.phi() << ", "
410  << "mass: " << candidate.mass() << "\n";
411  }
412 }
413 
414 
416  std::vector<boost::iterator_range<std::string::const_iterator>> tokens;
417  boost::split(tokens, branch, boost::is_any_of("_."), boost::token_compress_off);
418  return boost::copy_range<std::string>(tokens[3]);
419 }
420 
421 std::unique_ptr<HLTConfigDataEx> getHLTConfigData(fwlite::EventBase const & event, std::string process) {
422  auto const & history = event.processHistory();
423  if (process.empty()) {
424  // determine the process name from the most recent "TriggerResults" object
425  auto const & branch = event.getBranchNameFor( edm::Wrapper<edm::TriggerResults>::typeInfo(), "TriggerResults", "", process.c_str() );
426  process = getProcessNameFromBranch( branch );
427  }
428 
430  if (not history.getConfigurationForProcess(process, config)) {
431  std::cerr << "error: the process " << process << " is not in the Process History" << std::endl;
432  exit(1);
433  }
435  if (pset == nullptr) {
436  std::cerr << "error: the configuration for the process " << process << " is not available in the Provenance" << std::endl;
437  exit(1);
438  }
439  return std::unique_ptr<HLTConfigDataEx>(new HLTConfigDataEx(HLTConfigData(pset)));
440 }
441 
442 
443 struct TriggerDiff {
444  TriggerDiff() : count(0), gained(0), lost(0), internal(0) { }
445 
446  unsigned int count;
447  unsigned int gained;
448  unsigned int lost;
449  unsigned int internal;
450 
451  static
452  std::string format(unsigned int value, char sign = '+') {
453  if (value == 0)
454  return std::string("-");
455 
456  char buffer[12]; // sign, 10 digits, null
457  memset(buffer, 0, 12);
458 
459  unsigned int digit = 10;
460  while (value > 0) {
461  buffer[digit] = value % 10 + 48;
462  value /= 10;
463  --digit;
464  }
465  buffer[digit] = sign;
466 
467  return std::string(buffer + digit);
468  }
469 };
470 
471 std::ostream & operator<<(std::ostream & out, TriggerDiff diff) {
472  out << std::setw(12) << diff.count
473  << std::setw(12) << TriggerDiff::format(diff.gained, '+')
474  << std::setw(12) << TriggerDiff::format(diff.lost, '-')
475  << std::setw(12) << TriggerDiff::format(diff.internal, '~');
476  return out;
477 }
478 
479 
480 bool check_file(std::string const & file) {
481  std::unique_ptr<TFile> f(TFile::Open(file.c_str()));
482  return (f and not f->IsZombie());
483 }
484 
485 
486 bool check_files(std::vector<std::string> const & files) {
487  bool flag = true;
488  for (auto const & file: files)
489  if (not check_file(file)) {
490  flag = false;
491  std::cerr << "hltDiff: error: file " << file << " does not exist, or is not a regular file." << std::endl;
492  }
493  return flag;
494 }
495 
496 
497 void compare(std::vector<std::string> const & old_files, std::string const & old_process,
498  std::vector<std::string> const & new_files, std::string const & new_process,
499  unsigned int max_events, bool ignore_prescales, int verbose, int quiet) {
500 
501  std::shared_ptr<fwlite::ChainEvent> old_events;
502  std::shared_ptr<fwlite::ChainEvent> new_events;
503 
504  if (check_files(old_files))
505  old_events = std::make_shared<fwlite::ChainEvent>(old_files);
506  else
507  return;
508 
509  if (new_files.size() == 1 and new_files[0] == "-")
510  new_events = old_events;
511  else if (check_files(new_files))
512  new_events = std::make_shared<fwlite::ChainEvent>(new_files);
513  else
514  return;
515 
516  std::unique_ptr<HLTConfigDataEx> old_config_data;
517  std::unique_ptr<HLTConfigDataEx> new_config_data;
518  std::unique_ptr<HLTCommonConfig> common_config;
519  HLTConfigInterface const * old_config = nullptr;
520  HLTConfigInterface const * new_config = nullptr;
521 
522  unsigned int counter = 0;
523  unsigned int skipped = 0;
524  unsigned int affected = 0;
525  bool new_run = true;
526  std::vector<TriggerDiff> differences;
527 
528  // loop over the reference events
529  for (old_events->toBegin(); not old_events->atEnd(); ++(*old_events)) {
530 
531  // seek the same event in the "new" files
532  edm::EventID const& id = old_events->id();
533  if (new_events != old_events and not new_events->to(id)) {
534  if (not quiet)
535  std::cerr << "run " << id.run() << ", lumi " << id.luminosityBlock() << ", event " << id.event() << ": not found in the 'new' files, skipping." << std::endl;
536  ++skipped;
537  continue;
538  }
539 
540  // read the TriggerResults and TriggerEvent
542  edm::TriggerResults const * old_results = nullptr;
543  old_results_h.getByLabel<fwlite::Event>(* old_events->event(), "TriggerResults", "", old_process.c_str());
544  if (old_results_h.isValid())
545  old_results = old_results_h.product();
546  else {
547  if (not quiet)
548  std::cerr << "run " << id.run() << ", lumi " << id.luminosityBlock() << ", event " << id.event() << ": 'old' TriggerResults not found, skipping." << std::endl;
549  continue;
550  }
551 
553  trigger::TriggerEvent const * old_summary = nullptr;
554  old_summary_h.getByLabel<fwlite::Event>(* old_events->event(), "hltTriggerSummaryAOD", "", old_process.c_str());
555  if (old_summary_h.isValid())
556  old_summary = old_summary_h.product();
557 
559  edm::TriggerResults const * new_results = nullptr;
560  new_results_h.getByLabel<fwlite::Event>(* new_events->event(), "TriggerResults", "", new_process.c_str());
561  if (new_results_h.isValid())
562  new_results = new_results_h.product();
563  else {
564  if (not quiet)
565  std::cerr << "run " << id.run() << ", lumi " << id.luminosityBlock() << ", event " << id.event() << ": 'new' TriggerResults not found, skipping." << std::endl;
566  continue;
567  }
568 
570  trigger::TriggerEvent const * new_summary = nullptr;
571  new_summary_h.getByLabel<fwlite::Event>(* new_events->event(), "hltTriggerSummaryAOD", "", new_process.c_str());
572  if (new_summary_h.isValid())
573  new_summary = new_summary_h.product();
574 
575  // initialise the trigger configuration
576  if (new_run) {
577  new_run = false;
578  old_events->fillParameterSetRegistry();
579  new_events->fillParameterSetRegistry();
580 
581  old_config_data = getHLTConfigData(* old_events->event(), old_process);
582  new_config_data = getHLTConfigData(* new_events->event(), new_process);
583  if (new_config_data->triggerNames() == old_config_data->triggerNames()) {
584  old_config = old_config_data.get();
585  new_config = new_config_data.get();
586  } else {
587  common_config = std::unique_ptr<HLTCommonConfig>(new HLTCommonConfig(*old_config_data, *new_config_data));
588  old_config = & common_config->getView(HLTCommonConfig::Index::First);
589  new_config = & common_config->getView(HLTCommonConfig::Index::Second);
590  std::cerr << "Warning: old and new TriggerResults come from different HLT menus. Only the common triggers will be compared:" << std::endl;
591  for (unsigned int i = 0; i < old_config->size(); ++i)
592  std::cerr << " " << old_config->triggerName(i) << std::endl;
593  std::cerr << std::endl;
594  }
595 
596  differences.clear();
597  differences.resize(old_config->size());
598  }
599 
600  // compare the TriggerResults
601  bool needs_header = true;
602  bool affected_event = false;
603  for (unsigned int p = 0; p < old_config->size(); ++p) {
604  // FIXME explicitly converting the indices is a hack, it should be properly encapsulated instead
605  unsigned int old_index = old_config->triggerIndex(p);
606  unsigned int new_index = new_config->triggerIndex(p);
607  State old_state = prescaled_state(old_results->state(old_index), p, old_results->index(old_index), * old_config);
608  State new_state = prescaled_state(new_results->state(new_index), p, new_results->index(new_index), * new_config);
609 
610  if (old_state == Pass)
611  ++differences[p].count;
612 
613  bool flag = false;
614  if (not ignore_prescales or (old_state != Prescaled and new_state != Prescaled)) {
615  if (old_state == Pass and new_state != Pass) {
616  ++differences[p].lost;
617  flag = true;
618  } else if (old_state != Pass and new_state == Pass) {
619  ++differences[p].gained;
620  flag = true;
621  } else if (old_results->index(old_index) != new_results->index(new_index)) {
622  ++differences[p].internal;
623  flag = true;
624  }
625  }
626 
627  if (flag) {
628  affected_event = true;
629 
630  if (verbose > 0) {
631  if (needs_header) {
632  needs_header = false;
633  std::cout << "run " << id.run() << ", lumi " << id.luminosityBlock() << ", event " << id.event() << ": "
634  << "old result is '" << event_state(old_results->accept()) << "', "
635  << "new result is '" << event_state(new_results->accept()) << "'"
636  << std::endl;
637  }
638  // print the Trigger path and filter responsible for the discrepancy
639  std::cout << " Path " << old_config->triggerName(p) << ":\n"
640  << " old state is ";
641  print_detailed_path_state(std::cout, old_state, p, old_results->index(old_index), * old_config);
642  std::cout << ",\n"
643  << " new state is ";
644  print_detailed_path_state(std::cout, new_state, p, new_results->index(new_index), * new_config);
645  std::cout << std::endl;
646  }
647  if (verbose > 1 and old_summary and new_summary) {
648  // print TriggerObjects for the filter responsible for the discrepancy
649  unsigned int module = std::min(old_results->index(old_index), new_results->index(new_index));
650  std::cout << " Filter " << old_config->moduleLabel(p, module) << ":\n";
651  std::cout << " old trigger candidates:\n";
652  print_trigger_candidates(std::cout, * old_summary, edm::InputTag(old_config->moduleLabel(p, module), "", old_config->processName()));
653  std::cout << " new trigger candidates:\n";
654  print_trigger_candidates(std::cout, * new_summary, edm::InputTag(new_config->moduleLabel(p, module), "", new_config->processName()));
655  }
656  if (verbose > 0)
657  std::cout << std::endl;
658  }
659  }
660  if (affected_event)
661  ++affected;
662 
663  // compare the TriggerEvent
664  if (affected_event and verbose > 2 and old_summary and new_summary) {
665  std::set<std::string> names;
666  names.insert(old_summary->collectionTags().begin(), old_summary->collectionTags().end());
667  names.insert(new_summary->collectionTags().begin(), new_summary->collectionTags().end());
668  for (auto const & collection: names) {
669  std::cout << " Collection " << collection << ":\n";
670  std::cout << " old trigger candidates:\n";
671  print_trigger_collection(std::cout, * old_summary, collection);
672  std::cout << " new trigger candidates:\n";
673  print_trigger_collection(std::cout, * new_summary, collection);
674  std::cout << std::endl;
675  }
676  }
677 
678  ++counter;
679  if (max_events and counter >= max_events)
680  break;
681  }
682 
683  if (not counter) {
684  std::cout << "There are no common events between the old and new files";
685  if (skipped)
686  std::cout << ", " << skipped << " events were skipped";
687  std::cout << "." << std::endl;
688  } else {
689  std::cout << "Found " << affected << " events out of " << counter << " with differences";
690  if (skipped)
691  std::cout << ", " << skipped << " events were skipped";
692  std::cout << ":\n" << std::endl;
693  std::cout << std::setw(12) << "Events" << std::setw(12) << "Accepted" << std::setw(12) << "Gained" << std::setw(12) << "Lost" << std::setw(12) << "Other" << " " << "Trigger" << std::endl;
694  for (unsigned int p = 0; p < old_config->size(); ++p)
695  std::cout << std::setw(12) << counter << differences[p] << " " << old_config->triggerName(p) << std::endl;
696  }
697 }
698 
699 
700 int main(int argc, char ** argv) {
701  // options
702  const char optstring[] = "o:O:n:N:m:pqvh";
703  const option longopts[] = {
704  option{ "old-files", required_argument, nullptr, 'o' },
705  option{ "old-process", required_argument, nullptr, 'O' },
706  option{ "new-files", required_argument, nullptr, 'n' },
707  option{ "new-process", required_argument, nullptr, 'N' },
708  option{ "max-events", required_argument, nullptr, 'm' },
709  option{ "prescales", no_argument, nullptr, 'p' },
710  option{ "quet", no_argument, nullptr, 'q' },
711  option{ "verbose", no_argument, nullptr, 'v' },
712  option{ "help", no_argument, nullptr, 'h' },
713  };
714 
715  // default values
716  std::vector<std::string> old_files;
717  std::string old_process("");
718  std::vector<std::string> new_files;
719  std::string new_process("");
720  unsigned int max_events = 0;
721  bool ignore_prescales = true;
722  bool quiet = false;
723  unsigned int verbose = 0;
724 
725  // parse the command line options
726  int c = -1;
727  while ((c = getopt_long(argc, argv, optstring, longopts, nullptr)) != -1) {
728  switch (c) {
729  case 'o':
730  old_files.emplace_back(optarg);
731  while (optind < argc) {
732  if (argv[optind][0] == '-')
733  break;
734  old_files.emplace_back(argv[optind]);
735  ++optind;
736  }
737  break;
738 
739  case 'O':
740  old_process = optarg;
741  break;
742 
743  case 'n':
744  new_files.emplace_back(optarg);
745  while (optind < argc) {
746  if (argv[optind][0] == '-')
747  break;
748  new_files.emplace_back(argv[optind]);
749  ++optind;
750  }
751  break;
752 
753  case 'N':
754  new_process = optarg;
755  break;
756 
757  case 'm':
758  max_events = atoi(optarg);
759  break;
760 
761  case 'p':
762  ignore_prescales = false;
763  break;
764 
765  case 'q':
766  quiet = true;
767  break;
768 
769  case 'v':
770  ++verbose;
771  break;
772 
773  case 'h':
774  usage(std::cerr);
775  exit(0);
776  break;
777 
778  default:
779  error(std::cerr);
780  exit(1);
781  break;
782  }
783  }
784 
785  if (old_files.empty()) {
786  error(std::cerr, "hltDiff: please specify the 'old' file(s)");
787  exit(1);
788  }
789  if (new_files.empty()) {
790  error(std::cerr, "hltDiff: please specify the 'new' file(s)");
791  exit(1);
792  }
793 
794  compare(old_files, old_process, new_files, new_process, max_events, ignore_prescales, verbose, quiet);
795 
796  return 0;
797 }
virtual unsigned int triggerIndex(unsigned int trigger) const override
Definition: hltDiff.cc:143
virtual std::string const & triggerName(unsigned int trigger) const override
Definition: hltDiff.cc:298
virtual std::string const & moduleLabel(unsigned int trigger, unsigned int module) const =0
type
Definition: HCALResponse.h:21
unsigned int count
Definition: hltDiff.cc:446
int i
Definition: DBlmapReader.cc:9
std::set< std::string > moduleTypeSet_
Definition: hltDiff.cc:161
virtual bool prescaler(unsigned int trigger, unsigned int module) const override
Definition: hltDiff.cc:155
std::vector< std::pair< unsigned int, unsigned int > > triggerIndices_
Definition: hltDiff.cc:282
virtual bool prescaler(unsigned int trigger, unsigned int module) const override
Definition: hltDiff.cc:314
std::string const & moduleLabel(Index index, unsigned int trigger, unsigned int module) const
Definition: hltDiff.cc:254
virtual std::string const & moduleType(unsigned int trigger, unsigned int module) const override
Definition: hltDiff.cc:310
virtual unsigned int size(unsigned int trigger) const override
Definition: hltDiff.cc:131
unsigned int internal
Definition: hltDiff.cc:449
not [yet] run
Definition: HLTenums.h:18
bool check_files(std::vector< std::string > const &files)
Definition: hltDiff.cc:486
int id() const
getters
Definition: TriggerObject.h:55
const std::vector< std::string > & collectionTags() const
Definition: TriggerEvent.h:96
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:135
bool verbose
static const HistoName names[]
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
string usage
Definition: geometryDiff.py:6
Definition: hltDiff.cc:321
void print_trigger_candidates(std::ostream &out, trigger::TriggerEvent const &summary, edm::InputTag const &filter)
Definition: hltDiff.cc:355
bool isValid() const
Definition: Handle.h:61
unsigned int size(Index index, unsigned int trigger) const
Definition: hltDiff.cc:233
trigger::size_type collectionKey(trigger::size_type index) const
Definition: TriggerEvent.h:102
float phi() const
Definition: TriggerObject.h:58
unsigned int lost
Definition: hltDiff.cc:448
std::vector< std::vector< std::string const * > > moduleTypes_
Definition: hltDiff.cc:162
double sign(double x)
bool accept() const
Has at least one path accepted the event?
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
View(HLTCommonConfig const &config, HLTCommonConfig::Index index)
Definition: hltDiff.cc:181
const std::vector< std::string > & triggerNames() const
names of trigger paths
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:123
reject
Definition: HLTenums.h:20
virtual bool prescaler(unsigned int trigger, unsigned int module) const =0
virtual std::string const & moduleLabel(unsigned int trigger, unsigned int module) const override
Definition: hltDiff.cc:306
unsigned int size() const
number of trigger paths in trigger table
HLTConfigData data_
Definition: hltDiff.cc:160
void print_detailed_path_state(std::ostream &out, State state, int path, int module, HLTConfigInterface const &config)
Definition: hltDiff.cc:344
virtual std::string const & processName() const override
Definition: hltDiff.cc:123
float eta() const
Definition: TriggerObject.h:57
const char * event_state(bool state)
Definition: hltDiff.cc:167
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
virtual std::string const & triggerName(unsigned int trigger) const override
Definition: hltDiff.cc:139
list diff
Definition: mps_update.py:85
View secondView_
Definition: hltDiff.cc:280
HLTCommonConfig(HLTConfigDataEx const &first, HLTConfigDataEx const &second)
Definition: hltDiff.cc:201
virtual std::vector< std::string > const & triggerNames() const
Definition: hltDiff.cc:135
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:22
U second(std::pair< T, U > const &p)
static std::string format(unsigned int value, char sign= '+')
Definition: hltDiff.cc:452
void getByLabel(const P &iP, const char *iModuleLabel, const char *iProductInstanceLabel=0, const char *iProcessLabel=0)
Definition: Handle.h:91
unsigned int gained
Definition: hltDiff.cc:447
virtual std::string const & moduleLabel(unsigned int trigger, unsigned int module) const override
Definition: hltDiff.cc:147
State prescaled_state(int state, int path, int module, HLTConfigInterface const &config)
Definition: hltDiff.cc:338
virtual std::string const & triggerName(unsigned int trigger) const =0
const Vids & filterIds(trigger::size_type index) const
Definition: TriggerEvent.h:110
ParameterSetID const & parameterSetID() const
virtual std::string const & processName() const override
Definition: hltDiff.cc:286
accept
Definition: HLTenums.h:19
HLTConfigDataEx const & second_
Definition: hltDiff.cc:277
std::unique_ptr< HLTConfigDataEx > getHLTConfigData(fwlite::EventBase const &event, std::string process)
Definition: hltDiff.cc:421
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
unsigned int index(const unsigned int i) const
Get index (slot position) of module giving the decision of the ith path.
def move
Definition: eostools.py:510
std::string getProcessNameFromBranch(std::string const &branch)
Definition: hltDiff.cc:415
HLTCommonConfig const & config_
Definition: hltDiff.cc:196
virtual unsigned int size() const override
Definition: hltDiff.cc:127
void compare(std::vector< std::string > const &old_files, std::string const &old_process, std::vector< std::string > const &new_files, std::string const &new_process, unsigned int max_events, bool ignore_prescales, int verbose, int quiet)
Definition: hltDiff.cc:497
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:18
virtual std::string const & moduleType(unsigned int trigger, unsigned int module) const =0
const std::string moduleType(const std::string &module) const
C++ class name of module.
double f[11][100]
unsigned int size(Index index) const
Definition: hltDiff.cc:229
#define end
Definition: vmac.h:37
T min(T a, T b)
Definition: MathUtil.h:58
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
virtual unsigned int triggerIndex(unsigned int trigger) const =0
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
void print_trigger_collection(std::ostream &out, trigger::TriggerEvent const &summary, std::string const &tag)
Definition: hltDiff.cc:385
HLTConfigDataEx(HLTConfigData data)
Definition: hltDiff.cc:107
const std::string & processName() const
Accessors (const methods)
unsigned int triggerIndex(Index index, unsigned int trigger) const
Definition: hltDiff.cc:247
virtual std::string const & processName() const =0
tuple argc
Definition: dir2webdir.py:38
Definition: hltDiff.cc:322
const char * path_state(State state)
Definition: hltDiff.cc:328
HLTConfigDataEx const & first_
Definition: hltDiff.cc:276
bool check_file(std::string const &file)
Definition: hltDiff.cc:480
#define begin
Definition: vmac.h:30
virtual unsigned int size() const =0
static std::atomic< unsigned int > counter
std::string const & moduleType(Index index, unsigned int trigger, unsigned int module) const
Definition: hltDiff.cc:261
bool prescaler(Index index, unsigned int trigger, unsigned int module) const
Definition: hltDiff.cc:268
std::string const & processName(Index index) const
Definition: hltDiff.cc:222
State
Definition: hltDiff.cc:319
const std::string & moduleLabel(unsigned int trigger, unsigned int module) const
tuple cout
Definition: gather_cfg.py:145
virtual unsigned int size() const override
Definition: hltDiff.cc:290
T const * product() const
Definition: Handle.h:66
View const & getView(Index index) const
Definition: hltDiff.cc:215
std::vector< std::vector< bool > > prescalers_
Definition: hltDiff.cc:163
std::string const & triggerName(Index index, unsigned int trigger) const
Definition: hltDiff.cc:240
const std::string & triggerName(unsigned int triggerIndex) const
virtual std::string const & moduleType(unsigned int trigger, unsigned int module) const override
Definition: hltDiff.cc:151
float mass() const
Definition: TriggerObject.h:59
tuple process
Definition: LaserDQM_cfg.py:3
Definition: vlib.h:208
double split
Definition: MVATrainer.cc:139
virtual unsigned int triggerIndex(unsigned int trigger) const override
Definition: hltDiff.cc:302
static Registry * instance()
Definition: Registry.cc:12
hlt::HLTState state(const unsigned int i) const
Get status of ith path.