ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CmsHi/JetAnalysis/macros/plotFigure.C
(Generate patch)

Comparing UserCode/CmsHi/JetAnalysis/macros/plotFigure.C (file contents):
Revision 1.1 by yilmaz, Tue Jan 29 00:37:01 2013 UTC vs.
Revision 1.2 by yilmaz, Sat Feb 2 14:00:34 2013 UTC

# Line 1 | Line 1
1   #if !defined(__CINT__) || defined(__MAKECINT__)
2  
3   #include <iostream>
4 + #include <string>
5   #include "TCanvas.h"
6   #include "TError.h"
7   #include "TPad.h"
# Line 17 | Line 18
18   #include "TLatex.h"
19   #include "TString.h"
20  
21 + using namespace std;
22 +
23   #endif
24  
25   #include "weightMix.C"
26  
27   static int iPlot = -99;
28  
29 + int centMode = 1;
30 + int entryMode = 0;
31  
32   //---------------------------------------------------------------------
33   void makeMultiPanelCanvas(TCanvas*& canv, const Int_t columns,
# Line 51 | Line 56 | void drawText(const char *text, float xp
56   void drawPatch(float x1, float y1, float x2, float y2);
57   //---------------------------------------------------------------------
58  
59 < void plotFigure(int iplot = 3){
60 <  TString infname = "/d101/yetkin/analysis/d0128/data_pPb.root";
59 > void plotFigure(int iplot = 9){
60 >  TString infname = "/d101/yetkin/analysis/d0131/ntuple_data_akPu3PF_forest68_20130201_01.root";
61    TString refname = "/d101/yetkin/analysis/d0128/data_PbPb.root";
62 <  TString mixname = "/d101/yetkin/analysis/d0128/mix_hydjet.root";
62 >  //  TString mixname = "/d101/yetkin/analysis/d0128/mix_hydjet.root";
63 >  TString mixname = "/d101/yetkin/analysis/d0201/hijing.root";
64 >
65 >  string hfNames[] = {
66 >    "30<E_{T}^{HF[#eta > 4]}<70",
67 >    "20<E_{T}^{HF[#eta > 4]}<30",
68 >    "15<E_{T}^{HF[#eta > 4]}<20",
69 >    "10<E_{T}^{HF[#eta > 4]}<15",
70 >    "5<E_{T}^{HF[#eta > 4]}<10",
71 >    "0<E_{T}^{HF[#eta > 4]}<5"
72 >  };
73 >
74 >
75 >  string ntrkNames[] = {
76 >    "180 #leq N_{trk}^{offline}",
77 >    "150 #leq N_{trk}^{offline} < 180",
78 >    "110 #leq N_{trk}^{offline} < 150",
79 >    "90 #leq N_{trk}^{offline} < 110",
80 >    "60 #leq N_{trk}^{offline} < 90",
81 >    "N_{trk}^{offline} < 60"
82 >  };
83 >
84 >  string *binNames = hfNames;
85 >  if(centMode == 0) binNames = ntrkNames;
86  
87    iPlot = iplot;
88  
# Line 64 | Line 92 | void plotFigure(int iplot = 3){
92     makeMultiPanelCanvas(c1,3,2,0.0,0.0,0.2,0.2,0.02);
93     TLatex *jetf_PbPb;
94  
95 <   if(iplot == 3){
95 >   if(iPlot == 3 || iPlot == 8 || iPlot == 11 || iPlot == 12){
96       for(int i = 0; i < 6; ++i){
97         c1->cd(i+1)->SetLogy();
98       }
# Line 78 | Line 106 | void plotFigure(int iplot = 3){
106    jetf_PbPb->SetTextSize(15);
107    jetf_PbPb->Draw();
108  
109 <  double y1 = 0.07;
110 <  plotBalance(5,infname,refname,mixname,true,false,false);
111 <  drawText("N_{trk}^{offline} < 60",0.6,y1);
109 >  for(int i = 0; i < 6; ++i){
110 >    c1->cd(6-i);
111 >    plotBalance(i,infname,refname,mixname,true,false,false);
112 >    double y1 = 0.07;
113 >    if(i < 3) y1 = 0.23;
114 >    y1=  0.9;
115 >    drawText(binNames[i].data(),0.3,y1);
116 >    //  drawText("(d)",0.25,0.92);
117 >  }
118  
119    c1->cd(2);
120  
87  plotBalance(4,infname,refname,mixname,0,false,false);
88  drawText("60 #leq N_{trk}^{offline} < 90",0.4,y1);
89
90
91  c1->cd(3);
92
93  plotBalance(3,infname,refname,mixname,0,false,false);
94  drawText("90 #leq N_{trk}^{offline} < 110",0.4,y1);
95  //  drawText("(c)",0.05,0.885);
96
97
121    TLatex tsel;
122    tsel.SetNDC();
123    tsel.SetTextFont(63);
# Line 103 | Line 126 | void plotFigure(int iplot = 3){
126    tsel.DrawLatex(0.15,0.65,Form("p_{T,2} > %d GeV/c",subleadCut));
127    tsel.DrawLatex(0.15,0.55,"#Delta#phi_{12} > #frac{2}{3}#pi");
128  
106
107  double y2 = 0.23;
108
109  c1->cd(4);
110  plotBalance(2,infname,refname,mixname,0,false,false);
111  drawText("110 #leq N_{trk}^{offline} < 150",0.45,y2);
112  //  drawText("(d)",0.25,0.92);
113  
114
115
116  c1->cd(5);
117  plotBalance(1,infname,refname,mixname,0,true,false);
118  drawText("150 #leq N_{trk}^{offline} < 180",0.42,y2);
119  //  drawText("(e)",0.05,0.92);
120
121  if(sideCorrect == 0){
122    jetf_PbPb = new TLatex(0.05,0.21,"Mismatched background not subtracted");
123    //    jetf_PbPb->Draw();
124  }
125
126  c1->cd(6);
127  plotBalance(0,infname,refname,mixname,0,false,1);
128  drawText("180 #leq N_{trk}^{offline}",0.45,y2);
129  //  drawText("(f)",0.05,0.92);
130
129    c1->cd(1);
130          
131    TLatex *cms = new TLatex(0.03,0.28,"CMS Preliminary");
# Line 163 | Line 161 | void plotFigure(int iplot = 3){
161    jetf_pp->Draw();
162  
163    const char* date = "20130127";
164 <  string figures[] = {"imbalance","","","dphi"};
164 >
165 >  string figures[150] = {"imbalance","etaDijet","",    "dphi","",
166 >                      "","",        "", "pudifference", "ntrk",
167 >                      "","pu1","pu2","","",
168 >                      "","","","","",
169 >                      "","eta1","eta2"
170 >  };
171 >
172    string formats[] = {"gif","pdf","eps","C"};
173  
174    for(int it = 0; it < 4; ++it){
# Line 196 | Line 201 | void plotBalance(int cbin,
201    TCut jetID("trkMax1 > 4 || trkMax2 > 4");
202    //  jetID = "trkMax1 > -99999";
203    TCut noise("noise < 0");
204 <  TCut weight("weight");
204 >  TCut weight("weight*(pthat > 50)");
205  
206  
207    double sideScale = sideCorrect*(3.1415926536-2.0944)/(sideMax-sideMin);
# Line 206 | Line 211 | void plotBalance(int cbin,
211    TCut centHF("");
212    TCut centNtrk("");
213  
214 <  if(cbin==0) centHF = "bin>=20 && bin<26";
215 <  if(cbin==1) centHF = "bin>=26 && bin<27";
216 <  if(cbin==2) centHF = "bin>=27 && bin<28";
217 <  if(cbin==3) centHF = "bin>=28 && bin<29";
218 <  if(cbin==4) centHF = "bin>=29 && bin<31";
219 <  if(cbin==5) centHF = "bin>=31";
220 <
221 <  if(cbin==0) centNtrk = "ntrk >= 180";
222 <  if(cbin==1) centNtrk = "150 <= ntrk && ntrk < 180";
223 <  if(cbin==2) centNtrk = "110 <= ntrk && ntrk < 150";
224 <  if(cbin==3) centNtrk = "90 <= ntrk && ntrk < 150";
225 <  if(cbin==4) centNtrk = "60 <= ntrk && ntrk < 90";
226 <  if(cbin==5) centNtrk = "ntrk < 60";
214 >  if(centMode == 0){
215 >    if(cbin==0) centHF = "bin>=20 && bin<26";
216 >    if(cbin==1) centHF = "bin>=26 && bin<27";
217 >    if(cbin==2) centHF = "bin>=27 && bin<28";
218 >    if(cbin==3) centHF = "bin>=28 && bin<29";
219 >    if(cbin==4) centHF = "bin>=29 && bin<31";
220 >    if(cbin==5) centHF = "bin>=31";
221 >
222 >    if(cbin==0) centNtrk = "ntrk >= 180";
223 >    if(cbin==1) centNtrk = "150 <= ntrk && ntrk < 180";
224 >    if(cbin==2) centNtrk = "110 <= ntrk && ntrk < 150";
225 >    if(cbin==3) centNtrk = "90 <= ntrk && ntrk < 150";
226 >    if(cbin==4) centNtrk = "60 <= ntrk && ntrk < 90";
227 >    if(cbin==5) centNtrk = "ntrk < 60";
228 >  }
229 >
230 >  if(centMode == 1){
231 >    if(cbin==0) centHF = "hf>=30 && hf<70";
232 >    if(cbin==1) centHF = "hf>=20 && hf<30";
233 >    if(cbin==2) centHF = "hf>=15 && hf<20";
234 >    if(cbin==3) centHF = "hf>=10 && hf<15";
235 >    if(cbin==4) centHF = "hf>=5 && hf<10";
236 >    if(cbin==5) centHF = "hf<5";
237 >
238 >    if(cbin==0) centHF = "cent>=30 && cent<70";
239 >    if(cbin==1) centHF = "cent>=20 && cent<30";
240 >    if(cbin==2) centHF = "cent>=15 && cent<20";
241 >    if(cbin==3) centHF = "cent>=10 && cent<15";
242 >    if(cbin==4) centHF = "cent>=5 && cent<10";
243 >    if(cbin==5) centHF = "cent<5";
244 >
245 >    centNtrk = centHF;
246 >  }
247 >
248 >
249 >
250  
251  
252    cout<<"plotting ntrk bin : "<<cbin<<endl;
253  
254    // open the data file
255 +
256 +  if(iPlot > 100) entryMode = 1;
257 +
258 +  string treeName = "ntdijet";
259 +  string wName = "ntw";
260 +  if(entryMode == 1){
261 +    treeName = "ntjet";
262 +    wName = "ntjetw";
263 +  }
264 +
265 +  if(entryMode == 2){
266 +    treeName = "nttrk";
267 +    wName = "nttrkw";
268 +  }
269 +
270    TFile *inf = new TFile(infname.Data());
271 <  TTree *nt =(TTree*)inf->FindObjectAny("ntdijet");
271 >  TTree *nt =(TTree*)inf->FindObjectAny(treeName.data());
272    TTree *ntevt =(TTree*)inf->FindObjectAny("ntevt");
273 <  nt->AddFriend(ntevt);
273 >  if(entryMode < 1) nt->AddFriend(ntevt);
274  
275    // open the pythia (MC) file
276    TFile *infPythia = new TFile(pythia.Data());
277    TTree *ntPythia;
278    TTree *ntevtPythia;
279    if(!refOldNtuple){
280 <    ntPythia = (TTree*) infPythia->FindObjectAny("ntdijet");
280 >    ntPythia = (TTree*) infPythia->FindObjectAny(treeName.data());
281      ntevtPythia = (TTree*) infPythia->FindObjectAny("ntevt");
282 <    ntPythia->AddFriend(ntevtPythia);
282 >    if(entryMode < 1) ntPythia->AddFriend(ntevtPythia);
283    }else{
284      ntPythia = (TTree*) infPythia->FindObjectAny("nt");
285    }
286  
287    // open the datamix file
288    TFile *infMix = new TFile(mix.Data());
289 <  TTree *ntMix =(TTree*)infMix->FindObjectAny("ntdijet");
289 >  TTree *ntMix =(TTree*)infMix->FindObjectAny(treeName.data());
290    TTree *ntevtMix =(TTree*)infMix->FindObjectAny("ntevt");
291    //  TFile *infW = new TFile("weights_hydjet.root");
292    //  TTree *ntw =(TTree*)infW->FindObjectAny("ntw");
293  
294 <  TTree *ntw =(TTree*)infMix->FindObjectAny("ntw");
294 >  TTree *ntw =(TTree*)infMix->FindObjectAny(wName.data());
295    ntMix->AddFriend(ntw);
296 <  ntMix->AddFriend(ntevtMix);
296 >  if(entryMode < 1) ntMix->AddFriend(ntevtMix);
297  
298    int Nbin = 10;
299    double max = 1.;
300 +  double min = 0;
301 +
302 +  if(iPlot == 1 || iPlot == 21 || iPlot == 22){
303 +    Nbin = 20;
304 +    max = 2;
305 +    min = -2;
306 +  };
307  
308    if(iPlot == 3){
309      Nbin = 30;
310      max = pi;
311    };
312  
313 +  if(iPlot == 8){
314 +    Nbin = 50;
315 +    max = 25;
316 +    min = -25;
317 +  };
318 +
319 +  if(iPlot == 9){
320 +    Nbin = 50;
321 +    max = 250;
322 +  };
323 +
324 +  if(iPlot == 11 || iPlot == 12){
325 +    Nbin = 50;
326 +    max = 25;
327 +  };
328 +
329 +  if(iPlot == 101){
330 +    Nbin = 20;
331 +    max = 2;
332 +    min = -2;
333 +  }
334  
335    // projection histogram
336 <  TH1D *h = new TH1D(Form("h",cbin),"",Nbin,0,max);
337 <  TH1D *hPythia = new TH1D(Form("hPythia",cbin),"",Nbin,0,max);
338 <  TH1D *hDataMix = new TH1D(Form("hDataMix",cbin),"",Nbin,0,max);
339 <
340 <  TH1D *hB = new TH1D(Form("hB",cbin),"",Nbin,0,max);
341 <  TH1D *hPythiaB = new TH1D(Form("hPythiaB",cbin),"",Nbin,0,max);
342 <  TH1D *hDataMixB = new TH1D(Form("hDataMixB",cbin),"",Nbin,0,max);
343 <
344 <  TH1D *hFull = new TH1D("hFull","",Nbin,0,max);
345 <  TH1D *hPythiaFull = new TH1D("hPythiaFull","",Nbin,0,max);
346 <  TH1D *hDataMixFull = new TH1D("hDataMixFull","",Nbin,0,max);
336 >  TH1D *h = new TH1D(Form("h",cbin),"",Nbin,min,max);
337 >  TH1D *hPythia = new TH1D(Form("hPythia",cbin),"",Nbin,min,max);
338 >  TH1D *hDataMix = new TH1D(Form("hDataMix",cbin),"",Nbin,min,max);
339 >
340 >  TH1D *hB = new TH1D(Form("hB",cbin),"",Nbin,min,max);
341 >  TH1D *hPythiaB = new TH1D(Form("hPythiaB",cbin),"",Nbin,min,max);
342 >  TH1D *hDataMixB = new TH1D(Form("hDataMixB",cbin),"",Nbin,min,max);
343 >
344 >  TH1D *hFull = new TH1D("hFull","",Nbin,min,max);
345 >  TH1D *hPythiaFull = new TH1D("hPythiaFull","",Nbin,min,max);
346 >  TH1D *hDataMixFull = new TH1D("hDataMixFull","",Nbin,min,max);
347  
348    TH1D* hNorm = new TH1D("hNorm","",1000,0,1000);
349    TH1D* hNormPythia = new TH1D("hNormPythia","",1000,0,1000);
# Line 309 | Line 380 | void plotBalance(int cbin,
380      ntPythia->SetAlias("phi2","jtphi2");
381    }
382  
383 +  nt->SetAlias("cent","hf");
384 +  ntMix->SetAlias("cent","hf");
385 +  ntPythia->SetAlias("cent","hf");
386 +
387    nt->SetAlias("dphi","acos(cos(phi1-phi2))");
388    ntMix->SetAlias("dphi","acos(cos(phi1-phi2))");
389    ntPythia->SetAlias("dphi","acos(cos(phi1-phi2))");
# Line 319 | Line 394 | void plotBalance(int cbin,
394      ntMix->SetAlias("var","pt2/pt1");
395    }
396  
397 +  if(iPlot == 1){
398 +    nt->SetAlias("var","(eta1+eta2)/2");
399 +    ntPythia->SetAlias("var","(eta1+eta2)/2");
400 +    ntMix->SetAlias("var","(eta1+eta2)/2");
401 +  }
402 +
403    if(iPlot == 3){
404      nt->SetAlias("var","acos(cos(phi1-phi2))");
405      ntPythia->SetAlias("var","acos(cos(phi1-phi2))");
# Line 326 | Line 407 | void plotBalance(int cbin,
407    }
408  
409    if(iPlot == 8){
410 <    nt->SetAlias("var","pu2/pu1");
411 <    ntPythia->SetAlias("var","pu2/pu1");
412 <    ntMix->SetAlias("var","pu2/pu1");
410 >    nt->SetAlias("var","pu1-pu2");
411 >    ntPythia->SetAlias("var","pu1-pu2");
412 >    ntMix->SetAlias("var","pu1-pu2");
413    }
414  
415 +  if(iPlot == 11){
416 +    nt->SetAlias("var","pu1");
417 +    ntPythia->SetAlias("var","pu1");
418 +    ntMix->SetAlias("var","pu1");
419 +  }
420 +
421 +  if(iPlot == 12){
422 +    nt->SetAlias("var","pu2");
423 +    ntPythia->SetAlias("var","pu2");
424 +    ntMix->SetAlias("var","pu2");
425 +  }
426 +
427 +  if(iPlot == 9){
428 +    nt->SetAlias("var","ntrk");
429 +    ntPythia->SetAlias("var","ntrk");
430 +    ntMix->SetAlias("var","ntrk");
431 +  }
432 +
433 +  if(iPlot == 21){
434 +    nt->SetAlias("var","eta1");
435 +    ntPythia->SetAlias("var","eta1");
436 +    ntMix->SetAlias("var","eta1");
437 +  }
438 +
439 +  if(iPlot == 22){
440 +    nt->SetAlias("var","eta2");
441 +    ntPythia->SetAlias("var","eta2");
442 +    ntMix->SetAlias("var","eta2");
443 +  }
444 +
445 +
446 +
447 +  if(iPlot == 101){
448 +    nt->SetAlias("var","eta");
449 +    ntPythia->SetAlias("var","eta");
450 +    ntMix->SetAlias("var","eta");
451 +  }
452 +
453 +  if(iPlot == 51){
454 +    nt->SetAlias("var","matchPt1/pt1");
455 +    ntPythia->SetAlias("var","matchPt1/pt1");
456 +    ntMix->SetAlias("var","matchPt1/pt1");
457 +  }
458 +
459 +  if(iPlot == 52){
460 +    nt->SetAlias("var","matchPt2/pt2");
461 +    ntPythia->SetAlias("var","matchPt2/pt2");
462 +    ntMix->SetAlias("var","matchPt2/pt2");
463 +  }
464 +
465 +
466    nt->Draw("var>>hFull",dijet&&noise&&jetID&&centNtrk);
467    nt->Draw("var>>hB",side&&noise&&jetID&&centNtrk);
468    nt->Draw("pt1>>hNorm",lead&&noise&&jetID&&centNtrk);
# Line 413 | Line 545 | void plotBalance(int cbin,
545    if(drawXLabel) hDataMix->SetXTitle("A_{J} = (p_{T,1}-p_{T,2})/(p_{T,1}+p_{T,2})");  
546    hDataMix->SetYTitle("Event Fraction");
547  
548 <  if(iPlot==9)hDataMix->SetXTitle("p_{T,2}^{background}/p_{T,1}^{background}");
548 >  if(iPlot==1) hDataMix->SetXTitle("#eta_{dijet} = (#eta_{1}+#eta_{2})/2");
549 >  if(iPlot==21) hDataMix->SetXTitle("#eta_{1}");
550 >  if(iPlot==22) hDataMix->SetXTitle("#eta_{2}");
551 >
552 >  if(iPlot==8) hDataMix->SetXTitle("p_{T,1}^{background}-p_{T,2}^{background}");
553 >  if(iPlot==9) hDataMix->SetXTitle("N_{trk}^{offline}");
554 >
555 >  if(iPlot==11) hDataMix->SetXTitle("p_{T,1}^{background}");
556 >  if(iPlot==12) hDataMix->SetXTitle("p_{T,2}^{background}");
557  
558    if(drawXLabel){
559      if(iPlot==0) hDataMix->SetXTitle("p_{T,2}/p_{T,1}");
# Line 421 | Line 561 | void plotBalance(int cbin,
561    }
562  
563    if(iPlot==0) hDataMix->SetMaximum(0.32);
564 +
565 +  if(iPlot == 1 || iPlot==21 || iPlot==22){
566 +    hDataMix->SetMaximum(0.3);
567 +    hDataMix->SetMinimum(0);
568 +  }
569 +
570 +
571    if(iPlot==3){
572      hDataMix->SetMaximum(2.52);
573      hDataMix->SetMinimum(0.00004);
574    }
575  
576 +  if(iPlot==8){
577 +    hDataMix->SetMaximum(10);
578 +    hDataMix->SetMinimum(0.00004);
579 +  }
580 +
581 +  if(iPlot==9){
582 +    hDataMix->SetMaximum(0.15);
583 +    hDataMix->SetMinimum(0.);
584 +  }
585 +
586 +  if(iPlot==11 || iPlot == 12){
587 +    hDataMix->SetMaximum(10);
588 +    hDataMix->SetMinimum(0.00004);
589 +  }
590 +
591 +
592 +
593    //hDataMix->GetXaxis()->SetNdivisions(905,true);
594    hDataMix->GetYaxis()->SetNdivisions(505,true);
595  
596    hPythia->SetMarkerColor(ppColor);
597    hPythia->SetLineColor(ppColor);
598 <  hPythia->SetMarkerStyle(24);
598 >  hPythia->SetMarkerStyle(25);
599  
600          hDataMix->Draw();//"hist");
601          hDataMix->Draw("hist same");
602 <        hPythia->Draw("same");
602 >        //      hPythia->Draw("same");
603  
604          cout<<"PbPb ENTRIES : "<<endl;
605          cout<<hPythia->GetEntries()<<endl;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines