LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
reco_tool::BaselinedGausFitCache Class Reference
Inheritance diagram for reco_tool::BaselinedGausFitCache:
hit::GausFitCache

Public Member Functions

 BaselinedGausFitCache (std::string const &new_name="BaselinedGausFitCache")
 Constructor (see base class constructor). More...
 
std::string GetName () const
 Return the name of this cache. More...
 
virtual TF1 * Get (size_t nFunc)
 Returns a function sum of nFunc base functions. More...
 
virtual TF1 * GetClone (size_t nGaus)
 
virtual std::string FunctionName (size_t nFunc) const
 Returns a name for the function with nFunc base functions. More...
 

Protected Member Functions

virtual TF1 * CreateFunction (size_t nFunc) const
 

Protected Attributes

std::string name
 name of the cache More...
 
std::vector< TF1 * > funcs
 

Detailed Description

Customized function cache for Gaussians with a baseline.

The baseline parameter is always the last one.

Definition at line 27 of file PeakFitterGaussian_tool.cc.

Constructor & Destructor Documentation

reco_tool::BaselinedGausFitCache::BaselinedGausFitCache ( std::string const &  new_name = "BaselinedGausFitCache")
inline

Constructor (see base class constructor).

Definition at line 31 of file PeakFitterGaussian_tool.cc.

32  : hit::GausFitCache(new_name)
33  {}
A set of TF1 linear sum of base functions (Gaussians)
Definition: GausFitCache.h:45

Member Function Documentation

virtual TF1* reco_tool::BaselinedGausFitCache::CreateFunction ( size_t  nFunc) const
inlineprotectedvirtual

Creates and returns the function with specified number of Gaussians.

The formula is gaus(0) + gaus(3) + ... + gaus(3*(nFunc-1)) + [nFunc*3].

Reimplemented from hit::GausFitCache.

Definition at line 39 of file PeakFitterGaussian_tool.cc.

References hit::GausFitCache::FunctionName(), and util::to_string().

40  {
41  // add the Gaussians first
42  std::string formula;
43  std::size_t iGaus = 0;
44  while (iGaus < nFunc)
45  formula += "gaus(" + std::to_string(3 * (iGaus++)) + ") + ";
46  formula += "[" + std::to_string(3 * nFunc) + "]";
47 
48  std::string const func_name = FunctionName(nFunc);
49  auto* pF = new TF1(func_name.c_str(), formula.c_str());
50  pF->SetParName(iGaus * 3, "baseline");
51  return pF;
52  } // CreateFunction()
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
virtual std::string FunctionName(size_t nFunc) const
Returns a name for the function with nFunc base functions.
std::string hit::GausFitCache::FunctionName ( size_t  nFunc) const
virtualinherited

Returns a name for the function with nFunc base functions.

Definition at line 83 of file GausFitCache.cxx.

References hit::GausFitCache::name.

Referenced by hit::details::CompiledGausFitCacheBaseStruct::AppendFunction(), CreateFunction(), hit::GausFitCache::CreateFunction(), hit::details::CompiledGausFitCacheBaseStruct::InitializeFuncSumVector< NFunc, Func >::fill(), hit::details::CompiledGausFitCacheBaseStruct::InitializeFuncSumVector< 0U, Func >::fill(), and hit::GausFitCache::GetName().

84  {
85  std::ostringstream sstr;
86  sstr << name << "_" << nFunc;
87  return sstr.str();
88  } // GausFitCache::FunctionName()
std::string name
name of the cache
Definition: GausFitCache.h:77
TF1 * hit::GausFitCache::Get ( size_t  nFunc)
virtualinherited

Returns a function sum of nFunc base functions.

Parameters
nGausthe number of base functions in the function
Returns
a pointer to a TF1 with the required characteristics

The returned function must not be deleted at any time!

This implementation returns a function sum of nFunc Gaussians. The parameters are sorted by Gaussian: first normalization (not the area, but the coefficient), first mean, first sigma, second normalization etc.

Definition at line 44 of file GausFitCache.cxx.

References hit::GausFitCache::CreateFunction(), and hit::GausFitCache::funcs.

Referenced by reco_tool::PeakFitterGaussian::findPeakParameters(), hit::GausFitCache::GetClone(), and hit::GausFitCache::GetName().

45  {
46 
47  // expand the list if needed
48  if (nFunc >= funcs.size()) funcs.resize(nFunc + 1, nullptr);
49 
50  // get the pointer we need...
51  TF1*& pFunc = funcs[nFunc];
52 
53  if (!pFunc) pFunc = CreateFunction(nFunc);
54 
55  return pFunc;
56  } // GausFitCache::Get()
std::vector< TF1 * > funcs
Definition: GausFitCache.h:80
virtual TF1 * CreateFunction(size_t nFunc) const
Creates a new sum function.
TF1 * hit::GausFitCache::GetClone ( size_t  nGaus)
virtualinherited

Returns a new function sum of nFunc base functions (caller needs to set limits and parameters)

Reimplemented in hit::details::CompiledGausFitCacheBaseStruct.

Definition at line 59 of file GausFitCache.cxx.

References hit::GausFitCache::Get().

Referenced by hit::GausFitCache::GetName().

60  {
61  return static_cast<TF1*>(Get(nFunc)->Clone());
62  }
virtual TF1 * Get(size_t nFunc)
Returns a function sum of nFunc base functions.
std::string hit::GausFitCache::GetName ( ) const
inlineinherited

Return the name of this cache.

Definition at line 54 of file GausFitCache.h.

References hit::GausFitCache::FunctionName(), hit::GausFitCache::Get(), hit::GausFitCache::GetClone(), and hit::GausFitCache::name.

54 { return name; }
std::string name
name of the cache
Definition: GausFitCache.h:77

Member Data Documentation

std::string hit::GausFitCache::name
protectedinherited

name of the cache

Gaussian sum functions; n-th element is sum of n base functions

Definition at line 77 of file GausFitCache.h.

Referenced by hit::details::CompiledGausFitCacheBaseStruct::CannotCreateFunction(), hit::GausFitCache::FunctionName(), and hit::GausFitCache::GetName().


The documentation for this class was generated from the following file: