// @(#)root/tmva $Id$    
// Author: Andrzej Zemla

/**********************************************************************************
 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
 * Package: TMVA                                                                  *
 * Class  : SVEvent                                                               *
 * Web    : http://tmva.sourceforge.net                                           *
 *                                                                                *
 * Description:                                                                   *
 *      Event class for Support Vector Machine                                    *
 *                                                                                *
 * Authors (alphabetical):                                                        *
 *      Marcin Wolter  <Marcin.Wolter@cern.ch> - IFJ PAN, Krakow, Poland          *
 *      Andrzej Zemla  <azemla@cern.ch>        - IFJ PAN, Krakow, Poland          *
 *      (IFJ PAN: Henryk Niewodniczanski Inst. Nucl. Physics, Krakow, Poland)     *   
 *                                                                                *
 * Copyright (c) 2005:                                                            *
 *      CERN, Switzerland                                                         * 
 *      MPI-K Heidelberg, Germany                                                 * 
 *      PAN, Krakow, Poland                                                       *
 *                                                                                *
 * Redistribution and use in source and binary forms, with or without             *
 * modification, are permitted according to the terms listed in LICENSE           *
 * (http://tmva.sourceforge.net/LICENSE)                                          *
 **********************************************************************************/

#ifndef ROOT_TMVA_SVEvent
#define ROOT_TMVA_SVEvent

#include <vector>
#include <iostream>

#ifndef ROOT_Rtypes
#include "Rtypes.h"
#endif

namespace TMVA 
{
   class Event;

   class SVEvent {

   public:

      SVEvent();
      SVEvent( const Event*, Float_t, Bool_t isSignal = kFALSE );
      SVEvent( const std::vector<Float_t>*, Float_t alpha, Int_t typeFlag, UInt_t ns );
      SVEvent( const std::vector<Float_t>* svector, Float_t alpha, Float_t alpha_p, Int_t typeFlag);

      virtual ~SVEvent();

      void SetAlpha        ( Float_t  alpha )      { fAlpha = alpha; }
      void SetAlpha_p      ( Float_t  alpha )      { fAlpha_p = alpha; }
      void SetErrorCache   ( Float_t  err_cache )  { fErrorCache = err_cache; }
      void SetIsShrinked   ( Int_t    isshrinked ) { fIsShrinked = isshrinked; }
      void SetLine         ( Float_t* line )       { fLine = line; } 
      void SetIdx          ( Int_t    idx )        { fIdx = idx; }
      void SetNs           ( UInt_t   ns )         { fNs = ns; }
      void UpdateErrorCache(Float_t upercache )    { fErrorCache += upercache; } 
         
      std::vector<Float_t>* GetDataVector() { return &fDataVector; } 
      Float_t  GetAlpha()         const { return fAlpha; }
      Float_t  GetAlpha_p()       const { return fAlpha_p; }
      Float_t  GetDeltaAlpha()    const { return fAlpha -  fAlpha_p; }

      Float_t  GetErrorCache()  const { return fErrorCache; }
      Int_t    GetTypeFlag()    const  { return fTypeFlag; }
      Int_t    GetNVar()        const  { return fNVar; }
      Int_t    GetIdx()         const  { return fIdx;}
      Float_t* GetLine()        const  { return fLine;}
      UInt_t   GetNs()          const  { return fNs;} 
      Float_t  GetCweight()     const  { return fCweight;}
      Float_t  GetTarget()      const  { return fTarget;}
      
      Bool_t  IsInI0a() const { return (0.< fAlpha) && (fAlpha<fCweight); }
      Bool_t  IsInI0b() const { return (0.< fAlpha) && (fAlpha_p<fCweight); }
      Bool_t  IsInI0()  const { return (IsInI0a() || IsInI0b()); } 
      Bool_t  IsInI1()  const { return (fAlpha == 0. && fAlpha_p == 0.); }
      Bool_t  IsInI2()  const { return (fAlpha == 0. && fAlpha_p == fCweight); }
      Bool_t  IsInI3()  const { return (fAlpha == fCweight && fAlpha_p == 0.); }
      
