Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TFractionFitter Class Reference

Fits MC fractions to data histogram.

A la HMCMLL, see R. Barlow and C. Beeston, Comp. Phys. Comm. 77 (1993) 219-228, and http://www.hep.man.ac.uk/~roger/hfrac.f

The virtue of this fit is that it takes into account both data and Monte Carlo statistical uncertainties. The way in which this is done is through a standard likelihood fit using Poisson statistics; however, the template (MC) predictions are also varied within statistics, leading to additional contributions to the overall likelihood. This leads to many more fit parameters (one per bin per template), but the minimisation with respect to these additional parameters is done analytically rather than introducing them as formal fit parameters. Some special care needs to be taken in the case of bins with zero content. For more details please see the original publication cited above.

An example application of this fit is given below. For a TH1* histogram ("data") fitted as the sum of three Monte Carlo sources ("mc"):

{
TH1F *data; //data histogram
TH1F *mc0; // first MC histogram
TH1F *mc1; // second MC histogram
TH1F *mc2; // third MC histogram
.... // retrieve histograms
TObjArray *mc = new TObjArray(3); // MC histograms are put in this array
mc->Add(mc0);
mc->Add(mc1);
mc->Add(mc2);
TFractionFitter* fit = new TFractionFitter(data, mc); // initialise
fit->Constrain(1,0.0,1.0); // constrain fraction 1 to be between 0 and 1
fit->SetRangeX(1,15); // use only the first 15 bins in the fit
Int_t status = fit->Fit(); // perform the fit
std::cout << "fit status: " << status << std::endl;
if (status == 0) { // check on fit status
TH1F* result = (TH1F*) fit->GetPlot();
data->Draw("Ep");
result->Draw("same");
}
}
RooFitResult * fit(const char *options)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Fits MC fractions to data histogram.
TFractionFitter()
TFractionFitter default constructor.
1-D histogram with a float per channel (see TH1 documentation)}
Definition TH1.h:577
An array of TObjects.
Definition TObjArray.h:31
void Add(TObject *obj) override
Definition TObjArray.h:68

Assumptions

A few assumptions need to be made for the fit procedure to be carried out: 1 The total number of events in each template is not too small (so that its Poisson uncertainty can be neglected). 2 The number of events in each bin is much smaller than the total number of events in each template (so that multinomial uncertainties can be replaced with Poisson uncertainties).

Biased fit uncertainties may result if these conditions are not fulfilled (see e.g. arXiv:0803.2711).

Instantiation

A fit object is instantiated through TFractionFitter* fit = new TFractionFitter(data, mc); A number of basic checks (intended to ensure that the template histograms represent the same "kind" of distribution as the data one) are carried out. The TVirtualFitter object is then addressed and all fit parameters (the template fractions) declared (initially unbounded).

Applying constraints

Fit parameters can be constrained through

