laura is hosted by Hepforge, IPPP Durham
Laura++  v3r5
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauSimFitMaster.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 
37 #ifndef LAU_SIM_FIT_MASTER
38 #define LAU_SIM_FIT_MASTER
39 
40 #include <map>
41 #include <vector>
42 
43 #include "TMatrixD.h"
44 #include "TStopwatch.h"
45 #include "TString.h"
46 
47 #include "LauFitObject.hh"
48 
49 class TMessage;
50 class TMonitor;
51 class TSocket;
52 class LauAbsRValue;
53 class LauParameter;
54 class LauFitNtuple;
55 
56 
57 class LauSimFitMaster : public LauFitObject {
58 
59  public:
61 
65  LauSimFitMaster( UInt_t numSlaves, UInt_t port = 9090 );
66 
68  virtual ~LauSimFitMaster();
69 
71 
78  void runSimFit( const TString& fitNtupleFileName, const UInt_t nExp, const UInt_t firstExp = 0, const Bool_t useAsymmErrors = kFALSE, const Bool_t doTwoStageFit = kFALSE );
79 
81 
89  virtual void withinAsymErrorCalc(const Bool_t inAsymErrCalc);
90 
91  // Need to unshadow the query method defined in the base class
93 
95 
102  virtual void setParsFromMinuit(Double_t* par, Int_t npar);
103 
105 
109  virtual Double_t getTotNegLogLikelihood();
110 
111  protected:
113  void printParInfo() const;
114 
116  void initialise();
117 
119  void initSockets();
120 
123 
126 
129 
131  void checkParameter( const LauParameter* param, UInt_t index ) const;
132 
134  void addConParameters();
135 
137  Double_t getLogLikelihoodPenalty();
138 
140 
143  Bool_t readData();
144 
146 
149  Bool_t cacheInputData();
150 
152  void fitExpt();
153 
155  void checkInitFitParams();
156 
158  Bool_t finalise();
159 
161  Bool_t writeOutResults();
162 
163 
164  private:
166  LauSimFitMaster(const LauSimFitMaster& rhs);
167 
170 
172  std::vector<StoreConstraints> storeCon_;
173 
175  const UInt_t nSlaves_;
176 
178  const UInt_t reqPort_;
179 
181  std::vector<TMatrixD> covMatrices_;
182 
184  TMonitor* socketMonitor_;
185 
187  std::vector<TSocket*> sSlaves_;
188 
190  std::vector<TMessage*> messagesToSlaves_;
191 
193  TMessage* messageFromSlave_;
194 
196  std::map< TString, UInt_t > parIndices_;
197 
199  std::map< UInt_t, TString > parNames_;
200 
202  std::vector<LauParameter*> params_;
203 
205  std::vector<LauAbsRValue*> conVars_;
206 
208  std::vector<Double_t> parValues_;
209 
211  std::vector< std::vector<UInt_t> > slaveIndices_;
212 
214  std::vector< std::vector<UInt_t> > slaveFreeIndices_;
215 
217  std::vector<Double_t*> vectorPar_;
218 
220  std::vector<Double_t> vectorRes_;
221 
223  TStopwatch timer_;
224 
226  TStopwatch cumulTimer_;
227 
230 
232 };
233 
234 #endif
235 
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:88
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:49
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:58
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:43
virtual ~LauSimFitMaster()
Destructor.
The abstract interface for the objects that control the calculation of the likelihood.
Definition: LauFitObject.hh:44
LauSimFitMaster(UInt_t numSlaves, UInt_t port=9090)
Constructor.
void printParInfo() const
Print information on the parameters.