File indexing completed on 2023-03-17 11:16:32
0001
0002 static const char *directory = "analyzeBJetTracks";
0003
0004 static const char *plots[] = {
0005 "allIP", "allIPErr", "allIPSig",
0006 "trackIP", "trackIPErr", "trackIPSig",
0007 "negativeIP", "negativeIPErr", "negativeIPSig",
0008 "allDeltaR", "nTracks",
0009 0
0010 };
0011
0012 static const char *flavours[] = { "b", "c", "udsg", 0 };
0013
0014 void patBJetTracks_showPlots()
0015 {
0016
0017 setNiceStyle();
0018 gStyle->SetOptStat(0);
0019
0020
0021 TFile* file = new TFile("analyzePatBJetTracks.root");
0022
0023
0024 unsigned int i = 3;
0025 unsigned int j = 0;
0026 TCanvas *canv;
0027 for(const char **plot = plots; *plot; plot++) {
0028 if (i >= 3) {
0029 canv = new TCanvas(Form("canv%d", j++), "track counting variables", 800, 400);
0030 canv->Divide(3, 2);
0031 i -= 3;
0032 }
0033
0034 canv->cd(i + 1);
0035 if (TString(*plot).Contains("IP"))
0036 gPad->SetLogy(1);
0037 TH1 *h = (TH1*)file->Get(Form("%s/%s_all", directory, *plot));
0038 TString title = h->GetTitle();
0039 if (TString(*plot).Contains("IP") || TString(*plot).Contains("nTrack"))
0040 title.Resize(title.Index(" in "));
0041 else if (TString(*plot).Contains("DeltaR")) {
0042 title.Resize(title.Index(" and "));
0043 title += " and jet";
0044 }
0045 h->SetTitle(title);
0046 setHistStyle(h);
0047 h->Draw();
0048 TLegend *l = new TLegend(0.6, 0.75, 0.85, 0.85);
0049 l->AddEntry(h, "all");
0050 l->Draw();
0051
0052 canv->cd(i + 4);
0053 unsigned int k = 1;
0054 if (TString(*plot).Contains("IP"))
0055 gPad->SetLogy(1);
0056 l = new TLegend(0.5, 0.6, 0.85, 0.85);
0057 for(const char **flavour = flavours; *flavour; flavour++) {
0058 h = (TH1*)file->Get(Form("%s/%s_%s", directory, *plot, *flavour));
0059 title = h->GetTitle();
0060 if (TString(*plot).Contains("IP") || TString(*plot).Contains("nTrack"))
0061 title.Resize(title.Index(" in "));
0062 else if (TString(*plot).Contains("DeltaR")) {
0063 title.Resize(title.Index(" and "));
0064 title += " and jet";
0065 }
0066 h->SetTitle(title);
0067 setHistStyle(h);
0068 h->SetMarkerColor(k);
0069 h->SetLineColor(k++);
0070 h->DrawNormalized(k > 1 ? "same" : "");
0071 l->AddEntry(h, *flavour);
0072 }
0073 l->Draw();
0074 i++;
0075 }
0076
0077 canv->cd(3);
0078 TH1 *h = (TH1*)file->Get(Form("%s/flavours", directory));
0079 setHistStyle(h);
0080 h->Draw();
0081 }
0082
0083 void setAxisStyle(TH1 *hist) {
0084
0085
0086
0087 hist->GetXaxis()->SetTitleSize( 0.06);
0088 hist->GetXaxis()->SetTitleColor( 1);
0089 hist->GetXaxis()->SetTitleOffset( 0.8);
0090 hist->GetXaxis()->SetTitleFont( 62);
0091 hist->GetXaxis()->SetLabelSize( 0.05);
0092 hist->GetXaxis()->SetLabelFont( 62);
0093 hist->GetXaxis()->CenterTitle();
0094 hist->GetXaxis()->SetNdivisions( 505);
0095
0096 hist->GetYaxis()->SetTitleSize( 0.07);
0097 hist->GetYaxis()->SetTitleColor( 1);
0098 hist->GetYaxis()->SetTitleOffset( 0.5);
0099 hist->GetYaxis()->SetTitleFont( 62);
0100 hist->GetYaxis()->SetLabelSize( 0.05);
0101 hist->GetYaxis()->SetLabelFont( 62);
0102 }
0103
0104 void setHistStyle(TH1 *hist)
0105 {
0106
0107
0108
0109 setAxisStyle(hist);
0110 hist->GetXaxis()->SetTitle(hist->GetTitle());
0111 hist->SetTitle();
0112 hist->SetLineColor(4.);
0113 hist->SetLineWidth(2.);
0114 hist->SetMarkerSize(0.75);
0115 hist->SetMarkerColor(4.);
0116 hist->SetMarkerStyle(20.);
0117 }
0118
0119 void setNiceStyle()
0120 {
0121 gROOT->SetStyle("Plain");
0122
0123
0124
0125
0126 TStyle *MyStyle = new TStyle ("MyStyle", "My style for nicer plots");
0127
0128 Float_t xoff = MyStyle->GetLabelOffset("X"),
0129 yoff = MyStyle->GetLabelOffset("Y"),
0130 zoff = MyStyle->GetLabelOffset("Z");
0131
0132 MyStyle->SetCanvasBorderMode ( 0 );
0133 MyStyle->SetPadBorderMode ( 0 );
0134 MyStyle->SetPadColor ( 0 );
0135 MyStyle->SetCanvasColor ( 0 );
0136 MyStyle->SetTitleColor ( 0 );
0137 MyStyle->SetStatColor ( 0 );
0138 MyStyle->SetTitleBorderSize ( 0 );
0139 MyStyle->SetTitleFillColor ( 0 );
0140 MyStyle->SetTitleH ( 0.07 );
0141 MyStyle->SetTitleW ( 1.00 );
0142 MyStyle->SetTitleFont ( 132 );
0143
0144 MyStyle->SetLabelOffset (1.5*xoff, "X");
0145 MyStyle->SetLabelOffset (1.5*yoff, "Y");
0146 MyStyle->SetLabelOffset (1.5*zoff, "Z");
0147
0148 MyStyle->SetTitleOffset (0.9, "X");
0149 MyStyle->SetTitleOffset (0.9, "Y");
0150 MyStyle->SetTitleOffset (0.9, "Z");
0151
0152 MyStyle->SetTitleSize (0.045, "X");
0153 MyStyle->SetTitleSize (0.045, "Y");
0154 MyStyle->SetTitleSize (0.045, "Z");
0155
0156 MyStyle->SetLabelFont (132, "X");
0157 MyStyle->SetLabelFont (132, "Y");
0158 MyStyle->SetLabelFont (132, "Z");
0159
0160 MyStyle->SetPalette(1);
0161
0162 MyStyle->cd();
0163 }