Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-09 08:12:16

0001 #ifndef VTXZDIST_COMP_H
0002 #define VTXZDIST_COMP_H
0003 
0004 #include <iostream>
0005 #include <numeric>
0006 
0007 #include <TH1.h>
0008 #include <TH2.h>
0009 #include <TFile.h>
0010 #include <TCanvas.h>
0011 #include <TStyle.h>
0012 #include <TLegend.h>
0013 #include <TLatex.h>
0014 #include <TGaxis.h>
0015 #include <TObject.h>
0016 #include <TKey.h>
0017 #include <TGraphErrors.h>
0018 
0019 #include "sPhenixStyle.h"
0020 
0021 #include "../../Constants.h"
0022 
0023 class vtxZDist_comp{
0024     public:
0025         vtxZDist_comp(
0026             std::string sPH_labeling_in,
0027             std::string MC_labeling_in,
0028             std::vector<std::pair<std::string, std::pair<std::string, std::string>>> data_input_directory_pair_vec_in, // note: directory, and description
0029             std::vector<std::pair<std::string, std::pair<std::string, std::string>>> MC_input_directory_pair_vec_in, // note: directory, and description
0030             std::map<std::string, std::vector<std::tuple<double,double,std::string>>> labelling_vec_map_in, // note: starting XY, and description 
0031             std::string output_directory_in,
0032 
0033             bool WithVtxZReWeighting_in // note: MC with reweighting
0034         );
0035 
0036         void MakeDataPlot(std::string draw_method = "hist");
0037         void MakeMCPlot(std::string draw_method = "hist");
0038         void MakeComparisonPlot();
0039 
0040         void MakeVtxZCheckPlot();
0041 
0042         void PrepareINTTvtxZReWeight();
0043 
0044     protected:
0045         // Division: ---For constructor---------------------------------------------------------------------------------------------------------------------------------------------
0046         std::string sPH_labeling;
0047         std::string MC_labeling;
0048         std::vector<std::pair<std::string, std::pair<std::string, std::string>>> data_input_directory_pair_vec;
0049         std::vector<std::pair<std::string, std::pair<std::string, std::string>>> MC_input_directory_pair_vec;
0050         std::map<std::string, std::vector<std::tuple<double,double,std::string>>> labelling_vec_map;
0051         std::string output_directory;
0052         bool WithVtxZReWeighting;
0053         bool with_data;
0054         bool with_MC;
0055 
0056 
0057         std::map<std::string, std::pair<std::string, std::string>> data_input_directory_map;
0058         std::map<std::string, std::pair<std::string, std::string>> MC_input_directory_map;
0059         // Division: ---For input files---------------------------------------------------------------------------------------------------------------------------------------------
0060         std::vector<TFile*> file_data_vec;
0061         std::map<std::string, std::map<std::string, TH1D*>> data_h1D_map_map; // note : file_name, hist_name, hist
0062         std::map<std::string, std::map<std::string, TH2D*>> data_h2D_map_map; // note : file_name, hist_name, hist
0063 
0064         std::vector<TFile*> file_MC_vec;
0065         std::map<std::string, std::map<std::string, TH1D*>> MC_h1D_map_map; // note : file_name, hist_name, hist
0066         std::map<std::string, std::map<std::string, TH2D*>> MC_h2D_map_map; // note : file_name, hist_name, hist
0067 
0068         void PrepareInputFiles();
0069         std::string string_convertor(std::string input_string);
0070 
0071 
0072         // Division: ---For Plots---------------------------------------------------------------------------------------------------------------------------------------------
0073         TLatex * ltx;
0074         TCanvas * c1;
0075         TLegend * All_leg;
0076         TLegend * All_leg_long;
0077         TLatex * sub_ltx;
0078 
0079         std::pair<double,double> make_comparison(
0080             std::vector<std::pair<std::string, TH1D*>> data_hist_vec_in,  // note : description, hist
0081             std::vector<std::pair<std::string, TH1D*>> MC_hist_vec_in,    // note : description, hist
0082             std::string output_directory_in, 
0083             std::string output_filename_in, 
0084             std::string sub_label_text_in,
0085             bool set_log_y = false, 
0086             bool isData_more = false,
0087             double MainPlot_y_low = 0, 
0088             double MainPlot_y_top = -99, 
0089             double ratio_y_low = 0,
0090             double ratio_y_top = 2
0091         );
0092 
0093         void MakePlots(std::string draw_method, bool isData);
0094 
0095         double GetNonZeroMinimalBin(TH1D * hist_in);
0096 
0097         std::vector<std::string> h1comp_logy_plot_vec = {
0098             "h1D_VtxZDiff_MBD_INTT_Inclusive100",
0099             "h1D_VtxZDiff_MBD_INTT_Inclusive70",
0100             "h1D_VtxZDiff_MBD_INTT_HighNClus",
0101             "h1D_NgroupTrapezoidal",
0102             "h1D_NgroupCoarse",
0103             "h1D_INTTvtxZError",
0104 
0105             // note : for the RestDist
0106             "h1D_Cluster_phi_size",
0107             "h1D_Cluster_adc",
0108             "h1D_NClus",
0109             "h1D_NClus_inner",
0110             "h1D_NClus_outer",
0111             "h1D_inner_typeA_NClus",
0112             "h1D_outer_typeA_NClus",
0113             "h1D_inner_typeB_NClus",
0114             "h1D_outer_typeB_NClus"
0115 
0116         };
0117 
0118         std::vector<std::string> h1data_only_logy_plot_vec = {
0119 
0120         };
0121 
0122         std::vector<std::string> h1MC_only_logy_plot_vec = {
0123 
0124         };
0125 
0126         std::vector<std::string> h2_logz_plot_vec = {
0127             "h2D_NClus_INTTvtxZ",
0128             "h2D_NClus_TrapezoidalFitWidth",
0129             "h2D_NClus_TrapezoidalFWHM",
0130             "h2D_NClus_INTTvtxZError",
0131 
0132             // note : common
0133             "h2D_confirm_InttNClus_MbdChargeSum",
0134             "h2D_confirm_InttInnerOuterNClus",
0135 
0136             // note : for RestDist
0137             "h2D_ClusPhiSize_ClusAdc",
0138             "h2D_MBDcharge_south_north",
0139             "h2D_MBDvtxZ_MBDchargeSum",
0140             "h2D_MBDvtxZ_MBDchargeSouth",
0141             "h2D_MBDvtxZ_MBDchargeNorth",
0142             "h2D_NClus_ClusPhiSize"
0143 
0144 
0145         };
0146 
0147 
0148         // Division ---For constants---------------------------------------------------------------------------------------------------------------------------------------------
0149         int nCentrality_bin;
0150 
0151         double logy_max_factor;
0152         double lineary_max_factor;
0153         
0154         const std::vector<std::string> color_code = {
0155             "#000000",
0156             "#9e0142",
0157             "#5e4fa2",
0158             "#66c2a5",
0159             "#fdae61",
0160             "#0076A7",
0161             "#fee08b",
0162 
0163             "#d53e4f",
0164             "#abdda4",
0165             "#f46d43",
0166             "#e6f598",
0167             "#00A1FF",
0168 
0169             "#1b9e77",  // Teal Green  
0170             "#d95f02",  // Deep Orange  
0171             "#7570b3",  // Muted Purple  
0172             "#e7298a",  // Vivid Pink  
0173             "#66a61e",  // Olive Green  
0174             "#a6761d",  // Brown  
0175             "#666666",  // Dark Gray  
0176             "#f781bf",  // Light Pink  
0177             "#0173b2",  // Rich Blue  
0178             "#ff7f00"   // Bright Orange  
0179 
0180         };
0181 
0182         const std::vector<int> ROOT_color_code = {
0183             51, 61, 70, 79, 88, 98, 100, 113, 120, 129
0184         };
0185         
0186         const int inner_barrel_0 = 3;
0187         const int inner_barrel_1 = 4;
0188         const int outer_barrel_0 = 5;
0189         const int outer_barrel_1 = 6;
0190 
0191         const int nLadder_inner = 12;
0192         const int nLadder_outer = 16;
0193 
0194         const int south_typeB_ZID = 1;
0195         const int south_typeA_ZID = 0;
0196         const int north_typeA_ZID = 2;
0197         const int north_typeB_ZID = 3;
0198 };
0199 
0200 #endif