00001 #ifndef TK_PhysVarHisto_h
00002 #define TK_PhysVarHisto_h 1
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <string>
00021 #include <vector>
00022
00023
00024 #include <TH1D.h>
00025 #include <TH1F.h>
00026
00027
00028 #include "PhysicsTools/UtilAlgos/interface/TFileService.h"
00029
00030 namespace pat {
00031
00032 class PhysVarHisto
00033 {
00034 public:
00035 PhysVarHisto( std::string name,
00036 std::string title,
00037 int nbins,
00038 double xlow,
00039 double xhigh,
00040 TFileDirectory * currDir = 0,
00041 std::string units = "",
00042 std::string type = "D",
00043 bool saveHist = true,
00044 bool saveNtup = false );
00045
00046 virtual ~PhysVarHisto() { };
00047
00048
00049 virtual void makeTH1();
00050
00051
00052 virtual void fill( double x,
00053 unsigned int imulti = 1,
00054 double weight = 1.0 );
00055
00056
00057 inline std::string name() { return name_ ; }
00058 inline std::string type() { return type_ ; }
00059 inline double value() { return value_ ; }
00060
00061 template <class T>
00062 void vec(std::vector<T> & retVec)
00063 {
00064 retVec.resize( valueColl_.size() );
00065 for ( unsigned int i = 0; i < valueColl_.size(); i++ )
00066 retVec[i] = static_cast<T>( valueColl_[i] );
00067 }
00068
00069 inline bool saveHist() { return saveHist_ ; }
00070 inline bool saveNtup() { return saveNtup_ ; }
00071
00072 inline void setSaveHist(bool flag) { saveHist_ = flag; }
00073 inline void setSaveNtup(bool flag) { saveNtup_ = flag; }
00074
00075 inline void setTFileDirectory(TFileDirectory * dir) { currDir_ = dir; };
00076
00077 inline void clearVec() { valueColl_.clear(); }
00078
00079 private:
00080
00081 TFileDirectory * currDir_ ;
00082 std::string name_ ;
00083 std::string type_ ;
00084 std::string title_ ;
00085 int nbins_ ;
00086 double xlow_ ;
00087 double xhigh_ ;
00088 std::string units_ ;
00089
00090
00091 std::vector<TH1D *> histos_ ;
00092
00093
00094
00095 double value_ ;
00096 void * value_ext_ ;
00097 std::vector<double> valueColl_;
00098
00099
00100
00101 bool saveHist_ ;
00102 bool saveNtup_ ;
00103
00104 int verboseLevel_ ;
00105 };
00106
00107 }
00108
00109 #endif