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 const char* className =
nullptr,
const char* methodName =
nullptr)
54 : TF1(name, p, memFn, xmin, xmax, npar, className, methodName)
59 template <
typename Func>
60 TDecayFit(
const char* name, Func f, Double_t xmin, Double_t xmax, Int_t npar,
const char* className =
nullptr)
61 : TF1(name, f, xmin, xmax, npar, className)
75 void Print(Option_t* opt = "") const override;
79 TFitResultPtr
Fit(TH1*
hist, Option_t* opt =
"");
101 virtual
void DrawComponents(Option_t* opt = "", Bool_t color_flag = true);
102 void Print(Option_t* opt = "") const override = 0;
120 : fDetectionEfficiency(1.0)
132 UInt_t GetGeneration()
const {
return fGeneration; }
135 return (fDecayFunc->GetParameter(1) > 0.) ? std::log(2.0) / fDecayFunc->GetParameter(1) : 0.0;
142 return (GetDecayRate() > 0.) ? GetHalfLife() * GetDecayRateError() / GetDecayRate() : 0.0;
148 fDecayFunc->SetParameter(1, std::log(2.0) / halflife);
153 fDecayFunc->SetParameter(1, decayrate);
158 fDecayFunc->SetParameter(0, intens);
164 fDecayFunc->FixParameter(1, std::log(2) / halflife);
169 fDecayFunc->FixParameter(1, GetHalfLife());
174 fDecayFunc->FixParameter(1, decayrate);
179 fDecayFunc->FixParameter(0, GetDecayRate());
182 void FixIntensity(
const Double_t& intensity) { fDecayFunc->FixParameter(0, intensity); }
184 void SetHalfLifeLimits(
const Double_t& low,
const Double_t& high);
185 void SetIntensityLimits(
const Double_t& low,
const Double_t& high);
186 void SetDecayRateLimits(
const Double_t& low,
const Double_t& high);
187 void GetHalfLifeLimits(Double_t& low, Double_t& high)
const;
188 void GetIntensityLimits(Double_t& low, Double_t& high)
const;
189 void GetDecayRateLimits(Double_t& low, Double_t& high)
const;
193 void Draw(Option_t* option =
"")
override;
194 Double_t Eval(Double_t t);
195 Double_t EvalPar(
const Double_t* x,
const Double_t* par =
nullptr);
196 TFitResultPtr Fit(TH1* fithist, Option_t* opt =
"");
199 void SetRange(Double_t tlow, Double_t thigh);
200 void SetName(
const char* name)
override;
201 void SetLineColor(Color_t color) { fTotalDecayFunc->SetLineColor(color); }
202 Color_t
GetLineColor()
const {
return fTotalDecayFunc->GetLineColor(); }
205 fTotalDecayFunc->SetMinimum(min);
206 fDecayFunc->SetMinimum(min);
210 fTotalDecayFunc->SetMaximum(max);
211 fDecayFunc->SetMaximum(max);
216 void SetTotalDecayParameters();
224 SetTotalDecayParameters();
225 return fTotalDecayFunc;
231 Double_t ActivityFunc(Double_t* dim, Double_t* par);
233 void Print(Option_t* option =
"")
const override;
245 SetTotalDecayParameters();
246 return fTotalDecayFunc;
249 UInt_t fGeneration{0};
250 Double_t fDetectionEfficiency{0.};
276 Double_t Eval(Double_t t) const;
277 void Draw(Option_t* opt = "") override;
278 Int_t Size()
const {
return static_cast<Int_t
>(fDecayChain.size()); }
280 void Print(Option_t* option =
"")
const override;
282 void SetChainParameters();
283 void SetRange(Double_t xlow, Double_t xhigh);
286 SetChainParameters();
289 void DrawComponents(Option_t* opt =
"", Bool_t color_flag =
true)
override;
290 TFitResultPtr Fit(TH1* fithist, Option_t* opt =
"");
291 Double_t EvalPar(
const Double_t* x,
const Double_t* par =
nullptr);
297 Double_t ChainActivityFunc(Double_t* dim, Double_t* par);
301 SetChainParameters();
337 explicit TDecay(std::vector<TDecayChain*> chainList);
344 void AddChain(
TDecayChain* chain) { fChainList.push_back(chain); }
345 Double_t DecayFit(Double_t* dim, Double_t* par);
348 void SetHalfLife(Int_t Id, Double_t halflife);
349 void SetHalfLifeLimits(Int_t Id, Double_t low, Double_t high);
350 void SetDecayRateLimits(Int_t Id, Double_t low, Double_t high);
353 SetHalfLife(Id, halflife);
354 SetHalfLifeLimits(Id, halflife, halflife);
356 TFitResultPtr Fit(TH1* fithist, Option_t* opt =
"");
358 void Print(Option_t* opt =
"")
const override;
359 void PrintMap()
const;
361 void SetBackground(Double_t background) { fFitFunc->SetParameter(0, background); }
364 void SetRange(Double_t xlow, Double_t xhigh);
365 void DrawComponents(Option_t* opt =
"", Bool_t color_flag =
true)
override;
366 void Draw(Option_t* opt =
"")
override;
367 void DrawBackground(Option_t* opt =
"");
368 void FixBackground(
const Double_t& background) { fFitFunc->FixParameter(0, background); }
370 void SetBackgroundLimits(
const Double_t& low,
const Double_t& high) { fFitFunc->SetParLimits(0, low, high); }
377 void SetParameters();
378 Double_t ComponentFunc(Double_t* dim, Double_t* par);
386 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