File indexing completed on 2024-04-06 12:24:03
0001
0002 static const char *directory = "analyzeTracks";
0003
0004
0005 static const char *qualities[] = {
0006 "loose", "tight", "highPurity",
0007
0008 0
0009 };
0010
0011 static const char *plots[] = {
0012 "pt", "ptErr", "eta",
0013 "invPt", "invPtErr", "phi",
0014 "d0", "d0Err", "nHits",
0015 0
0016 };
0017
0018 static const char *components[] = {
0019 "pxb", "pxe",
0020 "tib", "tid", "tob", "tec",
0021 0
0022 };
0023
0024 void patTracks_showPlots()
0025 {
0026
0027 setNiceStyle();
0028 gStyle->SetOptStat(0);
0029
0030
0031 TFile* file = new TFile("analyzePatTracks.root");
0032
0033
0034 TCanvas* canv0 = new TCanvas("canv0", "track variables", 800, 600);
0035 canv0->Divide(3, 3);
0036
0037 unsigned int i = 1;
0038 for(const char **plot = plots; *plot; plot++, i++) {
0039 canv0->cd(i);
0040 unsigned int j = 0;
0041
0042 TLegend *l = new TLegend(0.6, 0.6, 0.85, 0.85);
0043
0044 for(const char **quality = qualities; *quality; quality++, j++) {
0045 TH1 *h = file->Get(Form("%s/%s_%s", directory, *plot, *quality));
0046 TString title = h->GetTitle();
0047 title.Resize(title.Length() - (strlen(*quality) + 3));
0048 h->SetTitle(title);
0049 setHistStyle(h);
0050 h->SetLineColor(j + 2);
0051 h->SetMarkerColor(j + 2);
0052 h->Draw(j ? "same" : "");
0053 l->AddEntry(h, *quality);
0054 }
0055
0056 l->Draw();
0057 }
0058
0059
0060 TCanvas* canv1 = new TCanvas("canv1", "tracking components", 800, 600);
0061
0062 THStack *hs = new THStack("components", "average #hits in tracking components");
0063 TLegend *l = new TLegend(0.12, 0.15, 0.45, 0.35);
0064 const char *quality = qualities[0];
0065 unsigned int i = 0;
0066 for(const char **component = components; *component; component++, i++) {
0067 TProfile *p = file->Get(Form("%s/%sHitsEta_%s", directory, *component, quality));
0068 TString title = p->GetTitle();
0069 title.Resize(title.Length() - (strlen(quality) + 3));
0070 setHistStyle(p);
0071 TH1 *h = new TH1F(*component, title, p->GetNbinsX(), p->GetXaxis()->GetXmin(), p->GetXaxis()->GetXmax());
0072 for(unsigned int j = 1; j <= p->GetNbinsX(); j++)
0073 h->SetBinContent(j, p->GetBinContent(j));
0074 h->SetLineColor(kBlack);
0075 h->SetMarkerColor(kBlack);
0076 h->SetFillColor(i + 2);
0077 hs->Add(h);
0078 l->AddEntry(h);
0079 }
0080 hs->Draw();
0081 l->Draw();
0082 }
0083
0084 void setAxisStyle(TH1 *hist) {
0085
0086
0087
0088 hist->GetXaxis()->SetTitleSize( 0.06);
0089 hist->GetXaxis()->SetTitleColor( 1);
0090 hist->GetXaxis()->SetTitleOffset( 0.8);
0091 hist->GetXaxis()->SetTitleFont( 62);
0092 hist->GetXaxis()->SetLabelSize( 0.05);
0093 hist->GetXaxis()->SetLabelFont( 62);
0094 hist->GetXaxis()->CenterTitle();
0095 hist->GetXaxis()->SetNdivisions( 505);
0096
0097 hist->GetYaxis()->SetTitleSize( 0.07);
0098 hist->GetYaxis()->SetTitleColor( 1);
0099 hist->GetYaxis()->SetTitleOffset( 0.5);
0100 hist->GetYaxis()->SetTitleFont( 62);
0101 hist->GetYaxis()->SetLabelSize( 0.05);
0102 hist->GetYaxis()->SetLabelFont( 62);
0103 }
0104
0105 void setHistStyle(TH1 *hist)
0106 {
0107
0108
0109
0110 setAxisStyle(hist);
0111 hist->GetXaxis()->SetTitle(hist->GetTitle());
0112 hist->SetTitle();
0113 hist->SetLineColor(4.);
0114 hist->SetLineWidth(2.);
0115 hist->SetMarkerSize(0.75);
0116 hist->SetMarkerColor(4.);
0117 hist->SetMarkerStyle(20.);
0118 }
0119
0120 void setNiceStyle()
0121 {
0122 gROOT->SetStyle("Plain");
0123
0124
0125
0126
0127 TStyle *MyStyle = new TStyle ("MyStyle", "My style for nicer plots");
0128
0129 Float_t xoff = MyStyle->GetLabelOffset("X"),
0130 yoff = MyStyle->GetLabelOffset("Y"),
0131 zoff = MyStyle->GetLabelOffset("Z");
0132
0133 MyStyle->SetCanvasBorderMode ( 0 );
0134 MyStyle->SetPadBorderMode ( 0 );
0135 MyStyle->SetPadColor ( 0 );
0136 MyStyle->SetCanvasColor ( 0 );
0137 MyStyle->SetTitleColor ( 0 );
0138 MyStyle->SetStatColor ( 0 );
0139 MyStyle->SetTitleBorderSize ( 0 );
0140 MyStyle->SetTitleFillColor ( 0 );
0141 MyStyle->SetTitleH ( 0.07 );
0142 MyStyle->SetTitleW ( 1.00 );
0143 MyStyle->SetTitleFont ( 132 );
0144
0145 MyStyle->SetLabelOffset (1.5*xoff, "X");
0146 MyStyle->SetLabelOffset (1.5*yoff, "Y");
0147 MyStyle->SetLabelOffset (1.5*zoff, "Z");
0148
0149 MyStyle->SetTitleOffset (0.9, "X");
0150 MyStyle->SetTitleOffset (0.9, "Y");
0151 MyStyle->SetTitleOffset (0.9, "Z");
0152
0153 MyStyle->SetTitleSize (0.045, "X");
0154 MyStyle->SetTitleSize (0.045, "Y");
0155 MyStyle->SetTitleSize (0.045, "Z");
0156
0157 MyStyle->SetLabelFont (132, "X");
0158 MyStyle->SetLabelFont (132, "Y");
0159 MyStyle->SetLabelFont (132, "Z");
0160
0161 MyStyle->SetPalette(1);
0162
0163 MyStyle->cd();
0164 }