/* #ifndef HISTOGRAM_H */ /* #define HISTOGRAM_H 1 */ #ifndef __Histogram__ #define __Histogram__ //ROOT libraries #include "TObject.h" #include "TH1.h" #include "TH2.h" #include "TH3.h" #include "TCanvas.h" #include "TTree.h" #include "TFile.h" // C++ libraries #include #include #include #include #include class Histogram : public TObject{ public: Histogram(); Histogram(std::string name , std::string title, std::string type ); ~Histogram(); typedef std::map mapFloat; typedef std::map mapInt; typedef std::map mapDouble; typedef std::map > mapVector; void Create(); void Create(std::string type); void Create(std::string type,std::vector binsx ,std::vector binsy , std::vector binsz); void Create(std::string type,int x_nbins, double x_min,double x_max ,int y_nbins=0 , double y_min=0 ,double y_max =0 ,int z_nbins =0 , double z_min=0 ,double z_max =0 ); TH1* hist(){ if( m_type == "1D" ) return m_hist1D; else if( m_type == "2D" ) return m_hist2D; else if( m_type == "3D" ) return m_hist3D; else return m_hist1D; }; std::string type(){ return m_type; } bool copyFromFile(TString filename, TString hist_name); bool fillFromFile(TString filename, TString treename); bool fillFromTree(TTree* tree); bool fillEvents(int weight, double x, double y , double z ); void clear(); void DeleteHist(); void DrawHist(TString outputName,bool logScale,TString options=""); void DrawHist(TString options=""); void ratio( Histogram* hist,bool scaled); void ratio( TH1D* hist,bool scaled); void ratio( TH2D* hist,bool scaled); void ratio( TH3D* hist,bool scaled); void defineSelection(std::string varType, mapVector selection ); void defineVariables(TString varType,std::vector variables ); void defineWeightVariables(TString varType,std::vector weightsVar ); void defineWeightHist( TH1D* weightHist ); void defineWeightHist( TH2D* weightHist ); void defineWeightHist( TH3D* weightHist ); void defineSelVar( std::string varname,std::string varType, std::vector selVector , bool min = false); void setMaximum( double maximum ){m_defaultHist->SetMaximum(maximum);}; void setMinimum( double minimum ){m_defaultHist->SetMinimum(minimum);}; void setRange( double x_min,double x_max ,double y_min= 0 ,double y_max = 0 , double z_min= 0 ,double z_max = 0 ); void defineBins( int x_nbins, double x_min,double x_max ,int y_nbins=0 , double y_min=0 ,double y_max =0 ,int z_nbins =0 , double z_min=0 ,double z_max =0 ); void defineBins( std::vector binsx ,std::vector binsy , std::vector binsz ); void changeBins( int x_nbins, double x_min,double x_max ,int y_nbins=0 , double y_min=0 ,double y_max=0 ,int z_nbins=0 , double z_min =0 ,double z_max =0 ); void changeBins( std::vector binsx ,std::vector binsy , std::vector binsz ); void setLabels(std::string xlabel,std::string ylabel = "events", std::string zlabel = "" ); void setMarkerStyle(Style_t MarkerStyle, Color_t MarkerColor, float MarkerSize); void setLineStyle(Style_t LineStyle, Color_t LineColor , float LineWidth); void setFillStyle(Color_t FillColor); private : std::string m_name; std::string m_title; std::string m_type; TH1* m_defaultHist;//! TH1D* m_hist1D;//! TH2D* m_hist2D;//! TH3D* m_hist3D;//! int m_x_nbins; int m_y_nbins; int m_z_nbins; std::vector m_x_bins; std::vector m_y_bins; std::vector m_z_bins; mapVector m_selectionCuts; mapFloat m_selFloat; mapFloat m_varFloat; mapFloat m_weightsFloat; mapDouble m_selDouble; mapDouble m_varDouble; mapDouble m_weightsDouble; mapInt m_selInt; mapInt m_varInt; mapInt m_weightsInt; TH1* m_weightsHist ; bool asymmetricBins; bool fillfromTree; bool weigths; bool defineBranchAddress(TTree* tree); bool passSelection(); void checkVariables(); ClassDef(Histogram,1); }; #endif /* //> !HISTOGRAM_H*/