ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Anghel/macros/src/makePlots.cc
Revision: 1.1
Committed: Fri Jan 29 23:03:50 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("/uscms/home/omanghel/work/Top/macros/histosFile.root");
21     file->cd();
22    
23     string dataType[8] = {"Wjets_Wjets","Wc_Wc","inclusiveMu_noFilter","Wjets_Wcc","Wjets_Wbb","TTjets_noFilter","Vqq_Wcc","Vqq_Wbb"};
24    
25     int N = 8; //# of samples
26    
27     //define histograms and related parameters
28     string histoType[8] = {"jetFlavor","jetMultiplicity","jetMultiplicity_4bins","jetPt","metEt","pdgID","bpartonsDR","cpartonsDR"};
29     string histoLabelX[8] = {"good Jet Flavor","# of jets","# of jets","p_{T}^{good_Jet}", "E_{T}^{#nu}", "partonID", "DR","DR"};
30     Int_t color[8] = {kAzure,kCyan-1,kTeal,kGreen+1,kYellow,kYellow+2,kOrange-3,kMagenta};
31     Int_t xbins[8] = {4000,10,4,500,500,20,40,40};
32     Double_t xlow[8] = {-10.,0.,0.,0.,0.,-10.,-20.,-20.};
33     Double_t xhigh[8] = {20.,10.,4.,300.,300.,10.,20.,20.};
34    
35     //int k=2;
36     //file[k]->cd();
37    
38     //TH1F *f;
39     //gDirectory->GetObject(histoType[0].c_str(),f);
40     //cout << "name = " << f->GetName() << endl;
41    
42     TH1F *hist[64];
43     THStack *hs = new THStack("hs","");
44    
45     for (int i=0; i < 8; i++) {
46     for (int j=0; j < N; j++) {
47     string histName = "h_" + histoType[i]+"_"+dataType[j];
48     cout << histName << endl;
49     hist[i*N+j] = (TH1F*) file->Get(histName.c_str());
50    
51     //gDirectory->GetObject(histName.c_str(),hist[i*N+j]);
52     cout << "hist[" << i*N+j << "] = " << hist[i*N+j]->GetName() << endl;
53     //hist[i*N+j]->Sumw2();
54    
55     if (j==5) hist[i*N+j]->SetLineColor(2);
56     else hist[i*N+j]->SetLineColor(color[j]);
57     if ((i==1)||(i==2)) {
58     hist[i*N+j]->SetFillStyle(1000);
59     if (j==5) hist[i*N+j]->SetFillColor(2);
60     else hist[i*N+j]->SetFillColor(color[j]);
61     }
62     else {
63     if (j==5) hist[i*N+j]->SetMarkerColor(2);
64     else hist[i*N+j]->SetMarkerColor(color[j]);
65     hist[i*N+j]->SetMarkerStyle(20);
66     hist[i*N+j]->SetMarkerSize(1.4);
67     }
68     hist[i*N+j]->SetStats(0);
69     if ((i==3)||(i==4)) hist[i*N+j]->Rebin(8); //rebin for Pt of the jets
70    
71     hist[i*N+j]->GetXaxis()->SetRangeUser(xlow[i], xhigh[i]);
72     hist[i*N+j]->GetXaxis()->SetTitle((histoLabelX[i]).c_str());
73     hist[i*N+j]->GetYaxis()->SetTitle("Entries");
74     }
75    
76     if (i==1) {
77     TCanvas *canvas1 = new TCanvas(histoType[i].c_str(), "");
78     hist[i*N]->Draw("hist e0");
79     for (int j=0; j != N; j++) {
80     if (j==0) continue;
81     hist[i*N+j]->Draw("same hist e0");
82     }
83     TLegend *legend1 = new TLegend(0.7, 0.5, 0.9, 0.85);
84     for (int j=0; j < N; j++) legend1->AddEntry(hist[i*N+j],dataType[j].c_str());
85     legend1->Draw();
86     legend1->SetFillColor(kWhite);
87     latex->DrawLatex(0.22,0.91,histoType[i].c_str());
88     //canvas1->SetLogy();
89     string nameCanvas1 = histoType[i]+".eps";
90     canvas1->SaveAs(nameCanvas1.c_str());
91     }
92    
93     if ((i!=1) && (i!=2)){
94     TCanvas *canvas3 = new TCanvas(histoType[i].c_str(), "");
95     hist[i*N]->Draw("P e0");
96     for (int j=0; j != N; j++) {
97     if (j==0) continue;
98     hist[i*N+j]->Draw("same P e0");
99     }
100     TLegend *legend3 = new TLegend(0.7, 0.5, 0.9, 0.85);
101     for (int j=0; j < N; j++) legend3->AddEntry(hist[i*N+j],dataType[j].c_str());
102     legend3->Draw();
103     legend3->SetFillColor(kWhite);
104     latex->DrawLatex(0.22,0.91,histoType[i].c_str());
105     //canvas1->SetLogy();
106     string nameCanvas3 = histoType[i]+".eps";
107     canvas3->SaveAs(nameCanvas3.c_str());
108     }
109    
110     }
111    
112     TCanvas *canvas2 = new TCanvas(histoType[2].c_str(), "");
113     for (int j=0; j < N; j++) hs->Add(hist[2*N+j]);
114     hs->Draw();
115     TLegend *legend2 = new TLegend(0.7, 0.5, 0.9, 0.85);
116     for (int j=0; j < N; j++) legend2->AddEntry(hist[2*N+j],dataType[j].c_str());
117     legend2->Draw();
118     legend2->SetFillColor(kWhite);
119     latex->DrawLatex(0.22,0.91,histoType[2].c_str());
120     string nameCanvas2 = histoType[2]+".eps";
121     canvas2->SaveAs(nameCanvas2.c_str());
122     }
123    
124    
125    
126    
127