29 #ifndef ROOT_TMVA_DataSetFactory
30 #define ROOT_TMVA_DataSetFactory
58 class DataInputHandler;
68 struct DeleteFunctor_t
70 DeleteFunctor_t& operator()(
const T* p) {
77 DeleteFunctor_t<const T> DeleteFunctor()
79 return DeleteFunctor_t<const T>();
83 template<
typename T >
87 Increment( T start ) : value( start ){ }
101 typedef F argument_type;
102 F operator()(
const F& argF)
const
108 template <
typename F>
109 inline null_t<F> null() {
115 template <
typename F,
typename G,
typename H>
116 class compose_binary_t :
public std::binary_function<typename G::argument_type,
117 typename H::argument_type,
118 typename F::result_type>
125 compose_binary_t(
const F& _f,
const G& _g,
const H& _h) : f(_f), g(_g), h(_h)
129 typename F::result_type operator()(
const typename G::argument_type& argG,
130 const typename H::argument_type& argH)
const
132 return f(g(argG),h(argH));
136 template <
typename F,
typename G,
typename H>
137 inline compose_binary_t<F,G,H> compose_binary(
const F& _f,
const G& _g,
const H& _h) {
138 return compose_binary_t<F,G,H>(_f,_g,_h);
144 template <
typename F,
typename G>
145 class compose_unary_t :
public std::unary_function<typename G::argument_type,
146 typename F::result_type>
152 compose_unary_t(
const F& _f,
const G& _g) : f(_f), g(_g)
156 typename F::result_type operator()(
const typename G::argument_type& argG)
const
162 template <
typename F,
typename G>
163 inline compose_unary_t<F,G> compose_unary(
const F& _f,
const G& _g) {
164 return compose_unary_t<F,G>(_f,_g);
173 class DataSetFactory:
public TObject {
175 typedef std::vector<Event* > EventVector;
176 typedef std::vector< EventVector > EventVectorOfClasses;
177 typedef std::map<Types::ETreeType, EventVectorOfClasses > EventVectorOfClassesOfTreeType;
178 typedef std::map<Types::ETreeType, EventVector > EventVectorOfTreeType;
180 typedef std::vector< Double_t > ValuePerClass;
181 typedef std::map<Types::ETreeType, ValuePerClass > ValuePerClassOfTreeType;
185 Int_t nTrainingEventsRequested;
186 Int_t nTestingEventsRequested;
187 Float_t TrainTestSplitRequested;
188 Int_t nInitialEvents;
191 Float_t nWeEvBeforeCut;
192 Float_t nWeEvAfterCut;
193 Double_t nNegWeights;
194 Float_t* varAvLength;
196 nTrainingEventsRequested(0),
197 nTestingEventsRequested(0),
198 TrainTestSplitRequested(0),
207 ~EventStats() {
delete[] varAvLength; }
208 Float_t cutScaling()
const {
return Float_t(nEvAfterCut)/nEvBeforeCut; }
211 typedef std::vector< int > NumberPerClass;
212 typedef std::vector< EventStats > EvtStatsPerClass;
220 DataSet* CreateDataSet( DataSetInfo &, DataInputHandler& );
224 DataSet* BuildInitialDataSet( DataSetInfo&, TMVA::DataInputHandler& );
225 DataSet* BuildDynamicDataSet( DataSetInfo& );
228 void BuildEventVector ( DataSetInfo& dsi,
229 DataInputHandler& dataInput,
230 EventVectorOfClassesOfTreeType& eventsmap,
231 EvtStatsPerClass& eventCounts);
233 DataSet* MixEvents ( DataSetInfo& dsi,
234 EventVectorOfClassesOfTreeType& eventsmap,
235 EvtStatsPerClass& eventCounts,
236 const TString& splitMode,
237 const TString& mixMode,
238 const TString& normMode,
241 void RenormEvents ( DataSetInfo& dsi,
242 EventVectorOfClassesOfTreeType& eventsmap,
243 const EvtStatsPerClass& eventCounts,
244 const TString& normMode );
246 void InitOptions ( DataSetInfo& dsi,
247 EvtStatsPerClass& eventsmap,
248 TString& normMode, UInt_t& splitSeed,
249 TString& splitMode, TString& mixMode);
255 TMatrixD* CalcCorrelationMatrix( DataSet*,
const UInt_t classNumber );
256 TMatrixD* CalcCovarianceMatrix ( DataSet*,
const UInt_t classNumber );
257 void CalcMinMax ( DataSet*, DataSetInfo& dsi );
260 void ResetBranchAndEventAddresses( TTree* );
261 void ResetCurrentTree() { fCurrentTree = 0; }
262 void ChangeToNewTree( TreeInfo&,
const DataSetInfo & );
263 Bool_t CheckTTreeFormula( TTreeFormula* ttf,
const TString& expression, Bool_t& hasDollar );
266 Bool_t Verbose() {
return fVerbose; }
272 TString fVerboseLevel;
275 Bool_t fCorrelations = kFALSE;
276 Bool_t fComputeCorrelations = kFALSE;
278 Bool_t fScaleWithPreselEff;
282 UInt_t fCurrentEvtIdx;
285 std::vector<TTreeFormula*> fInputFormulas;
286 std::vector<std::pair<TTreeFormula*, Int_t>> fInputTableFormulas;
287 std::vector<TTreeFormula *> fTargetFormulas;
288 std::vector<TTreeFormula*> fCutFormulas;
289 std::vector<TTreeFormula*> fWeightFormula;
290 std::vector<TTreeFormula*> fSpectatorFormulas;
293 MsgLogger& Log()
const {
return *fLogger; }
295 ClassDef(DataSetFactory, 2);