Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Analyze.h

Go to the documentation of this file.
00001 // Analyze.h
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     // base class for analysis. Provides setup for simple analysis of a TupleItem
00013     // and formating functions for output
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     // make a separator line for output
00042     static std::string   make_label(const std::string&);
00043     // format a label for tablular output
00044     static bool     showperc () { return s_showperc; }
00045     // are percentages shown in readout?
00046     static void     showperc ( bool s ) { s_showperc = s; }
00047     // set the show percentages on display flag
00048 
00049 private:
00050     virtual bool    apply() { return true; }
00051     // default analysis function. Note private, should only be accessed by operator()
00052     // subclass should make private also.
00053 
00054     unsigned        m_count;        // keep track of success
00055     const TupleItem*  m_tupleItem;  // the tuple item to analyze or cut.
00056     std::string     m_name;         // name to describe this
00057 
00058     unsigned        m_seen;         // number of events seen (for making ratios)
00059 
00060     static bool     s_showperc;     // flag to determine whether percentages are shown
00061 };
00062 
00063 #endif

Generated at Wed Nov 21 12:20:38 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000