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

◆ CutFlowResult() [1/3]

vid::CutFlowResult::CutFlowResult ( )
inline

Definition at line 32 of file VIDCutFlowResult.h.

Referenced by getCutFlowResultMasking().

32 : bitmap_(0) {}

◆ CutFlowResult() [2/3]

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.

16  : name_(name), hash_(hash), bitmap_(bitmap), mask_(mask), values_(values) {
17  for (const auto& val : n2idx) {
18  names_.push_back(val.first);
19  indices_.push_back(val.second);
20  }
21  }
std::vector< unsigned > indices_
std::vector< std::string > names_
std::vector< double > values_

◆ CutFlowResult() [3/3]

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 83 of file VIDCutFlowResult.h.

std::vector< unsigned > indices_
std::vector< std::string > names_
const std::string names[nVars_]
std::vector< double > values_

Member Function Documentation

◆ cutFlowHash()

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

Definition at line 43 of file VIDCutFlowResult.h.

References hash_.

43 { return hash_; }

◆ cutFlowName()

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

Definition at line 41 of file VIDCutFlowResult.h.

References name_.

41 { return name_; }

◆ cutFlowPassed()

bool vid::CutFlowResult::cutFlowPassed ( ) const
inline

Definition at line 45 of file VIDCutFlowResult.h.

References bitmap_, and indices_.

45  {
46  const unsigned all_pass = (1 << indices_.size()) - 1;
47  return (all_pass & bitmap_) == all_pass;
48  }
std::vector< unsigned > indices_

◆ cutFlowSize()

size_t vid::CutFlowResult::cutFlowSize ( ) const
inline

Definition at line 50 of file VIDCutFlowResult.h.

References indices_.

50 { return indices_.size(); }
std::vector< unsigned > indices_

◆ getCutBit()

bool vid::CutFlowResult::getCutBit ( const unsigned  idx) const
inlineprivate

Definition at line 94 of file VIDCutFlowResult.h.

References bitmap_, and heavyIonCSV_trainingSettings::idx.

Referenced by getCutResultByIndex(), and getCutResultByName().

94 { return (bool)(0x1 & (bitmap_ >> idx)); }

◆ getCutFlowResultMasking() [1/4]

CutFlowResult vid::CutFlowResult::getCutFlowResultMasking ( const unsigned  idx) const

Definition at line 106 of file VIDCutFlowResult.cc.

References bitmap_, CutFlowResult(), Exception, heavyIonCSV_trainingSettings::idx, indices_, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, mask_, name_, names_, and values_.

106  {
107  unsigned bitmap = bitmap_;
108  unsigned mask = mask_;
109  if (idx >= indices_.size()) {
110  throw cms::Exception("OutOfBounds") << idx << " is out of bounds for this cut flow!";
111  }
112  mask = mask | 1 << idx;
113  bitmap = bitmap | mask;
114  return CutFlowResult(name_, empty_str, names_, indices_, values_, bitmap, mask);
115  }
std::vector< unsigned > indices_
std::vector< std::string > names_
std::vector< double > values_

◆ getCutFlowResultMasking() [2/4]

CutFlowResult vid::CutFlowResult::getCutFlowResultMasking ( const std::string &  name) const

Definition at line 117 of file VIDCutFlowResult.cc.

References bitmap_, CutFlowResult(), HLT_2024v12_cff::distance, Exception, indices_, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, mask_, Skims_PA_cff::name, name_, names_, and values_.

117  {
118  unsigned bitmap = bitmap_;
119  unsigned mask = mask_;
120  auto found_name = std::lower_bound(names_.begin(), names_.end(), name);
121  if (found_name == names_.end() || *found_name != name) {
122  throw cms::Exception("UnknownName") << "Cut name: " << name << " is not known for this cutflow!";
123  }
124  mask = mask | 1 << indices_[std::distance(names_.begin(), found_name)];
125  bitmap = bitmap | mask;
126  return CutFlowResult(name_, empty_str, names_, indices_, values_, bitmap, mask);
127  }
std::vector< unsigned > indices_
std::vector< std::string > names_
std::vector< double > values_

◆ getCutFlowResultMasking() [3/4]

CutFlowResult vid::CutFlowResult::getCutFlowResultMasking ( const std::vector< unsigned > &  idxs) const

