00001
00002
00003 #ifndef ANALYZE_H
00004 #define ANALYZE_H
00005
00006 #include "analysis/Tuple.h"
00007
00008 #include <iosfwd>
00009
00010
00011 class Analyze {
00012
00013
00014 public:
00015 Analyze(std::string name="Generic count") : m_count(0),m_tupleItem(0),m_name(name)
00016 , m_seen(0) {}
00017 Analyze(const Tuple& t, const std::string& item_name, const std::string& cut_name="");
00018
00019 Analyze(const TupleItem& item, const std::string& cut_name="");
00020
00021 virtual ~Analyze() {}
00022
00023 bool operator() () { bool b = apply(); if (b) m_count++; m_seen++; return b; }
00024
00025
00026 unsigned count () const { return m_count; }
00027 unsigned seen () const { return m_seen; }
00028 float item()const{ return * m_tupleItem;}
00029 const std::string& name() const { return m_name; }
00030
00031
00032 void set_name(std::string newname){m_name=newname;}
00033 void set_tuple_item(const Tuple&t, std::string item_name);
00034
00035 virtual void report(std::ostream& out);
00036
00037
00038 virtual void clear() {m_count=0;}
00039
00040 static void separator(std::ostream& out, char ='-');
00041
00042 static std::string make_label(const std::string&);
00043
00044 static bool showperc () { return s_showperc; }
00045
00046 static void showperc ( bool s ) { s_showperc = s; }
00047
00048
00049 private:
00050 virtual bool apply() { return true; }
00051
00052
00053
00054 unsigned m_count;
00055 const TupleItem* m_tupleItem;
00056 std::string m_name;
00057
00058 unsigned m_seen;
00059
00060 static bool s_showperc;
00061 };
00062
00063 #endif