Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Static Private Member Functions | Private Attributes | List of all members
JCALIBRATE::JFitToT Struct Reference

Parametrisation of time-over-threshold distribution. More...

#include <JFitToT.hh>

Inheritance diagram for JCALIBRATE::JFitToT:
JCALIBRATE::JFitToTParameters

Public Member Functions

 JFitToT (const JPMTParameters &parameters, const JRange_t &range)
 Constructor. More...
 
void fitInit (TH1 &h1, const double gradientThreshold=-0.005)
 Fit initializer. More...
 
TFitResultPtr operator() (TH1 &h1, const double minWeight, const std::string &option)
 Fit histogram. More...
 
Double_t getValue (Double_t *x, Double_t *par)
 Get rate as a function of the fit parameters. More...
 
const double getInitGain () const
 Retrieve initial gain. More...
 
const double getInitGainSpread () const
 Retrieve initial gainspread. More...
 
const Double_t * getModelParameters () const
 Get model parameters. More...
 
Double_t * getModelParameters ()
 Get model parameters. More...
 
void setModelParameter (const int i, const Double_t value)
 Set model parameter. More...
 
void setModelParameters (const Double_t *data)
 Set model parameters. More...
 
const Double_t getModelParameter (const int i) const
 Get model parameter. More...
 
JFitParameter_t getModelParameter (Double_t JFitToTParameters::*p) const
 Get model parameter. More...
 

Static Public Member Functions

static Int_t getNumberOfModelParameters ()
 Get number of model parameters. More...
 

Public Attributes

Double_t gain
 PMT gain. More...
 
Double_t gainSpread
 PMT gain spread. More...
 

Static Private Member Functions

static
JPMTAnalogueSignalProcessor
getInstance ()
 Get unique instance of PMT analogue signal processor. More...
 

Private Attributes

JRange_t fitRange
 fit-range [ns] More...
 
double WfitRange
 Cumulative weight within fit-range. More...
 
double init_gain
 Initial input value for gain. More...
 
double init_gainSpread
 Initial input value for gainSpread. More...
 
const int NPE
 True number of photo-electrons. More...
 

Detailed Description

Parametrisation of time-over-threshold distribution.

Note that for use in ROOT fit operations, the member method JFitToT::getValue is static.

Definition at line 173 of file JFitToT.hh.

Constructor & Destructor Documentation

JCALIBRATE::JFitToT::JFitToT ( const JPMTParameters parameters,
const JRange_t range 
)
inline

Constructor.

Parameters
parametersparameters
rangeabscissa range

Definition at line 184 of file JFitToT.hh.

