File indexing completed on 2025-08-06 08:12:43
0001 #ifndef PREPAREDNDETACLUSEACH_H
0002 #define PREPAREDNDETACLUSEACH_H
0003
0004 #include <iostream>
0005 #include <vector>
0006 #include <string>
0007 #include <numeric>
0008 #include <cctype> // For isdigit
0009
0010 #include <TFile.h>
0011 #include <TTree.h>
0012 #include <TH2D.h>
0013 #include <TH1D.h>
0014 #include <TMath.h>
0015 #include <TF1.h>
0016 #include <TProfile.h>
0017 #include <TCanvas.h>
0018 #include <TPad.h>
0019 #include <TGraphErrors.h>
0020 #include <TLatex.h>
0021 #include <THStack.h>
0022 #include <TCanvas.h> // note : for the combined case
0023 #include <TGraph.h> // note : for the combined case
0024
0025 #include <TKey.h>
0026 #include <TRandom.h> // note : for the offset
0027 #include <TRandom3.h> // note : for the offset
0028
0029 #include <TColor.h>
0030
0031 #include <TObjArray.h>
0032
0033 #include "../Constants.h"
0034
0035 class PreparedNdEtaClusEach{
0036 public:
0037 PreparedNdEtaClusEach(
0038 int process_id_in,
0039 int runnumber_in,
0040 std::string input_directory_in,
0041 std::string input_file_name_in,
0042 std::string output_directory_in,
0043 std::string output_file_name_suffix_in,
0044
0045 bool ApplyAlphaCorr_in,
0046 bool isTypeA_in,
0047 std::pair<double,double> cut_INTTvtxZ_in,
0048 int SelectedMbin_in
0049 );
0050
0051 std::string GetOutputFileName() {
0052 return output_filename;
0053 }
0054
0055 std::vector<std::string> GetAlphaCorrectionNameMap() {return alpha_correction_name_map;}
0056
0057 void SetAlphaCorrectionH1DMap(std::map<std::string, TH1D*> map_in) {
0058 h1D_alpha_correction_map_in = map_in;
0059
0060 for (auto &pair : h1D_alpha_correction_map_in){
0061 if (std::find(alpha_correction_name_map.begin(), alpha_correction_name_map.end(), pair.first) == alpha_correction_name_map.end()){
0062 std::cout << "Error : the alpha correction name is not found in the map" << std::endl;
0063 exit(1);
0064 }
0065
0066
0067
0068
0069
0070 }
0071 }
0072
0073 void SetSelectedEtaRange(std::pair<double, double> cut_EtaRange_in) {
0074 cut_EtaRange_pair = cut_EtaRange_in;
0075 }
0076
0077
0078 void PrepareStacks();
0079 void PreparedNdEtaHist();
0080 void DeriveAlphaCorrection();
0081 void EndRun();
0082
0083 protected:
0084
0085
0086 int process_id;
0087 int runnumber;
0088 std::string input_directory;
0089 std::string input_file_name;
0090 std::string output_directory;
0091 std::string output_file_name_suffix;
0092 bool ApplyAlphaCorr;
0093 bool isTypeA;
0094 std::pair<double,double> cut_INTTvtxZ;
0095 int SelectedMbin;
0096
0097
0098 TFile * file_in;
0099 TTree * tree_in;
0100 void PrepareInputRootFie();
0101 std::map<std::string, TH1D*> h1D_input_map;
0102 std::map<std::string, TH2D*> h2D_input_map;
0103
0104 std::vector<double> *centrality_edges;
0105 int nCentrality_bin;
0106
0107 double CentralityFineEdge_min;
0108 double CentralityFineEdge_max;
0109 int nCentralityFineBin;
0110
0111 double EtaEdge_min;
0112 double EtaEdge_max;
0113 int nEtaBin;
0114
0115 double VtxZEdge_min;
0116 double VtxZEdge_max;
0117 int nVtxZBin;
0118
0119
0120 TFile * file_out;
0121 std::string output_filename;
0122 void PrepareOutPutFileName();
0123 void PrepareOutPutRootFile();
0124
0125 TCanvas * c1;
0126
0127
0128 std::map<int, int> GetVtxZIndexMap();
0129 void PrepareHist();
0130 std::tuple<int, int, int, int, int> GetHistStringInfo(std::string hist_name);
0131 double get_EvtCount(TH2D * hist_in, int centrality_bin_in);
0132
0133 std::map<int, int> vtxZ_index_map;
0134 std::pair<double, double> cut_EtaRange_pair = {std::nan(""), std::nan("")};
0135
0136
0137 std::map<std::string, THStack*> hstack2D_NClusEtaVtxZ_map;
0138 std::map<std::string, THStack*> hstack1D_NClusEta_map;
0139 TH1D * h1D_inner_NClusEta;
0140 TH1D * h1D_inner_NClusEtaPerEvt;
0141 TH1D * h1D_inner_NClusEtaPerEvtPostAC;
0142 TH1D * h1D_outer_NClusEta;
0143 TH1D * h1D_outer_NClusEtaPerEvt;
0144 TH1D * h1D_outer_NClusEtaPerEvtPostAC;
0145
0146
0147 std::map<std::string, THStack*> hstack2D_TrueEtaVtxZ_map;
0148 std::map<std::string, THStack*> hstack1D_TrueEta_map;
0149 std::map<std::string, TH1D*> h1D_TruedNdEta_map;
0150
0151
0152 std::map<std::string, TH1D*> h1D_alpha_correction_map_in;
0153 std::map<std::string, TH1D*> h1D_alpha_correction_map_out;
0154 std::vector<std::string> alpha_correction_name_map = {
0155 "h1D_inner_alpha_correction",
0156 "h1D_outer_alpha_correction"
0157 };
0158
0159
0160 int Semi_inclusive_Mbin = Constants::Semi_inclusive_bin;
0161
0162 const std::vector<int> ROOT_color_code = {
0163 51, 61, 70, 79, 88, 98
0164 };
0165 };
0166
0167 #endif