CMS 3D CMS Logo

Classes | Enumerations | Functions
hltDiff.cc File Reference
#include <vector>
#include <set>
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstdio>
#include <iomanip>
#include <memory>
#include <algorithm>
#include <cstring>
#include <unistd.h>
#include <getopt.h>
#include <cmath>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <TFile.h>
#include <TCanvas.h>
#include <TH1F.h>
#include <TH2F.h>
#include <TGraphAsymmErrors.h>
#include "FWCore/Common/interface/TriggerNames.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/Registry.h"
#include "DataFormats/Common/interface/TriggerResults.h"
#include "DataFormats/HLTReco/interface/TriggerObject.h"
#include "DataFormats/HLTReco/interface/TriggerEvent.h"
#include "DataFormats/FWLite/interface/Handle.h"
#include "DataFormats/FWLite/interface/Event.h"
#include "DataFormats/FWLite/interface/ChainEvent.h"
#include "HLTrigger/HLTcore/interface/HLTConfigData.h"

Go to the source code of this file.

Classes

struct  SummaryOutputProducer::Event
 
struct  SummaryOutputProducer::GenericSummary
 
class  HLTCommonConfig
 
class  HLTConfigDataEx
 
class  HLTConfigInterface
 
class  HltDiff
 
struct  JsonOutputProducer::JsonConfiguration
 
struct  JsonOutputProducer::JsonConfigurationBlock
 
struct  JsonOutputProducer::JsonEvent
 
struct  JsonOutputProducer::JsonEventState
 
class  JsonOutputProducer
 
struct  JsonOutputProducer::JsonTriggerEventState
 
struct  JsonOutputProducer::JsonVars
 
struct  SummaryOutputProducer::Pair
 
class  SummaryOutputProducer
 
struct  TriggerDiff
 
struct  SummaryOutputProducer::TriggerSummary
 
class  HLTCommonConfig::View
 

Enumerations

enum  State {
  InvalidLinkId, InvalidROCId, InvalidPixelId, Unknown,
  Ready = edm::hlt::Ready, Pass = edm::hlt::Pass, Fail = edm::hlt::Fail, Exception = edm::hlt::Exception,
  Prescaled, Invalid
}
 

Functions

bool check_file (std::string const &file)
 
bool check_files (std::vector< std::string > const &files)
 
void error (std::ostream &out)
 
void error (std::ostream &out, const char *message)
 
void error (std::ostream &out, const std::string &message)
 
const char * event_state (bool state)
 
std::unique_ptr< HLTConfigDataExgetHLTConfigData (fwlite::EventBase const &event, std::string process)
 
std::string getProcessNameFromBranch (std::string const &branch)
 
int main (int argc, char **argv)
 
std::ostream & operator<< (std::ostream &out, TriggerDiff diff)
 
const char * path_state (State state)
 
State prescaled_state (int state, int path, int module, HLTConfigInterface const &config)
 
void print_detailed_path_state (std::ostream &out, State state, int path, int module, HLTConfigInterface const &config)
 
void print_trigger_candidates (std::ostream &out, trigger::TriggerEvent const &summary, edm::InputTag const &filter)
 
void print_trigger_collection (std::ostream &out, trigger::TriggerEvent const &summary, std::string const &tag)
 
std::string strip_process_name (std::string const &s)
 

Enumeration Type Documentation

◆ State

enum State
Enumerator
InvalidLinkId 
InvalidROCId 
InvalidPixelId 
Unknown 
Ready 
Pass 
Fail 
Exception 
Prescaled 
Invalid 

Definition at line 242 of file hltDiff.cc.

242  {
247  Prescaled,
248  Invalid
249 };

Function Documentation

◆ check_file()

bool check_file ( std::string const &  file)

Definition at line 1177 of file hltDiff.cc.

1177  {
1178  std::unique_ptr<TFile> f(TFile::Open(file.c_str()));
1179  return (f and not f->IsZombie());
1180 }

References f, and FrontierConditions_GlobalTag_cff::file.

Referenced by check_files().

◆ check_files()

bool check_files ( std::vector< std::string > const &  files)

Definition at line 1182 of file hltDiff.cc.

