Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef TRACKLETHISTOGRAMFILL_H
0002 #define TRACKLETHISTOGRAMFILL_H
0003 
0004 #include <iostream>
0005 #include <vector>
0006 #include <string>
0007 #include <numeric>
0008 
0009 #include <TFile.h>
0010 #include <TTree.h>
0011 #include <TH2D.h>
0012 #include <TH1D.h>
0013 #include <TMath.h>
0014 
0015 #include <TObjArray.h>
0016 
0017 #include "../EvtVtxZTracklet/structure.h"
0018 #include "../Constants.h"
0019 
0020 class TrackletHistogramFill{
0021     
0022     public:
0023         TrackletHistogramFill(
0024             int process_id_in,
0025             int runnumber_in,
0026 
0027             std::string output_directory_in,
0028             std::string output_file_name_suffix_in
0029         );
0030 
0031         void SetvtxZReweight(bool tag){ vtxZReweight = tag; }
0032         void SetBcoFullDiffCut(bool tag){ BcoFullDiffCut = tag; }
0033         void SetINTT_vtxZ_QA(bool tag){ INTT_vtxZ_QA = tag; }
0034         void SetWithRotate(bool tag){ isWithRotate = tag; }
0035         void SetClusQA(std::pair<bool, std::pair<double, double>> pair_in) {isClusQA = pair_in;} // note : {adc, phi size}
0036 
0037         void SetVtxZReweightHist(TH1D * input_hist) {h1D_vtxZReweightFactor = (TH1D*)input_hist->Clone();}
0038 
0039         virtual void PrepareOutPutFileName();
0040         std::string GetOutputFileName() {return output_filename;}
0041         virtual void PrepareOutPutRootFile();
0042         virtual void PrepareHistograms();
0043         void FillHistogram(
0044             // note : MBD & centrality relevant
0045             float MBD_z_vtx,
0046             int is_min_bias,
0047             float MBD_centrality,
0048             float MBD_south_charge_sum,
0049             float MBD_north_charge_sum,
0050             // float MBD_charge_sum,
0051             // float MBD_charge_asymm,
0052             int InttBcoFullDiff_next,
0053 
0054             // // note : trigger tag
0055             int MBDNSg2,
0056             // int MBDNSg2_vtxZ10cm,
0057             // int MBDNSg2_vtxZ30cm,
0058             // int MBDNSg2_vtxZ60cm,
0059 
0060             // std::vector<float> *ClusX,
0061             // std::vector<float> *ClusY,
0062             // std::vector<float> *ClusZ,
0063             // std::vector<int> *ClusLayer,
0064             std::vector<unsigned char> *ClusLadderZId,
0065             // std::vector<unsigned char> *ClusLadderPhiId,
0066             std::vector<int> *ClusAdc,
0067             std::vector<float> *ClusPhiSize,
0068 
0069             // note : INTT vertex Z
0070             double INTTvtxZ,
0071             double INTTvtxZError,
0072             // double NgroupTrapezoidal,
0073             // double NgroupCoarse,
0074             double TrapezoidalFitWidth,
0075             double TrapezoidalFWHM,
0076 
0077             // note : the tracklet pair
0078             std::vector<pair_str> *evt_TrackletPair_vec,
0079             std::vector<pair_str> *evt_TrackletPairRotate_vec,
0080 
0081             // note : MC
0082             // float TruthPV_trig_x,
0083             // float TruthPV_trig_y,
0084             float TruthPV_trig_z,
0085             int NTruthVtx,
0086             int NPrimaryG4P,
0087             // std::vector<float> *PrimaryG4P_Pt,
0088             std::vector<float> *PrimaryG4P_Eta,
0089             // std::vector<float> *PrimaryG4P_Phi,
0090             // std::vector<float> *PrimaryG4P_E,
0091             // std::vector<float> *PrimaryG4P_PID,
0092             std::vector<int> *PrimaryG4P_isChargeHadron
0093         );
0094         void EndRun();
0095 
0096     protected:
0097 
0098         // note : ----------------- for the constructor -----------------
0099         int process_id;
0100         int runnumber;
0101         std::string output_directory;
0102         std::string output_file_name_suffix;
0103 
0104         bool vtxZReweight;
0105         bool BcoFullDiffCut;
0106         bool INTT_vtxZ_QA;
0107         bool isWithRotate;
0108         std::pair<bool, std::pair<double, double>> isClusQA;
0109 
0110         // note : ----------------- for the root file out -----------------
0111         TFile * file_out;
0112         TTree * tree_out_par;
0113         std::string output_filename;
0114 
0115         // note : ----------------- for the loop -----------------
0116         void EvtCleanUp();
0117         std::map<int,int> Used_Clus_index_map;
0118         std::vector<double> Pair_DeltaPhi_vec;
0119 
0120 
0121         // note : ----------------- for the histogram -----------------
0122         std::map<std::string,TH1D*> h1D_map;
0123         std::map<std::string, TH2D*> h2D_map;
0124         
0125         TH1D * h1D_PairDeltaEta_inclusive;
0126         TH1D * h1D_PairDeltaPhi_inclusive;
0127 
0128         // note : ----------------- for the centrality -----------------
0129         TH1D * h1D_centrality_bin;
0130         // int convert_centrality_bin (double centrality_in);
0131         
0132 
0133         // note : ----------------- for the reweights -----------------
0134         TH1D * h1D_vtxZReweightFactor = nullptr;
0135         double vtxZReweightFactor;
0136 
0137         // note : ----------------- constants -----------------
0138 
0139         // note : for centrality fine
0140         double CentralityFineEdge_min = -0.005;
0141         double CentralityFineEdge_max = 1.005;
0142         int nCentralityFineBin = 101;
0143         
0144         // note : for eta (tracklet)
0145         double EtaEdge_min = -2.7;
0146         double EtaEdge_max = 2.7;
0147         int nEtaBin = 27;
0148         TH1D * h1D_eta_template;
0149 
0150         // note : for z
0151         double VtxZEdge_min = -45; // note : cm
0152         double VtxZEdge_max = 45; // note : cm
0153         int nVtxZBin = 18;
0154         TH1D * h1D_vtxz_template;
0155 
0156         // note : for deta_phi
0157         double DeltaPhiEdge_min = -0.07; // note : rad ~ -4 degree
0158         double DeltaPhiEdge_max = 0.07;  // note : rad ~ 4 degree
0159         int    nDeltaPhiBin = 140;
0160 
0161         // note : for deta_eta
0162         double DeltaEtaEdge_min = -1.; // note : rad ~ -4 degree
0163         double DeltaEtaEdge_max = 1.;  // note : rad ~ 4 degree
0164         int    nDeltaEtaBin = 100;
0165 
0166         std::vector<int> typeA_sensorZID = {0,2}; // note : sensor Z ID for type A // note -> 1, 0, 2, 3        
0167 
0168         std::pair<double, double> cut_GlobalMBDvtxZ    = Constants::cut_GlobalMBDvtxZ;
0169         std::pair<double, double> cut_vtxZDiff = Constants::cut_vtxZDiff;
0170         std::pair<double, double> cut_TrapezoidalFitWidth = Constants::cut_TrapezoidalFitWidth;
0171         std::pair<double, double> cut_TrapezoidalFWHM = Constants::cut_TrapezoidalFWHM;
0172         std::pair<double, double> cut_INTTvtxZError = Constants::cut_INTTvtxZError;
0173 
0174         int cut_InttBcoFullDIff_next = Constants::cut_InttBcoFullDIff_next;
0175 
0176         std::vector<double> centrality_edges = Constants::centrality_edges;
0177         int nCentrality_bin;
0178 
0179         // note : for the best pair
0180         std::pair<double, double> cut_bestPair_DeltaPhi = {0,0.017}; // note : rad
0181         std::pair<double, double> cut_GoodProtoTracklet_DeltaPhi = {-0.017,0.017}; // note : rad
0182 };
0183 
0184 #endif // TRACKLETHISTOGRAMFILL_H