25 inline T
sqr(T v) {
return v*v; }
34 GausFitCache::~GausFitCache() {
36 (funcs.begin(), funcs.end(), std::default_delete<TF1>());
44 if (nFunc >= funcs.size()) funcs.resize(nFunc + 1,
nullptr);
47 TF1*& pFunc = funcs[nFunc];
49 if (!pFunc) pFunc = CreateFunction(nFunc);
55 TF1* GausFitCache::GetClone(
size_t nFunc)
56 {
return static_cast<TF1*
>(
Get(nFunc)->Clone()); }
60 TF1* GausFitCache::CreateFunction(
size_t nFunc)
const {
62 std::string func_name = FunctionName(nFunc);
65 if (nFunc == 0)
return new TF1(func_name.c_str(),
"0");
67 std::ostringstream sstr;
69 for (
size_t iGaus = 1; iGaus < nFunc; ++iGaus)
70 sstr <<
" + gaus(" << (iGaus*3) <<
")";
73 return new TF1(func_name.c_str(), sstr.str().c_str());
78 std::string GausFitCache::FunctionName(
size_t nFunc)
const {
79 std::ostringstream sstr;
80 sstr << name <<
"_" << nFunc;
88 Double_t details::CompiledGausFitCacheBaseStruct::gaus
89 (Double_t
const*
x, Double_t
const* params)
91 return params[0] * std::exp(-0.5*
sqr((x[0] - params[1])/params[2]));
95 TF1* details::CompiledGausFitCacheBaseStruct::GetClone(
size_t nFunc) {
97 <<
"CompiledGausFitCacheBaseStruct: compiled functions can't be cloned";
101 void details::CompiledGausFitCacheBaseStruct::CannotCreateFunction
105 << name <<
" function cache can't create functions at run-time; " << nFunc
106 <<
"-addend function was requested, but we have only functions with up to " 107 << MaxGaussians() <<
" addends available\n";
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Detector simulation of raw signals on wires.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Provide caches for TF1 functions to be used with ROOT fitters.