Logo ROOT   6.12/07
Reference Guide
makeExample.C
Go to the documentation of this file.
1 
3 {
4 
5  TFile* file = new TFile("dataDriven.root", "RECREATE");
6 
7  TH1F* FlatHist = new TH1F("FlatHist","FlatHist", 2,0,2);
8  FlatHist->SetBinContent( 1, 1.0 );
9  FlatHist->SetBinContent( 2, 1.0 );
10 
11  TH1F* Signal = new TH1F("Signal", "Signal", 2,0,2);
12  Signal->SetBinContent(1, 10);
13  Signal->SetBinContent(2, 80);
14 
15  // MC Background
16  TH1F* Background1 = new TH1F("Background1", "Background1", 2,0,2);
17  Background1->SetBinContent(1, 20);
18  Background1->SetBinContent(2, 20);
19 
20  // This is the "Data-Driven" measurement
21  // that represents Background2
22  // Assume the extrapolation factor is 1.0
23  TH1F* ControlRegion = new TH1F("ControlRegion", "ControlRegion", 2,0,2);
24  ControlRegion->SetBinContent(1, 75);
25  ControlRegion->SetBinContent(2, 35);
26 
27 
28  TH1F* StatUncert = new TH1F("StatUncert", "StatUncert", 2,0,2);
29  StatUncert->SetBinContent(1, .15); // 15% uncertainty
30  StatUncert->SetBinContent(2, .15); // 15% uncertainty
31 
32 
33  TH1F* data = new TH1F("data", "data", 2,0,2);
34  data->SetBinContent(1, 90);
35  data->SetBinContent(2, 110);
36 
37 
38  file->Write();
39  file->Close();
40 
41 
42 }
43 
44 
45 
47 {
48 
49  TFile* file = new TFile("ShapeSys2D.root", "RECREATE");
50 
51  TH2F* signal = new TH2F("signal", "signal", 2,0,2, 2,0,2);
52  signal->SetBinContent(1, 1, 10);
53  signal->SetBinContent(2, 1, 10);
54  signal->SetBinContent(1, 2, 20);
55  signal->SetBinContent(2, 2, 20);
56 
57  // Background 1
58  TH2F* background1 = new TH2F("background1", "background1", 2,0,2, 2,0,2);
59  background1->SetBinContent(1, 1, 100);
60  background1->SetBinContent(2, 1, 100);
61  background1->SetBinContent(1, 2, 10);
62  background1->SetBinContent(2, 2, 10);
63 
64  // Background 1 Error
65  TH2F* bkg1ShapeError = new TH2F("bkg1ShapeError", "bkg1ShapeError", 2,0,2, 2,0,2);
66  bkg1ShapeError->SetBinContent(1, 1, .10); // 10%
67  bkg1ShapeError->SetBinContent(2, 1, .15); // 15%
68  bkg1ShapeError->SetBinContent(1, 2, .10); // 10%
69  bkg1ShapeError->SetBinContent(2, 2, .15); // 15%
70 
71 
72  // Background 2
73  TH2F* background2 = new TH2F("background2", "background2", 2,0,2, 2,0,2);
74  background2->SetBinContent(1, 1, 10);
75  background2->SetBinContent(2, 1, 10);
76  background2->SetBinContent(1, 2, 100);
77  background2->SetBinContent(2, 2, 100);
78 
79  // Background 2 Error
80  TH2F* bkg2ShapeError = new TH2F("bkg2ShapeError", "bkg2ShapeError", 2,0,2, 2,0,2);
81  bkg2ShapeError->SetBinContent(1, 1, .05); // 5%
82  bkg2ShapeError->SetBinContent(2, 1, .20); // 20%
83  bkg2ShapeError->SetBinContent(1, 2, .05); // 5%
84  bkg2ShapeError->SetBinContent(2, 2, .20); // 20%
85 
86 
87  TH2F* data = new TH2F("data", "data", 2,0,2, 2,0,2);
88  data->SetBinContent(1, 1, 122);
89  data->SetBinContent(2, 1, 122);
90  data->SetBinContent(1, 2, 132);
91  data->SetBinContent(2, 2, 132);
92 
93  file->Write();
94  file->Close();
95 
96 
97 }
98 
99 
101 {
102 
103  TFile* file = new TFile("ShapeSys.root", "RECREATE");
104 
105  TH1F* signal = new TH1F("signal", "signal", 2,0,2);
106  signal->SetBinContent(1, 20);
107  signal->SetBinContent(2, 10);
108 
109  // Background 1
110  TH1F* background1 = new TH1F("background1", "background1", 2,0,2);
111  background1->SetBinContent(1, 100);
112  background1->SetBinContent(2, 0);
113 
114  // Background 1 Error
115  TH1F* bkg1ShapeError = new TH1F("bkg1ShapeError", "bkg1ShapeError", 2,0,2);
116  bkg1ShapeError->SetBinContent(1, .10); // 10%
117  bkg1ShapeError->SetBinContent(2, .15); // 15%
118 
119 
120  // Background 2
121  TH1F* background2 = new TH1F("background2", "background2", 2,0,2);
122  background2->SetBinContent(1, 0);
123  background2->SetBinContent(2, 100);
124 
125  // Background 2 Error
126  TH1F* bkg2ShapeError = new TH1F("bkg2ShapeError", "bkg2ShapeError", 2,0,2);
127  bkg2ShapeError->SetBinContent(1, .05); // 5%
128  bkg2ShapeError->SetBinContent(2, .20); // 20%
129 
130 
131  TH1F* data = new TH1F("data", "data", 2,0,2);
132  data->SetBinContent(1, 122);
133  data->SetBinContent(2, 112);
134 
135  file->Write();
136  file->Close();
137 
138 
139 }
140 
141 
143 {
144 
145  TFile* file = new TFile("StatError.root", "RECREATE");
146 
147  TH1F* FlatHist = new TH1F("FlatHist","FlatHist", 2,0,2);
148  FlatHist->SetBinContent( 1, 1.0 );
149  FlatHist->SetBinContent( 2, 1.0 );
150 
151  TH1F* signal = new TH1F("signal", "signal", 2,0,2);
152  signal->SetBinContent(1, 20);
153  signal->SetBinContent(2, 10);
154 
155  // MC background
156  TH1F* background1 = new TH1F("background1", "background1", 2,0,2);
157  background1->SetBinContent(1, 100);
158  background1->SetBinContent(2, 0);
159 
160  // A small statistical uncertainty
161  TH1F* bkg1StatUncert = new TH1F("bkg1StatUncert", "bkg1StatUncert", 2,0,2);
162  bkg1StatUncert->SetBinContent(1, .05); // 5% uncertainty
163  bkg1StatUncert->SetBinContent(2, .10); // 10% uncertainty
164 
165  // MC background
166  TH1F* background2 = new TH1F("background2", "background2", 2,0,2);
167  background2->SetBinContent(1, 0);
168  background2->SetBinContent(2, 100);
169 
170  TH1F* data = new TH1F("data", "data", 2,0,2);
171  data->SetBinContent(1, 122);
172  data->SetBinContent(2, 112);
173 
174 
175  file->Write();
176  file->Close();
177 
178 
179 }
180 
181 
182 
184  TFile* example = new TFile("example.root","RECREATE");
185  TH1F* data = new TH1F("data","data", 2,1,2);
186  TH1F* signal = new TH1F("signal","signal histogram (pb)", 2,1,2);
187  TH1F* background1 = new TH1F("background1","background 1 histogram (pb)", 2,1,2);
188  TH1F* background2 = new TH1F("background2","background 2 histogram (pb)", 2,1,2);
189  TH1F* statUncert = new TH1F("background1_statUncert", "statUncert", 2,1,2);
190 
191  // run with 1 pb
192  data->SetBinContent(1,122);
193  data->SetBinContent(2,112);
194 
195  signal->SetBinContent(1,20);
196  signal->SetBinContent(2,10);
197 
198  background1->SetBinContent(1,100);
199  background2->SetBinContent(2,100);
200 
201  // A small statistical uncertainty
202  statUncert->SetBinContent(1, .05); // 5% uncertainty
203  statUncert->SetBinContent(2, .05); // 5% uncertainty
204 
205 
206  example->Write();
207  example->Close();
208  //////////////////////
209 
210 
211 }
212 
213 void makeExample(){
214  makeDataDriven();
219 }
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
Definition: THist.hxx:285
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:567
void makeShapeSys2DDataset()
Definition: makeExample.C:46
virtual Int_t Write(const char *name=0, Int_t opt=0, Int_t bufsiz=0)
Write memory objects to this file.
Definition: TFile.cxx:2313
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:249
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
Definition: TH1.cxx:8477
void makeExample()
Definition: makeExample.C:213
void makeShapeSysDataset()
Definition: makeExample.C:100
void makeDataDriven()
Definition: makeExample.C:2
void makeStatErrorDataSet()
Definition: makeExample.C:142
Definition: file.py:1
void makeSimpleExample()
Definition: makeExample.C:183
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content.
Definition: TH2.cxx:2471
THist< 2, float, THistStatContent, THistStatUncertainty > TH2F
Definition: THist.hxx:291
virtual void Close(Option_t *option="")
Close a file.
Definition: TFile.cxx:916