LauSimFitMaster.cc
Go to the documentation of this file.
62 for ( std::vector<TSocket*>::iterator iter = sSlaves_.begin(); iter != sSlaves_.end(); ++iter ) {
70 for (std::vector<LauAbsRValue*>::iterator iter = conVars_.begin(); iter != conVars_.end(); ++iter){
79 for ( std::vector<LauParameter*>::iterator iter = params_.begin(); iter != params_.end(); ++iter ) {
84 for ( std::vector<Double_t*>::iterator iter = vectorPar_.begin(); iter != vectorPar_.end(); ++iter ) {
91 for ( std::vector<TMessage*>::iterator iter = messagesToSlaves_.begin(); iter != messagesToSlaves_.end(); ++iter ) {
102 std::cerr << "ERROR in LauSimFitMaster::initSockets : Sockets already initialised." << std::endl;
106 //initialise socket connection, then accept a connection and return a full-duplex communication socket.
112 std::cout << "INFO in LauSimFitMaster::initSockets : Waiting for connection with " << nSlaves_ << " workers on port " << actual_port << std::endl;
140 * OLD VERSION THAT JUST GETS THE NAMES - COULD HAVE A SERIES OF EXCHANGES TO GET THE NAMES, INIT VALUES, RANGES, ETC. INSTEAD OF PASSING PARAMETERS
141 * THIS INCREASES THE GENERALITY OF THE CODE, I.E. THERE IS NO NEED FOR THE SLAVES TO KNOW ANY LAURA++ CLASS BUT THIS ONE, BUT MAKES IT RATHER MORE DENSE
142 * FOR THE MOMENT I WILL STICK WITH THE METHOD OF PASSING LAUPARAMETER OBJECTS AROUND AND CONSIDER GOING BACK TO THIS GENERAL METHOD ONCE EVERYTHING IS WORKING
156 // Wait to receive the response and check that it has come from the slave we just requested from
159 std::cerr << "ERROR in LauSimFitMaster::getParametersFromSlavesFirstTime : Received message from a different slave than expected!" << std::endl;
165 TObjArray * objarray = dynamic_cast<TObjArray*>( messageFromSlave_->ReadObject( messageFromSlave_->GetClass() ) );
167 std::cerr << "ERROR in LauSimFitMaster::getParametersFromSlavesFirstTime : Error reading parameter names from slave" << std::endl;
175 std::cerr << "ERROR in LauSimFitMaster::getParametersFromSlavesFirstTime : Error reading parameter names from slave" << std::endl;
204 std::cerr << "ERROR in LauSimFitMaster::getParametersFromSlaves : Sockets not initialised." << std::endl;
231 // Wait to receive the response and check that it has come from the slave we just requested from
234 std::cerr << "ERROR in LauSimFitMaster::updateParametersFromSlaves : Received message from a different slave than expected!" << std::endl;
240 TObjArray * objarray = dynamic_cast<TObjArray*>( messageFromSlave_->ReadObject( messageFromSlave_->GetClass() ) );
242 std::cerr << "ERROR in LauSimFitMaster::updateParametersFromSlaves : Error reading parameter names from slave" << std::endl;
251 std::cerr << "ERROR in LauSimFitMaster::updateParametersFromSlaves : Unexpected number of parameters received from slave" << std::endl;
258 std::cerr << "ERROR in LauSimFitMaster::updateParametersFromSlaves : Error reading parameter from slave" << std::endl;
267 std::cerr << "ERROR in LauSimFitMaster::updateParametersFromSlaves : Unexpected parameter name received from slave" << std::endl;
273 std::cerr << "ERROR in LauSimFitMaster::updateParametersFromSlaves : Unexpected parameter received from slave" << std::endl;
306 // Wait to receive the response and check that it has come from the slave we just requested from
309 std::cerr << "ERROR in LauSimFitMaster::getParametersFromSlavesFirstTime : Received message from a different slave than expected!" << std::endl;
315 TObjArray * objarray = dynamic_cast<TObjArray*>( messageFromSlave_->ReadObject( messageFromSlave_->GetClass() ) );
317 std::cerr << "ERROR in LauSimFitMaster::getParametersFromSlavesFirstTime : Error reading parameters from slave" << std::endl;
328 std::cerr << "ERROR in LauSimFitMaster::getParametersFromSlavesFirstTime : Error reading parameter from slave" << std::endl;
368 std::cout << "INFO in LauSimFitMaster::printParInfo : Slave " << iSlave << " has the following parameters:\n";
369 for ( std::vector<UInt_t>::const_iterator iter = indices.begin(); iter != indices.end(); ++iter ) {
374 std::cerr << "ERROR in LauSimFitMaster::printParInfo : Discrepancy in parameter name and value records, this is very strange!!" << std::endl;
383 std::cout << "INFO in LauSimFitMaster::printParInfo : " << "There are " << params_.size() << " parameters in total" << std::endl;
392 std::cerr << "ERROR in LauSimFitMaster::checkParameter : Parameter name is different!! This shouldn't happen!!" << std::endl;
395 std::cerr << "WARNING in LauSimFitMaster::checkParameter : Initial value for parameter " << parName << " is different, will use the value first set: " << storedPar->initValue() << std::endl;
398 std::cerr << "WARNING in LauSimFitMaster::checkParameter : Minimum allowed value for parameter " << parName << " is different, will use the value first set: " << storedPar->minValue() << std::endl;
401 std::cerr << "WARNING in LauSimFitMaster::checkParameter : Maximum allowed value for parameter " << parName << " is different, will use the value first set: " << storedPar->maxValue() << std::endl;
404 std::cerr << "WARNING in LauSimFitMaster::checkParameter : Fixed/floating property of parameter " << parName << " is different, will use the value first set: " << (storedPar->fixed() ? "fixed" : "floating") << std::endl;
407 std::cerr << "WARNING in LauSimFitMaster::checkParameter : Second stage property of parameter " << parName << " is different, will use the value first set: " << (storedPar->secondStage() ? "true" : "false") << std::endl;
416 void LauSimFitMaster::runSimFit( const TString& fitNtupleFileName, const UInt_t nExp, const UInt_t firstExp, const Bool_t useAsymmErrors, const Bool_t doTwoStageFit )
425 std::cout << "INFO in LauSimFitMaster::runSimFit : First experiment = " << firstExp << std::endl;
426 std::cout << "INFO in LauSimFitMaster::runSimFit : Number of experiments = " << nExp << std::endl;
449 std::cerr << "ERROR in LauSimFitMaster::runSimFit : One or more slaves reported problems with reading data for experiment " << iExp << ", skipping..." << std::endl;
476 std::cout << "INFO in LauSimFitMaster::runSimFit : Number of OK Fits = " << nOKFits << std::endl;
477 std::cout << "INFO in LauSimFitMaster::runSimFit : Number of Failed Fits = " << nBadFits << std::endl;
480 std::cout << "INFO in LauSimFitMaster::runSimFit : Fit efficiency = " << fitEff*100.0 << "%." << std::endl;
491 std::cerr << "ERROR in LauSimFitMaster::withinAsymErrorCalc : Sockets not initialised." << std::endl;
495 // Construct a message, informing the slaves whether or not we are now within the asymmetric error calculation
522 std::cerr << "WARNING in LauSimFitMaster::withinAsymErrorCalc : Problem informing slave " << iSlave << std::endl;
565 std::cerr << "ERROR in LauSimFitMaster::readData : Slave " << iSlave << " reports no events found for experiment " << iExp << std::endl;
568 std::cerr << "INFO in LauSimFitMaster::readData : Slave " << iSlave << " reports " << nEvents << " events found for experiment " << iExp << std::endl;
580 std::cerr << "ERROR in LauSimFitMaster::cacheInputData : Sockets not initialised." << std::endl;
610 std::cerr << "ERROR in LauSimFitMaster::cacheInputData : Slave " << iSlave << " reports an error performing caching" << std::endl;
630 // Instruct the slaves to update initial fit parameters if required (e.g. if using random numbers).
638 this->startNewFit( LauFitter::fitter()->nParameters(), LauFitter::fitter()->nFreeParameters() );
648 std::cerr << "ERROR in LauSimFitMaster:fitExpt : Not running second stage fit since first stage failed." << std::endl;
652 this->startNewFit( LauFitter::fitter()->nParameters(), LauFitter::fitter()->nFreeParameters() );
676 std::cerr << "ERROR in LauSimFitMaster::setParsFromMinuit : Unexpected number of free parameters: " << npar << ".\n";
699 std::cerr << "ERROR in LauSimFitMaster::getTotNegLogLikelihood : Sockets not initialised." << std::endl;
751 std::cerr << "WARNING in LauSimFitMaster::getTotNegLogLikelihood : Strange NLL value returned by one or more slaves\n";
752 std::cerr << " : Returning worst NLL found so far to force MINUIT out of this region." << std::endl;
765 for ( std::vector<LauAbsRValue*>::const_iterator iter = conVars_.begin(); iter != conVars_.end(); ++iter ) {
782 for ( std::vector<LauParameter*>::const_iterator iter = params_.begin(); iter != params_.end(); ++iter ) {
785 std::cout << "INFO in LauSimFitMaster::addConParameters : Added Gaussian constraint to parameter "<< (*iter)->name() << std::endl;
791 for ( std::vector<StoreConstraints>::const_iterator iter = storeCon.begin(); iter != storeCon.end(); ++iter ) {
794 for ( std::vector<TString>::const_iterator iternames = names.begin(); iternames != names.end(); ++iternames ) {
795 for ( std::vector<LauParameter*>::const_iterator iterfit = params_.begin(); iterfit != params_.end(); ++iterfit ) {
804 std::cerr << "WARNING in LauSimFitMaster::addConParameters: Could not find parameters to constrain in the formula... skipping" << std::endl;
812 std::cout << "INFO in LauSimFitMaster::addConParameters : Added Gaussian constraint to formula\n";
814 for ( std::vector<LauParameter*>::iterator iterparam = params.begin(); iterparam != params.end(); ++iterparam ) {
920 TObjArray * objarray = dynamic_cast<TObjArray*>( messageFromSlave_->ReadObject( messageFromSlave_->GetClass() ) );
922 std::cerr << "ERROR in LauSimFitMaster::finalise : Error reading finalised parameters from slave" << std::endl;
930 std::cerr << "ERROR in LauSimFitMaster::finalise : Unexpected number of finalised parameters received from slave" << std::endl;
936 std::cerr << "ERROR in LauSimFitMaster::finalise : Error reading parameter from slave" << std::endl;
945 std::cerr << "ERROR in LauSimFitMaster::finalise : Unexpected parameter name received from slave" << std::endl;
952 std::cerr << "ERROR in LauSimFitMaster::finalise : Unexpected parameter received from slave" << std::endl;
966 std::cerr << "ERROR in LauSimFitMaster::finalise : Slave " << iSlave << " reports an error performing finalisation" << std::endl;
975 for ( std::vector<LauParameter*>::iterator iter = params_.begin(); iter != params_.end(); ++iter ) {
992 std::cerr << "ERROR in LauSimFitMaster::writeOutResults : Sockets not initialised." << std::endl;
1022 std::cerr << "ERROR in LauSimFitMaster::writeOutResults : Slave " << iSlave << " reports an error performing finalisation" << std::endl;
UInt_t nTotParams() const Access the total number of fit parameters. Definition: LauFitObject.hh:186 virtual const FitStatus & minimise()=0 Perform the minimisation of the fit function. std::vector< std::vector< UInt_t > > slaveIndices_ Lists of indices for each slave. Definition: LauSimFitMaster.hh:197 Bool_t readData() Instruct the slaves to read the input data for the given experiment. Definition: LauSimFitMaster.cc:530 File containing declaration of LauFormulaPar class. void getParametersFromSlaves() Determine/update the parameter initial values from all slaves. Definition: LauSimFitMaster.cc:201 Bool_t fixed() const Check whether the parameter is fixed or floated. Definition: LauParameter.hh:214 virtual void updateParameters()=0 Update the values and errors of the parameters based on the fit minimum. std::map< UInt_t, TString > parNames_ Reverse map of index in the values vector to parameter names. Definition: LauSimFitMaster.hh:185 void addConParameters() Add parameters to the list of Gaussian constrained parameters. Definition: LauSimFitMaster.cc:777 File containing declaration of LauParamFixed class. Bool_t withinAsymErrorCalc() const Query whether the fit is calculating the asymmetric errors. Definition: LauFitObject.hh:74 Double_t maxValue() const The maximum value allowed for the parameter. Definition: LauParameter.hh:202 Bool_t writeOutResults() Instruct the slaves to write out the fit results. Definition: LauSimFitMaster.cc:989 ClassImp(LauAbsCoeffSet) Class for defining combinations of fit parameter objects. Definition: LauFormulaPar.hh:35 Double_t worstLogLike() const Access the worst log likelihood found so far. Definition: LauFitObject.hh:170 virtual Bool_t twoStageFit() const =0 Determine whether the two-stage fit is enabled. File containing declaration of LauAbsFitter class. void storeFitStatus(const LauAbsFitter::FitStatus &status, const TMatrixD &covMatrix) Store fit status information. Definition: LauFitObject.cc:56 Double_t minValue() const The minimum value allowed for the parameter. Definition: LauParameter.hh:196 void getParametersFromSlavesFirstTime() Determine the parameter names and initial values from all slaves. Definition: LauSimFitMaster.cc:288 Bool_t twoStageFit() const Report whether the two-stage fit is enabled. Definition: LauFitObject.hh:59 std::vector< Double_t > vectorRes_ Likelihood values returned from the slaves. Definition: LauSimFitMaster.hh:206 UInt_t nFreeParams() const Access the total number of fit parameters. Definition: LauFitObject.hh:189 std::map< TString, UInt_t > parIndices_ Map of parameter names to index in the values vector. Definition: LauSimFitMaster.hh:182 void addGaussianConstraint(Double_t newGaussMean, Double_t newGaussWidth) Add a Gaussian constraint (or modify an existing one) Definition: LauFormulaPar.cc:151 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. Definition: LauSimFitMaster.cc:416 virtual void initialise(LauFitObject *fitObj, const std::vector< LauParameter * > ¶meters)=0 Initialise the fitter, setting the information on the parameters. File containing declaration of LauFitter class. void storeCorrMatrix(const UInt_t iExpt, const LauAbsFitter::FitStatus &fitStatus, const TMatrixD &covMatrix) Store the correlation matrix and other fit information. Definition: LauFitNtuple.cc:60 Double_t getLogLikelihoodPenalty() Calculate the penalty terms to the log likelihood from Gaussian constraints. Definition: LauSimFitMaster.cc:761 void setCurrentExperiment(const UInt_t curExpt) Set the ID of the current experiment. Definition: LauFitObject.hh:157 const std::vector< StoreConstraints > & constraintsStore() const Const access to the constraints store. Definition: LauFitObject.hh:145 std::vector< std::vector< UInt_t > > slaveFreeIndices_ Lists of indices of free parameters for each slave. Definition: LauSimFitMaster.hh:200 void checkInitFitParams() Instruct the slaves to update the initial fit parameter values, if required. Definition: LauSimFitMaster.cc:620 File containing declaration of LauParameter class. Predicate to allow counting of the number of fixed parameters. Definition: LauParamFixed.hh:24 std::vector< Double_t * > vectorPar_ Parameter values to send to the slaves. Definition: LauSimFitMaster.hh:203 Bool_t secondStage() const Check whether the parameter should be floated only in the second stage of a two stage fit... Definition: LauParameter.hh:220 void updateParametersFromSlaves() Update and verify the parameter initial values from all slaves. Definition: LauSimFitMaster.cc:218 std::vector< TMatrixD > covMatrices_ The covariance sub-matrices for each slave. Definition: LauSimFitMaster.hh:167 virtual void releaseSecondStageParameters()=0 Release parameters marked as "second stage". void checkParameter(const LauParameter *param, UInt_t index) const Check for compatibility between two same-named parameters, which should therefore be identical... Definition: LauSimFitMaster.cc:386 const TMatrixD & covarianceMatrix() const Access the fit covariance matrix. Definition: LauFitObject.hh:204 static LauAbsFitter * fitter() Method that provides access to the singleton fitter. Definition: LauFitter.cc:34 Bool_t finalise() Return the final parameters to the slaves and instruct them to perform their finalisation. Definition: LauSimFitMaster.cc:821 virtual void setParsFromMinuit(Double_t *par, Int_t npar) This function sets the parameter values from Minuit. Definition: LauSimFitMaster.cc:666 Bool_t useAsymmFitErrors() const Report whether or not calculation of asymmetric errors is enabled. Definition: LauFitObject.hh:43 File containing declaration of LauSimFitMaster class. void storeParsAndErrors(const std::vector< LauParameter * > &fitVars, const std::vector< LauParameter > &extraVars) Store parameters and their errors. Definition: LauFitNtuple.cc:186 void startNewFit(const UInt_t nPars, const UInt_t nFreePars) Indicate the start of a new fit. Definition: LauFitObject.cc:46 const LauAbsFitter::FitStatus & fitStatus() const Access the fit status information. Definition: LauFitObject.hh:192 virtual Bool_t useAsymmFitErrors() const =0 Determine whether calculation of asymmetric errors is enabled. Bool_t cacheInputData() Instruct the slaves to perform the caching. Definition: LauSimFitMaster.cc:577 virtual Double_t getTotNegLogLikelihood() Calculate the new value of the negative log likelihood. Definition: LauSimFitMaster.cc:696 File containing declaration of LauFitNtuple class. virtual const TMatrixD & covarianceMatrix() const =0 Retrieve the fit covariance matrix. Generated by 1.8.5 |