Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
29namespace 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 */
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
double Double_t
Definition RtypesCore.h:59
int type
Definition TGX11.cxx:121
Bool_t operator<(const BDTEventWrapper &other) const
const Event * operator*() const
static Int_t & GetVarIndex()
void SetCumulativeWeight(Bool_t type, Double_t weight)
Set the accumulated weight, for sorted signal/background events.
Double_t GetVal(Int_t var) const
Double_t GetCumulativeWeight(Bool_t type) const
Get the accumulated weight.
static void SetVarIndex(Int_t iVar)
Double_t GetVal() const
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
Definition Event.cxx:236
create variable transformations