LauSimFitMaster.cc
Go to the documentation of this file.
65 for ( std::vector<TSocket*>::iterator iter = sSlaves_.begin(); iter != sSlaves_.end(); ++iter ) {
71 for ( std::vector<LauParameter*>::iterator iter = params_.begin(); iter != params_.end(); ++iter ) {
75 for ( std::vector<Double_t*>::iterator iter = vectorPar_.begin(); iter != vectorPar_.end(); ++iter ) {
80 for ( std::vector<TMessage*>::iterator iter = messagesToSlaves_.begin(); iter != messagesToSlaves_.end(); ++iter ) {
90 std::cerr << "ERROR in LauSimFitMaster::initSockets : Sockets already initialised." << std::endl;
94 //initialise socket connection, then accept a connection and return a full-duplex communication socket.
100 std::cout << "INFO in LauSimFitMaster::initSockets : Waiting for connection with " << nSlaves_ << " workers on port " << actual_port << std::endl;
127 * 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
128 * 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
129 * 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
143 // Wait to receive the response and check that it has come from the slave we just requested from
146 std::cerr << "ERROR in LauSimFitMaster::getParametersFromSlavesFirstTime : Received message from a different slave than expected!" << std::endl;
152 TObjArray * objarray = dynamic_cast<TObjArray*>( messageFromSlave_->ReadObject( messageFromSlave_->GetClass() ) );
154 std::cerr << "ERROR in LauSimFitMaster::getParametersFromSlavesFirstTime : Error reading parameter names from slave" << std::endl;
162 std::cerr << "ERROR in LauSimFitMaster::getParametersFromSlavesFirstTime : Error reading parameter names from slave" << std::endl;
191 std::cerr << "ERROR in LauSimFitMaster::getParametersFromSlaves : Sockets not initialised." << std::endl;
215 // Wait to receive the response and check that it has come from the slave we just requested from
218 std::cerr << "ERROR in LauSimFitMaster::updateParametersFromSlaves : Received message from a different slave than expected!" << std::endl;
224 TObjArray * objarray = dynamic_cast<TObjArray*>( messageFromSlave_->ReadObject( messageFromSlave_->GetClass() ) );
226 std::cerr << "ERROR in LauSimFitMaster::updateParametersFromSlaves : Error reading parameter names from slave" << std::endl;
235 std::cerr << "ERROR in LauSimFitMaster::updateParametersFromSlaves : Unexpected number of parameters received from slave" << std::endl;
242 std::cerr << "ERROR in LauSimFitMaster::updateParametersFromSlaves : Error reading parameter from slave" << std::endl;
251 std::cerr << "ERROR in LauSimFitMaster::updateParametersFromSlaves : Unexpected parameter name received from slave" << std::endl;
257 std::cerr << "ERROR in LauSimFitMaster::updateParametersFromSlaves : Unexpected parameter received from slave" << std::endl;
289 // Wait to receive the response and check that it has come from the slave we just requested from
292 std::cerr << "ERROR in LauSimFitMaster::getParametersFromSlavesFirstTime : Received message from a different slave than expected!" << std::endl;
298 TObjArray * objarray = dynamic_cast<TObjArray*>( messageFromSlave_->ReadObject( messageFromSlave_->GetClass() ) );
300 std::cerr << "ERROR in LauSimFitMaster::getParametersFromSlavesFirstTime : Error reading parameters from slave" << std::endl;
311 std::cerr << "ERROR in LauSimFitMaster::getParametersFromSlavesFirstTime : Error reading parameter from slave" << std::endl;
346 std::cout << "INFO in LauSimFitMaster::printParInfo : Slave " << iSlave << " has the following parameters:\n";
347 for ( std::vector<UInt_t>::const_iterator iter = indices.begin(); iter != indices.end(); ++iter ) {
352 std::cerr << "ERROR in LauSimFitMaster::printParInfo : Discrepancy in parameter name and value records, this is very strange!!" << std::endl;
361 std::cout << "INFO in LauSimFitMaster::printParInfo : " << "There are " << nParams_ << " parameters in total" << std::endl;
370 std::cerr << "ERROR in LauSimFitMaster::checkParameter : Parameter name is different!! This shouldn't happen!!" << std::endl;
373 std::cerr << "WARNING in LauSimFitMaster::checkParameter : Initial value for parameter " << parName << " is different, will use the value first set: " << storedPar->initValue() << std::endl;
376 std::cerr << "WARNING in LauSimFitMaster::checkParameter : Minimum allowed value for parameter " << parName << " is different, will use the value first set: " << storedPar->minValue() << std::endl;
379 std::cerr << "WARNING in LauSimFitMaster::checkParameter : Maximum allowed value for parameter " << parName << " is different, will use the value first set: " << storedPar->maxValue() << std::endl;
382 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;
385 std::cerr << "WARNING in LauSimFitMaster::checkParameter : First stage property of parameter " << parName << " is different, will use the value first set: " << (storedPar->firstStage() ? "true" : "false") << std::endl;
388 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;
397 void LauSimFitMaster::runSimFit( const TString& fitNtupleFileName, UInt_t nExpt, UInt_t firstExpt, Bool_t useAsymmErrors, Bool_t twoStageFit )
404 std::cout << "INFO in LauSimFitMaster::runSimFit : First experiment = " << firstExpt << std::endl;
405 std::cout << "INFO in LauSimFitMaster::runSimFit : Number of experiments = " << nExpt << std::endl;
427 std::cerr << "ERROR in LauSimFitMaster::runSimFit : One or more slaves reported problems with reading data for experiment " << iExpt_ << ", skipping..." << std::endl;
459 std::cout << "INFO in LauSimFitMaster::runSimFit : Number of OK Fits = " << numberOKFits_ << std::endl;
460 std::cout << "INFO in LauSimFitMaster::runSimFit : Number of Failed Fits = " << numberBadFits_ << std::endl;
463 std::cout << "INFO in LauSimFitMaster::runSimFit : Fit efficiency = " << fitEff*100.0 << "%." << std::endl;
503 std::cerr << "ERROR in LauSimFitMaster::readData : Slave " << iSlave << " reports no events found for experiment " << iExpt_ << std::endl;
506 std::cerr << "INFO in LauSimFitMaster::readData : Slave " << iSlave << " reports " << nEvents << " events found for experiment " << iExpt_ << std::endl;
518 std::cerr << "ERROR in LauSimFitMaster::cacheInputData : Sockets not initialised." << std::endl;
548 std::cerr << "ERROR in LauSimFitMaster::cacheInputData : Slave " << iSlave << " reports an error performing caching" << std::endl;
568 // Instruct the salves to update initial fit parameters if required (e.g. if using random numbers).
591 std::cerr << "ERROR in LauSimFitMaster:fitExpt : Not running second stage fit since first stage failed." << std::endl;
625 std::cerr << "ERROR in LauSimFitMaster::setParsFromMinuit : Unexpected number of free parameters: " << npar << ".\n";
643 std::cerr << "ERROR in LauSimFitMaster::getTotNegLogLikelihood : Sockets not initialised." << std::endl;
738 // TODO - at present we lose the information on the correlations between the parameters that are unique to each slave
739 // - so should we store the full correlation matrix in an ntuple? along with all the parameters?
778 TObjArray * objarray = dynamic_cast<TObjArray*>( messageFromSlave_->ReadObject( messageFromSlave_->GetClass() ) );
780 std::cerr << "ERROR in LauSimFitMaster::finalise : Error reading finalised parameters from slave" << std::endl;
788 std::cerr << "ERROR in LauSimFitMaster::finalise : Unexpected number of finalised parameters received from slave" << std::endl;
794 std::cerr << "ERROR in LauSimFitMaster::finalise : Error reading parameter from slave" << std::endl;
803 std::cerr << "ERROR in LauSimFitMaster::finalise : Unexpected parameter name received from slave" << std::endl;
810 std::cerr << "ERROR in LauSimFitMaster::finalise : Unexpected parameter received from slave" << std::endl;
824 std::cerr << "ERROR in LauSimFitMaster::finalise : Slave " << iSlave << " reports an error performing finalisation" << std::endl;
833 for ( std::vector<LauParameter*>::iterator iter = params_.begin(); iter != params_.end(); ++iter ) {
850 std::cerr << "ERROR in LauSimFitMaster::writeOutResults : Sockets not initialised." << std::endl;
880 std::cerr << "ERROR in LauSimFitMaster::writeOutResults : Slave " << iSlave << " reports an error performing finalisation" << std::endl;
std::vector< std::vector< UInt_t > > slaveIndices_ Lists of indices for each slave. Definition: LauSimFitMaster.hh:202 Bool_t readData() Instruct the slaves to read the input data for the given experiment. Definition: LauSimFitMaster.cc:469 void getParametersFromSlaves() Determine/update the parameter initial values from all slaves. Definition: LauSimFitMaster.cc:188 Bool_t fixed() const Check whether the parameter is fixed or floated. Definition: LauParameter.hh:193 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:193 File containing declaration of LauParamFixed class. Double_t maxValue() const The maximum value allowed for the parameter. Definition: LauParameter.hh:181 Bool_t writeOutResults() Instruct the slaves to write out the fit results. Definition: LauSimFitMaster.cc:847 virtual Bool_t twoStageFit() const =0 Determine whether the two-stage fit is enabled. File containing declaration of LauAbsFitter class. Double_t minValue() const The minimum value allowed for the parameter. Definition: LauParameter.hh:175 void getParametersFromSlavesFirstTime() Determine the parameter names and initial values from all slaves. Definition: LauSimFitMaster.cc:272 std::vector< Double_t > vectorRes_ Likelihood values returned from the slaves. Definition: LauSimFitMaster.hh:208 std::map< TString, UInt_t > parIndices_ Map of parameter names to index in the values vector. Definition: LauSimFitMaster.hh:190 virtual void initialise(LauFitObject *fitObj, const std::vector< LauParameter * > ¶meters)=0 Initialise the fitter, setting the information on the parameters. virtual std::pair< Int_t, Double_t > minimise()=0 Perform the minimisation of the fit function. Bool_t withinAsymErrorCalc_ Flag to indicate if the asymmetric error calculation (e.g. MINOS) is currently running. Definition: LauSimFitMaster.hh:154 File containing LauFitter namespace. Bool_t firstStage() const Check whether the parameter should be floated only in the first stage of a two stage fit... Definition: LauParameter.hh:199 void checkInitFitParams() Instruct the slaves to update the initial fit parameter values, if required. Definition: LauSimFitMaster.cc:558 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:205 Bool_t secondStage() const Check whether the parameter should be floated only in the second stage of a two stage fit... Definition: LauParameter.hh:205 void updateParametersFromSlaves() Update and verify the parameter initial values from all slaves. Definition: LauSimFitMaster.cc:202 virtual void fixFirstStageParameters()=0 Fix parameters marked as "first stage". std::vector< TMatrixD > covMatrices_ The covariance sub-matrices for each slave. Definition: LauSimFitMaster.hh:175 virtual UInt_t nParameters() const =0 Get the total number of fit parameters. virtual void releaseSecondStageParameters()=0 Release parameters marked as "second stage". void storeCorrMatrix(UInt_t iExpt, Double_t NLL, Int_t fitStatus, const TMatrixD &covMatrix) Store the correlation matrix and other fit information. Definition: LauFitNtuple.cc:63 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:364 void fitExpt(Bool_t useAsymmErrors, Bool_t twoStageFit) Perform the fit for the current experiment. Definition: LauSimFitMaster.cc:564 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:682 virtual UInt_t nFreeParameters() const =0 Get the number of floating fit parameters. virtual void setParsFromMinuit(Double_t *par, Int_t npar) This function sets the parameter values from Minuit. Definition: LauSimFitMaster.cc:616 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:133 void runSimFit(const TString &fitNtupleFileName, UInt_t nExpt, UInt_t firstExpt=0, Bool_t useAsymmErrors=kFALSE, Bool_t twoStageFit=kFALSE) Run the fit. Definition: LauSimFitMaster.cc:397 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:515 virtual Double_t getTotNegLogLikelihood() Calculate the new value of the negative log likelihood. Definition: LauSimFitMaster.cc:640 virtual void releaseFirstStageParameters()=0 Release parameters marked as "first stage". File containing declaration of LauFitNtuple class. virtual const TMatrixD & covarianceMatrix() const =0 Retrieve the fit covariance matrix. Generated by 1.8.5 |