histossss.root (22.8 KB)

Hi all, I am trying to find an x-value given a y-value of a sigmoid function that I fitted to a an efficiency plot (divided 2 histograms) . So, I used GetFunction to get my fitted function, and then I tried to use GetX to find my x-value. However, I get the warning that “null passed to a callee that requires a non-null argument: double x_value = sigmoid->GetX(1., 65, 72);”, so I think something went wrong with the GetFunction part but I’m not sure what… Thanks!

```
void Efficiency(){
auto f = new TFile ("histossss.root");
TH1D *k1 = (TH1D*)f->Get("notrigger");
std::vector<std::string> TriggerCut = {"J20", "J40", "J50", "J75", "J100"};
int n = TriggerCut.size();
TH1D *h[n];
TGraphAsymmErrors *eff[n];
TF1 *fit[n];
std::vector<int> offset = {50, 75, 90, 125, 160};
for (unsigned i = 0; i < n; i++) {
f->GetObject(TString::Format("%s", TriggerCut[i].c_str()) , h[i]);
eff[i] = new TGraphAsymmErrors();
eff[i]->Divide(h[i], k1);
eff[i]->SetNameTitle("eff", "Trigger Efficiency");
if (i == 0) eff[i]->SetLineColor(kRed-7);
else if (i == 1) eff[i]->SetLineColor(kBlue+3);
else if (i == 2) eff[i]->SetLineColor(kViolet+7);
else if (i == 3) eff[i]->SetLineColor(kAzure+7);
else eff[i]->SetLineColor(kGreen+1);
if (i==0) eff[i]->Draw("ap");
else eff[i]->Draw("p same");
fit[i] = new TF1("sigm_%d", "(1/(1+ TMath::Exp(-[0]*(x-[1]))))", 0, 230);
fit[i]->SetParNames("stretching", "x-axis");
fit[i]->SetParameters(0.2, offset[i]);
eff[i]->Fit("sigm_%d");
}
sigmoid = eff[0]->GetFunction("fit[0]");
double x_value = sigmoid->GetX(1., 65, 72);
}
```