CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
heppy::TriggerBitChecker Class Reference

#include <TriggerBitChecker.h>

Classes

struct  pathStruct
 

Public Member Functions

bool check (const edm::EventBase &event, const edm::TriggerResults &result) const
 
bool check_unprescaled (const edm::EventBase &event, const edm::TriggerResults &result_tr, const pat::PackedTriggerPrescales &result) const
 
template<typename T = int>
T getprescale (const edm::EventBase &event, const edm::TriggerResults &result_tr, const pat::PackedTriggerPrescales &result) const
 
 TriggerBitChecker (const std::string &path="DUMMY")
 
 TriggerBitChecker (const std::vector< std::string > &paths)
 
 ~TriggerBitChecker ()
 

Private Member Functions

pathStruct returnPathStruct (const std::string &path) const
 
void rmstar ()
 executes a 'rm -rf *' in current directory More...
 
void syncIndices (const edm::EventBase &event, const edm::TriggerResults &result) const
 sync indices with path names More...
 

Private Attributes

std::vector< unsigned int > indices_
 
edm::ParameterSetID lastID_
 
std::vector< pathStructpaths_
 

Detailed Description

Definition at line 16 of file TriggerBitChecker.h.

Constructor & Destructor Documentation

◆ TriggerBitChecker() [1/2]

heppy::TriggerBitChecker::TriggerBitChecker ( const std::string &  path = "DUMMY")

Definition at line 6 of file TriggerBitChecker.cc.

References rmstar().

void rmstar()
executes a &#39;rm -rf *&#39; in current directory
pathStruct returnPathStruct(const std::string &path) const
std::vector< pathStruct > paths_

◆ TriggerBitChecker() [2/2]

heppy::TriggerBitChecker::TriggerBitChecker ( const std::vector< std::string > &  paths)

Definition at line 8 of file TriggerBitChecker.cc.

References mps_fire::i, Skims_PA_cff::paths, paths_, returnPathStruct(), and rmstar().

8  : paths_(paths.size()) {
9  for (size_t i = 0; i < paths.size(); ++i)
11  rmstar();
12  }
void rmstar()
executes a &#39;rm -rf *&#39; in current directory
pathStruct returnPathStruct(const std::string &path) const
std::vector< pathStruct > paths_

◆ ~TriggerBitChecker()

heppy::TriggerBitChecker::~TriggerBitChecker ( )
inline

Definition at line 28 of file TriggerBitChecker.h.

28 {}

Member Function Documentation

◆ check()

bool heppy::TriggerBitChecker::check ( const edm::EventBase event,
const edm::TriggerResults result 
) const

Definition at line 24 of file TriggerBitChecker.cc.

References indices_, lastID_, mps_fire::result, and syncIndices().

24  {
25  if (result.parameterSetID() != lastID_) {
27  lastID_ = result.parameterSetID();
28  }
29  for (std::vector<unsigned int>::const_iterator it = indices_.begin(), ed = indices_.end(); it != ed; ++it) {
30  if (result.accept(*it))
31  return true;
32  }
33  return false;
34  }
void syncIndices(const edm::EventBase &event, const edm::TriggerResults &result) const
sync indices with path names
std::vector< unsigned int > indices_
edm::ParameterSetID lastID_
Definition: event.py:1

◆ check_unprescaled()

bool heppy::TriggerBitChecker::check_unprescaled ( const edm::EventBase event,
const edm::TriggerResults result_tr,
const pat::PackedTriggerPrescales result 
) const

Definition at line 36 of file TriggerBitChecker.cc.

References indices_, lastID_, edm::TriggerResults::parameterSetID(), mps_fire::result, and syncIndices().

38  {
39  if (result_tr.parameterSetID() != lastID_) {
40  syncIndices(event, result_tr);
41  lastID_ = result_tr.parameterSetID();
42  }
43  bool outcome = true;
44  for (std::vector<unsigned int>::const_iterator it = indices_.begin(), ed = indices_.end(); it != ed; ++it) {
45  if (result.getPrescaleForIndex<double>(*it) != 1) {
46  outcome = false;
47  break;
48  }
49  }
50  return outcome; // true only if all paths are unprescaled
51  }
const ParameterSetID & parameterSetID() const
Get stored parameter set id.
void syncIndices(const edm::EventBase &event, const edm::TriggerResults &result) const
sync indices with path names
std::vector< unsigned int > indices_
edm::ParameterSetID lastID_
Definition: event.py:1

◆ getprescale()

template<typename T >
T heppy::TriggerBitChecker::getprescale ( const edm::EventBase event,
const edm::TriggerResults result_tr,
const pat::PackedTriggerPrescales result 
) const

