13#include "TFitResult.h"
14#include "TFitResultPtr.h"
18#include "TVirtualFitter.h"
28 TDecayFit(
const char* name,
const char* formula, Double_t xmin = 0, Double_t xmax = 1)
29 : TF1(name, formula, xmin, xmax)
33 TDecayFit(
const char* name, Double_t xmin, Double_t xmax, Int_t npar) : TF1(name, xmin, xmax, npar)
37 TDecayFit(
const char* name,
const ROOT::Math::ParamFunctor& f, Double_t xmin = 0, Double_t xmax = 1, Int_t npar = 0)
38 : TF1(name, f, xmin, xmax, npar)
42#if !defined(__CINT__) && !defined(__CLING__)
43 TDecayFit(
const char* name, Double_t (*fcn)(Double_t*, Double_t*), Double_t xmin = 0, Double_t xmax = 1, Int_t npar = 0)
44 : TF1(name, fcn, xmin, xmax, npar)
48 TDecayFit(
const char* name, Double_t (*fcn)(
const Double_t*,
const Double_t*), Double_t xmin = 0, Double_t xmax = 1, Int_t npar = 0)
49 : TF1(name, fcn, xmin, xmax, npar)
55 template <
class PtrObj,
typename MemFn>
56 TDecayFit(
const char* name,
const PtrObj& p, MemFn memFn, Double_t xmin, Double_t xmax, Int_t npar,
57 const char* className =
nullptr,
const char* methodName =
nullptr)
58 : TF1(name, p, memFn, xmin, xmax, npar, className, methodName)
63 template <
typename Func>
64 TDecayFit(
const char* name, Func f, Double_t xmin, Double_t xmax, Int_t npar,
const char* className =
nullptr)
65 : TF1(name, f, xmin, xmax, npar, className)
79 void Print(Option_t* opt = "") const override;
83 TFitResultPtr
Fit(TH1*
hist, Option_t* opt =
"");
105 virtual
void DrawComponents(Option_t* opt = "", Bool_t color_flag = true);
106 void Print(Option_t* opt = "") const override = 0;
124 : fDetectionEfficiency(1.0)
136 UInt_t GetGeneration()
const {
return fGeneration; }
139 return (fDecayFunc->GetParameter(1) > 0.) ? std::log(2.0) / fDecayFunc->GetParameter(1) : 0.0;
146 return (GetDecayRate() > 0.) ? GetHalfLife() * GetDecayRateError() / GetDecayRate() : 0.0;
152 fDecayFunc->SetParameter(1, std::log(2.0) / halflife);
157 fDecayFunc->SetParameter(1, decayrate);
162 fDecayFunc->SetParameter(0, intens);
168 fDecayFunc->FixParameter(1, std::log(2) / halflife);
173 fDecayFunc->FixParameter(1, GetHalfLife());
178 fDecayFunc->FixParameter(1, decayrate);
183 fDecayFunc->FixParameter(0, GetDecayRate());
186 void FixIntensity(
const Double_t& intensity) { fDecayFunc->FixParameter(0, intensity); }
188 void SetHalfLifeLimits(
const Double_t& low,
const Double_t& high);
189 void SetIntensityLimits(
const Double_t& low,
const Double_t& high);
190 void SetDecayRateLimits(
const Double_t& low,
const Double_t& high);
191 void GetHalfLifeLimits(Double_t& low, Double_t& high)
const;
192 void GetIntensityLimits(Double_t& low, Double_t& high)
const;
193 void GetDecayRateLimits(Double_t& low, Double_t& high)
const;
197 void Draw(Option_t* option =
"")
override;
198 Double_t Eval(Double_t t);
199 Double_t EvalPar(
const Double_t* x,
const Double_t* par =
nullptr);
200 TFitResultPtr Fit(TH1* fithist, Option_t* opt =
"");
203 void SetRange(Double_t tlow, Double_t thigh);
204 void SetName(
const char* name)
override;
205 void SetLineColor(Color_t color) { fTotalDecayFunc->SetLineColor(color); }
206 Color_t
GetLineColor()
const {
return fTotalDecayFunc->GetLineColor(); }
209 fTotalDecayFunc->SetMinimum(min);
210 fDecayFunc->SetMinimum(min);
214 fTotalDecayFunc->SetMaximum(max);
215 fDecayFunc->SetMaximum(max);
220 void SetTotalDecayParameters();
228 SetTotalDecayParameters();
229 return fTotalDecayFunc;
235 Double_t ActivityFunc(Double_t* dim, Double_t* par);
237 void Print(Option_t* option =
"")
const override;
249 SetTotalDecayParameters();
250 return fTotalDecayFunc;
253 UInt_t fGeneration{0};
254 Double_t fDetectionEfficiency{0.};
280 Double_t Eval(Double_t t) const;
281 void Draw(Option_t* opt = "") override;
282 Int_t Size()
const {
return static_cast<Int_t
>(fDecayChain.size()); }
284 void Print(Option_t* option =
"")
const override;
286 void SetChainParameters();
287 void SetRange(Double_t xlow, Double_t xhigh);
290 SetChainParameters();
293 void DrawComponents(Option_t* opt =
"", Bool_t color_flag =
true)
override;
294 TFitResultPtr Fit(TH1* fithist, Option_t* opt =
"");
295 Double_t EvalPar(
const Double_t* x,
const Double_t* par =
nullptr);
301 Double_t ChainActivityFunc(Double_t* dim, Double_t* par);
305 SetChainParameters();
341 explicit TDecay(std::vector<TDecayChain*> chainList);
348 void AddChain(
TDecayChain* chain) { fChainList.push_back(chain); }
349 Double_t DecayFit(Double_t* dim, Double_t* par);
352 void SetHalfLife(Int_t Id, Double_t halflife);
353 void SetHalfLifeLimits(Int_t Id, Double_t low, Double_t high);
354 void SetDecayRateLimits(Int_t Id, Double_t low, Double_t high);
357 SetHalfLife(Id, halflife);
358 SetHalfLifeLimits(Id, halflife, halflife);
360 TFitResultPtr Fit(TH1* fithist, Option_t* opt =
"");
362 void Print(Option_t* opt =
"")
const override;
363 void PrintMap()
const;
365 void SetBackground(Double_t background) { fFitFunc->SetParameter(0, background); }
368 void SetRange(Double_t xlow, Double_t xhigh);
369 void DrawComponents(Option_t* opt =
"", Bool_t color_flag =
true)
override;
370 void Draw(Option_t* opt =
"")
override;
371 void DrawBackground(Option_t* opt =
"");
372 void FixBackground(
const Double_t& background) { fFitFunc->FixParameter(0, background); }
374 void SetBackgroundLimits(
const Double_t& low,
const Double_t& high) { fFitFunc->SetParLimits(0, low, high); }
381 void SetParameters();
382 Double_t ComponentFunc(Double_t* dim, Double_t* par);
390 ClassDefOverride(
TDecay, 1)
std::vector< TSingleDecay * > fDecayChain
TDecayChain(const TDecayChain &)=default
static UInt_t fChainCounter
const TDecayFit * GetFitFunction() override
TDecayChain(TDecayChain &&) noexcept=default
const TDecayFit * GetChainFunc()
TDecayFit(const char *name, Double_t(*fcn)(Double_t *, Double_t *), Double_t xmin=0, Double_t xmax=1, Int_t npar=0)
void Print(Option_t *opt="") const override
TDecayFit(const char *name, Double_t xmin, Double_t xmax, Int_t npar)
TFitResultPtr Fit(TH1 *hist, Option_t *opt="")
TDecayFit(TDecayFit &&) noexcept=default
TDecayFit(const char *name, const PtrObj &p, MemFn memFn, Double_t xmin, Double_t xmax, Int_t npar, const char *className=nullptr, const char *methodName=nullptr)
void SetDecay(TVirtualDecay *decay)
TDecayFit(const char *name, const char *formula, Double_t xmin=0, Double_t xmax=1)
void DrawComponents() const
TDecayFit(const char *name, Double_t(*fcn)(const Double_t *, const Double_t *), Double_t xmin=0, Double_t xmax=1, Int_t npar=0)
void UpdateResiduals(TH1 *hist)
TDecayFit(const char *name, const ROOT::Math::ParamFunctor &f, Double_t xmin=0, Double_t xmax=1, Int_t npar=0)
TDecayFit(const char *name, Func f, Double_t xmin, Double_t xmax, Int_t npar, const char *className=nullptr)
TDecayFit(const TDecayFit &)=default
TVirtualDecay * GetDecay() const
TDecay(TDecay &&) noexcept=default
Double_t GetBackgroundError() const
std::map< Int_t, std::vector< TSingleDecay * > > fDecayMap
std::vector< TDecayChain * > fChainList
void SetBackgroundLimits(const Double_t &low, const Double_t &high)
Double_t GetBackground() const
const TDecayFit * GetFitFunction() override
TDecay(const TDecay &)=default
void FixHalfLife(Int_t Id, Double_t halflife)
void FixBackground(const Double_t &background)
void SetBackground(Double_t background)
void SetDecayRate(const Double_t &decayrate)
void FixHalfLife(const Double_t &halflife)
void SetDaughterDecay(TSingleDecay *daughter)
Color_t GetLineColor() const
Double_t GetHalfLife() const
Double_t GetDecayRateError() const
Double_t GetIntensityError() const
void SetMaximum(Double_t max)
void FixDecayRate(const Double_t &decayrate)
void SetChainId(Int_t id)
Double_t GetEfficiency() const
const TDecayFit * GetDecayFunc() const
void SetDecayRateError(Double_t err)
void SetMinimum(Double_t min)
void SetIntensity(const Double_t &intens)
void SetLineColor(Color_t color)
const TDecayFit * GetFitFunction() override
void FixIntensity(const Double_t &intensity)
Double_t GetDecayRate() const
void SetDecayId(Int_t Id)
void SetHalfLife(const Double_t &halflife)
Double_t GetHalfLifeError() const
void SetParentDecay(TSingleDecay *parent)
Double_t GetIntensity() const
void SetIntensityError(Double_t err)
const TDecayFit * GetTotalDecayFunc()
TSingleDecay(TSingleDecay &&) noexcept=default
void SetEfficiency(const Double_t &eff)
TSingleDecay(const TSingleDecay &)=default
virtual const TDecayFit * GetFitFunction()=0
void Print(Option_t *opt="") const override=0
virtual void DrawComponents(Option_t *opt="", Bool_t color_flag=true)
TVirtualDecay(TVirtualDecay &&) noexcept=default
TVirtualDecay(const TVirtualDecay &)=default