laura is hosted by Hepforge, IPPP Durham
Laura++  v3r2
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, const UInt_t nExp, const UInt_t firstExp = 0, const Bool_t useAsymmErrors = kFALSE, const Bool_t doTwoStageFit = kFALSE );
65 
67 
75  virtual void withinAsymErrorCalc(const Bool_t inAsymErrCalc);
76 
77  // Need to unshadow the query method defined in the base class
79 
81 
88  virtual void setParsFromMinuit(Double_t* par, Int_t npar);
89 
91 
95  virtual Double_t getTotNegLogLikelihood();
96 
97  protected:
99  void printParInfo() const;
100 
102  void initialise();
103 
105  void initSockets();
106 
109 
112 
115 
117  void checkParameter( const LauParameter* param, UInt_t index ) const;
118 
120  void addConParameters();
121 
123  Double_t getLogLikelihoodPenalty();
124 
126 
129  Bool_t readData();
130 
132 
135  Bool_t cacheInputData();
136 
138  void fitExpt();
139 
141  void checkInitFitParams();
142 
144  Bool_t finalise();
145 
147  Bool_t writeOutResults();
148 
149 
150  private:
152  LauSimFitMaster(const LauSimFitMaster& rhs);
153 
156 
158  std::vector<StoreConstraints> storeCon_;
159 
161  const UInt_t nSlaves_;
162 
164  const UInt_t reqPort_;
165 
167  std::vector<TMatrixD> covMatrices_;
168 
170  TMonitor* socketMonitor_;
171 
173  std::vector<TSocket*> sSlaves_;
174 
176  std::vector<TMessage*> messagesToSlaves_;
177 
179  TMessage* messageFromSlave_;
180 
182  std::map< TString, UInt_t > parIndices_;
183 
185  std::map< UInt_t, TString > parNames_;
186 
188  std::vector<LauParameter*> params_;
189 
191  std::vector<LauAbsRValue*> conVars_;
192 
194  std::vector<Double_t> parValues_;
195 
197  std::vector< std::vector<UInt_t> > slaveIndices_;
198 
200  std::vector< std::vector<UInt_t> > slaveFreeIndices_;
201 
203  std::vector<Double_t*> vectorPar_;
204 
206  std::vector<Double_t> vectorRes_;
207 
209  TStopwatch timer_;
210 
212  TStopwatch cumulTimer_;
213 
216 
218 };
219 
220 #endif
221 
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.
Bool_t withinAsymErrorCalc() const
Query whether the fit is calculating the asymmetric errors.
Definition: LauFitObject.hh:74
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.
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.
void runSimFit(const TString &fitNtupleFileName, const UInt_t nExp, const UInt_t firstExp=0, const Bool_t useAsymmErrors=kFALSE, const Bool_t doTwoStageFit=kFALSE)
Run the fit.
void initSockets()
Initialise socket connections for the slaves.
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.
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
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.
File containing declaration of LauFitObject class.
Class to store the results from the fit into an ntuple.
Definition: LauFitNtuple.hh:44
TMessage * messageFromSlave_
Message from slaves to the master.
void fitExpt()
Perform the fit for the current experiment.
Bool_t cacheInputData()
Instruct the slaves to perform the caching.
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)
Pure abstract base class for defining a parameter containing an R value.
Definition: LauAbsRValue.hh:29
virtual ~LauSimFitMaster()
Destructor.
The abstract interface for the objects that control the calculation of the likelihood.
Definition: LauFitObject.hh:30
LauSimFitMaster(UInt_t numSlaves, UInt_t port=9090)
Constructor.
void printParInfo() const
Print information on the parameters.