CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
vid::CutFlowResult Class Reference

#include <VIDCutFlowResult.h>

Public Member Functions

const std::string & cutFlowHash () const
 
const std::string & cutFlowName () const
 
bool cutFlowPassed () const
 
 CutFlowResult ()
 
 CutFlowResult (const std::string &name, const std::string &hash, const std::map< std::string, unsigned > &n2idx, const std::vector< double > &values, unsigned bitmap, unsigned mask=0)
 
size_t cutFlowSize () const
 
CutFlowResult getCutFlowResultMasking (const unsigned idx) const
 
CutFlowResult getCutFlowResultMasking (const std::string &name) const
 
CutFlowResult getCutFlowResultMasking (const std::vector< unsigned > &idxs) const
 
CutFlowResult getCutFlowResultMasking (const std::vector< std::string > &names) const
 
bool getCutResultByIndex (const unsigned idx) const
 
bool getCutResultByName (const std::string &name) const
 
const std::string & getNameAtIndex (const unsigned idx) const
 
double getValueCutUpon (const unsigned idx) const
 
double getValueCutUpon (const std::string &name) const
 
bool isCutMasked (const unsigned idx) const
 
bool isCutMasked (const std::string &name) const
 

Private Member Functions

 CutFlowResult (const std::string &name, const std::string &hash, const std::vector< std::string > &names, const std::vector< unsigned > &indices, const std::vector< double > &values, unsigned bitmap, unsigned mask)
 
bool getCutBit (const unsigned idx) const
 
double getCutValue (const unsigned idx) const
 
bool getMaskBit (const unsigned idx) const
 

Private Attributes

unsigned bitmap_
 
std::string hash_
 
std::vector< unsigned > indices_
 
unsigned mask_
 
std::string name_
 
std::vector< std::string > names_
 
std::vector< double > values_
 

Friends

template<class T >
class VersionedSelector
 

Detailed Description

Definition at line 27 of file VIDCutFlowResult.h.

Constructor & Destructor Documentation

vid::CutFlowResult::CutFlowResult ( )
inline
vid::CutFlowResult::CutFlowResult ( const std::string &  name,
const std::string &  hash,
const std::map< std::string, unsigned > &  n2idx,
const std::vector< double > &  values,
unsigned  bitmap,
unsigned  mask = 0 
)

Definition at line 10 of file VIDCutFlowResult.cc.

References indices_, names_, and heppy_batch::val.

15  :
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  }
std::vector< unsigned > indices_
std::vector< std::string > names_
std::vector< double > values_
vid::CutFlowResult::CutFlowResult ( const std::string &  name,
const std::string &  hash,
const std::vector< std::string > &  names,
const std::vector< unsigned > &  indices,
const std::vector< double > &  values,
unsigned  bitmap,
unsigned  mask 
)
inlineprivate

Definition at line 82 of file VIDCutFlowResult.h.

88  :
89  name_(name),
90  hash_(hash),
91  bitmap_(bitmap),
92  mask_(mask),
93  values_(values),
94  names_(names),
95  indices_(indices) {}
std::vector< unsigned > indices_
std::vector< std::string > names_
const std::string names[nVars_]
std::vector< double > values_

Member Function Documentation

const std::string& vid::CutFlowResult::cutFlowHash ( ) const
inline

Definition at line 42 of file VIDCutFlowResult.h.

References hash_.

42 { return hash_; }
const std::string& vid::CutFlowResult::cutFlowName ( ) const
inline

Definition at line 40 of file VIDCutFlowResult.h.

References name_.

40 { return name_; }
bool vid::CutFlowResult::cutFlowPassed ( ) const
inline

Definition at line 44 of file VIDCutFlowResult.h.

References bitmap_, and indices_.

44  {
45  const unsigned all_pass = (1 << indices_.size()) - 1;
46  return (all_pass&bitmap_) == all_pass;
47  }
std::vector< unsigned > indices_
size_t vid::CutFlowResult::cutFlowSize ( ) const
inline
bool vid::CutFlowResult::getCutBit ( const unsigned  idx) const
inlineprivate

Definition at line 102 of file VIDCutFlowResult.h.

References training_settings::idx.

Referenced by getCutResultByIndex(), and getCutResultByName().

102  {
103  return (bool)(0x1&(bitmap_>>idx));
104  }
CutFlowResult vid::CutFlowResult::getCutFlowResultMasking ( const unsigned  idx) const

Definition at line 125 of file VIDCutFlowResult.cc.

References bitmap_, CutFlowResult(), Exception, training_settings::idx, indices_, RecoTauDiscriminantConfiguration::mask, mask_, name_, names_, and values_.

Referenced by cutFlowSize(), getCutFlowResultMasking(), and getValueCutUpon().

125  {
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  }
std::vector< unsigned > indices_
std::vector< std::string > names_
std::vector< double > values_
CutFlowResult vid::CutFlowResult::getCutFlowResultMasking ( const std::string &  name) const

Definition at line 138 of file VIDCutFlowResult.cc.

References bitmap_, CutFlowResult(), SoftLeptonByDistance_cfi::distance, Exception, indices_, RecoTauDiscriminantConfiguration::mask, mask_, dataset::name, name_, names_, and values_.

138  {
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  }
std::vector< unsigned > indices_
std::vector< std::string > names_
std::vector< double > values_
CutFlowResult vid::CutFlowResult::getCutFlowResultMasking ( const std::vector< unsigned > &  idxs) const

