Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
efficiency.C
Go to the documentation of this file.
1 
2 
3 void efficiency(void)
4 {
5  gROOT->Reset();
6  gStyle->SetPalette(1,NULL);
7 
8  // Open ROOT file and get pointer to tree
9  TFile *f = new TFile("hd_root.root");
10  f->cd("TRACKING");
11  TTree *trkeff = (TTree*)gROOT->FindObject("trkeff");
12 
13  // It turns out that the resolutions used to determine the pulls
14  // could be off which in turn, leads to an inaccurate chisq
15  // and an inaccurate efficiency. To avoid this, we first fit the
16  // pulls to gaussians in order to determine thier sigmas (which
17  // really should be 1). These are then used to scale the event
18  // by event pulls such that they are equivalent to sigma=1 and
19  // the chisq re-calculated for use in determining the efficiency.
20  double sigma_pt_pull = 1.0;
21  double sigma_theta_pull = 1.0;
22  double sigma_phi_pull = 1.0;
23 
24  TH1D *h = new TH1D("h","",200, -10.0, 10.0);
25  TCut cut1 = "isreconstructable==1";
26 
27  // sigma pt_pull
28  trkeff->Project("h","pt_pull", cut1);
29  h->Fit("gaus","0Q");
30  sigma_pt_pull = h->GetFunction("gaus")->GetParameter(2);
31 
32  // sigma sigma_theta_pull
33  trkeff->Project("h","theta_pull", cut1);
34  h->Fit("gaus","0Q");
35  sigma_theta_pull = h->GetFunction("gaus")->GetParameter(2);
36 
37  // sigma pt_pull
38  trkeff->Project("h","phi_pull", cut1);
39  h->Fit("gaus","0Q");
40  sigma_phi_pull = h->GetFunction("gaus")->GetParameter(2);
41 
42  cout<<"sigma_pt_pull="<<sigma_pt_pull<<" sigma_theta_pull="<<sigma_theta_pull<<" sigma_phi_pull="<<sigma_phi_pull<<endl;
43 
44  char chisq_str[256];
45  char cut_str[256];
46  sprintf(chisq_str, "((pow(pt_pull/%f,2.0) + pow(theta_pull/%f,2.0) + pow(phi_pull/%f,2.0))/3.0)", sigma_pt_pull, sigma_theta_pull, sigma_phi_pull);
47  sprintf(cut_str, "%s<50.0", chisq_str);
48  TCut cut2 = cut_str;
49 
50  TH2D *found_vs_pt_vs_theta = new TH2D("found_vs_pt_vs_theta","", 80, 0.0, 160.0, 30, 0.0, 5.0);
51  TH2D *thrown_vs_pt_vs_theta = found_vs_pt_vs_theta->Clone("thrown_vs_pt_vs_theta");
52  TH2D *eff_vs_pt_vs_theta = found_vs_pt_vs_theta->Clone("eff_vs_pt_vs_theta");
53 
54  trkeff->Project("found_vs_pt_vs_theta", "E.pthrown.Perp():E.pthrown.Theta()*57.3", cut1 && cut2);
55  trkeff->Project("thrown_vs_pt_vs_theta", "E.pthrown.Perp():E.pthrown.Theta()*57.3", cut1);
56  eff_vs_pt_vs_theta->Divide(found_vs_pt_vs_theta, thrown_vs_pt_vs_theta);
57 
58  eff_vs_pt_vs_theta->SetStats(0);
59  eff_vs_pt_vs_theta->GetZaxis()->SetRangeUser(0.8, 1.0);
60  eff_vs_pt_vs_theta->Draw("colz");
61 
62  int maxbin = eff_vs_pt_vs_theta->GetMaximumBin();
63  cout<<"Maximum efficiency:"<<eff_vs_pt_vs_theta->GetBinContent(maxbin)<<endl;
64 
65  //trkeff->Draw(chisq_str, cut1&&"chisq<1000000.0");
66 }
67 
void trkeff(int pid)
Definition: trkeff.C:1
sprintf(text,"Post KinFit Cut")
TF1 * f
Definition: FitGains.C:21
void efficiency(void)
Definition: efficiency.C:3