test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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> friend class VersionedSelector;
29  public:
30 
33  const std::string& hash,
34  const std::map<std::string,unsigned>& n2idx,
35  const std::vector<double>& values,
36  unsigned bitmap,
37  unsigned mask = 0);
38 
39  // get the original name of this cutflow
40  const std::string& cutFlowName() const { return name_; }
41  // get the md5 hash for this cutflow
42  const std::string& cutFlowHash() const { return hash_; }
43  // did this cutflow (in its current state!) pass?
44  bool cutFlowPassed() const {
45  const unsigned all_pass = (1 << indices_.size()) - 1;
46  return (all_pass&bitmap_) == all_pass;
47  }
48  // how many cuts in this cutflow?
49  size_t cutFlowSize() const { return indices_.size(); }
50 
51  // get the name of a cut in the cutflow
52  // indexed by order it was executed
53  const std::string& getNameAtIndex(const unsigned idx) const;
54 
55  // get the individual cut result (pass/fail) either by name or by index
56  bool getCutResultByIndex(const unsigned idx) const;
57  bool getCutResultByName(const std::string& name) const;
58 
59  // return true if the cut as index/name is masked out
60  bool isCutMasked(const unsigned idx) const;
61  bool isCutMasked(const std::string& name) const;
62 
63  // get the value of variable that was cut on, either by name or by index
64  double getValueCutUpon(const unsigned idx) const;
65  double getValueCutUpon(const std::string& name) const;
66 
67  // create a new copy of this cutflow masking out the listed cuts
68  // can be done either by name or by index
69  CutFlowResult getCutFlowResultMasking(const unsigned idx) const;
71 
72  CutFlowResult getCutFlowResultMasking(const std::vector<unsigned>& idxs) const;
73  CutFlowResult getCutFlowResultMasking(const std::vector<std::string>& names) const;
74 
75  private:
77  unsigned bitmap_, mask_;
78  std::vector<double> values_;
79  std::vector<std::string> names_;
80  std::vector<unsigned> indices_;
81 
83  const std::string& hash,
84  const std::vector<std::string>& names,
85  const std::vector<unsigned>& indices,
86  const std::vector<double>& values,
87  unsigned bitmap,
88  unsigned mask) :
89  name_(name),
90  hash_(hash),
91  bitmap_(bitmap),
92  mask_(mask),
93  values_(values),
94  names_(names),
95  indices_(indices) {}
96 
97 
98  bool getMaskBit(const unsigned idx) const {
99  return (bool)(0x1&(mask_>>idx));
100  }
101 
102  bool getCutBit(const unsigned idx) const {
103  return (bool)(0x1&(bitmap_>>idx));
104  }
105 
106  double getCutValue(const unsigned idx) const {
107  return values_[idx];
108  }
109  };
110 }
111 
112 #endif
static const HistoName names[]
bool cutFlowPassed() const
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 getCutResultByIndex(const unsigned idx) const
std::vector< unsigned > indices_
const std::string & cutFlowName() const
std::vector< std::string > names_
bool getCutResultByName(const std::string &name) const
bool isCutMasked(const unsigned idx) const
std::vector< double > values_
const std::string & cutFlowHash() const
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
size_t cutFlowSize() const
double getValueCutUpon(const unsigned idx) const
cut-flow versioning info in the event provenance
bool getMaskBit(const unsigned idx) const