40 std::for_each(
funcs.begin(),
funcs.end(), std::default_delete<TF1>());
48 if (nFunc >=
funcs.size())
funcs.resize(nFunc + 1,
nullptr);
51 TF1*& pFunc =
funcs[nFunc];
61 return static_cast<TF1*
>(
Get(nFunc)->Clone());
71 if (nFunc == 0)
return new TF1(func_name.c_str(),
"0");
73 std::ostringstream sstr;
75 for (
size_t iGaus = 1; iGaus < nFunc; ++iGaus)
76 sstr <<
" + gaus(" << (iGaus * 3) <<
")";
79 return new TF1(func_name.c_str(), sstr.str().c_str());
85 std::ostringstream sstr;
86 sstr <<
name <<
"_" << nFunc;
95 return params[0] * std::exp(-0.5 *
sqr((x[0] - params[1]) / params[2]));
101 <<
"CompiledGausFitCacheBaseStruct: compiled functions can't be cloned";
107 <<
name <<
" function cache can't create functions at run-time; " << nFunc
108 <<
"-addend function was requested, but we have only functions with up to " << MaxGaussians()
109 <<
" addends available\n";
std::vector< TF1 * > funcs
static Double_t gaus(Double_t const *x, Double_t const *params)
Single Gaussian function.
virtual TF1 * CreateFunction(size_t nFunc) const
Creates a new sum function.
virtual TF1 * GetClone(size_t nGaus)
Throws an exception (ROOT does not support cloning compiled functions)
virtual ~GausFitCache()
Destructor.
void CannotCreateFunction(size_t nGaus) const
Throws an error asserting compiled functions can't be cretead run-time.
virtual TF1 * Get(size_t nFunc)
Returns a function sum of nFunc base functions.
Detector simulation of raw signals on wires.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
virtual std::string FunctionName(size_t nFunc) const
Returns a name for the function with nFunc base functions.
Provide caches for TF1 functions to be used with ROOT fitters.
std::string name
name of the cache
virtual TF1 * GetClone(size_t nGaus)