I suggest to write your test script in the following way to avoid double deletes.
[code]void manyfits(void) {
TString names[] = {“hH00”, “hH01”, “hH02”, “hH03”, “hH04”,
“hH05”, “hH06”, “hH07”, “hH08”, “hH09”,
“hH10”, “hH11”, “hH12”, “hH16”, “hH17”,
“hH18”, “hH19”, “hH24”, “hH25”, “hH26”,
“hH27”, “hH28”, “hH29”, “hH30”, “hH31”};
Float_t zeroth[] = {-0.822299, -0.650575, -1.004017, -1.015329, -1.078479 ,
-0.491117, -0.318672, -2.518277, 0.347851, -0.277543 ,
-1.567872, -0.589049, -0.139822, -1.085679, 0.86937 ,
-0.817956, -0.497455, -1.270019, -1.403638, -1.1102 ,
-0.794053, -1.702961, -1.554968, -0.91216, -2.094039};
Float_t first[] = {0.742309, 0.74639, 0.750189, 0.748014, 0.750298,
0.741829, 0.758071, 0.745851, 0.750407, 0.752432,
0.749916, 0.74413, 0.744559, 0.741616, 0.735589,
0.749916, 0.740764, 0.749481, 0.752981, 0.751446,
0.754302, 0.753421, 0.744452, 0.753366, 0.74959};
Int_t error;
//gROOT->ProcessLine(".L TGTsBGFit.cxx+", &error);
TH1D *h=0;
TGTsBGFit *t=0;
TFile *f = new TFile(“coin3953_sumprj.root”,“read”);
TCanvas c = new TCanvas();
for (Int_t times=0;times<20;times++) {
for (Int_t idx=0; idx<25; idx++) {
cout << “<< " << names[idx] << " >>” << endl;
delete t;
delete h;
c->Clear();
h = (TH1D)f->Get(names[idx]);
t = new TGTsBGFit(h,481.,541.,zeroth[idx],first[idx],1,c);
t->FindPeaks();
t->FitThePeaks();
c->Update();
} // idx
} // times
f->Close();
delete c;
}
[/code]
Concerning the functors have a look at the TF1 doc and the tutorials.
Rene