#include <IterationConfig.h>
Definition at line 337 of file IterationConfig.h.
◆ ConfigJson()
mkfit::ConfigJson::ConfigJson |
( |
bool |
verbose = false | ) |
|
|
inline |
◆ dump()
◆ load_File()
std::unique_ptr< IterationConfig > mkfit::ConfigJson::load_File |
( |
const std::string & |
fname | ) |
|
Definition at line 498 of file IterationConfig.cc.
References gather_cfg::cout, alignmentValidation::fname, mkfit::from_json(), dqmiolumiharvest::j, and m_verbose.
Referenced by MkFitIterationConfigESProducer::produce().
500 open_ifstream(ifs,
fname, __func__);
503 printf(
"%s begin reading from file %s.\n", __func__,
fname.c_str());
506 if (!skipws_ifstream(ifs))
507 throw std::runtime_error(
"empty file");
513 std::cout <<
" Read JSON entity, iteration index is " <<
j[
"m_iteration_index"] <<
", track algorithm is " 514 <<
j[
"m_track_algorithm"] <<
". Instantiating IterationConfig object and over-laying it with JSON.\n";
517 IterationConfig *icp =
new IterationConfig();
521 return std::unique_ptr<IterationConfig>(icp);
void from_json(const nlohmann::json &nlohmann_json_j, mkfit::LayerControl &nlohmann_json_t)
◆ patch_Files()
Definition at line 380 of file IterationConfig.cc.
References mkfit::ConfigJsonPatcher::cd_top(), gather_cfg::cout, alignmentValidation::fname, SiStripCommissioningSource_FromRAW_cfg::fnames, dqmiolumiharvest::j, mkfit::ConfigJsonPatcher::load(), m_verbose, cuy::rep, mkfit::ConfigJsonPatcher::replace(), edmIntegrityCheck::report, and mkfit::ConfigJsonPatcher::save().
Referenced by initGeom().
386 ConfigJsonPatcher::PatchReport
rep;
390 open_ifstream(ifs,
fname, __func__);
393 printf(
"%s begin reading from file %s.\n", __func__,
fname.c_str());
396 int n_read = 0, n_tot_replaced = 0;
397 while (skipws_ifstream(ifs)) {
403 std::cout <<
" Read JSON entity " << n_read <<
" -- applying patch:\n";
407 int n_replaced = cjp.replace(
j);
410 std::cout <<
" Replaced " << n_replaced <<
" entries.\n";
413 n_tot_replaced += n_replaced;
417 printf(
"%s read %d JSON entities from file %s, replaced %d parameters.\n",
426 rep.inc_counts(1, n_read, n_tot_replaced);
429 if (
rep.n_replacements > 0) {
◆ patchLoad_File()
Definition at line 437 of file IterationConfig.cc.
References mkfit::ConfigJsonPatcher::cd_top(), gather_cfg::cout, alignmentValidation::fname, mps_fire::i, dqmiolumiharvest::j, mkfit::ConfigJsonPatcher::load(), m_verbose, cuy::rep, mkfit::ConfigJsonPatcher::replace(), edmIntegrityCheck::report, mkfit::ConfigJsonPatcher::save(), and mkfit::IterationsInfo::size().
Referenced by initGeom().
440 ConfigJsonPatcher::PatchReport
rep;
443 open_ifstream(ifs,
fname, __func__);
446 printf(
"%s begin reading from file %s.\n", __func__,
fname.c_str());
449 if (!skipws_ifstream(ifs))
450 throw std::runtime_error(
"empty file");
454 int track_algo =
j[
"m_track_algorithm"];
457 for (
int i = 0;
i < its_info.size(); ++
i) {
458 if (its_info[
i].m_track_algorithm == track_algo) {
464 throw std::runtime_error(
"matching IterationConfig not found");
467 std::cout <<
" Read JSON entity, Iteration index is " << iii <<
" -- cloning and applying JSON patch:\n";
470 IterationConfig *icp =
new IterationConfig(its_info[iii]);
471 IterationConfig &ic = *icp;
476 int n_replaced = cjp.replace(
j);
481 printf(
"%s read 1 JSON entity from file %s, replaced %d parameters.\n", __func__,
fname.c_str(), n_replaced);
486 rep.inc_counts(1, 1, n_replaced);
488 if (
rep.n_replacements > 0) {
495 return std::unique_ptr<IterationConfig>(icp);
◆ save_Iterations()
void mkfit::ConfigJson::save_Iterations |
( |
IterationsInfo & |
its_info, |
|
|
const std::string & |
fname_fmt, |
|
|
bool |
include_iter_info_preamble |
|
) |
| |
Definition at line 528 of file IterationConfig.cc.
References mkfit::TrackBase::algoint_to_cstr(), cms::cuda::assert(), alignmentValidation::fname, cuy::ii, dqmiolumiharvest::j, mkfit::IterationConfig::m_track_algorithm, mkfit::IterationsInfo::size(), and mkfit::to_json().
Referenced by initGeom().
531 bool has_pct_d = fname_fmt.find(
"%d") != std::string::npos;
532 bool has_pct_s = fname_fmt.find(
"%s") != std::string::npos;
534 assert((has_pct_d || has_pct_s) &&
"JSON save filename-format must include a %d or %s substring");
535 assert(!(has_pct_d && has_pct_s) &&
"JSON save filename-format must include only one of %d or %s substrings");
537 for (
int ii = 0;
ii < its_info.size(); ++
ii) {
538 const IterationConfig &itconf = its_info[
ii];
542 snprintf(
fname, 1024, fname_fmt.c_str(),
ii);
547 open_ofstream(ofs,
fname, __func__);
549 if (include_iter_info_preamble) {
550 ofs <<
"{ \"m_iterations/" <<
ii <<
"\": ";
553 nlohmann::ordered_json
j;
559 if (include_iter_info_preamble) {
void to_json(nlohmann::json &nlohmann_json_j, const mkfit::LayerControl &nlohmann_json_t)
static const char * algoint_to_cstr(int algo)
◆ test_Direct()
Definition at line 577 of file IterationConfig.cc.
References gather_cfg::cout, mkfit::from_json(), createfilelist::int, dqmiolumiharvest::j, mkfit::IterationConfig::m_layer_configs, mkfit::IterationConfig::m_n_regions, mkfit::IterationConfig::m_steering_params, AlCaHLTBitMon_ParallelJobs::p, AlCaHLTBitMon_QueryRunRegistry::string, and x.
585 std::cout <<
"Layer 43, m_select_max_dphi = " <<
j[
"/m_layer_configs/43/m_select_max_dphi"_json_pointer] <<
"\n";
588 { "op": "replace", "path": "/m_layer_configs/43/m_select_max_dphi", "value": 3.141 } 591 std::cout << "Layer 43, m_select_max_dphi = " <<
j[
"/m_layer_configs/43/m_select_max_dphi"_json_pointer] <<
"\n";
593 auto &jx =
j[
"/m_layer_configs/60"_json_pointer];
595 json::json_pointer jp(lojz);
601 printf(
"Layer 43 : m_select_max_dphi = %f, size_of_layer_vec=%d, m_n_regions=%d, size_of_steering_params=%d\n",
602 it_cfg.m_layer_configs[43].m_select_max_dphi,
603 (
int)it_cfg.m_layer_configs.size(),
605 (
int)it_cfg.m_steering_params.size());
607 printf(
"Layer 60 : m_select_max_dphi = %f, size_of_layer_vec=%d, m_n_regions=%d, size_of_steering_params=%d\n",
608 it_cfg.m_layer_configs[60].m_select_max_dphi,
609 (
int)it_cfg.m_layer_configs.size(),
611 (
int)it_cfg.m_steering_params.size());
617 auto &
x =
j[
"/m_layer_configs"_json_pointer];
618 std::cout <<
"Typename /m_layer_configs " <<
x.type_name() <<
"\n";
619 auto &
y =
j[
"/m_layer_configs/143"_json_pointer];
620 std::cout <<
"Typename /m_layer_configs/143 " <<
y.type_name() <<
", is_null=" <<
y.is_null() <<
"\n";
void from_json(const nlohmann::json &nlohmann_json_j, mkfit::LayerControl &nlohmann_json_t)
◆ test_Patcher()
Definition at line 623 of file IterationConfig.cc.
References mkfit::ConfigJsonPatcher::cd(), mkfit::ConfigJsonPatcher::cd_top(), gather_cfg::cout, mkfit::ConfigJsonPatcher::dump(), cppFunctionSkipper::exception, mkfit::ConfigJsonPatcher::get(), mps_fire::i, createfilelist::int, dqmiolumiharvest::j, mkfit::ConfigJsonPatcher::load(), mkfit::IterationConfig::m_layer_configs, mkfit::IterationConfig::m_n_regions, mkfit::IterationConfig::m_steering_params, mkfit::ConfigJsonPatcher::replace(), mkfit::ConfigJsonPatcher::save(), and x.
624 ConfigJsonPatcher cjp;
630 cjp.cd(
"/m_layer_configs/43/m_select_max_dphi");
631 std::cout <<
"Layer 43, m_select_max_dphi = " << cjp.get(
"") <<
"\n";
633 cjp.replace(
"", 3.141);
635 std::cout <<
"Layer 43, m_select_max_dphi = " << cjp.get(
"/m_layer_configs/43/m_select_max_dphi") <<
"\n";
638 std::cout <<
"Replacing layer 60 m_select_max_dphi with full path\n";
639 cjp.replace(
"/m_layer_configs/60/m_select_max_dphi", 99.876);
642 std::cout <<
"Trying to replace an non-existent array entry\n";
643 cjp.replace(
"/m_layer_configs/1460/m_select_max_dphi", 666.666);
645 std::cout <<
"Caugth exception: " << exc.what() <<
"\n";
648 std::cout <<
"Trying to replace an non-existent object entry\n";
649 cjp.replace(
"/m_layer_configs/1/moo_select_max_dphi", 666.666);
651 std::cout <<
"Caugth exception: " << exc.what() <<
"\n";
654 std::cout <<
"Replacing m_select_max_dphi on layers 1 to 3 to 7.7\n";
655 cjp.cd(
"/m_layer_configs");
656 cjp.replace(1, 3,
"/m_select_max_dphi", 7.7);
664 printf(
"Layer 43: m_select_max_dphi = %f, size_of_layer_vec=%d, m_n_regions=%d, size_of_steering_params=%d\n",
665 it_cfg.m_layer_configs[43].m_select_max_dphi,
666 (
int)it_cfg.m_layer_configs.size(),
668 (
int)it_cfg.m_steering_params.size());
670 printf(
"Layer 60: m_select_max_dphi = %f\n", it_cfg.m_layer_configs[60].m_select_max_dphi);
671 for (
int i = 0;
i < 5; ++
i)
672 printf(
"Layer %2d: m_select_max_dphi = %f\n",
i, it_cfg.m_layer_configs[
i].m_select_max_dphi);
678 auto &
j = cjp.get(
"");
680 auto &
x =
j[
"/m_layer_configs"_json_pointer];
681 std::cout <<
"Typename /m_layer_configs " <<
x.type_name() <<
"\n";
682 auto &
y =
j[
"/m_layer_configs/143"_json_pointer];
683 std::cout <<
"Typename /m_layer_configs/143 " <<
y.type_name() <<
", is_null=" <<
y.is_null() <<
"\n";
◆ m_verbose
bool mkfit::ConfigJson::m_verbose = false |
|
private |