ROOT  6.06/09
Reference Guide
BDTEventWrapper.h
Go to the documentation of this file.
1 
2 /**********************************************************************************
3  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
4  * Package: TMVA *
5  * Class : BDTEventWrapper *
6  * Web : http://tmva.sourceforge.net *
7  * *
8  * Description: *
9  * *
10  * *
11  * Author: Doug Schouten (dschoute@sfu.ca) *
12  * *
13  * Copyright (c) 2007: *
14  * CERN, Switzerland *
15  * U. of Texas at Austin, USA *
16  * *
17  * Redistribution and use in source and binary forms, with or without *
18  * modification, are permitted according to the terms listed in LICENSE *
19  * (http://tmva.sourceforge.net/LICENSE) *
20  **********************************************************************************/
21 
22 #ifndef ROOT_TMVA_BDTEventWrapper
23 #define ROOT_TMVA_BDTEventWrapper
24 
25 #ifndef ROOT_Event
26 #include "Event.h"
27 #endif
28 
29 namespace TMVA {
30 
32 
33  public:
34 
35  BDTEventWrapper( const Event* );
37 
38  // Require '<' operator to use std::sort algorithms on collection of Events
39  Bool_t operator <( const BDTEventWrapper& other ) const;
40 
41  // Set the accumulated weight, for sorted signal/background events
42  /**
43  * @param fType - true for signal, false for background
44  * @param weight - the total weight
45  */
46  void SetCumulativeWeight( Bool_t type, Double_t weight );
47 
48  // Get the accumulated weight
49  /**
50  * @param fType - true for signal, false for background
51  * @return the cumulative weight for sorted signal/background events
52  */
53  Double_t GetCumulativeWeight( Bool_t type ) const;
54 
55  // Set the index of the variable to compare on
56  /**
57  * @param iVar - index of the variable in fEvent to use
58  */
59  inline static void SetVarIndex( Int_t iVar ) { if (iVar >= 0) GetVarIndex() = iVar; }
60 
61  // Return the value of variable fVarIndex for this event
62  /**
63  * @return value of variable fVarIndex for this event
64  */
65  inline Double_t GetVal() const { return fEvent->GetValue(GetVarIndex()); }
66  const Event* operator*() const { return fEvent; }
67 
68  private:
69 
70  // This is a workaround for OSx where static thread_local data members are
71  // not supported. The C++ solution would indeed be the following:
72  static Int_t& GetVarIndex(){TTHREAD_TLS(Int_t) fVarIndex(0); return fVarIndex;}; // index of the variable to sort on
73 
74  const Event* fEvent; // pointer to the event
75 
76  Double_t fBkgWeight; // cumulative background weight for splitting
77  Double_t fSigWeight; // same for the signal weights
78  };
79 }
80 
82 {
83  return GetVal() < other.GetVal();
84 }
85 
86 #endif
87 
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
BDTEventWrapper(const Event *)
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
Definition: Event.cxx:231
static Int_t & GetVarIndex()
Bool_t operator<(const BDTEventWrapper &other) const
const Event * operator*() const
static void SetVarIndex(Int_t iVar)
Double_t GetCumulativeWeight(Bool_t type) const
double Double_t
Definition: RtypesCore.h:55
int type
Definition: TGX11.cxx:120
Double_t GetVal() const
Abstract ClassifierFactory template that handles arbitrary types.
void SetCumulativeWeight(Bool_t type, Double_t weight)