Revision: | 1.1 |
Committed: | Fri Jul 29 10:34:15 2011 UTC (13 years, 9 months ago) by arizzi |
Content type: | text/plain |
Branch: | MAIN |
CVS Tags: | EDMV42_Step2_V8, EDMV42_Step2_V7, EDMV42_Step2_V6, EDMV42_Step2_V5a, EDMV42_Step2_V5, tauCandV42, hbbsubstructDev_11, hbbsubstructDev_10, hbbsubstructDev_9, hbbsubstructDev_8, hbbsubstructDev_7, hbbsubstructDev_6, hbbsubstructDev_5, hbbsubstructDev_4, hbbsubstructDev_3, hbbsubstructDev_2, hbbsubstructDev_1, hbbsubstructDev, V21TauCand_0, EDMV42_Step2_V4a, EDMV42_Step2_V4, EDMV42_Step2_V3, EDMV42_Step2_V2, EDMV42_Step2_V1, EdmV42, EdmV41alpha1, EdmV40alpha1, EdmV40alpha, V21emuCand, EdmV33Jun12v2_consistent, Step2ForV33_v2, Step2ForV33_v1, EdmV33Jun12v2, EdmV33Jun12v1, EdmV33Jun12v0, Step2ForV32_v2, Step2ForV32_v1, Step2ForV32_v0, Step2ForV31_v0, EdmV32May24v0, EdmV31May21v1, EdmV31May17v0, May14thStep2, EdmV30Apr10, EdmV21Apr10v2, EdmV22May9, EdmV21Apr06, EdmV21Apr10, EdmV21Apr04, EdmV21Apr03, EdmV21Apr2, EdmV21Mar30, EdmV20Mar12, AR_Nov10Ntuple, AR_step2_Oct25, AR_step2_oct19, EdmV11Oct2011, AR_Step2_Oct13, AR_Oct9Ntuple, AR_Oct7_step2ntuple, AR_Oct5Ntuple, EdmV10Oct2011, EdmV9Sept2011, Sept19th2011_2, Sept19th2011, Sept19th, VHNtupleV9_AR1, VHSept15_AR1, Sept14th2011_2, Sept14th2011_AR1, Sept14th2011, Sept13th2011, AR_Sep8_LightNtuple, VHBB_EDMNtupleV3, AndreaAug10th, HEAD |
Branch point for: | V42TauCandidate, hbbsubstructDevPostHCP, V21TauCand, V21emuCandidate |
Log Message: | macros |
# | User | Rev | Content |
---|---|---|---|
1 | arizzi | 1.1 | #include<samples.h> |
2 | #include <iostream> | ||
3 | #include <TCanvas.h> | ||
4 | #include <TRegexp.h> | ||
5 | #include <TLegend.h> | ||
6 | #include <THStack.h> | ||
7 | #include "setTDRStyle.C" | ||
8 | #include <TROOT.h> | ||
9 | #include "customize.h" | ||
10 | |||
11 | void plottingmacro() | ||
12 | { | ||
13 | setTDRStyle(); | ||
14 | gROOT->ForceStyle(); | ||
15 | initOptions(); | ||
16 | |||
17 | std::vector<Sample> s = samples(); | ||
18 | Sample data(1,"fake data","S1.root",0,true,1000); | ||
19 | |||
20 | for(size_t i=0;i< s.size();i++) if(s[i].data) {data=s[i];break;} | ||
21 | data.file()->ls(); | ||
22 | for(size_t i=0;i< s.size();i++) s[i].dump(data.lumi()); | ||
23 | |||
24 | std::vector<std::string> names; | ||
25 | |||
26 | TList * subs = data.file()->GetListOfKeys(); | ||
27 | for(size_t i=0;i< subs->GetSize();i++) | ||
28 | { | ||
29 | TList * objs = ((TDirectoryFile *) data.file()->Get(subs->At(i)->GetName()))->GetListOfKeys(); | ||
30 | for(size_t j=0;j< objs->GetSize();j++) | ||
31 | { | ||
32 | names.push_back(subs->At(i)->GetName()+std::string("/") + objs->At(j)->GetName()); | ||
33 | // std::cout << subs->At(i)->GetName() << "/" << objs->At(j)->GetName() << std::endl; | ||
34 | //TODO: select plots via regexp | ||
35 | } | ||
36 | |||
37 | } | ||
38 | |||
39 | for(size_t i = 0 ; i < names.size() ; i++) | ||
40 | { | ||
41 | std::map<std::string,TH1F *> grouped; | ||
42 | TString n=names[i]; | ||
43 | if(!n.Contains(TRegexp("V.*RegionH.*mu.*HiggsMass"))) continue; | ||
44 | TCanvas *c = new TCanvas(); | ||
45 | c->SetLogy(true); | ||
46 | c->SetTitle(names[i].c_str()); | ||
47 | TH1F *hd = ((TH1F*)data.file()->Get(names[i].c_str())); | ||
48 | Options o=options[names[i]]; | ||
49 | hd->Rebin(o.rebin); | ||
50 | hd->SetMarkerStyle(21); | ||
51 | hd->Draw("E1"); | ||
52 | hd->SetYTitle(o.yaxis.c_str()); | ||
53 | THStack * sta = new THStack("sta",hd->GetTitle()); | ||
54 | TLegend * l = new TLegend(o.legendx1,o.legendy1,o.legendx2,o.legendy2); //0.7,0.1,0.9,0.6); | ||
55 | |||
56 | l->AddEntry(hd, "Data","LP"); | ||
57 | |||
58 | for(size_t j=0;j< s.size() ;j++) | ||
59 | { | ||
60 | if(!s[j].data) | ||
61 | { | ||
62 | TH1F * h = ((TH1F*)s[j].file()->Get(names[i].c_str())); | ||
63 | h->Scale(s[j].scale(data.lumi())); | ||
64 | h->SetLineColor(s[j].color); | ||
65 | h->SetFillColor(s[j].color); | ||
66 | h->Rebin(options[names[i]].rebin); | ||
67 | if(grouped.find(s[j].name)==grouped.end()) { | ||
68 | grouped[s[j].name]=(TH1F *)h->Clone(("_"+names[i]).c_str()); | ||
69 | l->AddEntry(h,s[j].name.c_str(),"F"); | ||
70 | } | ||
71 | else | ||
72 | { | ||
73 | grouped[s[j].name]->Add(h); | ||
74 | } | ||
75 | sta->Add(h); | ||
76 | // h->Draw("same"); | ||
77 | } | ||
78 | } | ||
79 | sta->Draw("same"); | ||
80 | hd->Draw("E1same"); | ||
81 | hd->GetYaxis()->SetRangeUser(options[names[i]].min,options[names[i]].max); | ||
82 | l->Draw(); | ||
83 | |||
84 | |||
85 | std::cout << names[i] << " d: " << hd->Integral() << " "; | ||
86 | THStack * sta2 = new THStack("sta2",hd->GetTitle()); | ||
87 | float tot=0; | ||
88 | float toterr2=0; | ||
89 | |||
90 | for(std::map<std::string,TH1F *>::iterator it = grouped.begin(); it != grouped.end();it++) | ||
91 | { | ||
92 | std::cout << it->first << " " << it->second->Integral() << " | " ; | ||
93 | if(it->second->GetEntries() > 0) { | ||
94 | float er=1.*sqrt(it->second->GetEntries())/it->second->GetEntries()*it->second->Integral(); | ||
95 | toterr2+=er*er; | ||
96 | } | ||
97 | tot+=it->second->Integral(); | ||
98 | sta2->Add(it->second); | ||
99 | } | ||
100 | std::cout << " Tot: " << tot << "+-" << sqrt(toterr2) << " SF: " << hd->Integral()/tot << std::endl; | ||
101 | c = new TCanvas(); | ||
102 | sta2->Draw(); | ||
103 | hd->Draw("E1,same"); | ||
104 | sta2->GetYaxis()->SetRangeUser(options[names[i]].min,options[names[i]].max); | ||
105 | hd->GetYaxis()->SetRangeUser(options[names[i]].min,options[names[i]].max); | ||
106 | l->Draw(); | ||
107 | |||
108 | |||
109 | |||
110 | } | ||
111 | |||
112 | } |