test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
VIDCutFlowResult.cc
Go to the documentation of this file.
3 
4 namespace {
5  static const std::string empty_str("");
6 }
7 
8 namespace vid {
9 
11  const std::string& hash,
12  const std::map<std::string,unsigned>& n2idx,
13  const std::vector<double>& values,
14  unsigned bitmap,
15  unsigned mask) :
16  name_(name),
17  hash_(hash),
18  bitmap_(bitmap),
19  mask_(mask),
20  values_(values) {
21  for( const auto& val : n2idx ) {
22  names_.push_back(val.first);
23  indices_.push_back(val.second);
24  }
25  }
26 
27  const std::string& CutFlowResult::getNameAtIndex(const unsigned idx) const {
28  unsigned internal_idx = 0;
29  for( const auto& value : indices_ ) {
30  if( value == idx ) return names_[internal_idx];
31  ++internal_idx;
32  }
33  throw cms::Exception("IndexNotFound")
34  << "index = " << idx << " has no corresponding cut name!";
35  return empty_str;
36  }
37 
38  bool CutFlowResult::getCutResultByIndex(const unsigned idx) const {
39  if( idx >= indices_.size() ) {
40  throw cms::Exception("OutOfBounds")
41  << idx << " is out of bounds for this cut flow!";
42  }
43  return getCutBit(idx);
44  }
45 
47  auto found_name = std::lower_bound(names_.begin(),names_.end(),name);
48  if( found_name == names_.end() || *found_name != name ) {
49  throw cms::Exception("UnknownName")
50  << "Cut name: " << name
51  << " is not known for this cutflow!";
52  }
53  return getCutBit(indices_[std::distance(names_.begin(),found_name)]);
54  }
55 
56  bool CutFlowResult::isCutMasked(const unsigned idx) const {
57  if( idx >= indices_.size() ) {
58  throw cms::Exception("OutOfBounds")
59  << idx << " is out of bounds for this cut flow!";
60  }
61  return getMaskBit(idx);
62  }
63 
65  auto found_name = std::lower_bound(names_.begin(),names_.end(),name);
66  if( found_name == names_.end() || *found_name != name ) {
67  throw cms::Exception("UnknownName")
68  << "Cut name: " << name
69  << " is not known for this cutflow!";
70  }
71  return getMaskBit(indices_[std::distance(names_.begin(),found_name)]);
72  }
73 
74  double CutFlowResult::getValueCutUpon(const unsigned idx) const {
75  if( idx >= indices_.size() ) {
76  throw cms::Exception("OutOfBounds")
77  << idx << " is out of bounds for this cut flow!";
78  }
79  return getCutValue(idx);
80  }
81 
83  auto found_name = std::lower_bound(names_.begin(),names_.end(),name);
84  if( found_name == names_.end() || *found_name != name ) {
85  throw cms::Exception("UnknownName")
86  << "Cut name: " << name
87  << " is not known for this cutflow!";
88  }
89  return getCutValue(indices_[std::distance(names_.begin(),found_name)]);
90  }
91 
93  getCutFlowResultMasking(const std::vector<unsigned>& idxs) const {
94  unsigned bitmap = bitmap_;
95  unsigned mask = mask_;
96  for( const unsigned idx : idxs ) {
97  if( idx >= indices_.size() ) {
98  throw cms::Exception("OutOfBounds")
99  << idx << " is out of bounds for this cut flow!";
100  }
101  mask = mask | 1 << idx;
102  }
103  bitmap = bitmap | mask;
104  return CutFlowResult(name_,empty_str,names_,indices_,values_,bitmap,mask);
105  }
106 
108  getCutFlowResultMasking(const std::vector<std::string>& names) const {
109  unsigned bitmap = bitmap_;
110  unsigned mask = mask_;
111  for( const std::string& name : names ) {
112  auto found_name = std::lower_bound(names_.begin(),names_.end(),name);
113  if( found_name == names_.end() || *found_name != name ) {
114  throw cms::Exception("UnknownName")
115  << "Cut name: " << name
116  << " is not known for this cutflow!";
117  }
118  mask = mask | 1 << indices_[std::distance(names_.begin(),found_name)];
119  }
120  bitmap = bitmap | mask;
121  return CutFlowResult(name_,empty_str,names_,indices_,values_,bitmap,mask);
122  }
123 
125  getCutFlowResultMasking(const unsigned idx) const {
126  unsigned bitmap = bitmap_;
127  unsigned mask = mask_;
128  if( idx >= indices_.size() ) {
129  throw cms::Exception("OutOfBounds")
130  << idx << " is out of bounds for this cut flow!";
131  }
132  mask = mask | 1 << idx;
133  bitmap = bitmap | mask;
134  return CutFlowResult(name_,empty_str,names_,indices_,values_,bitmap,mask);
135  }
136 
139  unsigned bitmap = bitmap_;
140  unsigned mask = mask_;
141  auto found_name = std::lower_bound(names_.begin(),names_.end(),name);
142  if( found_name == names_.end() || *found_name != name ) {
143  throw cms::Exception("UnknownName")
144  << "Cut name: " << name
145  << " is not known for this cutflow!";
146  }
147  mask = mask | 1 << indices_[std::distance(names_.begin(),found_name)];
148  bitmap = bitmap | mask;
149  return CutFlowResult(name_,empty_str,names_,indices_,values_,bitmap,mask);
150  }
151 }
static const HistoName names[]
bool getCutResultByIndex(const unsigned idx) const
std::vector< unsigned > indices_
std::vector< std::string > names_
bool getCutResultByName(const std::string &name) const
bool isCutMasked(const unsigned idx) const
std::vector< double > values_
double getCutValue(const unsigned idx) const
bool getCutBit(const unsigned idx) const
const std::string & getNameAtIndex(const unsigned idx) const
CutFlowResult getCutFlowResultMasking(const unsigned idx) const
double getValueCutUpon(const unsigned idx) const
bool getMaskBit(const unsigned idx) const