00001 #ifndef LIT_LIKEMODULE_H
00002 #define LIT_LIKEMODULE_H
00003
00004
00005 #include <iosfwd>
00006 #include <map>
00007
00008
00009 #include "Node.h"
00010 #include "Result.h"
00011
00012 class TDirectory;
00013
00014 namespace Lit
00015 {
00016 typedef std::vector<Lit::Event> EventVec;
00017
00018 class LikeModule
00019 {
00020 public:
00021
00022 typedef std::map<int, std::vector<double> > VarMap;
00023 typedef std::map<short, double> ProbMap;
00024
00025 public:
00026
00027 LikeModule();
00028 ~LikeModule();
00029
00030 bool Read(const std::string &filepath, int nevent = 0, const std::string &treename = "events");
00031 bool Read(TDirectory *dir, int nevent = 0, const std::string &treename = "events");
00032
00033 bool Write(const std::string &filepath, const std::string &treename = "events");
00034 void Write(TDirectory *dir, const std::string &treename = "events");
00035
00036 void Add(const Event &event);
00037
00038 bool Fill(unsigned short optimize_depth = 7, const std::string &option = "");
00039
00040 bool Find(Event event, unsigned int nfind = 100) const;
00041
00042 bool Find(unsigned int nfind, const std::string &option) const;
00043
00044 const EventVec& GetEventVec() const;
00045 const Result& GetResult() const;
00046
00047 const VarMap& GetVarMap() const;
00048
00049 const std::map<int, double>& GetMetric() const;
00050
00051 void Print() const;
00052 void Print(std::ostream &os) const;
00053
00054 private:
00055
00056 Node* Balance(unsigned int bdepth);
00057
00058 void ComputeMetric(unsigned int ifrac = 10);
00059
00060 const Event Scale(const Event &event) const;
00061
00062 private:
00063
00064 unsigned int fDimn;
00065
00066 Node *fTree;
00067
00068 std::map<int, double> fVarScale;
00069
00070 mutable Result fResult;
00071
00072 std::map<short, unsigned int> fCount;
00073
00074 EventVec fEvent;
00075 VarMap fVar;
00076 };
00077
00078 inline const Result& LikeModule::GetResult() const
00079 {
00080 return fResult;
00081 }
00082 inline const EventVec& LikeModule::GetEventVec() const
00083 {
00084 return fEvent;
00085 }
00086 inline const LikeModule::VarMap& LikeModule::GetVarMap() const
00087 {
00088 return fVar;
00089 }
00090 inline const std::map<int, double>& LikeModule::GetMetric() const
00091 {
00092 return fVarScale;
00093 }
00094 }
00095
00096 #endif
00097