ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
ZDCFitExpFermiLinearFixedTaus Class Reference

#include <ZDCFitWrapper.h>

Inheritance diagram for ZDCFitExpFermiLinearFixedTaus:
Collaboration diagram for ZDCFitExpFermiLinearFixedTaus:

Public Member Functions

 ZDCFitExpFermiLinearFixedTaus (const std::string &tag, float tmin, float tmax, float tau1, float tau2)
 
 ~ZDCFitExpFermiLinearFixedTaus ()
 
virtual void DoInitialize (float initialAmp, float initialT0, float ampMin, float ampMax) override
 
virtual void SetT0FitLimits (float tMin, float tMax) override
 
virtual void ConstrainFit () override
 
virtual void UnconstrainFit () override
 
virtual float GetAmplitude () const override
 
virtual float GetAmpError () const override
 
virtual float GetTau1 () const override
 
virtual float GetTau2 () const override
 
virtual float GetTime () const override
 
virtual float GetShapeParameter (size_t index) const override
 
virtual float GetBkgdMaxFraction () const override
 
virtual double operator() (const double *x, const double *p) override
 
void Initialize (float initialAmp, float initialT0, float ampMin, float ampMax)
 
void Initialize (float initialAmp, float initialT0, float ampMin, float ampMax, float fitTmin, float fitTmax, float fitTRef)
 
void SetAmpMinMax (float minAmp, float maxAmp)
 
void SetT0Range (float t0Min, float t0Max)
 
float GetMinAmp () const
 
float GetMaxAmp () const
 
float GetTMin () const
 
float GetTMax () const
 
float GetT0Min () const
 
float GetT0Max () const
 
float GetTMinAdjust () const
 
virtual std::shared_ptr< TF1 > GetWrapperTF1 ()
 
virtual const TF1 * GetWrapperTF1 () const
 
virtual TF1 * GetWrapperTF1RawPtr () const
 

Private Attributes

float m_tau1
 
float m_tau2
 
float m_norm
 
float m_timeCorr
 
std::shared_ptr< TF1 > m_expFermiFunc
 
std::shared_ptr< TF1 > m_wrapperTF1 {}
 
float m_tmin {0}
 
float m_tmax {0}
 
float m_ampMin {0}
 
float m_ampMax {0}
 
float m_t0Min {0}
 
float m_t0Max {0}
 
bool m_adjTLimitsEvent {false}
 
float m_tminAdjust {0}
 
float m_tempTmin {0}
 
float m_tempTmax {0}
 

Detailed Description

Definition at line 784 of file ZDCFitWrapper.h.

Constructor & Destructor Documentation

◆ ZDCFitExpFermiLinearFixedTaus()

ZDCFitExpFermiLinearFixedTaus::ZDCFitExpFermiLinearFixedTaus ( const std::string &  tag,
float  tmin,
float  tmax,
float  tau1,
float  tau2 
)

Definition at line 683 of file ZDCFitWrapper.cxx.

683  :
684  ZDCFitWrapper(std::make_shared<TF1>(("ExpFermiFixedTaus" + tag).c_str(), this, tmin, tmax, 4)),
685  m_tau1(tau1), m_tau2(tau2)
686 {
687  std::shared_ptr<TF1> theTF1 = GetWrapperTF1();
688 
689  // BAC, parameter 0 limits now is set in DoInitialize
690  theTF1->SetParLimits(1, tmin, tmax);
691 
692  theTF1->SetParName(0, "Amp");
693  theTF1->SetParName(1, "T0");
694  theTF1->SetParName(2, "s_{b}");
695  theTF1->SetParName(3, "c_{b}");
696 
697  // Now create the reference function that we use to evaluate ExpFermiFit more efficiently
698  //
699  std::string funcNameRefFunc = "ExpFermiFixedTausRefFunc" + tag;
700 
701  m_expFermiFunc = std::make_shared<TF1>(funcNameRefFunc.c_str(), ZDCFermiExpFit, -50, 100, 5);
702 
703  m_expFermiFunc->SetParameter(0, 1);
704  m_expFermiFunc->SetParameter(1, 0);
705  m_expFermiFunc->SetParameter(2, m_tau1);
706  m_expFermiFunc->SetParameter(3, m_tau2);
707  m_expFermiFunc->FixParameter(4, 0);
708 
709  m_norm = 1. / m_expFermiFunc->GetMaximum();
710  m_timeCorr = m_tau1 * std::log(m_tau2 / m_tau1 - 1.0);
711 }

