diff --git a/examples/ProgOpts/Test_Dpipi_ProgOpts.cc b/examples/ProgOpts/Test_Dpipi_ProgOpts.cc index 43ca097..4ab844e 100644 --- a/examples/ProgOpts/Test_Dpipi_ProgOpts.cc +++ b/examples/ProgOpts/Test_Dpipi_ProgOpts.cc @@ -1,172 +1,173 @@ #include #include #include "boost/program_options.hpp" #include "boost/tokenizer.hpp" #include "Test_Dpipi_ProgOpts.hh" namespace po = boost::program_options; void validate( boost::any& v, const std::vector& values, Command* /*target_type*/, int) { // Make sure no previous assignment to 'v' has been made po::validators::check_first_occurrence(v); // Extract the first string from 'values'. If there is more than // one string, it's an error, and exception will be thrown. const std::string& s { po::validators::get_single_string(values) }; if ( s == "gen" ) { v = boost::any( Command::Generate ); } else if ( s == "fit" ) { v = boost::any( Command::Fit ); } else if ( s == "simfit" ) { v = boost::any( Command::SimFit ); } else { throw po::validation_error(po::validation_error::invalid_option_value, "command", s, 3); } } void validate( boost::any& v, const std::vector& values, LauTimeDepFitModel::CPEigenvalue* /*target_type*/, int) { // Make sure no previous assignment to 'v' has been made po::validators::check_first_occurrence(v); // Extract the first string from 'values'. If there is more than // one string, it's an error, and exception will be thrown. const std::string& s { po::validators::get_single_string(values) }; if ( s == "QFS" ) { v = boost::any( LauTimeDepFitModel::CPEigenvalue::QFS ); } else if ( s == "CPEven" ) { v = boost::any( LauTimeDepFitModel::CPEigenvalue::CPEven ); } else if ( s == "CPOdd" ) { v = boost::any( LauTimeDepFitModel::CPEigenvalue::CPOdd ); } else { throw po::validation_error(po::validation_error::invalid_option_value); } } namespace LauDecayTime { void validate( boost::any& v, const std::vector& values, EfficiencyMethod* /*target_type*/, int) { // Make sure no previous assignment to 'v' has been made po::validators::check_first_occurrence(v); // Extract the first string from 'values'. If there is more than // one string, it's an error, and exception will be thrown. const std::string& s { po::validators::get_single_string(values) }; if ( s == "uniform" || s == "flat" ) { v = boost::any( EfficiencyMethod::Uniform ); } else if ( s == "binned" || s == "hist" ) { v = boost::any( EfficiencyMethod::Binned ); } else if ( s == "spline" ) { v = boost::any( EfficiencyMethod::Spline ); } else { throw po::validation_error(po::validation_error::invalid_option_value); } } }; TestDpipi_ProgramSettings::TestDpipi_ProgramSettings(const int argc, const char ** argv) { po::options_description main_desc{"Main options"}; main_desc.add_options() ("command", po::value(&command)->required(), "main command: gen, fit, or simfit") ; po::positional_options_description p; p.add("command", 1); po::options_description common_desc{"Common options"}; common_desc.add_options() ("help", "produce help message") ("dtype", po::value(&dType)->default_value(LauTimeDepFitModel::CPEigenvalue::QFS,"QFS"), "type of D decay: QFS, CPOdd, or CPEven") ("dta-model", po::value(&timeEffModel)->default_value(LauDecayTime::EfficiencyMethod::Uniform,"uniform"), "decay-time acceptance model: uniform/flat, binned/hist, spline") ("dtr", po::value(&timeResolution)->default_value(kTRUE), "enable/disable decay-time resolution") ("dtr-perevent", po::value(&perEventTimeErr)->default_value(kFALSE), "enable/disable use of per-event decay-time error (requires decay-time resolution to be enabled to take effect)") ("scaleYields", po::value(&scaleYields)->default_value(kTRUE), "toggle whether (kTRUE) the yields are scaled to account for the neglected components (the default strategy) or (kFALSE) the neglected components' yields are added to the combinatorial yield") + ("setNegToZero", po::value(&scaleYields)->default_value(kFALSE), "toggle whether (kTRUE) the negative yields from the mass fits for Run 1 KK are set to 0") ("seed", po::value(&RNGseed)->default_value(0), "set the seed for the RNG; if not set, the time is used to generate a seed") ("run", po::value(&run)->default_value(2), "set the Run number (1 or 2)") ("dir", po::value(&directory)->default_value(""), "set the directory used to find the nTuples within the root file. Defaults to no directory") ("bkgndList", po::value(&bkgndListStr)->default_value("comb,Bd2DKpi,Bs2DKpi,Lb2Dppi"), "the comma-separated list of background components to include") ("fitBackInput", po::value(&fitBackInput)->default_value("fit0_ToyMC_QFS_expts0-0_expt0.root"), "set the file used as input to the fit: only used if fitBack is also selected") ("eosRoot", po::value(&eosRoot)->default_value("root://eoslhcb.cern.ch//eos/lhcb/wg/b2oc/B2D0pipi"), "set the base EOS area from which all the input data/histograms/json files/etc. should be read") ("eosConfigDir", po::value(&eosConfigDir)->default_value("timedep_fit_histos"), "set the directory name from which the configuration (json files / histogram files) should be read") ("eosDataDir", po::value(&eosDataDir)->default_value("Tuples22/Data"), "set the directory name from which the data should be read") ; po::options_description gen_desc{"Generation options"}; gen_desc.add_options() ("firstExptGen", po::value(&firstExptGen)->default_value(0), "first experiment to generate") ("nExptGen", po::value(&nExptGen)->default_value(1), "number of experiments to generate") ; po::options_description fit_desc{"Fitting options"}; fit_desc.add_options() ("firstExpt", po::value(&firstExptFit)->default_value(0), "first experiment to fit") ("nExpt", po::value(&nExptFit)->default_value(1), "number of experiments to fit") ("iFit", po::value(&iFit)->default_value(0), "fit ID - used to distinguish multiple fits to a given dataset (used to disentangle multiple minima)") ("fixTau", po::value(&fixLifetime)->default_value(kTRUE), "enable/disable floating of B lifetime parameter") ("fixDm", po::value(&fixDeltaM)->default_value(kTRUE), "enable/disable floating of B mixing frequency parameter") ("fixPhiMix", po::value(&fixPhiMix)->default_value(kFALSE), "enable/disable floating of B mixing phase parameter(s)") ("fixSplineKnots", po::value(&fixSplineKnots)->default_value(kFALSE), "enable/disable floating of the decay-time-acceptance spline") ("useSinCos", po::value(&useSinCos)->default_value(kTRUE), "enable/disable using sine and cosine of B mixing phase as the floating parameters rather than the phase itself") ("useAveDeltaCalibVals", po::value(&useAveDeltaCalibVals)->default_value(kTRUE), "enable/disable fitting calib values as their average +/- delta values rather than having separate values for B and Bbar") ("addTaggers", po::value(&addTaggers)->default_value(kTRUE), "add/omit taggers") ("floatCalibPars", po::value(&floatCalibPars)->default_value(kTRUE), "enable/disable floating of the FT calibration parameters") ("floatYields", po::value(&floatYields)->default_value(kFALSE), "enable/disable floating of the yields of each component - if enabled/disabled implies inclusion/exclusion of non-DP PDFs in/from the likelihood") ("fitBack", po::value(&fitBack)->default_value(kFALSE), "enable/disable refitting some generated data from a model") ("blindFit", po::value(&blindFit)->default_value(kFALSE), "enable/disable blinding of the physics parameters") ("dataFit", po::value(&dataFit)->default_value(kFALSE), "fit to data (not MC or toys)") ("genToy", po::value(&genToy)->default_value(kFALSE), "enable/disable generation of a toy to a fit result") ; po::options_description simfit_desc{"Simultaneous fitting options"}; simfit_desc.add_options() ("port", po::value(&port)->default_value(0), "port number on which sim fit coordinator is listening") ; po::options_description all_desc; all_desc.add(main_desc).add(common_desc).add(gen_desc).add(fit_desc).add(simfit_desc); po::variables_map vm; try { po::store(po::command_line_parser(argc, argv). options(all_desc). positional(p). run(), vm); po::notify(vm); } catch ( boost::wrapexcept& e ) { std::cout << argv[0] << " requires a command, one of 'gen', 'fit', or 'simfit'\n" << "Append --help to those commands to see help on the related options" << std::endl; parsedOK = kFALSE; return; } catch ( po::validation_error& e ) { std::cerr << e.what() << std::endl; parsedOK = kFALSE; return; } if ( vm.count("help") ) { po::options_description help_desc; help_desc.add(common_desc).add(gen_desc).add(fit_desc).add(simfit_desc); std::cout << help_desc << std::endl; helpRequested = kTRUE; return; } if ( ! bkgndListStr.empty() ) { const boost::char_separator sep{","}; const boost::tokenizer> tokens{bkgndListStr, sep}; for (const auto& t : tokens) { bkgndList.insert( t ); } } } diff --git a/examples/ProgOpts/Test_Dpipi_ProgOpts.hh b/examples/ProgOpts/Test_Dpipi_ProgOpts.hh index ce3c7f8..1cfa0f1 100644 --- a/examples/ProgOpts/Test_Dpipi_ProgOpts.hh +++ b/examples/ProgOpts/Test_Dpipi_ProgOpts.hh @@ -1,61 +1,62 @@ #ifndef TEST_DPIPI_PROGOPTS #define TEST_DPIPI_PROGOPTS #include "Rtypes.h" #include "LauDecayTime.hh" #include "LauTimeDepFitModel.hh" #include "Command.hh" #include #include struct TestDpipi_ProgramSettings { TestDpipi_ProgramSettings(const int argc, const char ** argv); Bool_t parsedOK{kTRUE}; Bool_t helpRequested{kFALSE}; Command command{Command::Generate}; LauTimeDepFitModel::CPEigenvalue dType{LauTimeDepFitModel::CPEigenvalue::QFS}; LauDecayTime::EfficiencyMethod timeEffModel{LauDecayTime::EfficiencyMethod::Uniform}; UInt_t firstExptGen{0}; UInt_t nExptGen{1}; UInt_t firstExptFit{0}; UInt_t nExptFit{1}; UInt_t iFit{0}; UInt_t port{0}; UInt_t RNGseed{0}; UInt_t run{2}; Bool_t timeResolution{kTRUE}; Bool_t perEventTimeErr{kFALSE}; Bool_t fixLifetime{kTRUE}; Bool_t fixDeltaM{kTRUE}; Bool_t fixPhiMix{kFALSE}; Bool_t fixSplineKnots{kFALSE}; Bool_t useSinCos{kTRUE}; Bool_t useAveDeltaCalibVals{kTRUE}; Bool_t addTaggers{kTRUE}; Bool_t floatCalibPars{kTRUE}; Bool_t floatYields{kFALSE}; Bool_t fitBack{kFALSE}; Bool_t blindFit{kFALSE}; Bool_t dataFit{kFALSE}; Bool_t genToy{kFALSE}; Bool_t scaleYields{kTRUE}; + Bool_t setNegToZero{kFALSE}; std::string bkgndListStr{""}; std::string directory{""}; std::string fitBackInput{""}; std::string eosRoot{""}; std::string eosConfigDir{""}; std::string eosDataDir{""}; std::set bkgndList; }; #endif