Dear Experts
I want to read some values from several files, and fit the points to several spline functions, but when I check the output file, only the points from the first input file were successfully fitted, others give NaN value when I use Eval(). Here are codes:
// includes
static constexpr double Pi = 3.1415926535897932384626433832795;
int main(){
TFile* f_out = new TFile("fx2t.root", "RECREATE");
TSpline3* spline[4][72];
for(int i=0; i<4; i++){
double dis, time, phi, l[72];
TGraph* g[72];
for(int j=0;j<72;j++){
g[j] = new TGraph();
}
TFile* f = new TFile(Form("x2t_beta%d_1.00T.root", i));
if(!f) std::cout<<"cannot find input file"<<std::endl;
TTree* t = (TTree*)f->Get("t");
t->SetBranchAddress("driftDistance", &dis);
t->SetBranchAddress("t1", &time);
t->SetBranchAddress("phi", &phi);
f->cd();
for(int j=0; j<t->GetEntries(); j++){
t->GetEntry(j);
for(int k=0; k<72; k++){
if(phi==k*Pi*2/72){
g[k]->SetPoint(l[k], dis,time);
l[k]++;
}
}
}
f_out->cd();
for(int k=0; k<72; k++){
spline[i][k] = new TSpline3(Form("spline_beta%d_phi%d", i, k), g[k]);
spline[i][k]->Write(Form("spline_beta%d_phi%d", i, k));
}
f->Close();
}
f_out->Close();
return 0;
}
and the output file contains all 4*72=288 spline functions.
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.22/02
Platform: CentOS
Compiler: GCC