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
 
int 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 12 of file TriggerBitChecker.h.

Constructor & Destructor Documentation

◆ TriggerBitChecker() [1/2]

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

Definition at line 9 of file TriggerBitChecker.cc.

References rmstar().

◆ TriggerBitChecker() [2/2]

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

Definition at line 11 of file TriggerBitChecker.cc.

11  : paths_(paths.size()) {
12  for (size_t i = 0; i < paths.size(); ++i)
14  rmstar();
15  }

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

◆ ~TriggerBitChecker()

heppy::TriggerBitChecker::~TriggerBitChecker ( )
inline

Definition at line 24 of file TriggerBitChecker.h.

24 {}

Member Function Documentation

◆ check()

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

Definition at line 27 of file TriggerBitChecker.cc.

27  {
28  if (result.parameterSetID() != lastID_) {
30  lastID_ = result.parameterSetID();
31  }
32  for (std::vector<unsigned int>::const_iterator it = indices_.begin(), ed = indices_.end(); it != ed; ++it) {
33  if (result.accept(*it))
34  return true;
35  }
36  return false;
37  }

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

◆ check_unprescaled()

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

Definition at line 39 of file TriggerBitChecker.cc.

41  {
42  if (result_tr.parameterSetID() != lastID_) {
43  syncIndices(event, result_tr);
44  lastID_ = result_tr.parameterSetID();
45  }
46  bool outcome = true;
47  for (std::vector<unsigned int>::const_iterator it = indices_.begin(), ed = indices_.end(); it != ed; ++it) {
48  if (result.getPrescaleForIndex(*it) != 1) {
49  outcome = false;
50  break;
51  }
52  }
53  return outcome; // true only if all paths are unprescaled
54  }

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

◆ getprescale()

int heppy::TriggerBitChecker::getprescale ( const edm::EventBase event,
const edm::TriggerResults result_tr,
const pat::PackedTriggerPrescales result 
) const

Definition at line 56 of file TriggerBitChecker.cc.

58  {
59  if (result_tr.parameterSetID() != lastID_) {
60  syncIndices(event, result_tr);
61  lastID_ = result_tr.parameterSetID();
62  }
63  if (indices_.empty()) {
64  // std::cout << " trying to check an inexistent trigger" << std::endl;
65  return -999;
66  }
67  if (indices_.size() > 1) {
68  std::cout << " trying to get prescale for multiple trigger objects at the same time" << std::endl;
69  assert(0);
70  }
71 
72  return result.getPrescaleForIndex(*(indices_.begin()));
73  }

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

◆ returnPathStruct()

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

Definition at line 17 of file TriggerBitChecker.cc.

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

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

Referenced by TriggerBitChecker().

◆ rmstar()

void heppy::TriggerBitChecker::rmstar ( )
private

executes a 'rm -rf *' in current directory

Definition at line 88 of file TriggerBitChecker.cc.

88  {
89  std::vector<pathStruct>::iterator itp, bgp = paths_.begin(), edp = paths_.end();
90  for (itp = bgp; itp != edp; ++itp) {
91  std::string::size_type idx = itp->pathName.find('*');
92  if (idx != std::string::npos)
93  itp->pathName.erase(idx);
94  }
95  }

References heavyIonCSV_trainingSettings::idx, and paths_.

Referenced by TriggerBitChecker().

◆ syncIndices()

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

sync indices with path names

Definition at line 75 of file TriggerBitChecker.cc.

75  {
76  indices_.clear();
77  const edm::TriggerNames &names = event.triggerNames(result);
78  std::vector<pathStruct>::const_iterator itp, bgp = paths_.begin(), edp = paths_.end();
79  for (size_t i = 0, n = names.size(); i < n; ++i) {
80  const std::string &thispath = names.triggerName(i);
81  for (itp = bgp; itp != edp; ++itp) {
82  if (thispath.find(itp->pathName) == 0 && event.id().run() >= itp->first && event.id().run() <= itp->last)
83  indices_.push_back(i);
84  }
85  }
86  }

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

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

Member Data Documentation

◆ indices_

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

Definition at line 39 of file TriggerBitChecker.h.

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

◆ lastID_

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

Definition at line 38 of file TriggerBitChecker.h.

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

◆ paths_

std::vector<pathStruct> heppy::TriggerBitChecker::paths_
private
mps_fire.i
i
Definition: mps_fire.py:428
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::TriggerResults::parameterSetID
const ParameterSetID & parameterSetID() const
Get stored parameter set id.
Definition: TriggerResults.h:57
heppy::TriggerBitChecker::rmstar
void rmstar()
executes a 'rm -rf *' in current directory
Definition: TriggerBitChecker.cc:88
cms::cuda::assert
assert(be >=bs)
heppy::TriggerBitChecker::returnPathStruct
pathStruct returnPathStruct(const std::string &path) const
Definition: TriggerBitChecker.cc:17
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
heppy::TriggerBitChecker::indices_
std::vector< unsigned int > indices_
Definition: TriggerBitChecker.h:39
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
heppy::TriggerBitChecker::paths_
std::vector< pathStruct > paths_
Definition: TriggerBitChecker.h:36
heppy::TriggerBitChecker::syncIndices
void syncIndices(const edm::EventBase &event, const edm::TriggerResults &result) const
sync indices with path names
Definition: TriggerBitChecker.cc:75
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
heppy::TriggerBitChecker::lastID_
edm::ParameterSetID lastID_
Definition: TriggerBitChecker.h:38
edm::TriggerNames
Definition: TriggerNames.h:55
Skims_PA_cff.paths
paths
Definition: Skims_PA_cff.py:18
mps_fire.result
result
Definition: mps_fire.py:311
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
event
Definition: event.py:1