I tried running this program again
by .x SampleAveragingCode01.C++
void SampleAveragingCode01()
{
static Int_t nf = 10;
auto can = new TCanvas("c1", "c1", 800,500);
gStyle->SetOptStat(0);
auto hh = new TH1F("hh", "Averaging functions", 100,0,10);
can->Draw();
hh->Draw();
TF1 * fp[nf];
TString fn;
for (Int_t i=0; i<nf; i++)
{
fn = "f"; fn += i;
fp[i] = new TF1(fn, "[0]*x - [1]*x*x", 0, 10);
fp[i]->SetParameters(60, 4 + gRandom->Gaus(1,0.3));
fp[i]->SetLineColor(i+2);
fp[i]->SetLineWidth(1);
fp[i]->Draw("same");
}
Int_t npoints=100;
Double_t x,y, dy = 10./npoints;
auto avg = new TGraph(npoints);
for (Int_t ip=0; ip < npoints; ip++)
{
x = dy*ip + 0.5*dy;
avg->SetPoint(ip, x, 0.);
}
for (Int_t i=0; i<nf; i++)
{
for (Int_t ip=0; ip < npoints; ip++)
{
avg->GetPoint(ip, x,y);
avg->SetPoint(ip, x, y + fp[i]->Eval(x)/(Double_t)nf);
}
}
avg->SetMarkerColor(1);
avg->SetMarkerSize(1);
avg->Draw("* same");
hh->SetMaximum(300);
can->Modified();
can->Update();
}
but it gives error…
root [2] .x SampleAveragingCode01.C++
Info in <TUnixSystem::ACLiC>: creating shared library /home/jaybee/CodesScattering/./SampleAveragingCode01_C.so
In file included from /home/jaybee/CodesScattering/SampleAveragingCode01_C_ACLiC_dict.h:34:0,
from /home/jaybee/CodesScattering/SampleAveragingCode01_C_ACLiC_dict.cxx:17:
/home/jaybee/CodesScattering/./SampleAveragingCode01.C: In function ‘void SampleAveragingCode01()’:
/home/jaybee/CodesScattering/./SampleAveragingCode01.C:4:7: error: ‘can’ does not name a type
auto can = new TCanvas("c1", "c1", 800,500);
^
/home/jaybee/CodesScattering/./SampleAveragingCode01.C:5:2: error: ‘gStyle’ was not declared in this scope
gStyle->SetOptStat(0);
^
/home/jaybee/CodesScattering/./SampleAveragingCode01.C:6:7: error: ‘hh’ does not name a type
auto hh = new TH1F("hh", "Averaging functions", 100,0,10);
^
/home/jaybee/CodesScattering/./SampleAveragingCode01.C:7:2: error: ‘can’ was not declared in this scope
can->Draw();
^
/home/jaybee/CodesScattering/./SampleAveragingCode01.C:8:2: error: ‘hh’ was not declared in this scope
hh->Draw();
^
/home/jaybee/CodesScattering/./SampleAveragingCode01.C:10:2: error: ‘TF1’ was not declared in this scope
TF1 * fp[nf];
^
/home/jaybee/CodesScattering/./SampleAveragingCode01.C:10:8: error: ‘fp’ was not declared in this scope
TF1 * fp[nf];
^
/home/jaybee/CodesScattering/./SampleAveragingCode01.C:11:10: error: aggregate ‘TString fn’ has incomplete type and cannot be defined
TString fn;
^
/home/jaybee/CodesScattering/./SampleAveragingCode01.C:15:15: error: expected type-specifier before ‘TF1’
fp[i] = new TF1(fn, "[0]*x - [1]*x*x", 0, 10);
^
/home/jaybee/CodesScattering/./SampleAveragingCode01.C:16:32: error: ‘gRandom’ was not declared in this scope
fp[i]->SetParameters(60, 4 + gRandom->Gaus(1,0.3));
^
/home/jaybee/CodesScattering/./SampleAveragingCode01.C:24:7: error: ‘avg’ does not name a type
auto avg = new TGraph(npoints);
^
/home/jaybee/CodesScattering/./SampleAveragingCode01.C:28:3: error: ‘avg’ was not declared in this scope
avg->SetPoint(ip, x, 0.);
^
/home/jaybee/CodesScattering/./SampleAveragingCode01.C:35:4: error: ‘avg’ was not declared in this scope
avg->GetPoint(ip, x,y);
^
/home/jaybee/CodesScattering/./SampleAveragingCode01.C:40:2: error: ‘avg’ was not declared in this scope
avg->SetMarkerColor(1);
^
g++: error: /home/jaybee/CodesScattering/SampleAveragingCode01_C_ACLiC_dict.o: No such file or directory
Error in <ACLiC>: Compilation failed!
Error: Function SampleAveragingCode01() is not defined in current scope :0:
*** Interpreter error recovered ***
root [3]
what could have been wrong?
regards,
jaybee