using namespace std; using namespace TMath; void DrawFitReverse(TGraph *g) { TF1* f = g->GetFunction("pol1"); f->SetBit(TF1::kNotDraw); auto gf = new TGraph(); gf->SetLineColor(kRed); gf->SetLineWidth(3); int n = 100; int np = g->GetN(); double x1 = g->GetPointX(0); double x2 = g->GetPointX(np-1); double dx = (x2-x1)/n; double x = x1; for (int i=0; iSetPoint(i,x,f->Eval(x)); x = x+dx; } gf->Draw("L RX"); } void usccaa(){ auto in = new TFile("EfficiencyResults.root"); auto tree = (TTree*)in->Get("Efficiency"); double entries, eff, sig1, count, sig2; tree->SetBranchAddress("Entries",&entries); tree->SetBranchAddress("Efficiency",&eff); tree->SetBranchAddress("Eff_Sigma",&sig1); tree->SetBranchAddress("Counts",&count); tree->SetBranchAddress("Counts_Sigma",&sig2); const int ds = tree->GetEntries(); double hent[ds], hcount[ds], hsig[ds], hex[ds]; for(int i = 0; iGetEntry(i); hent[i] = entries; hcount[i] = count; hsig[i] = sig2/Sqrt(40); hex[i] = 0; } auto g = new TGraphErrors(ds,hent,hcount,hex,hsig); g->Fit("pol1"); g->GetYaxis()->SetTitle("Counts"); g->GetXaxis()->SetTitle("Signal"); g->SetMarkerColor(kBlue); g->SetMarkerStyle(20); g->Draw("ALP RX"); DrawFitReverse(g); }