Definition at line 93 of file VIDCutFlowResult.cc.

References bitmap_, CutFlowResult(), Exception, getCutFlowResultMasking(), training_settings::idx, indices_, RecoTauDiscriminantConfiguration::mask, mask_, name_, names_, and values_.

93  {
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  }
std::vector< unsigned > indices_
std::vector< std::string > names_
std::vector< double > values_
CutFlowResult vid::CutFlowResult::getCutFlowResultMasking ( const std::vector< std::string > &  names) const

Definition at line 108 of file VIDCutFlowResult.cc.

References bitmap_, CutFlowResult(), SoftLeptonByDistance_cfi::distance, Exception, getCutFlowResultMasking(), indices_, RecoTauDiscriminantConfiguration::mask, mask_, dataset::name, name_, names_, AlCaHLTBitMon_QueryRunRegistry::string, and values_.

108  {
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  }
std::vector< unsigned > indices_
std::vector< std::string > names_
const std::string names[nVars_]
std::vector< double > values_
bool vid::CutFlowResult::getCutResultByIndex ( const unsigned  idx) const

Definition at line 38 of file VIDCutFlowResult.cc.

References Exception, getCutBit(), and indices_.

Referenced by cutFlowSize().

38  {
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  }
std::vector< unsigned > indices_
bool getCutBit(const unsigned idx) const
bool vid::CutFlowResult::getCutResultByName ( const std::string &  name) const

Definition at line 46 of file VIDCutFlowResult.cc.

References SoftLeptonByDistance_cfi::distance, Exception, getCutBit(), indices_, dataset::name, and names_.

Referenced by cutFlowSize().

46  {
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  }
std::vector< unsigned > indices_
std::vector< std::string > names_
bool getCutBit(const unsigned idx) const
double vid::CutFlowResult::getCutValue ( const unsigned  idx) const
inlineprivate

Definition at line 106 of file VIDCutFlowResult.h.

References training_settings::idx.

Referenced by getValueCutUpon().

106  {
107  return values_[idx];
108  }
std::vector< double > values_
bool vid::CutFlowResult::getMaskBit ( const unsigned  idx) const
inlineprivate

Definition at line 98 of file VIDCutFlowResult.h.

References training_settings::idx.

Referenced by isCutMasked().

98  {
99  return (bool)(0x1&(mask_>>idx));
100  }
const std::string & vid::CutFlowResult::getNameAtIndex ( const unsigned  idx) const

Definition at line 27 of file VIDCutFlowResult.cc.

References Exception, indices_, and names_.

Referenced by cutFlowSize().

27  {
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  }
std::vector< unsigned > indices_
std::vector< std::string > names_
Definition: value.py:1
double vid::CutFlowResult::getValueCutUpon ( const unsigned  idx) const

Definition at line 74 of file VIDCutFlowResult.cc.

References Exception, getCutValue(), and indices_.

Referenced by cutFlowSize().

74  {
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  }
std::vector< unsigned > indices_
double getCutValue(const unsigned idx) const
double vid::CutFlowResult::getValueCutUpon ( const std::string &  name) const

Definition at line 82 of file VIDCutFlowResult.cc.

References SoftLeptonByDistance_cfi::distance, Exception, getCutFlowResultMasking(), getCutValue(), indices_, dataset::name, and names_.

82  {
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  }
std::vector< unsigned > indices_
std::vector< std::string > names_
double getCutValue(const unsigned idx) const
bool vid::CutFlowResult::isCutMasked ( const unsigned  idx) const

Definition at line 56 of file VIDCutFlowResult.cc.

References Exception, getMaskBit(), and indices_.

Referenced by cutFlowSize().

56  {
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  }
std::vector< unsigned > indices_
bool getMaskBit(const unsigned idx) const
bool vid::CutFlowResult::isCutMasked ( const std::string &  name) const

Definition at line 64 of file VIDCutFlowResult.cc.

References SoftLeptonByDistance_cfi::distance, Exception, getMaskBit(), indices_, dataset::name, and names_.

64  {
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  }
std::vector< unsigned > indices_
std::vector< std::string > names_
bool getMaskBit(const unsigned idx) const

Friends And Related Function Documentation

template<class T >
friend class VersionedSelector
friend

Definition at line 28 of file VIDCutFlowResult.h.

Member Data Documentation

unsigned vid::CutFlowResult::bitmap_
private

Definition at line 77 of file VIDCutFlowResult.h.

Referenced by cutFlowPassed(), and getCutFlowResultMasking().

std::string vid::CutFlowResult::hash_
private

Definition at line 76 of file VIDCutFlowResult.h.

Referenced by cutFlowHash().

std::vector<unsigned> vid::CutFlowResult::indices_
private
unsigned vid::CutFlowResult::mask_
private

Definition at line 77 of file VIDCutFlowResult.h.

Referenced by getCutFlowResultMasking().

std::string vid::CutFlowResult::name_
private

Definition at line 76 of file VIDCutFlowResult.h.

Referenced by cutFlowName(), and getCutFlowResultMasking().

std::vector<std::string> vid::CutFlowResult::names_
private
std::vector<double> vid::CutFlowResult::values_
private

Definition at line 78 of file VIDCutFlowResult.h.

Referenced by getCutFlowResultMasking().