File indexing completed on 2024-04-06 12:04:56
0001 #ifndef __DataFormats_PatCandidates_VIDResult_H__
0002 #define __DataFormats_PatCandidates_VIDResult_H__
0003
0004 #include <map>
0005 #include <vector>
0006 #include <string>
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 namespace vid {
0027 class CutFlowResult {
0028 template <class T>
0029 friend class VersionedSelector;
0030
0031 public:
0032 CutFlowResult() : bitmap_(0) {}
0033 CutFlowResult(const std::string& name,
0034 const std::string& hash,
0035 const std::map<std::string, unsigned>& n2idx,
0036 const std::vector<double>& values,
0037 unsigned bitmap,
0038 unsigned mask = 0);
0039
0040
0041 const std::string& cutFlowName() const { return name_; }
0042
0043 const std::string& cutFlowHash() const { return hash_; }
0044
0045 bool cutFlowPassed() const {
0046 const unsigned all_pass = (1 << indices_.size()) - 1;
0047 return (all_pass & bitmap_) == all_pass;
0048 }
0049
0050 size_t cutFlowSize() const { return indices_.size(); }
0051
0052
0053
0054 const std::string& getNameAtIndex(const unsigned idx) const;
0055
0056
0057 bool getCutResultByIndex(const unsigned idx) const;
0058 bool getCutResultByName(const std::string& name) const;
0059
0060
0061 bool isCutMasked(const unsigned idx) const;
0062 bool isCutMasked(const std::string& name) const;
0063
0064
0065 double getValueCutUpon(const unsigned idx) const;
0066 double getValueCutUpon(const std::string& name) const;
0067
0068
0069
0070 CutFlowResult getCutFlowResultMasking(const unsigned idx) const;
0071 CutFlowResult getCutFlowResultMasking(const std::string& name) const;
0072
0073 CutFlowResult getCutFlowResultMasking(const std::vector<unsigned>& idxs) const;
0074 CutFlowResult getCutFlowResultMasking(const std::vector<std::string>& names) const;
0075
0076 private:
0077 std::string name_, hash_;
0078 unsigned bitmap_, mask_;
0079 std::vector<double> values_;
0080 std::vector<std::string> names_;
0081 std::vector<unsigned> indices_;
0082
0083 CutFlowResult(const std::string& name,
0084 const std::string& hash,
0085 const std::vector<std::string>& names,
0086 const std::vector<unsigned>& indices,
0087 const std::vector<double>& values,
0088 unsigned bitmap,
0089 unsigned mask)
0090 : name_(name), hash_(hash), bitmap_(bitmap), mask_(mask), values_(values), names_(names), indices_(indices) {}
0091
0092 bool getMaskBit(const unsigned idx) const { return (bool)(0x1 & (mask_ >> idx)); }
0093
0094 bool getCutBit(const unsigned idx) const { return (bool)(0x1 & (bitmap_ >> idx)); }
0095
0096 double getCutValue(const unsigned idx) const { return values_[idx]; }
0097 };
0098 }
0099
0100 #endif