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