LauAbsFitModel.cc
Go to the documentation of this file.
103 for (std::vector<LauAbsRValue*>::iterator iter = conVars_.begin(); iter != conVars_.end(); ++iter){
111 void LauAbsFitModel::run(const TString& applicationCode, const TString& dataFileName, const TString& dataTreeName,
176 std::cout << "INFO in LauAbsFitModel::runSlave : Established connection to master on port " << portMaster << std::endl;
207 std::cout << "INFO in LauAbsFitModel::runSlave : Fit slave " << slaveId_ << " has finished successfully" << std::endl;
213 std::cerr << "WARNING in LauAbsFitModel::doSFit : sWeight branch name is empty string, not setting-up sFit." << std::endl;
225 std::cerr << "WARNING in LauAbsFitModel::setBkgndClassNames : Names already stored, not changing them." << std::endl;
244 for ( LauBkgndClassMap::const_iterator iter = bkgndClassNames_.begin(); iter != bkgndClassNames_.end(); ++iter ) {
257 std::cerr << "ERROR in LauAbsFitModel::bkgndClassID : Request for ID for invalid background class \"" << className << "\"." << std::endl;
262 for ( LauBkgndClassMap::const_iterator iter = bkgndClassNames_.begin(); iter != bkgndClassNames_.end(); ++iter ) {
277 std::cerr << "ERROR in LauAbsFitModel::bkgndClassName : Request for name of invalid background class ID " << classID << "." << std::endl;
286 std::cout << "INFO in LauAbsFitModel::clearFitParVectors : Clearing fit variable vectors" << std::endl;
289 for (std::vector<LauAbsRValue*>::iterator iter = conVars_.begin(); iter != conVars_.end(); ++iter){
301 std::cout << "INFO in LauAbsFitModel::clearExtraVarVectors : Clearing extra ntuple variable vectors" << std::endl;
314 void LauAbsFitModel::writeSPlotData(const TString& fileName, const TString& treeName, Bool_t storeDPEfficiency, const TString& verbosity)
317 std::cerr << "ERROR in LauAbsFitModel::writeSPlotData : Already have an sPlot ntuple setup, not doing it again." << std::endl;
331 void LauAbsFitModel::generate(const TString& dataFileName, const TString& dataTreeName, const TString& /*histFileName*/, const TString& tableFileNameBase)
359 std::cout << "INFO in LauAbsFitModel::generate : Generating experiment number " << iExpt_ << std::endl;
371 std::cerr << "WARNING in LauAbsFitModel::generate : Problem in toy MC generation. Starting again with updated parameters..." << std::endl;
388 std::cout << "INFO in LauAbsFitModel::generate : Finished generating all experiments." << std::endl;
393 std::cout << "INFO in LauAbsFitModel::generate : Building experiment:event index." << std::endl;
399 std::cout << "INFO in LauAbsFitModel::generate : Writing data to file " << dataFileName << "." << std::endl;
463 void LauAbsFitModel::fit(const TString& dataFileName, const TString& dataTreeName, const TString& histFileName, const TString& tableFileNameBase)
507 std::cerr << "WARNING in LauAbsFitModel::fit : Zero events in experiment " << iExpt_ << ", skipping..." << std::endl;
565 std::cout << "INFO in LauAbsFitModel::fit : Number of OK Fits = " << numberOKFits_ << std::endl;
566 std::cout << "INFO in LauAbsFitModel::fit : Number of Failed Fits = " << numberBadFits_ << std::endl;
569 std::cout << "INFO in LauAbsFitModel::fit : Fit efficiency = " << fitEff*100.0 << "%." << std::endl;
578 void LauAbsFitModel::fitSlave(const TString& dataFileName, const TString& dataTreeName, const TString& histFileName, const TString& tableFileNameBase)
606 std::cout << "INFO in LauAbsFitModel::fitSlave : Received message from master: " << msgStr << std::endl;
633 std::cerr << "WARNING in LauAbsFitModel::fitSlave : Zero events in experiment " << firstExpt_ << ", the master should skip this experiment..." << std::endl;
672 std::cout << "INFO in LauAbsFitModel::fitSlave : Received message from master: Finalise" << std::endl;
677 TObjArray * objarray = dynamic_cast<TObjArray*>( messageFromMaster_->ReadObject( messageFromMaster_->GetClass() ) );
679 std::cerr << "ERROR in LauAbsFitModel::fitSlave : Error reading parameters from master" << std::endl;
683 TMatrixD * covMat = dynamic_cast<TMatrixD*>( messageFromMaster_->ReadObject( messageFromMaster_->GetClass() ) );
685 std::cerr << "ERROR in LauAbsFitModel::fitSlave : Error reading covariance matrix from master" << std::endl;
697 std::cerr << "ERROR in LauAbsFitModel::fitSlave : Unexpected number of parameters received from master" << std::endl;
705 std::cerr << "ERROR in LauAbsFitModel::fitSlave : Error reading parameter from master" << std::endl;
710 std::cerr << "ERROR in LauAbsFitModel::fitSlave : Error reading parameter from master" << std::endl;
749 std::cerr << "ERROR in LauAbsFitModel::fitSlave : Unexpected number of parameters received from master" << std::endl;
815 std::cerr << "ERROR in LauAbsFitModel::cacheInputSWeights : Input data does not contain variable \"" << sWeightBranchName_ << "\".\n";
865 std::cerr << "WARNING in LauAbsFitModel:fitExpt : Not running second stage fit since first stage failed." << std::endl;
903 LauSPlot splot(sPlotNtuple_->fileName(), sPlotNtuple_->treeName(), this->firstExpt(), this->nExpt(),
911 void LauAbsFitModel::compareFitData(UInt_t toyMCScale, const TString& mcFileName, const TString& tableFileName, Bool_t poissonSmearing)
955 std::cout << "INFO in LauAbsFitModel::createFitToyMC : Generating toy MC in " << fileName << " to compare fit with data..." << std::endl;
957 std::cout << " : This is to allow the toy MC to be made with reduced statistical fluctuations." << std::endl;
1016 std::cout << "INFO in LauAbsFitModel::createFitToyMC : Finished in createFitToyMC." << std::endl;
1046 for ( LauAbsRValuePList::const_iterator iter = conVars_.begin(); iter != conVars_.end(); ++iter ) {
1081 std::cerr << "WARNING in LauAbsFitModel::getLogLikelihood : Strange likelihood value for event " << iEvt << ": " << likelihood << "\n";
1083 this->printVarsInfo(); //Write the values of the floated variables for which the likelihood is zero
1089 std::cerr << " : Returning worst NLL found so far to force MINUIT out of this region." << std::endl;
1107 std::cerr << "ERROR in LauAbsFitModel::setParsFromMinuit : Unexpected number of free parameters: " << npar << ".\n";
1150 for (LauAbsRValuePList::iterator pars_iter = pars.begin(); pars_iter != pars.end(); ++pars_iter) {
1152 for (LauParameterPList::iterator params_iter = params.begin(); params_iter != params.end(); ++params_iter) {
1154 (this->twoStageFit() && ( (*params_iter)->secondStage() || (*params_iter)->firstStage())) ) ) {
1164 void LauAbsFitModel::addConstraint(const TString& formula, const std::vector<TString>& pars, const Double_t mean, const Double_t width)
1176 for ( LauParameterPList::const_iterator iter = fitVars_.begin(); iter != fitVars_.end(); ++iter ) {
1179 std::cout << "INFO in LauAbsFitModel::addConParameters : Added Gaussian constraint to parameter "<< (*iter)->name() << std::endl;
1184 for ( std::vector<StoreConstraints>::iterator iter = storeCon_.begin(); iter != storeCon_.end(); ++iter ) {
1187 for ( std::vector<TString>::iterator iternames = names.begin(); iternames != names.end(); ++iternames ) {
1188 for ( LauParameterPList::const_iterator iterfit = fitVars_.begin(); iterfit != fitVars_.end(); ++iterfit ) {
1197 std::cerr << "WARNING in LauAbsFitModel::addConParameters: Could not find parameters to constrain in the formula... skipping" << std::endl;
1205 std::cout << "INFO in LauAbsFitModel::addConParameters : Added Gaussian constraint to formula\n";
1207 for ( std::vector<LauParameter*>::iterator iterparam = params.begin(); iterparam != params.end(); ++iterparam ) {
1224 for (LauPdfList::const_iterator pdf_iter = pdfList.begin(); pdf_iter != pdfList.end(); ++pdf_iter) {
1226 for (LauAbsRValuePList::const_iterator pars_iter = pars.begin(); pars_iter != pars.end(); ++pars_iter) {
1228 for (LauParameterPList::iterator params_iter = params.begin(); params_iter != params.end(); ++params_iter) {
1275 std::cerr << " " << (fitVars_[i]->name()).Data() << " = " << fitVars_[i]->value() << std::endl;
Double_t mean_ The mean value of the Gaussian constraint to be applied. Definition: LauAbsFitModel.hh:720 virtual void addSPlotNtupleIntegerBranch(const TString &name) Add a branch to the sPlot tree for storing an integer. Definition: LauAbsFitModel.cc:438 virtual Bool_t twoStageFit() const Determine whether the two-stage fit is enabled. Definition: LauAbsFitModel.hh:117 virtual Bool_t genExpt()=0 The method that actually generates the toy MC events for the given experiment. void createFitToyMC(const TString &mcFileName, const TString &tableFileName) Create a toy MC sample from the fitted parameters. Definition: LauAbsFitModel.cc:920 UInt_t firstExpt() const Obtain the number of the first experiment. Definition: LauAbsFitModel.hh:215 File containing declaration of LauFitDataTree class. virtual Double_t getEventSum() const =0 Returns the sum of the expected events over all hypotheses; used in the EML fit scenario. Bool_t fixed() const Check whether the parameter is fixed or floated. Definition: LauParameter.hh:195 virtual void updateParameters()=0 Update the values and errors of the parameters based on the fit minimum. UInt_t eventsPerExpt() const Obtain the total number of events in the current experiment. Definition: LauAbsFitModel.hh:209 void setGenValues() Make sure all parameters hold their genValue as the current value. Definition: LauAbsFitModel.cc:305 Double_t * parValues_ Parameter values array (for reading from the master) Definition: LauAbsFitModel.hh:865 virtual void writeOutTable(const TString &outputFile)=0 Write the latex table. Bool_t writeLatexTable() const Determine whether writing out of the latex table is enabled. Definition: LauAbsFitModel.hh:169 Bool_t writeSPlotData() const Determine whether the sPlot data is to be written out. Definition: LauAbsFitModel.hh:187 File containing declaration of LauParamFixed class. Double_t getTotNegLogLikelihood() Calculates the total negative log-likelihood. Definition: LauAbsFitModel.cc:1019 LauAbsRValuePList conVars_ Internal vectors of Gaussian parameters. Definition: LauAbsFitModel.hh:776 Bool_t storeDPEff_ Option to store DP efficiencies in the sPlot ntuple. Definition: LauAbsFitModel.hh:741 void cacheInfo(LauPdfList &pdfList, const LauFitDataTree &theData) Have all PDFs in the list cache the data. Definition: LauAbsFitModel.cc:1245 void runCalculations(const TString &option="q") Method to calculate the sWeights and cN coeffs. Definition: LauSPlot.cc:626 virtual void setGenNtupleIntegerBranchValue(const TString &name, Int_t value) Set the value of an integer branch in the gen tree. Definition: LauAbsFitModel.cc:413 ClassImp(LauAbsCoeffSet) virtual void setupBkgndVectors()=0 Method to set up the storage for background-related quantities called by setBkgndClassNames. File containing declaration of LauAbsFitModel class. Bool_t withinAsymErrorCalc_ Flag to indicate if the asymmetric error calculation (e.g. MINOS) is currently running. Definition: LauAbsFitModel.hh:808 Bool_t useAsymmFitErrors() const Determine whether calculation of asymmetric errors is enabled. Definition: LauAbsFitModel.hh:133 Class for defining combinations of fit parameter objects. Definition: LauFormulaPar.hh:35 virtual void setupGenNtupleBranches()=0 Setup the generation ntuple branches. UInt_t addFitParameters(LauPdfList &pdfList) Add parameters of the PDFs in the list to the list of all fit parameters. Definition: LauAbsFitModel.cc:1141 virtual void generate(const TString &dataFileName, const TString &dataTreeName, const TString &histFileName, const TString &tableFileNameBase) Generate toy MC. Definition: LauAbsFitModel.cc:331 virtual void setBkgndClassNames(const std::vector< TString > &names) Setup the background class names. Definition: LauAbsFitModel.cc:222 Int_t buildIndex(const TString &majorName, const TString &minorName="0") Create an index table using leaves of the tree. Definition: LauGenNtuple.cc:164 void compareFitData(UInt_t toyMCScale=10, const TString &mcFileName="fitToyMC.root", const TString &tableFileName="fitToyMCTable.tex", Bool_t poissonSmearing=kTRUE) Specify that a toy MC sample should be created for a successful fit to an experiment. Definition: LauAbsFitModel.cc:911 std::vector< TString > conPars_ The list of LauParameter names to be used in the LauFormulaPar. Definition: LauAbsFitModel.hh:718 Int_t getIntegerBranchValue(const TString &name) const Get value of an integer branch. Definition: LauGenNtuple.cc:101 virtual void cacheInputSWeights() Cache the value of the sWeights to be used in the sFit. Definition: LauAbsFitModel.cc:811 virtual Bool_t twoStageFit() const =0 Determine whether the two-stage fit is enabled. virtual void setGenNtupleDoubleBranchValue(const TString &name, Double_t value) Set the value of a double branch in the gen tree. Definition: LauAbsFitModel.cc:418 File containing declaration of LauAbsFitter class. void addFriendTree(const TString &rootFileName, const TString &rootTreeName) Add a friend tree. Definition: LauGenNtuple.cc:195 virtual void storePerEvtLlhds()=0 Store the per-event likelihood values. virtual void printEventInfo(UInt_t iEvt) const Prints the values of all the fit variables for the specified event - useful for diagnostics. Definition: LauAbsFitModel.cc:1262 Bool_t pdfsDependOnDP() const Do any of the PDFs have a dependence on the DP? Definition: LauAbsFitModel.hh:653 Bool_t compareFitData_ Option to make toy from 1st successful experiment. Definition: LauAbsFitModel.hh:735 File containing declaration of LauPrint class. Double_t prodPdfValue(LauPdfList &pdfList, UInt_t iEvt) Calculate the product of the per-event likelihoods of the PDFs in the list. Definition: LauAbsFitModel.cc:1252 virtual void addConstraint(const TString &formula, const std::vector< TString > &pars, const Double_t mean, const Double_t width) Store constraint information for fit parameters. Definition: LauAbsFitModel.cc:1164 Double_t getDoubleBranchValue(const TString &name) const Get value of a double branch. Definition: LauGenNtuple.cc:112 std::map< TString, Double_t > LauFitData Type for holding event data. Definition: LauFitDataTree.hh:31 virtual Int_t getGenNtupleIntegerBranchValue(const TString &name) const Get the value of an integer branch in the gen tree. Definition: LauAbsFitModel.cc:423 virtual LauSPlot::NumbMap fixdSpeciesNames() const =0 Returns the names and yields of species that are fixed in the fit. virtual void setupSPlotNtupleBranches()=0 Setup the branches of the sPlot tuple. void fitSlave(const TString &dataFileName, const TString &dataTreeName, const TString &histFileName, const TString &tableFileNameBase) Slaves required when performing a simultaneous fit. Definition: LauAbsFitModel.cc:578 virtual void setSPlotNtupleDoubleBranchValue(const TString &name, Double_t value) Set the value of a double branch in the sPlot tree. Definition: LauAbsFitModel.cc:453 void printFitParameters(const LauPdfList &pdfList, std::ostream &fout) const Print the fit parameters for all PDFs in the list. Definition: LauAbsFitModel.cc:1221 void addGaussianConstraint(Double_t newGaussMean, Double_t newGaussWidth) Add a Gaussian constraint (or modify an existing one) Definition: LauFormulaPar.cc:140 virtual void initialise(LauFitObject *fitObj, const std::vector< LauParameter * > ¶meters)=0 Initialise the fitter, setting the information on the parameters. void readExperimentData(UInt_t iExpt) Read events only for the given experiment. Definition: LauFitDataTree.cc:144 virtual std::pair< Int_t, Double_t > minimise()=0 Perform the minimisation of the fit function. std::vector< LauAbsRValue * > LauAbsRValuePList List of parameter pointers. Definition: LauAbsFitModel.hh:328 virtual Double_t getTotEvtLikelihood(UInt_t iEvt)=0 Calculates the likelihood for a given event. File containing LauFitter class. virtual void propagateParUpdates()=0 This function (specific to each model) calculates anything that depends on the fit parameter values... void addConParameters() Add parameters to the list of Gaussian constrained parameters. Definition: LauAbsFitModel.cc:1174 virtual void recalculateNormalisation()=0 Recalculate normalisation the signal DP model(s) Bool_t doSFit() const Return the flag to store the status of using an sFit or not. Definition: LauAbsFitModel.hh:98 void run(const TString &applicationCode, const TString &dataFileName, const TString &dataTreeName, const TString &histFileName, const TString &tableFileName="") Start the toy generation / fitting. Definition: LauAbsFitModel.cc:111 std::vector< LauParameter * > LauParameterPList List of parameter pointers. Definition: LauAbsFitModel.hh:326 LauParameterList extraVars_ Extra variables that aren't in the fit but are stored in the ntuple. Definition: LauAbsFitModel.hh:773 std::vector< StoreConstraints > storeCon_ Store the constraints for fit parameters until initialisation is complete. Definition: LauAbsFitModel.hh:726 void addIntegerBranch(const TString &name) Add integer branch to tree. Definition: LauGenNtuple.cc:73 virtual void addGenNtupleIntegerBranch(const TString &name) Add a branch to the gen tree for storing an integer. Definition: LauAbsFitModel.cc:403 File containing declaration of LauParameter class. Bool_t doPoissonSmearing() const Determine whether Poisson smearing is enabled for the toy MC generation. Definition: LauAbsFitModel.hh:142 virtual Double_t getGenNtupleDoubleBranchValue(const TString &name) const Get the value of a double branch in the gen tree. Definition: LauAbsFitModel.cc:428 void setNExpts(UInt_t nExperiments, UInt_t firstExperiment=0) Set the number of experiments and the first experiment. Definition: LauAbsFitModel.hh:203 virtual void weightEvents(const TString &dataFileName, const TString &dataTreeName)=0 Reweighting - allows e.g. MC events to be weighted by the DP model. Bool_t doEMLFit() const Determine whether an extended maximum likelihood fit it being performed. Definition: LauAbsFitModel.hh:108 virtual void fixFirstStageParameters()=0 Fix parameters marked as "first stage". File containing declaration of LauComplex class. virtual Bool_t isDPDependent() const Specifies whether or not the PDF is DP dependent. Definition: LauAbsPdf.hh:111 virtual UInt_t nParameters() const =0 Get the total number of fit parameters. virtual LauSPlot::NumbMap freeSpeciesNames() const =0 Returns the names and yields of species that are free in the fit. Class to store the results from the toy MC generation into an ntuple. Definition: LauGenNtuple.hh:32 File containing declaration of LauSPlot class. virtual Bool_t splitSignal() const =0 Check if the signal is split into well-reconstructed and mis-reconstructed types. ... virtual void releaseSecondStageParameters()=0 Release parameters marked as "second stage". void clearFitParVectors() Clear the vectors containing fit parameters. Definition: LauAbsFitModel.cc:284 virtual void addSPlotNtupleDoubleBranch(const TString &name) Add a branch to the sPlot tree for storing a double. Definition: LauAbsFitModel.cc:443 void clearExtraVarVectors() Clear the vectors containing extra ntuple variables. Definition: LauAbsFitModel.cc:299 Struct to store constraint information until the fit is run. Definition: LauAbsFitModel.hh:714 virtual void cacheInputFitVars()=0 Cache the input data values to calculate the likelihood during the fit. void fitExpt() Routine to perform the actual fit for a given experiment. Definition: LauAbsFitModel.cc:835 virtual const std::vector< LauAbsRValue * > & getParameters() const Retrieve the parameters of the PDF, e.g. so that they can be loaded into a fit. Definition: LauAbsPdf.hh:239 File containing declaration of LauAbsPdf class. UInt_t bkgndClassID(const TString &className) const The number assigned to a background class. Definition: LauAbsFitModel.cc:254 const LauFitData & getData(UInt_t iEvt) const Retrieve the data for a given event. Definition: LauFitDataTree.cc:312 virtual void finaliseFitResults(const TString &tableFileName)=0 Write the results of the fit into the ntuple. static LauAbsFitter * fitter() Method that provides access to the singleton fitter. Definition: LauFitter.cc:34 void setIntegerBranchValue(const TString &name, Int_t value) Set value of an integer branch. Definition: LauGenNtuple.cc:91 virtual void checkInitFitParams()=0 Update initial fit parameters if required. virtual void printVarsInfo() const Same as printEventInfo, but printing out the values of the variables in the fit. Definition: LauAbsFitModel.cc:1271 Bool_t validBkgndClass(const TString &className) const Check if the given background class is in the list. Definition: LauAbsFitModel.cc:237 virtual UInt_t nFreeParameters() const =0 Get the number of floating fit parameters. virtual Bool_t scfDPSmear() const =0 Check if the mis-reconstructed signal is to be smeared in the DP. Bool_t cacheFitData(const TString &dataFileName, const TString &dataTreeName) Store variables from the input file into the internal data storage. Definition: LauAbsFitModel.cc:795 void fit(const TString &dataFileName, const TString &dataTreeName, const TString &histFileName, const TString &tableFileNameBase) Perform the total fit. Definition: LauAbsFitModel.cc:463 virtual void setSPlotNtupleIntegerBranchValue(const TString &name, Int_t value) Set the value of an integer branch in the sPlot tree. Definition: LauAbsFitModel.cc:448 Double_t width_ The width of the Gaussian constraint to be applied. Definition: LauAbsFitModel.hh:722 void printFormat(std::ostream &stream, Double_t value) const Method to choose the printing format to a specified level of precision. Definition: LauPrint.cc:32 void runSlave(const TString &dataFileName, const TString &dataTreeName, const TString &histFileName, const TString &tableFileName="", const TString &addressMaster="localhost", const UInt_t portMaster=9090) Start the slave process for simultaneous fitting. Definition: LauAbsFitModel.cc:158 virtual LauSPlot::TwoDMap twodimPDFs() const =0 Returns the species and variables for all 2D PDFs in the fit. Double_t getLogLikelihoodPenalty() Calculate the penalty terms to the log likelihood from Gaussian constraints. Definition: LauAbsFitModel.cc:1042 Bool_t haveBranch(const TString &name) const Check if the named branch is stored. Definition: LauFitDataTree.cc:237 const TString & bkgndClassName(UInt_t classID) const Get the name of a background class from the number. Definition: LauAbsFitModel.cc:272 LauParameterPSet resVars_ Internal set of fit parameters upon which the DP normalisation depends. Definition: LauAbsFitModel.hh:770 virtual Bool_t useAsymmFitErrors() const =0 Determine whether calculation of asymmetric errors is enabled. Bool_t enableEmbedding() const Determine whether embedding of events is enabled in the generation. Definition: LauAbsFitModel.hh:151 Double_t getLogLikelihood(UInt_t iStart, UInt_t iEnd) Calculate the sum of the log-likelihood over the specified events. Definition: LauAbsFitModel.cc:1058 virtual LauSPlot::NameSet variableNames() const =0 Returns the names of all variables in the fit. virtual void addGenNtupleDoubleBranch(const TString &name) Add a branch to the gen tree for storing a double. Definition: LauAbsFitModel.cc:408 void updateFitParameters(LauPdfList &pdfList) Update the fit parameters for all PDFs in the list. Definition: LauAbsFitModel.cc:1214 virtual void setParsFromMinuit(Double_t *par, Int_t npar) This function sets the parameter values from Minuit. Definition: LauAbsFitModel.cc:1098 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. File containing declaration of LauGenNtuple class. void setDoubleBranchValue(const TString &name, Double_t value) Set value of a double branch. Definition: LauGenNtuple.cc:96 Generated by 1.8.5 |