Changeset View
Changeset View
Standalone View
Standalone View
examples/SimFitTask.cc
- This file was moved from examples/Slave.cc.
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | void usage( std::ostream& out, const TString& progName ) | ||||
out<<"or\n"; | out<<"or\n"; | ||||
out<<progName<<" fit <category = DD or LL> <iFit> <port> [hostname] [nExpt = 1] [firstExpt = 0]"<<std::endl; | out<<progName<<" fit <category = DD or LL> <iFit> <port> [hostname] [nExpt = 1] [firstExpt = 0]"<<std::endl; | ||||
} | } | ||||
int main( int argc, char** argv ) | int main( int argc, char** argv ) | ||||
{ | { | ||||
// Process command-line arguments | // Process command-line arguments | ||||
// Usage: | // Usage: | ||||
// ./Slave gen <category = DD or LL> [nExpt = 1] [firstExpt = 0] | // ./SimFitTask gen <category = DD or LL> [nExpt = 1] [firstExpt = 0] | ||||
// or | // or | ||||
// ./Slave fit <category = DD or LL> <iFit> <port> [nExpt = 1] [firstExpt = 0] | // ./SimFitTask fit <category = DD or LL> <iFit> <port> [nExpt = 1] [firstExpt = 0] | ||||
if ( argc < 3 ) { | if ( argc < 3 ) { | ||||
usage( std::cerr, argv[0] ); | usage( std::cerr, argv[0] ); | ||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
TString command = argv[1]; | TString command = argv[1]; | ||||
command.ToLower(); | command.ToLower(); | ||||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | int main( int argc, char** argv ) | ||||
fitModel->doEMLFit(haveBkgnds); | fitModel->doEMLFit(haveBkgnds); | ||||
// Activate two-stage fit | // Activate two-stage fit | ||||
fitModel->twoStageFit(kTRUE); | fitModel->twoStageFit(kTRUE); | ||||
// Generate toy from the fitted parameters | // Generate toy from the fitted parameters | ||||
//TString fitToyFileName("fitToyMC_"); | //TString fitToyFileName("fitToyMC_"); | ||||
//fitToyFileName += category; | //fitToyFileName += category; | ||||
//fitToyFileName += "-Slave_"; | //fitToyFileName += "-Task_"; | ||||
//fitToyFileName += iFit; | //fitToyFileName += iFit; | ||||
//fitToyFileName += ".root"; | //fitToyFileName += ".root"; | ||||
//fitModel->compareFitData(100, fitToyFileName); | //fitModel->compareFitData(100, fitToyFileName); | ||||
// Write out per-event likelihoods and sWeights | // Write out per-event likelihoods and sWeights | ||||
//TString splotFileName("splot_"); | //TString splotFileName("splot_"); | ||||
//splotFileName += category; | //splotFileName += category; | ||||
//splotFileName += "-Slave_"; | //splotFileName += "-Task_"; | ||||
//splotFileName += iFit; | //splotFileName += iFit; | ||||
//splotFileName += ".root"; | //splotFileName += ".root"; | ||||
//fitModel->writeSPlotData(splotFileName, "splot", kFALSE); | //fitModel->writeSPlotData(splotFileName, "splot", kFALSE); | ||||
// Set the names of the files to read/write | // Set the names of the files to read/write | ||||
TString dataFile("gen-"); dataFile += category; dataFile += "-Slave.root"; | TString dataFile("gen-"); dataFile += category; dataFile += "-Task.root"; | ||||
TString treeName("genResults"); | TString treeName("genResults"); | ||||
TString rootFileName(""); | TString rootFileName(""); | ||||
TString tableFileName(""); | TString tableFileName(""); | ||||
if (command == "fit") { | if (command == "fit") { | ||||
rootFileName = "fit"; rootFileName += category; rootFileName += "-Slave_"; rootFileName += iFit; | rootFileName = "fit"; rootFileName += category; rootFileName += "-Task_"; rootFileName += iFit; | ||||
rootFileName += "_expt_"; rootFileName += firstExpt; | rootFileName += "_expt_"; rootFileName += firstExpt; | ||||
rootFileName += "-"; rootFileName += (firstExpt+nExpt-1); | rootFileName += "-"; rootFileName += (firstExpt+nExpt-1); | ||||
rootFileName += ".root"; | rootFileName += ".root"; | ||||
tableFileName = "fit"; tableFileName += category; tableFileName += "SlaveResults_"; tableFileName += iFit; | tableFileName = "fit"; tableFileName += category; tableFileName += "TaskResults_"; tableFileName += iFit; | ||||
} else { | } else { | ||||
rootFileName = "dummy.root"; | rootFileName = "dummy.root"; | ||||
tableFileName = "gen"; tableFileName += category; tableFileName += "SlaveResults_"; | tableFileName = "gen"; tableFileName += category; tableFileName += "TaskResults_"; | ||||
} | } | ||||
// Execute the generation/fit | // Execute the generation/fit | ||||
if ( command == "fit" ) { | if ( command == "fit" ) { | ||||
fitModel->runSlave( dataFile, treeName, rootFileName, tableFileName, hostname, port ); | fitModel->runTask( dataFile, treeName, rootFileName, tableFileName, hostname, port ); | ||||
} else { | } else { | ||||
fitModel->run( command, dataFile, treeName, rootFileName, tableFileName ); | fitModel->run( command, dataFile, treeName, rootFileName, tableFileName ); | ||||
} | } | ||||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||||
} | } |