Changeset View
Changeset View
Standalone View
Standalone View
inc/LauRooFitTask.hh
- This file was moved from inc/LauRooFitSlave.hh.
Show All 16 Lines | |||||
/* | /* | ||||
Laura++ package authors: | Laura++ package authors: | ||||
John Back | John Back | ||||
Paul Harrison | Paul Harrison | ||||
Thomas Latham | Thomas Latham | ||||
*/ | */ | ||||
/*! \file LauRooFitSlave.hh | /*! \file LauRooFitTask.hh | ||||
\brief File containing declaration of LauRooFitSlave class. | \brief File containing declaration of LauRooFitTask class. | ||||
*/ | */ | ||||
/*! \class LauRooFitSlave | /*! \class LauRooFitTask | ||||
\brief A class for creating a RooFit-based slave process for simultaneous/combined fits | \brief A class for creating a RooFit-based task process for simultaneous/combined fits | ||||
Implementation of the JFit method described in arXiv:1409.5080 [physics.data-an]. | Implementation of the JFit method described in arXiv:1409.5080 [physics.data-an]. | ||||
*/ | */ | ||||
#ifndef LAU_ROO_FIT_SLAVE | #ifndef LAU_ROO_FIT_TASK | ||||
#define LAU_ROO_FIT_SLAVE | #define LAU_ROO_FIT_TASK | ||||
#include <set> | |||||
#include <utility> | #include <utility> | ||||
#include <vector> | #include <vector> | ||||
#include "RooAbsPdf.h" | #include "RooAbsPdf.h" | ||||
#include "RooAbsData.h" | #include "RooAbsData.h" | ||||
#include "RooCategory.h" | #include "RooCategory.h" | ||||
#include "RooNLLVar.h" | #include "RooNLLVar.h" | ||||
#include "TMatrixDfwd.h" | #include "TMatrixDfwd.h" | ||||
#include "TString.h" | #include "TString.h" | ||||
#include "LauSimFitSlave.hh" | #include "LauSimFitTask.hh" | ||||
class LauParameter; | class LauParameter; | ||||
class LauRooFitSlave : public LauSimFitSlave { | class LauRooFitTask : public LauSimFitTask { | ||||
public: | public: | ||||
//! Constructor | //! Constructor | ||||
LauRooFitSlave( RooAbsPdf& model, const Bool_t extended, const RooArgSet& vars, const TString& weightVarName = "" ); | LauRooFitTask( RooAbsPdf& model, const Bool_t extended, const RooArgSet& vars, const TString& weightVarName = "" ); | ||||
//! Destructor | //! Destructor | ||||
virtual ~LauRooFitSlave(); | virtual ~LauRooFitTask(); | ||||
//! Initialise the fit model | //! Initialise the fit model | ||||
virtual void initialise(); | virtual void initialise(); | ||||
//! This function sets the parameter values from Minuit | //! This function sets the parameter values from Minuit | ||||
/*! | /*! | ||||
\param [in] par an array storing the various parameter values | \param [in] par an array storing the various parameter values | ||||
\param [in] npar the number of free parameters | \param [in] npar the number of free parameters | ||||
*/ | */ | ||||
virtual void setParsFromMinuit(Double_t* par, Int_t npar); | virtual void setParsFromMinuit(Double_t* par, Int_t npar); | ||||
//! Calculates the total negative log-likelihood | //! Calculates the total negative log-likelihood | ||||
virtual Double_t getTotNegLogLikelihood(); | virtual Double_t getTotNegLogLikelihood(); | ||||
protected: | protected: | ||||
//! Package the initial fit parameters for transmission to the master | //! Package the initial fit parameters for transmission to the coordinator | ||||
/*! | /*! | ||||
\param [out] array the array to be filled with the LauParameter objects | \param [out] array the array to be filled with the LauParameter objects | ||||
*/ | */ | ||||
virtual void prepareInitialParArray( TObjArray& array ); | virtual void prepareInitialParArray( TObjArray& array ); | ||||
//! Convert a RooRealVar into a LauParameter | //! Convert a RooRealVar into a LauParameter | ||||
/*! | /*! | ||||
\param [in] rooParameter the RooRealVar to be converted | \param [in] rooParameter the RooRealVar to be converted | ||||
\return the newly created LauParameter | \return the newly created LauParameter | ||||
*/ | */ | ||||
LauParameter* convertToLauParameter( const RooRealVar* rooParameter ) const; | LauParameter* convertToLauParameter( const RooRealVar* rooParameter ) const; | ||||
//! Convert a RooFormulaVar into LauParameters | //! Convert a RooFormulaVar into LauParameters | ||||
/*! | /*! | ||||
\param [in] rooFormula the RooFormulaVar to be converted | \param [in] rooFormula the RooFormulaVar to be converted | ||||
\return the vector of pointers to the RooRealVars and newly created LauParameters | \return the vector of pointers to the RooRealVars and newly created LauParameters | ||||
*/ | */ | ||||
std::vector< std::pair<RooRealVar*,LauParameter*> > convertToLauParameters( const RooFormulaVar* rooFormula ) const; | std::vector< std::pair<RooRealVar*,LauParameter*> > convertToLauParameters( const RooFormulaVar* rooFormula ) const; | ||||
//! Perform all finalisation actions | //! Perform all finalisation actions | ||||
/*! | /*! | ||||
- Receive the results of the fit from the master | - Receive the results of the fit from the coordinator | ||||
- Perform any finalisation routines | - Perform any finalisation routines | ||||
- Package the finalised fit parameters for transmission back to the master | - Package the finalised fit parameters for transmission back to the coordinator | ||||
\param [in] fitStat the status of the fit, e.g. status code, EDM, NLL | \param [in] fitStat the status of the fit, e.g. status code, EDM, NLL | ||||
\param [in] parsFromMaster the parameters at the fit minimum | \param [in] parsFromCoordinator the parameters at the fit minimum | ||||
\param [in] covMat the fit covariance matrix | \param [in] covMat the fit covariance matrix | ||||
\param [out] parsToMaster the array to be filled with the finalised LauParameter objects | \param [out] parsToCoordinator the array to be filled with the finalised LauParameter objects | ||||
*/ | */ | ||||
virtual void finaliseExperiment( const LauAbsFitter::FitStatus& fitStat, const TObjArray* parsFromMaster, const TMatrixD* covMat, TObjArray& parsToMaster ); | virtual void finaliseExperiment( const LauAbsFitter::FitStatus& fitStat, const TObjArray* parsFromCoordinator, const TMatrixD* covMat, TObjArray& parsToCoordinator ); | ||||
//! Open the input file and verify that all required variables are present | //! Open the input file and verify that all required variables are present | ||||
/*! | /*! | ||||
\param [in] dataFileName the name of the input file | \param [in] dataFileName the name of the input file | ||||
\param [in] dataTreeName the name of the input tree | \param [in] dataTreeName the name of the input tree | ||||
*/ | */ | ||||
virtual Bool_t verifyFitData(const TString& dataFileName, const TString& dataTreeName); | virtual Bool_t verifyFitData(const TString& dataFileName, const TString& dataTreeName); | ||||
//! Read in the data for the current experiment | //! Read in the data for the current experiment | ||||
/*! | /*! | ||||
\return the number of events read in | \return the number of events read in | ||||
*/ | */ | ||||
virtual UInt_t readExperimentData(); | virtual UInt_t readExperimentData(); | ||||
//! Cache the input data values to calculate the likelihood during the fit | //! Cache the input data values to calculate the likelihood during the fit | ||||
virtual void cacheInputFitVars(); | virtual void cacheInputFitVars(); | ||||
private: | private: | ||||
//! Cleanup the data | //! Cleanup the data | ||||
void cleanData(); | void cleanData(); | ||||
//! Copy constructor (not implemented) | //! Copy constructor (not implemented) | ||||
LauRooFitSlave(const LauRooFitSlave& rhs); | LauRooFitTask(const LauRooFitTask& rhs); | ||||
//! Copy assignment operator (not implemented) | //! Copy assignment operator (not implemented) | ||||
LauRooFitSlave& operator=(const LauRooFitSlave& rhs); | LauRooFitTask& operator=(const LauRooFitTask& rhs); | ||||
//! The model | //! The model | ||||
RooAbsPdf& model_; | RooAbsPdf& model_; | ||||
//! The dataset variables | //! The dataset variables | ||||
RooArgSet dataVars_; | RooArgSet dataVars_; | ||||
//! The name of the (optional) weight variable in the dataset | //! The name of the (optional) weight variable in the dataset | ||||
TString weightVarName_; | TString weightVarName_; | ||||
//! The data file | //! The data file | ||||
TFile* dataFile_; | TFile* dataFile_; | ||||
//! The data tree | //! The data tree | ||||
TTree* dataTree_; | TTree* dataTree_; | ||||
//! The data for the current experiment | //! The data for the current experiment | ||||
RooAbsData* exptData_; | RooAbsData* exptData_; | ||||
//! Is the PDF extended? | //! Is the PDF extended? | ||||
const Bool_t extended_; | const Bool_t extended_; | ||||
//! The experiment category variable | //! The experiment category variable | ||||
RooCategory iExptCat_; | std::set<UInt_t> iExptSet_; | ||||
//! The NLL variable | //! The NLL variable | ||||
RooNLLVar* nllVar_; | RooNLLVar* nllVar_; | ||||
//! The fit parameters (as RooRealVar's) | //! The fit parameters (as RooRealVar's) | ||||
std::vector<RooRealVar*> fitVars_; | std::vector<RooRealVar*> fitVars_; | ||||
//! The fit parameters (as LauParameter's) | //! The fit parameters (as LauParameter's) | ||||
std::vector<LauParameter*> fitPars_; | std::vector<LauParameter*> fitPars_; | ||||
ClassDef(LauRooFitSlave,0); | ClassDef(LauRooFitTask,0); | ||||
}; | }; | ||||
#endif | #endif |