28template<
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());
70 TF1 *
f = (
TF1*) functions[
n]->IsA()->New();
71 functions[
n]->Copy(*
f);
76 Fatal(
"InitializeDataMembers",
"Invalid input function -- abort");
90 for (
int i=0; i<npar; i++)
98 for (
int i=0; i < npar; i++)
134 fFunctions = std::vector<std::unique_ptr<TF1>>(0);
135 fCoeffs = std::vector < Double_t >(0) ;
153 std::vector<TF1 *> functions(2);
154 std::vector < Double_t > coeffs(2);
156 functions = {function1, function2};
157 coeffs = {coeff1, coeff2};
167 std::vector<TF1 *> functions(3);
168 std::vector < Double_t > coeffs(3);
170 functions = {function1, function2, function3};
171 coeffs = {coeff1, coeff2, coeff3};
188 Int_t noffunctions = (formula.
Tokenize(
"+")) -> GetEntries();
189 Int_t nofobj = arrayall -> GetEntries();
190 Int_t nofcoeffs = nofobj - noffunctions;
192 std::vector<TF1 *> functions(noffunctions);
193 std::vector < Double_t > coeffs(noffunctions);
194 std::vector < TString > funcstringall(nofobj);
195 std::vector < Int_t > indexsizetimes(nofcoeffs+1);
196 std::vector < Bool_t > isacoeff(nofobj);
198 for (
int i=0; i<nofobj; i++)
200 funcstringall[i] = ((
TObjString*)((*arrayall)[i])) -> GetString();
201 funcstringall[i].ReplaceAll(
" ",
"");
207 for (
int i=0; i<nofcoeffs+1; i++)
209 indexsizetimes[i] = ( ( ( (
TObjString*)(*arraytimes)[i] ) -> GetString() ).Tokenize(
"+") ) -> GetEntries();
210 while (k < indexsizetimes[i])
215 j = j+indexsizetimes[i];
216 if (j==nofobj) isacoeff[j-1] = 0;
217 else isacoeff[j-1] = 1;
221 Double_t old_xmin = 0.0, old_xmax = 0.0;
223 for (
int i=0; i<noffunctions; i++)
227 coeffs[i] = funcstringall[k].Atof();
234 functions[i] = (
TF1 *)(
gROOT->GetListOfFunctions()->FindObject(funcstringall[k]));
236 Error(
"TF1NormSum",
"Function %s does not exist", funcstringall[k].Data());
239 functions[i]->GetRange(old_xmin, old_xmax);
248 if (noffunctions > 0 && functions[0])
249 functions[0]->SetRange(old_xmin, old_xmax);
291 std::vector<double> params(
GetNpar() );
293 int nOfNonCstParams = 0;
297 offset += nOfNonCstParams;
299 for (
int j = 0; j <
fFunctions[
n]->GetNpar(); ++j) {
324 bool equalParams =
true;
329 for (
int i = 0; i < npar; ++i) {
334 equalParams &= (funcParams[i] == params[k+
fNOfFunctions+offset] );
354 const double params[] = {p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10};
378 Warning(
"SetRange",
"Invalid range: %f >= %f",
a,
b);
425 ((
TF1NormSum &)obj).fFunctions[
n] = std::unique_ptr<TF1>(
f);
void FixDuplicateNames(Iterator begin, Iterator end)
Function to find and rename duplicate parameters with the same name.
Class adding two functions: c1*f1+c2*f2.
Double_t fScale
Fixed Scale parameter to normalize function (e.g. bin width)
const char * GetParName(Int_t ipar) const
void GetRange(Double_t &a, Double_t &b) const
TF1NormSum & operator=(const TF1NormSum &rhs)
Operator =.
Double_t fXmax
Minimal bound of range of NormSum.
std::vector< TString > fParNames
Parameter names.
void SetParameters(const Double_t *params)
Initialize array of all parameters.
std::vector< double > GetParameters() const
Return array of parameters.
std::vector< std::unique_ptr< TF1 > > fFunctions
Maximal bound of range of NormSum.
void InitializeDataMembers(const std::vector< TF1 * > &functions, const std::vector< Double_t > &coeffs, Double_t scale)
void Copy(TObject &obj) const
Copy this to obj.
std::vector< Double_t > fCoeffs
Vector of size afNOfFunctions containing coefficients in front of each function.
Int_t GetNpar() const
Return the number of (non constant) parameters including the coefficients: for 2 functions: c1,...
void Update()
Update the component functions of the normalized sum.
unsigned int fNOfFunctions
Number of functions to add.
double operator()(const Double_t *x, const Double_t *p)
Overload the parenthesis to add the functions.
void SetRange(Double_t a, Double_t b)
std::vector< Int_t > fCstIndexes
Vector with size of fNOfFunctions containing the index of the constant parameter/ function (the remov...
static void InitStandardFunctions()
Create the basic function objects.
Collectable string class.
Mother of all ROOT objects.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
static long int sum(long int i)