184  :
185 
187 
188  TF1 (FITTOT_FNAME.c_str(),
189  this,
191  range.getLowerLimit(),
192  range.getUpperLimit(),
194 
195  fitRange (range),
196  WfitRange (1.0),
197 
198  NPE (1)
199  {
201 
204  }
static Int_t getNumberOfModelParameters()
Get number of model parameters.
Definition: JFitToT.hh:82
double gain
gain [unit]
double gainSpread
gain spread [unit]
static JPMTAnalogueSignalProcessor & getInstance()
Get unique instance of PMT analogue signal processor.
Definition: JFitToT.hh:374
void setPMTParameters(const JPMTParameters &parameters)
Set PMT parameters.
Double_t getValue(Double_t *x, Double_t *par)
Get rate as a function of the fit parameters.
Definition: JFitToT.hh:329
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
JFitToTParameters(const JPMTParameters &parameters)
Constructor.
Definition: JFitToT.hh:56
double init_gain
Initial input value for gain.
Definition: JFitToT.hh:384
double init_gainSpread
Initial input value for gainSpread.
Definition: JFitToT.hh:385
JRange_t fitRange
fit-range [ns]
Definition: JFitToT.hh:381
const int NPE
True number of photo-electrons.
Definition: JFitToT.hh:387
double WfitRange
Cumulative weight within fit-range.
Definition: JFitToT.hh:382
static const std::string FITTOT_FNAME
Definition: JFitToT.hh:45

Member Function Documentation

void JCALIBRATE::JFitToT::fitInit ( TH1 &  h1,
const double  gradientThreshold = -0.005 
)
inline

Fit initializer.

Parameters
h1ROOT 1D-histogram
gradientThresholdtreshold gradient for search of maximum

Definition at line 213 of file JFitToT.hh.

214  {
215  using namespace std;
216  using namespace JPP;
217 
218  // Find gain and gainspread initial values
219  const Int_t N = h1.GetXaxis()->GetNbins();
220 
221  double max = h1.GetBinContent(N);
222  double mode = h1.GetBinCenter(N);
223 
224  for (int i = h1.GetBinCenter(N-1);
225  i > h1.GetBinCenter(h1.FindBin(getInstance().mean_ns));
226  --i) {
227 
228  const double x = h1.GetBinCenter (i);
229  const double y = h1.GetBinContent(i);
230 
231  const double gradient = ( (h1.GetBinContent(i-1) - h1.GetBinContent(i+1)) /
232  (h1.GetBinCenter (i+1) - h1.GetBinCenter (i-1)) );
233 
234  if (y > max) {
235 
236  mode = x;
237  max = y;
238 
239  } else if (gradient < gradientThreshold) {
240 
241  break;
242  }
243  }
244 
245  init_gain = getInstance().getNPE(mode);
247  init_gain / 3.0 : FITTOT_GAINSPREAD_MIN ); // Range rule of thumb
248 
249 
250  // Set parameter names and initial values
251  const Int_t Ngain = this->getModelParameter(&JFitToT::gain);
252  const Int_t NgainSpread = this->getModelParameter(&JFitToT::gainSpread);
253 
254  this->SetParName(Ngain, MAKE_CSTRING("gain"));
255  this->SetParName(NgainSpread, MAKE_CSTRING("gainSpread"));
256 
259 
261  setModelParameter(NgainSpread, init_gainSpread);
262 
263  this->SetParameters(this->getModelParameters());
264 
265 
266  // Set parameter ranges
269 
270 
271  // Set fit range and compute corresponding histogram weight
272  if (!fitRange.is_valid()) {
274  mode + FITTOT_TOT_RMARGIN);
275  }
276 
277  fitRange.setRange(std::max(h1.GetXaxis()->GetXmin(), fitRange.getLowerLimit()),
278  std::min(h1.GetXaxis()->GetXmax(), fitRange.getUpperLimit()));
279 
280  WfitRange = h1.Integral(h1.FindBin(fitRange.getLowerLimit()),
281  h1.FindBin(fitRange.getUpperLimit()));
282 
283  this->SetRange(fitRange.getLowerLimit(), fitRange.getUpperLimit());
284  }
double gain
gain [unit]
const Double_t getModelParameter(const int i) const
Get model parameter.
Definition: JFitToT.hh:141
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:215
double gainSpread
gain spread [unit]
static JPMTAnalogueSignalProcessor & getInstance()
Get unique instance of PMT analogue signal processor.
Definition: JFitToT.hh:374
static const double FITTOT_GAIN_MAX
Maximal gain.
Definition: JFitToT.hh:37
Double_t gainSpread
PMT gain spread.
Definition: JFitToT.hh:164
static const double FITTOT_GAIN_MIN
Minimal gain.
Definition: JFitToT.hh:36
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:708
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
const Double_t * getModelParameters() const
Get model parameters.
Definition: JFitToT.hh:93
static const double FITTOT_GAINSPREAD_MAX
Maximal gain spread.
Definition: JFitToT.hh:40
double init_gain
Initial input value for gain.
Definition: JFitToT.hh:384
void setRange(const range_type &range)
Set range.
Definition: JRange.hh:139
T getUpperLimit() const
Get upper limit.
Definition: JRange.hh:226
Double_t gain
PMT gain.
Definition: JFitToT.hh:163
bool setParLimits(TF1 &f1, const Int_t index, Double_t xmin, Double_t xmax)
Set fit parameter limits.
double init_gainSpread
Initial input value for gainSpread.
Definition: JFitToT.hh:385
virtual double getNPE(const double tot_ns, const double eps=1.0e-3) const
Get number of photo-electrons.
bool is_valid() const
Check validity of range.
Definition: JRange.hh:324
JRange_t fitRange
fit-range [ns]
Definition: JFitToT.hh:381
void setModelParameter(const int i, const Double_t value)
Set model parameter.
Definition: JFitToT.hh:116
static const double FITTOT_GAINSPREAD_MIN
Minimal gain spread.
Definition: JFitToT.hh:39
double WfitRange
Cumulative weight within fit-range.
Definition: JFitToT.hh:382
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition: JMuonPostfit.sh:37
static const double FITTOT_TOT_RMARGIN
Fit-region right of peak [ns].
Definition: JFitToT.hh:43
static const double FITTOT_TOT_LMARGIN
Fit-region left of peak [ns].
Definition: JFitToT.hh:42
TFitResultPtr JCALIBRATE::JFitToT::operator() ( TH1 &  h1,
const double  minWeight,
const std::string &  option 
)
inline