1182  {
1183  bool flag = true;
1184  for (auto const& file : files)
1185  if (not check_file(file)) {
1186  flag = false;
1187  std::cerr << "hltDiff: error: file " << file << " does not exist, or is not a regular file." << std::endl;
1188  }
1189  return flag;
1190 }

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, check_file(), FrontierConditions_GlobalTag_cff::file, submitPVResolutionJobs::files, and RemoveAddSevLevel::flag.

Referenced by HltDiff::compare().

◆ error() [1/3]

void error ( std::ostream &  out)

Definition at line 44 of file hltDiff.cc.

44 { out << "Try 'hltDiff --help' for more information" << std::endl; }

References MillePedeFileConverter_cfg::out.

Referenced by error(), and main().

◆ error() [2/3]

void error ( std::ostream &  out,
const char *  message 
)

Definition at line 46 of file hltDiff.cc.

46  {
47  out << message << std::endl;
48  error(out);
49 }

References error(), and MillePedeFileConverter_cfg::out.

◆ error() [3/3]

void error ( std::ostream &  out,
const std::string &  message 
)

Definition at line 51 of file hltDiff.cc.

51  {
52  out << message << std::endl;
53  error(out);
54 }

References error(), and MillePedeFileConverter_cfg::out.

◆ event_state()

const char* event_state ( bool  state)

Definition at line 114 of file hltDiff.cc.

114 { return state ? "accepted" : "rejected"; }

Referenced by HltDiff::compare().

◆ getHLTConfigData()

std::unique_ptr<HLTConfigDataEx> getHLTConfigData ( fwlite::EventBase const &  event,
std::string  process 
)

Definition at line 363 of file hltDiff.cc.

363  {
364  auto const& history = event.processHistory();
365  if (process.empty()) {
366  // determine the process name from the most recent "TriggerResults" object
367  auto const& branch =
368  event.getBranchNameFor(edm::Wrapper<edm::TriggerResults>::typeInfo(), "TriggerResults", "", process.c_str());
370  }
371 
373  if (not history.getConfigurationForProcess(process, config)) {
374  std::cerr << "error: the process " << process << " is not in the Process History" << std::endl;
375  exit(1);
376  }
378  if (pset == nullptr) {
379  std::cerr << "error: the configuration for the process " << process << " is not available in the Provenance"
380  << std::endl;
381  exit(1);
382  }
383  return std::make_unique<HLTConfigDataEx>(HLTConfigData(pset));
384 }

References MicroEventContent_cff::branch, EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, submitPVResolutionJobs::config, beamvalidation::exit(), edm::pset::Registry::getMapped(), getProcessNameFromBranch(), edm::pset::Registry::instance(), LaserDQM_cfg::process, and muonDTDigis_cfi::pset.

Referenced by HltDiff::compare().

◆ getProcessNameFromBranch()

std::string getProcessNameFromBranch ( std::string const &  branch)

Definition at line 357 of file hltDiff.cc.

357  {
358  std::vector<boost::iterator_range<std::string::const_iterator>> tokens;
359  boost::split(tokens, branch, boost::is_any_of("_."), boost::token_compress_off);
360  return boost::copy_range<std::string>(tokens[3]);
361 }

References MicroEventContent_cff::branch, and submitPVValidationJobs::split().

Referenced by getHLTConfigData().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 1581 of file hltDiff.cc.

