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