Fit histogram.

Note that the PMT parameters which are part of the model are reset before the fit according the status of each PMT and the obtained fit parameters are copied back to the model parameters after the fit.

Parameters
h1ROOT 1D-histogram
minWeightminimum histogram weight in fit-range
optionfit option

Definition at line 297 of file JFitToT.hh.

298  {
299  using namespace std;
300  using namespace JPP;
301 
302  fitInit(h1);
303 
304  if (WfitRange > minWeight &&
306 
307  const TFitResultPtr result = h1.Fit(this, option.c_str());
308 
309  this->setModelParameters(this->GetParameters());
310 
311  const double ToTcheck = getInstance().getTimeOverThreshold(gain);
312 
313  return (fitRange(ToTcheck) ? result : TFitResultPtr());
314 
315  } else {
316 
317  return TFitResultPtr();
318  }
319  }
static JPMTAnalogueSignalProcessor & getInstance()
Get unique instance of PMT analogue signal processor.
Definition: JFitToT.hh:374
static const double FITTOT_GAIN_MAX
Maximal gain.
Definition: JFitToT.hh:37
static const double FITTOT_GAIN_MIN
Minimal gain.
Definition: JFitToT.hh:36
virtual double getTimeOverThreshold(const double npe) const
Get time-over-threshold (ToT).
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
void fitInit(TH1 &h1, const double gradientThreshold=-0.005)
Fit initializer.
Definition: JFitToT.hh:213
double init_gain
Initial input value for gain.
Definition: JFitToT.hh:384
return result
Definition: JPolint.hh:695
Double_t gain
PMT gain.
Definition: JFitToT.hh:163
void setModelParameters(const Double_t *data)
Set model parameters.
Definition: JFitToT.hh:127
JRange_t fitRange
fit-range [ns]
Definition: JFitToT.hh:381
double WfitRange
Cumulative weight within fit-range.
Definition: JFitToT.hh:382
Double_t JCALIBRATE::JFitToT::getValue ( Double_t *  x,
Double_t *  par 
)
inline

Get rate as a function of the fit parameters.

Parameters
xpointer to abscissa values
parpointer to parameter values
Returns
rate distribution at specified time-over-threshold [Hz/ns]

Definition at line 329 of file JFitToT.hh.

330  {
331  const Double_t tot_ns = x[0];
332 
333  getInstance().gain = par[0];
334  getInstance().gainSpread = par[1];
335 
336  // Compute total weight (= histogram weight within fit range
337  // plus pdf weight outside fit range)
338  const double Wtot = (WfitRange +
341  NPE));
342 
343  return Wtot * getInstance().getTimeOverThresholdProbability(tot_ns, NPE);
344  }
double gain
gain [unit]
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:215
double gainSpread
gain spread [unit]
static JPMTAnalogueSignalProcessor & getInstance()
Get unique instance of PMT analogue signal processor.
Definition: JFitToT.hh:374
T getUpperLimit() const
Get upper limit.
Definition: JRange.hh:226
JRange_t fitRange
fit-range [ns]
Definition: JFitToT.hh:381
double getIntegralOfTimeOverThresholdProbability(const double Tmin, const double Tmax, const int NPE) const
Get cumulative probability of time-over-threshold distribution.
double getTimeOverThresholdProbability(const double tot_ns, const int NPE) const
Get probability of having a pulse with specific time-over-threshold.
const int NPE
True number of photo-electrons.
Definition: JFitToT.hh:387
double WfitRange
Cumulative weight within fit-range.
Definition: JFitToT.hh:382
const double JCALIBRATE::JFitToT::getInitGain ( ) const
inline

Retrieve initial gain.

Returns
initial gain setting

Definition at line 352 of file JFitToT.hh.

352  {
353  return init_gain;
354  }
double init_gain
Initial input value for gain.
Definition: JFitToT.hh:384
const double JCALIBRATE::JFitToT::getInitGainSpread ( ) const
inline

Retrieve initial gainspread.

Returns
initial gainspread setting

Definition at line 362 of file JFitToT.hh.

362  {
363  return init_gainSpread;
364  }
double init_gainSpread
Initial input value for gainSpread.
Definition: JFitToT.hh:385
static JPMTAnalogueSignalProcessor& JCALIBRATE::JFitToT::getInstance ( )
inlinestaticprivate