◆ ~ZDCFitExpFermiLinearFixedTaus()

ZDCFitExpFermiLinearFixedTaus::~ZDCFitExpFermiLinearFixedTaus ( )
inline

Definition at line 799 of file ZDCFitWrapper.h.

799 {}

Member Function Documentation

◆ ConstrainFit()

void ZDCFitExpFermiLinearFixedTaus::ConstrainFit ( )
overridevirtual

Implements ZDCFitWrapper.

Definition at line 713 of file ZDCFitWrapper.cxx.

714 {
715  // We force the linear terms to zero
716  //
717  std::shared_ptr<TF1> theTF1 = GetWrapperTF1();
718 
719  theTF1->FixParameter(2, 0);
720  theTF1->FixParameter(3, 0);
721 }

◆ DoInitialize()

void ZDCFitExpFermiLinearFixedTaus::DoInitialize ( float  initialAmp,
float  initialT0,
float  ampMin,
float  ampMax 
)
overridevirtual

Implements ZDCFitWrapper.

Definition at line 730 of file ZDCFitWrapper.cxx.

731 {
732  float slope = std::abs(0.1 * initialAmp / initialT0);
733  float intercept = std::abs(0.1 * initialAmp);
734  GetWrapperTF1()->SetParLimits(2, -slope , slope );
735  GetWrapperTF1()->SetParLimits(3, -intercept, intercept);
736 
737  GetWrapperTF1()->SetParameter(0, initialAmp);
738  GetWrapperTF1()->SetParameter(1, initialT0);
739  GetWrapperTF1()->SetParameter(2, 0);
740  GetWrapperTF1()->SetParameter(3, 0);
741 
742  GetWrapperTF1()->SetParLimits(0, ampMin, ampMax);
743 
744  double ampStep = std::min(0.05*initialAmp, std::abs(ampMax - initialAmp)/2.);
745 
746  GetWrapperTF1()->SetParError(0, ampStep);
747  GetWrapperTF1()->SetParError(1, 1);
748  GetWrapperTF1()->SetParError(2, 1);
749  GetWrapperTF1()->SetParError(3, 0.5);
750 }

◆ GetAmpError()

virtual float ZDCFitExpFermiLinearFixedTaus::GetAmpError ( ) const
inlineoverridevirtual

Implements ZDCFitWrapper.

Definition at line 808 of file ZDCFitWrapper.h.

808 {return GetWrapperTF1()->GetParError(0); }

◆ GetAmplitude()

virtual float ZDCFitExpFermiLinearFixedTaus::GetAmplitude ( ) const
inlineoverridevirtual

Implements ZDCFitWrapper.

Definition at line 807 of file ZDCFitWrapper.h.

807 {return GetWrapperTF1()->GetParameter(0); }

◆ GetBkgdMaxFraction()

virtual float ZDCFitExpFermiLinearFixedTaus::GetBkgdMaxFraction ( ) const
inlineoverridevirtual

Implements ZDCFitWrapper.

Definition at line 824 of file ZDCFitWrapper.h.

825  {
826  const TF1* theTF1 = ZDCFitWrapper::GetWrapperTF1();
827  double amp = theTF1->GetParameter(0);
828  double slope = theTF1->GetParameter(2);
829 
830  double background = slope * GetTime();
831  return background / amp;
832  }

◆ GetMaxAmp()

float ZDCFitWrapper::GetMaxAmp ( ) const
inlineinherited

Definition at line 87 of file ZDCFitWrapper.h.

87 {return m_ampMax;}

◆ GetMinAmp()

float ZDCFitWrapper::GetMinAmp ( ) const
inlineinherited

Definition at line 86 of file ZDCFitWrapper.h.

86 {return m_ampMin;}

◆ GetShapeParameter()

virtual float ZDCFitExpFermiLinearFixedTaus::GetShapeParameter ( size_t  index) const
inlineoverridevirtual

Implements ZDCFitWrapper.

Definition at line 817 of file ZDCFitWrapper.h.

818  {
819  if (index == 0) return m_tau1;
820  else if (index == 1) return m_tau2;
821  else throw std::runtime_error("Fit parameter does not exist.");
822  }

◆ GetT0Max()

float ZDCFitWrapper::GetT0Max ( ) const
inlineinherited