fit->Constrain(parameter #, lower bound, upper bound);

Setting lower bound = upper bound = 0 removes the constraint (a la Minuit); however, a function

fit->Unconstrain(parameter #)

is also provided to simplify this.

Setting parameter values

The function

ROOT::Fit::Fitter* fitter = fit->GetFitter();

is provided for direct access to the ROOT::Fit::Fitter object. This allows to set and fix parameter values, limits and set step sizes directly via

fitter->Config().ParSettings(parameter #).Set(const std::string &name, double value, double step, double lower, double upper);

Restricting the fit range

The fit range can be restricted through

fit->SetRangeX(first bin #, last bin #);

and freed using

fit->ReleaseRangeX();

For 2D histograms the Y range can be similarly restricted using

fit->SetRangeY(first bin #, last bin #);
fit->ReleaseRangeY();

and for 3D histograms also

fit->SetRangeZ(first bin #, last bin #);
fit->ReleaseRangeZ();

It is also possible to exclude individual bins from the fit through

fit->ExcludeBin(bin #);

where the given bin number is assumed to follow the TH1::GetBin() numbering. Any bins excluded in this way can be included again using the corresponding

fit->IncludeBin(bin #);

Weights histograms

Weights histograms (for a motivation see the above publication) can be specified for the individual MC sources through

fit->SetWeight(parameter #, pointer to weights histogram);

and unset by specifying a null pointer.

Obtaining fit results

The fit is carried out through

Int_t status = fit->Fit();

where status is the code returned from the "MINIMIZE" command. For fits that converged, parameter values and errors can be obtained through

fit->GetResult(parameter #, value, error);

and the histogram corresponding to the total Monte Carlo prediction (which is not the same as a simple weighted sum of the input Monte Carlo distributions) can be obtained by

TH1* result = fit->GetPlot();

Using different histograms

It is possible to change the histogram being fitted through

fit->SetData(TH1* data);

and to change the template histogram for a given parameter number through

fit->SetMC(parameter #, TH1* MC);

This can speed up code in case of multiple data or template histograms; however, it should be done with care as any settings are taken over from the previous fit. In addition, neither the dimensionality nor the numbers of bins of the histograms should change (in that case it is better to instantiate a new TFractionFitter object).

Errors

Any serious inconsistency results in an error.

Definition at line 27 of file TFractionFitter.h.

Public Member Functions

 TFractionFitter ()
 TFractionFitter default constructor.
 
 TFractionFitter (TH1 *data, TObjArray *MCs, Option_t *option="")
 TFractionFitter constructor.
 
 ~TFractionFitter () override
 TFractionFitter default destructor.
 
void Constrain (Int_t parm, Double_t low, Double_t high)
 Constrain the values of parameter number <parm> (the parameter numbering follows that of the input template vector).
 
void ErrorAnalysis (Double_t UP)
 Set UP to the given value (see class TMinuit), and perform a MINOS minimisation.
 
Double_t EvaluateFCN (const Double_t *par)
 
void ExcludeBin (Int_t bin)
 Exclude the given bin from the fit.
 
TFitResultPtr Fit ()
 Perform the fit with the default UP value.
 
Double_t GetChisquare () const
 Return the likelihood ratio Chi-squared (chi2) for the fit.
 
ROOT::Fit::FitterGetFitter () const
 Give direct access to the underlying fitter class.
 
TH1GetMCPrediction (Int_t parm) const
 Return the adjusted MC template (Aji) for template (parm).
 
Int_t GetNDF () const
 return the number of degrees of freedom in the fit the fNDF parameter has been previously computed during a fit.
 
TH1GetPlot ()
 Return the "template prediction" corresponding to the fit result (this is not the same as the weighted sum of template distributions, as template statistical uncertainties are taken into account).
 
Double_t GetProb () const
 return the fit probability
 
void GetResult (Int_t parm, Double_t &value, Double_t &error) const
 Obtain the fit result for parameter <parm> (the parameter numbering follows that of the input template vector).
 
void IncludeBin (Int_t bin)
 Include the given bin in the fit, if it was excluded before using ExcludeBin().
 
TClassIsA () const override
 
void ReleaseRangeX ()
 Release restrictions on the X range of the histogram to be used in the fit.
 
void ReleaseRangeY ()
 Release restrictions on the Y range of the histogram to be used in the fit.
 
void ReleaseRangeZ ()
 Release restrictions on the Z range of the histogram to be used in the fit.
 
void SetData (TH1 *data)
 Change the histogram to be fitted to.
 
void SetMC (Int_t parm, TH1 *MC)
 Change the histogram for template number <parm>.
 
void SetRangeX (Int_t low, Int_t high)
 Set the X range of the histogram to be used in the fit.
 
void SetRangeY (Int_t low, Int_t high)
 Set the Y range of the histogram to be used in the fit (2D or 3D histograms only).
 
void SetRangeZ (Int_t low, Int_t high)
 Set the Z range of the histogram to be used in the fit (3D histograms only).
 
void SetWeight (Int_t parm, TH1 *weight)
 Set bin by bin weights for template number <parm> (the parameter numbering follows that of the input template vector).
 
void Streamer (TBuffer &) override
 Stream an object of class TObject.
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
void UnConstrain (Int_t parm)
 Remove the constraints on the possible values of parameter <parm>.
 
- Public Member Functions inherited from TObject
 TObject ()
 TObject constructor.
 
 TObject (const TObject &object)
 TObject copy ctor.
 
virtual ~TObject ()
 TObject destructor.
 
void AbstractMethod (const char *method) const
 Use this method to implement an "abstract" method that you don't want to leave purely abstract.
 
virtual void AppendPad (Option_t *option="")
 Append graphics object to current pad.
 
virtual void Browse (TBrowser *b)
 Browse object. May be overridden for another default action.
 
ULong_t CheckedHash ()
 Check and record whether this class has a consistent Hash/RecursiveRemove setup (*) and then return the regular Hash value for this object.
 
virtual const char * ClassName () const
 Returns name of class to which the object belongs.
 
virtual void Clear (Option_t *="")
 
virtual TObjectClone (const char *newname="") const
 Make a clone of an object using the Streamer facility.
 
virtual Int_t Compare (const TObject *obj) const
 Compare abstract method.
 
virtual void Copy (TObject &object) const
 Copy this to obj.
 
virtual void Delete (Option_t *option="")
 Delete this object.
 
virtual Int_t DistancetoPrimitive (Int_t px, Int_t py)
 Computes distance from point (px,py) to the object.
 
virtual void Draw (Option_t *option="")
 Default Draw method for all objects.
 
virtual void DrawClass () const
 Draw class inheritance tree of the class to which this object belongs.
 
virtual TObjectDrawClone (Option_t *option="") const
 Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
 
virtual void Dump () const
 Dump contents of object on stdout.
 
virtual void Error (const char *method, const char *msgfmt,...) const
 Issue error message.
 
virtual void Execute (const char *method, const char *params, Int_t *error=nullptr)
 Execute method on this object with the given parameter string, e.g.
 
virtual void Execute (TMethod *method, TObjArray *params, Int_t *error=nullptr)
 Execute method on this object with parameters stored in the TObjArray.
 
virtual void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 Execute action corresponding to an event at (px,py).
 
virtual void Fatal (const char *method, const char *msgfmt,...) const
 Issue fatal error message.
 
virtual TObjectFindObject (const char *name) const
 Must be redefined in derived classes.
 
virtual TObjectFindObject (const TObject *obj) const
 Must be redefined in derived classes.
 
virtual Option_tGetDrawOption () const
 Get option used by the graphics system to draw this object.
 
virtual const char * GetIconName () const
 Returns mime type name of object.
 
virtual const char * GetName () const
 Returns name of object.
 
virtual char * GetObjectInfo (Int_t px, Int_t py) const
 Returns string containing info about the object at position (px,py).
 
virtual Option_tGetOption () const
 
virtual const char * GetTitle () const
 Returns title of object.
 
virtual UInt_t GetUniqueID () const
 Return the unique object id.
 
virtual Bool_t HandleTimer (TTimer *timer)
 Execute action in response of a timer timing out.
 
virtual ULong_t Hash () const
 Return hash value for this object.
 
Bool_t HasInconsistentHash () const
 Return true is the type of this object is known to have an inconsistent setup for Hash and RecursiveRemove (i.e.
 
virtual void Info (const char *method, const char *msgfmt,...) const
 Issue info message.
 
virtual Bool_t InheritsFrom (const char *classname) const
 Returns kTRUE if object inherits from class "classname".
 
virtual Bool_t InheritsFrom (const TClass *cl) const
 Returns kTRUE if object inherits from TClass cl.
 
virtual void Inspect () const
 Dump contents of this object in a graphics canvas.
 
void InvertBit (UInt_t f)
 
Bool_t IsDestructed () const
 IsDestructed.
 
virtual Bool_t IsEqual (const TObject *obj) const
 Default equal comparison (objects are equal if they have the same address in memory).
 
virtual Bool_t IsFolder () const
 Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
 
R__ALWAYS_INLINE Bool_t IsOnHeap () const
 
virtual Bool_t IsSortable () const
 
R__ALWAYS_INLINE Bool_t IsZombie () const
 
virtual void ls (Option_t *option="") const
 The ls function lists the contents of a class on stdout.
 
void MayNotUse (const char *method) const
 Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary).
 
virtual Bool_t Notify ()
 This method must be overridden to handle object notification.
 
void Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const
 Use this method to declare a method obsolete.
 
void operator delete (void *ptr)
 Operator delete.
 
void operator delete[] (void *ptr)
 Operator delete [].
 
void * operator new (size_t sz)
 
void * operator new (size_t sz, void *vp)
 
void * operator new[] (size_t sz)
 
void * operator new[] (size_t sz, void *vp)
 
TObjectoperator= (const TObject &rhs)
 TObject assignment operator.
 
virtual void Paint (Option_t *option="")
 This method must be overridden if a class wants to paint itself.
 
virtual void Pop ()
 Pop on object drawn in a pad to the top of the display list.
 
virtual void Print (Option_t *option="") const
 This method must be overridden when a class wants to print itself.
 
virtual Int_t Read (const char *name)
 Read contents of object with specified name from the current directory.
 
virtual void RecursiveRemove (TObject *obj)
 Recursively remove this object from a list.
 
void ResetBit (UInt_t f)
 
virtual void SaveAs (const char *filename="", Option_t *option="") const
 Save this object in the file specified by filename.
 
virtual void SavePrimitive (std::ostream &out, Option_t *option="")
 Save a primitive as a C++ statement(s) on output stream "out".
 
void SetBit (UInt_t f)
 
void SetBit (UInt_t f, Bool_t set)
 Set or unset the user status bits as specified in f.
 
virtual void SetDrawOption (Option_t *option="")
 Set drawing option for object.
 
virtual void SetUniqueID (UInt_t uid)
 Set the unique object id.
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
virtual void SysError (const char *method, const char *msgfmt,...) const
 Issue system error message.
 
R__ALWAYS_INLINE Bool_t TestBit (UInt_t f) const
 
Int_t TestBits (UInt_t f) const
 
virtual void UseCurrentStyle ()
 Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked.
 
virtual void Warning (const char *method, const char *msgfmt,...) const
 Issue warning message.
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
 Write this object to the current directory.
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const
 Write this object to the current directory.
 

Static Public Member Functions

static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
- Static Public Member Functions inherited from TObject
static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
static Longptr_t GetDtorOnly ()
 Return destructor only flag.
 
static Bool_t GetObjectStat ()
 Get status of object stat flag.
 
static void SetDtorOnly (void *obj)
 Set destructor only flag.
 
static void SetObjectStat (Bool_t stat)
 Turn on/off tracking of objects in the TObjectTable.
 

Protected Attributes

TObjArray fAji
 Array of pointers to predictions of real template distributions.
 
Double_t fChisquare
 Template fit chisquare.
 
std::vector< Int_tfExcludedBins
 Bins excluded from the fit.
 
Bool_t fFitDone
 Flags whether a valid fit has been performed.
 
Int_t fHighLimitX
 Last bin in X dimension.
 
Int_t fHighLimitY
 Last bin in Y dimension.
 
Int_t fHighLimitZ
 Last bin in Z dimension.
 
Int_t fLowLimitX
 First bin in X dimension.
 
Int_t fLowLimitY
 First bin in Y dimension.
 
Int_t fLowLimitZ
 First bin in Z dimension.
 
Int_t fNDF
 Number of degrees of freedom in the fit.
 
Int_t fNpar
 number of fit parameters
 
Int_t fNpfits
 Number of points used in the fit.
 
Histograms
TH1fData
 Pointer to the "data" histogram to be fitted to.
 
TObjArray fMCs
 Array of pointers to template histograms.
 
TObjArray fWeights
 Array of pointers to corresponding weight factors (may be null)
 
Double_t fIntegralData
 "data" histogram content integral over allowed fit range
 
Double_tfIntegralMCs
 Same for template histograms (weights not taken into account)
 
Double_tfFractions
 Template fractions scaled to the "data" histogram statistics.
 
TH1fPlot
 Pointer to histogram containing summed template predictions.
 
ROOT::Fit::FitterfFractionFitter
 Pointer to Fitter class.
 

Private Member Functions

void CheckConsistency ()
 Function used internally to check the consistency between the various histograms.
 
void CheckParNo (Int_t parm) const
 Function for internal use, checking parameter validity An invalid parameter results in an error.
 
void ComputeChisquareLambda ()
 Method used internally to compute the likelihood ratio chi2 See the function GetChisquare() for details.
 
void ComputeFCN (Double_t &f, const Double_t *par, Int_t flag)
 Used internally to compute the likelihood value.
 
void FindPrediction (int bin, double &t_i, int &k_0, double &A_ki) const
 Function used internally to obtain the template prediction in the individual bins 'bin' <=> 'i' (paper) 'par' <=> 'j' (paper)
 
void GetRanges (Int_t &minX, Int_t &maxX, Int_t &minY, Int_t &maxY, Int_t &minZ, Int_t &maxZ) const
 Used internally to obtain the bin ranges according to the dimensionality of the histogram and the limits set by hand.
 
bool IsExcluded (Int_t bin) const
 Function for internal use, checking whether the given bin is excluded from the fit or not.
 

Additional Inherited Members

- Public Types inherited from TObject
enum  {
  kIsOnHeap = 0x01000000 , kNotDeleted = 0x02000000 , kZombie = 0x04000000 , kInconsistent = 0x08000000 ,
  kBitMask = 0x00ffffff
}
 
enum  { kSingleKey = (1ULL << ( 0 )) , kOverwrite = (1ULL << ( 1 )) , kWriteDelete = (1ULL << ( 2 )) }
 
enum  EDeprecatedStatusBits { kObjInCanvas = (1ULL << ( 3 )) }
 
enum  EStatusBits {
  kCanDelete = (1ULL << ( 0 )) , kMustCleanup = (1ULL << ( 3 )) , kIsReferenced = (1ULL << ( 4 )) , kHasUUID = (1ULL << ( 5 )) ,
  kCannotPick = (1ULL << ( 6 )) , kNoContextMenu = (1ULL << ( 8 )) , kInvalidObject = (1ULL << ( 13 ))
}
 
- Protected Types inherited from TObject
enum  { kOnlyPrepStep = (1ULL << ( 3 )) }
 
- Protected Member Functions inherited from TObject
virtual void DoError (int level, const char *location, const char *fmt, va_list va) const
 Interface to ErrorHandler (protected).
 
void MakeZombie ()
 

#include <TFractionFitter.h>

Inheritance diagram for TFractionFitter:
[legend]

Constructor & Destructor Documentation

◆ TFractionFitter() [1/2]

TFractionFitter::TFractionFitter ( )

TFractionFitter default constructor.

Definition at line 163 of file TFractionFitter.cxx.

◆ TFractionFitter() [2/2]

TFractionFitter::TFractionFitter ( TH1 data,
TObjArray MCs,
Option_t option = "" 
)

TFractionFitter constructor.

Does a complete initialisation (including consistency checks, default fit range as the whole histogram but without under- and overflows, and declaration of the fit parameters). Note that the histograms are not copied, only references are used.

Parameters
[in]datahistogram to be fitted
[in]MCsarray of TH1* corresponding template distributions
[in]optioncan be used to control the print level of the minimization algorithm
  • option = "Q" : quite - no message is printed
  • option = "V" : verbose - max print out
  • option = "" : default: print initial fraction values and result

Definition at line 193 of file TFractionFitter.cxx.

◆ ~TFractionFitter()

TFractionFitter::~TFractionFitter ( )
override

TFractionFitter default destructor.

Definition at line 257 of file TFractionFitter.cxx.

Member Function Documentation

◆ CheckConsistency()

void TFractionFitter::CheckConsistency ( )
private

Function used internally to check the consistency between the various histograms.

Checks are performed on nonexistent or empty histograms, the precise histogram class, and the number of bins. In addition, integrals over the "allowed" bin ranges are computed. Any inconsistency results in a error.

Definition at line 484 of file TFractionFitter.cxx.

◆ CheckParNo()

void TFractionFitter::CheckParNo ( Int_t  parm) const
private

Function for internal use, checking parameter validity An invalid parameter results in an error.

Definition at line 327 of file TFractionFitter.cxx.

◆ Class()

static TClass * TFractionFitter::Class ( )
static
Returns
TClass describing this class

◆ Class_Name()

static const char * TFractionFitter::Class_Name ( )
static
Returns
Name of this class

◆ Class_Version()

static constexpr Version_t TFractionFitter::Class_Version ( )
inlinestaticconstexpr
Returns
Version of this class

Definition at line 112 of file TFractionFitter.h.

◆ ComputeChisquareLambda()

void TFractionFitter::ComputeChisquareLambda ( )
private

Method used internally to compute the likelihood ratio chi2 See the function GetChisquare() for details.

Definition at line 914 of file TFractionFitter.cxx.

◆ ComputeFCN()

void TFractionFitter::ComputeFCN ( Double_t f,
const Double_t par,
Int_t  flag 
)
private

Used internally to compute the likelihood value.

Definition at line 664 of file TFractionFitter.cxx.

◆ Constrain()

void TFractionFitter::Constrain ( Int_t  parm,
Double_t  low,
Double_t  high 
)

Constrain the values of parameter number <parm> (the parameter numbering follows that of the input template vector).

Use UnConstrain() to remove this constraint.

Definition at line 463 of file TFractionFitter.cxx.

◆ DeclFileName()

static const char * TFractionFitter::DeclFileName ( )
inlinestatic
Returns
Name of the file containing the class declaration

Definition at line 112 of file TFractionFitter.h.

◆ ErrorAnalysis()

void TFractionFitter::ErrorAnalysis ( Double_t  UP)

Set UP to the given value (see class TMinuit), and perform a MINOS minimisation.

Definition at line 583 of file TFractionFitter.cxx.

◆ EvaluateFCN()

Double_t TFractionFitter::EvaluateFCN ( const Double_t par)
inline

Definition at line 66 of file TFractionFitter.h.

◆ ExcludeBin()

void TFractionFitter::ExcludeBin ( Int_t  bin)

Exclude the given bin from the fit.

The bin numbering to be used is that of TH1::GetBin().

Definition at line 418 of file TFractionFitter.cxx.

◆ FindPrediction()

void TFractionFitter::FindPrediction ( int  bin,
double t_i,
int k_0,
double A_ki 
) const
private

Function used internally to obtain the template prediction in the individual bins 'bin' <=> 'i' (paper) 'par' <=> 'j' (paper)

Definition at line 757 of file TFractionFitter.cxx.

◆ Fit()

TFitResultPtr TFractionFitter::Fit ( )

Perform the fit with the default UP value.

The value returned is the minimisation status.

Definition at line 553 of file TFractionFitter.cxx.

◆ GetChisquare()

Double_t TFractionFitter::GetChisquare ( ) const

Return the likelihood ratio Chi-squared (chi2) for the fit.

The value is computed when the fit is executed successfully. Chi2 calculation is based on the "likelihood ratio" lambda, lambda = L(y;n) / L(m;n), where L(y;n) is the likelihood of the fit result <y> describing the data <n> and L(m;n) is the likelihood of an unknown "true" underlying distribution <m> describing the data <n>. Since <m> is unknown, the data distribution is used instead, lambda = L(y;n) / L(n;n). Note that this ratio is 1 if the fit is perfect. The chi2 value is then computed according to chi2 = -2*ln(lambda). This parameter can be shown to follow a Chi-square distribution. See for example S. Baker and R. Cousins, "Clarification of the use of chi-square and likelihood functions in fits to histograms", Nucl. Instr. Meth. A221, pp. 437-442 (1984)

Definition at line 883 of file TFractionFitter.cxx.

◆ GetFitter()

ROOT::Fit::Fitter * TFractionFitter::GetFitter ( ) const

Give direct access to the underlying fitter class.

This can be used e.g. to modify parameter values or step sizes.

Definition at line 319 of file TFractionFitter.cxx.

◆ GetMCPrediction()

TH1 * TFractionFitter::GetMCPrediction ( Int_t  parm) const

Return the adjusted MC template (Aji) for template (parm).

Note that the (Aji) times fractions only sum to the total prediction of the fit if all weights are 1. Note also that the histogram is managed by the TFractionFitter class, so the returned pointer will be invalid if the class is deleted

Definition at line 961 of file TFractionFitter.cxx.

◆ GetNDF()

Int_t TFractionFitter::GetNDF ( ) const

return the number of degrees of freedom in the fit the fNDF parameter has been previously computed during a fit.

The number of degrees of freedom corresponds to the number of points used in the fit minus the number of templates.

Definition at line 894 of file TFractionFitter.cxx.

◆ GetPlot()

TH1 * TFractionFitter::GetPlot ( )

Return the "template prediction" corresponding to the fit result (this is not the same as the weighted sum of template distributions, as template statistical uncertainties are taken into account).

Note that the name of this histogram will simply be the same as that of the "data" histogram, prefixed with the string "Fraction fit to hist: ". Note also that the histogram is managed by the TFractionFitter class, so the returned pointer will be invalid if the class is deleted

Definition at line 621 of file TFractionFitter.cxx.

◆ GetProb()

Double_t TFractionFitter::GetProb ( ) const

return the fit probability

Definition at line 903 of file TFractionFitter.cxx.

◆ GetRanges()

void TFractionFitter::GetRanges ( Int_t minX,
Int_t maxX,
Int_t minY,
Int_t maxY,
Int_t minZ,
Int_t maxZ 
) const
private

Used internally to obtain the bin ranges according to the dimensionality of the histogram and the limits set by hand.

Definition at line 639 of file TFractionFitter.cxx.

◆ GetResult()

void TFractionFitter::GetResult ( Int_t  parm,
Double_t value,
Double_t error 
) const

Obtain the fit result for parameter <parm> (the parameter numbering follows that of the input template vector).

Definition at line 602 of file TFractionFitter.cxx.

◆ IncludeBin()

void TFractionFitter::IncludeBin ( Int_t  bin)

Include the given bin in the fit, if it was excluded before using ExcludeBin().

The bin numbering to be used is that of TH1::GetBin().

Definition at line 435 of file TFractionFitter.cxx.

◆ IsA()

TClass * TFractionFitter::IsA ( ) const
inlineoverridevirtual
Returns
TClass describing current object

Reimplemented from TObject.

Definition at line 112 of file TFractionFitter.h.

◆ IsExcluded()

bool TFractionFitter::IsExcluded ( Int_t  bin) const
private

Function for internal use, checking whether the given bin is excluded from the fit or not.

Definition at line 452 of file TFractionFitter.cxx.

◆ ReleaseRangeX()

void TFractionFitter::ReleaseRangeX ( )

Release restrictions on the X range of the histogram to be used in the fit.

Definition at line 350 of file TFractionFitter.cxx.

◆ ReleaseRangeY()

void TFractionFitter::ReleaseRangeY ( )

Release restrictions on the Y range of the histogram to be used in the fit.

Definition at line 378 of file TFractionFitter.cxx.

◆ ReleaseRangeZ()

void TFractionFitter::ReleaseRangeZ ( )

Release restrictions on the Z range of the histogram to be used in the fit.

Definition at line 408 of file TFractionFitter.cxx.

◆ SetData()

void TFractionFitter::SetData ( TH1 data)

Change the histogram to be fitted to.

Notes:

  • Parameter constraints and settings are retained from a possible previous fit.
  • Modifying the dimension or number of bins results in an error (in this case rather instantiate a new TFractionFitter object)

Definition at line 271 of file TFractionFitter.cxx.

◆ SetMC()

void TFractionFitter::SetMC ( Int_t  parm,
TH1 MC 
)

Change the histogram for template number <parm>.

Notes:

  • Parameter constraints and settings are retained from a possible previous fit.
  • Modifying the dimension or number of bins results in an error (in this case rather instantiate a new TFractionFitter object)

Definition at line 283 of file TFractionFitter.cxx.

◆ SetRangeX()

void TFractionFitter::SetRangeX ( Int_t  low,
Int_t  high 
)

Set the X range of the histogram to be used in the fit.

Use ReleaseRangeX() to go back to fitting the full histogram. The consistency check ensures that no empty fit range occurs (and also recomputes the bin content integrals).

Parameters
[in]lowlower X bin number
[in]highupper X bin number

Definition at line 341 of file TFractionFitter.cxx.

◆ SetRangeY()

void TFractionFitter::SetRangeY ( Int_t  low,
Int_t  high 
)

Set the Y range of the histogram to be used in the fit (2D or 3D histograms only).

Use ReleaseRangeY() to go back to fitting the full histogram. The consistency check ensures that no empty fit range occurs (and also recomputes the bin content integrals).

Parameters
[in]lowlower X bin number
[in]highupper X bin number

Definition at line 364 of file TFractionFitter.cxx.

◆ SetRangeZ()

void TFractionFitter::SetRangeZ ( Int_t  low,
Int_t  high 
)

Set the Z range of the histogram to be used in the fit (3D histograms only).

Use ReleaseRangeY() to go back to fitting the full histogram. The consistency check ensures that no empty fit range occurs (and also recomputes the bin content integrals).

Parameters
[in]lowlower X bin number
[in]highupper X bin number

Definition at line 393 of file TFractionFitter.cxx.

◆ SetWeight()

void TFractionFitter::SetWeight ( Int_t  parm,
TH1 weight 
)

Set bin by bin weights for template number <parm> (the parameter numbering follows that of the input template vector).

Weights can be "unset" by passing a null pointer. Consistency of the weights histogram with the data histogram is checked at this point, and an error in case of problems.

Definition at line 298 of file TFractionFitter.cxx.

◆ Streamer()

void TFractionFitter::Streamer ( TBuffer R__b)
overridevirtual

Stream an object of class TObject.

Reimplemented from TObject.

◆ StreamerNVirtual()

void TFractionFitter::StreamerNVirtual ( TBuffer ClassDef_StreamerNVirtual_b)
inline

Definition at line 112 of file TFractionFitter.h.

◆ UnConstrain()

void TFractionFitter::UnConstrain ( Int_t  parm)

Remove the constraints on the possible values of parameter <parm>.

Definition at line 472 of file TFractionFitter.cxx.

Member Data Documentation

◆ fAji

TObjArray TFractionFitter::fAji
protected

Array of pointers to predictions of real template distributions.

Definition at line 96 of file TFractionFitter.h.

◆ fChisquare

Double_t TFractionFitter::fChisquare
protected

Template fit chisquare.

Definition at line 94 of file TFractionFitter.h.

◆ fData

TH1* TFractionFitter::fData
protected

Pointer to the "data" histogram to be fitted to.

Definition at line 100 of file TFractionFitter.h.

◆ fExcludedBins

std::vector<Int_t> TFractionFitter::fExcludedBins
protected

Bins excluded from the fit.

Definition at line 90 of file TFractionFitter.h.

◆ fFitDone

Bool_t TFractionFitter::fFitDone
protected

Flags whether a valid fit has been performed.

Definition at line 83 of file TFractionFitter.h.

◆ fFractionFitter

ROOT::Fit::Fitter* TFractionFitter::fFractionFitter
protected

Pointer to Fitter class.

Definition at line 107 of file TFractionFitter.h.

◆ fFractions

Double_t* TFractionFitter::fFractions
protected

Template fractions scaled to the "data" histogram statistics.

Definition at line 105 of file TFractionFitter.h.

◆ fHighLimitX

Int_t TFractionFitter::fHighLimitX
protected

Last bin in X dimension.

Definition at line 85 of file TFractionFitter.h.

◆ fHighLimitY

Int_t TFractionFitter::fHighLimitY
protected

Last bin in Y dimension.

Definition at line 87 of file TFractionFitter.h.

◆ fHighLimitZ

Int_t TFractionFitter::fHighLimitZ
protected

Last bin in Z dimension.

Definition at line 89 of file TFractionFitter.h.

◆ fIntegralData

Double_t TFractionFitter::fIntegralData
protected

"data" histogram content integral over allowed fit range

Definition at line 103 of file TFractionFitter.h.

◆ fIntegralMCs

Double_t* TFractionFitter::fIntegralMCs
protected

Same for template histograms (weights not taken into account)

Definition at line 104 of file TFractionFitter.h.

◆ fLowLimitX

Int_t TFractionFitter::fLowLimitX
protected

First bin in X dimension.

Definition at line 84 of file TFractionFitter.h.

◆ fLowLimitY

Int_t TFractionFitter::fLowLimitY
protected

First bin in Y dimension.

Definition at line 86 of file TFractionFitter.h.

◆ fLowLimitZ

Int_t TFractionFitter::fLowLimitZ
protected

First bin in Z dimension.

Definition at line 88 of file TFractionFitter.h.

◆ fMCs

TObjArray TFractionFitter::fMCs
protected

Array of pointers to template histograms.

Definition at line 101 of file TFractionFitter.h.

◆ fNDF

Int_t TFractionFitter::fNDF
protected

Number of degrees of freedom in the fit.

Definition at line 93 of file TFractionFitter.h.

◆ fNpar

Int_t TFractionFitter::fNpar
protected

number of fit parameters

Definition at line 110 of file TFractionFitter.h.

◆ fNpfits

Int_t TFractionFitter::fNpfits
protected

Number of points used in the fit.

Definition at line 92 of file TFractionFitter.h.

◆ fPlot

TH1* TFractionFitter::fPlot
protected

Pointer to histogram containing summed template predictions.

Definition at line 106 of file TFractionFitter.h.

◆ fWeights

TObjArray TFractionFitter::fWeights
protected

Array of pointers to corresponding weight factors (may be null)

Definition at line 102 of file TFractionFitter.h.

Libraries for TFractionFitter:

The documentation for this class was generated from the following files: