28 template<
class Iterator>
33 std::multimap<TString, int > parMap;
34 for (Iterator it = begin; it != end; ++it) {
35 parMap.insert( std::make_pair( *it, std::distance(begin,it) ) );
37 for (
auto & elem : parMap) {
39 int n = parMap.count( name);
41 std::pair <std::multimap<TString,int>::iterator, std::multimap<TString,int>::iterator> ret;
42 ret = parMap.equal_range(name);
44 for (std::multimap<TString,int>::iterator it=ret.first; it!=ret.second; ++it) {
66 fFunctions = std::vector<std::unique_ptr<TF1>>(functions.size());
69 functions[
n]->Copy(*f);
74 Fatal(
"InitializeDataMembers",
"Invalid input function -- abort");
88 for (
int i=0; i<npar; i++)
96 for (
int i=0; i < npar; i++)
106 if (fNOfFunctions == 0) {
132 fFunctions = std::vector<std::unique_ptr<TF1>>(0);
133 fCoeffs = std::vector < Double_t >(0) ;
151 std::vector<TF1 *> functions(2);
152 std::vector < Double_t > coeffs(2);
154 functions = {function1, function2};
155 coeffs = {coeff1, coeff2};
165 std::vector<TF1 *> functions(3);
166 std::vector < Double_t > coeffs(3);
168 functions = {function1, function2, function3};
169 coeffs = {coeff1, coeff2, coeff3};
186 Int_t noffunctions = (formula.
Tokenize(
"+")) -> GetEntries();
187 Int_t nofobj = arrayall -> GetEntries();
188 Int_t nofcoeffs = nofobj - noffunctions;
190 std::vector<TF1 *> functions(noffunctions);
191 std::vector < Double_t > coeffs(noffunctions);
192 std::vector < TString > funcstringall(nofobj);
193 std::vector < Int_t > indexsizetimes(nofcoeffs+1);
194 std::vector < Bool_t > isacoeff(nofobj);
196 for (
int i=0; i<nofobj; i++)
198 funcstringall[i] = ((
TObjString*)((*arrayall)[i])) -> GetString();
199 funcstringall[i].ReplaceAll(
" ",
"");
205 for (
int i=0; i<nofcoeffs+1; i++)
207 indexsizetimes[i] = ( ( ( (
TObjString*)(*arraytimes)[i] ) -> GetString() ).Tokenize(
"+") ) -> GetEntries();
208 while (k < indexsizetimes[i])
213 j = j+indexsizetimes[i];
214 if (j==nofobj) isacoeff[j-1] = 0;
215 else isacoeff[j-1] = 1;
219 Double_t old_xmin = 0.0, old_xmax = 0.0;
221 for (
int i=0; i<noffunctions; i++)
225 coeffs[i] = funcstringall[k].Atof();
232 functions[i] = (
TF1 *)(
gROOT->GetListOfFunctions()->FindObject(funcstringall[k]));
234 Error(
"TF1NormSum",
"Function %s does not exist", funcstringall[k].Data());
237 functions[i]->GetRange(old_xmin, old_xmax);
238 functions[i]->SetRange(xmin, xmax);
246 if (noffunctions > 0 && functions[0])
247 functions[0]->SetRange(old_xmin, old_xmax);
289 std::vector<double> params(
GetNpar() );
291 int nOfNonCstParams = 0;
295 offset += nOfNonCstParams;
297 for (
int j = 0; j <
fFunctions[
n]->GetNpar(); ++j) {
299 params[k+fNOfFunctions+offset] =
fFunctions[
n]->GetParameter(j);
322 bool equalParams =
true;
327 for (
int i = 0; i < npar; ++i) {
332 equalParams &= (funcParams[i] == params[k+fNOfFunctions+offset] );
333 funcParams[i] = params[k+fNOfFunctions+offset];
352 const double params[] = {p0,
p1,
p2,
p3,p4,p5,p6,p7,p8,p9,p10};
376 Warning(
"SetRange",
"Invalid range: %f >= %f", a, b);
void InitializeDataMembers(const std::vector< TF1 *> &functions, const std::vector< Double_t > &coeffs, Double_t scale)
static long int sum(long int i)
Int_t GetNpar() const
Return the number of (non constant) parameters including the coefficients: for 2 functions: c1...
std::vector< TString > fParNames
Parameter names.
static double p3(double t, double a, double b, double c, double d)
Collectable string class.
const char * GetParName(Int_t ipar) const
unsigned int fNOfFunctions
Number of functions to add.
std::vector< Int_t > fCstIndexes
Vector with size of fNOfFunctions containing the index of the constant parameter/ function (the remov...
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
static double p2(double t, double a, double b, double c)
void SetRange(Double_t a, Double_t b)
void FixDuplicateNames(Iterator begin, Iterator end)
Function to find and rename duplicate parameters with the same name.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
double operator()(const Double_t *x, const Double_t *p)
Overload the parenthesis to add the functions.
Class adding two functions: c1*f1+c2*f2.
static void InitStandardFunctions()
Create the basic function objects.
static double p1(double t, double a, double b)
void Update()
Update the component functions of the normalized sum.
std::vector< Double_t > fCoeffs
Vector of size afNOfFunctions containing coefficients in front of each function.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
void GetRange(Double_t &a, Double_t &b) const
Double_t fScale
Fixed Scale parameter to normalize function (e.g. bin width)
std::vector< double > GetParameters() const
Return array of parameters.
TF1NormSum & operator=(const TF1NormSum &rhs)
Operator =.
void Copy(TObject &obj) const
Copy this to obj.
void SetParameters(const Double_t *params)
Initialize array of all parameters.
Mother of all ROOT objects.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
std::vector< std::unique_ptr< TF1 > > fFunctions
Maximal bound of range of NormSum.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Double_t fXmax
Minimal bound of range of NormSum.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
const char * Data() const