00001
00002
00003
00004
00005 #ifndef __CINT__
00006 # include <TFile.h>
00007 # include <TCanvas.h>
00008 # include <TPad.h>
00009 # include <TH1D.h>
00010 # include <TString.h>
00011 # include <TLatex.h>
00012 # include <TLegend.h>
00013 # include <THStack.h>
00014 # include <TStyle.h>
00015 # include <iostream>
00016 using namespace std;
00017 #endif
00018
00021
00025 Float_t
00026 deg2eta(Float_t ang)
00027 {
00028 if (ang == 180) ang -= .001;
00029 if (ang == 0) ang += .001;
00030 Float_t theta = ang * TMath::Pi() / 180;
00031 Float_t eta = - TMath::Log(TMath::Tan(theta / 2));
00032 return eta;
00033 }
00034
00035
00036
00042 TH1*
00043 getHisto(const Char_t* which, const Char_t* what, TH1* back=0)
00044 {
00045 TFile* file = TFile::Open(Form("Lego_%s.root", which), "READ");
00046 if (!file) {
00047 cerr << "Couldn't open the file 'Lego_" << which << ".root"
00048 << endl;
00049 return 0;
00050 }
00051 TH1D* h1d = static_cast<TH1D*>(file->Get(Form("h%s_py", what)));
00052 if (!h1d) {
00053 cerr << "Couldn't find h" << what << "_py in "
00054 << "Lego_" << which << ".root" << endl;
00055 return 0;
00056 }
00057
00058 TAxis* xaxis = h1d->GetXaxis();
00059 Int_t n = xaxis->GetNbins();
00060 TArrayF bins(n-1);
00061 for (Int_t i = n-1; i > 1; i--) {
00062 Float_t ang = xaxis->GetBinUpEdge(i);
00063 Float_t eta = deg2eta(ang);
00064 bins[n-i-1] = deg2eta(xaxis->GetBinUpEdge(i));
00065 }
00066 bins[n-2] = deg2eta(xaxis->GetBinLowEdge(2));
00067
00068 TH1F* heta = new TH1F(Form("%s_eta", what), h1d->GetTitle(),
00069 n-2, bins.fArray);
00070 heta->SetXTitle("#eta");
00071 heta->GetXaxis()->SetTitleSize(0);
00072 heta->GetXaxis()->SetTitleOffset(1.5);
00073 heta->GetXaxis()->SetTitleFont(132);
00074 heta->GetXaxis()->SetLabelFont(132);
00075 heta->SetYTitle(Form("%s per degree", h1d->GetTitle()));
00076 heta->GetYaxis()->SetTitleOffset(1.5);
00077 heta->GetYaxis()->SetTitleFont(132);
00078 heta->GetYaxis()->SetLabelFont(132);
00079 heta->GetYaxis()->SetTitleSize(0);
00080 heta->GetZaxis()->SetTitle(heta->GetTitle());
00081 heta->GetZaxis()->SetTitleOffset(1.5);
00082 heta->GetZaxis()->SetTitleFont(132);
00083 heta->GetZaxis()->SetLabelFont(132);
00084 heta->GetYaxis()->SetTitleOffset(1.5);
00085 for (Int_t i = 2; i < n; i++) {
00086 Float_t ang = xaxis->GetBinUpEdge(i);
00087 Float_t eta = deg2eta(ang);
00088 Float_t y = h1d->GetBinContent(i);
00089 Float_t j = heta->FindBin(eta);
00090 if (back) {
00091 Float_t b = back->GetBinContent(j);
00092 if (y - b <= 0) y = .000001;
00093 else y = y - b;
00094 }
00095
00096 heta->SetBinContent(j, y);
00097 }
00098 return heta;
00099 }
00100
00101
00105 void
00106 drawLego(const char* what="abso")
00107 {
00108 gStyle->SetOptTitle(0);
00109 gStyle->SetOptStat(0);
00110 gStyle->SetPadLeftMargin(0.15);
00111 gStyle->SetPadRightMargin(0.05);
00112 gStyle->SetPadTopMargin(0.05);
00113 gStyle->SetPadBottomMargin(0.15);
00114 gStyle->SetLabelFont(132, "xyz");
00115 gStyle->SetTitleFont(132, "xyz");
00116 gStyle->SetTitleOffset(1.5, "y");
00117
00118 TH1* nothing = getHisto("Nothing", what);
00119 TH1* its = getHisto("ITS", what, nothing);
00120 TH1* fmd = getHisto("FMD", what, nothing);
00121 TH1* pipe = getHisto("PIPE", what, nothing);
00122 TH1* inner = getHisto("Inner", what);
00123
00124 if (!inner || !pipe || !fmd || !its || !nothing) {
00125 cerr << "Failed to get a histogram!" << endl;
00126 return;
00127 }
00128 TCanvas* c = new TCanvas(Form("single_%s", what),
00129 Form("Single %s", what), 800, 800);
00130 c->SetFillColor(0);
00131 c->SetBorderMode(0);
00132 c->SetBorderSize(0);
00133 TPad* p1 = new TPad("p1", "p1", 0.0, 0.5, 0.5, 1.0, 0, 0, 0);
00134 TPad* p2 = new TPad("p2", "p2", 0.5, 0.5, 1.0, 1.0, 0, 0, 0);
00135 TPad* p3 = new TPad("p3", "p3", 0.0, 0.0, 0.5, 0.5, 0, 0, 0);
00136 TPad* p4 = new TPad("p4", "p4", 0.5, 0.0, 1.0, 0.5, 0, 0, 0);
00137
00138 TLatex* latex = new TLatex(0,0,"");
00139 latex->SetTextFont(132);
00140
00141 float logmax = inner->GetMaximum();
00142 float logmin = .001 * logmax;
00143 float latexy = 6 * logmin;
00144
00145 c->cd();
00146 p1->SetLogy();
00147 p1->SetGridy();
00148 p1->SetTopMargin(0.15);
00149 p1->SetBottomMargin(0);
00150 p1->SetRightMargin(0);
00151 p1->Draw();
00152 p1->cd();
00153 fmd->SetFillColor(4);
00154 fmd->GetYaxis()->SetRangeUser(logmin, logmax);
00155 fmd->GetYaxis()->SetTitleSize(.04);
00156 fmd->Draw();
00157 latex->DrawLatex(-1, latexy, "FMD only");
00158
00159 c->cd();
00160 p2->SetLogy();
00161 p2->SetGridy();
00162 p2->SetTopMargin(0.15);
00163 p2->SetBottomMargin(0);
00164 p2->SetLeftMargin(0);
00165 p2->SetRightMargin(0.15);
00166 p2->Draw();
00167 p2->cd();
00168 its->SetFillColor(2);
00169 its->GetYaxis()->SetRangeUser(logmin, logmax);
00170 its->Draw();
00171 latex->DrawLatex(-1, latexy, "ITS only");
00172
00173 c->cd();
00174 p3->SetLogy();
00175 p3->SetGridy();
00176 p3->SetTopMargin(0);
00177 p3->SetLeftMargin(0.15);
00178 p3->SetRightMargin(0);
00179 p3->Draw();
00180 p3->cd();
00181 pipe->SetFillColor(3);
00182 pipe->GetYaxis()->SetRangeUser(logmin, logmax);
00183 pipe->Draw();
00184 latex->DrawLatex(-1, latexy, "PIPE only");
00185
00186 c->cd();
00187 p4->SetLogy();
00188 p4->SetGridy();
00189 p4->SetTopMargin(0);
00190 p4->SetLeftMargin(0.);
00191 p4->SetRightMargin(0.15);
00192 p4->Draw();
00193 p4->cd();
00194 inner->GetYaxis()->SetRangeUser(logmin, logmax);
00195 inner->GetXaxis()->SetTitleSize(.04);
00196 inner->SetFillColor(5);
00197 inner->Draw();
00198 latex->DrawLatex(-1, latexy, "PIPE, ITS, FMD and Air");
00199
00200 c->Modified();
00201 c->cd();
00202 c->Print(Form("%s_single.png", what));
00203
00204 TCanvas* accum = new TCanvas(Form("accum_%s", what),
00205 Form("Accumalted %s",what),
00206 800, 500);
00207 accum->SetLogy();
00208 accum->SetFillColor(0);
00209 accum->SetBorderMode(0);
00210 accum->SetBorderSize(0);
00211
00212 THStack* stack = new THStack("stack", "Stack");
00213 nothing->SetFillColor(6);
00214 stack->Add(nothing);
00215 stack->Add(pipe);
00216 stack->Add(fmd);
00217 stack->Add(its);
00218
00219 TLegend* legend = new TLegend(.15, .65, .27, .95);
00220 legend->SetFillColor(0);
00221 legend->SetBorderSize(1);
00222 legend->AddEntry(its, "ITS", "f");
00223 legend->AddEntry(fmd, "FMD", "f");
00224 legend->AddEntry(pipe, "PIPE", "f");
00225 legend->AddEntry(nothing, "Air", "f");
00226
00227 stack->SetMinimum(nothing->GetMinimum());
00228 stack->SetMaximum(logmax);
00229 stack->Draw();
00230 stack->GetXaxis()->SetTitle("#eta");
00231
00232 stack->GetYaxis()->SetTitle(fmd->GetTitle());
00233 legend->Draw();
00234 accum->Modified();
00235
00236 accum->Modified();
00237 accum->cd();
00238
00239 accum->Print(Form("%s_accum.png", what));
00240
00241 }
00242
00243
00244
00245
00248 void
00249 DrawLego()
00250 {
00251 drawLego("abso");
00252 drawLego("radl");
00253 drawLego("gcm2");
00254 }
00255
00256
00257
00258
00259
00260
00261