CMS 3D CMS Logo

TriggerBitChecker.cc
Go to the documentation of this file.
3 
4 namespace heppy {
5 
6  TriggerBitChecker::TriggerBitChecker(const std::string &path) : paths_(1, returnPathStruct(path)) { rmstar(); }
7 
8  TriggerBitChecker::TriggerBitChecker(const std::vector<std::string> &paths) : paths_(paths.size()) {
9  for (size_t i = 0; i < paths.size(); ++i)
11  rmstar();
12  }
13 
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  }
23 
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  }
35 
37  const edm::TriggerResults &result_tr,
38  const pat::PackedTriggerPrescales &result) const {
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  }
52 
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  }
65 
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  }
74 } // namespace heppy
void rmstar()
executes a &#39;rm -rf *&#39; in current directory
bool check_unprescaled(const edm::EventBase &event, const edm::TriggerResults &result_tr, const pat::PackedTriggerPrescales &result) const
pathStruct returnPathStruct(const std::string &path) const
bool check(const edm::EventBase &event, const edm::TriggerResults &result) const
const ParameterSetID & parameterSetID() const
Get stored parameter set id.
uint16_t size_type
const std::string names[nVars_]
TAKEN FROM http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/ElectroWeakAnalysis/Utilities/src/PdfWeig...
Definition: AlphaT.h:16
std::vector< pathStruct > paths_
TriggerBitChecker(const std::string &path="DUMMY")
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