1581  {
1582  // options
1583  const char optstring[] = "dfo:O:n:N:m:pcjrF:v::hq";
1584  const option longopts[] = {
1585  option{"debug", no_argument, nullptr, 'd'},
1586  option{"file-check", no_argument, nullptr, 'f'},
1587  option{"old-files", required_argument, nullptr, 'o'},
1588  option{"old-process", required_argument, nullptr, 'O'},
1589  option{"new-files", required_argument, nullptr, 'n'},
1590  option{"new-process", required_argument, nullptr, 'N'},
1591  option{"max-events", required_argument, nullptr, 'm'},
1592  option{"prescales", no_argument, nullptr, 'p'},
1593  option{"csv-output", optional_argument, nullptr, 'c'},
1594  option{"json-output", optional_argument, nullptr, 'j'},
1595  option{"root-output", optional_argument, nullptr, 'r'},
1596  option{"output-file", optional_argument, nullptr, 'F'},
1597  option{"verbose", optional_argument, nullptr, 'v'},
1598  option{"help", no_argument, nullptr, 'h'},
1599  option{"quiet", no_argument, nullptr, 'q'},
1600  };
1601 
1602  // Creating an HltDiff object with the default configuration
1603  auto hlt = new HltDiff();
1604 
1605  // parse the command line options
1606  int c = -1;
1607  while ((c = getopt_long(argc, argv, optstring, longopts, nullptr)) != -1) {
1608  switch (c) {
1609  case 'd':
1610  hlt->debug = true;
1611  break;
1612 
1613  case 'f':
1614  hlt->file_check = true;
1615  break;
1616 
1617  case 'o':
1618  hlt->old_files.emplace_back(optarg);
1619  while (optind < argc) {
1620  if (argv[optind][0] == '-')
1621  break;
1622  hlt->old_files.emplace_back(argv[optind]);
1623  ++optind;
1624  }
1625  break;
1626 
1627  case 'O':
1628  hlt->old_process = optarg;
1629  break;
1630 
1631  case 'n':
1632  hlt->new_files.emplace_back(optarg);
1633  while (optind < argc) {
1634  if (argv[optind][0] == '-')
1635  break;
1636  hlt->new_files.emplace_back(argv[optind]);
1637  ++optind;
1638  }
1639  break;
1640 
1641  case 'N':
1642  hlt->new_process = optarg;
1643  break;
1644 
1645  case 'm':
1646  hlt->max_events = atoi(optarg);
1647  break;
1648 
1649  case 'p':
1650  hlt->ignore_prescales = false;
1651  break;
1652 
1653  case 'c':
1654  hlt->csv_out = true;
1655  break;
1656 
1657  case 'j':
1658  hlt->json_out = true;
1659  break;
1660 
1661  case 'r':
1662  hlt->root_out = true;
1663  break;
1664 
1665  case 'F':
1666  hlt->output_file = optarg;
1667  break;
1668 
1669  case 'v':
1670  hlt->verbose = 1;
1671  if (optarg) {
1672  hlt->verbose = std::max(1, atoi(optarg));
1673  } else if (!optarg && nullptr != argv[optind] && '-' != argv[optind][0]) {
1674  // workaround for a bug in getopt which doesn't allow space before optional arguments
1675  const char* tmp_optarg = argv[optind++];
1676  hlt->verbose = std::max(1, atoi(tmp_optarg));
1677  }
1678  break;
1679 
1680  case 'h':
1681  hlt->usage(std::cerr);
1682  exit(0);
1683  break;
1684 
1685  case 'q':
1686  hlt->quiet = true;
1687  break;
1688 
1689  default:
1690  error(std::cerr);
1691  exit(1);
1692  break;
1693  }
1694  }
1695 
1696  if (hlt->old_files.empty()) {
1697  error(std::cerr, "hltDiff: please specify the 'old' file(s)");
1698  exit(1);
1699  }
1700  if (hlt->new_files.empty()) {
1701  error(std::cerr, "hltDiff: please specify the 'new' file(s)");
1702  exit(1);
1703  }
1704 
1705  hlt->compare();
1706 
1707  return 0;
1708 }

References dir2webdir::argc, cmsBatch::argv, HltBtagPostValidation_cff::c, EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, error(), beamvalidation::exit(), ValidationMatrix::hlt, SiStripPI::max, and fileinputsource_cfi::option.

◆ operator<<()

std::ostream& operator<< ( std::ostream &  out,
TriggerDiff  diff 
)

Definition at line 415 of file hltDiff.cc.

415  {
416  out << std::setw(12) << diff.count << std::setw(12) << TriggerDiff::format(diff.gained, '+') << std::setw(12)
417  << TriggerDiff::format(diff.lost, '-') << std::setw(12) << TriggerDiff::format(diff.internal, '~');
418  return out;
419 }

References change_name::diff, TriggerDiff::format(), and MillePedeFileConverter_cfg::out.

◆ path_state()

const char* path_state ( State  state)

Definition at line 251 of file hltDiff.cc.

251  {
252  static const char* message[] = {"not run", "accepted", "rejected", "exception", "prescaled", "invalid"};
253 
254  if (state > 0 and state < Invalid)
255  return message[state];
256  else
257  return message[Invalid];
258 }

References Invalid.

Referenced by HltDiff::compare(), and print_detailed_path_state().

◆ prescaled_state()

