00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef ROOT_TMVA_BinarySearchTree
00031 #define ROOT_TMVA_BinarySearchTree
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <vector>
00042 #include <queue>
00043 #ifndef ROOT_time
00044 #include "time.h"
00045 #endif
00046
00047 #ifndef ROOT_TMVA_Volume
00048 #include "TMVA/Volume.h"
00049 #endif
00050 #ifndef ROOT_TMVA_BinaryTree
00051 #include "TMVA/BinaryTree.h"
00052 #endif
00053 #ifndef ROOT_TMVA_BinarySearchTreeNode
00054 #include "TMVA/BinarySearchTreeNode.h"
00055 #endif
00056 #ifndef ROOT_TMVA_VariableInfo
00057 #include "TMVA/VariableInfo.h"
00058 #endif
00059
00060 class TString;
00061 class TTree;
00062
00063
00064
00065
00066 namespace TMVA {
00067
00068 class DataSet;
00069 class Event;
00070
00071
00072 class BinarySearchTree : public BinaryTree {
00073
00074 public:
00075
00076
00077 BinarySearchTree( void );
00078
00079
00080 BinarySearchTree (const BinarySearchTree &b);
00081
00082
00083 virtual ~BinarySearchTree( void );
00084
00085 virtual Node * CreateNode( UInt_t ) const { return new BinarySearchTreeNode(); }
00086 virtual BinaryTree* CreateTree() const { return new BinarySearchTree(); }
00087 static BinarySearchTree* CreateFromXML(void* node, UInt_t tmva_Version_Code = TMVA_VERSION_CODE);
00088 virtual const char* ClassName() const { return "BinarySearchTree"; }
00089
00090
00091
00092 BinarySearchTreeNode* Search( Event * event ) const;
00093
00094
00095 void Insert( const Event * );
00096
00097
00098 Double_t GetSumOfWeights( void ) const;
00099
00100
00101 Double_t GetSumOfWeights( Int_t theType ) const;
00102
00103
00104 void SetPeriode( Int_t p ) { fPeriod = p; }
00105
00106
00107 UInt_t GetPeriode( void ) const { return fPeriod; }
00108
00109
00110 Double_t SearchVolume( Volume*, std::vector<const TMVA::BinarySearchTreeNode*>* events = 0 );
00111
00112
00113
00114 Double_t Fill( const std::vector<TMVA::Event*>& events, const std::vector<Int_t>& theVars, Int_t theType = -1 );
00115
00116
00117
00118 Double_t Fill( const std::vector<TMVA::Event*>& events, Int_t theType = -1 );
00119
00120 void NormalizeTree ();
00121
00122 void CalcStatistics( TMVA::Node* n = 0 );
00123 void Clear ( TMVA::Node* n = 0 );
00124
00125
00126 Float_t Mean(Types::ESBType sb, UInt_t var ) { return fMeans[sb==Types::kSignal?0:1][var]; }
00127
00128
00129 Float_t RMS(Types::ESBType sb, UInt_t var ) { return fRMS[sb==Types::kSignal?0:1][var]; }
00130
00131
00132 Float_t Min(Types::ESBType sb, UInt_t var ) { return fMin[sb==Types::kSignal?0:1][var]; }
00133
00134
00135 Float_t Max(Types::ESBType sb, UInt_t var ) { return fMax[sb==Types::kSignal?0:1][var]; }
00136
00137 Int_t SearchVolumeWithMaxLimit( TMVA::Volume*, std::vector<const TMVA::BinarySearchTreeNode*>* events = 0, Int_t = -1);
00138
00139
00140 Float_t RMS(UInt_t var ) { return fRMS[0][var]; }
00141
00142 void SetNormalize( Bool_t norm ) { fCanNormalize = norm; }
00143
00144 private:
00145
00146
00147 void Insert( const Event*, Node* );
00148
00149 BinarySearchTreeNode* Search( Event*, Node *) const ;
00150
00151
00152 Bool_t InVolume (const std::vector<Float_t>&, Volume* ) const;
00153
00154 void DestroyNode ( BinarySearchTreeNode* );
00155
00156
00157 void NormalizeTree( std::vector< std::pair< Double_t, const TMVA::Event* > >::iterator,
00158 std::vector< std::pair< Double_t, const TMVA::Event* > >::iterator, UInt_t );
00159
00160
00161 Double_t SearchVolume( Node*, Volume*, Int_t,
00162 std::vector<const TMVA::BinarySearchTreeNode*>* events );
00163 UInt_t fPeriod;
00164 UInt_t fCurrentDepth;
00165 Bool_t fStatisticsIsValid;
00166
00167 std::vector<Float_t> fMeans[2];
00168 std::vector<Float_t> fRMS[2];
00169 std::vector<Float_t> fMin[2];
00170 std::vector<Float_t> fMax[2];
00171 std::vector<Double_t> fSum[2];
00172 std::vector<Double_t> fSumSq[2];
00173 Double_t fNEventsW[2];
00174 Double_t fSumOfWeights;
00175
00176
00177 Bool_t fCanNormalize;
00178 std::vector< std::pair<Double_t,const TMVA::Event*> > fNormalizeTreeTable;
00179
00180 ClassDef(BinarySearchTree,0)
00181 };
00182
00183 }
00184
00185 #endif