34 template<
class Iterator>
40 std::multimap<TString, int > parMap;
41 for (Iterator it = begin; it != end; ++it) {
42 parMap.insert( std::make_pair( *it,
std::distance(begin,it) ) );
44 for (
auto & elem : parMap) {
46 int n = parMap.count( name);
48 std::pair <std::multimap<TString,int>::iterator, std::multimap<TString,int>::iterator> ret;
49 ret = parMap.equal_range(name);
51 for (std::multimap<TString,int>::iterator it=ret.first; it!=ret.second; ++it) {
88 for (
int i=0; i<npar; i++)
96 for (
int i=0; i < npar; i++)
112 fFunctions = std::vector< std::shared_ptr < TF1 >>(0) ;
113 fCoeffs = std::vector < Double_t >(0) ;
121 std::vector <std::shared_ptr < TF1 > >
f;
122 for (
unsigned int i = 0; i<functions.size(); i++)
124 f[i] = std::shared_ptr < TF1 >((
TF1*)functions[i]->Clone());
135 std::vector < std::shared_ptr < TF1 > > functions(2);
136 std::vector < Double_t > coeffs(2);
141 fnew1 = (
TF1*) function1->IsA()->New();
142 function1->
Copy(*fnew1);
145 fnew2 = (
TF1*) function2->IsA()->New();
146 function2->
Copy(*fnew2);
148 if (fnew1 ==
nullptr || fnew2 ==
nullptr)
149 Fatal(
"TF1NormSum",
"Invalid input functions - Abort");
151 std::shared_ptr < TF1 >
f1( fnew1);
152 std::shared_ptr < TF1 >
f2( fnew2);
154 functions = {
f1, f2};
155 coeffs = {coeff1, coeff2};
165 std::vector < std::shared_ptr < TF1 > > functions(3);
166 std::vector < Double_t > coeffs(3);
171 fnew1 = (
TF1*) function1->IsA()->New();
172 function1->
Copy(*fnew1);
175 fnew2 = (
TF1*) function2->IsA()->New();
176 function2->
Copy(*fnew2);
179 fnew3 = (
TF1*) function3->IsA()->New();
180 function3->
Copy(*fnew2);
182 if (!fnew1 || !fnew2 || !fnew3 )
183 Fatal(
"TF1NormSum",
"Invalid input functions - Abort");
185 std::shared_ptr < TF1 >
f1( fnew1);
186 std::shared_ptr < TF1 >
f2( fnew2);
187 std::shared_ptr < TF1 > f3( fnew3);
190 functions = {
f1,
f2, f3};
191 coeffs = {coeff1, coeff2, coeff3};
208 Int_t noffunctions = (formula.
Tokenize(
"+")) -> GetEntries();
209 Int_t nofobj = arrayall -> GetEntries();
210 Int_t nofcoeffs = nofobj - noffunctions;
212 std::vector < std::shared_ptr < TF1 > > functions(noffunctions);
213 std::vector < Double_t > coeffs(noffunctions);
214 std::vector < TString > funcstringall(nofobj);
215 std::vector < Int_t > indexsizetimes(nofcoeffs+1);
216 std::vector < Bool_t > isacoeff(nofobj);
218 for (
int i=0; i<nofobj; i++)
220 funcstringall[i] = ((
TObjString*)((*arrayall)[i])) -> GetString();
221 funcstringall[i].ReplaceAll(
" ",
"");
227 for (
int i=0; i<nofcoeffs+1; i++)
229 indexsizetimes[i] = ( ( ( (
TObjString*)(*arraytimes)[i] ) -> GetString() ).Tokenize(
"+") ) -> GetEntries();
230 while (k < indexsizetimes[i])
235 j = j+indexsizetimes[i];
236 if (j==nofobj) isacoeff[j-1] = 0;
237 else isacoeff[j-1] = 1;
241 for (
int i=0; i<noffunctions; i++)
246 TF1*
f = (
TF1*)(
gROOT -> GetListOfFunctions() -> FindObject(funcstringall[k]));
247 if (!f)
Error(
"TF1NormSum",
"Function %s does not exist", funcstringall[k].
Data());
248 functions[i] = std::shared_ptr < TF1 > ((
TF1*)f->
Clone(
TString::Format(
"function_%s_%d",funcstringall[k].Data(), i)));
249 functions[i]->SetRange(xmin,xmax);
254 coeffs[i] = funcstringall[k].Atof();
255 TF1*
f = (
TF1*)(
gROOT -> GetListOfFunctions() -> FindObject(funcstringall[k+1]));
256 if (!f)
Error(
"TF1NormSum",
"Function %s does not exist", funcstringall[k+1].
Data());
257 functions[i] = std::shared_ptr < TF1 >((
TF1*)f->
Clone(
TString::Format(
"function_%s_%d",funcstringall[k+1].Data(), i) ));
258 functions[i]->SetRange(xmin,xmax);
294 std::vector<double> params(
GetNpar() );
296 int nOfNonCstParams = 0;
300 offset += nOfNonCstParams;
302 for (
int j = 0; j <
fFunctions[
n]->GetNpar(); ++j) {
304 params[k+fNOfFunctions+offset] =
fFunctions[
n]->GetParameter(j);
327 bool equalParams =
true;
332 for (
int i = 0; i < npar; ++i) {
337 equalParams &= (funcParams[i] == params[k+fNOfFunctions+offset] );
338 funcParams[i] = params[k+fNOfFunctions+offset];
357 const double params[] = {p0,
p1,
p2,
p3,p4,p5,p6,p7,p8,p9,p10};
std::vector< TString > fParNames
static double p3(double t, double a, double b, double c, double d)
void Fatal(const char *location, const char *msgfmt,...)
Collectable string class.
Double_t distance(const TPoint2 &p1, const TPoint2 &p2)
unsigned int fNOfFunctions
const char * Data() const
std::vector< Int_t > fCstIndexes
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
std::vector< double > GetParameters() const
Return array of parameters.
const char * GetParName(Int_t ipar) const
static double p2(double t, double a, double b, double c)
virtual void Copy(TObject &f1) const
Copy this F1 to a new F1.
std::vector< std::vector< double > > Data
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
void InitializeDataMembers(const std::vector< std::shared_ptr< TF1 >> &functions, const std::vector< Double_t > &coeffs, Double_t scale)
void Error(const char *location, const char *msgfmt,...)
void FixDuplicateNames(Iterator begin, Iterator end)
static void InitStandardFunctions()
Create the basic function objects.
static double p1(double t, double a, double b)
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
std::vector< Double_t > fCoeffs
Double_t fScale
Number of functions to add.
void SetParameters(const double *params)
Initialize array of all parameters.
std::vector< std::shared_ptr< TF1 > > fFunctions
double f2(const double *x)
double operator()(double *x, double *p)
Overload the parenthesis to add the functions.