void plot() { TFile *f = new TFile("input.root"); f->ls(); TCanvas *canvas = new TCanvas("canvas","proton range study",200,10,700,500); h2->Draw(); int n; double x, y; double theta_appear_with[100], pcut_appear_with[100]; double theta_appear_without[100], pcut_appear_without[100]; double theta_track_with[100], pcut_track_with[100]; double theta_track_without[100], pcut_track_without[100]; ifstream input("pcut_appear_wcf.dat"); if (!input) { cout << "could not open file\n"; return 1; } n = 0; while (input >> x >> y) { // cout << n << ' ' << x << ' ' << y << ' ' << endl; theta_appear_with[n] = x; pcut_appear_with[n] = y/1000.; n++; } input.close(); TGraph *grw = new TGraph(n, theta_appear_with, pcut_appear_with); grw->SetLineColor(2); grw->Draw(); ifstream input("pcut_appear_wocf.dat"); if (!input) { cout << "could not open file\n"; return 1; } n = 0; while (input >> x >> y) { // cout << n << ' ' << x << ' ' << y << ' ' << endl; theta_appear_without[n] = x; pcut_appear_without[n] = y/1000.; n++; } input.close(); TGraph *grwo = new TGraph(n, theta_appear_without, pcut_appear_without); grwo->SetLineColor(4); grwo->Draw(); ifstream input("pcut_track_wcf.dat"); if (!input) { cout << "could not open file\n"; return 1; } n = 0; while (input >> x >> y) { // cout << n << ' ' << x << ' ' << y << ' ' << endl; theta_track_with[n] = x; pcut_track_with[n] = y/1000.; n++; } input.close(); TGraph *grtw = new TGraph(n, theta_track_with, pcut_track_with); grtw->SetLineColor(1); grtw->Draw(); ifstream input("pcut_track_wocf.dat"); if (!input) { cout << "could not open file\n"; return 1; } n = 0; while (input >> x >> y) { // cout << n << ' ' << x << ' ' << y << ' ' << endl; theta_track_without[n] = x; pcut_track_without[n] = y/1000.; n++; } input.close(); TGraph *grtwo = new TGraph(n, theta_track_without, pcut_track_without); grtwo->SetLineColor(3); grtwo->Draw(); canvas->Print("sc_study_cut.png", "png"); TEfficiency* eff_appear_without = new TEfficiency("effawo","efficiency;theta;#epsilon",90,0,90); TEfficiency* eff_appear_with = new TEfficiency("effaw","efficiency;theta;#epsilon",90,0,90); TEfficiency* eff_track_without = new TEfficiency("efftwo","efficiency;theta;#epsilon",90,0,90); TEfficiency* eff_track_with = new TEfficiency("efftw","efficiency;theta;#epsilon",90,0,90); TH1F* h1pa = new TH1F("h1pa","proton polar angle",90,0,90); float thrange = theta_appear_without[n-1] - theta_appear_without[0]; float thbin = thrange/(float)(n - 1); float thhalfbin = 0.5*thbin; float thmin = theta_appear_without[0] - thhalfbin; cout << "binning params: " << thrange << ' ' << thbin << endl; int ibin; bool pass; int nev = ntuple->GetEntries(); float weight = 5./(double)nev; float theta0, ptot0; // define some counters int naw = 0, nawo = 0, ntw = 0, ntwo = 0; ntuple->SetBranchAddress("theta",&theta0); ntuple->SetBranchAddress("ptot",&ptot0); for (int i = 0; i < nev; i++) { ntuple->GetEntry(i); h1pa->Fill(theta0, weight); ibin = (int)((theta0-thmin)/thbin); if (i < 3) { cout << i << ' ' << theta0 << ' ' << ptot0 << endl; cout << " " << ibin << ' ' << theta_appear_without[ibin] << ' ' << pcut_appear_without[ibin] << endl; } if (ptot0 >= pcut_appear_without[ibin]) {pass = true; nawo++;} else {pass = false;} eff_appear_without->Fill(pass, theta0); if (ptot0 >= pcut_appear_with[ibin]) {pass = true; naw++;} else {pass = false;} eff_appear_with->Fill(pass, theta0); if (ptot0 >= pcut_track_without[ibin]) {pass = true; ntwo++;} else {pass = false;} eff_track_without->Fill(pass, theta0); if (ptot0 >= pcut_track_with[ibin]) {pass = true; ntw++;} else {pass = false;} eff_track_with->Fill(pass, theta0); } eff_appear_without->SetMarkerColor(4); eff_appear_without->SetMarkerStyle(20); eff_appear_without->SetMarkerSize(1); eff_appear_without->Draw(); eff_appear_with->SetMarkerColor(2); eff_appear_with->SetMarkerStyle(20); eff_appear_with->SetMarkerSize(1); eff_appear_with->Draw("same"); eff_track_without->SetMarkerColor(3); eff_track_without->SetMarkerStyle(20); eff_track_without->SetMarkerSize(1); eff_track_without->Draw("same"); eff_track_with->SetMarkerColor(1); eff_track_with->SetMarkerStyle(20); eff_track_with->SetMarkerSize(1); eff_track_with->Draw("same"); h1pa->Draw("same"); canvas->Print("sc_study_eff.png", "png"); // overall efficiencies float fnev = (float)nev; float eaw = naw/fnev, eawo = nawo/fnev, etw = ntw/fnev , etwo = ntwo/fnev; cout << "overall efficiencies:" << " eawo = " << eawo << " eaw = " << eaw << " etwo = " << etwo << " etw = " << etw << endl; }