Logo ROOT  
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 #include "ThreadLocalStorage.h"
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 type - 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 type - true for signal, false for background
51  * @return the cumulative weight for sorted signal/background events
52  */
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  inline Double_t GetVal(Int_t var) const { return fEvent->GetValue(var); }
69  private:
70 
71  // This is a workaround for OSx where static thread_local data members are
72  // not supported. The C++ solution would indeed be the following:
73  static Int_t& GetVarIndex(){TTHREAD_TLS(Int_t) fVarIndex(0); return fVarIndex;}; // index of the variable to sort on
74 
75  const Event* fEvent; // pointer to the event
76 
77  Double_t fBkgWeight; // cumulative background weight for splitting
78  Double_t fSigWeight; // same for the signal weights
79  };
80 }
81 
83 {
84  return GetVal() < other.GetVal();
85 }
86 
87 #endif
TMVA::BDTEventWrapper::fBkgWeight
Double_t fBkgWeight
Definition: BDTEventWrapper.h:77
TMVA::BDTEventWrapper::SetCumulativeWeight
void SetCumulativeWeight(Bool_t type, Double_t weight)
Set the accumulated weight, for sorted signal/background events.
Definition: BDTEventWrapper.cxx:54
TMVA::BDTEventWrapper::BDTEventWrapper
BDTEventWrapper(const Event *)
Constructor.
Definition: BDTEventWrapper.cxx:36
TMVA::BDTEventWrapper::operator*
const Event * operator*() const
Definition: BDTEventWrapper.h:66
TMVA::BDTEventWrapper::GetVarIndex
static Int_t & GetVarIndex()
Definition: BDTEventWrapper.h:73
bool
TMVA::BDTEventWrapper::operator<
Bool_t operator<(const BDTEventWrapper &other) const
Definition: BDTEventWrapper.h:82
TMVA::Event::GetValue
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
Definition: Event.cxx:236
TMVA::BDTEventWrapper
Definition: BDTEventWrapper.h:31
TMVA::BDTEventWrapper::GetVal
Double_t GetVal(Int_t var) const
Definition: BDTEventWrapper.h:68
Event.h
TMVA::BDTEventWrapper::GetCumulativeWeight
Double_t GetCumulativeWeight(Bool_t type) const
Get the accumulated weight.
Definition: BDTEventWrapper.cxx:64
TMVA::BDTEventWrapper::fEvent
const Event * fEvent
Definition: BDTEventWrapper.h:73
TMVA::BDTEventWrapper::fSigWeight
Double_t fSigWeight
Definition: BDTEventWrapper.h:78
Double_t
double Double_t
Definition: RtypesCore.h:59
TMVA::BDTEventWrapper::SetVarIndex
static void SetVarIndex(Int_t iVar)
Definition: BDTEventWrapper.h:59
RtypesCore.h
TMVA::BDTEventWrapper::~BDTEventWrapper
~BDTEventWrapper()
Destructor.
Definition: BDTEventWrapper.cxx:45
TMVA::Event
Definition: Event.h:51
type
int type
Definition: TGX11.cxx:121
TMVA::BDTEventWrapper::GetVal
Double_t GetVal() const
Definition: BDTEventWrapper.h:65
ThreadLocalStorage.h
TMVA
create variable transformations
Definition: GeneticMinimizer.h:22
int