Event.h

Go to the documentation of this file.
00001 // @(#)root/tmva $Id: Event.h 37986 2011-02-04 21:42:15Z pcanal $   
00002 // Author: Andreas Hoecker, Peter Speckmayer, Joerg Stelzer, Helge Voss
00003 
00004 /**********************************************************************************
00005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
00006  * Package: TMVA                                                                  *
00007  * Class  : Event                                                                 *
00008  * Web    : http://tmva.sourceforge.net                                           *
00009  *                                                                                *
00010  * Description:                                                                   *
00011  *      Event container                                                           *
00012  *                                                                                *
00013  * Authors (alphabetical):                                                        *
00014  *      Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland              *
00015  *      Joerg Stelzer   <Joerg.Stelzer@cern.ch>  - CERN, Switzerland              *
00016  *      Peter Speckmayer <Peter.Speckmayer@cern.ch>  - CERN, Switzerland          *
00017  *      Helge Voss      <Helge.Voss@cern.ch>     - MPI-K Heidelberg, Germany      *
00018  *                                                                                *
00019  * Copyright (c) 2005:                                                            *
00020  *      CERN, Switzerland                                                         * 
00021  *      U. of Victoria, Canada                                                    * 
00022  *      MPI-K Heidelberg, Germany                                                 * 
00023  *      LAPP, Annecy, France                                                      *
00024  *                                                                                *
00025  * Redistribution and use in source and binary forms, with or without             *
00026  * modification, are permitted according to the terms listed in LICENSE           *
00027  * (http://mva.sourceforge.net/license.txt)                                       *
00028  **********************************************************************************/
00029 
00030 #ifndef ROOT_TMVA_Event
00031 #define ROOT_TMVA_Event
00032 
00033 #include <iosfwd>
00034 #include <vector>
00035 
00036 #ifndef ROOT_Rtypes
00037 #include "Rtypes.h"
00038 #endif
00039 #ifndef ROOT_TMVA_Types
00040 #include "TMVA/Types.h"
00041 #endif
00042 
00043 class TCut;
00044 
00045 namespace TMVA {
00046 
00047    class Event;
00048 
00049    std::ostream& operator<<( std::ostream& os, const Event& event );
00050 
00051    class Event {
00052 
00053       friend std::ostream& operator<<( std::ostream& os, const Event& event );
00054 
00055    public:
00056 
00057       // constructors
00058       Event();
00059       Event( const Event& );
00060       explicit Event( const std::vector<Float_t>& values, 
00061                       const std::vector<Float_t>& targetValues, 
00062                       const std::vector<Float_t>& spectatorValues, 
00063                       UInt_t theClass = 0, Double_t weight = 1.0, Double_t boostweight = 1.0 );
00064       explicit Event( const std::vector<Float_t>& values, 
00065                       const std::vector<Float_t>& targetValues, 
00066                       UInt_t theClass = 0, Double_t weight = 1.0, Double_t boostweight = 1.0 );
00067       explicit Event( const std::vector<Float_t>&, 
00068                       UInt_t theClass, Double_t weight = 1.0, Double_t boostweight = 1.0 );
00069       explicit Event( const std::vector<Float_t*>*&, UInt_t nvar );
00070 
00071       ~Event();
00072 
00073       // accessors
00074       Bool_t  IsDynamic()         const {return fDynamic; }
00075 
00076       Double_t GetWeight()         const { return fWeight*fBoostWeight; }
00077       Double_t GetOriginalWeight() const { return fWeight; }
00078       Double_t GetBoostWeight()    const { return TMath::Max(Double_t(0.0001),fBoostWeight); }
00079       UInt_t  GetClass()          const { return fClass; }  
00080 
00081       UInt_t  GetNVariables()        const;
00082       UInt_t  GetNTargets()          const;
00083       UInt_t  GetNSpectators()       const;
00084 
00085       const std::vector<UInt_t>* GetVariableArrangement() const { return fVariableArrangement; }
00086 
00087       Float_t GetValue( UInt_t ivar) const;
00088       const std::vector<Float_t>& GetValues() const;
00089 
00090       Float_t GetTarget( UInt_t itgt ) const { return fTargets.at(itgt); }
00091       std::vector<Float_t>& GetTargets() const { return fTargets; }
00092 
00093       Float_t GetSpectator( UInt_t ivar) const;
00094       std::vector<Float_t>& GetSpectators() const { return fSpectators; }
00095 
00096       void    ScaleWeight           ( Double_t s ) { fWeight*=s; }
00097       void    SetWeight             ( Double_t w ) { fWeight=w; }
00098       void    SetBoostWeight        ( Double_t w ) { fBoostWeight=w; }
00099       void    ScaleBoostWeight      ( Double_t s ) { fBoostWeight *= s; }
00100       void    SetClass              ( UInt_t t )  { fClass=t; }
00101       void    SetVal                ( UInt_t ivar, Float_t val );
00102       void    SetTarget             ( UInt_t itgt, Float_t value );
00103       void    SetSpectator          ( UInt_t ivar, Float_t value );
00104       void    SetVariableArrangement( std::vector<UInt_t>* const m ) const;
00105 
00106       static void ClearDynamicVariables();
00107 
00108       void    CopyVarValues( const Event& other );
00109       void    Print        ( std::ostream & o ) const;
00110 
00111    private:
00112 
00113       mutable std::vector<Float_t>   fValues;               // the event values
00114       mutable std::vector<Float_t*>* fValuesDynamic;       // the event values
00115       mutable std::vector<Float_t>   fTargets;              // target values for regression
00116       mutable std::vector<Float_t>   fSpectators;           // "visisting" variables which are never used for any calculation
00117       mutable std::vector<UInt_t>*   fVariableArrangement;  // needed for MethodCategories, where we can train on other than the main variables
00118 
00119       UInt_t                         fClass;           // signal or background type: signal=1, background=0
00120       Double_t                       fWeight;          // event weight (product of global and individual weights)
00121       Double_t                       fBoostWeight;     // internal weight to be set by boosting algorithm
00122       Bool_t                         fDynamic;         // is set when the dynamic values are taken
00123    };
00124 }
00125 
00126 #endif

Generated on Tue Jul 5 14:27:27 2011 for ROOT_528-00b_version by  doxygen 1.5.1