Definition at line 59 of file TriggerBitChecker.h.

References cms::cuda::assert(), gather_cfg::cout, indices_, lastID_, edm::TriggerResults::parameterSetID(), mps_fire::result, and syncIndices().

61  {
62  static_assert(std::is_same_v<T, double>,
63  "\n\n\tPlease use getprescale<double> "
64  "(other types for trigger prescales are not supported anymore by TriggerBitChecker)");
65  if (result_tr.parameterSetID() != lastID_) {
66  syncIndices(event, result_tr);
67  lastID_ = result_tr.parameterSetID();
68  }
69  if (indices_.empty()) {
70  return -999;
71  }
72  if (indices_.size() > 1) {
73  std::cout << " trying to get prescale for multiple trigger objects at the same time" << std::endl;
74  assert(0);
75  }
76 
77  return result.getPrescaleForIndex<T>(*(indices_.begin()));
78  }
const ParameterSetID & parameterSetID() const
Get stored parameter set id.
assert(be >=bs)
void syncIndices(const edm::EventBase &event, const edm::TriggerResults &result) const
sync indices with path names
std::vector< unsigned int > indices_
long double T
edm::ParameterSetID lastID_
Definition: event.py:1

◆ returnPathStruct()

TriggerBitChecker::pathStruct heppy::TriggerBitChecker::returnPathStruct ( const std::string &  path) const
private

Definition at line 14 of file TriggerBitChecker.cc.

References heppy::TriggerBitChecker::pathStruct::first, heppy::TriggerBitChecker::pathStruct::last, castor_dqm_sourceclient_file_cfg::path, and heppy::TriggerBitChecker::pathStruct::pathName.

Referenced by TriggerBitChecker().

14  {
15  pathStruct newPathStruct(path);
16  if (path[0] > 48 /*'0'*/ && path[0] <= 57 /*'9'*/) {
17  newPathStruct.first = atoi(path.substr(0, path.find('-')).c_str());
18  newPathStruct.last = atoi(path.substr(path.find('-') + 1, path.find(':') - path.find('-') - 1).c_str());
19  newPathStruct.pathName = path.substr(path.find(':') + 1);
20  }
21  return newPathStruct;
22  }

◆ rmstar()

void heppy::TriggerBitChecker::rmstar ( )
private

executes a 'rm -rf *' in current directory

Definition at line 66 of file TriggerBitChecker.cc.

References heavyIonCSV_trainingSettings::idx, and paths_.

Referenced by TriggerBitChecker().

66  {
67  std::vector<pathStruct>::iterator itp, bgp = paths_.begin(), edp = paths_.end();
68  for (itp = bgp; itp != edp; ++itp) {
69  std::string::size_type idx = itp->pathName.find('*');
70  if (idx != std::string::npos)
71  itp->pathName.erase(idx);
72  }
73  }
uint16_t size_type
std::vector< pathStruct > paths_

◆ syncIndices()

void heppy::TriggerBitChecker::syncIndices ( const edm::EventBase event,
const edm::TriggerResults result 
) const
private

sync indices with path names

Definition at line 53 of file TriggerBitChecker.cc.

References mps_fire::i, indices_, dqmiodumpmetadata::n, names, paths_, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by check(), check_unprescaled(), and getprescale().

53  {
54  indices_.clear();
55  const edm::TriggerNames &names = event.triggerNames(result);
56  std::vector<pathStruct>::const_iterator itp, bgp = paths_.begin(), edp = paths_.end();
57  for (size_t i = 0, n = names.size(); i < n; ++i) {
58  const std::string &thispath = names.triggerName(i);
59  for (itp = bgp; itp != edp; ++itp) {
60  if (thispath.find(itp->pathName) == 0 && event.id().run() >= itp->first && event.id().run() <= itp->last)
61  indices_.push_back(i);
62  }
63  }
64  }
const std::string names[nVars_]
std::vector< pathStruct > paths_
std::vector< unsigned int > indices_

Member Data Documentation

◆ indices_

std::vector<unsigned int> heppy::TriggerBitChecker::indices_
mutableprivate

Definition at line 48 of file TriggerBitChecker.h.

Referenced by check(), check_unprescaled(), getprescale(), and syncIndices().

◆ lastID_

edm::ParameterSetID heppy::TriggerBitChecker::lastID_
mutableprivate

Definition at line 47 of file TriggerBitChecker.h.

Referenced by check(), check_unprescaled(), and getprescale().

◆ paths_

std::vector<pathStruct> heppy::TriggerBitChecker::paths_
private