CMS 3D CMS Logo

VIDCutFlowResult.h
Go to the documentation of this file.
1 #ifndef __DataFormats_PatCandidates_VIDResult_H__
2 #define __DataFormats_PatCandidates_VIDResult_H__
3 
4 #include <map>
5 #include <vector>
6 #include <string>
7 
8 /*********
9  *
10  * Class: vid::CutFlowResult
11  * Author: L. Gray (FNAL)
12  *
13  * A synthesis of the output of a VID selector into an easily
14  * manipulated class, such that cuts can be masked and sidebands
15  * created without major intervention on the part of the person
16  * doing analysis.
17  *
18  * The class is self-describing and the original cut-names, the
19  * values cut upon, the result of each cut used, and final cutflow
20  * decision can be accessed with this class. Using this information
21  * the cut flow can be masked interactively by the user, allowing
22  * for a large degree of flexibility at the analysis level.
23  *
24  *********/
25 
26 namespace vid {
27  class CutFlowResult {
28  template <class T>
29  friend class VersionedSelector;
30 
31  public:
32  CutFlowResult() : bitmap_(0) {}
34  const std::string& hash,
35  const std::map<std::string, unsigned>& n2idx,
36  const std::vector<double>& values,
37  unsigned bitmap,
38  unsigned mask = 0);
39 
40  // get the original name of this cutflow
41  const std::string& cutFlowName() const { return name_; }
42  // get the md5 hash for this cutflow
43  const std::string& cutFlowHash() const { return hash_; }
44  // did this cutflow (in its current state!) pass?
45  bool cutFlowPassed() const {
46  const unsigned all_pass = (1 << indices_.size()) - 1;
47  return (all_pass & bitmap_) == all_pass;
48  }
49  // how many cuts in this cutflow?
50  size_t cutFlowSize() const { return indices_.size(); }
51 
52  // get the name of a cut in the cutflow
53  // indexed by order it was executed
54  const std::string& getNameAtIndex(const unsigned idx) const;
55 
56  // get the individual cut result (pass/fail) either by name or by index
57  bool getCutResultByIndex(const unsigned idx) const;
58  bool getCutResultByName(const std::string& name) const;
59 
60  // return true if the cut as index/name is masked out
61  bool isCutMasked(const unsigned idx) const;
62  bool isCutMasked(const std::string& name) const;
63 
64  // get the value of variable that was cut on, either by name or by index
65  double getValueCutUpon(const unsigned idx) const;
66  double getValueCutUpon(const std::string& name) const;
67 
68  // create a new copy of this cutflow masking out the listed cuts
69  // can be done either by name or by index
70  CutFlowResult getCutFlowResultMasking(const unsigned idx) const;
72 
73  CutFlowResult getCutFlowResultMasking(const std::vector<unsigned>& idxs) const;
74  CutFlowResult getCutFlowResultMasking(const std::vector<std::string>& names) const;
75 
76  private:
78  unsigned bitmap_, mask_;
79  std::vector<double> values_;
80  std::vector<std::string> names_;
81  std::vector<unsigned> indices_;
82 
84  const std::string& hash,
85  const std::vector<std::string>& names,
86  const std::vector<unsigned>& indices,
87  const std::vector<double>& values,
88  unsigned bitmap,
89  unsigned mask)
90  : name_(name), hash_(hash), bitmap_(bitmap), mask_(mask), values_(values), names_(names), indices_(indices) {}
91 
92  bool getMaskBit(const unsigned idx) const { return (bool)(0x1 & (mask_ >> idx)); }
93 
94  bool getCutBit(const unsigned idx) const { return (bool)(0x1 & (bitmap_ >> idx)); }
95 
96  double getCutValue(const unsigned idx) const { return values_[idx]; }
97  };
98 } // namespace vid
99 
100 #endif
vid::CutFlowResult::mask_
unsigned mask_
Definition: VIDCutFlowResult.h:107
bTagCombinedSVVariables_cff.indices
indices
Definition: bTagCombinedSVVariables_cff.py:67
vid::CutFlowResult::values_
std::vector< double > values_
Definition: VIDCutFlowResult.h:108
vid
Definition: VIDCutFlowResult.h:25
vid::CutFlowResult::CutFlowResult
CutFlowResult()
Definition: VIDCutFlowResult.h:61
cond::hash
Definition: Time.h:19
training_settings.idx
idx
Definition: training_settings.py:16
vid::CutFlowResult::cutFlowHash
const std::string & cutFlowHash() const
Definition: VIDCutFlowResult.h:72
vid::CutFlowResult
Definition: VIDCutFlowResult.h:41
vid::CutFlowResult::bitmap_
unsigned bitmap_
Definition: VIDCutFlowResult.h:107
vid::CutFlowResult::getCutValue
double getCutValue(const unsigned idx) const
Definition: VIDCutFlowResult.h:125
vid::CutFlowResult::names_
std::vector< std::string > names_
Definition: VIDCutFlowResult.h:109
vid::CutFlowResult::getCutFlowResultMasking
CutFlowResult getCutFlowResultMasking(const unsigned idx) const
Definition: VIDCutFlowResult.cc:106
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:122
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
VersionedSelector
cut-flow versioning info in the event provenance
Definition: VersionedSelector.h:46
vid::CutFlowResult::getCutResultByIndex
bool getCutResultByIndex(const unsigned idx) const
Definition: VIDCutFlowResult.cc:34
vid::CutFlowResult::indices_
std::vector< unsigned > indices_
Definition: VIDCutFlowResult.h:110
vid::CutFlowResult::getNameAtIndex
const std::string & getNameAtIndex(const unsigned idx) const
Definition: VIDCutFlowResult.cc:23
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
vid::CutFlowResult::name_
std::string name_
Definition: VIDCutFlowResult.h:106
vid::CutFlowResult::cutFlowPassed
bool cutFlowPassed() const
Definition: VIDCutFlowResult.h:74
vid::CutFlowResult::cutFlowName
const std::string & cutFlowName() const
Definition: VIDCutFlowResult.h:70
vid::CutFlowResult::getCutResultByName
bool getCutResultByName(const std::string &name) const
Definition: VIDCutFlowResult.cc:41
vid::CutFlowResult::cutFlowSize
size_t cutFlowSize() const
Definition: VIDCutFlowResult.h:79
vid::CutFlowResult::getCutBit
bool getCutBit(const unsigned idx) const
Definition: VIDCutFlowResult.h:123
vid::CutFlowResult::isCutMasked
bool isCutMasked(const unsigned idx) const
Definition: VIDCutFlowResult.cc:49
vid::CutFlowResult::getMaskBit
bool getMaskBit(const unsigned idx) const
Definition: VIDCutFlowResult.h:121
vid::CutFlowResult::getValueCutUpon
double getValueCutUpon(const unsigned idx) const
Definition: VIDCutFlowResult.cc:64
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
vid::CutFlowResult::hash_
std::string hash_
Definition: VIDCutFlowResult.h:106