State prescaled_state ( int  state,
int  path,
int  module,
HLTConfigInterface const &  config 
)
inline

Definition at line 260 of file hltDiff.cc.

260  {
261  if (state == Fail and config.prescaler(path, module))
262  return Prescaled;
263  return (State)state;
264 }

References Fail, castor_dqm_sourceclient_file_cfg::path, and Prescaled.

Referenced by HltDiff::compare().

◆ print_detailed_path_state()

void print_detailed_path_state ( std::ostream &  out,
State  state,
int  path,
int  module,
HLTConfigInterface const &  config 
)

Definition at line 287 of file hltDiff.cc.

287  {
288  auto const& label = config.moduleLabel(path, module);
289  auto const& type = config.moduleType(path, module);
290 
291  out << "'" << path_state(state) << "'";
292  if (state == Fail)
293  out << " by module " << module << " '" << label << "' [" << type << "]";
294  else if (state == Exception)
295  out << " at module " << module << " '" << label << "' [" << type << "]";
296 }

References Fail, label, MillePedeFileConverter_cfg::out, castor_dqm_sourceclient_file_cfg::path, and path_state().

Referenced by HltDiff::compare().

◆ print_trigger_candidates()

void print_trigger_candidates ( std::ostream &  out,
trigger::TriggerEvent const &  summary,
edm::InputTag const &  filter 
)

Definition at line 298 of file hltDiff.cc.

298  {
299  // find the index of the collection of trigger candidates corresponding to the filter
300  unsigned int index = summary.filterIndex(filter);
301 
302  if (index >= summary.sizeFilters()) {
303  // the collection of trigger candidates corresponding to the filter could not be found
304  out << " not found\n";
305  return;
306  }
307 
308  if (summary.filterKeys(index).empty()) {
309  // the collection of trigger candidates corresponding to the filter is empty
310  out << " none\n";
311  return;
312  }
313 
314  for (unsigned int i = 0; i < summary.filterKeys(index).size(); ++i) {
315  auto key = summary.filterKeys(index)[i];
316  auto id = summary.filterIds(index)[i];
317  trigger::TriggerObject const& candidate = summary.getObjects().at(key);
318  out << " "
319  << "filter id: " << id << ", "
320  << "object id: " << candidate.id() << ", "
321  << "pT: " << candidate.pt() << ", "
322  << "eta: " << candidate.eta() << ", "
323  << "phi: " << candidate.phi() << ", "
324  << "mass: " << candidate.mass() << "\n";
325  }
326 }

References trigger::TriggerObject::eta(), ALCARECOTkAlBeamHalo_cff::filter, mps_fire::i, trigger::TriggerObject::id(), crabWrapper::key, trigger::TriggerObject::mass(), MillePedeFileConverter_cfg::out, trigger::TriggerObject::phi(), trigger::TriggerObject::pt(), and edmLumisInFiles::summary.

Referenced by HltDiff::compare().

◆ print_trigger_collection()

void print_trigger_collection ( std::ostream &  out,
trigger::TriggerEvent const &  summary,
std::string const &  tag 
)

Definition at line 328 of file hltDiff.cc.

328  {
329  auto iterator = std::find(summary.collectionTags().begin(), summary.collectionTags().end(), tag);
330  if (iterator == summary.collectionTags().end()) {
331  // the collection of trigger candidates could not be found
332  out << " not found\n";
333  return;
334  }
335 
336  unsigned int index = iterator - summary.collectionTags().begin();
337  unsigned int begin = (index == 0) ? 0 : summary.collectionKey(index - 1);
338  unsigned int end = summary.collectionKey(index);
339 
340  if (end == begin) {
341  // the collection of trigger candidates is empty
342  out << " none\n";
343  return;
344  }
345 
346  for (unsigned int key = begin; key < end; ++key) {
347  trigger::TriggerObject const& candidate = summary.getObjects().at(key);
348  out << " "
349  << "object id: " << candidate.id() << ", "
350  << "pT: " << candidate.pt() << ", "
351  << "eta: " << candidate.eta() << ", "
352  << "phi: " << candidate.phi() << ", "
353  << "mass: " << candidate.mass() << "\n";
354  }
355 }

