laura is hosted by Hepforge, IPPP Durham
Laura++  v3r1
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauSimFitMaster.hh
Go to the documentation of this file.
1 
2 // Copyright University of Warwick 2013 - 2013.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 // Authors:
7 // Thomas Latham
8 // John Back
9 // Paul Harrison
10 
23 #ifndef LAU_SIM_FIT_MASTER
24 #define LAU_SIM_FIT_MASTER
25 
26 #include <map>
27 #include <vector>
28 
29 #include "TMatrixD.h"
30 #include "TStopwatch.h"
31 #include "TString.h"
32 
33 #include "LauFitObject.hh"
34 
35 class TMessage;
36 class TMonitor;
37 class TSocket;
38 class LauAbsRValue;
39 class LauParameter;
40 class LauFitNtuple;
41 
42 
43 class LauSimFitMaster : public LauFitObject {
44 
45  public:
47 
51  LauSimFitMaster( UInt_t numSlaves, UInt_t port = 9090 );
52 
54  virtual ~LauSimFitMaster();
55 
57 
64  void runSimFit( const TString& fitNtupleFileName, UInt_t nExpt, UInt_t firstExpt = 0, Bool_t useAsymmErrors = kFALSE, Bool_t twoStageFit = kFALSE );
65 
67 
75  virtual void withinAsymErrorCalc(Bool_t inAsymErrCalc) { withinAsymErrorCalc_ = inAsymErrCalc; }
76 
78 
85  virtual void setParsFromMinuit(Double_t* par, Int_t npar);
86 
88 
92  virtual Double_t getTotNegLogLikelihood();
93 
95 
101  virtual void addConstraint(const TString& formula, const std::vector<TString>& pars, const Double_t mean, const Double_t width);
102 
103  protected:
105  void printParInfo() const;
106 
108  void initialise();
109 
111  void initSockets();
112 
115 
118 
121 
123  void checkParameter( const LauParameter* param, UInt_t index ) const;
124 
126  void addConParameters();
127 
129  Double_t getLogLikelihoodPenalty();
130 
132 
135  Bool_t readData();
136 
138 
141  Bool_t cacheInputData();
142 
144  void fitExpt( Bool_t useAsymmErrors, Bool_t twoStageFit );
145 
147  void checkInitFitParams();
148 
150  Bool_t finalise();
151 
153  Bool_t writeOutResults();
154 
155 
156  private:
158  LauSimFitMaster(const LauSimFitMaster& rhs);
159 
162 
164  std::vector<StoreConstraints> storeCon_;
165 
167  const UInt_t nSlaves_;
168 
170  const UInt_t reqPort_;
171 
173  UInt_t nParams_;
174 
176  UInt_t nFreeParams_;
177 
180 
183 
186 
188  Int_t fitStatus_;
189 
191  UInt_t iExpt_;
192 
194  Double_t NLL_;
195 
197  TMatrixD covMatrix_;
198 
200  std::vector<TMatrixD> covMatrices_;
201 
203  TMonitor* socketMonitor_;
204 
206  std::vector<TSocket*> sSlaves_;
207 
209  std::vector<TMessage*> messagesToSlaves_;
210 
212  TMessage* messageFromSlave_;
213 
215  std::map< TString, UInt_t > parIndices_;
216 
218  std::map< UInt_t, TString > parNames_;
219 
221  std::vector<LauParameter*> params_;
222 
224  std::vector<LauAbsRValue*> conVars_;
225 
227  std::vector<Double_t> parValues_;
228 
230  std::vector< std::vector<UInt_t> > slaveIndices_;
231 
233  std::vector< std::vector<UInt_t> > slaveFreeIndices_;
234 
236  std::vector<Double_t*> vectorPar_;
237 
239  std::vector<Double_t> vectorRes_;
240 
242  TStopwatch timer_;
243 
245  TStopwatch cumulTimer_;
246 
249 
251 };
252 
253 #endif
254 
TMonitor * socketMonitor_
Parallel setup monitor.
std::vector< std::vector< UInt_t > > slaveIndices_
Lists of indices for each slave.
std::vector< LauAbsRValue * > conVars_
Gaussian constraints.
Bool_t readData()
Instruct the slaves to read the input data for the given experiment.
ClassDef(LauSimFitMaster, 0)
void getParametersFromSlaves()
Determine/update the parameter initial values from all slaves.
TStopwatch timer_
The fit timer.
std::map< UInt_t, TString > parNames_
Reverse map of index in the values vector to parameter names.
void addConParameters()
Add parameters to the list of Gaussian constrained parameters.
LauFitNtuple * fitNtuple_
The fit results ntuple.
Bool_t writeOutResults()
Instruct the slaves to write out the fit results.
std::vector< LauParameter * > params_
Parameters.
void getParametersFromSlavesFirstTime()
Determine the parameter names and initial values from all slaves.
UInt_t nParams_
The number of fit parameters.
std::vector< TSocket * > sSlaves_
Sockets for each of the slaves.
const UInt_t reqPort_
The requested port.
std::vector< StoreConstraints > storeCon_
Store the constraints for fit parameters until initialisation is complete.
std::vector< Double_t > vectorRes_
Likelihood values returned from the slaves.
std::map< TString, UInt_t > parIndices_
Map of parameter names to index in the values vector.
Bool_t withinAsymErrorCalc_
Flag to indicate if the asymmetric error calculation (e.g. MINOS) is currently running.
void initSockets()
Initialise socket connections for the slaves.
UInt_t numberBadFits_
The number of fit failures.
TMatrixD covMatrix_
The fit covariance matrix.
Double_t getLogLikelihoodPenalty()
Calculate the penalty terms to the log likelihood from Gaussian constraints.
std::vector< std::vector< UInt_t > > slaveFreeIndices_
Lists of indices of free parameters for each slave.
void checkInitFitParams()
Instruct the slaves to update the initial fit parameter values, if required.
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.
std::vector< Double_t * > vectorPar_
Parameter values to send to the slaves.
void updateParametersFromSlaves()
Update and verify the parameter initial values from all slaves.
std::vector< TMatrixD > covMatrices_
The covariance sub-matrices for each slave.
std::vector< TMessage * > messagesToSlaves_
Messages to slaves.
void checkParameter(const LauParameter *param, UInt_t index) const
Check for compatibility between two same-named parameters, which should therefore be identical...
Class for defining the fit parameter objects.
Definition: LauParameter.hh:35
void fitExpt(Bool_t useAsymmErrors, Bool_t twoStageFit)
Perform the fit for the current experiment.
Int_t fitStatus_
The status of the current fit.
The master process for simultaneous/combined fits.
Bool_t finalise()
Return the final parameters to the slaves and instruct them to perform their finalisation.
TStopwatch cumulTimer_
The total fit timer.
virtual void setParsFromMinuit(Double_t *par, Int_t npar)
This function sets the parameter values from Minuit.
std::vector< Double_t > parValues_
Parameter values.
const UInt_t nSlaves_
The number of slaves.
void runSimFit(const TString &fitNtupleFileName, UInt_t nExpt, UInt_t firstExpt=0, Bool_t useAsymmErrors=kFALSE, Bool_t twoStageFit=kFALSE)
Run the fit.
File containing declaration of LauFitObject class.
UInt_t nFreeParams_
The number of free fit parameters.
Class to store the results from the fit into an ntuple.
Definition: LauFitNtuple.hh:42
virtual void withinAsymErrorCalc(Bool_t inAsymErrCalc)
Mark that the fit is calculating asymmetric errors.
TMessage * messageFromSlave_
Message from slaves to the master.
Bool_t cacheInputData()
Instruct the slaves to perform the caching.
Double_t NLL_
The negative log-likelihood.
void initialise()
Initialise.
virtual Double_t getTotNegLogLikelihood()
Calculate the new value of the negative log likelihood.
LauSimFitMaster & operator=(const LauSimFitMaster &rhs)
Copy assignment operator (not implemented)
UInt_t iExpt_
The experiment number of the current fit.
Pure abstract base class for defining a parameter containing an R value.
Definition: LauAbsRValue.hh:29
virtual ~LauSimFitMaster()
Destructor.
UInt_t numberOKFits_
The number of successful fits.
The abstract interface for the objects that control the calculation of the likelihood.
Definition: LauFitObject.hh:26
LauSimFitMaster(UInt_t numSlaves, UInt_t port=9090)
Constructor.
void printParInfo() const
Print information on the parameters.