TFraction Fitter

Hi there, Can you please help me resolve this issue
null passed to a callee that requires a non-null argument [-Wnonnull]
hist->SetDirectory(0);
here are my script
fit1.C (1.4 KB)
and data files
data.root (5.7 KB)
7He.root (5.7 KB)
6He.root (5.7 KB)
5He.root (5.7 KB)
4He.root (5.7 KB)
Actually, I am trying to use TFractionFitter to find the contribution of phase-space coming from 7He,6He,5He,4He in data.
It will be a great help. Thanks

The “rootls -l *.root” shows that all your histograms are “TH1F” but, in your macro, you try to get “TH1D”.

void fit1()
{
   TFile fData("data.root");
   TH1F* hist;
   fData.GetObject("h5",hist);
   hist->SetDirectory(0);
   hist->Draw("hist");

   TFile f4He("4He.root");
   TH1F* hist4He;
   f4He.GetObject("h1",hist4He);
   hist4He->SetDirectory(0);

   TFile f5He("5He.root");
   TH1F* hist5He;
   f5He.GetObject("h2",hist5He);
   hist5He->SetDirectory(0);

   TFile f6He("6He.root");
   TH1F* hist6He;
   f6He.GetObject("h3",hist6He);
   hist6He->SetDirectory(0);

   TFile f7He("7He.root");
   TH1F* hist7He;
   f7He.GetObject("h4",hist7He);
   hist7He->SetDirectory(0);

   TObjArray *mc = new TObjArray(4);

   mc->Add(hist4He);
   mc->Add(hist5He);
   mc->Add(hist6He);
   mc->Add(hist7He);

   TFractionFitter* fit = new TFractionFitter(hist,mc);
   fit->Constrain(0,0.0,1.0);
   fit->Constrain(1,0.0,1.0);
   fit->Constrain(2,0.0,1.0);
   fit->Constrain(3,0.0,1.0);

   fit->SetRangeX(1,45);
   Int_t status = fit->Fit();
   std::cout<<"fit status"<< status << std::endl;
   if (status == 0) {
      TH1F* result = (TH1F*) fit->GetPlot();
      hist->Draw("PE");
      result->SetDirectory(0);
   }
}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.