Definition at line 97 of file ZDCFitWrapper.h.

97  {
98  if (m_adjTLimitsEvent) return m_tempTmax;
99  else return m_t0Max;
100  }

◆ GetT0Min()

float ZDCFitWrapper::GetT0Min ( ) const
inlineinherited

Definition at line 92 of file ZDCFitWrapper.h.

92  {
93  if (m_adjTLimitsEvent) return m_tempTmin;
94  else return m_t0Min;
95  }

◆ GetTau1()

virtual float ZDCFitExpFermiLinearFixedTaus::GetTau1 ( ) const
inlineoverridevirtual

Implements ZDCFitWrapper.

Definition at line 810 of file ZDCFitWrapper.h.

810 {return m_tau1;}

◆ GetTau2()

virtual float ZDCFitExpFermiLinearFixedTaus::GetTau2 ( ) const
inlineoverridevirtual

Implements ZDCFitWrapper.

Definition at line 811 of file ZDCFitWrapper.h.

811 {return m_tau2;}

◆ GetTime()

virtual float ZDCFitExpFermiLinearFixedTaus::GetTime ( ) const
inlineoverridevirtual

Implements ZDCFitWrapper.

Definition at line 813 of file ZDCFitWrapper.h.

813  {
814  return GetWrapperTF1()->GetParameter(1) + m_timeCorr; // Correct the time to the maximum
815  }

◆ GetTMax()

float ZDCFitWrapper::GetTMax ( ) const
inlineinherited

Definition at line 90 of file ZDCFitWrapper.h.

90 {return m_tmax;}

◆ GetTMin()

float ZDCFitWrapper::GetTMin ( ) const
inlineinherited

Definition at line 89 of file ZDCFitWrapper.h.

89 {return m_tmin;}

◆ GetTMinAdjust()

float ZDCFitWrapper::GetTMinAdjust ( ) const
inlineinherited

Definition at line 102 of file ZDCFitWrapper.h.

102 {return m_tminAdjust;}

◆ GetWrapperTF1() [1/2]

virtual std::shared_ptr<TF1> ZDCFitWrapper::GetWrapperTF1 ( )
inlinevirtualinherited

Definition at line 110 of file ZDCFitWrapper.h.

110 {return m_wrapperTF1;}

◆ GetWrapperTF1() [2/2]

virtual const TF1* ZDCFitWrapper::GetWrapperTF1 ( ) const
inlinevirtualinherited

Definition at line 111 of file ZDCFitWrapper.h.

111 {return m_wrapperTF1.get();}

◆ GetWrapperTF1RawPtr()

virtual TF1* ZDCFitWrapper::GetWrapperTF1RawPtr ( ) const
inlinevirtualinherited

Definition at line 112 of file ZDCFitWrapper.h.

112 {return m_wrapperTF1.get();}

◆ Initialize() [1/2]

void ZDCFitWrapper::Initialize ( float  initialAmp,
float  initialT0,
float  ampMin,
float  ampMax 
)
inherited

Definition at line 9 of file ZDCFitWrapper.cxx.

10 {
11  // Clear the errors on the TF1 because retaining the errors seems to affect
12  // the convergence of fits
13  //
14  unsigned int npar = GetWrapperTF1()->GetNpar();
15  std::vector<double> zeroVec(npar, 0.0);
16  GetWrapperTF1()->SetParErrors(&zeroVec[0]);
17 
18  // If we adjusted the time range on the previous event, restore to default
19  //
20  if (m_adjTLimitsEvent) {
22 
23  m_adjTLimitsEvent = false;
24  m_tminAdjust = 0;
25  }
26 
27  SetAmpMinMax(ampMin, ampMax);
28 
29  DoInitialize(initialAmp, initialT0, ampMin, ampMax);
30 }

◆ Initialize() [2/2]

void ZDCFitWrapper::Initialize ( float  initialAmp,
float  initialT0,
float  ampMin,
float  ampMax,
float  fitTmin,
float  fitTmax,
float  fitTRef 
)
inherited

Definition at line 32 of file ZDCFitWrapper.cxx.

