LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 28 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 32 of file PeakFitterGaussian_tool.cc.

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

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 41 of file PeakFitterGaussian_tool.cc.

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

42  {
43  // add the Gaussians first
44  std::string formula;
45  std::size_t iGaus = 0;
46  while (iGaus < nFunc)
47  formula += "gaus(" + std::to_string(3 * (iGaus++)) + ") + ";
48  formula += "[" + std::to_string(3 * iGaus) + "]";
49 
50  std::string const func_name = FunctionName(nFunc);
51  auto* pF = new TF1(func_name.c_str(), formula.c_str());
52  pF->SetParName(iGaus * 3, "baseline");
53  return pF;
54  } // CreateFunction()
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
Definition: BitMask.h:187
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 78 of file GausFitCache.cxx.

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

78  {
79  std::ostringstream sstr;
80  sstr << name << "_" << nFunc;
81  return sstr.str();
82  } // GausFitCache::FunctionName()
std::string name
name of the cache
Definition: GausFitCache.h:83
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 41 of file GausFitCache.cxx.

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

41  {
42 
43  // expand the list if needed
44  if (nFunc >= funcs.size()) funcs.resize(nFunc + 1, nullptr);
45 
46  // get the pointer we need...
47  TF1*& pFunc = funcs[nFunc];
48 
49  if (!pFunc) pFunc = CreateFunction(nFunc);
50 
51  return pFunc;
52  } // GausFitCache::Get()
std::vector< TF1 * > funcs
Definition: GausFitCache.h:86
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 55 of file GausFitCache.cxx.

References Get.

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

56  { return static_cast<TF1*>(Get(nFunc)->Clone()); }
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 59 of file GausFitCache.h.

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

59 { return name; }
std::string name
name of the cache
Definition: GausFitCache.h:83

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 83 of file GausFitCache.h.

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


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