ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Anghel/macros/makePlots.cc
Revision: 1.1
Committed: Fri Jan 29 23:12:38 2010 UTC (15 years, 3 months ago) by anghel
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
Revision 29Jan2010

File Contents

# User Rev Content
1 anghel 1.1 #include "../../Style.cc"
2     #include "TFile.h"
3     #include "TH1F.h"
4     #include "THStack.h"
5     #include "TMath.h"
6     #include "TLatex.h"
7     #include "TLegend.h"
8     #include "TCanvas.h"
9     #include <iostream>
10     #include <string>
11    
12     using namespace std;
13    
14     void makePlots() {
15     Style();
16     TLatex *latex = new TLatex();
17     latex->SetNDC();
18    
19     TFile *file;
20     file = TFile::Open("histosFileMediumOP_newF.root");
21     //file = TFile::Open("histosFileTightOP_newF.root");
22     file->cd();
23    
24     string dataType[13] = {"TTjets","Wjets_Wbb","Wjets_Wcc","Wjets_Wjets","Zjets_Wbb","Zjets_Wcc","Zjets_Wjets","Vqq_Wbb","Vqq_Wb","Vqq_Wcc","Vqq_Wc","Wc_Wc","inclusiveMu"};
25    
26     int N = 13; //# of samples
27    
28     //define histograms and related parameters
29     string histoType[12] = {"jetMultiplicity_4binInclusive","tagjetMultiplicity","tagBjetMultiplicity","jetPt","tagjetPt","tagBjetPt","jetFlavor","tagjetFlavor","metEt","pdgID","bpartonsDR","cpartonsDR"};
30     string histoLabelX[12] = {"# of jets","# of tags","# of B tags","p_{T}^{good_Jet}","p_{T}^{tagged_Jet}","p_{T}^{tagged_Bjet}","jet_Flavor","Bjet_Flavor","E_{T}^{#nu}","partonID","DR","DR"};
31     Int_t color[13] = {kRed,kAzure,kCyan-1,kTeal,kGreen+1,kYellow,kYellow+2,kOrange-3,kMagenta,kOrange+3,kMagenta-2,kAzure+5};
32     Int_t xbins[12] = {4,4,4,500,500,500,2000,2000,500,20,40,40};
33     Double_t xlow[12] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,-10.,-20.,-20.};
34     Double_t xhigh[12] = {4.,4.,4.,300.,300.,300.,25.,25.,300.,10.,20.,20.};
35    
36     //int k=2;
37     //file[k]->cd();
38    
39     //TH1F *f;
40     //gDirectory->GetObject(histoType[0].c_str(),f);
41     //cout << "name = " << f->GetName() << endl;
42    
43     TH1F *hist[156];
44     THStack *hs[3];
45     hs[0] = new THStack("hs","");
46     hs[1] = new THStack("hstag","");
47     hs[2] = new THStack("hstagB","");
48    
49     for (int i=0; i < 12; i++) { //loop over histo types
50     for (int j=0; j < N; j++) { //loop over samples
51     string histName;
52     if ((dataType[j]=="TTjets")||(dataType[j]=="inclusiveMu")) histName = "h_" + histoType[i]+"_"+dataType[j]+"_noFilter";
53     else histName = "h_" + histoType[i]+"_"+dataType[j];
54     cout << histName << endl;
55     hist[i*N+j] = (TH1F*) file->Get(histName.c_str());
56    
57     //gDirectory->GetObject(histName.c_str(),hist[i*N+j]);
58     cout << "hist[" << i*N+j << "] = " << hist[i*N+j]->GetName() << endl;
59     //hist[i*N+j]->Sumw2();
60    
61     hist[i*N+j]->SetLineColor(color[j]);
62     if (i < 3) {
63     hist[i*N+j]->SetFillStyle(1000);
64     hist[i*N+j]->SetFillColor(color[j]);
65     }
66     else {
67     hist[i*N+j]->SetMarkerStyle(20);
68     hist[i*N+j]->SetMarkerColor(color[j]);
69     hist[i*N+j]->SetMarkerSize(1.4);
70     }
71     hist[i*N+j]->SetStats(0);
72     if ((i==3)||(i==4)||(i==5)||(i==8)) hist[i*N+j]->Rebin(8); //rebin for Pt of the jets
73    
74     hist[i*N+j]->GetXaxis()->SetRangeUser(xlow[i], xhigh[i]);
75     hist[i*N+j]->GetXaxis()->SetTitle((histoLabelX[i]).c_str());
76     hist[i*N+j]->GetYaxis()->SetTitle("Entries");
77     hist[i*N+j]->SetTitle("");
78     }
79    
80     if(i < 3) {
81     TCanvas *canvas3 = new TCanvas(histoType[i].c_str(), "");
82     for (int j=0; j < N; j++) hs[i]->Add(hist[j]);
83     hs[i]->Draw();
84     TLegend *legend3 = new TLegend(0.7, 0.5, 0.9, 0.85);
85     for (int j=0; j < N; j++) legend3->AddEntry(hist[j],dataType[j].c_str());
86     legend3->Draw();
87     legend3->SetFillColor(kWhite);
88     latex->DrawLatex(0.22,0.91,histoType[i].c_str());
89     string nameCanvas3 = histoType[i]+".eps";
90     canvas3->SaveAs(nameCanvas3.c_str());
91     }
92    
93     if ((i > 5)&&(i!=8)) {
94     TCanvas *canvas1 = new TCanvas(histoType[i].c_str(), "");
95     hist[i*N]->Draw("hist e0");
96     for (int j=1; j != N; j++) {
97     hist[i*N+j]->Draw("same hist e0");
98     }
99     TLegend *legend1 = new TLegend(0.7, 0.5, 0.9, 0.85);
100     for (int j=0; j < N; j++) legend1->AddEntry(hist[i*N+j],dataType[j].c_str());
101     legend1->Draw();
102     legend1->SetFillColor(kWhite);
103     latex->DrawLatex(0.22,0.91,histoType[i].c_str());
104     //canvas1->SetLogy();
105     string nameCanvas1 = histoType[i]+".eps";
106     canvas1->SaveAs(nameCanvas1.c_str());
107     }
108    
109     if ((i==3)||(i==4)||(i==5)||(i==8)) {
110     TCanvas *canvas2 = new TCanvas(histoType[i].c_str(), "");
111     hist[0]->Draw("P e0");
112     for (int j=1; j != N; j++) {
113     hist[i*N+j]->Draw("same P e0");
114     }
115     TLegend *legend2 = new TLegend(0.7, 0.5, 0.9, 0.85);
116     for (int j=0; j < N; j++) legend2->AddEntry(hist[i*N+j],dataType[j].c_str());
117     legend2->Draw();
118     legend2->SetFillColor(kWhite);
119     latex->DrawLatex(0.22,0.91,histoType[i].c_str());
120     //canvas2->SetLogy();
121     string nameCanvas2 = histoType[i]+".eps";
122     canvas2->SaveAs(nameCanvas2.c_str());
123     }
124     }
125     /*
126     TCanvas *canvas3 = new TCanvas(histoType[0].c_str(), "");
127     for (int j=0; j < N; j++) hs->Add(hist[j]);
128     hs->Draw();
129     TLegend *legend3 = new TLegend(0.7, 0.5, 0.9, 0.85);
130     for (int j=0; j < N; j++) legend3->AddEntry(hist[j],dataType[j].c_str());
131     legend2->Draw();
132     legend2->SetFillColor(kWhite);
133     latex->DrawLatex(0.22,0.91,histoType[2].c_str());
134     string nameCanvas2 = histoType[2]+".eps";
135     canvas2->SaveAs(nameCanvas2.c_str());*/
136     }
137    
138    
139    
140    
141