ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/rootEWKanalyzer/plotDataMCwSignal.C
(Generate patch)

Comparing UserCode/rootEWKanalyzer/plotDataMCwSignal.C (file contents):
Revision 1.1 by jueugste, Mon Jun 7 14:57:40 2010 UTC vs.
Revision 1.2 by jueugste, Tue Jul 20 15:32:44 2010 UTC

# Line 6 | Line 6 | void plotDataMCwSignal(){
6    // specify the DATA/MC root file!!!
7    // --------------------------------------------------------------------------
8    TFile *data = TFile::Open("Data/root/Data.root");
9 <  TFile *mc = TFile::Open("bckgd.root");
9 >  TFile *mc = TFile::Open("QCD_bckgd.root");
10 >  TFile *mcOther = TFile::Open("other_bckgd.root");
11 >  TFile *mcTTbar = TFile::Open("TTbar_bckgd.root");
12    TFile *mcSignal = TFile::Open("mcSignal.root");
13  
14    char *legDataTitle = "Data";//"Signal, W #rightarrow e #nu";
15 <  char *legMCTitle = "MC QCD, #gamma + jet"; //"Background";
16 <  char *legMCsigTitle = "MC W #rightarrow e #nu"; //"Signal";
15 >  char *legMCTitle = "QCD, #gamma + jet"; //"Background";
16 >  char *legMCotherTitle = "EWK"; //"Background";
17 >  char *legMCttbarTitle = "ttbar"; //"Background";
18 >  char *legMCsigTitle = "W #rightarrow e #nu"; //"Signal";
19    TString dataset="";
20    TString overallTitle="CMS preliminary 2010";
21 <  TString CMen="#sqrt{s}=7TeV,   #int L = 7.6 nb^{-1}";
21 >  TString CMen="#sqrt{s}=7TeV,   #int L = 130 nb^{-1}";
22    TString cuts1="";
23    TString cuts2="";
24    double rebin=2.;
# Line 46 | Line 50 | void plotDataMCwSignal(){
50   //   TRegexp dijet("DiJet");
51   //   TRegexp cons("cons");
52  
53 <  int islog=1;
53 >  int islog=0;
54 >
55 >  int index=0;
56  
57    for (TKey* key = 0; (key = (TKey *) next());) {
58   //     isptplot=false;
# Line 71 | Line 77 | void plotDataMCwSignal(){
77  
78   //     }
79      
80 <    islog=0;
80 >    islog=1;
81   //     if(name.Index(eta)>-1||name.Index(phi)>-1||name.Index(hits)>-1 || name.Index(emf)>-1 || name.Index(CHF)>-1 || name.Index(NHF)>-1|| name.Index(NEF)>-1||name.Index(cons)>-1) islog=0;
82      TH1D * h_data= data->Get(key->GetName());
83      TH1D * h_mc=mc->Get(key->GetName());
84 +    TH1D * h_other=mcOther->Get(key->GetName());
85 +    TH1D * h_ttbar=mcTTbar->Get(key->GetName());
86      TH1D * h_sig=mcSignal->Get(key->GetName());
87      // only for filled histos
88   //     if( h_mc->GetEntries()!=0) {
89        //
90 +
91 +
92 + //     cout<<"here"<<endl;
93 +
94        h_data->SetTitle(overallTitle);
95        h_mc->SetTitle(overallTitle);
96 +      h_other->SetTitle(overallTitle);
97 +      h_ttbar->SetTitle(overallTitle);
98        h_sig->SetTitle(overallTitle);
99   //       if(name.Index(pt)>-1) {
100   //      h_data->SetYTitle("Jets/GeV");
# Line 132 | Line 146 | void plotDataMCwSignal(){
146  
147  
148      h_mc->SetFillColor(colour);
149 <    h_mc->SetLineColor(colour);
150 <    h_mc->SetFillStyle(3315);
149 >    h_mc->SetLineColor(1);
150 >    h_other->SetFillColor(8);
151 >    h_other->SetLineColor(1);
152 >    h_ttbar->SetFillColor(15);
153 >    h_ttbar->SetLineColor(1);
154      h_sig->SetFillColor(46);
155 <    h_sig->SetLineColor(46);
139 <    h_sig->SetFillStyle(3315);
155 >    h_sig->SetLineColor(1);
156      h_data->SetMarkerStyle(20);
157 < //     h_data->SetFillColor(2);
142 < //     h_data->SetLineColor(2);
143 < //     h_data->SetFillStyle(3351);
157 >
158  
159      //    h_data->SetTitle(overallTitle);
160      //    h_mc->SetTitle(overallTitle);
# Line 148 | Line 162 | void plotDataMCwSignal(){
162   //     h_mc->SetMinimum(0.01);
163   //     h_data->SetMinimum(0.01);
164  
165 +
166 +
167      //draw title
168 <    MoveStatsAndDraw(h_data , h_mc, h_sig, legDataTitle, legMCTitle, legMCsigTitle, overallTitle, CMen, islog, colour, false, cuts1, cuts2, isptplot);
168 >    MoveStatsAndDraw(h_data , h_mc, h_other, h_ttbar, h_sig, legDataTitle, legMCTitle, legMCsigTitle, legMCotherTitle, legMCttbarTitle, overallTitle, CMen, islog, colour, false, cuts1, cuts2, isptplot);
169 >
170      char histname [256];
171 <    sprintf (histname, "%s.gif", key->GetName());
172 <    c->Print (histname);
171 >    sprintf (histname, "plotting/%s.gif", key->GetName());
172 > //     cout<<key->GetName()<<endl;
173 >    char test [256];//="s_El_ElCharge_";
174 >    //    index++;
175 >    sprintf (test, "%s%i",  "s_El_ElCharge_",index);
176 > //     cout<<test<<endl;
177 >    if(!strcmp(key->GetName(),test)) {
178 >      index++;
179 >      continue;
180 >    }
181 >    c->Print(histname);
182 > //     cout<<"here2"<<endl;
183 >
184      delete c;
185 +
186 +
187   //     } //if Entries != 0
188    } // loop over keys
189  
# Line 186 | Line 216 | void plotDataMCwSignal(){
216  
217  
218   //-------------------------------------------------------------------------------------
219 < void MoveStatsAndDraw (TH1 *data, TH1 *mc, TH1 *sig, char *dataTitle, char* mcTitle, char *mcSigTitle, char* firstline, char* secondline, int log, int col, bool stat, TString cut1, TString cut2, bool movepave){
219 > void MoveStatsAndDraw (TH1 *data, TH1 *mc, TH1 *other, TH1 *ttbar, TH1 *sig, char *dataTitle, char* mcTitle,  char *mcSigTitle, char* otherTitle, char *ttbarTitle, char* firstline, char* secondline, int log, int col, bool stat, TString cut1, TString cut2, bool movepave){
220  
221    c->SetLogy(log);
222  
223   //    maximumData;
224   //   double maximumMc;
225    int maximumData=data->GetBinContent(data->GetMaximumBin());
226 <  int maximumMc=sig->GetBinContent(mc->GetMaximumBin());
226 >  int maximumMc=mc->GetBinContent(mc->GetMaximumBin());
227 >
228 >
229 >
230    
231   //   if(data->GetBinContent(data->GetMaximum())<mc->GetBinContent(mc->GetMaximum())) {
232    if(maximumData<maximumMc) {
233 <    sig->Draw("");
234 <    mc->Draw("sames");
233 >    sig->SetMaximum(maximumMc * 1.6);
234 >    if(log==1) sig->SetMinimum(0.0001);
235 >    if(log==0) sig->SetMinimum(0.);
236 >    mc->Draw("");
237 >    other->Draw("sames");
238 >    ttbar->Draw("sames");
239 >    sig->Draw("sames");
240      data->Draw("pe1sames");
241    }
242    else {
243 +    data->SetMaximum(maximumData * 1.6);
244 +    if(log==1) data->SetMinimum(0.0001);
245 +    if(log==0) data->SetMinimum(0.);
246      data->Draw("pe1");
206    sig->Draw("sames");
247      mc->Draw("sames");
248 +    other->Draw("sames");
249 +    ttbar->Draw("sames");
250 +    sig->Draw("sames");
251 +    data->Draw("pe1 sames");
252      
253    }
254  
255  
256    gStyle->SetOptStat(00000000);
257 <  stat=1;  
257 >  stat=0;  
258    if(stat) gStyle->SetOptStat(1111111);
259  
260  
# Line 241 | Line 285 | void MoveStatsAndDraw (TH1 *data, TH1 *m
285    if(!movepave) {
286      TLegend *leg = new TLegend(0.65,0.83,1.,0.93);
287    } else {
288 <    TLegend *leg = new TLegend(0.65,0.60,1.,0.7);
288 >    TLegend *leg = new TLegend(0.60,0.53,1.,0.7);
289    }
290    leg->SetFillStyle(4000);
291    leg->SetFillColor(kWhite);
# Line 249 | Line 293 | void MoveStatsAndDraw (TH1 *data, TH1 *m
293    leg->SetTextFont(42);
294    leg->AddEntry(data,dataTitle,"p");   //p
295    leg->AddEntry(mc,mcTitle,"f");
296 +  leg->AddEntry(other,otherTitle,"f");
297 +  leg->AddEntry(ttbar,ttbarTitle,"f");
298    leg->AddEntry(sig,mcSigTitle, "f");
299    leg->Draw();
300  
# Line 296 | Line 342 | void MoveStatsAndDraw (TH1 *data, TH1 *m
342    else std::cout << "Null pointer to TPaveStats: " << ps3 << std::endl;
343  
344    }
345 +
346 +
347   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines