Warning, file /include/root/TMVA/RuleCut.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #ifndef ROOT_TMVA_RuleCut
0025 #define ROOT_TMVA_RuleCut
0026
0027 #include "TMVA/Event.h"
0028
0029 #include <vector>
0030
0031 namespace TMVA {
0032
0033 class Node;
0034 class MsgLogger;
0035
0036 class RuleCut {
0037
0038 public:
0039
0040
0041 RuleCut( const std::vector< const TMVA::Node * > & nodes );
0042
0043
0044 RuleCut( const RuleCut & other ) : fLogger(nullptr) { Copy( other ); }
0045
0046
0047 RuleCut();
0048
0049
0050 virtual ~RuleCut();
0051
0052
0053 inline Bool_t EvalEvent( const Event &eve );
0054
0055
0056 Bool_t GetCutRange(Int_t sel,Double_t &rmin, Double_t &rmax, Bool_t &dormin, Bool_t &dormax) const;
0057
0058
0059 UInt_t GetNcuts() const;
0060
0061
0062 inline void SetNvars( UInt_t nc );
0063 void SetNeve( Double_t n ) { fCutNeve = n; }
0064 void SetPurity( Double_t ssb ) { fPurity = ssb; }
0065 void SetSelector( Int_t i, UInt_t s ) { fSelector[i] = s; }
0066 void SetCutMin( Int_t i, Double_t v ) { fCutMin[i] = v; }
0067 void SetCutMax( Int_t i, Double_t v ) { fCutMax[i] = v; }
0068 void SetCutDoMin( Int_t i, Bool_t v ) { fCutDoMin[i] = v; }
0069 void SetCutDoMax( Int_t i, Bool_t v ) { fCutDoMax[i] = v; }
0070
0071
0072 UInt_t GetNvars() const { return fSelector.size(); }
0073 UInt_t GetSelector(Int_t is) const { return fSelector[is]; }
0074 Double_t GetCutMin(Int_t is) const { return fCutMin[is]; }
0075 Double_t GetCutMax(Int_t is) const { return fCutMax[is]; }
0076 Char_t GetCutDoMin(Int_t is) const { return fCutDoMin[is]; }
0077 Char_t GetCutDoMax(Int_t is) const { return fCutDoMax[is]; }
0078 Double_t GetCutNeve() const { return fCutNeve; }
0079 Double_t GetPurity() const { return fPurity; }
0080
0081 private:
0082
0083 inline void Copy( const RuleCut & other);
0084
0085
0086 void MakeCuts( const std::vector< const TMVA::Node * > & nodes );
0087
0088 std::vector<UInt_t> fSelector;
0089 std::vector<Double_t> fCutMin;
0090 std::vector<Double_t> fCutMax;
0091 std::vector<Char_t> fCutDoMin;
0092 std::vector<Char_t> fCutDoMax;
0093 Double_t fCutNeve;
0094 Double_t fPurity;
0095
0096
0097 mutable MsgLogger* fLogger;
0098 MsgLogger& Log() const { return *fLogger; }
0099 };
0100 }
0101
0102
0103 inline void TMVA::RuleCut::Copy( const TMVA::RuleCut & other )
0104 {
0105
0106 if (&other != this) {
0107 for (UInt_t ns=0; ns<other.GetNvars(); ns++) {
0108 fSelector.push_back( other.GetSelector(ns) );
0109 fCutMin.push_back( other.GetCutMin(ns) );
0110 fCutMax.push_back( other.GetCutMax(ns) );
0111 fCutDoMin.push_back( other.GetCutDoMin(ns) );
0112 fCutDoMax.push_back( other.GetCutDoMax(ns) );
0113 }
0114 fCutNeve = other.GetCutNeve();
0115 fPurity = other.GetPurity();
0116 }
0117 }
0118
0119
0120 inline Bool_t TMVA::RuleCut::EvalEvent( const Event &eve )
0121 {
0122
0123
0124
0125 Int_t sel;
0126 Double_t val;
0127 Bool_t done=kFALSE;
0128 Bool_t minOK, cutOK=kFALSE;
0129 UInt_t nc=0;
0130 while (!done) {
0131 sel = fSelector[nc];
0132 val = eve.GetValue(sel);
0133 minOK = (fCutDoMin[nc] ? (val>fCutMin[nc]):kTRUE);
0134 cutOK = (minOK ? ((fCutDoMax[nc] ? (val<fCutMax[nc]):kTRUE)) : kFALSE);
0135 nc++;
0136 done = ((!cutOK) || (nc==fSelector.size()));
0137 }
0138
0139 return cutOK;
0140 }
0141
0142
0143 inline void TMVA::RuleCut::SetNvars( UInt_t nc )
0144 {
0145
0146 fSelector.clear();
0147 fCutMin.clear();
0148 fCutMax.clear();
0149 fCutDoMin.clear();
0150 fCutDoMax.clear();
0151
0152 fSelector.resize(nc);
0153 fCutMin.resize(nc);
0154 fCutMax.resize(nc);
0155 fCutDoMin.resize(nc);
0156 fCutDoMax.resize(nc);
0157 }
0158
0159 #endif