Good afternoon,
EDIT: The first problems I managed to solve. Now however:
I would like to fill align3[ii] with 0 if there’s too little data in the histogram, e.g. such that TF1 *fit = hpx->GetFunction(“gaus”); can’t be called. How could I go about this?
EDIT2: Solved it.
int x(){
gROOT->ProcessLine("StrawAlignment->cd()");
double align3[7808];
TH1 *h1 = new TH1F("h1", "", 100, -2.5, 2.5);
TString filename = "align3.dat";
ofstream file_out(filename);
for (int ii = 0; ii < 7808; ii++){
for (int jj = 0; jj < 100; jj++){
double binnumber = fHResidual->GetBin(jj+1, ii+1);
double bincontent = fHResidual->GetBinContent(binnumber);
h1->SetBinContent(jj+1, bincontent);
}
if (h1->GetBinContent(h1->GetMaximumBin())>200){
TH1F *hpx = (TH1F*)h1->Clone("hnew");
double r = hpx->Fit("gaus");
int fitStatus = r;
TF1 *fit = hpx->GetFunction("gaus");
if ( fit->GetParameter(2) < 8e-01 ){
align3[ii] = fit->GetParameter(1);
file_out << align3[ii] << "\n";
} else { file_out << "0" << "\n"; }
} else { file_out << "1" << "\n"; }
h1->Reset();
}
}
Best,
rjseen