References mps_fire::end, trigger::TriggerObject::eta(), spr::find(), trigger::TriggerObject::id(), crabWrapper::key, trigger::TriggerObject::mass(), MillePedeFileConverter_cfg::out, trigger::TriggerObject::phi(), trigger::TriggerObject::pt(), edmLumisInFiles::summary, and GlobalPosition_Frontier_DevDB_cff::tag.

Referenced by HltDiff::compare().

◆ strip_process_name()

std::string strip_process_name ( std::string const &  s)

Definition at line 273 of file hltDiff.cc.

273  {
274  if (std::count(s.begin(), s.end(), ':') == 2) {
275  // remove the process name and the second ':' separator
276  size_t end = s.find_last_of(':');
277  if (end > 0 and s.at(end - 1) == ':')
278  // no instance name, remove also the first ':' separator
279  --end;
280  return s.substr(0, end);
281  } else {
282  // no process name, return the string unchanged
283  return s;
284  }
285 }

References submitPVResolutionJobs::count, mps_fire::end, and alignCSCRings::s.

Referenced by HltDiff::compare().

trigger::TriggerObject::phi
float phi() const
Definition: TriggerObject.h:54
edm::pset::Registry::instance
static Registry * instance()
Definition: Registry.cc:12
change_name.diff
diff
Definition: change_name.py:13
cmsBatch.argv
argv
Definition: cmsBatch.py:279
mps_fire.i
i
Definition: mps_fire.py:428
Prescaled
Definition: hltDiff.cc:247
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
HLTConfigData
Definition: HLTConfigData.h:25
dir2webdir.argc
argc
Definition: dir2webdir.py:39
MicroEventContent_cff.branch
branch
Definition: MicroEventContent_cff.py:180
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
fileinputsource_cfi.option
option
Definition: fileinputsource_cfi.py:87
TriggerDiff::format
static std::string format(unsigned int value, char sign='+')
Definition: hltDiff.cc:394
edm::Wrapper
Definition: Product.h:10
config
Definition: config.py:1
alignCSCRings.s
s
Definition: alignCSCRings.py:92
trigger::TriggerObject::pt
float pt() const
Definition: TriggerObject.h:52
submitPVResolutionJobs.files
files
Definition: submitPVResolutionJobs.py:373
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
submitPVValidationJobs.split
def split(sequence, size)
Definition: submitPVValidationJobs.py:352
submitPVResolutionJobs.config
config
parse the configuration file
Definition: submitPVResolutionJobs.py:281
mps_fire.end
end
Definition: mps_fire.py:242
Pass
Definition: hltDiff.cc:244
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
trigger::TriggerObject
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:21
error
void error(std::ostream &out)
Definition: hltDiff.cc:44
edm::hlt::Fail
reject
Definition: HLTenums.h:19
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
Ready
Definition: hltDiff.cc:243
HltDiff
Definition: hltDiff.cc:1192
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
LaserDQM_cfg.process
process
Definition: LaserDQM_cfg.py:3
Exception
trigger::TriggerObject::id
int id() const
getters
Definition: TriggerObject.h:51
State
State
Definition: RPixErrorChecker.h:15
edm::hlt::Ready
not [yet] run
Definition: HLTenums.h:17
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
edmLumisInFiles.summary
summary
Definition: edmLumisInFiles.py:39
getProcessNameFromBranch
std::string getProcessNameFromBranch(std::string const &branch)
Definition: hltDiff.cc:357
trigger::TriggerObject::eta
float eta() const
Definition: TriggerObject.h:53
Invalid
Definition: hltDiff.cc:248
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
path_state
const char * path_state(State state)
Definition: hltDiff.cc:251
Fail
Definition: hltDiff.cc:245
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
check_file
bool check_file(std::string const &file)
Definition: hltDiff.cc:1177
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
edm::hlt::Exception
error
Definition: HLTenums.h:20
edm::hlt::Pass
accept
Definition: HLTenums.h:18
crabWrapper.key
key
Definition: crabWrapper.py:19
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
edm::pset::Registry::getMapped
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:17
trigger::TriggerObject::mass
float mass() const
Definition: TriggerObject.h:55
label
const char * label
Definition: PFTauDecayModeTools.cc:11
edm::ProcessConfiguration
Definition: ProcessConfiguration.h:14
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116
ValidationMatrix.hlt
hlt
Definition: ValidationMatrix.py:459