Definition at line 79 of file VIDCutFlowResult.cc.

References bitmap_, CutFlowResult(), Exception, heavyIonCSV_trainingSettings::idx, indices_, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, mask_, name_, names_, and values_.

79  {
80  unsigned bitmap = bitmap_;
81  unsigned mask = mask_;
82  for (const unsigned idx : idxs) {
83  if (idx >= indices_.size()) {
84  throw cms::Exception("OutOfBounds") << idx << " is out of bounds for this cut flow!";
85  }
86  mask = mask | 1 << idx;
87  }
88  bitmap = bitmap | mask;
89  return CutFlowResult(name_, empty_str, names_, indices_, values_, bitmap, mask);
90  }
std::vector< unsigned > indices_
std::vector< std::string > names_
std::vector< double > values_

◆ getCutFlowResultMasking() [4/4]

CutFlowResult vid::CutFlowResult::getCutFlowResultMasking ( const std::vector< std::string > &  names) const

Definition at line 92 of file VIDCutFlowResult.cc.

References bitmap_, CutFlowResult(), HLT_2024v12_cff::distance, Exception, indices_, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, mask_, Skims_PA_cff::name, name_, names, names_, AlCaHLTBitMon_QueryRunRegistry::string, and values_.

92  {
93  unsigned bitmap = bitmap_;
94  unsigned mask = mask_;
95  for (const std::string& name : names) {
96  auto found_name = std::lower_bound(names_.begin(), names_.end(), name);
97  if (found_name == names_.end() || *found_name != name) {
98  throw cms::Exception("UnknownName") << "Cut name: " << name << " is not known for this cutflow!";
99  }
100  mask = mask | 1 << indices_[std::distance(names_.begin(), found_name)];
101  }
102  bitmap = bitmap | mask;
103  return CutFlowResult(name_, empty_str, names_, indices_, values_, bitmap, mask);
104  }
std::vector< unsigned > indices_
std::vector< std::string > names_
const std::string names[nVars_]
std::vector< double > values_

◆ getCutResultByIndex()

bool vid::CutFlowResult::getCutResultByIndex ( const unsigned  idx) const

Definition at line 34 of file VIDCutFlowResult.cc.

References Exception, getCutBit(), heavyIonCSV_trainingSettings::idx, and indices_.

34  {
35  if (idx >= indices_.size()) {
36  throw cms::Exception("OutOfBounds") << idx << " is out of bounds for this cut flow!";
37  }
38  return getCutBit(idx);
39  }
bool getCutBit(const unsigned idx) const
std::vector< unsigned > indices_

◆ getCutResultByName()

bool vid::CutFlowResult::getCutResultByName ( const std::string &  name) const

Definition at line 41 of file VIDCutFlowResult.cc.

References HLT_2024v12_cff::distance, Exception, getCutBit(), indices_, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, Skims_PA_cff::name, and names_.

41  {
42  auto found_name = std::lower_bound(names_.begin(), names_.end(), name);
43  if (found_name == names_.end() || *found_name != name) {
44  throw cms::Exception("UnknownName") << "Cut name: " << name << " is not known for this cutflow!";
45  }
46  return getCutBit(indices_[std::distance(names_.begin(), found_name)]);
47  }
bool getCutBit(const unsigned idx) const
std::vector< unsigned > indices_
std::vector< std::string > names_

◆ getCutValue()

double vid::CutFlowResult::getCutValue ( const unsigned  idx) const
inlineprivate

Definition at line 96 of file VIDCutFlowResult.h.

References heavyIonCSV_trainingSettings::idx, and values_.

Referenced by getValueCutUpon().

◆ getMaskBit()

bool vid::CutFlowResult::getMaskBit ( const unsigned  idx) const
inlineprivate

Definition at line 92 of file VIDCutFlowResult.h.

References heavyIonCSV_trainingSettings::idx, and mask_.

Referenced by isCutMasked().

92 { return (bool)(0x1 & (mask_ >> idx)); }

◆ getNameAtIndex()

const std::string & vid::CutFlowResult::getNameAtIndex ( const unsigned  idx) const

Definition at line 23 of file VIDCutFlowResult.cc.

