File indexing completed on 2025-08-06 08:12:21
0001 #include <iostream>
0002 #include "../../sPhenixStyle.C"
0003
0004 #include "MegaTrackRatio.h"
0005
0006 MegaTrackRatio::MegaTrackRatio()
0007 {
0008 return;
0009 }
0010
0011 MegaTrackRatio::MegaTrackRatio(string run_type, string input1_directory, string input1_name, string tree1_name, string input2_directory, string input2_name, string tree2_name)
0012 : run_type(run_type),
0013 input1_directory(input1_directory),
0014 input1_name(input1_name),
0015 tree1_name(tree1_name),
0016 input2_directory(input2_directory),
0017 input2_name(input2_name),
0018 tree2_name(tree2_name)
0019 {
0020 plot_text = (run_type == "MC") ? "Simulation" : "Work-in-progress";
0021 Init();
0022 return;
0023 }
0024
0025 void MegaTrackRatio::Init()
0026 {
0027
0028
0029 SetsPhenixStyle();
0030
0031 file_in1 = TFile::Open(Form("%s/%s",input1_directory.c_str(), input1_name.c_str()));
0032 tree_in1 = (TTree *)file_in1->Get(tree1_name.c_str());
0033 readEta1 = new ReadEta_v1(tree_in1);
0034 std::cout<<"tree1 entry : "<<tree_in1 -> GetEntries()<<std::endl;
0035
0036 file_in2 = TFile::Open(Form("%s/%s",input2_directory.c_str(), input2_name.c_str()));
0037 tree_in2 = (TTree *)file_in2->Get(tree2_name.c_str());
0038 readEta2 = new ReadEta_v1(tree_in2);
0039 std::cout<<"tree2 entry : "<<tree_in2 -> GetEntries()<<std::endl;
0040
0041 if (tree_in1 -> GetEntries() != tree_in2 -> GetEntries())
0042 {
0043 std::cout<<"Error : tree1 and tree2 have different entries"<<std::endl;
0044 return;
0045 }
0046 InitCanvas();
0047 InitHist();
0048 InitRest();
0049
0050 }
0051
0052 void MegaTrackRatio::InitCanvas()
0053 {
0054 c1 = new TCanvas("","",950,800);
0055 c1 -> cd();
0056 }
0057
0058
0059 void MegaTrackRatio::InitHist()
0060 {
0061 MegaTrackRatio_Mbin_2D = new TH2F("","MegaTrackRatio_Mbin_2D", 10, 0, 10, 100,95,105);
0062 MegaTrackRatio_Mbin_2D -> GetXaxis() -> SetTitle("Centrality bin");
0063 MegaTrackRatio_Mbin_2D -> GetYaxis() -> SetTitle("Ratio [%]");
0064 MegaTrackRatio_Mbin_2D -> GetXaxis() -> SetNdivisions(505);
0065
0066 MegaTtrackRatio_NMegaTrack_2D = new TH2F("","MegaTtrackRatio_NMegaTrack_2D", 40, 0, 40, 100,95,105);
0067 MegaTtrackRatio_NMegaTrack_2D -> GetXaxis() -> SetTitle("N Mega Track");
0068 MegaTtrackRatio_NMegaTrack_2D -> GetYaxis() -> SetTitle("Ratio [%]");
0069 MegaTtrackRatio_NMegaTrack_2D -> GetXaxis() -> SetNdivisions(505);
0070 }
0071
0072 void MegaTrackRatio::InitRest()
0073 {
0074 ltx = new TLatex();
0075 ltx->SetNDC();
0076 ltx->SetTextSize(0.045);
0077 ltx->SetTextAlign(31);
0078 }
0079
0080
0081 void MegaTrackRatio::ProcessEvent()
0082 {
0083 double N_track_file1;
0084 double N_track_file2;
0085 double file1_Mbin;
0086 double file2_Mbin;
0087
0088 std::cout<<"test : "<<tree_in1 -> GetEntries()<<std::endl;
0089
0090 for (int i = 0; i < tree_in1 -> GetEntries(); i++)
0091 {
0092 readEta1 -> LoadTree(i);
0093 readEta1 -> GetEntry(i);
0094 if ((readEta1 -> N3Clu_track + readEta1 -> N4Clu_track) == 0) {continue;}
0095
0096 N_track_file1 = readEta1 -> N2Clu_track + readEta1 -> N3Clu_track + readEta1 -> N4Clu_track;
0097 file1_Mbin = readEta1 -> Evt_centrality_bin;
0098
0099 readEta2 -> LoadTree(i);
0100 readEta2 -> GetEntry(i);
0101 N_track_file2 = readEta2 -> N2Clu_track + readEta2 -> N3Clu_track + readEta2 -> N4Clu_track;
0102 file2_Mbin = readEta2 -> Evt_centrality_bin;
0103
0104 if (file1_Mbin != file2_Mbin)
0105 {
0106 std::cout<<"Error : file1_Mbin != file2_Mbin"<<std::endl;
0107 return;
0108 }
0109
0110 MegaTrackRatio_Mbin_2D -> Fill(centrality_map[file1_Mbin], (N_track_file1/N_track_file2) * 100.);
0111 MegaTtrackRatio_NMegaTrack_2D -> Fill(readEta1 -> N3Clu_track + readEta1 -> N4Clu_track, (N_track_file1/N_track_file2) * 100.);
0112 }
0113
0114 return;
0115 }
0116
0117 void MegaTrackRatio::PrintPlot()
0118 {
0119 c1 -> cd();
0120 MegaTrackRatio_Mbin_2D -> Draw("colz0");
0121 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX INTT}} %s", plot_text.c_str()));
0122 c1 -> Print(Form("%s/MegaTrackRatio_Mbin_2D.pdf",input1_directory.c_str()));
0123 c1 -> Clear();
0124
0125 c1 -> cd();
0126 MegaTtrackRatio_NMegaTrack_2D -> Draw("colz0");
0127 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX INTT}} %s", plot_text.c_str()));
0128 c1 -> Print(Form("%s/MegaTtrackRatio_NMegaTrack_2D.pdf",input1_directory.c_str()));
0129 c1 -> Clear();
0130
0131 return;
0132 }