Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

PhysicsNtuple/kNNAlg/Event.h

Go to the documentation of this file.
00001 #ifndef LIT_EVENT_H
00002 #define LIT_EVENT_H
00003 
00004 // $Id: Event.h,v 1.5 2009/02/17 19:15:40 rustem Exp $
00005 //
00006 // Internal knn class that stores classification variables
00007 //
00008 
00009 // C/C++
00010 #include <cassert>
00011 #include <iostream>
00012 #include <vector>
00013 
00014 namespace Lit
00015 {
00016    typedef float VarType;
00017    typedef std::vector<VarType> VarVec;
00018 
00019    class Event
00020    {
00021    public:
00022 
00023       Event();
00024       Event(const VarVec &vvec, double weight, short type);
00025       Event(const VarVec &vvec, double weight, short type, const VarVec &tvec);
00026       ~Event();
00027       
00028       double GetWeight() const;
00029 
00030       VarType GetVar(unsigned int i) const;
00031       VarType GetTgt(unsigned int i) const;
00032 
00033       unsigned int GetNVar() const;
00034       unsigned int GetNTgt() const;
00035 
00036       const VarVec& GetVarVec() const;
00037       const VarVec& GetTgtVec() const;
00038 
00039       short GetType() const;
00040       
00041       void Print(std::ostream& os = std::cout, unsigned int w = 5, unsigned int p = 3) const;
00042 
00043    private:
00044 
00045       VarVec fVar;     // classificaion variables vector
00046       VarVec fTgt;     // target variables vector
00047       double fWeight;  // event weight
00048       short  fType;    // event type: signal, background, etc
00049    };
00050 
00051    //
00052    // Global functions used by k-nearest neighbor algorithm
00053    //
00054    inline VarType Distance(const VarType var1, const VarType var2)
00055    {
00056       return (var1 - var2) * (var1 - var2);
00057    }
00058 
00059    VarType Distance(const Event &event1, const Event &event2);
00060 
00061    std::ostream& operator<<(std::ostream& os, const Event& event);
00062    
00063 
00064    //
00065    // Inlined member functions
00066    //
00067    inline double Event::GetWeight() const
00068    {
00069       return fWeight;
00070    }
00071 
00072    inline unsigned int Event::GetNVar() const { return fVar.size(); }
00073    inline unsigned int Event::GetNTgt() const { return fTgt.size(); }
00074       
00075    inline const VarVec& Event::GetVarVec() const { return fVar; }
00076    inline const VarVec&Event:: GetTgtVec() const { return fTgt; }
00077 
00078    inline short Event::GetType() const
00079    {
00080       return fType;
00081    }
00082 }
00083 
00084 #endif

Generated on Mon Feb 15 11:06:39 2010 for loon by  doxygen 1.3.9.1