I’ve been trying to create an array of TF1 objects within a method of a given class, using a function defined within the class itself, but haven’t had much success. (using http://root.cern.ch/root/htmldoc/TF1.html#F5 ).
The analysis class is called AliV0Module, and here is the code I’m attempting to use:
TF1 *lfitNoise[50];
TF1 *lSampleNoise[50];
char lFitNameOne[50];
for(long i=0; i<fptbinnumb; i++){
//Define Function to Fit Background
sprintf(lFitNameOne,"lfitNoise%i",i);
cout<<"creating fitnoise, named "<<lFitNameOne<<endl;
lfitNoise[i] = new TF1(lFitNameOne, this, &AliV0Module::myBgPol1,
RoundToThousandth ( lLeftBgLeftLimit[i] ),
RoundToThousandth ( lRightBgRightLimit[i] ), 4 , "AliV0Module", "myBgPol1");
lfitNoise[i] -> FixParameter(2,RoundToThousandth ( lLeftBgRightLimit[i] ) );
lfitNoise[i] -> FixParameter(3,RoundToThousandth ( lRightBgLeftLimit[i] ) );
lfitNoise[i] -> SetParameter(0,lLeftPlusRightBgV0[i]*lHistoFullV0[i]->GetBinWidth(5));
lfitNoise[i] -> SetParameter(1,0);
sprintf(lFitNameOne,"lSampleNoise%i",i);
//Define Function to Sample Background
cout<<"creating sample "<<i<<endl;
lSampleNoise[i] = new TF1(lFitNameOne, this, &AliV0Module::myBgPolToEval1,
RoundToThousandth ( lLeftBgLeftLimit[i] ),
RoundToThousandth ( lRightBgRightLimit[i] ), 2 ,"AliV0Module", "myBgPolToEval1");
}
When I try to, later, access the objects called “lfitNoise1”, “lfitNoise2” (note: lfitNoise0 works fine) and so on, I get the message:
Unknown function: lfitNoise1
Since I have a pointer, I can try to ask for lfitNoise[i]->GetName(), which returns gibberish… If I define the myBgPol1 and myBgPolToEval1 functions without the AliV0Module:: and use them as standalone C++ functions, it works just fine…
What am I doing wrong? Is it that I’m passing the “this” argument to the pointer? Could you please help me? Thanks a lot in advance!