Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ana.C
Go to the documentation of this file.
1 using namespace std;
2 
3 double ratio_error(
4  const double a,
5  const double b,
6  const double ea,
7  const double eb
8  ) {
9  double r = a/b;
10  double er = r*sqrt(
11  (ea/a)*(ea/a) + (eb/b)*(eb/b)
12  );
13  return er;
14 }
15 
16 double binom_error(
17  const double a,
18  const double b
19  ){
20  double r=a/b;
21  return sqrt(r*(1-r)/b);
22 }
23 
24 TH1D * getEffHist(
25  const char* hname,
26  const TH1D* h1,
27  const TH1D* h2
28  ) {
29  TH1D *h = h1->Clone(hname);
30  int nbin = h->GetNbinsX();
31  for(int ibin=1; ibin<=nbin; ++ibin) {
32  double a = h1->GetBinContent(ibin);
33  double b = h2->GetBinContent(ibin);
34  double r = a/b;
35  double e = binom_error(a, b);
36  h->SetBinContent(ibin, r);
37  h->SetBinError(ibin, e);
38  }
39 
40  return h;
41 }
42 
44 
45  int n = 3;
46  float y[] = { 43.0, 23.6, 11.6};
47  float x[] = { 0, 2, 3};
48 
49  float y_error[] = { 0, 0, 0, 0, 0, 0};
50  float x_error[] = { 0, 0, 0, 0, 0, 0};
51 
52  for(int i=0;i<n;++i) {
53  y_error[i] = 0.1*y[i];
54  }
55 
56  TCanvas *c0 = new TCanvas("drawTimeNumber", "drawTimeNumber");
57  TGraphErrors* gr = new TGraphErrors(n, x, y, x_error, y_error);
58  gr->SetTitle(";DS level ; Time/event [sec.]");
59  gr->SetMarkerStyle(20);
60  gr->Draw("ap");
61  //gr->SetMaximum(2);
62  //gr->GetXaxis()->SetRangeUser(-5,11);
63  //TF1 *fpol = new TF1("fpol","[0]*pow(x,[1])+[2]");
64  //gr->Fit(fpol);
65 }
66 
67 void drawTimeMul() {
68 
69  int n = 6;
70  float y[] = { 0.074, 0.207, 0.913, 5.503, 10.950, 46.440};
71  float y_error[] = { 0, 0, 0, 0, 0, 0};
72  float x[] = { 1, 2, 5, 8, 10, 20};
73  float x_error[] = { 0, 0, 0, 0, 0, 0};
74 
75  for(int i=0;i<n;++i) {
76  y[i] /= x[i];
77  y_error[i] = 0.1*y[i];
78  }
79 
80  TCanvas *c0 = new TCanvas("drawTimeMul", "drawTimeMul");
81  TGraphErrors* gr = new TGraphErrors(n, x, y, x_error, y_error);
82  gr->SetTitle(";multiplicity ; Time/event/particle [sec.]");
83  gr->SetMarkerStyle(20);
84  gr->Draw("ap");
85  gr->SetMaximum(2);
86  //gr->GetXaxis()->SetRangeUser(-5,11);
87  TF1 *fpol = new TF1("fpol","[0]*pow(x,[1])+[2]");
88  gr->Fit(fpol);
89 }
90 
92  const char* name,
93  const char* cut
94  ) {
95 
96  int n = 2;
97  char* inputs [] = {
98  "no_event_reducer/T7_2_res222_ds0_200/ktracker_ana.root",
99  "no_event_reducer/T7_2_res222_ds2_200/ktracker_ana.root"
100  //"T1_1_res222_ds0_100_b2/ktracker_ana.root",
101  //"T1_1_res222_ds2_100_b2/ktracker_ana.root"
102  };
103  float x[] = { 0, 2};
104 
105  float y[] = { 0, 0, 0, 0, 0, 0};
106  float y_error[] = { 0, 0, 0, 0, 0, 0};
107  float x_error[] = { 0, 0, 0, 0, 0, 0};
108 
109  for(int i=0;i<n;++i) {
110  TFile *f = TFile::Open(inputs[i],"read");
111  TH1D *h = new TH1D("h","h",50,-0.5,49.5);
112  TNtuple *T = (TNtuple*) f->Get("Event");
113  T->Project("h",name,cut);
114  y[i] = h->GetMean();
115  y_error[i] = h->GetMeanError();
116  }
117 
118  TCanvas *c0 = new TCanvas(name, name);
119  c0->SetGridy();
120  //c0->SetLogy();
121  TGraphErrors* gr = new TGraphErrors(n, x, y, x_error, y_error);
122  gr->SetTitle(";DS Level ; Time/event [sec.]");
123  gr->SetMarkerStyle(20);
124  gr->Draw("ap");
125  gr->SetMaximum(20);
126  gr->SetMinimum(0);
127  gr->GetXaxis()->SetRangeUser(-1,4);
128  gr->Print();
129 }
130 
131 
132 void drawEffMul() {
133 
134  int n = 6;
135  char* inputs [] = {
136  "batch1/mu1/trk_eval.root",
137  "batch1/mu2/trk_eval.root",
138  "batch1/mu5/trk_eval.root",
139  "batch1/mu8/trk_eval.root",
140  "batch1/mu10/trk_eval.root",
141  "batch1/mu20/trk_eval.root"
142  };
143 
144  float y[] = { 0, 0, 0, 0, 0, 0};
145  float y_error[] = { 0, 0, 0, 0, 0, 0};
146  float x[] = { 1, 2, 5, 8, 10,20};
147  float x_error[] = { 0, 0, 0, 0, 0, 0};
148 
149  for(int i=0;i<n;++i) {
150  TFile *f = TFile::Open(inputs[i],"read");
151  TH1D *h = new TH1D("h","h",2,-0.5,1.5);
152  T->Project("h","ntruhits>0","gndc>=18");
153  y[i] = h->GetMean();
154  y_error[i] = h->GetMeanError();
155  }
156 
157  TCanvas *c0 = new TCanvas("drawEffMul", "drawEffMul");
158  TGraphErrors* gr = new TGraphErrors(n, x, y, x_error, y_error);
159  gr->SetTitle(";multiplicity ; Eff.");
160  gr->SetMarkerStyle(20);
161  gr->Draw("ap");
162  gr->SetMaximum(1.5);
163  gr->SetMinimum(0);
164 }
165 
166 
168 
169  int n = 6;
170  char* inputs [] = {
171  "st123/0.0cm/trk_eval.root"
172  ,"st123/.15cm/trk_eval.root"
173  ,"st123/0.1cm/trk_eval.root"
174  ,"st123/0.2cm/trk_eval.root"
175  ,"st123/0.5cm/trk_eval.root"
176  ,"st123/1.0cm/trk_eval.root"
177  };
178 
179  float y[] = { 0, 0, 0, 0, 0, 0};
180  float y_error[] = { 0, 0, 0, 0, 0, 0};
181  float x[] = { 0, 0.1, 0.15, 0.2, 0.5, 1};
182  float x_error[] = { 0, 0, 0, 0, 0, 0};
183 
184  for(int i=0;i<n;++i) {
185  TFile *f = TFile::Open(inputs[i],"read");
186  TH1D *h = new TH1D("h","h",2,-0.5,1.5);
187  T->Project("h","ntruhits>0","gndc>=18");
188  y[i] = h->GetMean();
189  y_error[i] = h->GetMeanError();
190  }
191 
192  TCanvas *c0 = new TCanvas("drawEffDS123Survey", "drawEffDS123Survey");
193  c0->SetGridy();
194  TGraphErrors* gr = new TGraphErrors(n, x, y, x_error, y_error);
195  gr->SetTitle("; X0 shift [cm] ; Eff.");
196  gr->SetMarkerStyle(20);
197  gr->Draw("ap");
198  gr->SetMaximum(1.1);
199  gr->SetMinimum(0);
200 }
201 
202 
204  const char* tree = "T",
205  const char* var = "pz<500",
206  const char* cut = "krecstat!=-1&&gndc>=18"
207 
208  ) {
209 
210  int n = 4;
211  char* inputs [] = {
212  "emb0_ds0_er1.root",
213  "emb0_ds2_er1.root",
214  "emb1_ds0_er1/trk_eval.root",
215  "emb1_ds2_er1/trk_eval.root"
216  };
217 
218  float x[] = { 1, 2, 3, 4};
219 
220  float x_error[] = { 0, 0, 0, 0, 0, 0};
221  float y[] = { 0, 0, 0, 0, 0, 0};
222  float y_error[] = { 0, 0, 0, 0, 0, 0};
223 
224  float ref_mean = 1.0;
225 
226  for(int i=0;i<n;++i) {
227  TFile *f = TFile::Open(inputs[i],"read");
228  TH1D *h = new TH1D("h","h",2,-0.5,1.5);
229  TTree *T = (TTree*) f->Get(tree);
230  T->Project("h", var, cut);
231  //if(i==0) ref_mean = h->GetMean();
232  y[i] = h->GetMean()/ref_mean;
233  y_error[i] = h->GetMeanError()/ref_mean;
234  }
235 
236  TCanvas *c0 = new TCanvas("EffDSLevel", "EffDSLevel");
237  c0->SetGridy();
238  TGraphErrors* gr = new TGraphErrors(n, x, y, x_error, y_error);
239  gr->SetTitle("; Category; Eff.");
240  gr->SetMarkerStyle(20);
241  gr->Draw("ap");
242  gr->SetMaximum(1.1);
243  gr->SetMinimum(0);
244  gr->GetXaxis()->SetRangeUser(-1,6);
245  gr->Print();
246 }
247 
248 
250 
251  int n = 4;
252  char* inputs [] = {
253  "st23/0.0cm/trk_eval.root"
254  ,"st23/0.5cm/trk_eval.root"
255  ,"st23/1.0cm/trk_eval.root"
256  ,"st23/2.0cm/trk_eval.root"
257  };
258 
259  float y[] = { 0, 0, 0, 0, 0, 0};
260  float y_error[] = { 0, 0, 0, 0, 0, 0};
261  float x[] = { 0, 0.5, 1, 2};
262  float x_error[] = { 0, 0, 0, 0, 0, 0};
263 
264  for(int i=0;i<n;++i) {
265  TFile *f = TFile::Open(inputs[i],"read");
266  TH1D *h = new TH1D("h","h",2,-0.5,1.5);
267  T->Project("h","ntruhits>0","gndc>=18");
268  y[i] = h->GetMean();
269  y_error[i] = h->GetMeanError();
270  }
271 
272  TCanvas *c0 = new TCanvas("drawEffDS23Survey", "drawEffDS23Survey");
273  c0->SetGridy();
274  TGraphErrors* gr = new TGraphErrors(n, x, y, x_error, y_error);
275  gr->SetTitle("; X0 shift [cm] ; Eff.");
276  gr->SetMarkerStyle(20);
277  gr->Draw("ap");
278  gr->SetMaximum(1.1);
279  gr->SetMinimum(0);
280 }
281 
282 
283 void ana() {
284  gStyle->SetOptFit();
285 
286  //drawTimeAna("TEvent","NSt2>=1");
287  drawEffDSLevel("Truth", "px<500", "krecstat!=-1&&gndc>17");
288  //drawEffDSLevel("Truth", "px<500", "Sum$(hodo_mask>0&&detectorID<31&&truth_z<5000)>17");
289 
290  //drawTimeNumber();
291 
292  //drawEffDS23Survey();
293  //drawEffDS123Survey();
294 
295  //drawEffMul();
296  //drawTimeMul();
297 }
TH1D * getEffHist(const char *hname, const TH1D *h1, const TH1D *h2)
Definition: ana.C:24
void drawEffDSLevel(const char *tree="T", const char *var="pz<500", const char *cut="krecstat!=-1&&gndc>=18")
Definition: ana.C:203
void drawEffDS23Survey()
Definition: ana.C:249
double binom_error(const double a, const double b)
Definition: ana.C:16
void drawEffDS123Survey()
Definition: ana.C:167
void drawTimeAna(const char *name, const char *cut)
Definition: ana.C:91
void drawEffMul()
Definition: ana.C:132
void ana()
Definition: ana.C:291
void drawTimeMul()
Definition: ana.C:67
double ratio_error(const double a, const double b, const double ea, const double eb)
Definition: ana.C:3
void drawTimeNumber()
Definition: ana.C:43