Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:14:30

0001 #pragma once
0002 #include <Rtypes.h>
0003 #include <TH2.h>
0004 #include <TGraphErrors.h>
0005 #include <string>
0006 #include <vector>
0007 
0008 class BinnedHistSet {
0009     public:
0010     int nbins = 0;
0011     int hist_Nbins = 0;
0012     double hist_lower = 0.0;
0013     double hist_upper = 0.0;
0014     std::string name_base = "";
0015     std::string title_base = "";
0016     std::string binned_quantity = "";
0017     std::string axislabels = "";
0018     std::vector<double> bin_edges = std::vector<double>();
0019     std::vector<TH1*> hist_vec = std::vector<TH1*>();
0020 
0021     BinnedHistSet();
0022     BinnedHistSet(std::string name, std::string title, int n_hist_bins, double lower, double upper, std::string binquantity, std::vector<double> edges);
0023     BinnedHistSet(TH1* h_prototype, std::string binquantity, std::vector<double> edges);
0024     ~BinnedHistSet();
0025 
0026     void printEdges(std::vector<double> edges);
0027     std::vector<double> getUniformBinEdges(int nbins, double lower, double upper);
0028     std::vector<double> getUniformBinEdges(int nbins, TH1* hist);
0029     std::vector<double> getEquallyPopulatedBinEdges(int nbins, TH1* hist);
0030     std::vector<double> getBinCenters(std::vector<double> edges);
0031     std::vector<double> doubleFitHist(TH1* hist, bool response=false);
0032 
0033     std::string GetName() {return name_base;};
0034     void SetName(std::string namestr) {name_base = namestr;};
0035     std::string GetTitle() {return title_base;};
0036     void SetTitle(std::string titlestr) {title_base = titlestr;};
0037     std::string GetBinQuantity() {return binned_quantity;};
0038     void SetBinQuantity(std::string binquantstr) {binned_quantity = binquantstr;};
0039     std::vector<double> GetBinEdges() {return bin_edges;};
0040     void SetBinEdges(std::vector<double> edges) {bin_edges = edges; nbins = edges.size() - 1;};
0041     int GetHistBins() {return hist_Nbins;};
0042     void SetHistBins(int N) {hist_Nbins = N;};
0043     std::string GetTitlePrefix();
0044     void GetAxisLabels();
0045     std::string GetBinnedQuantityName();
0046     std::string GetBinnedQuantityUnits();
0047 
0048     void MakeHists();
0049     void FillHists(double binValue, double fillValue);
0050     void WriteHists();
0051     void GetHistsFromFile(std::string name);
0052     TH1** GetHistArr();
0053 
0054     void PlotAllHistsWithFits(std::string outpdfname, bool response, std::string fitfunc);
0055     TGraphErrors* GetEnergyResolution();
0056     void PlotEnergyResolution(std::string outpdfname, double low=0.0, double high=0.3);
0057     TGraphErrors* GetBinnedMeansWide();
0058     TGraphErrors* GetBinnedMeansNarrow();
0059     void PlotBinnedMeans(std::string outpdfname, double low, double high);
0060 
0061     private:
0062 };