CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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>
29  friend class VersionedSelector;
30 
31  public:
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
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
const std::string names[nVars_]
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
list indices
Definition: dqmdumpme.py:50
double getValueCutUpon(const unsigned idx) const
cut-flow versioning info in the event provenance
bool getMaskBit(const unsigned idx) const