      void Print( std::ostream& os ) const;
      void PrintData();

   private:

      std::vector<Float_t> fDataVector;
      const Float_t        fCweight;     // svm cost weight
      Float_t              fAlpha;       // lagrange multiplier
      Float_t              fAlpha_p;     // lagrange multiplier
      Float_t              fErrorCache;  // optimization parameter
      UInt_t               fNVar;        // number of variables
      const Int_t          fTypeFlag;    // is sig or bkg - svm requieres 1 for sig and -1 for bkg
      Int_t                fIdx;         // index flag
      UInt_t               fNs;          // documentation
      Int_t                fIsShrinked;  // shrinking flag, see documentation
      Float_t*             fLine;        // pointer to column of kerenl matrix 
      const Float_t        fTarget;      // regression target
      
      ClassDef(SVEvent,0) // Event for SVM
   };
}

#endif //ROOT_TMVA_SVEvent
 SVEvent.h:1
 SVEvent.h:2
 SVEvent.h:3
 SVEvent.h:4
 SVEvent.h:5
 SVEvent.h:6
 SVEvent.h:7
 SVEvent.h:8
 SVEvent.h:9
 SVEvent.h:10
 SVEvent.h:11
 SVEvent.h:12
 SVEvent.h:13
 SVEvent.h:14
 SVEvent.h:15
 SVEvent.h:16
 SVEvent.h:17
 SVEvent.h:18
 SVEvent.h:19
 SVEvent.h:20
 SVEvent.h:21
 SVEvent.h:22
 SVEvent.h:23
 SVEvent.h:24
 SVEvent.h:25
 SVEvent.h:26
 SVEvent.h:27
 SVEvent.h:28
 SVEvent.h:29
 SVEvent.h:30
 SVEvent.h:31
 SVEvent.h:32
 SVEvent.h:33
 SVEvent.h:34
 SVEvent.h:35
 SVEvent.h:36
 SVEvent.h:37
 SVEvent.h:38
 SVEvent.h:39
 SVEvent.h:40
 SVEvent.h:41
 SVEvent.h:42
 SVEvent.h:43
 SVEvent.h:44
 SVEvent.h:45
 SVEvent.h:46
 SVEvent.h:47
 SVEvent.h:48
 SVEvent.h:49
 SVEvent.h:50
 SVEvent.h:51
 SVEvent.h:52
 SVEvent.h:53
 SVEvent.h:54
 SVEvent.h:55
 SVEvent.h:56
 SVEvent.h:57
 SVEvent.h:58
 SVEvent.h:59
 SVEvent.h:60
 SVEvent.h:61
 SVEvent.h:62
 SVEvent.h:63
 SVEvent.h:64
 SVEvent.h:65
 SVEvent.h:66
 SVEvent.h:67
 SVEvent.h:68
 SVEvent.h:69
 SVEvent.h:70
 SVEvent.h:71
 SVEvent.h:72
 SVEvent.h:73
 SVEvent.h:74
 SVEvent.h:75
 SVEvent.h:76
 SVEvent.h:77
 SVEvent.h:78
 SVEvent.h:79
 SVEvent.h:80
 SVEvent.h:81
 SVEvent.h:82
 SVEvent.h:83
 SVEvent.h:84
 SVEvent.h:85
 SVEvent.h:86
 SVEvent.h:87
 SVEvent.h:88
 SVEvent.h:89
 SVEvent.h:90
 SVEvent.h:91
 SVEvent.h:92
 SVEvent.h:93
 SVEvent.h:94
 SVEvent.h:95
 SVEvent.h:96
 SVEvent.h:97
 SVEvent.h:98
 SVEvent.h:99
 SVEvent.h:100
 SVEvent.h:101
 SVEvent.h:102
 SVEvent.h:103
 SVEvent.h:104
 SVEvent.h:105