Get unique instance of PMT analogue signal processor.

Returns
reference to PMT analogue signal processor.

Definition at line 374 of file JFitToT.hh.

375  {
376  static JPMTAnalogueSignalProcessor object;
377 
378  return object;
379  }
static Int_t JCALIBRATE::JFitToTParameters::getNumberOfModelParameters ( )
inlinestaticinherited

Get number of model parameters.

Returns
number of parameters

Definition at line 82 of file JFitToT.hh.

83  {
84  return sizeof(JFitToTParameters) / sizeof(Double_t);
85  }
JFitToTParameters(const JPMTParameters &parameters)
Constructor.
Definition: JFitToT.hh:56
const Double_t* JCALIBRATE::JFitToTParameters::getModelParameters ( ) const
inlineinherited

Get model parameters.

Returns
pointer to parameters

Definition at line 93 of file JFitToT.hh.

94  {
95  return &this->gain;
96  }
Double_t gain
PMT gain.
Definition: JFitToT.hh:163
Double_t* JCALIBRATE::JFitToTParameters::getModelParameters ( )
inlineinherited

Get model parameters.

Returns
pointer to parameters

Definition at line 104 of file JFitToT.hh.

105  {
106  return &this->gain;
107  }
Double_t gain
PMT gain.
Definition: JFitToT.hh:163
void JCALIBRATE::JFitToTParameters::setModelParameter ( const int  i,
const Double_t  value 
)
inlineinherited

Set model parameter.

Parameters
iparameter index
valueparameter value

Definition at line 116 of file JFitToT.hh.

117  {
118  getModelParameters()[i] = value;
119  }
const Double_t * getModelParameters() const
Get model parameters.
Definition: JFitToT.hh:93
void JCALIBRATE::JFitToTParameters::setModelParameters ( const Double_t *  data)
inlineinherited

Set model parameters.

Parameters
datapointer to parameters

Definition at line 127 of file JFitToT.hh.

128  {
129  for (Int_t i = 0; i != getNumberOfModelParameters(); ++i) {
130  setModelParameter(i, data[i]);
131  }
132  }
static Int_t getNumberOfModelParameters()
Get number of model parameters.
Definition: JFitToT.hh:82
void setModelParameter(const int i, const Double_t value)
Set model parameter.
Definition: JFitToT.hh:116
const Double_t JCALIBRATE::JFitToTParameters::getModelParameter ( const int  i) const
inlineinherited

Get model parameter.

Parameters
iparameter index
Returns
parameter value

Definition at line 141 of file JFitToT.hh.

142  {
143  return getModelParameters()[i];
144  }
const Double_t * getModelParameters() const
Get model parameters.
Definition: JFitToT.hh:93
JFitParameter_t JCALIBRATE::JFitToTParameters::getModelParameter ( Double_t JFitToTParameters::*  p) const
inlineinherited

Get model parameter.

Parameters
ppointer to data member
Returns
parameter index and value

Definition at line 153 of file JFitToT.hh.

154  {
155  const Int_t i = &(this->*p) - getModelParameters();
156 
157  return JFitParameter_t(i, getModelParameter(i));
158  }
const Double_t getModelParameter(const int i) const
Get model parameter.
Definition: JFitToT.hh:141
const Double_t * getModelParameters() const
Get model parameters.
Definition: JFitToT.hh:93

Member Data Documentation

JRange_t JCALIBRATE::JFitToT::fitRange
private

fit-range [ns]

Definition at line 381 of file JFitToT.hh.

double JCALIBRATE::JFitToT::WfitRange
private

Cumulative weight within fit-range.

Definition at line 382 of file JFitToT.hh.

double JCALIBRATE::JFitToT::init_gain
private

Initial input value for gain.

Definition at line 384 of file JFitToT.hh.

double JCALIBRATE::JFitToT::init_gainSpread
private

Initial input value for gainSpread.

Definition at line 385 of file JFitToT.hh.

const int JCALIBRATE::JFitToT::NPE
private

True number of photo-electrons.

Definition at line 387 of file JFitToT.hh.

Double_t JCALIBRATE::JFitToTParameters::gain
inherited

PMT gain.

Definition at line 163 of file JFitToT.hh.

Double_t JCALIBRATE::JFitToTParameters::gainSpread
inherited

PMT gain spread.

Definition at line 164 of file JFitToT.hh.


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