33 {
34  // Clear the errors on the TF1 because retaining the errors seems to affect
35  // the convergence of fits
36  //
37  unsigned int npar = GetWrapperTF1()->GetNpar();
38  std::vector<double> zeroVec(npar, 0.0);
39  GetWrapperTF1()->SetParErrors(&zeroVec[0]);
40 
41  m_adjTLimitsEvent = true;
42 
43  m_tminAdjust = fitTRef; // Note: this is the time corresponding to the sample used for presample subtraction
44 
45  m_tempTmin = std::max(m_t0Min, fitTmin);
46  m_tempTmax = std::min(m_t0Max, fitTmax);
47 
48  SetAmpMinMax(ampMin, ampMax);
50 
51  DoInitialize(initialAmp, initialT0, ampMin, ampMax);
52 }

◆ operator()()

virtual double ZDCFitExpFermiLinearFixedTaus::operator() ( const double *  x,
const double *  p 
)
inlineoverridevirtual

Implements ZDCFitWrapper.

Definition at line 834 of file ZDCFitWrapper.h.

835  {
836  double amp = p[0];
837  double t0 = p[1];
838  double deltaT = x[0] - t0;
839 
840  double bckgd = p[2] * x[0] + p[3];
841 
842  double expFermi = amp * m_norm * m_expFermiFunc->operator()(deltaT);
843 
844  return expFermi + bckgd;
845  }

◆ SetAmpMinMax()

void ZDCFitWrapper::SetAmpMinMax ( float  minAmp,
float  maxAmp 
)
inlineinherited

Definition at line 63 of file ZDCFitWrapper.h.

64  {
65  m_ampMin = minAmp;
66  m_ampMax = maxAmp;
67  }

◆ SetT0FitLimits()

void ZDCFitExpFermiLinearFixedTaus::SetT0FitLimits ( float  tMin,
float  tMax 
)
overridevirtual

Implements ZDCFitWrapper.

Definition at line 752 of file ZDCFitWrapper.cxx.

753 {
754  std::shared_ptr<TF1> theTF1 = GetWrapperTF1();
755  theTF1->SetParLimits(1, t0Min, t0Max);
756 }

◆ SetT0Range()

void ZDCFitWrapper::SetT0Range ( float  t0Min,
float  t0Max 
)
inlineinherited

Definition at line 69 of file ZDCFitWrapper.h.

70  {
71  m_t0Min = t0Min;
72  m_t0Max = t0Max;
73 
74  SetT0FitLimits(t0Min, t0Max);
75  }

◆ UnconstrainFit()

void ZDCFitExpFermiLinearFixedTaus::UnconstrainFit ( )
overridevirtual

Implements ZDCFitWrapper.

Definition at line 723 of file ZDCFitWrapper.cxx.

724 {
725  std::shared_ptr<TF1> theTF1 = GetWrapperTF1();
726  theTF1->ReleaseParameter(2);
727  theTF1->ReleaseParameter(3);
728 }

Member Data Documentation

◆ m_adjTLimitsEvent

bool ZDCFitWrapper::m_adjTLimitsEvent {false}
privateinherited

Definition at line 32 of file ZDCFitWrapper.h.

◆ m_ampMax

float ZDCFitWrapper::m_ampMax {0}
privateinherited

Definition at line 27 of file ZDCFitWrapper.h.

◆ m_ampMin

float ZDCFitWrapper::m_ampMin {0}
privateinherited

Definition at line 26 of file ZDCFitWrapper.h.

◆ m_expFermiFunc

std::shared_ptr<TF1> ZDCFitExpFermiLinearFixedTaus::m_expFermiFunc
private

Definition at line 793 of file ZDCFitWrapper.h.

◆ m_norm

float ZDCFitExpFermiLinearFixedTaus::m_norm
private

Definition at line 790 of file ZDCFitWrapper.h.

◆ m_t0Max

float ZDCFitWrapper::m_t0Max {0}
privateinherited

Definition at line 30 of file ZDCFitWrapper.h.

◆ m_t0Min

float ZDCFitWrapper::m_t0Min {0}
privateinherited

Definition at line 29 of file ZDCFitWrapper.h.

◆ m_tau1

float ZDCFitExpFermiLinearFixedTaus::m_tau1
private

Definition at line 787 of file ZDCFitWrapper.h.

◆ m_tau2

float ZDCFitExpFermiLinearFixedTaus::m_tau2
private

Definition at line 788 of file ZDCFitWrapper.h.

◆ m_tempTmax

float ZDCFitWrapper::m_tempTmax {0}
privateinherited

Definition at line 35 of file ZDCFitWrapper.h.

◆ m_tempTmin

