CMS 3D CMS Logo

TriggerBitChecker.cc
Go to the documentation of this file.
2 
4 #include <cassert>
5 #include <iostream>
6 
7 namespace heppy {
8 
9 TriggerBitChecker::TriggerBitChecker(const std::string &path) : paths_(1,returnPathStruct(path)) { rmstar(); }
10 
11 TriggerBitChecker::TriggerBitChecker(const std::vector<std::string> &paths) : paths_(paths.size()) {
12  for(size_t i = 0; i < paths.size(); ++ i) paths_[i] = returnPathStruct(paths[i]);
13  rmstar();
14 }
15 
17  pathStruct newPathStruct(path);
18  if( path[0] > 48 /*'0'*/ && path[0] <= 57 /*'9'*/ ) {
19  newPathStruct.first = atoi(path.substr(0,path.find('-')).c_str());
20  newPathStruct.last = atoi(path.substr(path.find('-')+1,path.find(':')-path.find('-')-1).c_str());
21  newPathStruct.pathName = path.substr(path.find(':')+1);
22  }
23  return newPathStruct;
24 }
25 
27  if (result.parameterSetID() != lastID_) { syncIndices(event, result); lastID_ = result.parameterSetID(); }
28  for (std::vector<unsigned int>::const_iterator it = indices_.begin(), ed = indices_.end(); it != ed; ++it) {
29  if (result.accept(*it)) return true;
30  }
31  return false;
32 }
33 
35  if (result_tr.parameterSetID() != lastID_) { syncIndices(event, result_tr); lastID_ = result_tr.parameterSetID(); }
36  bool outcome = true;
37  for (std::vector<unsigned int>::const_iterator it = indices_.begin(), ed = indices_.end(); it != ed; ++it) {
38  if (result.getPrescaleForIndex(*it)!=1) {outcome = false; break;}
39  }
40  return outcome; // true only if all paths are unprescaled
41 }
42 
44  if (result_tr.parameterSetID() != lastID_) { syncIndices(event, result_tr); lastID_ = result_tr.parameterSetID(); }
45  if (indices_.empty() ){
46  // std::cout << " trying to check an inexistent trigger" << std::endl;
47  return -999;
48  }
49  if (indices_.size() > 1 ){
50  std::cout << " trying to get prescale for multiple trigger objects at the same time" << std::endl;
51  assert(0);
52  }
53 
54  return result.getPrescaleForIndex(*(indices_.begin())) ;
55 }
56 
57 
59  indices_.clear();
60  const edm::TriggerNames &names = event.triggerNames(result);
61  std::vector<pathStruct>::const_iterator itp, bgp = paths_.begin(), edp = paths_.end();
62  for (size_t i = 0, n = names.size(); i < n; ++i) {
63  const std::string &thispath = names.triggerName(i);
64  for (itp = bgp; itp != edp; ++itp) {
65  if (thispath.find(itp->pathName) == 0 && event.id().run() >= itp->first && event.id().run() <= itp->last) indices_.push_back(i);
66  }
67  }
68 }
69 
71  std::vector<pathStruct>::iterator itp, bgp = paths_.begin(), edp = paths_.end();
72  for (itp = bgp; itp != edp; ++itp) {
73  std::string::size_type idx = itp->pathName.find("*");
74  if (idx != std::string::npos) itp->pathName.erase(idx);
75  }
76 }
77 }
void rmstar()
executes a &#39;rm -rf *&#39; in current directory
size
Write out results.
bool check_unprescaled(const edm::EventBase &event, const edm::TriggerResults &result_tr, const pat::PackedTriggerPrescales &result) const
bool check(const edm::EventBase &event, const edm::TriggerResults &result) const
bool accept() const
Has at least one path accepted the event?
Strings::size_type size() const
Definition: TriggerNames.cc:39
uint16_t size_type
const std::string names[nVars_]
int getprescale(const edm::EventBase &event, const edm::TriggerResults &result_tr, const pat::PackedTriggerPrescales &result) const
TAKEN FROM http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/ElectroWeakAnalysis/Utilities/src/PdfWeig...
Definition: AlphaT.h:17
std::vector< pathStruct > paths_
TriggerBitChecker(const std::string &path="DUMMY")
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
std::vector< unsigned int > indices_
int getPrescaleForIndex(int index) const
edm::ParameterSetID lastID_
const ParameterSetID & parameterSetID() const
Get stored parameter set id.
pathStruct returnPathStruct(const std::string &path) const
Definition: event.py:1
void syncIndices(const edm::EventBase &event, const edm::TriggerResults &result) const
sync indices with path names