00001 00002 /********************************************************************************** 00003 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * 00004 * Package: TMVA * 00005 * Class : BDTEventWrapper * 00006 * Web : http://tmva.sourceforge.net * 00007 * * 00008 * Description: * 00009 * * 00010 * * 00011 * Author: Doug Schouten (dschoute@sfu.ca) * 00012 * * 00013 * Copyright (c) 2007: * 00014 * CERN, Switzerland * 00015 * U. of Texas at Austin, USA * 00016 * * 00017 * Redistribution and use in source and binary forms, with or without * 00018 * modification, are permitted according to the terms listed in LICENSE * 00019 * (http://tmva.sourceforge.net/LICENSE) * 00020 **********************************************************************************/ 00021 00022 #ifndef ROOT_TMVA_BDTEventWrapper 00023 #define ROOT_TMVA_BDTEventWrapper 00024 00025 #ifndef ROOT_Event 00026 #include "Event.h" 00027 #endif 00028 00029 namespace TMVA { 00030 00031 class BDTEventWrapper{ 00032 00033 public: 00034 00035 BDTEventWrapper( const Event* ); 00036 ~BDTEventWrapper(); 00037 00038 // Require '<' operator to use std::sort algorithms on collection of Events 00039 Bool_t operator <( const BDTEventWrapper& other ) const; 00040 00041 // Set the accumulated weight, for sorted signal/background events 00042 /** 00043 * @param fType - true for signal, false for background 00044 * @param weight - the total weight 00045 */ 00046 void SetCumulativeWeight( Bool_t type, Double_t weight ); 00047 00048 // Get the accumulated weight 00049 /** 00050 * @param fType - true for signal, false for background 00051 * @return the cumulative weight for sorted signal/background events 00052 */ 00053 Double_t GetCumulativeWeight( Bool_t type ) const; 00054 00055 // Set the index of the variable to compare on 00056 /** 00057 * @param iVar - index of the variable in fEvent to use 00058 */ 00059 inline static void SetVarIndex( Int_t iVar ) { if (iVar >= 0) fVarIndex = iVar; } 00060 00061 // Return the value of variable fVarIndex for this event 00062 /** 00063 * @return value of variable fVarIndex for this event 00064 */ 00065 inline Double_t GetVal() const { return fEvent->GetValue(fVarIndex); } 00066 const Event* operator*() const { return fEvent; } 00067 00068 private: 00069 00070 static Int_t fVarIndex; // index of the variable to sort on 00071 const Event* fEvent; // pointer to the event 00072 00073 Double_t fBkgWeight; // cumulative background weight for splitting 00074 Double_t fSigWeight; // same for the signal weights 00075 }; 00076 } 00077 00078 inline Bool_t TMVA::BDTEventWrapper::operator<( const BDTEventWrapper& other ) const 00079 { 00080 return GetVal() < other.GetVal(); 00081 } 00082 00083 #endif 00084