10#include "TFitResult.h"
11#include "TFitResultPtr.h"
24 TDecayFit(
const char* name,
const char* formula, Double_t xmin = 0, Double_t xmax = 1)
25 : TF1(name, formula, xmin, xmax)
29 TDecayFit(
const char* name, Double_t xmin, Double_t xmax, Int_t npar) : TF1(name, xmin, xmax, npar)
33 TDecayFit(
const char* name,
const ROOT::Math::ParamFunctor& f, Double_t xmin = 0, Double_t xmax = 1, Int_t npar = 0)
34 : TF1(name, f, xmin, xmax, npar)
38#if !defined(__CINT__) && !defined(__CLING__)
39 TDecayFit(
const char* name, Double_t (*fcn)(Double_t*, Double_t*), Double_t xmin = 0, Double_t xmax = 1, Int_t npar = 0)
40 : TF1(name, fcn, xmin, xmax, npar)
44 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)
45 : TF1(name, fcn, xmin, xmax, npar)
51 template <
class PtrObj,
typename MemFn>
52 TDecayFit(
const char* name,
const PtrObj& p, MemFn memFn, Double_t xmin, Double_t xmax, Int_t npar)
53 : TF1(name, p, memFn, xmin, xmax, npar)
58 template <
typename Func>
59 TDecayFit(
const char* name, Func f, Double_t xmin, Double_t xmax, Int_t npar,
const char* className =
nullptr)
60 : TF1(name, f, xmin, xmax, npar, className)
74 void Print(Option_t* opt = "") const override;
78 TFitResultPtr
Fit(TH1*
hist, Option_t* opt =
"");
100 virtual
void DrawComponents(Option_t* opt = "", Bool_t color_flag = true);
101 void Print(Option_t* opt = "") const override = 0;
119 : fDetectionEfficiency(1.0)
131 UInt_t GetGeneration()
const {
return fGeneration; }
134 return (fDecayFunc->GetParameter(1) > 0.) ? std::log(2.0) / fDecayFunc->GetParameter(1) : 0.0;
141 return (GetDecayRate() > 0.) ? GetHalfLife() * GetDecayRateError() / GetDecayRate() : 0.0;
147 fDecayFunc->SetParameter(1, std::log(2.0) / halflife);
152 fDecayFunc->SetParameter(1, decayrate);
157 fDecayFunc->SetParameter(0, intens);
163 fDecayFunc->FixParameter(1, std::log(2) / halflife);
168 fDecayFunc->FixParameter(1, GetHalfLife());
173 fDecayFunc->FixParameter(1, decayrate);
178 fDecayFunc->FixParameter(0, GetDecayRate());
181 void FixIntensity(
const Double_t& intensity) { fDecayFunc->FixParameter(0, intensity); }
183 void SetHalfLifeLimits(
const Double_t& low,
const Double_t& high);
184 void SetIntensityLimits(
const Double_t& low,
const Double_t& high);
185 void SetDecayRateLimits(
const Double_t& low,
const Double_t& high);
186 void GetHalfLifeLimits(Double_t& low, Double_t& high)
const;
187 void GetIntensityLimits(Double_t& low, Double_t& high)
const;
188 void GetDecayRateLimits(Double_t& low, Double_t& high)
const;
192 void Draw(Option_t* option =
"")
override;
193 Double_t Eval(Double_t t);
194 Double_t EvalPar(
const Double_t* x,
const Double_t* par =
nullptr);
195 TFitResultPtr Fit(TH1* fithist, Option_t* opt =
"");
198 void SetRange(Double_t tlow, Double_t thigh);
199 void SetName(
const char* name)
override;
200 void SetLineColor(Color_t color) { fTotalDecayFunc->SetLineColor(color); }
201 Color_t
GetLineColor()
const {
return fTotalDecayFunc->GetLineColor(); }
204 fTotalDecayFunc->SetMinimum(min);
205 fDecayFunc->SetMinimum(min);
209 fTotalDecayFunc->SetMaximum(max);
210 fDecayFunc->SetMaximum(max);
215 void SetTotalDecayParameters();
223 SetTotalDecayParameters();
224 return fTotalDecayFunc;
230 Double_t ActivityFunc(Double_t* dim, Double_t* par);
232 void Print(Option_t* option =
"")
const override;
244 SetTotalDecayParameters();
245 return fTotalDecayFunc;
248 UInt_t fGeneration{0};
249 Double_t fDetectionEfficiency{0.};
275 Double_t Eval(Double_t t) const;
276 void Draw(Option_t* opt = "") override;
277 Int_t Size()
const {
return static_cast<Int_t
>(fDecayChain.size()); }
279 void Print(Option_t* option =
"")
const override;
281 void SetChainParameters();
282 void SetRange(Double_t xlow, Double_t xhigh);
285 SetChainParameters();
288 void DrawComponents(Option_t* opt =
"", Bool_t color_flag =
true)
override;
289 TFitResultPtr Fit(TH1* fithist, Option_t* opt =
"");
290 Double_t EvalPar(
const Double_t* x,
const Double_t* par =
nullptr);
296 Double_t ChainActivityFunc(Double_t* dim, Double_t* par);
300 SetChainParameters();
336 explicit TDecay(std::vector<TDecayChain*> chainList);
343 void AddChain(
TDecayChain* chain) { fChainList.push_back(chain); }
344 Double_t DecayFit(Double_t* dim, Double_t* par);
347 void SetHalfLife(Int_t Id, Double_t halflife);
348 void SetHalfLifeLimits(Int_t Id, Double_t low, Double_t high);
349 void SetDecayRateLimits(Int_t Id, Double_t low, Double_t high);
352 SetHalfLife(Id, halflife);
353 SetHalfLifeLimits(Id, halflife, halflife);
355 TFitResultPtr Fit(TH1* fithist, Option_t* opt =
"");
357 void Print(Option_t* opt =
"")
const override;
358 void PrintMap()
const;
360 void SetBackground(Double_t background) { fFitFunc->SetParameter(0, background); }
363 void SetRange(Double_t xlow, Double_t xhigh);
364 void DrawComponents(Option_t* opt =
"", Bool_t color_flag =
true)
override;
365 void Draw(Option_t* opt =
"")
override;
366 void DrawBackground(Option_t* opt =
"");
367 void FixBackground(
const Double_t& background) { fFitFunc->FixParameter(0, background); }
369 void SetBackgroundLimits(
const Double_t& low,
const Double_t& high) { fFitFunc->SetParLimits(0, low, high); }
376 void SetParameters();
377 Double_t ComponentFunc(Double_t* dim, Double_t* par);
385 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)
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