References Exception, heavyIonCSV_trainingSettings::idx, indices_, and names_.

23  {
24  unsigned internal_idx = 0;
25  for (const auto& value : indices_) {
26  if (value == idx)
27  return names_[internal_idx];
28  ++internal_idx;
29  }
30  throw cms::Exception("IndexNotFound") << "index = " << idx << " has no corresponding cut name!";
31  return empty_str;
32  }
std::vector< unsigned > indices_
std::vector< std::string > names_
Definition: value.py:1

◆ getValueCutUpon() [1/2]

double vid::CutFlowResult::getValueCutUpon ( const unsigned  idx) const

Definition at line 64 of file VIDCutFlowResult.cc.

References Exception, getCutValue(), heavyIonCSV_trainingSettings::idx, and indices_.

64  {
65  if (idx >= indices_.size()) {
66  throw cms::Exception("OutOfBounds") << idx << " is out of bounds for this cut flow!";
67  }
68  return getCutValue(idx);
69  }
double getCutValue(const unsigned idx) const
std::vector< unsigned > indices_

◆ getValueCutUpon() [2/2]

double vid::CutFlowResult::getValueCutUpon ( const std::string &  name) const

Definition at line 71 of file VIDCutFlowResult.cc.

References HLT_2024v12_cff::distance, Exception, getCutValue(), indices_, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, Skims_PA_cff::name, and names_.

71  {
72  auto found_name = std::lower_bound(names_.begin(), names_.end(), name);
73  if (found_name == names_.end() || *found_name != name) {
74  throw cms::Exception("UnknownName") << "Cut name: " << name << " is not known for this cutflow!";
75  }
76  return getCutValue(indices_[std::distance(names_.begin(), found_name)]);
77  }
double getCutValue(const unsigned idx) const
std::vector< unsigned > indices_
std::vector< std::string > names_

◆ isCutMasked() [1/2]

bool vid::CutFlowResult::isCutMasked ( const unsigned  idx) const

Definition at line 49 of file VIDCutFlowResult.cc.

References Exception, getMaskBit(), heavyIonCSV_trainingSettings::idx, and indices_.

49  {
50  if (idx >= indices_.size()) {
51  throw cms::Exception("OutOfBounds") << idx << " is out of bounds for this cut flow!";
52  }
53  return getMaskBit(idx);
54  }
std::vector< unsigned > indices_
bool getMaskBit(const unsigned idx) const

◆ isCutMasked() [2/2]

bool vid::CutFlowResult::isCutMasked ( const std::string &  name) const

Definition at line 56 of file VIDCutFlowResult.cc.

References HLT_2024v12_cff::distance, Exception, getMaskBit(), indices_, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, Skims_PA_cff::name, and names_.

56  {
57  auto found_name = std::lower_bound(names_.begin(), names_.end(), name);
58  if (found_name == names_.end() || *found_name != name) {
59  throw cms::Exception("UnknownName") << "Cut name: " << name << " is not known for this cutflow!";
60  }
61  return getMaskBit(indices_[std::distance(names_.begin(), found_name)]);
62  }
std::vector< unsigned > indices_
std::vector< std::string > names_
bool getMaskBit(const unsigned idx) const

Friends And Related Function Documentation

◆ VersionedSelector

template<class T >
friend class VersionedSelector
friend

Definition at line 29 of file VIDCutFlowResult.h.

Member Data Documentation

◆ bitmap_

unsigned vid::CutFlowResult::bitmap_
private

Definition at line 78 of file VIDCutFlowResult.h.

Referenced by cutFlowPassed(), getCutBit(), and getCutFlowResultMasking().

◆ hash_

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

Definition at line 77 of file VIDCutFlowResult.h.

Referenced by cutFlowHash().

◆ indices_

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

◆ mask_

unsigned vid::CutFlowResult::mask_
private

Definition at line 78 of file VIDCutFlowResult.h.

Referenced by getCutFlowResultMasking(), and getMaskBit().

◆ name_

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

Definition at line 77 of file VIDCutFlowResult.h.

Referenced by cutFlowName(), and getCutFlowResultMasking().

◆ names_

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

◆ values_

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

Definition at line 79 of file VIDCutFlowResult.h.

Referenced by getCutFlowResultMasking(), and getCutValue().