FairRoot/PandaRoot
toy_core_ntp.C
Go to the documentation of this file.
1 #include <iostream>
2 #include <fstream>
3 #include <vector>
4 #include <map>
5 
6 #include "TFile.h"
7 #include "TTree.h"
8 #include "TRandom3.h"
9 #include "TDatabasePDG.h"
10 #include "TParticlePDG.h"
11 #include "TCanvas.h"
12 #include "TH1F.h"
13 #include "TH2F.h"
14 #include "TLegend.h"
15 #include "TParticle.h"
16 #include "TClonesArray.h"
17 #include "TF1.h"
18 #include "TStyle.h"
19 #include "TNtuple.h"
20 #include "TLatex.h"
21 #include "TGaxis.h"
22 #include "TEventList.h"
23 
24 using std::cout;
25 using std::endl;
26 
27 TRandom3 fRand;
28 TLorentzVector fIni;
29 
30 // *** some program parameters
31 const int fMAX = 100; // *** max tracks per event
32 int nbins = 300; // *** bins of mass histograms
33 double low = 0.0; // *** lower edge of histo
34 double high = 6.; // *** higher edge of histo (will be modified acc. to resonance mass)
35 
36 std::map<int, int> evcnt;
37 std::map<TString, TString> cuts;
38 std::map<TString, TString> modes;
39 
40 TString ntpname[10] = {"nphi","nlam","nee","njpsi1","njpsi2","netac","nd0","ndpm","nds","nlamc"};
41 TString plotname[10] = {"phim","lamm","eem","jpsi1m","jpsi2m","etacm","d0m","dm" ,"dsm","lamcm"};
42 
43 // *** setup style
44 void setStyle()
45 {
46  gStyle->SetPadTopMargin(0.13);
47  gStyle->SetPadBottomMargin(0.18);
48  gStyle->SetPadLeftMargin(0.2);
49  gStyle->SetPadRightMargin(0.016);
50 
51  gStyle->SetLabelSize(0.076,"X");
52  gStyle->SetLabelSize(0.07,"Y");
53 
54  gStyle->SetStatY(0.87);
55  gStyle->SetStatX(0.986);
56  gStyle->SetStatW(0.4);
57  gStyle->SetStatH(0.12);
58  gStyle->SetOptStat("e"); // only entries
59 
60  gStyle->SetTitleH(0.1);
61  gStyle->SetTitleX(0.08);
62  gStyle->SetTitleOffset(1.1,"x");
63  gStyle->SetTitleXSize(0.076);
64 }
65 
66 void configHisto(TH1* h)
67 {
68  h->SetFillStyle(3001);
69  h->SetFillColor(602);
70  h->SetLineStyle(3);
71  h->SetLineColor(602);
72 /* TGaxis *ax = (TGaxis*)h->GetYaxis();
73  ax->SetMaxDigits(2);*/
74 }
75 
76 void init_modes()
77 {
78  modes["nphi"] = "000";
79  modes["nlam"] = "400";
80  modes["nee"] = "300";
81  modes["njpsi1"] = "200";
82  modes["njpsi2"] = "201";
83  modes["netac"] = "221";
84  modes["nd0"] = "100";
85  modes["ndpm"] = "120";
86  modes["nds"] = "140";
87  modes["nlamc"] = "420";
88 
89  modes["DPM"] = "900";
90 }
91 
93 {
94  if (energy=="24")
95  {
96  cuts["nphi"] = "pmax<0.6&&phipcm>0.55&&phipcm<0.7";
97  cuts["nlam"] = "abs(lampcm-0.44)<0.04&&fw1>0.1&&fw2>0.1";
98  cuts["nee"] = "1";
99  }
100  else if (energy=="38")
101  {
102  cuts["nphi"] = "thr>0.87&&phipcm>1.35&&phip>0.8";
103  cuts["nlam"] = "fw2>0.66&&fw5>0.21&&lampcm>1.4&&fw1<0.75";
104  cuts["nee"] = "1";
105  cuts["njpsi1"] = "1";
106  cuts["njpsi2"] = "1";
107  cuts["netac"] = "sumpc>3.3&&ptmax>0.83&&etace>5.5";
108  cuts["nd0"] = "abs(d0pcm-0.275)<0.045&&d0e>3.1&&ptmax>0.68&&pmax>0.85";
109  cuts["ndpm"] = "abs(dpcm-0.23)<0.03&&de>3.3&&ptmax>0.58&&pmax<0.8";
110 
111  }
112  else if (energy=="45")
113  {
114  cuts["nphi"] = "thr>0.93&&phipcm>1.8";
115  cuts["nlam"] = "lampcm>1.7&&fw2>0.75&&lamtht>0.09&&fw4>0.5&&pmax>1.4";
116  cuts["nee"] = "1";
117  cuts["njpsi1"] = "sumpc>3";
118  cuts["njpsi2"] = "sumpc>3";
119  cuts["netac"] = "sumptc>3&&ptmax>0.7&&sumpc>4.1&&ptmax>0.85";
120  cuts["nd0"] = "abs(d0pcm-1.28)<0.09&&ptmax>1&&sumpt>3&&d0tht<0.31";
121  cuts["ndpm"] = "abs(dpcm-1.25)<0.05&&ptmax>0.87&&abs(dp-5)<2&&dpt>1.1";
122  cuts["nds"] = "abs(dspcm-1.1)<0.07&&ptmax>0.85&&dspt>0.8&&dstht<0.27";
123  }
124  else if (energy=="55")
125  {
126  cuts["nphi"] = "thr>0.955&&phipcm>2";
127  cuts["nlam"] = "fw2>0.87&&sumptc>0.9&&lampcm>2.2&&fw1>-0.1";
128  cuts["nee"] = "1";
129  cuts["njpsi1"] = "sumptc>2.1&&pmax>1.5";
130  cuts["njpsi2"] = "sumptc>2.1&&pmax>1.5";
131  cuts["netac"] = "ptmax>1&&sumptc>2.6&&sumpc>4.9";
132  cuts["nd0"] = "d0pcm>1.8&&sumpt>2.7&&ptmax>0.8&&d0pt>1.3&&d0tht<0.41";
133  cuts["ndpm"] = "dpcm>1.9&&dp>4&&ptmax>0.7&&dtht>0.09";
134  cuts["nds"] = "dspcm>1.8&&ptmax>0.8&&dsp>3&&dspt>1&&dspcm<2.1";
135  cuts["nlamc"] = "lamcpcm>1.43&&lamcpcm<1.65&&fw1>0&&lamcpt>1.27";
136 
137  }
138  else
139  {
140  cuts["nphi"] = "1";
141  cuts["nlam"] = "1";
142  cuts["nee"] = "1";
143  cuts["njpsi1"] = "1";
144  cuts["njpsi2"] = "1";
145  cuts["netac"] = "1";
146  cuts["nd0"] = "1";
147  cuts["ndpm"] = "1";
148  cuts["nds"] = "1";
149  cuts["nlamc"] = "1";
150  }
151 }
152 
154 {
155  if (energy=="24")
156  {
157  cuts["nphi"] = "pmax<0.6&&phipcm>0.55&&phipcm<0.7";
158  cuts["nlam"] = "abs(lampcm-0.44)<0.04&&fw1>0.1&&fw2>0.1";
159  cuts["nee"] = "1";
160  }
161  else if (energy=="38")
162  {
163  cuts["nphi"] = "thr>0.87&&phipcm>1.35&&phip>0.8";
164  cuts["nlam"] = "fw2>0.66&&fw5>0.21&&lampcm>1.4&&fw1<0.75";
165  cuts["nee"] = "1";
166  cuts["njpsi1"] = "1";
167  cuts["njpsi2"] = "1";
168  cuts["netac"] = "etace>4.95&&sumpc>2.9&&etacpcm<0.75&&sumptc>1.63";
169  cuts["nd0"] = "abs(d0pcm-0.285)<0.085&&d0e>3.2&&ptmax>0.415";
170  cuts["ndpm"] = "abs(dpcm-0.2425)<0.0625&&dp>2.65&&ptmax>0.3&&de>3.25";
171 
172  }
173  else if (energy=="45")
174  {
175  cuts["nphi"] = "thr>0.93&&phipcm>1.8";
176  cuts["nlam"] = "lampcm>1.7&&fw2>0.75&&lamtht>0.09&&fw4>0.5&&pmax>1.4";
177  cuts["nee"] = "1";
178  cuts["njpsi1"] = "sumpc>3";
179  cuts["njpsi2"] = "sumpc>3";
180  cuts["netac"] = "sumptc>2.06&&ptmax>0.64&&sumpc>3.45&&pmax>0.8&&etace>5";
181  cuts["nd0"] = "abs(d0pcm-1.27)<0.13&&ptmax>0.64&&d0e>2.7";
182  cuts["ndpm"] = "abs(dpcm-1.255)<0.105&&de>2.6&&ptmax>0.48&&dtht<0.33";
183  cuts["nds"] = "abs(dspcm-1.095)<0.096&&dse>2.9&&ptmax>0.39&&dstht<0.28";
184  }
185  else if (energy=="55")
186  {
187  cuts["nphi"] = "thr>0.955&&phipcm>2";
188  cuts["nlam"] = "fw2>0.87&&sumptc>0.9&&lampcm>2.2&&fw1>-0.1";
189  cuts["nee"] = "1";
190  cuts["njpsi1"] = "sumptc>2.1&&pmax>1.5";
191  cuts["njpsi2"] = "sumptc>2.1&&pmax>1.5";
192  cuts["netac"] = "ptmax>0.75&&pmax>1.1&&sumptc>2.8&&sumpc>4";
193  cuts["nd0"] = "d0pcm>1.84&&sumpt>2.1&&d0e>2.1&&ptmax>0.8&&d0tht<0.45";
194  cuts["ndpm"] = "abs(dpcm-2.05)<0.2&&dp>2&&dpt>0.5&&ptmax>0.5";
195  cuts["nds"] = "abs(dspcm-1.96)<0.24&&ptmax>0.55&&dse>3";
196  cuts["nlamc"] = "abs(lamcpcm-1.54)<0.16&&fw1>-0.05&&lamcp>3.3&&sumptc>1.3";
197 
198  }
199  else
200  {
201  cuts["nphi"] = "1";
202  cuts["nlam"] = "1";
203  cuts["nee"] = "1";
204  cuts["njpsi1"] = "1";
205  cuts["njpsi2"] = "1";
206  cuts["netac"] = "1";
207  cuts["nd0"] = "1";
208  cuts["ndpm"] = "1";
209  cuts["nds"] = "1";
210  cuts["nlamc"] = "1";
211  }
212 }
213 
214 
216 {
217  if (energy=="24")
218  {
219  cuts["nphi"] = "pmax<0.56&&phipcm>0.55&&phipcm<0.68";
220  cuts["nlam"] = "lampcm<0.5&&fw1>0.16&&lampcm>0.39";
221  cuts["nee"] = "1";
222 
223  // factor 1000
224 /* cuts["nphi"] = "fw1>0.0129387&&phipt>0.2";
225  cuts["nlam"] = "fw3>0.2&&fw4>0.3&&sumpc>0.9";
226  cuts["nee"] = "1";*/
227  }
228  else if (energy=="38")
229  {
230  cuts["nphi"] = "thr>0.9&&phipcm>1.46";
231  cuts["nlam"] = "thr>0.93&&thr<0.99&&fw5>0.21&&lampcm>1.38&&fw4>0.35";
232  cuts["nee"] = "1";
233  cuts["njpsi1"] = "1";
234  cuts["njpsi2"] = "1";
235  cuts["netac"] = "sumptc>1.68&&ptmax>0.54&&sumpc>2.9";
236  cuts["nd0"] = "d0pcm<0.36&&pmax>0.8&&ptmax>0.42";
237  cuts["ndpm"] = "dpcm<0.32&&dpcm>0.17&&ptmax>0.4&&dp>2.7";
238 
239  // factor 1000
240 /* cuts["nphi"] = "phipcm>1.31489&&phipt>0.698733";
241  cuts["nlam"] = "fw2>0.688083&&lampt>0.990166";
242  cuts["nee"] = "1";
243  cuts["njpsi1"] = "1";
244  cuts["njpsi2"] = "1";
245  cuts["netac"] = "ptmax>0.84&&sumptc>2.9";
246  cuts["nd0"] = "d0pcm<0.35&&ptmax>0.8";
247  cuts["ndpm"] = "dpcm<0.34&&ptmax>0.67&&fw1>0";*/
248 
249  // first attempt
250 /* cuts["netac"] = "ptmax>0.7&&sumptc>2.7";
251  cuts["nd0"] = "d0pcm<0.33&&ptmax>0.75";
252  cuts["ndpm"] = "dpcm<0.31&&ptmax>0.6&&pmin>0.1";*/
253  }
254  else if (energy=="45")
255  {
256  cuts["nphi"] = "thr>0.94&&phipcm>1.85";
257  cuts["nlam"] = "thr>0.95&&fw4>0.53&&pmax>1.1&&sumptc>0.7";
258  cuts["nee"] = "1";
259  cuts["njpsi1"] = "sumpc>3.5";
260  cuts["njpsi2"] = "sumpc>3.5";
261  cuts["netac"] = "sumptc>2.1&&ptmax>0.65&&sumpc>3.4";
262  cuts["nd0"] = "ptmax>0.64&&d0pcm>0.95&&pmax>1&&sumpt>2&&d0pcm<1.4";
263  cuts["ndpm"] = "dpcm>1.1&&dpcm<1.4&&ptmax>0.58";
264  cuts["nds"] = "dspcm>0.9&&dspcm<1.35&&ptmax>0.55";
265 
266  // factor 1000
267 // cuts["nphi"] = "phipcm>1.9&&phipt>1";
268 // cuts["nlam"] = "lampcm>1.8&&thr>0.95&&lampt>1";
269 // cuts["nee"] = "1";
270 // cuts["njpsi1"] = "sumpc>3.5";
271 // cuts["njpsi2"] = "sumpc>3.5";
272 // cuts["netac"] = "ptmax>1&&sumpc>4";
273 // cuts["nd0"] = "abs(d0pcm-1.24)<0.15&&ptmax>1.05&&sumptc>3.1";
274 // cuts["ndpm"] = "abs(dpcm-1.24)<0.12&&dpt>1&&sumptc>3";
275 // cuts["nds"] = "abs(dspcm-1.1)<0.09&&ptmax>0.93";
276 
277  // first attempt cuts["nphi"] = "phipcm>1.9&&phipt>1";
278 /* cuts["nd0"] = "abs(d0pcm-1.24)<0.15&&ptmax>1.2";
279  cuts["ndpm"] = "abs(dpcm-1.24)<0.15&&dpt>1&&pmin>0.15";
280  cuts["nds"] = "abs(dspcm-1.1)<0.1&&ptmax>0.8";*/
281  }
282  else if (energy=="55")
283  {
284  cuts["nphi"] = "thr>0.96&&phipcm>2.3";
285  cuts["nlam"] = "thr>0.97&&pmax>1.6&&sumptc>1.4";
286  cuts["nee"] = "1";
287  cuts["njpsi1"] = "sumpc>4";
288  cuts["njpsi2"] = "sumpc>4";
289  cuts["netac"] = "ptmax>0.8&&sumptc>2.8&&pmax>1.15";
290  cuts["nd0"] = "d0pcm>1.75&&ptmax>0.8&&sumpt>2.4";
291  cuts["ndpm"] = "dpcm>1.8&&ptmax>0.68&&dpcm<2.3&&dpt>0.5";
292  cuts["nds"] = "dspcm>1.75&&dspcm<2.2&&ptmax>0.6";
293  cuts["nlamc"] = "lamcpcm>1.3&&lamcpcm<1.7&&ptmax>0.5&&fw1>-0.02";
294 
295  // factor 1000
296 /* cuts["nphi"] = "phipcm>2.4&&phipt>0.5";
297  cuts["nlam"] = "lampcm>0.23&&thr>0.98&&lampt>1.2";
298  cuts["nee"] = "1";
299  cuts["njpsi1"] = "sumpc>4";
300  cuts["njpsi2"] = "sumpc>4";
301  cuts["netac"] = "ptmax>1.1&&sumpc>4.8";
302  cuts["nd0"] = "ptmax>1&&d0pcm>1.8&&d0pt>1.5";
303  cuts["ndpm"] = "ptmax>1&&dpcm>1.8&&dpt>1.5";
304  cuts["nds"] = "dspcm>1.8&&ptmax>0.8&&dspt>1.2";
305  cuts["nlamc"] = "abs(lamcpcm-1.53)<0.12&&lamcpt>1.3&&fw1>0";*/
306  // first attempt
307 /* cuts["nlamc"] = "abs(lamcpcm-1.53)<0.15&&lamcpt>1.3";*/
308  }
309  else
310  {
311  cuts["nphi"] = "1";
312  cuts["nlam"] = "1";
313  cuts["nee"] = "1";
314  cuts["njpsi1"] = "1";
315  cuts["njpsi2"] = "1";
316  cuts["netac"] = "1";
317  cuts["nd0"] = "1";
318  cuts["ndpm"] = "1";
319  cuts["nds"] = "1";
320  cuts["nlamc"] = "1";
321  }
322 }
323 
324 int cnt_events(TTree* t, TString cut, bool globcnt=false)
325 {
326  Float_t ev;
327  t->Draw(">>el",cut);
328 
329  TEventList *el=(TEventList*)gDirectory->Get("el");
330 
331  t->SetBranchStatus("*",0);
332  t->SetBranchStatus("evt",1);
333  t->SetBranchAddress("evt",&ev);
334 
335  std::map<int, int> sigcnt;
336  for (int j=0;j<el->GetN();++j)
337  {
338  t->GetEntry(el->GetEntry(j));
339  sigcnt[(int)ev]+=1;
340  if (globcnt) evcnt[(int)ev]+=1;
341  }
342  t->SetBranchStatus("*",1);
343  return sigcnt.size();
344 }
345 
346 void fillHistos(TTree *t, TString var, TString cut, TString all, TString sel, TString sig)
347 {
348  t->Project(all,var,cut);
349  t->Project(sel,var,cut+" && tag");
350  t->Project(sig,var,cut+" && mct");
351 }
352 
353 int toy_core_ntp(TString fname, int nev=50, bool tagonly=false)
354 {
355  int i,j;
356  nev*=1000;
357 
358  setStyle();
359  init_modes();
360 
361  TString mode(fname(fname.Last('/')+7,3));
362 
363  TString energy(fname(fname.Last('/')+5,2));
364  double sqrts=energy.Atof();
365 
366 /* cout <<mode<<" "<<energy<<endl;
367  return;*/
368 
369  if (tagonly)
370  init_cuts_1000("");
371  else
372  init_cuts_1000(energy);
373 
374 
375  TFile *f=new TFile(fname);
376  TTree *t[10];
377 
378  for (i=0;i<10;++i)
379  {
380  t[i]=(TTree*)f->Get(ntpname[i]);
381 // cout <<t[i]<<endl;
382  }
383 
384  TCanvas *c2=new TCanvas("c2","c2",20,20,1800,800);
385  c2->Divide(5,2,0.005,0.01);
386 
387  double low2=0.5;
388 
389  // ****** Jpsi -> ee
390  TH1F *h_jpsi1=new TH1F("h_jpsi1","J/#psi #rightarrow e^{+}e^{-}",nbins,low,high);
391  TH1F *h_jpsi1sel=new TH1F("h_jpsi1sel","J/psi",nbins,low,high);
392  TH1F *h_jpsi1sig=new TH1F("h_jpsi1sig","J/psi",nbins,low,high);
393  h_jpsi1sig->SetLineColor(2);
394  configHisto(h_jpsi1sel);
395 
396  // ****** Jpsi -> mu mu
397  TH1F *h_jpsi2=new TH1F("h_jpsi2","J/#psi #rightarrow #mu^{+}#mu^{-}",nbins,low,high);
398  TH1F *h_jpsi2sel=new TH1F("h_jpsi2sel","J/psi",nbins,low,high);
399  TH1F *h_jpsi2sig=new TH1F("h_jpsi2sig","J/psi",nbins,low,high);
400  h_jpsi2sig->SetLineColor(2);
401  configHisto(h_jpsi2sel);
402 
403  // ****** eta_c -> Ks K pi
404  TH1F *h_etac=new TH1F("h_etac","#eta_{c} #rightarrow K_{S} K^{+} #pi^{-}",nbins,low,high);
405  TH1F *h_etacsel=new TH1F("h_etacsel","etac",nbins,low,high);
406  TH1F *h_etacsig=new TH1F("h_etacsig","etac",nbins,low,high);
407  h_etacsig->SetLineColor(2);
408  configHisto(h_etacsel);
409 
410  // ****** D0 -> K- pi+
411  TH1F *h_d0=new TH1F("h_d0","D^{0} #rightarrow K^{-}#pi^{+}",nbins,low,high);
412  TH1F *h_d0sel=new TH1F("h_d0sel","D0",nbins,low,high);
413  TH1F *h_d0sig=new TH1F("h_d0sig","D0",nbins,low,high);
414  h_d0sig->SetLineColor(2);
415  configHisto(h_d0sel);
416 
417  // ****** D+ -> K- pi+ pi+
418  TH1F *h_dpm=new TH1F("h_dpm","D^{+} #rightarrow K^{-}#pi^{+}#pi^{+}",nbins,low,high);
419  TH1F *h_dpmsel=new TH1F("h_dpmsel","D#pm",nbins,low,high);
420  TH1F *h_dpmsig=new TH1F("h_dpmsig","D#pm",nbins,low,high);
421  h_dpmsig->SetLineColor(2);
422  configHisto(h_dpmsel);
423 
424  // ****** Ds+ -> K+ K- pi+
425  TH1F *h_ds=new TH1F("h_ds","D_{s}^{+} #rightarrow K^{+}K^{-}#pi^{+}",nbins,low,high);
426  TH1F *h_dssel=new TH1F("h_dssel","Ds",nbins,low,high);
427  TH1F *h_dssig=new TH1F("h_dssig","Ds",nbins,low,high);
428  h_dssig->SetLineColor(2);
429  configHisto(h_dssel);
430 
431  // ****** phi -> K+ K-
432  TH1F *h_phi=new TH1F("h_phi","#phi #rightarrow K^{+}K^{-}",nbins,low2,high/2);
433  TH1F *h_phisel=new TH1F("h_phisel","Phi",nbins,low2,high/2);
434  TH1F *h_phisig=new TH1F("h_phisig","Phi",nbins,low2,high/2);
435  h_phisig->SetLineColor(2);
436  configHisto(h_phisel);
437 
438  // ****** Lambda_c -> p K- pi+
439  TH1F *h_lamc=new TH1F("h_lamc","#Lambda_{c} #rightarrow pK^{-}#pi^{+}",nbins,low,high);
440  TH1F *h_lamcsel=new TH1F("h_lamcsel","Lam_c",nbins,low,high);
441  TH1F *h_lamcsig=new TH1F("h_lamcsig","Lam_c",nbins,low,high);
442  h_lamcsig->SetLineColor(2);
443  configHisto(h_lamcsel);
444 
445  // ****** Lambda -> p pi-
446  TH1F *h_lam=new TH1F("h_lam","#Lambda #rightarrow p#pi^{-}",nbins,low2,high/2);
447  TH1F *h_lamsel=new TH1F("h_lamsel","Lam",nbins,low2,high/2);
448  TH1F *h_lamsig=new TH1F("h_lamsig","Lam",nbins,low2,high/2);
449  h_lamsig->SetLineColor(2);
450  configHisto(h_lamsel);
451 
452  // ****** pp -> e+ e-
453  TH1F *h_ee=new TH1F("h_ee","p#bar{p} #rightarrow e^{+}e^{-}",nbins,low,high*1.2);
454  TH1F *h_eesel=new TH1F("h_eesel","ee",nbins,low,high*1.2);
455  TH1F *h_eesig=new TH1F("h_eesig","ee",nbins,low,high*1.2);
456  h_eesig->SetLineColor(2);
457  configHisto(h_eesel);
458 
459  h_jpsi1->SetXTitle("m(e^{+}e^{-}) [GeV/c^{2}]");
460  h_jpsi2->SetXTitle("m(#mu^{+}#mu^{-}) [GeV/c^{2}]");
461  h_etac->SetXTitle("m(K_{S} K^{+}#pi^{-}) [GeV/c^{2}]");
462 
463  h_d0->SetXTitle("m(K^{-}#pi^{+}) [GeV/c^{2}]");
464 
465  h_dpm->SetXTitle("m(K^{-}#pi^{+}#pi^{+}) [GeV/c^{2}]");
466 
467  h_ds->SetXTitle("m(K^{+}K^{-}#pi^{+}) [GeV/c^{2}]");
468 
469  h_phi->SetXTitle("m(K^{+}K^{-}) [GeV/c^{2}]");
470  h_lamc->SetXTitle("m(pK^{-}#pi^{+}) [GeV/c^{2}]");
471  h_lam->SetXTitle("m(p#pi^{-}) [GeV/c^{2}]");
472  h_ee->SetXTitle("m(e^{+}e^{-}) [GeV/c^{2}]");
473 
474  // *** make histos
475  fillHistos(t[0], "phim", cuts["nphi"], "h_phi", "h_phisel", "h_phisig");
476  fillHistos(t[1], "lamm", cuts["nlam"], "h_lam", "h_lamsel", "h_lamsig");
477  fillHistos(t[2], "eem", cuts["nee"], "h_ee", "h_eesel", "h_eesig");
478 
479  if (sqrts>24)
480  {
481  fillHistos(t[3], "jpsi1m", cuts["njpsi1"], "h_jpsi1", "h_jpsi1sel", "h_jpsi1sig");
482  fillHistos(t[4], "jpsi2m", cuts["njpsi2"], "h_jpsi2", "h_jpsi2sel", "h_jpsi2sig");
483  fillHistos(t[5], "etacm", cuts["netac"], "h_etac", "h_etacsel", "h_etacsig");
484  fillHistos(t[6], "d0m", cuts["nd0"], "h_d0", "h_d0sel", "h_d0sig");
485  fillHistos(t[7], "dm", cuts["ndpm"], "h_dpm", "h_dpmsel", "h_dpmsig");
486  }
487 
488  if (sqrts>38)
489  fillHistos(t[8], "dsm", cuts["nds"], "h_ds", "h_dssel", "h_dssig");
490 
491  if (sqrts>45)
492  fillHistos(t[9], "lamcm", cuts["nlamc"], "h_lamc", "h_lamcsel", "h_lamcsig");
493 
494  // event counts
495 
496  double channelcount[10]={0,0,0,0,0,0,0,0,0,0};
497  double eff[10]={0,0,0,0,0,0,0,0,0,0};
498 
499  evcnt.clear();
500  for (i=0;i<3;++i)
501  {
502  channelcount[i]=cnt_events(t[i], cuts[ntpname[i]]+"&&tag", true);
503  cout <<i<< " "<<channelcount[i]<<endl;
504  }
505 
506  if (sqrts>24)
507  for (i=3;i<8;++i)
508  {
509  channelcount[i]=cnt_events(t[i], cuts[ntpname[i]]+"&&tag", true);
510  cout <<i<< " "<<channelcount[i]<<endl;
511  }
512  if (sqrts>38)
513  for (i=8;i<9;++i)
514  {
515  channelcount[i]=cnt_events(t[i], cuts[ntpname[i]]+"&&tag", true);
516  cout <<i<< " "<<channelcount[i]<<endl;
517  }
518  if (sqrts>45)
519  for (i=9;i<10;++i)
520  {
521  channelcount[i]=cnt_events(t[i], cuts[ntpname[i]]+"&&tag", true);
522  cout <<i<< " "<<channelcount[i]<<endl;
523  }
524 
525  double evCnt = evcnt.size();
526  for (i=0;i<10;++i) eff[i]=channelcount[i]/nev*100.;
527 
528  cout <<"all:"<<evCnt<<endl;
529 
530  // ** draw the plots
531  TLatex latex;
532  latex.SetTextSize(0.08);
533  char tmp[200];
534  double offset = 0.1;
535  double pos=3.3, pos2=1.85;
536  double hfac = 0.75;
537 
538 // // *** plot all stuff and write out info
539 // c1->cd(1); h_pi0->Draw(); h_pi0sel->Draw("same"); h_pi0sig->Draw("same");
540 // c1->cd(2); h_ks->Draw(); h_kssel->Draw("same"); h_kssig->Draw("same");
541 
542  c2->cd(2); h_phi->Draw(); h_phisel->Draw("same"); h_phisig->Draw("same");
543  sprintf(tmp,"#epsilon = %4.1f%%",eff[0]);
544  latex.DrawLatex(pos2,h_phi->GetMaximum()*hfac+offset,tmp);
545 
546  c2->cd(1); h_ee->Draw(); h_eesel->Draw("same"); h_eesig->Draw("same");
547  sprintf(tmp,"#epsilon = %4.1f%%",eff[2]);
548  latex.DrawLatex(pos*1.2,h_ee->GetMaximum()*hfac+offset,tmp);
549 
550  c2->cd(9); h_lam->Draw(); h_lamsel->Draw("same"); h_lamsig->Draw("same");
551  sprintf(tmp,"#epsilon = %4.1f%%",eff[1]);
552  latex.DrawLatex(pos2,h_lam->GetMaximum()*hfac+offset,tmp);
553 
554  c2->cd(3); h_etac->Draw(); h_etacsel->Draw("same"); h_etacsig->Draw("same");
555  sprintf(tmp,"#epsilon = %4.1f%%",eff[5]);
556  latex.DrawLatex(pos,h_etac->GetMaximum()*hfac+offset,tmp);
557 
558  c2->cd(4); h_jpsi1->Draw(); h_jpsi1sel->Draw("same"); h_jpsi1sig->Draw("same");
559  sprintf(tmp,"#epsilon = %4.1f%%",eff[3]);
560  latex.DrawLatex(pos,h_jpsi1->GetMaximum()*hfac+offset,tmp);
561 
562  c2->cd(5); h_jpsi2->Draw(); h_jpsi2sel->Draw("same"); h_jpsi2sig->Draw("same");
563  sprintf(tmp,"#epsilon = %4.1f%%",eff[4]);
564  latex.DrawLatex(pos,h_jpsi2->GetMaximum()*hfac+offset,tmp);
565 
566  c2->cd(7); h_dpm->Draw(); h_dpmsel->Draw("same"); h_dpmsig->Draw("same");
567  sprintf(tmp,"#epsilon = %4.1f%%",eff[7]);
568  latex.DrawLatex(pos,h_dpm->GetMaximum()*hfac+offset,tmp);
569 
570  c2->cd(6); h_d0->Draw(); h_d0sel->Draw("same"); h_d0sig->Draw("same");
571  sprintf(tmp,"#epsilon = %4.1f%%",eff[6]);
572  latex.DrawLatex(pos,h_d0->GetMaximum()*hfac+offset,tmp);
573 
574  c2->cd(8); h_ds->Draw(); h_dssel->Draw("same"); h_dssig->Draw("same");
575  sprintf(tmp,"#epsilon = %4.1f%%",eff[8]);
576  latex.DrawLatex(pos,h_ds->GetMaximum()*hfac+offset,tmp);
577 
578  c2->cd(10); h_lamc->Draw(); h_lamcsel->Draw("same"); h_lamcsig->Draw("same");
579  sprintf(tmp,"#epsilon = %4.1f%%",eff[9]);
580  latex.DrawLatex(pos,h_lamc->GetMaximum()*hfac+offset,tmp);
581 
582  // total efficiency in first plot (phi)
583  c2->cd(5);
584  double posy = h_jpsi2->GetMaximum()*1.12;
585  if (posy==0) posy=1.12;
586  sprintf(tmp,"(#epsilon_{t} = %4.1f%%)",double(evCnt)/double(nev)*100.);
587  latex.SetTextColor(kMagenta+2);
588  latex.DrawLatex(3.0,posy,tmp);
589 
590  c2->cd();
591 
592 // TString plot(fname(0,9));
593  TString plot(fname(fname.Last('/')+5,5));
594  if (!tagonly) plot+="_opt_supr1000";
595 
596  c2->SaveAs("figtoy_v2/toy_"+plot+".gif");
597  c2->SaveAs("figtoy_v2/toy_"+plot+".pdf");
598 
599  std::ofstream ofs;
600 
601  ofs.open("toy_supr1000.txt", std::ofstream::out | std::ofstream::app);
602  TString result=TString::Format("%s & %3.1f & %6.2f & %6.2f & %6.2f & %6.2f & %6.2f & %6.2f & %6.2f & %6.2f & %6.2f & %6.2f & %6.2f \\\\\n",
603  mode.Data(), sqrts/10., eff[2], eff[0], eff[5], eff[3], eff[4], eff[6], eff[7], eff[8], eff[1], eff[9], evCnt/nev*100);
604  cout <<result;
605  ofs <<result;
606  ofs.close();
607  return 0;
608 }
609 
610 
TVector3 pos
int modes[]
Definition: evaltrig.C:36
void setStyle()
Definition: crosstag.C:39
Int_t i
Definition: run_full.C:25
TString plotname[10]
Definition: full_core_ntp.C:44
int low
Definition: anaMvdDigi.C:51
void configHisto(TH1 *h)
Definition: full_core_ntp.C:76
TRandom3 fRand
Definition: full_core_ntp.C:28
void init_cuts_1000(TString energy)
int ev
const int fMAX
Definition: full_core_ntp.C:32
c2
Definition: plot_dirc.C:39
TString cuts[MAX]
Definition: autocutx.C:35
TString ntpname[10]
Definition: full_core_ntp.C:43
TVector3 offset(2, 0, 0)
void init_cuts_old(TString energy)
Definition: toy_core_ntp.C:215
double cut[MAX]
Definition: autocutx.C:36
Int_t mode
Definition: autocutx.C:47
int toy_core_ntp(TString fname, int nev=50, bool tagonly=false)
Definition: toy_core_ntp.C:353
TFile * f
Definition: bump_analys.C:12
int nbins
Definition: full_core_ntp.C:33
int cnt_events(TChain *t, TString cut, bool globcnt=false)
TFile * out
Definition: reco_muo.C:20
double high
Definition: full_core_ntp.C:35
TLorentzVector fIni
Definition: full_core_ntp.C:29
TTree * t
Definition: bump_analys.C:13
void fillHistos(TChain *t, TString var, TString cut, TString all, TString sel, TString sig)
CountMap evcnt
Definition: autocutx.C:31
void init_modes()
Definition: full_core_ntp.C:86
void init_cuts_95(TString energy)
Double_t energy
Definition: plot_dirc.C:15