File indexing completed on 2024-04-06 11:59:56
0001 #include <TH2F.h>
0002
0003 void ResolutionPlots_HistoMaker(const std::string& unit) {
0004 int n = 20;
0005
0006 float numbers[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0,
0007 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0};
0008
0009 std::string YAxisTitle;
0010 std::string HistoTitle;
0011 std::string OutputFile;
0012 std::string RootFile;
0013
0014 float UL[20] = {0};
0015 float NonUL[20] = {0};
0016
0017 if (unit == "centimetres") {
0018 float UL_Array[] = {0.00137706, 0.00142804, 0.00223064, 0.00313546, 0.00528442, 0.00328381, 0.00365521,
0019 0.00362465, 0.00404834, 0.00304523, 0.00154502, 0.00103244, 0.0108947, 0,
0020 0.0030021, 0.00229157, 0.00244635, 0.00576464, 0.00461518, 0.00464276};
0021
0022 float NonUL_Array[] = {0.00211815, 0.00243601, 0.002224, 0.00223777, 0.00284721, 0.00306343, 0.00310523,
0023 0.00334504, 0.00333095, 0.00326225, 0.00331065, 0.00237821, 0.00233033, 0,
0024 0.00285122, 0.00287095, 0.00226949, 0.0030951, 0.00284769, 0.00285031};
0025
0026 for (int i = 0; i < 20; i++) {
0027 UL[i] = UL_Array[i];
0028 NonUL[i] = NonUL_Array[i];
0029 }
0030
0031 YAxisTitle = "Resolution [cm]";
0032 HistoTitle = "Resolution values for UL and non-UL samples, in centimetres";
0033 OutputFile = "ResolutionComparison_ULAndNonUL_Centimetres.pdf";
0034 RootFile = "ResolutionComparison_ULAndNonUL_Centimetres.root";
0035
0036 } else if (unit == "pitch units") {
0037 float UL_Array[] = {0.172131, 0.143091, 0.161787, 0.126722, 0.17909, 0.197285, 0.180396,
0038 0.170818, 0.182258, 0.166405, 0.0844271, 0.0846207, 0.0400775, 0,
0039 0.120119, 0.171899, 0.160656, 0.18299, 0.177929, 0.178037};
0040
0041 float NonUL_Array[] = {0.153758, 0.151801, 0.14859, 0.148245, 0.147986, 0.146962, 0.147919,
0042 0.147431, 0.146219, 0.145619, 0.14549, 0.147042, 0.147267, 0,
0043 0.146873, 0.153169, 0.151639, 0.146694, 0.148681, 0.148683};
0044
0045 for (int i = 0; i < 20; i++) {
0046 UL[i] = UL_Array[i];
0047 NonUL[i] = NonUL_Array[i];
0048 }
0049
0050 YAxisTitle = "Resolution [pitch units]";
0051 HistoTitle = "Resolution values for the UL and non-UL samples in pitch units";
0052 OutputFile = "ResolutionComparison_ULAndNonUL_PitchUnits.pdf";
0053 RootFile = "ResolutionComparison_ULAndNonUL_PitchUnits.root";
0054
0055 } else {
0056 std::cout << "ERROR: Unit must be centimetres or pitch units" << std::endl;
0057 }
0058
0059 auto c1 = new TCanvas("c1", "c1", 800, 600);
0060
0061 TGraph* gr1 = new TGraph(n, numbers, UL);
0062 gr1->SetName("UL samples");
0063 gr1->SetTitle("UL samples");
0064 gr1->SetMarkerStyle(21);
0065 gr1->SetDrawOption("AP");
0066 gr1->SetLineColor(0);
0067 gr1->SetLineWidth(4);
0068 gr1->SetFillStyle(0);
0069
0070 TGraph* gr2 = new TGraph(n, numbers, NonUL);
0071 gr2->SetName("Non-UL samples");
0072 gr2->SetTitle("Non-UL samples");
0073 gr2->SetMarkerStyle(22);
0074 gr2->SetMarkerColor(2);
0075 gr2->SetDrawOption("P");
0076 gr2->SetLineColor(0);
0077 gr2->SetLineWidth(0);
0078 gr2->SetFillStyle(0);
0079
0080 TMultiGraph* mg = new TMultiGraph();
0081 mg->Add(gr1);
0082 mg->Add(gr2);
0083 mg->GetHistogram()->SetTitle(HistoTitle.c_str());
0084 mg->GetHistogram()->SetTitleOffset(0.05);
0085 mg->GetHistogram()->GetXaxis()->SetTitle("Region");
0086 mg->GetHistogram()->GetXaxis()->SetTitleOffset(2.5);
0087 c1->SetBottomMargin(0.2);
0088
0089 mg->GetHistogram()->GetXaxis()->SetBinLabel(1.0, "TIB L1");
0090 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(2.0), "TIB L2");
0091 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(3.0), "TIB L3");
0092 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(4.0), "TIB L4");
0093 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(5.0), "Side TID");
0094 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(6.0), "Wheel TID");
0095 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(7.0), "Ring TID");
0096 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(8.0), "TOB L1");
0097 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(9.0), "TOB L2");
0098 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(10.0), "TOB L3");
0099 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(11.0), "TOB L4");
0100 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(12.0), "TOB L5");
0101 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(13.0), "TOB L6");
0102 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(14.0), "Side TEC");
0103 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(15.0), "Wheel TEC");
0104 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(16.0), "Ring TEC");
0105 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(17.0), "TIB (All)");
0106 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(18.0), "TOB (All)");
0107 mg->GetHistogram()->GetXaxis()->SetBinLabel(mg->GetHistogram()->GetXaxis()->FindBin(19.0), "TID (All)");
0108 mg->GetHistogram()->GetXaxis()->SetBinLabel(100, "TEC (All)");
0109
0110 mg->GetHistogram()->GetYaxis()->SetTitle(YAxisTitle.c_str());
0111 mg->Draw("ALP");
0112 c1->BuildLegend();
0113 mg->SaveAs(OutputFile.c_str());
0114
0115 TFile* output = new TFile(RootFile.c_str(), "RECREATE");
0116 output->cd();
0117 mg->Write();
0118 output->Close();
0119 }
0120
0121 void ResolutionPlots() {
0122 ResolutionPlots_HistoMaker("centimetres");
0123 ResolutionPlots_HistoMaker("pitch units");
0124 }