float ZDCFitWrapper::m_tempTmin {0}
privateinherited

Definition at line 34 of file ZDCFitWrapper.h.

◆ m_timeCorr

float ZDCFitExpFermiLinearFixedTaus::m_timeCorr
private

Definition at line 791 of file ZDCFitWrapper.h.

◆ m_tmax

float ZDCFitWrapper::m_tmax {0}
privateinherited

Definition at line 24 of file ZDCFitWrapper.h.

◆ m_tmin

float ZDCFitWrapper::m_tmin {0}
privateinherited

Definition at line 23 of file ZDCFitWrapper.h.

◆ m_tminAdjust

float ZDCFitWrapper::m_tminAdjust {0}
privateinherited

Definition at line 33 of file ZDCFitWrapper.h.

◆ m_wrapperTF1

std::shared_ptr<TF1> ZDCFitWrapper::m_wrapperTF1 {}
privateinherited

Definition at line 21 of file ZDCFitWrapper.h.


The documentation for this class was generated from the following files:
ZDCFitWrapper::ZDCFitWrapper
ZDCFitWrapper(const std::shared_ptr< TF1 > &wrapperTF1)
Definition: ZDCFitWrapper.h:43
ZDCFitWrapper::m_wrapperTF1
std::shared_ptr< TF1 > m_wrapperTF1
Definition: ZDCFitWrapper.h:21
ZDCFitWrapper::m_tmin
float m_tmin
Definition: ZDCFitWrapper.h:23
ZDCFitWrapper::SetT0FitLimits
virtual void SetT0FitLimits(float tMin, float tMax)=0
ZDCFitWrapper::DoInitialize
virtual void DoInitialize(float initialAmp, float initialT0, float ampMin, float ampMax)=0
index
Definition: index.py:1
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
ZDCFitExpFermiLinearFixedTaus::m_timeCorr
float m_timeCorr
Definition: ZDCFitWrapper.h:791
ZDCFitWrapper::m_ampMin
float m_ampMin
Definition: ZDCFitWrapper.h:26
ALFA_EventTPCnv_Dict::t0
std::vector< ALFA_RawData_p1 > t0
Definition: ALFA_EventTPCnvDict.h:42
ZDCFitWrapper::m_t0Max
float m_t0Max
Definition: ZDCFitWrapper.h:30
ZDCFitWrapper::GetWrapperTF1
virtual std::shared_ptr< TF1 > GetWrapperTF1()
Definition: ZDCFitWrapper.h:110
ZDCFitWrapper::m_adjTLimitsEvent
bool m_adjTLimitsEvent
Definition: ZDCFitWrapper.h:32
ZDCFitWrapper::m_tempTmax
float m_tempTmax
Definition: ZDCFitWrapper.h:35
ZDCFitExpFermiLinearFixedTaus::m_tau2
float m_tau2
Definition: ZDCFitWrapper.h:788
x
#define x
ZDCFitWrapper::m_ampMax
float m_ampMax
Definition: ZDCFitWrapper.h:27
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ZDCFitExpFermiLinearFixedTaus::GetTime
virtual float GetTime() const override
Definition: ZDCFitWrapper.h:813
ZDCFitExpFermiLinearFixedTaus::m_norm
float m_norm
Definition: ZDCFitWrapper.h:790
ZDCFitWrapper::m_t0Min
float m_t0Min
Definition: ZDCFitWrapper.h:29
ZDCFitWrapper::m_tminAdjust
float m_tminAdjust
Definition: ZDCFitWrapper.h:33
ZDCFitWrapper::m_tmax
float m_tmax
Definition: ZDCFitWrapper.h:24
ZDCFitWrapper::SetAmpMinMax
void SetAmpMinMax(float minAmp, float maxAmp)
Definition: ZDCFitWrapper.h:63
ZDCFitExpFermiLinearFixedTaus::m_tau1
float m_tau1
Definition: ZDCFitWrapper.h:787
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
ZDCFitExpFermiLinearFixedTaus::m_expFermiFunc
std::shared_ptr< TF1 > m_expFermiFunc
Definition: ZDCFitWrapper.h:793
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
ZDCFitWrapper::m_tempTmin
float m_tempTmin
Definition: ZDCFitWrapper.h:34
ZDCFermiExpFit
double ZDCFermiExpFit(const double *xvec, const double *pvec)
Definition: ZDCFitWrapper.h:1209