Logo ROOT   6.12/07
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 #include "RtypesCore.h"
26 #include "Event.h"
27 
28 namespace TMVA {
29 
31 
32  public:
33 
34  BDTEventWrapper( const Event* );
36 
37  // Require '<' operator to use std::sort algorithms on collection of Events
38  Bool_t operator <( const BDTEventWrapper& other ) const;
39 
40  // Set the accumulated weight, for sorted signal/background events
41  /**
42  * @param fType - true for signal, false for background
43  * @param weight - the total weight
44  */
45  void SetCumulativeWeight( Bool_t type, Double_t weight );
46 
47  // Get the accumulated weight
48  /**
49  * @param fType - true for signal, false for background
50  * @return the cumulative weight for sorted signal/background events
51  */
52  Double_t GetCumulativeWeight( Bool_t type ) const;
53 
54  // Set the index of the variable to compare on
55  /**
56  * @param iVar - index of the variable in fEvent to use
57  */
58  inline static void SetVarIndex( Int_t iVar ) { if (iVar >= 0) GetVarIndex() = iVar; }
59 
60  // Return the value of variable fVarIndex for this event
61  /**
62  * @return value of variable fVarIndex for this event
63  */
64  inline Double_t GetVal() const { return fEvent->GetValue(GetVarIndex()); }
65  const Event* operator*() const { return fEvent; }
66 
67  private:
68 
69  // This is a workaround for OSx where static thread_local data members are
70  // not supported. The C++ solution would indeed be the following:
71  static Int_t& GetVarIndex(){TTHREAD_TLS(Int_t) fVarIndex(0); return fVarIndex;}; // index of the variable to sort on
72 
73  const Event* fEvent; // pointer to the event
74 
75  Double_t fBkgWeight; // cumulative background weight for splitting
76  Double_t fSigWeight; // same for the signal weights
77  };
78 }
79 
81 {
82  return GetVal() < other.GetVal();
83 }
84 
85 #endif
86 
const Event * operator*() const
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
BDTEventWrapper(const Event *)
Constructor.
static Int_t & GetVarIndex()
Bool_t operator<(const BDTEventWrapper &other) const
Double_t GetCumulativeWeight(Bool_t type) const
Get the accumulated weight.
Float_t GetValue(UInt_t ivar) const
return value of i&#39;th variable
Definition: Event.cxx:237
static void SetVarIndex(Int_t iVar)
double Double_t
Definition: RtypesCore.h:55
~BDTEventWrapper()
Destructor.
int type
Definition: TGX11.cxx:120
Abstract ClassifierFactory template that handles arbitrary types.
Double_t GetVal() const
void SetCumulativeWeight(Bool_t type, Double_t weight)
Set the accumulated weight, for sorted signal/background events.