void pion_eff(void) { gROOT->Reset(); //TFile *F1 = new TFile("pion.root"); TChain chain("TRACKING/trkeff"); chain.Add("pion1/pion1.root"); chain.Add("pion2/pion2.root"); chain.Add("pion3/pion3.root"); Double_t Red[5] = { 0.5,1.00,0,0, 0 }; Double_t Green[5] = { 0.1, 0.3, 1., 0., 0.}; Double_t Blue[5] = { 0.1, 0.35, 0.65,0.8,1.0 }; Double_t Length[5] = { 0.00, 0.3, 0.5, 0.85, 1.00 }; Int_t nb=50; TColor::CreateGradientColorTable(5,Length,Red,Green,Blue,nb); // If we are not already in the TRACKING directory, cd there //TDirectoryFile *TRACKING = (TDirectoryFile*)F1->Get("TRACKING"); //if(TRACKING)TRACKING->cd(); // Get pointer to trkeff tree //TTree *trkeff = (TTree*)TRACKING->Get("trkeff"); // Create histograms to calculate efficiency TH2D *np = new TH2D("np","Numerator", 70,0,140,60,0,6); TH2D *dp = new TH2D("dp","Denominator",70,0,140,60,0,6); TH2D *npcut = new TH2D("npcut","numerator",70,0,140,60,0,6); TH1D *prob = new TH1D("prob","prob",1000,0,1); chain.Project("prob","TMath::Prob(F.trktb.trk_chisq,F.trktb.trk_Ndof)"); chain.Project("np", "F.pthrown.Mag():180./3.14159*F.pthrown.Theta()", "F.trktb.Nfdc>0 || F.trktb.Ncdc>0"); chain.Project("dp", "F.pthrown.Mag():180/3.14159*F.pthrown.Theta()", ""); chain.Project("npcut", "F.pthrown.Mag():180./3.14159*F.pthrown.Theta()", "(F.trktb.Nfdc>0 || F.trktb.Ncdc>0) && TMath::Prob(F.trktb.trk_chisq,F.trktb.trk_Ndof)>0.001"); TH2D *effp = (TH2D *)np->Clone("effp"); TCanvas *c3 = new TCanvas("c3"); c3->SetTickx(); c3->SetTicky(); c3->SetLogy(); gPad->SetGrid(); prob->SetTitle("Pion probability distribution"); prob->SetXTitle("Confidence level for fit"); prob->Draw(); c3->SaveAs("pion_prob.png"); c3->SaveAs("pion_prob.pdf"); TCanvas *c1 = new TCanvas("c1"); c1->SetTickx(); c1->SetTicky(); gPad->SetGrid(); effp->Divide(dp); effp->SetMarkerStyle(2); effp->SetStats(0); //gStyle->SetPalette(1,0); effp->SetContour(nb); effp->SetTitle("Pion reconstruction efficiency"); effp->SetXTitle("#theta [degrees]"); effp->SetYTitle("p [GeV/c]"); effp->Draw("colz"); gPad->SetGrid(); c1->SaveAs("pion_efficiency.png"); c1->SaveAs("pion_efficiency.pdf"); TH2D *effpcut = (TH2D *)npcut->Clone("effpcut"); TCanvas *c2 = new TCanvas("c2"); c2->SetTickx(); c2->SetTicky(); gPad->SetGrid(); effpcut->Divide(dp); effpcut->SetMarkerStyle(2); effpcut->SetStats(0); effpcut->SetContour(nb); effpcut->SetTitle("Pion reconstruction efficiency, P(#chi^2)>0.001"); effpcut->SetXTitle("#theta [degrees]"); effpcut->SetYTitle("p [GeV/c]"); effpcut->Draw("colz"); c2->SaveAs("pion_efficiency_with_chi2_cut.png"); c2->SaveAs("pion_efficiency_with_chi2_cut.pdf"); ofstream ofile("pion_eff.txt"); ofile << "" <Single track reconstruction" <Pion events" <GetEntries()/dp->GetEntries(); ofile <<"

Overall efficiency = "<"<GetEntries()/dp->GetEntries(); ofile <<" Efficiency (Prob>0.001) = "<" << endl; ofile << "
" << endl; ofile <<"" <" <