laura is hosted by Hepforge, IPPP Durham
Laura++  v2r1p1
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 
21 #ifndef LAU_SIM_FIT_MASTER
22 #define LAU_SIM_FIT_MASTER
23 
24 #include <map>
25 #include <vector>
26 
27 #include "TMatrixD.h"
28 #include "TMessage.h"
29 #include "TStopwatch.h"
30 #include "TString.h"
31 #include "TVectorDfwd.h"
32 
33 #include "LauFitObject.hh"
34 
35 class TMessage;
36 class TMonitor;
37 class TSocket;
38 class LauParameter;
39 class LauFitNtuple;
40 
41 
42 class LauSimFitMaster : public LauFitObject {
43 
44  public:
46 
50  LauSimFitMaster( UInt_t numSlaves, UInt_t port = 9090 );
51 
53  virtual ~LauSimFitMaster();
54 
56 
63  void runSimFit( const TString& fitNtupleFileName, UInt_t nExpt, UInt_t firstExpt = 0, Bool_t useAsymmErrors = kFALSE, Bool_t twoStageFit = kFALSE );
64 
66 
74  virtual void withinAsymErrorCalc(Bool_t inAsymErrCalc) { withinAsymErrorCalc_ = inAsymErrCalc; }
75 
77 
84  virtual void setParsFromMinuit(Double_t* par, Int_t npar);
85 
87 
91  virtual Double_t getTotNegLogLikelihood();
92 
93  protected:
95  void printParInfo() const;
96 
98  void initialise();
99 
101  void initSockets();
102 
105 
108 
111 
113  void checkParameter( const LauParameter* param, UInt_t index ) const;
114 
116 
119  Bool_t readData();
120 
122 
125  Bool_t cacheInputData();
126 
128  void fitExpt( Bool_t useAsymmErrors, Bool_t twoStageFit );
129 
131  void checkInitFitParams();
132 
134  Bool_t finalise();
135 
137  Bool_t writeOutResults();
138 
139 
140  private:
142  const UInt_t nSlaves_;
143 
145  const UInt_t reqPort_;
146 
148  UInt_t nParams_;
149 
151  UInt_t nFreeParams_;
152 
155 
158 
161 
163  Int_t fitStatus_;
164 
166  UInt_t iExpt_;
167 
169  Double_t NLL_;
170 
172  TMatrixD covMatrix_;
173 
175  std::vector<TMatrixD> covMatrices_;
176 
178  TMonitor* socketMonitor_;
179 
181  std::vector<TSocket*> sSlaves_;
182 
184  std::vector<TMessage*> messagesToSlaves_;
185 
187  TMessage* messageFromSlave_;
188 
190  std::map< TString, UInt_t > parIndices_;
191 
193  std::map< UInt_t, TString > parNames_;
194 
196  std::vector<LauParameter*> params_;
197 
199  std::vector<Double_t> parValues_;
200 
202  std::vector< std::vector<UInt_t> > slaveIndices_;
203 
205  std::vector<Double_t*> vectorPar_;
206 
208  std::vector<Double_t> vectorRes_;
209 
211  TStopwatch timer_;
212 
214  TStopwatch cumulTimer_;
215 
218 
220 };
221 
222 #endif
223 
TMonitor * socketMonitor_
Parallel setup monitor.
std::vector< std::vector< UInt_t > > slaveIndices_
Lists of indices for each slave.
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.
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< 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.
void checkInitFitParams()
Instruct the slaves to update the initial fit parameter values, if required.
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:33
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.
UInt_t iExpt_
The experiment number of the current fit.
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.