laura is hosted by Hepforge, IPPP Durham
Laura++  v3r4
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauFitObject.hh
Go to the documentation of this file.
1 
2 /*
3 Copyright 2013 University of Warwick
4 
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 */
17 
18 /*
19 Laura++ package authors:
20 John Back
21 Paul Harrison
22 Thomas Latham
23 */
24 
33 #ifndef LAU_FIT_OBJECT
34 #define LAU_FIT_OBJECT
35 
36 #include <vector>
37 
38 #include "TMatrixD.h"
39 #include "TObject.h"
40 #include "TString.h"
41 
42 #include "LauAbsFitter.hh"
43 
44 class LauFitObject : public TObject {
45 
46  public:
48  virtual ~LauFitObject() {}
49 
51 
54  void useAsymmFitErrors(Bool_t useAsymmErrors) {useAsymmFitErrors_ = useAsymmErrors;}
55 
57  Bool_t useAsymmFitErrors() const {return useAsymmFitErrors_;}
58 
60 
70  void twoStageFit(Bool_t doTwoStageFit) {twoStageFit_ = doTwoStageFit;}
71 
73  Bool_t twoStageFit() const {return twoStageFit_;}
74 
76 
82  virtual void withinAsymErrorCalc(const Bool_t inAsymErrCalc) {withinAsymErrorCalc_ = inAsymErrCalc;}
83 
85 
88  Bool_t withinAsymErrorCalc() const {return withinAsymErrorCalc_;}
89 
91 
95  void setNExpts(UInt_t nExperiments, UInt_t firstExperiment = 0) {
96  nExpt_ = nExperiments;
97  firstExpt_ = firstExperiment;
98  }
99 
101  UInt_t eventsPerExpt() const {return evtsPerExpt_;}
102 
104  UInt_t nExpt() const {return nExpt_;}
105 
107  UInt_t firstExpt() const {return firstExpt_;}
108 
110  UInt_t iExpt() const {return iExpt_;}
111 
113 
120  virtual void setParsFromMinuit(Double_t* par, Int_t npar) = 0;
121 
123 
127  virtual Double_t getTotNegLogLikelihood() = 0;
128 
130 
136  virtual void addConstraint(const TString& formula, const std::vector<TString>& pars, const Double_t mean, const Double_t width);
137 
138  protected:
140  LauFitObject();
141 
142  // Setup a struct to store information on constrained fit parameters
149  TString formula_;
151  std::vector<TString> conPars_;
153  Double_t mean_;
155  Double_t width_;
156  };
157 
159  const std::vector<StoreConstraints>& constraintsStore() const {return storeCon_;}
160 
162  std::vector<StoreConstraints>& constraintsStore() {return storeCon_;}
163 
165  void resetFitCounters();
166 
168 
171  void setCurrentExperiment( const UInt_t curExpt ) { iExpt_ = curExpt; }
172 
174 
178  void startNewFit( const UInt_t nPars, const UInt_t nFreePars );
179 
181  void eventsPerExpt(UInt_t nEvents) {evtsPerExpt_ = nEvents;}
182 
184  Double_t worstLogLike() const {return worstLogLike_;}
185 
187 
190  void worstLogLike( const Double_t newWorstLogLike ) {worstLogLike_ = newWorstLogLike;}
191 
193 
197  void storeFitStatus( const LauAbsFitter::FitStatus& status, const TMatrixD& covMatrix );
198 
200  UInt_t nTotParams() const {return nParams_;}
201 
203  UInt_t nFreeParams() const {return nFreeParams_;}
204 
207 
209  Double_t nll() const {return fitStatus_.NLL;}
210 
212  Double_t edm() const {return fitStatus_.EDM;}
213 
215  Int_t statusCode() const {return fitStatus_.status;}
216 
218  const TMatrixD& covarianceMatrix() const {return covMatrix_;}
219 
221  UInt_t numberOKFits() const {return numberOKFits_;}
222 
224  UInt_t numberBadFits() const {return numberBadFits_;}
225 
226  private:
228  LauFitObject(const LauFitObject& rhs);
229 
231  LauFitObject& operator=(const LauFitObject& rhs);
232 
234  std::vector<StoreConstraints> storeCon_;
235 
237  Bool_t twoStageFit_;
238 
241 
243  UInt_t nParams_;
244 
246  UInt_t nFreeParams_;
247 
250 
252  UInt_t firstExpt_;
253 
255  UInt_t nExpt_;
256 
258  UInt_t iExpt_;
259 
261  UInt_t evtsPerExpt_;
262 
265 
267  Double_t worstLogLike_;
268 
270  TMatrixD covMatrix_;
271 
274 
277 
278  ClassDef(LauFitObject,0)
279 };
280 
281 #endif
282 
UInt_t iExpt_
The current experiment number.
UInt_t nTotParams() const
Access the total number of fit parameters.
Int_t statusCode() const
Access the fit status code.
Double_t width_
The width of the Gaussian constraint to be applied.
Double_t EDM
The estimated distance to the minimum.
Definition: LauAbsFitter.hh:61
Double_t mean_
The mean value of the Gaussian constraint to be applied.
virtual Double_t getTotNegLogLikelihood()=0
Calculate the new value of the negative log likelihood.
void eventsPerExpt(UInt_t nEvents)
Set the number of events in the current experiment.
Bool_t withinAsymErrorCalc() const
Query whether the fit is calculating the asymmetric errors.
Definition: LauFitObject.hh:88
void setNExpts(UInt_t nExperiments, UInt_t firstExperiment=0)
Set the number of experiments and the first experiment.
Definition: LauFitObject.hh:95
Double_t worstLogLike() const
Access the worst log likelihood found so far.
LauFitObject()
Constructor.
Definition: LauFitObject.cc:34
UInt_t evtsPerExpt_
The number of events in the current experiment.
std::vector< StoreConstraints > storeCon_
Store the constraints for fit parameters until initialisation is complete.
virtual void setParsFromMinuit(Double_t *par, Int_t npar)=0
This function sets the parameter values from Minuit.
File containing declaration of LauAbsFitter class.
virtual ~LauFitObject()
Destructor.
Definition: LauFitObject.hh:48
void storeFitStatus(const LauAbsFitter::FitStatus &status, const TMatrixD &covMatrix)
Store fit status information.
Definition: LauFitObject.cc:70
Bool_t twoStageFit() const
Report whether the two-stage fit is enabled.
Definition: LauFitObject.hh:73
TString formula_
The formula to be used in the LauFormulaPar.
Bool_t twoStageFit_
Option to perform a two stage fit.
virtual void addConstraint(const TString &formula, const std::vector< TString > &pars, const Double_t mean, const Double_t width)
Store constraint information for fit parameters.
Definition: LauFitObject.cc:91
void useAsymmFitErrors(Bool_t useAsymmErrors)
Turn on or off the computation of asymmetric errors (e.g. MINOS routine in Minuit) ...
Definition: LauFitObject.hh:54
TMatrixD covMatrix_
The fit covariance matrix.
LauAbsFitter::FitStatus fitStatus_
The status of the current fit.
UInt_t nFreeParams() const
Access the total number of fit parameters.
void resetFitCounters()
Reset the good/bad fit counters.
Definition: LauFitObject.cc:53
UInt_t firstExpt_
The number of the first experiment to consider.
Double_t edm() const
Access the current EDM value.
UInt_t eventsPerExpt() const
Obtain the total number of events in the current experiment.
void setCurrentExperiment(const UInt_t curExpt)
Set the ID of the current experiment.
UInt_t numberOKFits_
The number of successful fits.
const std::vector< StoreConstraints > & constraintsStore() const
Const access to the constraints store.
Double_t NLL
The negative log-likelihood.
Definition: LauAbsFitter.hh:59
Int_t status
The status code of the fit.
Definition: LauAbsFitter.hh:57
Struct to store fit status information.
Definition: LauAbsFitter.hh:55
UInt_t numberBadFits_
The number of fit failures.
UInt_t nExpt() const
Obtain the number of experiments.
const TMatrixD & covarianceMatrix() const
Access the fit covariance matrix.
virtual void withinAsymErrorCalc(const Bool_t inAsymErrCalc)
Mark that the fit is calculating asymmetric errors.
Definition: LauFitObject.hh:82
UInt_t nParams_
The number of fit parameters.
Bool_t useAsymmFitErrors_
Option to use asymmetric errors.
Bool_t useAsymmFitErrors() const
Report whether or not calculation of asymmetric errors is enabled.
Definition: LauFitObject.hh:57
void twoStageFit(Bool_t doTwoStageFit)
Turn on or off the two stage fit.
Definition: LauFitObject.hh:70
UInt_t numberOKFits() const
Access the number of successful fits.
UInt_t numberBadFits() const
Access the number of failed fits.
Bool_t withinAsymErrorCalc_
Flag to indicate if the asymmetric error calculation (e.g. MINOS) is currently running.
Double_t nll() const
Access the current NLL value.
std::vector< StoreConstraints > & constraintsStore()
Access to the constraints store.
Struct to store constraint information until the fit is run.
void startNewFit(const UInt_t nPars, const UInt_t nFreePars)
Indicate the start of a new fit.
Definition: LauFitObject.cc:60
const LauAbsFitter::FitStatus & fitStatus() const
Access the fit status information.
void worstLogLike(const Double_t newWorstLogLike)
Set a new value for the worst log likelihood.
UInt_t nExpt_
The number of experiments to consider.
UInt_t iExpt() const
Obtain the number of the current experiment.
Double_t worstLogLike_
The worst log likelihood value found so far.
LauFitObject & operator=(const LauFitObject &rhs)
Copy assignment operator (not implemented)
UInt_t firstExpt() const
Obtain the number of the first experiment.
std::vector< TString > conPars_
The list of LauParameter names to be used in the LauFormulaPar.
The abstract interface for the objects that control the calculation of the likelihood.
Definition: LauFitObject.hh:44
UInt_t nFreeParams_
The number of free fit parameters.