Changeset View
Changeset View
Standalone View
Standalone View
src/LauAbsFitModel.cc
Show First 20 Lines • Show All 507 Lines • ▼ Show 20 Lines | void LauAbsFitModel::fit(const TString& dataFileName, const TString& dataTreeName, const TString& histFileName, const TString& tableFileNameBase) | ||||
this->writeOutAllFitResults(); | this->writeOutAllFitResults(); | ||||
if ( this->writeSPlotData() ) { | if ( this->writeSPlotData() ) { | ||||
this->calculateSPlotData(); | this->calculateSPlotData(); | ||||
} | } | ||||
} | } | ||||
void LauAbsFitModel::setupResultsOutputs( const TString& histFileName, const TString& tableFileName ) | void LauAbsFitModel::setupResultsOutputs( const TString& histFileName, const TString& tableFileName ) | ||||
{ | { | ||||
this->LauSimFitSlave::setupResultsOutputs( histFileName, tableFileName ); | this->LauSimFitTask::setupResultsOutputs( histFileName, tableFileName ); | ||||
outputTableName_ = tableFileName; | outputTableName_ = tableFileName; | ||||
} | } | ||||
Bool_t LauAbsFitModel::verifyFitData(const TString& dataFileName, const TString& dataTreeName) | Bool_t LauAbsFitModel::verifyFitData(const TString& dataFileName, const TString& dataTreeName) | ||||
{ | { | ||||
// From the input data stream, store the variables into the | // From the input data stream, store the variables into the | ||||
// internal tree inputFitData_ that can be used by the sub-classes | // internal tree inputFitData_ that can be used by the sub-classes | ||||
▲ Show 20 Lines • Show All 471 Lines • ▼ Show 20 Lines | if ( ! (*iter)->fixed() ) { | ||||
++nFreePars; | ++nFreePars; | ||||
} | } | ||||
array.Add( *iter ); | array.Add( *iter ); | ||||
} | } | ||||
this->startNewFit( nPars, nFreePars ); | this->startNewFit( nPars, nFreePars ); | ||||
} | } | ||||
void LauAbsFitModel::finaliseExperiment( const LauAbsFitter::FitStatus& fitStat, const TObjArray* parsFromMaster, const TMatrixD* covMat, TObjArray& parsToMaster ) | void LauAbsFitModel::finaliseExperiment( const LauAbsFitter::FitStatus& fitStat, const TObjArray* parsFromCoordinator, const TMatrixD* covMat, TObjArray& parsToCoordinator ) | ||||
{ | { | ||||
// Copy the fit status information | // Copy the fit status information | ||||
this->storeFitStatus( fitStat, *covMat ); | this->storeFitStatus( fitStat, *covMat ); | ||||
// Now process the parameters | // Now process the parameters | ||||
const UInt_t nPars = this->nTotParams(); | const UInt_t nPars = this->nTotParams(); | ||||
UInt_t nParsFromMaster = parsFromMaster->GetEntries(); | UInt_t nParsFromCoordinator = parsFromCoordinator->GetEntries(); | ||||
if ( nParsFromMaster != nPars ) { | if ( nParsFromCoordinator != nPars ) { | ||||
std::cerr << "ERROR in LauAbsFitModel::finaliseExperiment : Unexpected number of parameters received from master" << std::endl; | std::cerr << "ERROR in LauAbsFitModel::finaliseExperiment : Unexpected number of parameters received from coordinator" << std::endl; | ||||
std::cerr << " : Received " << nParsFromMaster << " when expecting " << nPars << std::endl; | std::cerr << " : Received " << nParsFromCoordinator << " when expecting " << nPars << std::endl; | ||||
gSystem->Exit( EXIT_FAILURE ); | gSystem->Exit( EXIT_FAILURE ); | ||||
} | } | ||||
for ( UInt_t iPar(0); iPar < nParsFromMaster; ++iPar ) { | for ( UInt_t iPar(0); iPar < nParsFromCoordinator; ++iPar ) { | ||||
LauParameter* parameter = dynamic_cast<LauParameter*>( (*parsFromMaster)[iPar] ); | LauParameter* parameter = dynamic_cast<LauParameter*>( (*parsFromCoordinator)[iPar] ); | ||||
if ( ! parameter ) { | if ( ! parameter ) { | ||||
std::cerr << "ERROR in LauAbsFitModel::finaliseExperiment : Error reading parameter from master" << std::endl; | std::cerr << "ERROR in LauAbsFitModel::finaliseExperiment : Error reading parameter from coordinator" << std::endl; | ||||
gSystem->Exit( EXIT_FAILURE ); | gSystem->Exit( EXIT_FAILURE ); | ||||
} | } | ||||
if ( parameter->name() != fitVars_[iPar]->name() ) { | if ( parameter->name() != fitVars_[iPar]->name() ) { | ||||
std::cerr << "ERROR in LauAbsFitModel::finaliseExperiment : Error reading parameter from master" << std::endl; | std::cerr << "ERROR in LauAbsFitModel::finaliseExperiment : Error reading parameter from coordinator" << std::endl; | ||||
gSystem->Exit( EXIT_FAILURE ); | gSystem->Exit( EXIT_FAILURE ); | ||||
} | } | ||||
*(fitVars_[iPar]) = *parameter; | *(fitVars_[iPar]) = *parameter; | ||||
} | } | ||||
// Write the results into the ntuple | // Write the results into the ntuple | ||||
this->finaliseFitResults( outputTableName_ ); | this->finaliseFitResults( outputTableName_ ); | ||||
// Store the per-event likelihood values | // Store the per-event likelihood values | ||||
if ( this->writeSPlotData() ) { | if ( this->writeSPlotData() ) { | ||||
this->storePerEvtLlhds(); | this->storePerEvtLlhds(); | ||||
} | } | ||||
// Create a toy MC sample using the fitted parameters so that | // Create a toy MC sample using the fitted parameters so that | ||||
// the user can compare the fit to the data. | // the user can compare the fit to the data. | ||||
if (compareFitData_ == kTRUE && fitStat.status == 3) { | if (compareFitData_ == kTRUE && fitStat.status == 3) { | ||||
this->createFitToyMC(fitToyMCFileName_, fitToyMCTableName_); | this->createFitToyMC(fitToyMCFileName_, fitToyMCTableName_); | ||||
} | } | ||||
// Send the finalised fit parameters | // Send the finalised fit parameters | ||||
for ( LauParameterPList::iterator iter = fitVars_.begin(); iter != fitVars_.end(); ++iter ) { | for ( LauParameterPList::iterator iter = fitVars_.begin(); iter != fitVars_.end(); ++iter ) { | ||||
parsToMaster.Add( *iter ); | parsToCoordinator.Add( *iter ); | ||||
} | } | ||||
} | } | ||||
UInt_t LauAbsFitModel::readExperimentData() | UInt_t LauAbsFitModel::readExperimentData() | ||||
{ | { | ||||
// retrieve the data and find out how many events have been read | // retrieve the data and find out how many events have been read | ||||
const UInt_t exptIndex = this->iExpt(); | const UInt_t exptIndex = this->iExpt(); | ||||
inputFitData_->readExperimentData( exptIndex ); | inputFitData_->readExperimentData( exptIndex ); | ||||
Show All 33 Lines |