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

FillkNN.h

Go to the documentation of this file.
00001 #ifndef ANP_FILLKNN_H
00002 #define ANP_FILLKNN_H
00003 
00004 // $Id: FillkNN.h,v 1.11 2009/02/17 19:15:40 rustem Exp $
00005 //
00006 // FillkNN algorithm fills muon track probability using
00007 // k-nearest neighbors method. The algorithm does two tasks:
00008 //    1) creates prototype files storing events
00009 //    2) finds k-nearest neighbors for signal and background
00010 //       reconstructed tracks and/or events using prototype file.
00011 //
00012 // This algorithm depends on FillMuonId algorithm, which fills
00013 // input variables.
00014 //
00015 
00016 // C++
00017 #include <map>
00018 #include <iostream>
00019 #include <string>
00020 #include <vector>
00021 
00022 // Local
00023 #include "PhysicsNtuple/AlgEvent.h"
00024 #include "PhysicsNtuple/AlgSnarl.h"
00025 
00026 // Local
00027 #include "Node.h"
00028 
00029 class TFile;
00030 
00031 namespace Lit
00032 {
00033    class LikeModule;
00034 }
00035 
00036 namespace Anp
00037 {
00038    class FillkNN : public AlgSnarl, public AlgEvent
00039    {
00040    public:
00041       
00042       FillkNN();
00043       virtual ~FillkNN();
00044 
00045       bool Run(Record &record);
00046 
00047       bool Run(Event &event, const Record& record, bool pass);
00048       
00049       void Config(const Registry &reg);
00050 
00051       bool Init(const Header &);
00052 
00053       void End(const DataBlock &);
00054 
00055    private:
00056 
00057       typedef std::vector<short> ShortVec;
00058       typedef std::map<short, int> ShortMap;
00059 
00060    private:
00061 
00062       bool Fill(DataIter beg, DataIter end, double weight);
00063 
00064       const DataVec Find(DataIter beg, DataIter end, short keybase) const;
00065 
00066       double PidKer(Lit::List::const_iterator beg, Lit::List::const_iterator end) const;
00067 
00068       const std::vector<float> Get(DataIter beg, DataIter end, const ShortVec &kvec) const;
00069 
00070       double Kernel(const double value) const;
00071 
00072    private:
00073 
00074       mutable unsigned int fNAbortFind; // # of aborted knn searches: knn value already exists
00075       unsigned int fNTrackMiss;         // # of tracks with not enough data to filled knn
00076       unsigned int fNTrackFill;         // # of tracks with correctly filled knn
00077       unsigned int fNEventMiss;         // # of events with not enough data to filled knn
00078       unsigned int fNEventFill;         // # of events with correctly filled knn
00079 
00080       std::string fDirName;
00081       std::string fFilePath;
00082 
00083       int fMaxNEvent;   // maximum number of events read from knn protype file
00084       int fKeyBase;     // key base for knn pid = base + type(optional) + knn
00085       int fKeySignal;   // when type is option, then this gives type of signal events
00086       int fKeyTruth;    // key where true type is stored
00087       int fTrimDelta;   // do not fill events that exceed min # of events by fTrimDelta
00088 
00089       unsigned int fKNeighbor;    // k-nearest neighbors
00090       unsigned int fKNeighborMod; // report pid for knn = count % fKNeighborMod 
00091 
00092       bool fAddAll;     // add all signal types?
00093       bool fAddEvent;   // when running as AlgSnarl && fUseTrack=true, add keys to event?
00094       bool fCreateNew;  // create new knn prototype?
00095       bool fPrint;      // print knn list?
00096       bool fRegression; // run regression analysis
00097       bool fTrim;       // use equal number of events of each type?
00098       bool fUseKernel;  // use kernel?
00099       bool fUseTrack;   // get input variables from track data vector?
00100 
00101       Lit::LikeModule *fModule;
00102 
00103       ShortVec fKeys;
00104       ShortVec fTgts;
00105       ShortVec fTypes;
00106       ShortMap fCount;
00107    };
00108 }
00109 
00110 #endif

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