From badad795ad5cdaf3b70dce63929debe21069a88a Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Thu, 24 Apr 2025 12:55:39 +0200 Subject: [PATCH 01/21] Add JSON support for PFSimple configuration --- at_interface/CMakeLists.txt | 7 +- at_interface/configs/config_lambda.json | 33 +++ at_interface/configs/config_omega.json | 56 +++++ at_interface/configs/config_xi.json | 55 +++++ at_interface/main_json.cpp | 289 ++++++++++++++++++++++++ 5 files changed, 439 insertions(+), 1 deletion(-) create mode 100644 at_interface/configs/config_lambda.json create mode 100644 at_interface/configs/config_omega.json create mode 100644 at_interface/configs/config_xi.json create mode 100644 at_interface/main_json.cpp diff --git a/at_interface/CMakeLists.txt b/at_interface/CMakeLists.txt index a700b86..9591d4f 100644 --- a/at_interface/CMakeLists.txt +++ b/at_interface/CMakeLists.txt @@ -26,6 +26,11 @@ add_dependencies(main KFMan) add_target_property(main COMPILE_FLAGS "-DDO_TPCCATRACKER_EFF_PERFORMANCE -DNonhomogeneousField -DCBM -DUSE_TIMERS") target_link_libraries(main KFMan KFParticleSimple KFParticleInterface KFParticle Vc) +add_executable(main_json main_json.cpp) +add_dependencies(main_json KFMan) +add_target_property(main_json COMPILE_FLAGS "-DDO_TPCCATRACKER_EFF_PERFORMANCE -DNonhomogeneousField -DCBM -DUSE_TIMERS") +target_link_libraries(main_json KFMan KFParticleSimple KFParticleInterface KFParticle Vc) + install(TARGETS KFMan EXPORT KFManTargets LIBRARY DESTINATION lib ARCHIVE DESTINATION lib @@ -49,4 +54,4 @@ install( lib OPTIONAL ) -install (TARGETS main RUNTIME DESTINATION bin) +install (TARGETS main main_json RUNTIME DESTINATION bin) diff --git a/at_interface/configs/config_lambda.json b/at_interface/configs/config_lambda.json new file mode 100644 index 0000000..3991ca6 --- /dev/null +++ b/at_interface/configs/config_lambda.json @@ -0,0 +1,33 @@ +{ + "io" : { + "input_treename" : "rTree", + "rectracks_branchname" : "VtxTracks", + "n_events" : -1, + "make_plain_tree" : false + }, + "pid_mode" : 0, + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "LdL" : 5.0, + "dist" : 1.0, + "chi2geo" : 3.0 + }, + "save_options" : [] + }, + "daughters" : [ + { + "pdg_codes" : [-211, -1], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [2212, 1], + "cuts" : {"chi2prim" : 18.42} + } + ] + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_omega.json b/at_interface/configs/config_omega.json new file mode 100644 index 0000000..31f6532 --- /dev/null +++ b/at_interface/configs/config_omega.json @@ -0,0 +1,56 @@ +{ + "io" : { + "input_treename" : "rTree", + "rectracks_branchname" : "VtxTracks", + "n_events" : -1, + "make_plain_tree" : false + }, + "pid_mode" : 1, + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "LdL" : 4.0, + "dist" : 0.15, + "chi2geo" : 11.0, + "chi2topo" : 29.0 + }, + "save_options" : [] + }, + "daughters" : [ + { + "pdg_codes" : [-211], + "cuts" : {"chi2prim" : 110} + }, + { + "pdg_codes" : [2212], + "cuts" : {"chi2prim" : 26, "cos" : 0.99825} + } + ] + }, + { + "mother" : { + "name" : "Omega", + "pdg_code" : 3334, + "cuts" : { + "chi2topo" : 5.0, + "LdL" : 5.0, + "chi2geo" : 6.0, + "dist" : 1.0 + }, + "save_options" : ["transport_to_pv"] + }, + "daughters" : [ + { + "pdg_codes" : [-321], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [3122] + } + ] + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_xi.json b/at_interface/configs/config_xi.json new file mode 100644 index 0000000..ca54d1c --- /dev/null +++ b/at_interface/configs/config_xi.json @@ -0,0 +1,55 @@ +{ + "io" : { + "input_treename" : "rTree", + "rectracks_branchname" : "VtxTracks", + "n_events" : -1, + "make_plain_tree" : false + }, + "pid_mode" : 0, + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "LdL" : 5.0, + "dist" : 1.0, + "chi2geo" : 3.0 + }, + "save_options" : [] + }, + "daughters" : [ + { + "pdg_codes" : [-211, -1], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [2212, 1], + "cuts" : {"chi2prim" : 18.42} + } + ] + }, + { + "mother" : { + "name" : "Xi-", + "pdg_code" : 3312, + "cuts" : { + "chi2topo" : 5.0, + "LdL" : 5.0, + "invmass" : 3, + "chi2geo" : 6.0 + }, + "save_options" : [] + }, + "daughters" : [ + { + "pdg_codes" : [-211, -1], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [3122] + } + ] + } + ] +} \ No newline at end of file diff --git a/at_interface/main_json.cpp b/at_interface/main_json.cpp new file mode 100644 index 0000000..d693b9a --- /dev/null +++ b/at_interface/main_json.cpp @@ -0,0 +1,289 @@ +#include "PFSimpleTask.hpp" + +#include "ConverterIn.hpp" +#include "ConverterOut.hpp" + +#include "AnalysisTree/PlainTreeFiller.hpp" +#include "AnalysisTree/TaskManager.hpp" + +#include +#include +#include +#include +#include +#include + +using namespace AnalysisTree; +using json = nlohmann::json; + +#define LIST_CONTAINS(list, value) std::find(list.begin(), list.end(), value) != list.end() + +void set_json_value(json& j, const std::string& path, const std::string& value); + +int main(int argc, char** argv) { + std::string input_file; + std::string config_file; + std::string output_file = "PFSimpleOutput.root"; + std::string plain_output_file = "PFSimplePlainTree.root"; + std::vector> overrides; + + //Parse command line args + + static struct option long_options[] = { + {"output", required_argument, nullptr, 'o'}, + {"plain-output", required_argument, nullptr, 'p'}, + {"set", required_argument, nullptr, 's'}, + {0, 0, 0, 0} + }; + + int opt; + while ((opt = getopt_long(argc, argv, "o:p:s:", long_options, nullptr)) != -1) { + switch (opt) { + case 'o': output_file = optarg; break; + case 'p': plain_output_file = optarg; break; + case 's': { + std::string arg = optarg; + size_t eqPos = arg.find('='); + if (eqPos != std::string::npos) { + std::string key = arg.substr(0, eqPos); + std::string value = arg.substr(eqPos + 1); + overrides.emplace_back(key, value); // ← Save for later + } else { + std::cerr << "Invalid --set format: use key=value\n"; + return 1; + } + break; + } + default: + return 1; + } + } + + if (optind + 2 > argc) { + std::cerr << "Usage: " << argv[0] << " input.root config.json [--output file] [--plain-output file] [--set key=value]\n"; + return 1; + } + + input_file = argv[optind]; + config_file = argv[optind + 1]; + + // Load config JSON file + json config; + std::ifstream cfg_file(config_file); + if (!cfg_file) { + std::cerr << "Cannot open config file: " << config_file << "\n"; + return 1; + } + cfg_file >> config; + + // Apply deferred overrides + for (const auto& [key, value] : overrides) { + set_json_value(config, key, value); + } + + // For demonstration + std::cout << "Modified config:\n" << config.dump(2) << std::endl; + + // Setup PFSimple from JSON config + auto* man = TaskManager::GetInstance(); + + auto* in_converter = new ConverterIn(); + in_converter->SetRecEventHeaderName("RecEventHeader"); + in_converter->SetRecTracksName(config["io"]["rectracks_branchname"]); + in_converter->SetSimTracksName("SimParticles"); + in_converter->SetTrackCuts(new Cuts("Cut to reproduce KFPF", {EqualsCut((config["io"]["rectracks_branchname"].get() + ".pass_cuts").c_str(), 1)})); + + + std::vector decays; + + for (const auto& decay_cfg : config["decays"]) { + printf("Configuring decay %s\n", decay_cfg["mother"]["name"].get().c_str()); + + // + auto daughters_cfg = decay_cfg["daughters"]; + std::vector daughters; + for (const auto& daughter_cfg : daughters_cfg) { + std::vector pdg_codes = daughter_cfg["pdg_codes"].get>(); + + std::cout << "Setting up daughter " << pdg_codes[0] << std::endl; + + if (pdg_codes.size() > 1) + daughters.emplace_back(Daughter(pdg_codes[0], pdg_codes)); + else + daughters.emplace_back(Daughter(pdg_codes[0])); + + auto& d = daughters.back(); + d.CancelCuts(); + if (daughter_cfg.contains("cuts")) { + std::cout << "Applying daughter cuts" << std::endl; + auto cuts = daughter_cfg["cuts"]; + if (cuts.contains("chi2prim")) d.SetCutChi2Prim(cuts["chi2prim"]); + if (cuts.contains("cos")) d.SetCutCos(cuts["cos"]); + } + } + + auto mother_cfg = decay_cfg["mother"]; + Mother mother(mother_cfg["pdg_code"]); + mother.CancelCuts(); + if (mother_cfg.contains("mass")) mother.SetMassPdg(mother_cfg["mass"]); + if (mother_cfg.contains("mass_sigma")) mother.SetMassPdgSigma(mother_cfg["mass_sigma"]); + + if (mother_cfg.contains("cuts")) { + auto cuts = mother_cfg["cuts"]; + if (cuts.contains("dist")) mother.SetCutDistance(cuts["dist"]); + if (cuts.contains("distSV")) mother.SetCutDistanceToSV(cuts["distSV"]); + if (cuts.contains("chi2geo")) mother.SetCutChi2Geo(cuts["chi2geo"]); + if (cuts.contains("cosopen")) mother.SetCutCosOpen(cuts["cosopen"]); + if (cuts.contains("chi2topo")) mother.SetCutChi2Topo(cuts["chi2topo"]); + if (cuts.contains("costopo")) mother.SetCutCosTopo(cuts["costopo"]); + if (cuts.contains("LdL")) mother.SetCutLdL(cuts["LdL"]); + if (cuts.contains("L")) mother.SetCutDecayLength(cuts["L"]); + if (cuts.contains("distPVline")) mother.SetCutDistancePVLine(cuts["distPVline"]); + if (cuts.contains("invmass")) mother.SetCutInvMass(cuts["invmass"]); + } + + // Secondary mother cuts (SM) + if (decay_cfg.contains("daughter_combination_cuts")) { + auto combo_cuts = decay_cfg["daughter_combination_cuts"]; + + if (combo_cuts.contains("chi2geo")) mother.SetCutChi2GeoSM(combo_cuts["chi2geo"].get>()); + if (combo_cuts.contains("cosopen")) mother.SetCutCosOpenSM(combo_cuts["cosopen"].get>()); + if (combo_cuts.contains("chi2topo")) mother.SetCutChi2TopoSM(combo_cuts["chi2topo"].get>()); + if (combo_cuts.contains("costopo")) mother.SetCutCosTopoSM(combo_cuts["costopo"].get>()); + } + + Decay decay(mother_cfg["name"], mother, {daughters}); + + if (mother_cfg.contains("save_options")) { + const auto& options = mother_cfg["save_options"]; + if (LIST_CONTAINS(options, "mass_constraint")) decay.SetIsApplyMassConstraint(); + if (LIST_CONTAINS(options, "transport_to_pv")) decay.SetIsTransportToPV(); + } + + decays.push_back(decay); + } + + // PID and IO settings + auto pid_mode = config["pid_mode"]; + auto pid_purity_cfg = config["pid_purity"]; + + in_converter->SetPidMode(pid_mode); + if (pid_purity_cfg.contains("default")) in_converter->SetPidPurity(pid_purity_cfg["default"]); + if (pid_purity_cfg.contains("protons")) in_converter->SetPidPurityProton(pid_purity_cfg["protons"]); + if (pid_purity_cfg.contains("pions")) in_converter->SetPidPurityPion(pid_purity_cfg["pions"]); + if (pid_purity_cfg.contains("kaons")) in_converter->SetPidPurityKaon(pid_purity_cfg["kaons"]); + if (pid_purity_cfg.contains("deuterons")) in_converter->SetPidPurityDeuteron(pid_purity_cfg["deuterons"]); + + auto* pf_task = new PFSimpleTask(); + pf_task->SetInTask(in_converter); + pf_task->SetDecays({decays}); + + auto* out_converter = new ConverterOut(); + man->SetOutputName(output_file, "pTree"); + out_converter->SetSimEventHeaderName("SimEventHeader"); + out_converter->SetRecTracksName(config["io"]["rectracks_branchname"]); + out_converter->SetSimTracksName("SimParticles"); + out_converter->SetPFSimpleTask(pf_task); + out_converter->SetDecays(decays); + + man->AddTask(in_converter); + man->AddTask(pf_task); + man->AddTask(out_converter); + man->SetVerbosityPeriod(100); + + man->Init({input_file}, {config["io"]["input_treename"]}); + man->Run(config["io"]["n_events"]);// -1 = all events + man->Finish(); + man->ClearTasks(); + + if (config["io"]["make_plain_tree"]) { + std::ofstream filelist; + filelist.open("filelist.txt"); + filelist << output_file; + filelist << "\n"; + filelist.close(); + + auto* tree_task = new PlainTreeFiller(); + tree_task->SetOutputName(plain_output_file, "plain_tree"); + std::string branchname_rec = "Candidates"; + tree_task->SetInputBranchNames({branchname_rec}); + tree_task->AddBranch(branchname_rec); + + man->AddTask(tree_task); + + man->Init({"filelist.txt"}, {"pTree"}); + man->Run(config["io"]["n_events"]);// -1 = all events + man->Finish(); + } + + return 0; +} + +void set_json_value(json& config, const std::string& path, const std::string& value) { + std::cout << "[DEBUG] Setting " << path << " to " << value << std::endl; + + std::regex token_regex(R"(([^.\[\]]+)(?:\[(\d+)\])?)"); + auto tokens_begin = std::sregex_iterator(path.begin(), path.end(), token_regex); + auto tokens_end = std::sregex_iterator(); + + json* current = &config; + + for (auto it = tokens_begin; it != tokens_end; ++it) { + std::string key = (*it)[1]; + std::string index_str = (*it)[2]; + + bool is_last = (std::next(it) == tokens_end); + + if (!index_str.empty()) { + // Key points to an array + int index = std::stoi(index_str); + + if (!(*current)[key].is_array()) { + (*current)[key] = json::array(); + } + + while ((*current)[key].size() <= index) { + (*current)[key].push_back(nullptr); + } + + if (is_last) { + // Set value at the array element + json& target = (*current)[key][index]; + try { + if (value == "true" || value == "false") { + target = (value == "true"); + } else if (value == "null") { + target = nlohmann::json(); + } else if (value.find('.') != std::string::npos) { + target = std::stod(value); + } else { + target = std::stoi(value); + } + } catch (...) { + target = value; + } + return; + } else { + current = &((*current)[key][index]); + } + } else { + if (is_last) { + json& target = (*current)[key]; + try { + if (value == "true" || value == "false") { + target = (value == "true"); + } else if (value.find('.') != std::string::npos) { + target = std::stod(value); + } else { + target = std::stoi(value); + } + } catch (...) { + target = value; + } + return; + } else { + current = &((*current)[key]); + } + } + } +} \ No newline at end of file From 0d15f4e2599f8667c305ed204970299d0ece0887 Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Thu, 24 Apr 2025 13:07:04 +0200 Subject: [PATCH 02/21] merge --- at_interface/main_json.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/at_interface/main_json.cpp b/at_interface/main_json.cpp index d693b9a..2b8d909 100644 --- a/at_interface/main_json.cpp +++ b/at_interface/main_json.cpp @@ -28,7 +28,6 @@ int main(int argc, char** argv) { std::vector> overrides; //Parse command line args - static struct option long_options[] = { {"output", required_argument, nullptr, 'o'}, {"plain-output", required_argument, nullptr, 'p'}, @@ -192,7 +191,7 @@ int main(int argc, char** argv) { man->SetVerbosityPeriod(100); man->Init({input_file}, {config["io"]["input_treename"]}); - man->Run(config["io"]["n_events"]);// -1 = all events + man->Run(config["io"]["n_events"]); man->Finish(); man->ClearTasks(); @@ -212,7 +211,7 @@ int main(int argc, char** argv) { man->AddTask(tree_task); man->Init({"filelist.txt"}, {"pTree"}); - man->Run(config["io"]["n_events"]);// -1 = all events + man->Run(config["io"]["n_events"]); man->Finish(); } From 2c0b5c67c6fef98cfaeb68760bd1a0ffcd83e0b6 Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Thu, 24 Apr 2025 13:59:12 +0200 Subject: [PATCH 03/21] Add new options --- at_interface/main_json.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/at_interface/main_json.cpp b/at_interface/main_json.cpp index 2b8d909..5add216 100644 --- a/at_interface/main_json.cpp +++ b/at_interface/main_json.cpp @@ -17,7 +17,6 @@ using namespace AnalysisTree; using json = nlohmann::json; #define LIST_CONTAINS(list, value) std::find(list.begin(), list.end(), value) != list.end() - void set_json_value(json& j, const std::string& path, const std::string& value); int main(int argc, char** argv) { @@ -46,7 +45,7 @@ int main(int argc, char** argv) { if (eqPos != std::string::npos) { std::string key = arg.substr(0, eqPos); std::string value = arg.substr(eqPos + 1); - overrides.emplace_back(key, value); // ← Save for later + overrides.emplace_back(key, value); // Save for later } else { std::cerr << "Invalid --set format: use key=value\n"; return 1; @@ -81,7 +80,7 @@ int main(int argc, char** argv) { } // For demonstration - std::cout << "Modified config:\n" << config.dump(2) << std::endl; + //std::cout << "Modified config:\n" << config.dump(2) << std::endl; // Setup PFSimple from JSON config auto* man = TaskManager::GetInstance(); @@ -104,8 +103,6 @@ int main(int argc, char** argv) { for (const auto& daughter_cfg : daughters_cfg) { std::vector pdg_codes = daughter_cfg["pdg_codes"].get>(); - std::cout << "Setting up daughter " << pdg_codes[0] << std::endl; - if (pdg_codes.size() > 1) daughters.emplace_back(Daughter(pdg_codes[0], pdg_codes)); else @@ -114,7 +111,6 @@ int main(int argc, char** argv) { auto& d = daughters.back(); d.CancelCuts(); if (daughter_cfg.contains("cuts")) { - std::cout << "Applying daughter cuts" << std::endl; auto cuts = daughter_cfg["cuts"]; if (cuts.contains("chi2prim")) d.SetCutChi2Prim(cuts["chi2prim"]); if (cuts.contains("cos")) d.SetCutCos(cuts["cos"]); @@ -157,6 +153,7 @@ int main(int argc, char** argv) { const auto& options = mother_cfg["save_options"]; if (LIST_CONTAINS(options, "mass_constraint")) decay.SetIsApplyMassConstraint(); if (LIST_CONTAINS(options, "transport_to_pv")) decay.SetIsTransportToPV(); + if (LIST_CONTAINS(options, "do_not_write_mother")) decay.SetIsDoNotWriteMother(); } decays.push_back(decay); @@ -184,6 +181,7 @@ int main(int argc, char** argv) { out_converter->SetSimTracksName("SimParticles"); out_converter->SetPFSimpleTask(pf_task); out_converter->SetDecays(decays); + if (config["io"].contains("write_detailed_bg")) out_converter->SetIsWriteDetailedBG(config["io"]["write_detailed_bg"]); man->AddTask(in_converter); man->AddTask(pf_task); @@ -207,6 +205,7 @@ int main(int argc, char** argv) { std::string branchname_rec = "Candidates"; tree_task->SetInputBranchNames({branchname_rec}); tree_task->AddBranch(branchname_rec); + //tree_task->SetIsPrependLeavesWithBranchName(false); //Uncomment when most recent AnalysisTree is installed in cbmroot man->AddTask(tree_task); From d50a8bffd9847bf9df448581f8ed9d2502218879 Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Thu, 24 Apr 2025 13:59:32 +0200 Subject: [PATCH 04/21] Add Omegastar config --- at_interface/configs/config_omegastar.json | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 at_interface/configs/config_omegastar.json diff --git a/at_interface/configs/config_omegastar.json b/at_interface/configs/config_omegastar.json new file mode 100644 index 0000000..b800751 --- /dev/null +++ b/at_interface/configs/config_omegastar.json @@ -0,0 +1,85 @@ +{ + "io" : { + "input_treename" : "rTree", + "rectracks_branchname" : "VtxTracks", + "n_events" : -1, + "make_plain_tree" : false + }, + "pid_mode" : 1, + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "LdL" : 5.0, + "dist" : 1.0, + "chi2geo" : 3.0 + } + }, + "daughters" : [ + { + "pdg_codes" : [-211], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [2212], + "cuts" : {"chi2prim" : 18.42} + } + ] + }, + { + "mother" : { + "name" : "Xi-", + "pdg_code" : 3312, + "cuts" : { + "chi2topo" : 5.0, + "LdL" : 5.0, + "invmass" : 3, + "chi2geo" : 6.0 + } + }, + "daughters" : [ + { + "pdg_codes" : [-211], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [3122] + } + ] + }, + { + "mother" : { + "name" : "Omega*-", + "pdg_code" : 1003334, + "cuts" : { + "dist" : 1.0, + "chi2topo" : 1000.0, + "LdL" : 5.0, + "mass" : 2.252, + "mass_sigma" : 0.055, + "chi2geo" : 3.0 + } + }, + "daughters" : [ + { + "pdg_codes" : [3312], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [211], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [-321], + "cuts" : {"chi2prim" : 18.42} + } + ], + "daughter_combination_cuts" : { + "comment" : "daugher 1 & 2, daughter 1 & 3, daughter 2 & 3", + "chi2geo" : [3.0] + } + } + ] +} \ No newline at end of file From dfbeaa4f08ac310e4a4dd2db62b7798528fb1da1 Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Mon, 28 Apr 2025 10:18:24 +0200 Subject: [PATCH 05/21] Update configs --- at_interface/configs/config_H3L1.json | 43 ++++++++++ at_interface/configs/config_H3L2.json | 51 +++++++++++ at_interface/configs/config_lambda1.json | 34 ++++++++ at_interface/configs/config_lambda2.json | 35 ++++++++ ...config_lambda.json => config_lambda3.json} | 9 +- at_interface/configs/config_lambda4.json | 34 ++++++++ at_interface/configs/config_omega.json | 22 ++--- at_interface/configs/config_omegastar.json | 30 ++++--- at_interface/configs/config_xi.json | 17 ++-- at_interface/main_json.cpp | 84 +++++++++++-------- 10 files changed, 291 insertions(+), 68 deletions(-) create mode 100644 at_interface/configs/config_H3L1.json create mode 100644 at_interface/configs/config_H3L2.json create mode 100644 at_interface/configs/config_lambda1.json create mode 100644 at_interface/configs/config_lambda2.json rename at_interface/configs/{config_lambda.json => config_lambda3.json} (73%) create mode 100644 at_interface/configs/config_lambda4.json diff --git a/at_interface/configs/config_H3L1.json b/at_interface/configs/config_H3L1.json new file mode 100644 index 0000000..75857a5 --- /dev/null +++ b/at_interface/configs/config_H3L1.json @@ -0,0 +1,43 @@ +//from parfile3.txt +//(H3L pid 1) +{ + "io" : { + "input_treename" : "rTree", + "rectracks_branchname" : "VtxTracks", + "n_events" : -1, + "make_plain_tree" : true + }, + "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + "decays" : [ + { + "mother" : { + "name" : "H3L", + "pdg_code" : 3004, + "cuts" : { + "LdL" : 10.0, + "dist" : 0.2, + "distSV" : 0.2 + } + }, + "daughters" : [ + { + "pdg_codes" : [2212], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [-211], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [1000010020], + "cuts" : {"chi2prim" : 10.0} + } + ], + "daughter_combination_cuts" : { + "comment" : "daugher 1 & 2, daughter 1 & 3, daughter 2 & 3", + "chi2geo" : [3.0], + "chi2topo" : [2.0] + } + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_H3L2.json b/at_interface/configs/config_H3L2.json new file mode 100644 index 0000000..27db93c --- /dev/null +++ b/at_interface/configs/config_H3L2.json @@ -0,0 +1,51 @@ +//from parfile3_H3L_pidmode4.txt +//(H3L pid 4) +{ + "io" : { + "input_treename" : "pTree", + "rectracks_branchname" : "RecTracks", + "n_events" : -1, + "make_plain_tree" : true + }, + "pid_mode" : 4, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + "pid_purity" : { + "default" : 0.5, + "protons" : 0.7, + "pions" : 0.7, + "kaons" : 0.7, + "deuterons" : 0.2, + "background" : 0.7 + }, + "decays" : [ + { + "mother" : { + "name" : "H3L", + "pdg_code" : 3004, + "cuts" : { + "LdL" : 10.0, + "dist" : 0.2, + "distSV" : 0.2 + } + }, + "daughters" : [ + { + "pdg_codes" : [2212], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [-211], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [1000010020], + "cuts" : {"chi2prim" : 10.0} + } + ], + "daughter_combination_cuts" : { + "comment" : "daugher 1 & 2, daughter 1 & 3, daughter 2 & 3", + "chi2geo" : [3.0], + "chi2topo" : [2.0] + } + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_lambda1.json b/at_interface/configs/config_lambda1.json new file mode 100644 index 0000000..a4d0938 --- /dev/null +++ b/at_interface/configs/config_lambda1.json @@ -0,0 +1,34 @@ +//from parfile2.txt +//(Lambda pid 1, cuts KFParticle) +{ + "io" : { + "input_treename" : "rTree", + "rectracks_branchname" : "VtxTracks", + "n_events" : -1, + "make_plain_tree" : true + }, + "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "LdL" : 5.0, + "dist" : 1.0, + "chi2geo" : 3.0 + } + }, + "daughters" : [ + { + "pdg_codes" : [-211], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [2212], + "cuts" : {"chi2prim" : 18.42} + } + ] + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_lambda2.json b/at_interface/configs/config_lambda2.json new file mode 100644 index 0000000..85c391f --- /dev/null +++ b/at_interface/configs/config_lambda2.json @@ -0,0 +1,35 @@ +//from parfile2_lambda_pidmode1_optcut.txt +//(Lambda pid 1, cuts optimized Oleksii) +{ + "io" : { + "input_treename" : "rTree", + "rectracks_branchname" : "VtxTracks", + "n_events" : -1, + "make_plain_tree" : true + }, + "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "LdL" : 4.0, + "dist" : 0.15, + "chi2geo" : 11.0, + "chi2topo" : 29.0 + } + }, + "daughters" : [ + { + "pdg_codes" : [-211], + "cuts" : {"chi2prim" : 110.00} + }, + { + "pdg_codes" : [2212], + "cuts" : {"chi2prim" : 26.00, "cos" : 0.99825} + } + ] + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_lambda.json b/at_interface/configs/config_lambda3.json similarity index 73% rename from at_interface/configs/config_lambda.json rename to at_interface/configs/config_lambda3.json index 3991ca6..c6f8797 100644 --- a/at_interface/configs/config_lambda.json +++ b/at_interface/configs/config_lambda3.json @@ -1,11 +1,13 @@ +//from parfile2_lambda_pidmode0.txt +//(Lambda pid 0) { "io" : { "input_treename" : "rTree", "rectracks_branchname" : "VtxTracks", "n_events" : -1, - "make_plain_tree" : false + "make_plain_tree" : true }, - "pid_mode" : 0, + "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) "decays" : [ { "mother" : { @@ -15,8 +17,7 @@ "LdL" : 5.0, "dist" : 1.0, "chi2geo" : 3.0 - }, - "save_options" : [] + } }, "daughters" : [ { diff --git a/at_interface/configs/config_lambda4.json b/at_interface/configs/config_lambda4.json new file mode 100644 index 0000000..da79e2f --- /dev/null +++ b/at_interface/configs/config_lambda4.json @@ -0,0 +1,34 @@ +//from parfile2_lambda_pidmode2.txt +//(Lambda pid 2) +{ + "io" : { + "input_treename" : "aTree", + "rectracks_branchname" : "RecParticles", + "n_events" : -1, + "make_plain_tree" : true + }, + "pid_mode" : 2, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "LdL" : 5.0, + "dist" : 1.0, + "chi2geo" : 3.0 + } + }, + "daughters" : [ + { + "pdg_codes" : [-211, -2], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [2212, 2], + "cuts" : {"chi2prim" : 18.42} + } + ] + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_omega.json b/at_interface/configs/config_omega.json index 31f6532..25b5ee8 100644 --- a/at_interface/configs/config_omega.json +++ b/at_interface/configs/config_omega.json @@ -3,7 +3,8 @@ "input_treename" : "rTree", "rectracks_branchname" : "VtxTracks", "n_events" : -1, - "make_plain_tree" : false + "write_detailed_bg" : true, + "make_plain_tree" : true }, "pid_mode" : 1, "decays" : [ @@ -12,21 +13,22 @@ "name" : "Lambda", "pdg_code" : 3122, "cuts" : { - "LdL" : 4.0, - "dist" : 0.15, - "chi2geo" : 11.0, - "chi2topo" : 29.0 + "LdL" : 10.0, + "dist" : 1.0, + "chi2geo" : 3.0, + "chi2topo" : 5.0, + "invmass" : 3.0 }, - "save_options" : [] + "save_options" : ["mass_constraint"] }, "daughters" : [ { - "pdg_codes" : [-211], - "cuts" : {"chi2prim" : 110} + "pdg_codes" : [-211, -1], + "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [2212], - "cuts" : {"chi2prim" : 26, "cos" : 0.99825} + "pdg_codes" : [2212, 1], + "cuts" : {"chi2prim" : 18.42} } ] }, diff --git a/at_interface/configs/config_omegastar.json b/at_interface/configs/config_omegastar.json index b800751..e993111 100644 --- a/at_interface/configs/config_omegastar.json +++ b/at_interface/configs/config_omegastar.json @@ -3,7 +3,8 @@ "input_treename" : "rTree", "rectracks_branchname" : "VtxTracks", "n_events" : -1, - "make_plain_tree" : false + "write_detailed_bg" : true, + "make_plain_tree" : true }, "pid_mode" : 1, "decays" : [ @@ -12,18 +13,21 @@ "name" : "Lambda", "pdg_code" : 3122, "cuts" : { - "LdL" : 5.0, + "LdL" : 10.0, "dist" : 1.0, - "chi2geo" : 3.0 - } + "chi2geo" : 3.0, + "chi2topo" : 5.0, + "invmass" : 3.0 + }, + "save_options" : ["mass_constraint"] }, "daughters" : [ { - "pdg_codes" : [-211], + "pdg_codes" : [-211, -1], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [2212], + "pdg_codes" : [2212, 1], "cuts" : {"chi2prim" : 18.42} } ] @@ -34,14 +38,16 @@ "pdg_code" : 3312, "cuts" : { "chi2topo" : 5.0, + "dist" : 1.0, "LdL" : 5.0, - "invmass" : 3, - "chi2geo" : 6.0 - } + "chi2geo" : 6.0, + "invmass" : 3.0 + }, + "save_options" : ["mass_constraint"] }, "daughters" : [ { - "pdg_codes" : [-211], + "pdg_codes" : [-211, -1], "cuts" : {"chi2prim" : 18.42} }, { @@ -53,12 +59,12 @@ "mother" : { "name" : "Omega*-", "pdg_code" : 1003334, + "mass" : 2.252, + "mass_sigma" : 0.055, "cuts" : { "dist" : 1.0, "chi2topo" : 1000.0, "LdL" : 5.0, - "mass" : 2.252, - "mass_sigma" : 0.055, "chi2geo" : 3.0 } }, diff --git a/at_interface/configs/config_xi.json b/at_interface/configs/config_xi.json index ca54d1c..227c82e 100644 --- a/at_interface/configs/config_xi.json +++ b/at_interface/configs/config_xi.json @@ -3,20 +3,23 @@ "input_treename" : "rTree", "rectracks_branchname" : "VtxTracks", "n_events" : -1, - "make_plain_tree" : false + "write_detailed_bg" : true, + "make_plain_tree" : true }, - "pid_mode" : 0, + "pid_mode" : 1, "decays" : [ { "mother" : { "name" : "Lambda", "pdg_code" : 3122, "cuts" : { - "LdL" : 5.0, + "LdL" : 10.0, "dist" : 1.0, - "chi2geo" : 3.0 + "chi2geo" : 3.0, + "chi2topo" : 5.0, + "invmass" : 3.0 }, - "save_options" : [] + "save_options" : ["mass_constraint"] }, "daughters" : [ { @@ -35,11 +38,11 @@ "pdg_code" : 3312, "cuts" : { "chi2topo" : 5.0, + "dist" : 1.0, "LdL" : 5.0, - "invmass" : 3, "chi2geo" : 6.0 }, - "save_options" : [] + "save_options" : ["transport_to_pv"] }, "daughters" : [ { diff --git a/at_interface/main_json.cpp b/at_interface/main_json.cpp index 5add216..bc8a7ba 100644 --- a/at_interface/main_json.cpp +++ b/at_interface/main_json.cpp @@ -19,6 +19,19 @@ using json = nlohmann::json; #define LIST_CONTAINS(list, value) std::find(list.begin(), list.end(), value) != list.end() void set_json_value(json& j, const std::string& path, const std::string& value); +nlohmann::json load_config(const std::string& filepath) { + std::ifstream file_stream(filepath); + if (!file_stream.is_open()) { + throw std::runtime_error("Failed to open file: " + filepath); + } + + try { + return nlohmann::json::parse(file_stream, nullptr, true, true); // last 'true' enables comment support + } catch (const nlohmann::json::parse_error& e) { + throw std::runtime_error("JSON parse error in file " + filepath + ": " + e.what()); + } +} + int main(int argc, char** argv) { std::string input_file; std::string config_file; @@ -28,9 +41,9 @@ int main(int argc, char** argv) { //Parse command line args static struct option long_options[] = { - {"output", required_argument, nullptr, 'o'}, + {"output", required_argument, nullptr, 'o'}, {"plain-output", required_argument, nullptr, 'p'}, - {"set", required_argument, nullptr, 's'}, + {"set", required_argument, nullptr, 's'}, {0, 0, 0, 0} }; @@ -66,13 +79,7 @@ int main(int argc, char** argv) { config_file = argv[optind + 1]; // Load config JSON file - json config; - std::ifstream cfg_file(config_file); - if (!cfg_file) { - std::cerr << "Cannot open config file: " << config_file << "\n"; - return 1; - } - cfg_file >> config; + json config = load_config(config_file); // Apply deferred overrides for (const auto& [key, value] : overrides) { @@ -97,7 +104,7 @@ int main(int argc, char** argv) { for (const auto& decay_cfg : config["decays"]) { printf("Configuring decay %s\n", decay_cfg["mother"]["name"].get().c_str()); - // + // Load daughters & cuts auto daughters_cfg = decay_cfg["daughters"]; std::vector daughters; for (const auto& daughter_cfg : daughters_cfg) { @@ -117,6 +124,7 @@ int main(int argc, char** argv) { } } + // Load mother auto mother_cfg = decay_cfg["mother"]; Mother mother(mother_cfg["pdg_code"]); mother.CancelCuts(); @@ -147,12 +155,13 @@ int main(int argc, char** argv) { if (combo_cuts.contains("costopo")) mother.SetCutCosTopoSM(combo_cuts["costopo"].get>()); } + // Construct decay and set save options Decay decay(mother_cfg["name"], mother, {daughters}); if (mother_cfg.contains("save_options")) { const auto& options = mother_cfg["save_options"]; - if (LIST_CONTAINS(options, "mass_constraint")) decay.SetIsApplyMassConstraint(); - if (LIST_CONTAINS(options, "transport_to_pv")) decay.SetIsTransportToPV(); + if (LIST_CONTAINS(options, "mass_constraint")) decay.SetIsApplyMassConstraint(); + if (LIST_CONTAINS(options, "transport_to_pv")) decay.SetIsTransportToPV(); if (LIST_CONTAINS(options, "do_not_write_mother")) decay.SetIsDoNotWriteMother(); } @@ -164,11 +173,12 @@ int main(int argc, char** argv) { auto pid_purity_cfg = config["pid_purity"]; in_converter->SetPidMode(pid_mode); - if (pid_purity_cfg.contains("default")) in_converter->SetPidPurity(pid_purity_cfg["default"]); - if (pid_purity_cfg.contains("protons")) in_converter->SetPidPurityProton(pid_purity_cfg["protons"]); - if (pid_purity_cfg.contains("pions")) in_converter->SetPidPurityPion(pid_purity_cfg["pions"]); - if (pid_purity_cfg.contains("kaons")) in_converter->SetPidPurityKaon(pid_purity_cfg["kaons"]); - if (pid_purity_cfg.contains("deuterons")) in_converter->SetPidPurityDeuteron(pid_purity_cfg["deuterons"]); + if (pid_purity_cfg.contains("default")) in_converter->SetPidPurity(pid_purity_cfg["default"]); + if (pid_purity_cfg.contains("protons")) in_converter->SetPidPurityProton(pid_purity_cfg["protons"]); + if (pid_purity_cfg.contains("pions")) in_converter->SetPidPurityPion(pid_purity_cfg["pions"]); + if (pid_purity_cfg.contains("kaons")) in_converter->SetPidPurityKaon(pid_purity_cfg["kaons"]); + if (pid_purity_cfg.contains("deuterons")) in_converter->SetPidPurityDeuteron(pid_purity_cfg["deuterons"]); + if (pid_purity_cfg.contains("background")) in_converter->SetPidPurityDeuteron(pid_purity_cfg["background"]); auto* pf_task = new PFSimpleTask(); pf_task->SetInTask(in_converter); @@ -194,29 +204,31 @@ int main(int argc, char** argv) { man->ClearTasks(); if (config["io"]["make_plain_tree"]) { - std::ofstream filelist; - filelist.open("filelist.txt"); - filelist << output_file; - filelist << "\n"; - filelist.close(); - - auto* tree_task = new PlainTreeFiller(); - tree_task->SetOutputName(plain_output_file, "plain_tree"); - std::string branchname_rec = "Candidates"; - tree_task->SetInputBranchNames({branchname_rec}); - tree_task->AddBranch(branchname_rec); - //tree_task->SetIsPrependLeavesWithBranchName(false); //Uncomment when most recent AnalysisTree is installed in cbmroot - - man->AddTask(tree_task); - - man->Init({"filelist.txt"}, {"pTree"}); - man->Run(config["io"]["n_events"]); - man->Finish(); + std::ofstream filelist; + filelist.open("filelist.txt"); + filelist << output_file; + filelist << "\n"; + filelist.close(); + + auto* tree_task = new PlainTreeFiller(); + tree_task->SetOutputName(plain_output_file, "plain_tree"); + std::string branchname_rec = "Candidates"; + tree_task->SetInputBranchNames({branchname_rec}); + tree_task->AddBranch(branchname_rec); + //tree_task->SetIsPrependLeavesWithBranchName(false); //Uncomment when most recent AnalysisTree is installed in cbmroot + + man->AddTask(tree_task); + + man->Init({"filelist.txt"}, {"pTree"}); + man->Run(config["io"]["n_events"]); + man->Finish(); } return 0; } + +/* Function to overide a value inside the json config, e.g. decays[0].mother.cuts.LdL=4.0 */ void set_json_value(json& config, const std::string& path, const std::string& value) { std::cout << "[DEBUG] Setting " << path << " to " << value << std::endl; @@ -270,6 +282,8 @@ void set_json_value(json& config, const std::string& path, const std::string& va try { if (value == "true" || value == "false") { target = (value == "true"); + } else if (value == "null") { + target = nlohmann::json(); } else if (value.find('.') != std::string::npos) { target = std::stod(value); } else { From e332eeab92e5f23a91598e62fc92771a4ad3936a Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Mon, 28 Apr 2025 13:35:00 +0200 Subject: [PATCH 06/21] Bugfix --- at_interface/main_json.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/at_interface/main_json.cpp b/at_interface/main_json.cpp index bc8a7ba..cc6f273 100644 --- a/at_interface/main_json.cpp +++ b/at_interface/main_json.cpp @@ -178,7 +178,7 @@ int main(int argc, char** argv) { if (pid_purity_cfg.contains("pions")) in_converter->SetPidPurityPion(pid_purity_cfg["pions"]); if (pid_purity_cfg.contains("kaons")) in_converter->SetPidPurityKaon(pid_purity_cfg["kaons"]); if (pid_purity_cfg.contains("deuterons")) in_converter->SetPidPurityDeuteron(pid_purity_cfg["deuterons"]); - if (pid_purity_cfg.contains("background")) in_converter->SetPidPurityDeuteron(pid_purity_cfg["background"]); + if (pid_purity_cfg.contains("background")) in_converter->SetPidPurityBG(pid_purity_cfg["background"]); auto* pf_task = new PFSimpleTask(); pf_task->SetInTask(in_converter); From 6a682c36a3d5bd652545816238d20bd9923b6f66 Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Mon, 28 Apr 2025 13:35:36 +0200 Subject: [PATCH 07/21] Update json configs --- at_interface/configs/config_H3L1.json | 4 +-- at_interface/configs/config_He5L.json | 43 ++++++++++++++++++++++++ at_interface/configs/config_lambda3.json | 2 +- at_interface/configs/config_lambda4.json | 4 +-- 4 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 at_interface/configs/config_He5L.json diff --git a/at_interface/configs/config_H3L1.json b/at_interface/configs/config_H3L1.json index 75857a5..b5f9fcf 100644 --- a/at_interface/configs/config_H3L1.json +++ b/at_interface/configs/config_H3L1.json @@ -2,8 +2,8 @@ //(H3L pid 1) { "io" : { - "input_treename" : "rTree", - "rectracks_branchname" : "VtxTracks", + "input_treename" : "pTree", + "rectracks_branchname" : "RecTracks", "n_events" : -1, "make_plain_tree" : true }, diff --git a/at_interface/configs/config_He5L.json b/at_interface/configs/config_He5L.json new file mode 100644 index 0000000..b2299eb --- /dev/null +++ b/at_interface/configs/config_He5L.json @@ -0,0 +1,43 @@ +//from parfile3_add.txt +//(H3L pid 1) +{ + "io" : { + "input_treename" : "pTree", + "rectracks_branchname" : "RecTracks", + "n_events" : -1, + "make_plain_tree" : true + }, + "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + "decays" : [ + { + "mother" : { + "name" : "He5L", + "pdg_code" : 3007, + "cuts" : { + "LdL" : 5.0, + "dist" : 1.0, + "chi2geo" : 6.0, + "chi2topo" : 5.0 + } + }, + "daughters" : [ + { + "pdg_codes" : [1000020040], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [-211], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [2212], + "cuts" : {"chi2prim" : 18.42} + } + ], + "daughter_combination_cuts" : { + "comment" : "daugher 1 & 2, daughter 1 & 3, daughter 2 & 3", + "chi2geo" : [3.0] + } + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_lambda3.json b/at_interface/configs/config_lambda3.json index c6f8797..aff655b 100644 --- a/at_interface/configs/config_lambda3.json +++ b/at_interface/configs/config_lambda3.json @@ -7,7 +7,7 @@ "n_events" : -1, "make_plain_tree" : true }, - "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + "pid_mode" : 0, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) "decays" : [ { "mother" : { diff --git a/at_interface/configs/config_lambda4.json b/at_interface/configs/config_lambda4.json index da79e2f..6acf55e 100644 --- a/at_interface/configs/config_lambda4.json +++ b/at_interface/configs/config_lambda4.json @@ -2,8 +2,8 @@ //(Lambda pid 2) { "io" : { - "input_treename" : "aTree", - "rectracks_branchname" : "RecParticles", + "input_treename" : "pTree", + "rectracks_branchname" : "RecTracks", "n_events" : -1, "make_plain_tree" : true }, From f2f8d6468fbac7a38e874f5204d3f80adecfe6cb Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Tue, 29 Apr 2025 16:09:10 +0200 Subject: [PATCH 08/21] Add AnalysisTree post cuts in JSON implementation --- at_interface/main_json.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/at_interface/main_json.cpp b/at_interface/main_json.cpp index cc6f273..fbd6fce 100644 --- a/at_interface/main_json.cpp +++ b/at_interface/main_json.cpp @@ -71,7 +71,7 @@ int main(int argc, char** argv) { } if (optind + 2 > argc) { - std::cerr << "Usage: " << argv[0] << " input.root config.json [--output file] [--plain-output file] [--set key=value]\n"; + std::cerr << "Usage: " << argv[0] << " filelist.txt config.json [--output file] [--plain-output file] [--set key=value]\n"; return 1; } @@ -192,6 +192,19 @@ int main(int argc, char** argv) { out_converter->SetPFSimpleTask(pf_task); out_converter->SetDecays(decays); if (config["io"].contains("write_detailed_bg")) out_converter->SetIsWriteDetailedBG(config["io"]["write_detailed_bg"]); + + if (config.contains("output_cuts")) + { + std::vector vec_output_cuts = {}; + for (const auto& cut_cfg : config["output_cuts"]) { + if (cut_cfg.contains("equal")) + vec_output_cuts.push_back(AnalysisTree::EqualsCut("Candidates." + cut_cfg["var"].get(), cut_cfg["equal"])); + else if (cut_cfg.contains("from")) + vec_output_cuts.push_back(AnalysisTree::RangeCut("Candidates." + cut_cfg["var"].get(), cut_cfg["from"], cut_cfg["to"])); + } + AnalysisTree::Cuts* output_cuts = new AnalysisTree::Cuts("output_cuts", vec_output_cuts); + out_converter->SetOutputCuts(output_cuts); + } man->AddTask(in_converter); man->AddTask(pf_task); From 042fa9a3da6de3ff96c641c65c64280a003d6061 Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Tue, 29 Apr 2025 16:09:25 +0200 Subject: [PATCH 09/21] Update readme --- README.md | 259 ++++++++++++++++++++++++++---------------------------- 1 file changed, 126 insertions(+), 133 deletions(-) diff --git a/README.md b/README.md index 8b79af5..4190ff0 100644 --- a/README.md +++ b/README.md @@ -27,163 +27,156 @@ AnalysisTree with c++17 standard is strongly recommended. Clone PFSimple Source ROOT - - source /path-to-root/install/bin/thisroot.sh - +``` +source /path-to-root/install/bin/thisroot.sh +``` To use pre-installed AnalysisTree set the environment variable: - export AnalysisTree_DIR=/path-to-analysistree/install/lib/cmake/AnalysisTree +``` +export AnalysisTree_DIR=/path-to-analysistree/install/lib/cmake/AnalysisTree +``` To build AnalysisTree automatically together with PFSimple use following cmake keys: - -DPFSimple_BUNDLED_AT=ON - -DPFSimple_BUNDLED_AT_VERSION=v2.3.4 +``` +-DPFSimple_BUNDLED_AT=ON +-DPFSimple_BUNDLED_AT_VERSION=v2.3.4 +``` You need to source root and export AnalysisTree each time when you are compiling project from 0 (perform cmake command) but have no need to do it when just recompiling project (perform just make). Install PFSimple - - mkdir build - cd build - cmake -DCMAKE_INSTALL_PREFIX=/path-to-install-pfsimple /path-to-source-pfsimple - make -j install - +``` +mkdir build +cd build +cmake -DCMAKE_INSTALL_PREFIX=/path-to-install-pfsimple /path-to-source-pfsimple +make -j install +``` ## Configuration of decay settings -The reconstruction will be executed with at_interface/main.cpp. - -The reconstruction can be configured with the parameter-files -at_interface/parfile2.txt for 2-body decays and at_interface/parfile3.txt for 3-body decays. - -The user can select: -1) Decay: mother and daughters - - Pdg mass and pdg mass sigma for mother: if set to "-1" values from - KFParticleDatabase are taken - - Option for daughters: alternative pdgs can be used in addition - for the reconstruction - - for background: set to "1" / "-1" for pos / neg daughters - - for tracks without TOF id: set to "2" / "-2" for pos / neg - daughters (in pid-mode 2, 3, 4) - - In pid-mode 0 optional daughers "1" / "-1" for pos / neg pdgs must be added. - - If no alternative pdgs should be used, set to "0". - - If more optional pdgs than 2 should be added, change in main2.cpp / - main3.cpp and recompile. - -2) Geometrical cuts to be applied and cut-values - - If a cut should not be used, set to "-1". - - For more information on specific cuts see " Constants.hpp". - -3) Options for the saving of the reconstructed mother - - - A nonlinear mass constraint can be applied on the mother particle which modifies the mother's state vector and covariance matrix to - assure the 4-momentum is consitent with the pdg mass. - - - The mother can be transported to the PV. - - - The writing out of the mother into the output-file (e.g. the lower-level mother in cascade decays) can get surpressed. But - if this option is selected, it is not possible to peform the MC-matching for the upper-level mother. - -4) Pid-method: - - - 0: no pid (only charge information is used ! optional daughers must - be set to "1" / "-1" for pos / neg pdgs !) - - - 1: mc-pid - - - 2: reconstructed TOF pid - default from Pid-framework - - - 3: reconstructed TOF pid - pdg with max. pdg-purity is selected, if pdg-purity >min. purity - - - 4: reconstructed TOF pid - pdg is selected, if pdg-purity > min. purity (pdg-specfic purities are possible) - - for 2-4: Pid-framework needs to be applied first to include TOF-pid & probabilities into the analysistree input-file - -5) Minium purities for pid-mode 3 & 4: - - for pid-mode 3: minimum purity is set for all pdgs (pdg-spefic purities - need to be set to "-1") - - for pid-mode 4: minimum purity can be set for all pdgs or specifically - for every pdg (general purity will be overwritten, if pdg-specific - purity is not set to "-1") - -6) Input/Output information: - - treename in input aTree, default names: "rTree" for standard aTree, - "aTree" after running Pid-framework - - branchname of reconstructed tracks in input analysistree, default names: "VtxTracks" - for standard analyistree, "RecParticles" after running Pid-framework - - optional detailed background information in output variable "generation": - format for bg for 2-body-decay: -m12 0 d2 d1 - format for bg for 3-body-decay: -m13 m23 m12 d3 d2 d1 - with m12: mother of daughter 1 & 2 etc. - code for daughters (d): - 1 - reco daughter is unmatched to mc - 2 - reco daughter is matched, but primary - 3 - reco daughter is secondary, produced not in decay from mother with not expected pdg - 4 - reco daughter is secondary, produced not in decay from mother with expected pdg - 5 - reco daughter is secondary, produced in decay from mother with not expected pdg - 6 - reco daughter is secondary, produced in decay from mother with expected pdg - code for mothers (m): - 1 - daughters have the same mother - 2 - daughters have different mothers - 0 - at least one daughter does not have mother (e.g. primary) - - If detailed background is not selected or if mc match for mother is found, value of variable "generation" is: - 0 - no mc match for mother - 1 - mother is primary particle - 2 - mother is second generation etc. - - - number of events to be processed (-1 = all events) - - Output format: default output is analysistree format - optional: plain tree: output is a simple root tree containing the candidates - -### 3-body-decays +The reconstruction will be executed with ```at_interface/main_json filelist.txt config.json [--output ] [--plain-output ] [--set =]```. The binary accepts 2 positional arguments: The path of the input filelist.txt file and the config file in JSON format. It is also possible to modify the output file paths with the `--output` and `--plain-output` optional arguments as well as to override keys in the JSON config file by adding keys like `--set decays[0].mother.cuts.LdL=4.0`. + +The config file contains various settings related to input and output as well as the decays to reconstruct. In the following, the different blocks are explained. + +### io block +| Key | Description | +| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `input_treename` | Name of the input AnalysisTree (normally `rTree`, after running PID framework `pTree`) | +| `rectracks_branchname` | branchname of reconstructed tracks in input analysistree, default names: `VtxTracks` for standard analyistree, `RecParticles` after running Pid-framework | +| `n_events` | Number of events to be processed, set to `-1` to process all events | +| `make_plain_tree` | Set to `true` to output a normal root tree containing the candidates (besides the default output tree in AnalysisTree format) | +| `write_detailed_bg` (optional) | optional detailed background information in output variable `generation` (see below) | + +The format of the detailed background information in the `generation` variable is as follows: +format for bg for 2-body-decay: -m12 0 d2 d1 +format for bg for 3-body-decay: -m13 m23 m12 d3 d2 d1 +with m12: mother of daughter 1 & 2 etc. +code for daughters (d): +1 - reco daughter is unmatched to mc +2 - reco daughter is matched, but primary +3 - reco daughter is secondary, produced not in decay from mother with not expected pdg +4 - reco daughter is secondary, produced not in decay from mother with expected pdg +5 - reco daughter is secondary, produced in decay from mother with not expected pdg +6 - reco daughter is secondary, produced in decay from mother with expected pdg +code for mothers (m): +1 - daughters have the same mother +2 - daughters have different mothers +0 - at least one daughter does not have mother (e.g. primary) + +If detailed background is not selected or if mc match for mother is found, value of variable "generation" is: +0 - no mc match for mother +1 - mother is primary particle +2 - mother is second generation etc. + +### pid mode +The method for particle identification is configured in the `pid_mode` variable and can be one of the following ones: +| `pid_mode` | Description | +| ---------- | -------------------------------------------------------------------------------------------------------- | +| `0` | mc-pid | +| `1` | reconstructed TOF pid - default from Pid-framework | +| `2` | reconstructed TOF pid - pdg with max. pdg-purity is selected, if pdg-purity >min. purity | +| `3` | reconstructed TOF pid - pdg is selected, if pdg-purity > min. purity (pdg-specfic purities are possible) | +| `4` | reconstructed TOF pid - pdg is selected, if pdg-purity > min. purity (pdg-specfic purities are possible) | + +for 2-4: Pid-framework needs to be applied first to include TOF-pid & probabilities into the analysistree input-file + +### pid_purity block +This block is fully optional and defines the minium purities for pid-mode 3 & 4: + - for pid-mode 3: minimum purity is set for all pdgs (pdg-spefic purities need to be omitted) + - for pid-mode 4: minimum purity can be set for all pdgs or specifically for every pdg (general purity will be overwritten, if pdg-specific purity is given) + +### decays block +The decay block contains the specific decays PFSimple shall reconstruct. Each decay is defined by several sub-blocks: + +#### mother block +The mother block must contain the fields `pdg_code` and `name` (chosen by user). You can optionally set the keys `mass` (Unit: GeV/c^2) and `mass_sigma` to be used when calculating mass decrepancies or setting nonlinear mass constrains, otherwise values from KFParticleDatabase are taken. +It is possible to define several cuts to be applied to the mother particle in the `cuts` subblock: +| Field | Function | +| ------------ | -------------------------------------------------- | +| `dist` | `mother.SetCutDistance(cuts["dist"]);` | +| `distSV` | `mother.SetCutDistanceToSV(cuts["distSV"]);` | +| `chi2geo` | `mother.SetCutChi2Geo(cuts["chi2geo"]);` | +| `cosopen` | `mother.SetCutCosOpen(cuts["cosopen"]);` | +| `chi2topo` | `mother.SetCutChi2Topo(cuts["chi2topo"]);` | +| `costopo` | `mother.SetCutCosTopo(cuts["costopo"]);` | +| `LdL` | `mother.SetCutLdL(cuts["LdL"]);` | +| `L` | `mother.SetCutDecayLength(cuts["L"]);` | +| `distPVline` | `mother.SetCutDistancePVLine(cuts["distPVline"]);` | +| `invmass` | `mother.SetCutInvMass(cuts["invmass"]);` | + +Cuts which shall not be applied you can just delete or comment out. For more information on specific cuts see `Constants.hpp`. + +#### daughters block +The daughters block is a list consisting of 2 to 3 subblocks, each defining a daugher particle of the mother. It is required to give a list of PDG codes to be considered as possible daughter candidates of the decay in the `pdg_codes` field. This is normally the official PDG code of the daugher and in some cases an additional code: +- for background: set to "1" / "-1" for pos / neg daughters +- for tracks without TOF id: set to "2" / "-2" for pos / neg daughters (in pid-mode 2, 3, 4) +- In pid-mode 0 optional daughers "1" / "-1" for pos / neg pdgs must be added + +Analogously to the mother you can also apply cuts for the daughters in the `cuts` subblock (`chi2prim` and `cos`). + +#### daughter_combination_cuts block (3-body-decays) For 3-body decays, the list of available cuts is extended, amoung others, to cuts on the secondary mothers (SM) of combinations of 2 daughters. E.g. for H3L->p + pi + d, cuts on the SM of p-pi can be applied. The cuts that test the mother against the PV, e.g. chi2topo, are inverted for -the SM to exclude SMs that come from the PV. +the SM to exclude SMs that come from the PV. They are defined in the optional `daughter_combination_cuts` subblock of the decay, which can contain for each of the 4 possible variables `chi2geo`, `cosopen`, `chi2topo` and `costopo` a list with up to 3 entries. The entries respectively reflect the cuts to be applied between daugher 1 & 2, daughter 1 & 3 and daughter 2 & 3. -### Multiple decays -If more than one decay should be reconstructed in the same run, additional -parfiles at_interface/parfile2_add.txt or at_interface/parfile3_add.txt can be added -where 1.) - 3.) can be selected. 4.) - 6.) can not be changed in the same run. The -decays can be independent or build a cascade decay. Multiple additional -parfiles can be added. +#### save_options block +The optional `save_options` block can contain specific string values which enable features related to the saving of the reconstructed mother: +| Flag | Description | +| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `mass_constraint` | A nonlinear mass constraint can be applied on the mother particle which modifies the mother's state vector and covariance matrix to assure the 4-momentum is consitent with the pdg mass. | +| `transport_to_pv` | The mother is transported to the PV before saving | +| `do_not_write_mother` | The writing of the mother into the output-file (e.g. the lower-level mother in cascade decays) can get surpressed. But if this option is selected, it is not possible to peform the MC-matching for the upper-level mother. | ### Cascade decays The reconstruction of a cascade decay works the same way as adding an additional decay -to the run as described above. The order of the parfiles need to be from last generation to +to the run as described above. The order of the decays need to be from last generation to first generation. Cascade decays with multiple stages as well as combinations of 2- and 3-body-decays can get reconstructed. -Several example parameter files can be found in the folder at_interface/example_parfiles. - -## First run - -Each time before running the prepared executable you should set the environment variables to let your system know where to find libraries: - - source /path-to-root/install/bin/thisroot.sh - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path-to-pfsimple-installation/lib/ - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path-to-pfsimple-installation/external/lib/ - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path-to-analysistree-installation/lib/ - -Then run the executable: +Several example parameter files can be found in the folder `at_interface/configs`. - ./main filelist.txt dataset parfile2.txt (parfile2_add.txt parfile3_add.txt) +### output_cuts block +The optional `output_cuts` block contains AnalysisTree field cuts to be applied to the output candidates before storing them to disk. It is possible to either impose an `EqualsCut` or a `RangeCut`, depending on the given fields in the block. To save only signal candidates one can e.g. write +```json + "output_cuts" : [ + {"var" : "generation", "from" : 0.9, "to" : 1000} + ] +``` +If instead of `from` and `to` fields a field named `equal` would be given, an `EqualsCut` would be used. It is possible to chain as many cuts as you want. -or - - ./main filelist.txt dataset parfile3.txt (parfile2_add.txt parfile3_add.txt) - -where filelist.txt must be a text file with names (including paths) to +## filelist.txt +filelist.txt must be a text file with names (including paths) to AnalysisTree files which you want to analyze with PFSimple. Each file name should be on the next line, and the last symbol should also be a switch to next line. The example of filelist is in the source directory of PFSimple (filelist_example.txt) -and where [dataset] specifies the names of the outputfiles: -- analyistree: [dataset].PFSimpleOutput.root -- plain tree: [dataset].PFSimplePlainTree.root +## First run +Each time before running the prepared executable you should set the environment variables to let your system know where to find libraries: +``` +source /path-to-root/install/bin/thisroot.sh +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path-to-pfsimple-installation/lib/ +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path-to-pfsimple-installation/external/lib/ +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path-to-analysistree-installation/lib/ #can be ommitted if PFSimple_BUNDLED_AT was set to ON +``` +Then run the executable as described above. From 74af5b372680dad799a610c59df418316babfc28 Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Wed, 14 May 2025 11:09:39 +0200 Subject: [PATCH 10/21] Addes Susannes corrections for Readme --- README.md | 112 +++++++++--------- at_interface/configs/config_H3L1.json | 4 +- at_interface/configs/config_H3L2.json | 4 +- at_interface/configs/config_He5L.json | 4 +- .../configs/config_antilambda_ml.json | 32 +++++ at_interface/configs/config_lambda_ml.json | 32 +++++ at_interface/configs/config_omegastar.json | 4 +- at_interface/main_json.cpp | 4 +- 8 files changed, 128 insertions(+), 68 deletions(-) create mode 100644 at_interface/configs/config_antilambda_ml.json create mode 100644 at_interface/configs/config_lambda_ml.json diff --git a/README.md b/README.md index 4190ff0..365466c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## General information -The Paticle Finder Simple package is simplified version of the KF Partice package based on its mathematical apparatus. It is developed for the complete reconstruction of short-lived particles with their momentum, energy, mass, lifetime, decaylength, rapidity, etc. +The Paticle Finder Simple package is simplified version of the KF Partice package based on its mathematical apparatus. It is developed for the complete reconstruction of short-lived particles with their momentum, energy, mass, lifetime, decaylength, rapidity, etc. 2- and 3-body decays can get reconstructed. It is also possible to reconstruct multiple decays in one run as well as cascade decays. ## Requirements @@ -50,15 +50,12 @@ cmake -DCMAKE_INSTALL_PREFIX=/path-to-install-pfsimple /path-to-source-pfsimple make -j install ``` ## Configuration of decay settings +The program is configured with a JSON config file which contains various settings related to input and output as well as the decays to reconstruct. In the following, the different blocks are explained. -The reconstruction will be executed with ```at_interface/main_json filelist.txt config.json [--output ] [--plain-output ] [--set =]```. The binary accepts 2 positional arguments: The path of the input filelist.txt file and the config file in JSON format. It is also possible to modify the output file paths with the `--output` and `--plain-output` optional arguments as well as to override keys in the JSON config file by adding keys like `--set decays[0].mother.cuts.LdL=4.0`. - -The config file contains various settings related to input and output as well as the decays to reconstruct. In the following, the different blocks are explained. - -### io block +### io | Key | Description | | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `input_treename` | Name of the input AnalysisTree (normally `rTree`, after running PID framework `pTree`) | +| `input_treename` | Name of the input AnalysisTree (for standard analysistree `rTree`, after running PID framework `pTree`) | | `rectracks_branchname` | branchname of reconstructed tracks in input analysistree, default names: `VtxTracks` for standard analyistree, `RecParticles` after running Pid-framework | | `n_events` | Number of events to be processed, set to `-1` to process all events | | `make_plain_tree` | Set to `true` to output a normal root tree containing the candidates (besides the default output tree in AnalysisTree format) | @@ -85,60 +82,42 @@ If detailed background is not selected or if mc match for mother is found, value 1 - mother is primary particle 2 - mother is second generation etc. -### pid mode +### pid_mode The method for particle identification is configured in the `pid_mode` variable and can be one of the following ones: | `pid_mode` | Description | | ---------- | -------------------------------------------------------------------------------------------------------- | -| `0` | mc-pid | -| `1` | reconstructed TOF pid - default from Pid-framework | -| `2` | reconstructed TOF pid - pdg with max. pdg-purity is selected, if pdg-purity >min. purity | -| `3` | reconstructed TOF pid - pdg is selected, if pdg-purity > min. purity (pdg-specfic purities are possible) | +| `0` | no pid (only charge information is used! optional daughers must be set to 1 / -1 for pos / neg pdgs!) | +| `1` | mc-pid | +| `2` | reconstructed TOF pid - default from Pid-framework | +| `3` | reconstructed TOF pid - pdg with max. pdg-purity is selected, if pdg-purity >min. purity | | `4` | reconstructed TOF pid - pdg is selected, if pdg-purity > min. purity (pdg-specfic purities are possible) | -for 2-4: Pid-framework needs to be applied first to include TOF-pid & probabilities into the analysistree input-file +**for 2-4: Pid-framework needs to be applied first to include TOF-pid & probabilities into the analysistree input-file** -### pid_purity block -This block is fully optional and defines the minium purities for pid-mode 3 & 4: +### pid_purity +This block is required in pid-mode 3 & 4 and defines the minium purities to be used: - for pid-mode 3: minimum purity is set for all pdgs (pdg-spefic purities need to be omitted) - for pid-mode 4: minimum purity can be set for all pdgs or specifically for every pdg (general purity will be overwritten, if pdg-specific purity is given) -### decays block +### decays The decay block contains the specific decays PFSimple shall reconstruct. Each decay is defined by several sub-blocks: -#### mother block +#### mother The mother block must contain the fields `pdg_code` and `name` (chosen by user). You can optionally set the keys `mass` (Unit: GeV/c^2) and `mass_sigma` to be used when calculating mass decrepancies or setting nonlinear mass constrains, otherwise values from KFParticleDatabase are taken. -It is possible to define several cuts to be applied to the mother particle in the `cuts` subblock: -| Field | Function | -| ------------ | -------------------------------------------------- | -| `dist` | `mother.SetCutDistance(cuts["dist"]);` | -| `distSV` | `mother.SetCutDistanceToSV(cuts["distSV"]);` | -| `chi2geo` | `mother.SetCutChi2Geo(cuts["chi2geo"]);` | -| `cosopen` | `mother.SetCutCosOpen(cuts["cosopen"]);` | -| `chi2topo` | `mother.SetCutChi2Topo(cuts["chi2topo"]);` | -| `costopo` | `mother.SetCutCosTopo(cuts["costopo"]);` | -| `LdL` | `mother.SetCutLdL(cuts["LdL"]);` | -| `L` | `mother.SetCutDecayLength(cuts["L"]);` | -| `distPVline` | `mother.SetCutDistancePVLine(cuts["distPVline"]);` | -| `invmass` | `mother.SetCutInvMass(cuts["invmass"]);` | - -Cuts which shall not be applied you can just delete or comment out. For more information on specific cuts see `Constants.hpp`. - -#### daughters block -The daughters block is a list consisting of 2 to 3 subblocks, each defining a daugher particle of the mother. It is required to give a list of PDG codes to be considered as possible daughter candidates of the decay in the `pdg_codes` field. This is normally the official PDG code of the daugher and in some cases an additional code: +It is possible to define several cuts to be applied to the mother particle in the `cuts` subblock by using the fields `dist`, `distSV` (3-body decays only), `chi2geo`, `cosopen`, `chi2topo`, `costopo`, `LdL`, `L`, `distPVline` and `invmass`. Cuts which shall not be applied you can just delete or comment out. For more information on specific cuts see `Constants.hpp`. + +#### daughters +The daughters block is a list consisting of 2 to 3 subblocks, each defining a daugher particle of the mother. It is required to give a JSON list in the `pdg_codes` field which contains the of PDG codes to be considered as possible daughter candidates of the decay in the. Optionally, alternative pdgs can be considered or further options can be selected for the reconstruction: - for background: set to "1" / "-1" for pos / neg daughters - for tracks without TOF id: set to "2" / "-2" for pos / neg daughters (in pid-mode 2, 3, 4) - In pid-mode 0 optional daughers "1" / "-1" for pos / neg pdgs must be added Analogously to the mother you can also apply cuts for the daughters in the `cuts` subblock (`chi2prim` and `cos`). -#### daughter_combination_cuts block (3-body-decays) -For 3-body decays, the list of available cuts is extended, amoung others, to cuts -on the secondary mothers (SM) of combinations of 2 daughters. E.g. for -H3L->p + pi + d, cuts on the SM of p-pi can be applied. The cuts -that test the mother against the PV, e.g. chi2topo, are inverted for -the SM to exclude SMs that come from the PV. They are defined in the optional `daughter_combination_cuts` subblock of the decay, which can contain for each of the 4 possible variables `chi2geo`, `cosopen`, `chi2topo` and `costopo` a list with up to 3 entries. The entries respectively reflect the cuts to be applied between daugher 1 & 2, daughter 1 & 3 and daughter 2 & 3. +#### daughter_combination_cuts (3-body-decays) +For 3-body decays, the list of available cuts is extended, amoung others, to cuts on the secondary mothers (SM) of combinations of 2 daughters. E.g. for H3L->p + pi + d, cuts on the SM of p-pi can be applied. The cuts that test the mother against the PV, e.g. chi2topo, are inverted for the SM to exclude SMs that come from the PV. They are defined in the optional `secondary_mother_cuts` block of the decay, which can contain for each of the 4 possible variables `chi2geo`, `cosopen`, `chi2topo` and `costopo` a list with up to 3 entries. The entries respectively reflect the cuts to be applied on the secondary mothers of daughter combinations 1 & 2, 1 & 3 and 2 & 3. -#### save_options block +#### save_options The optional `save_options` block can contain specific string values which enable features related to the saving of the reconstructed mother: | Flag | Description | | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -146,6 +125,9 @@ The optional `save_options` block can contain specific string values which enabl | `transport_to_pv` | The mother is transported to the PV before saving | | `do_not_write_mother` | The writing of the mother into the output-file (e.g. the lower-level mother in cascade decays) can get surpressed. But if this option is selected, it is not possible to peform the MC-matching for the upper-level mother. | +### output_cuts +The optional `output_cuts` block contains AnalysisTree field cuts to be applied to the output candidates before storing them to disk. One can either select a certain range for a cut variable with `from` and `to` or select a specific value with `equal`. It is possible to chain as many cuts as you want. + ### Cascade decays The reconstruction of a cascade decay works the same way as adding an additional decay to the run as described above. The order of the decays need to be from last generation to @@ -154,24 +136,26 @@ first generation. Cascade decays with multiple stages as well as combinations of Several example parameter files can be found in the folder `at_interface/configs`. -### output_cuts block -The optional `output_cuts` block contains AnalysisTree field cuts to be applied to the output candidates before storing them to disk. It is possible to either impose an `EqualsCut` or a `RangeCut`, depending on the given fields in the block. To save only signal candidates one can e.g. write -```json - "output_cuts" : [ - {"var" : "generation", "from" : 0.9, "to" : 1000} - ] -``` -If instead of `from` and `to` fields a field named `equal` would be given, an `EqualsCut` would be used. It is possible to chain as many cuts as you want. +## Example Configs +In the `at_interface/configs` directory are some example configs which have the following purpose: +| File | Description | +|---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| config_lambda1.json | Reconstructs Lambda with MC-PID mode (mode 1) using KFParticle cuts | +| config_lambda2.json | Reconstructs Lambda with MC-PID mode (mode 1) using cuts optimized by O. Lubynets | +| config_lambda3.json | Reconstructs Lambda without PID (mode 0) | +| config_lambda4.json | Reconstructs Lambda with the PID frameworks default PID mode (mode 2) | +| config_lambda_ml.json | Reconstructs Lambda with very loose cuts needed for machine learning applications, saves only mc-true signal candidates using `save_options` block | +| config_antilambda_ml.json | Reconstructs Anti-Lambda with very loose cuts needed for machine learning applications, saves only mc-true signal candidates using `save_options` block | +| config_H3L1.json | Reconstructs H3L with MC-PID mode (mode 1), example for 3-body decay and secondary mother cuts | +| config_H3L2.json | Reconstructs H3L with PID mode 4, shows application of minimum purities | +| config_He5L.json | Reconstructs He5L with MC-PID mode (mode 1), example for 3-body decay and secondary mother cuts | +| config_xi.json | Reconstructs Xi and Lambda with MC-PID mode (mode 1), basic example for the the cascade decay feature | +| config_omega.json | Reconstructs Omega and Lambda with MC-PID mode (mode 1), basic example for the the cascade decay feature | +| config_omegastar.json | Reconstructs Omega*, Xi and Lambda with MC-PID mode (mode 1), advanced example for the the cascade decay feature including a 3-body decay and secondary mother cuts | -## filelist.txt -filelist.txt must be a text file with names (including paths) to AnalysisTree -files which you want to analyze with PFSimple. Each file name should -be on the next line, and the last symbol should also be a switch to -next line. The example of filelist is in the source directory of -PFSimple (filelist_example.txt) -## First run +## First run Each time before running the prepared executable you should set the environment variables to let your system know where to find libraries: ``` source /path-to-root/install/bin/thisroot.sh @@ -179,4 +163,16 @@ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path-to-pfsimple-installation/lib/ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path-to-pfsimple-installation/external/lib/ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path-to-analysistree-installation/lib/ #can be ommitted if PFSimple_BUNDLED_AT was set to ON ``` -Then run the executable as described above. + +The reconstruction will be executed with the following command: +``` +at_interface/main_json filelist.txt config.json [--output ] [--plain-output ] [--set =] +``` +The binary accepts 2 positional arguments: The path of the input filelist.txt file and the config file in JSON format. It is also possible to modify the output file paths with the `--output` and `--plain-output` optional arguments as well as to override keys in the JSON config file by adding keys like `--set decays[0].mother.cuts.LdL=4.0`. + +### filelist.txt +filelist.txt must be a text file with names (including paths) to AnalysisTree +files which you want to analyze with PFSimple. Each file name should +be on the next line, and the last symbol should also be a switch to +next line. The example of filelist is in the source directory of +PFSimple (filelist_example.txt) \ No newline at end of file diff --git a/at_interface/configs/config_H3L1.json b/at_interface/configs/config_H3L1.json index b5f9fcf..115ec88 100644 --- a/at_interface/configs/config_H3L1.json +++ b/at_interface/configs/config_H3L1.json @@ -33,8 +33,8 @@ "cuts" : {"chi2prim" : 10.0} } ], - "daughter_combination_cuts" : { - "comment" : "daugher 1 & 2, daughter 1 & 3, daughter 2 & 3", + "secondary_mother_cuts" : { + // daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 "chi2geo" : [3.0], "chi2topo" : [2.0] } diff --git a/at_interface/configs/config_H3L2.json b/at_interface/configs/config_H3L2.json index 27db93c..04f0870 100644 --- a/at_interface/configs/config_H3L2.json +++ b/at_interface/configs/config_H3L2.json @@ -41,8 +41,8 @@ "cuts" : {"chi2prim" : 10.0} } ], - "daughter_combination_cuts" : { - "comment" : "daugher 1 & 2, daughter 1 & 3, daughter 2 & 3", + "secondary_mother_cuts" : { + // daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 "chi2geo" : [3.0], "chi2topo" : [2.0] } diff --git a/at_interface/configs/config_He5L.json b/at_interface/configs/config_He5L.json index b2299eb..7a42aeb 100644 --- a/at_interface/configs/config_He5L.json +++ b/at_interface/configs/config_He5L.json @@ -34,8 +34,8 @@ "cuts" : {"chi2prim" : 18.42} } ], - "daughter_combination_cuts" : { - "comment" : "daugher 1 & 2, daughter 1 & 3, daughter 2 & 3", + "secondary_mother_cuts" : { + // daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 "chi2geo" : [3.0] } } diff --git a/at_interface/configs/config_antilambda_ml.json b/at_interface/configs/config_antilambda_ml.json new file mode 100644 index 0000000..3133daa --- /dev/null +++ b/at_interface/configs/config_antilambda_ml.json @@ -0,0 +1,32 @@ +{ + "io" : { + "input_treename" : "rTree", + "rectracks_branchname" : "VtxTracks", + "n_events" : -1, + "make_plain_tree" : false + }, + "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + "decays" : [ + { + "mother" : { + "name" : "Anti-Lambda", + "pdg_code" : -3122, + "cuts" : { + "dist" : 100.0, + "chi2geo" : 1000.0 + } + }, + "daughters" : [ + { + "pdg_codes" : [211] + }, + { + "pdg_codes" : [-2212] + } + ] + } + ], + "output_cuts" : [ + {"var" : "generation", "from" : 0.9, "to" : 1000} + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_lambda_ml.json b/at_interface/configs/config_lambda_ml.json new file mode 100644 index 0000000..c46e44f --- /dev/null +++ b/at_interface/configs/config_lambda_ml.json @@ -0,0 +1,32 @@ +{ + "io" : { + "input_treename" : "rTree", + "rectracks_branchname" : "VtxTracks", + "n_events" : -1, + "make_plain_tree" : false + }, + "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "dist" : 100.0, + "chi2geo" : 1000.0 + } + }, + "daughters" : [ + { + "pdg_codes" : [-211] + }, + { + "pdg_codes" : [2212] + } + ] + } + ], + "output_cuts" : [ + {"var" : "generation", "from" : 0.9, "to" : 1000} + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_omegastar.json b/at_interface/configs/config_omegastar.json index e993111..fe40ff9 100644 --- a/at_interface/configs/config_omegastar.json +++ b/at_interface/configs/config_omegastar.json @@ -82,8 +82,8 @@ "cuts" : {"chi2prim" : 18.42} } ], - "daughter_combination_cuts" : { - "comment" : "daugher 1 & 2, daughter 1 & 3, daughter 2 & 3", + "secondary_mother_cuts" : { + //daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 "chi2geo" : [3.0] } } diff --git a/at_interface/main_json.cpp b/at_interface/main_json.cpp index fbd6fce..0862bcb 100644 --- a/at_interface/main_json.cpp +++ b/at_interface/main_json.cpp @@ -146,8 +146,8 @@ int main(int argc, char** argv) { } // Secondary mother cuts (SM) - if (decay_cfg.contains("daughter_combination_cuts")) { - auto combo_cuts = decay_cfg["daughter_combination_cuts"]; + if (decay_cfg.contains("secondary_mother_cuts")) { + auto combo_cuts = decay_cfg["secondary_mother_cuts"]; if (combo_cuts.contains("chi2geo")) mother.SetCutChi2GeoSM(combo_cuts["chi2geo"].get>()); if (combo_cuts.contains("cosopen")) mother.SetCutCosOpenSM(combo_cuts["cosopen"].get>()); From 6b3b3f63801b67c4eacdafd51a33ecfa363d470e Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Thu, 15 May 2025 18:05:38 +0200 Subject: [PATCH 11/21] Incorporate changes from zoom-session with Susanne --- README.md | 35 ++++--- at_interface/configs/config_H3L_pidmode1.json | 41 +++++++++ at_interface/configs/config_H3L_pidmode4.json | 49 ++++++++++ .../configs/config_He5L_pidmode1.json | 43 +++++++++ at_interface/configs/config_dummy.json | 59 ++++++++++++ .../configs/config_lambda_pidmode0.json | 32 +++++++ .../configs/config_lambda_pidmode1_v1.json | 34 +++++++ .../configs/config_lambda_pidmode1_v2.json | 34 +++++++ ...ml.json => config_lambda_pidmode1_v3.json} | 8 +- .../configs/config_lambda_pidmode2.json | 32 +++++++ .../configs/config_omega_pidmode1.json | 58 ++++++++++++ .../configs/config_omegastar_pidmode1.json | 91 +++++++++++++++++++ at_interface/configs/config_xi_pidmode1.json | 58 ++++++++++++ at_interface/main_json.cpp | 2 +- 14 files changed, 553 insertions(+), 23 deletions(-) create mode 100644 at_interface/configs/config_H3L_pidmode1.json create mode 100644 at_interface/configs/config_H3L_pidmode4.json create mode 100644 at_interface/configs/config_He5L_pidmode1.json create mode 100644 at_interface/configs/config_dummy.json create mode 100644 at_interface/configs/config_lambda_pidmode0.json create mode 100644 at_interface/configs/config_lambda_pidmode1_v1.json create mode 100644 at_interface/configs/config_lambda_pidmode1_v2.json rename at_interface/configs/{config_antilambda_ml.json => config_lambda_pidmode1_v3.json} (82%) create mode 100644 at_interface/configs/config_lambda_pidmode2.json create mode 100644 at_interface/configs/config_omega_pidmode1.json create mode 100644 at_interface/configs/config_omegastar_pidmode1.json create mode 100644 at_interface/configs/config_xi_pidmode1.json diff --git a/README.md b/README.md index 365466c..b3434cd 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ The program is configured with a JSON config file which contains various setting | `input_treename` | Name of the input AnalysisTree (for standard analysistree `rTree`, after running PID framework `pTree`) | | `rectracks_branchname` | branchname of reconstructed tracks in input analysistree, default names: `VtxTracks` for standard analyistree, `RecParticles` after running Pid-framework | | `n_events` | Number of events to be processed, set to `-1` to process all events | -| `make_plain_tree` | Set to `true` to output a normal root tree containing the candidates (besides the default output tree in AnalysisTree format) | +| `make_plain_tree` (optional) | normal root tree containing the candidates is written besides the default output tree in AnalysisTree format (set to `true`) | | `write_detailed_bg` (optional) | optional detailed background information in output variable `generation` (see below) | The format of the detailed background information in the `generation` variable is as follows: @@ -104,7 +104,7 @@ The decay block contains the specific decays PFSimple shall reconstruct. Each de #### mother The mother block must contain the fields `pdg_code` and `name` (chosen by user). You can optionally set the keys `mass` (Unit: GeV/c^2) and `mass_sigma` to be used when calculating mass decrepancies or setting nonlinear mass constrains, otherwise values from KFParticleDatabase are taken. -It is possible to define several cuts to be applied to the mother particle in the `cuts` subblock by using the fields `dist`, `distSV` (3-body decays only), `chi2geo`, `cosopen`, `chi2topo`, `costopo`, `LdL`, `L`, `distPVline` and `invmass`. Cuts which shall not be applied you can just delete or comment out. For more information on specific cuts see `Constants.hpp`. +It is possible to define several cuts to be applied to the mother particle in the `cuts` subblock, see `at_interface/config/config_dummy.json` for the available JSON keys. For more information on specific cuts see `Constants.hpp`. #### daughters The daughters block is a list consisting of 2 to 3 subblocks, each defining a daugher particle of the mother. It is required to give a JSON list in the `pdg_codes` field which contains the of PDG codes to be considered as possible daughter candidates of the decay in the. Optionally, alternative pdgs can be considered or further options can be selected for the reconstruction: @@ -129,8 +129,7 @@ The optional `save_options` block can contain specific string values which enabl The optional `output_cuts` block contains AnalysisTree field cuts to be applied to the output candidates before storing them to disk. One can either select a certain range for a cut variable with `from` and `to` or select a specific value with `equal`. It is possible to chain as many cuts as you want. ### Cascade decays -The reconstruction of a cascade decay works the same way as adding an additional decay -to the run as described above. The order of the decays need to be from last generation to +The reconstruction of a cascade decay works by adding all consecutive decays in one config file. The order of the decays need to be from last generation to first generation. Cascade decays with multiple stages as well as combinations of 2- and 3-body-decays can get reconstructed. @@ -138,20 +137,20 @@ Several example parameter files can be found in the folder `at_interface/configs ## Example Configs In the `at_interface/configs` directory are some example configs which have the following purpose: -| File | Description | -|---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| config_lambda1.json | Reconstructs Lambda with MC-PID mode (mode 1) using KFParticle cuts | -| config_lambda2.json | Reconstructs Lambda with MC-PID mode (mode 1) using cuts optimized by O. Lubynets | -| config_lambda3.json | Reconstructs Lambda without PID (mode 0) | -| config_lambda4.json | Reconstructs Lambda with the PID frameworks default PID mode (mode 2) | -| config_lambda_ml.json | Reconstructs Lambda with very loose cuts needed for machine learning applications, saves only mc-true signal candidates using `save_options` block | -| config_antilambda_ml.json | Reconstructs Anti-Lambda with very loose cuts needed for machine learning applications, saves only mc-true signal candidates using `save_options` block | -| config_H3L1.json | Reconstructs H3L with MC-PID mode (mode 1), example for 3-body decay and secondary mother cuts | -| config_H3L2.json | Reconstructs H3L with PID mode 4, shows application of minimum purities | -| config_He5L.json | Reconstructs He5L with MC-PID mode (mode 1), example for 3-body decay and secondary mother cuts | -| config_xi.json | Reconstructs Xi and Lambda with MC-PID mode (mode 1), basic example for the the cascade decay feature | -| config_omega.json | Reconstructs Omega and Lambda with MC-PID mode (mode 1), basic example for the the cascade decay feature | -| config_omegastar.json | Reconstructs Omega*, Xi and Lambda with MC-PID mode (mode 1), advanced example for the the cascade decay feature including a 3-body decay and secondary mother cuts | +| File | Particle(s) | `pid_mode` | Comment | +|----------------------------------|--------------------|------------|--------------------------------------------------------------------------------------------------------------------------------| +| `config_dummy.json` | Lambda | `1` | shows all available JSON fields, cuts are unphysical | +| `config_lambda_pidmode1_v1.json` | Lambda | `1` | using KFParticle cuts | +| `config_lambda_pidmode1_v2.json` | Lambda | `1` | using optimized cuts | +| `config_lambda_pidmode0.json` | Lambda | `0` | | +| `config_lambda_pidmode2.json` | Lambda | `2` | using PID frameworks default PID mode | +| `config_lambda_pidmode1_v3.json` | Lambda | `1` | with very loose cuts needed for machine learning applications, saves only mc-true signal candidates using `save_options` block | +| `config_H3L_pidmode1.json` | H3L | `1` | with MC-PID mode (mode 1), example for 3-body decay and secondary mother cuts | +| `config_H3L_pidmode4.json` | H3L | `4` | shows application of minimum purities | +| `config_He5L_pidmode1.json` | He5L | `1` | example for 3-body decay and secondary mother cuts | +| `config_xi_pidmode1.json` | Xi, Lambda | `1` | basic example for the the cascade decay feature | +| `config_omega_pidmode1.json` | Omega, Lambda | `1` | basic example for the the cascade decay feature | +| `config_omegastar_pidmode1.json` | Omega*, Xi, Lambda | `1` | advanced example for the the cascade decay feature including a 3-body decay and secondary mother cuts | diff --git a/at_interface/configs/config_H3L_pidmode1.json b/at_interface/configs/config_H3L_pidmode1.json new file mode 100644 index 0000000..79d5a78 --- /dev/null +++ b/at_interface/configs/config_H3L_pidmode1.json @@ -0,0 +1,41 @@ +{ + "io" : { + "input_treename" : "pTree", + "rectracks_branchname" : "RecTracks", + "n_events" : -1, + "make_plain_tree" : true + }, + "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + "decays" : [ + { + "mother" : { + "name" : "H3L", + "pdg_code" : 3004, + "cuts" : { + "LdL" : 10.0, + "dist" : 0.2, + "distSV" : 0.2 + } + }, + "daughters" : [ + { + "pdg_codes" : [2212], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [-211], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [1000010020], + "cuts" : {"chi2prim" : 10.0} + } + ], + "secondary_mother_cuts" : { + // daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 + "chi2geo" : [3.0], + "chi2topo" : [2.0] + } + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_H3L_pidmode4.json b/at_interface/configs/config_H3L_pidmode4.json new file mode 100644 index 0000000..b036dcd --- /dev/null +++ b/at_interface/configs/config_H3L_pidmode4.json @@ -0,0 +1,49 @@ +{ + "io" : { + "input_treename" : "pTree", + "rectracks_branchname" : "RecTracks", + "n_events" : -1, + "make_plain_tree" : true + }, + "pid_mode" : 4, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + "pid_purity" : { + "default" : 0.5, + "protons" : 0.7, + "pions" : 0.7, + "kaons" : 0.7, + "deuterons" : 0.2, + "background" : 0.7 + }, + "decays" : [ + { + "mother" : { + "name" : "H3L", + "pdg_code" : 3004, + "cuts" : { + "LdL" : 10.0, + "dist" : 0.2, + "distSV" : 0.2 + } + }, + "daughters" : [ + { + "pdg_codes" : [2212], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [-211], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [1000010020], + "cuts" : {"chi2prim" : 10.0} + } + ], + "secondary_mother_cuts" : { + // daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 + "chi2geo" : [3.0], + "chi2topo" : [2.0] + } + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_He5L_pidmode1.json b/at_interface/configs/config_He5L_pidmode1.json new file mode 100644 index 0000000..7a42aeb --- /dev/null +++ b/at_interface/configs/config_He5L_pidmode1.json @@ -0,0 +1,43 @@ +//from parfile3_add.txt +//(H3L pid 1) +{ + "io" : { + "input_treename" : "pTree", + "rectracks_branchname" : "RecTracks", + "n_events" : -1, + "make_plain_tree" : true + }, + "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + "decays" : [ + { + "mother" : { + "name" : "He5L", + "pdg_code" : 3007, + "cuts" : { + "LdL" : 5.0, + "dist" : 1.0, + "chi2geo" : 6.0, + "chi2topo" : 5.0 + } + }, + "daughters" : [ + { + "pdg_codes" : [1000020040], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [-211], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [2212], + "cuts" : {"chi2prim" : 18.42} + } + ], + "secondary_mother_cuts" : { + // daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 + "chi2geo" : [3.0] + } + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_dummy.json b/at_interface/configs/config_dummy.json new file mode 100644 index 0000000..aa4acc3 --- /dev/null +++ b/at_interface/configs/config_dummy.json @@ -0,0 +1,59 @@ +{ + "io" : { + "input_treename" : "rTree", // set to pTree in pid_mode > 2 + "rectracks_branchname" : "VtxTracks", // set to RecTracks in pid_mode > 2 + "n_events" : -1, + "write_detailed_bg" : true, + "make_plain_tree" : true + }, + "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + // for 2-4: Pid-framework needs to be applied first +/* "pid_purity" : { // this block is only needed in pid_mode > 2 + "default" : 0.5, + "protons" : 0.7, + "pions" : 0.7, + "kaons" : 0.7, + "deuterons" : 0.2, + "background" : 0.7 + },*/ + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "dist" : 1.0, +// "distSV" : 0, //for 3-body decay + "chi2geo" : 3.0, +// "cosopen" : 0, + "chi2topo" : 5.0, +// "costopo" : 0, + "LdL" : 10.0, +// "L" : 0 +// "distPVline" : 0, +// "invmass" : 0 + }, + "save_options" : [/*"mass_constraint", "transport_to_pv", "do_not_write_mother"*/] + }, + "daughters" : [ + { + "pdg_codes" : [-211], + "cuts" : {"chi2prim" : 18.42, /*"cos" : 0*/} + }, + { + "pdg_codes" : [2212], + "cuts" : {"chi2prim" : 18.42, /*"cos" : 0*/} + } + ], +/* "secondary_mother_cuts" : { // for 3-body decay + // daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 + "chi2geo" : [3.0], + "cosopen" : [0.2, 0.3, 0.3], + "chi2topo" : [3.0, 2.0], + "costopo" : [0.1] + } +*/ + } + //add more decays to this list if needed... + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_lambda_pidmode0.json b/at_interface/configs/config_lambda_pidmode0.json new file mode 100644 index 0000000..9dedd4c --- /dev/null +++ b/at_interface/configs/config_lambda_pidmode0.json @@ -0,0 +1,32 @@ +{ + "io" : { + "input_treename" : "rTree", + "rectracks_branchname" : "VtxTracks", + "n_events" : -1, + "make_plain_tree" : true + }, + "pid_mode" : 0, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "LdL" : 5.0, + "dist" : 1.0, + "chi2geo" : 3.0 + } + }, + "daughters" : [ + { + "pdg_codes" : [-211, -1], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [2212, 1], + "cuts" : {"chi2prim" : 18.42} + } + ] + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_lambda_pidmode1_v1.json b/at_interface/configs/config_lambda_pidmode1_v1.json new file mode 100644 index 0000000..a4d0938 --- /dev/null +++ b/at_interface/configs/config_lambda_pidmode1_v1.json @@ -0,0 +1,34 @@ +//from parfile2.txt +//(Lambda pid 1, cuts KFParticle) +{ + "io" : { + "input_treename" : "rTree", + "rectracks_branchname" : "VtxTracks", + "n_events" : -1, + "make_plain_tree" : true + }, + "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "LdL" : 5.0, + "dist" : 1.0, + "chi2geo" : 3.0 + } + }, + "daughters" : [ + { + "pdg_codes" : [-211], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [2212], + "cuts" : {"chi2prim" : 18.42} + } + ] + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_lambda_pidmode1_v2.json b/at_interface/configs/config_lambda_pidmode1_v2.json new file mode 100644 index 0000000..3986e45 --- /dev/null +++ b/at_interface/configs/config_lambda_pidmode1_v2.json @@ -0,0 +1,34 @@ +//(Lambda pid 1, cuts optimized) +{ + "io" : { + "input_treename" : "rTree", + "rectracks_branchname" : "VtxTracks", + "n_events" : -1, + "make_plain_tree" : true + }, + "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "LdL" : 4.0, + "dist" : 0.15, + "chi2geo" : 11.0, + "chi2topo" : 29.0 + } + }, + "daughters" : [ + { + "pdg_codes" : [-211], + "cuts" : {"chi2prim" : 110.00} + }, + { + "pdg_codes" : [2212], + "cuts" : {"chi2prim" : 26.00, "cos" : 0.99825} + } + ] + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_antilambda_ml.json b/at_interface/configs/config_lambda_pidmode1_v3.json similarity index 82% rename from at_interface/configs/config_antilambda_ml.json rename to at_interface/configs/config_lambda_pidmode1_v3.json index 3133daa..c46e44f 100644 --- a/at_interface/configs/config_antilambda_ml.json +++ b/at_interface/configs/config_lambda_pidmode1_v3.json @@ -9,8 +9,8 @@ "decays" : [ { "mother" : { - "name" : "Anti-Lambda", - "pdg_code" : -3122, + "name" : "Lambda", + "pdg_code" : 3122, "cuts" : { "dist" : 100.0, "chi2geo" : 1000.0 @@ -18,10 +18,10 @@ }, "daughters" : [ { - "pdg_codes" : [211] + "pdg_codes" : [-211] }, { - "pdg_codes" : [-2212] + "pdg_codes" : [2212] } ] } diff --git a/at_interface/configs/config_lambda_pidmode2.json b/at_interface/configs/config_lambda_pidmode2.json new file mode 100644 index 0000000..3b0d826 --- /dev/null +++ b/at_interface/configs/config_lambda_pidmode2.json @@ -0,0 +1,32 @@ +{ + "io" : { + "input_treename" : "pTree", + "rectracks_branchname" : "RecTracks", + "n_events" : -1, + "make_plain_tree" : true + }, + "pid_mode" : 2, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "LdL" : 5.0, + "dist" : 1.0, + "chi2geo" : 3.0 + } + }, + "daughters" : [ + { + "pdg_codes" : [-211, -2], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [2212, 2], + "cuts" : {"chi2prim" : 18.42} + } + ] + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_omega_pidmode1.json b/at_interface/configs/config_omega_pidmode1.json new file mode 100644 index 0000000..25b5ee8 --- /dev/null +++ b/at_interface/configs/config_omega_pidmode1.json @@ -0,0 +1,58 @@ +{ + "io" : { + "input_treename" : "rTree", + "rectracks_branchname" : "VtxTracks", + "n_events" : -1, + "write_detailed_bg" : true, + "make_plain_tree" : true + }, + "pid_mode" : 1, + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "LdL" : 10.0, + "dist" : 1.0, + "chi2geo" : 3.0, + "chi2topo" : 5.0, + "invmass" : 3.0 + }, + "save_options" : ["mass_constraint"] + }, + "daughters" : [ + { + "pdg_codes" : [-211, -1], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [2212, 1], + "cuts" : {"chi2prim" : 18.42} + } + ] + }, + { + "mother" : { + "name" : "Omega", + "pdg_code" : 3334, + "cuts" : { + "chi2topo" : 5.0, + "LdL" : 5.0, + "chi2geo" : 6.0, + "dist" : 1.0 + }, + "save_options" : ["transport_to_pv"] + }, + "daughters" : [ + { + "pdg_codes" : [-321], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [3122] + } + ] + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_omegastar_pidmode1.json b/at_interface/configs/config_omegastar_pidmode1.json new file mode 100644 index 0000000..fe40ff9 --- /dev/null +++ b/at_interface/configs/config_omegastar_pidmode1.json @@ -0,0 +1,91 @@ +{ + "io" : { + "input_treename" : "rTree", + "rectracks_branchname" : "VtxTracks", + "n_events" : -1, + "write_detailed_bg" : true, + "make_plain_tree" : true + }, + "pid_mode" : 1, + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "LdL" : 10.0, + "dist" : 1.0, + "chi2geo" : 3.0, + "chi2topo" : 5.0, + "invmass" : 3.0 + }, + "save_options" : ["mass_constraint"] + }, + "daughters" : [ + { + "pdg_codes" : [-211, -1], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [2212, 1], + "cuts" : {"chi2prim" : 18.42} + } + ] + }, + { + "mother" : { + "name" : "Xi-", + "pdg_code" : 3312, + "cuts" : { + "chi2topo" : 5.0, + "dist" : 1.0, + "LdL" : 5.0, + "chi2geo" : 6.0, + "invmass" : 3.0 + }, + "save_options" : ["mass_constraint"] + }, + "daughters" : [ + { + "pdg_codes" : [-211, -1], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [3122] + } + ] + }, + { + "mother" : { + "name" : "Omega*-", + "pdg_code" : 1003334, + "mass" : 2.252, + "mass_sigma" : 0.055, + "cuts" : { + "dist" : 1.0, + "chi2topo" : 1000.0, + "LdL" : 5.0, + "chi2geo" : 3.0 + } + }, + "daughters" : [ + { + "pdg_codes" : [3312], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [211], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [-321], + "cuts" : {"chi2prim" : 18.42} + } + ], + "secondary_mother_cuts" : { + //daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 + "chi2geo" : [3.0] + } + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_xi_pidmode1.json b/at_interface/configs/config_xi_pidmode1.json new file mode 100644 index 0000000..227c82e --- /dev/null +++ b/at_interface/configs/config_xi_pidmode1.json @@ -0,0 +1,58 @@ +{ + "io" : { + "input_treename" : "rTree", + "rectracks_branchname" : "VtxTracks", + "n_events" : -1, + "write_detailed_bg" : true, + "make_plain_tree" : true + }, + "pid_mode" : 1, + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "LdL" : 10.0, + "dist" : 1.0, + "chi2geo" : 3.0, + "chi2topo" : 5.0, + "invmass" : 3.0 + }, + "save_options" : ["mass_constraint"] + }, + "daughters" : [ + { + "pdg_codes" : [-211, -1], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [2212, 1], + "cuts" : {"chi2prim" : 18.42} + } + ] + }, + { + "mother" : { + "name" : "Xi-", + "pdg_code" : 3312, + "cuts" : { + "chi2topo" : 5.0, + "dist" : 1.0, + "LdL" : 5.0, + "chi2geo" : 6.0 + }, + "save_options" : ["transport_to_pv"] + }, + "daughters" : [ + { + "pdg_codes" : [-211, -1], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_codes" : [3122] + } + ] + } + ] +} \ No newline at end of file diff --git a/at_interface/main_json.cpp b/at_interface/main_json.cpp index 0862bcb..b46b5ab 100644 --- a/at_interface/main_json.cpp +++ b/at_interface/main_json.cpp @@ -216,7 +216,7 @@ int main(int argc, char** argv) { man->Finish(); man->ClearTasks(); - if (config["io"]["make_plain_tree"]) { + if (config["io"].contains("make_plain_tree") && config["io"]["make_plain_tree"]) { std::ofstream filelist; filelist.open("filelist.txt"); filelist << output_file; From 757eb140526e76b05f0e485bcbd614ab911c6bf7 Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Thu, 15 May 2025 18:07:51 +0200 Subject: [PATCH 12/21] Update configs --- at_interface/configs/config_He5L_pidmode1.json | 2 -- at_interface/configs/config_lambda_pidmode1_v1.json | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/at_interface/configs/config_He5L_pidmode1.json b/at_interface/configs/config_He5L_pidmode1.json index 7a42aeb..9c0dd0a 100644 --- a/at_interface/configs/config_He5L_pidmode1.json +++ b/at_interface/configs/config_He5L_pidmode1.json @@ -1,5 +1,3 @@ -//from parfile3_add.txt -//(H3L pid 1) { "io" : { "input_treename" : "pTree", diff --git a/at_interface/configs/config_lambda_pidmode1_v1.json b/at_interface/configs/config_lambda_pidmode1_v1.json index a4d0938..7be6cff 100644 --- a/at_interface/configs/config_lambda_pidmode1_v1.json +++ b/at_interface/configs/config_lambda_pidmode1_v1.json @@ -1,5 +1,4 @@ -//from parfile2.txt -//(Lambda pid 1, cuts KFParticle) +//(Lambda pid 1, cuts from KFParticle) { "io" : { "input_treename" : "rTree", From ae39e943e86808409bfbfc3f3f8c5a5122004ca6 Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Mon, 19 May 2025 11:11:38 +0200 Subject: [PATCH 13/21] Add signal-only option --- README.md | 1 + at_interface/configs/config_dummy.json | 3 ++- at_interface/main_json.cpp | 9 ++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b3434cd..1bb2cee 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ The program is configured with a JSON config file which contains various setting | `n_events` | Number of events to be processed, set to `-1` to process all events | | `make_plain_tree` (optional) | normal root tree containing the candidates is written besides the default output tree in AnalysisTree format (set to `true`) | | `write_detailed_bg` (optional) | optional detailed background information in output variable `generation` (see below) | +| `save_signal_only` (optional) | save only mc-true signal candidates (set to `true`) | The format of the detailed background information in the `generation` variable is as follows: format for bg for 2-body-decay: -m12 0 d2 d1 diff --git a/at_interface/configs/config_dummy.json b/at_interface/configs/config_dummy.json index aa4acc3..55146f5 100644 --- a/at_interface/configs/config_dummy.json +++ b/at_interface/configs/config_dummy.json @@ -4,7 +4,8 @@ "rectracks_branchname" : "VtxTracks", // set to RecTracks in pid_mode > 2 "n_events" : -1, "write_detailed_bg" : true, - "make_plain_tree" : true + "make_plain_tree" : true, + "save_signal_only" : false }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) // for 2-4: Pid-framework needs to be applied first diff --git a/at_interface/main_json.cpp b/at_interface/main_json.cpp index b46b5ab..b936d0f 100644 --- a/at_interface/main_json.cpp +++ b/at_interface/main_json.cpp @@ -193,15 +193,22 @@ int main(int argc, char** argv) { out_converter->SetDecays(decays); if (config["io"].contains("write_detailed_bg")) out_converter->SetIsWriteDetailedBG(config["io"]["write_detailed_bg"]); + std::vector vec_output_cuts = {}; if (config.contains("output_cuts")) { - std::vector vec_output_cuts = {}; for (const auto& cut_cfg : config["output_cuts"]) { if (cut_cfg.contains("equal")) vec_output_cuts.push_back(AnalysisTree::EqualsCut("Candidates." + cut_cfg["var"].get(), cut_cfg["equal"])); else if (cut_cfg.contains("from")) vec_output_cuts.push_back(AnalysisTree::RangeCut("Candidates." + cut_cfg["var"].get(), cut_cfg["from"], cut_cfg["to"])); } + } + + if (config["io"].contains("save_signal_only") && config["io"]["save_signal_only"]) + vec_output_cuts.push_back(AnalysisTree::SimpleCut({"Candidates.generation"}, []( std::vector& var ) { return var.at(0) != 0; })); + + if (vec_output_cuts.size() > 0) + { AnalysisTree::Cuts* output_cuts = new AnalysisTree::Cuts("output_cuts", vec_output_cuts); out_converter->SetOutputCuts(output_cuts); } From deffe661231bc420e8b835db8445ee2dcdd75620 Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Mon, 19 May 2025 11:14:09 +0200 Subject: [PATCH 14/21] Delete obsolete configs --- at_interface/configs/config_H3L1.json | 43 ---------- at_interface/configs/config_H3L2.json | 51 ------------ at_interface/configs/config_He5L.json | 43 ---------- at_interface/configs/config_lambda1.json | 34 -------- at_interface/configs/config_lambda2.json | 35 --------- at_interface/configs/config_lambda3.json | 34 -------- at_interface/configs/config_lambda4.json | 34 -------- at_interface/configs/config_lambda_ml.json | 32 -------- at_interface/configs/config_omega.json | 58 -------------- at_interface/configs/config_omegastar.json | 91 ---------------------- at_interface/configs/config_xi.json | 58 -------------- 11 files changed, 513 deletions(-) delete mode 100644 at_interface/configs/config_H3L1.json delete mode 100644 at_interface/configs/config_H3L2.json delete mode 100644 at_interface/configs/config_He5L.json delete mode 100644 at_interface/configs/config_lambda1.json delete mode 100644 at_interface/configs/config_lambda2.json delete mode 100644 at_interface/configs/config_lambda3.json delete mode 100644 at_interface/configs/config_lambda4.json delete mode 100644 at_interface/configs/config_lambda_ml.json delete mode 100644 at_interface/configs/config_omega.json delete mode 100644 at_interface/configs/config_omegastar.json delete mode 100644 at_interface/configs/config_xi.json diff --git a/at_interface/configs/config_H3L1.json b/at_interface/configs/config_H3L1.json deleted file mode 100644 index 115ec88..0000000 --- a/at_interface/configs/config_H3L1.json +++ /dev/null @@ -1,43 +0,0 @@ -//from parfile3.txt -//(H3L pid 1) -{ - "io" : { - "input_treename" : "pTree", - "rectracks_branchname" : "RecTracks", - "n_events" : -1, - "make_plain_tree" : true - }, - "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) - "decays" : [ - { - "mother" : { - "name" : "H3L", - "pdg_code" : 3004, - "cuts" : { - "LdL" : 10.0, - "dist" : 0.2, - "distSV" : 0.2 - } - }, - "daughters" : [ - { - "pdg_codes" : [2212], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [-211], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [1000010020], - "cuts" : {"chi2prim" : 10.0} - } - ], - "secondary_mother_cuts" : { - // daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 - "chi2geo" : [3.0], - "chi2topo" : [2.0] - } - } - ] -} \ No newline at end of file diff --git a/at_interface/configs/config_H3L2.json b/at_interface/configs/config_H3L2.json deleted file mode 100644 index 04f0870..0000000 --- a/at_interface/configs/config_H3L2.json +++ /dev/null @@ -1,51 +0,0 @@ -//from parfile3_H3L_pidmode4.txt -//(H3L pid 4) -{ - "io" : { - "input_treename" : "pTree", - "rectracks_branchname" : "RecTracks", - "n_events" : -1, - "make_plain_tree" : true - }, - "pid_mode" : 4, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) - "pid_purity" : { - "default" : 0.5, - "protons" : 0.7, - "pions" : 0.7, - "kaons" : 0.7, - "deuterons" : 0.2, - "background" : 0.7 - }, - "decays" : [ - { - "mother" : { - "name" : "H3L", - "pdg_code" : 3004, - "cuts" : { - "LdL" : 10.0, - "dist" : 0.2, - "distSV" : 0.2 - } - }, - "daughters" : [ - { - "pdg_codes" : [2212], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [-211], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [1000010020], - "cuts" : {"chi2prim" : 10.0} - } - ], - "secondary_mother_cuts" : { - // daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 - "chi2geo" : [3.0], - "chi2topo" : [2.0] - } - } - ] -} \ No newline at end of file diff --git a/at_interface/configs/config_He5L.json b/at_interface/configs/config_He5L.json deleted file mode 100644 index 7a42aeb..0000000 --- a/at_interface/configs/config_He5L.json +++ /dev/null @@ -1,43 +0,0 @@ -//from parfile3_add.txt -//(H3L pid 1) -{ - "io" : { - "input_treename" : "pTree", - "rectracks_branchname" : "RecTracks", - "n_events" : -1, - "make_plain_tree" : true - }, - "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) - "decays" : [ - { - "mother" : { - "name" : "He5L", - "pdg_code" : 3007, - "cuts" : { - "LdL" : 5.0, - "dist" : 1.0, - "chi2geo" : 6.0, - "chi2topo" : 5.0 - } - }, - "daughters" : [ - { - "pdg_codes" : [1000020040], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [-211], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [2212], - "cuts" : {"chi2prim" : 18.42} - } - ], - "secondary_mother_cuts" : { - // daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 - "chi2geo" : [3.0] - } - } - ] -} \ No newline at end of file diff --git a/at_interface/configs/config_lambda1.json b/at_interface/configs/config_lambda1.json deleted file mode 100644 index a4d0938..0000000 --- a/at_interface/configs/config_lambda1.json +++ /dev/null @@ -1,34 +0,0 @@ -//from parfile2.txt -//(Lambda pid 1, cuts KFParticle) -{ - "io" : { - "input_treename" : "rTree", - "rectracks_branchname" : "VtxTracks", - "n_events" : -1, - "make_plain_tree" : true - }, - "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) - "decays" : [ - { - "mother" : { - "name" : "Lambda", - "pdg_code" : 3122, - "cuts" : { - "LdL" : 5.0, - "dist" : 1.0, - "chi2geo" : 3.0 - } - }, - "daughters" : [ - { - "pdg_codes" : [-211], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [2212], - "cuts" : {"chi2prim" : 18.42} - } - ] - } - ] -} \ No newline at end of file diff --git a/at_interface/configs/config_lambda2.json b/at_interface/configs/config_lambda2.json deleted file mode 100644 index 85c391f..0000000 --- a/at_interface/configs/config_lambda2.json +++ /dev/null @@ -1,35 +0,0 @@ -//from parfile2_lambda_pidmode1_optcut.txt -//(Lambda pid 1, cuts optimized Oleksii) -{ - "io" : { - "input_treename" : "rTree", - "rectracks_branchname" : "VtxTracks", - "n_events" : -1, - "make_plain_tree" : true - }, - "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) - "decays" : [ - { - "mother" : { - "name" : "Lambda", - "pdg_code" : 3122, - "cuts" : { - "LdL" : 4.0, - "dist" : 0.15, - "chi2geo" : 11.0, - "chi2topo" : 29.0 - } - }, - "daughters" : [ - { - "pdg_codes" : [-211], - "cuts" : {"chi2prim" : 110.00} - }, - { - "pdg_codes" : [2212], - "cuts" : {"chi2prim" : 26.00, "cos" : 0.99825} - } - ] - } - ] -} \ No newline at end of file diff --git a/at_interface/configs/config_lambda3.json b/at_interface/configs/config_lambda3.json deleted file mode 100644 index aff655b..0000000 --- a/at_interface/configs/config_lambda3.json +++ /dev/null @@ -1,34 +0,0 @@ -//from parfile2_lambda_pidmode0.txt -//(Lambda pid 0) -{ - "io" : { - "input_treename" : "rTree", - "rectracks_branchname" : "VtxTracks", - "n_events" : -1, - "make_plain_tree" : true - }, - "pid_mode" : 0, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) - "decays" : [ - { - "mother" : { - "name" : "Lambda", - "pdg_code" : 3122, - "cuts" : { - "LdL" : 5.0, - "dist" : 1.0, - "chi2geo" : 3.0 - } - }, - "daughters" : [ - { - "pdg_codes" : [-211, -1], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [2212, 1], - "cuts" : {"chi2prim" : 18.42} - } - ] - } - ] -} \ No newline at end of file diff --git a/at_interface/configs/config_lambda4.json b/at_interface/configs/config_lambda4.json deleted file mode 100644 index 6acf55e..0000000 --- a/at_interface/configs/config_lambda4.json +++ /dev/null @@ -1,34 +0,0 @@ -//from parfile2_lambda_pidmode2.txt -//(Lambda pid 2) -{ - "io" : { - "input_treename" : "pTree", - "rectracks_branchname" : "RecTracks", - "n_events" : -1, - "make_plain_tree" : true - }, - "pid_mode" : 2, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) - "decays" : [ - { - "mother" : { - "name" : "Lambda", - "pdg_code" : 3122, - "cuts" : { - "LdL" : 5.0, - "dist" : 1.0, - "chi2geo" : 3.0 - } - }, - "daughters" : [ - { - "pdg_codes" : [-211, -2], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [2212, 2], - "cuts" : {"chi2prim" : 18.42} - } - ] - } - ] -} \ No newline at end of file diff --git a/at_interface/configs/config_lambda_ml.json b/at_interface/configs/config_lambda_ml.json deleted file mode 100644 index c46e44f..0000000 --- a/at_interface/configs/config_lambda_ml.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "io" : { - "input_treename" : "rTree", - "rectracks_branchname" : "VtxTracks", - "n_events" : -1, - "make_plain_tree" : false - }, - "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) - "decays" : [ - { - "mother" : { - "name" : "Lambda", - "pdg_code" : 3122, - "cuts" : { - "dist" : 100.0, - "chi2geo" : 1000.0 - } - }, - "daughters" : [ - { - "pdg_codes" : [-211] - }, - { - "pdg_codes" : [2212] - } - ] - } - ], - "output_cuts" : [ - {"var" : "generation", "from" : 0.9, "to" : 1000} - ] -} \ No newline at end of file diff --git a/at_interface/configs/config_omega.json b/at_interface/configs/config_omega.json deleted file mode 100644 index 25b5ee8..0000000 --- a/at_interface/configs/config_omega.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "io" : { - "input_treename" : "rTree", - "rectracks_branchname" : "VtxTracks", - "n_events" : -1, - "write_detailed_bg" : true, - "make_plain_tree" : true - }, - "pid_mode" : 1, - "decays" : [ - { - "mother" : { - "name" : "Lambda", - "pdg_code" : 3122, - "cuts" : { - "LdL" : 10.0, - "dist" : 1.0, - "chi2geo" : 3.0, - "chi2topo" : 5.0, - "invmass" : 3.0 - }, - "save_options" : ["mass_constraint"] - }, - "daughters" : [ - { - "pdg_codes" : [-211, -1], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [2212, 1], - "cuts" : {"chi2prim" : 18.42} - } - ] - }, - { - "mother" : { - "name" : "Omega", - "pdg_code" : 3334, - "cuts" : { - "chi2topo" : 5.0, - "LdL" : 5.0, - "chi2geo" : 6.0, - "dist" : 1.0 - }, - "save_options" : ["transport_to_pv"] - }, - "daughters" : [ - { - "pdg_codes" : [-321], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [3122] - } - ] - } - ] -} \ No newline at end of file diff --git a/at_interface/configs/config_omegastar.json b/at_interface/configs/config_omegastar.json deleted file mode 100644 index fe40ff9..0000000 --- a/at_interface/configs/config_omegastar.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "io" : { - "input_treename" : "rTree", - "rectracks_branchname" : "VtxTracks", - "n_events" : -1, - "write_detailed_bg" : true, - "make_plain_tree" : true - }, - "pid_mode" : 1, - "decays" : [ - { - "mother" : { - "name" : "Lambda", - "pdg_code" : 3122, - "cuts" : { - "LdL" : 10.0, - "dist" : 1.0, - "chi2geo" : 3.0, - "chi2topo" : 5.0, - "invmass" : 3.0 - }, - "save_options" : ["mass_constraint"] - }, - "daughters" : [ - { - "pdg_codes" : [-211, -1], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [2212, 1], - "cuts" : {"chi2prim" : 18.42} - } - ] - }, - { - "mother" : { - "name" : "Xi-", - "pdg_code" : 3312, - "cuts" : { - "chi2topo" : 5.0, - "dist" : 1.0, - "LdL" : 5.0, - "chi2geo" : 6.0, - "invmass" : 3.0 - }, - "save_options" : ["mass_constraint"] - }, - "daughters" : [ - { - "pdg_codes" : [-211, -1], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [3122] - } - ] - }, - { - "mother" : { - "name" : "Omega*-", - "pdg_code" : 1003334, - "mass" : 2.252, - "mass_sigma" : 0.055, - "cuts" : { - "dist" : 1.0, - "chi2topo" : 1000.0, - "LdL" : 5.0, - "chi2geo" : 3.0 - } - }, - "daughters" : [ - { - "pdg_codes" : [3312], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [211], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [-321], - "cuts" : {"chi2prim" : 18.42} - } - ], - "secondary_mother_cuts" : { - //daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 - "chi2geo" : [3.0] - } - } - ] -} \ No newline at end of file diff --git a/at_interface/configs/config_xi.json b/at_interface/configs/config_xi.json deleted file mode 100644 index 227c82e..0000000 --- a/at_interface/configs/config_xi.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "io" : { - "input_treename" : "rTree", - "rectracks_branchname" : "VtxTracks", - "n_events" : -1, - "write_detailed_bg" : true, - "make_plain_tree" : true - }, - "pid_mode" : 1, - "decays" : [ - { - "mother" : { - "name" : "Lambda", - "pdg_code" : 3122, - "cuts" : { - "LdL" : 10.0, - "dist" : 1.0, - "chi2geo" : 3.0, - "chi2topo" : 5.0, - "invmass" : 3.0 - }, - "save_options" : ["mass_constraint"] - }, - "daughters" : [ - { - "pdg_codes" : [-211, -1], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [2212, 1], - "cuts" : {"chi2prim" : 18.42} - } - ] - }, - { - "mother" : { - "name" : "Xi-", - "pdg_code" : 3312, - "cuts" : { - "chi2topo" : 5.0, - "dist" : 1.0, - "LdL" : 5.0, - "chi2geo" : 6.0 - }, - "save_options" : ["transport_to_pv"] - }, - "daughters" : [ - { - "pdg_codes" : [-211, -1], - "cuts" : {"chi2prim" : 18.42} - }, - { - "pdg_codes" : [3122] - } - ] - } - ] -} \ No newline at end of file From e6600914ff9edb68423d24fd4453d4f1b2601791 Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Tue, 3 Jun 2025 11:27:27 +0200 Subject: [PATCH 15/21] Incorporate Susannes Change Requests --- README.md | 124 +++++++++--------- at_interface/configs/config_H3L_pidmode1.json | 6 +- at_interface/configs/config_H3L_pidmode4.json | 8 +- .../configs/config_He5L_pidmode1.json | 6 +- .../configs/config_lambda_pidmode0.json | 4 +- .../configs/config_lambda_pidmode1_v1.json | 4 +- .../configs/config_lambda_pidmode1_v2.json | 4 +- .../configs/config_lambda_pidmode1_v3.json | 4 +- .../configs/config_lambda_pidmode2.json | 4 +- .../configs/config_omega_pidmode1.json | 8 +- .../configs/config_omegastar_pidmode1.json | 14 +- ...config_dummy.json => config_template.json} | 8 +- at_interface/configs/config_xi_pidmode1.json | 8 +- at_interface/main_json.cpp | 4 +- 14 files changed, 106 insertions(+), 100 deletions(-) rename at_interface/configs/{config_dummy.json => config_template.json} (93%) diff --git a/README.md b/README.md index 1bb2cee..af3079a 100644 --- a/README.md +++ b/README.md @@ -50,19 +50,20 @@ cmake -DCMAKE_INSTALL_PREFIX=/path-to-install-pfsimple /path-to-source-pfsimple make -j install ``` ## Configuration of decay settings -The program is configured with a JSON config file which contains various settings related to input and output as well as the decays to reconstruct. In the following, the different blocks are explained. +The program is configured with a JSON config file which contains various settings related to input and output as well as the decays to reconstruct. In the following, the different blocks and fields are explained. In `at_interface/config/config_template.json` all available JSON fields are listed. ### io | Key | Description | | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `input_treename` | Name of the input AnalysisTree (for standard analysistree `rTree`, after running PID framework `pTree`) | +| `input_treename` | name of the input AnalysisTree (for standard analysistree `rTree`, after running PID framework `pTree`) | | `rectracks_branchname` | branchname of reconstructed tracks in input analysistree, default names: `VtxTracks` for standard analyistree, `RecParticles` after running Pid-framework | -| `n_events` | Number of events to be processed, set to `-1` to process all events | -| `make_plain_tree` (optional) | normal root tree containing the candidates is written besides the default output tree in AnalysisTree format (set to `true`) | -| `write_detailed_bg` (optional) | optional detailed background information in output variable `generation` (see below) | -| `save_signal_only` (optional) | save only mc-true signal candidates (set to `true`) | +| `n_events` | number of events to be processed, set to `-1` to process all events | +| `make_plain_tree` (optional) | normal root tree containing the candidates is written besides the default output tree in AnalysisTree format | +| `save_signal_only` (optional) | save only mc-true signal candidates | +| `write_detailed_bg` (optional) | detailed background information in output variable `generation`* | + +*Format of detailed background information in the `generation` variable: -The format of the detailed background information in the `generation` variable is as follows: format for bg for 2-body-decay: -m12 0 d2 d1 format for bg for 3-body-decay: -m13 m23 m12 d3 d2 d1 with m12: mother of daughter 1 & 2 etc. @@ -84,74 +85,79 @@ If detailed background is not selected or if mc match for mother is found, value 2 - mother is second generation etc. ### pid_mode -The method for particle identification is configured in the `pid_mode` variable and can be one of the following ones: -| `pid_mode` | Description | -| ---------- | -------------------------------------------------------------------------------------------------------- | -| `0` | no pid (only charge information is used! optional daughers must be set to 1 / -1 for pos / neg pdgs!) | -| `1` | mc-pid | -| `2` | reconstructed TOF pid - default from Pid-framework | -| `3` | reconstructed TOF pid - pdg with max. pdg-purity is selected, if pdg-purity >min. purity | -| `4` | reconstructed TOF pid - pdg is selected, if pdg-purity > min. purity (pdg-specfic purities are possible) | +Methods for particle identification: +| `pid_mode` | Description | +| ---------- | --------------------------------------------------------------------------------------------------------- | +| `0` | no pid (only charge information is used! optional daughers must be set to 1 / -1 for pos / neg pdgs!) | +| `1` | mc-pid | +| `2` | reconstructed TOF pid - default from Pid-framework* | +| `3` | reconstructed TOF pid - pdg with max. pdg-purity is selected, if pdg-purity >min. purity* | +| `4` | reconstructed TOF pid - pdg is selected, if pdg-purity > min. purity (pdg-specfic purities are possible)* | -**for 2-4: Pid-framework needs to be applied first to include TOF-pid & probabilities into the analysistree input-file** +** *for 2-4: Pid-framework needs to be applied first to include TOF-pid & probabilities into the analysistree input-file** ### pid_purity -This block is required in pid-mode 3 & 4 and defines the minium purities to be used: - - for pid-mode 3: minimum purity is set for all pdgs (pdg-spefic purities need to be omitted) - - for pid-mode 4: minimum purity can be set for all pdgs or specifically for every pdg (general purity will be overwritten, if pdg-specific purity is given) +Mimimum purities for pid-mode 3 & 4: +- `all_pdgs`: minimum purity is set for all pdgs (pdg-spefic purities need to be omitted) (in pid-mode 3 & 4) +- `protons`, `pions`, etc: minimum purity is set specifically for every pdg (general purity will be overwritten, if pdg-specific purity is given) (in pid-mode 4) ### decays -The decay block contains the specific decays PFSimple shall reconstruct. Each decay is defined by several sub-blocks: +One or multiple decays get can reconstructed in one run. Each decay is defined by several sub-blocks: #### mother -The mother block must contain the fields `pdg_code` and `name` (chosen by user). You can optionally set the keys `mass` (Unit: GeV/c^2) and `mass_sigma` to be used when calculating mass decrepancies or setting nonlinear mass constrains, otherwise values from KFParticleDatabase are taken. -It is possible to define several cuts to be applied to the mother particle in the `cuts` subblock, see `at_interface/config/config_dummy.json` for the available JSON keys. For more information on specific cuts see `Constants.hpp`. +- `pdg_code` +- `name` (chosen by user) +- `mass` (Unit: GeV/c^2) and `mass_sigma` (optional): if set to "-1" values from KFParticleDatabase are taken (if available) +- `cuts`: subblock for the definition of cuts to be applied to the mother (See `at_interface/config/config_template.json` for the available JSON keys and `Constants.hpp` for more details.) +- `save_options`: options for the saving of the reconstructed mother: + +| Flag | Description | +| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `mass_constraint` | nonlinear mass constraint is applied on the mother particle which modifies the mother's state vector and covariance matrix to assure the 4-momentum is consitent with the pdg mass | +| `transport_to_pv` | mother is transported to the PV before saving | +| `do_not_save_mother` | writing of the mother into the output-file (e.g. the lower-level mother in cascade decays) is surpressed. If this option is selected, it is not possible to peform the MC-matching for the upper-level mother. | #### daughters -The daughters block is a list consisting of 2 to 3 subblocks, each defining a daugher particle of the mother. It is required to give a JSON list in the `pdg_codes` field which contains the of PDG codes to be considered as possible daughter candidates of the decay in the. Optionally, alternative pdgs can be considered or further options can be selected for the reconstruction: -- for background: set to "1" / "-1" for pos / neg daughters -- for tracks without TOF id: set to "2" / "-2" for pos / neg daughters (in pid-mode 2, 3, 4) -- In pid-mode 0 optional daughers "1" / "-1" for pos / neg pdgs must be added - -Analogously to the mother you can also apply cuts for the daughters in the `cuts` subblock (`chi2prim` and `cos`). - -#### daughter_combination_cuts (3-body-decays) -For 3-body decays, the list of available cuts is extended, amoung others, to cuts on the secondary mothers (SM) of combinations of 2 daughters. E.g. for H3L->p + pi + d, cuts on the SM of p-pi can be applied. The cuts that test the mother against the PV, e.g. chi2topo, are inverted for the SM to exclude SMs that come from the PV. They are defined in the optional `secondary_mother_cuts` block of the decay, which can contain for each of the 4 possible variables `chi2geo`, `cosopen`, `chi2topo` and `costopo` a list with up to 3 entries. The entries respectively reflect the cuts to be applied on the secondary mothers of daughter combinations 1 & 2, 1 & 3 and 2 & 3. - -#### save_options -The optional `save_options` block can contain specific string values which enable features related to the saving of the reconstructed mother: -| Flag | Description | -| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `mass_constraint` | A nonlinear mass constraint can be applied on the mother particle which modifies the mother's state vector and covariance matrix to assure the 4-momentum is consitent with the pdg mass. | -| `transport_to_pv` | The mother is transported to the PV before saving | -| `do_not_write_mother` | The writing of the mother into the output-file (e.g. the lower-level mother in cascade decays) can get surpressed. But if this option is selected, it is not possible to peform the MC-matching for the upper-level mother. | +The 2 (3) daughters of the mother are be defined in 2 (3) subblocks (for 2-/3-body decays). +- `pdg_code` (in JSON list format): + first entry: daugher PDG; + second and following entries (optional): additional pdgs or background can be considered as possible daughter candidates, for background set: + - for background: set to "1" / "-1" for pos / neg daughters + - for tracks without TOF id: set to "2" / "-2" for pos / neg daughters (in pid-mode 2, 3, 4) + In pid-mode 0 optional daughers "1" / "-1" for pos / neg pdgs must be added +- `cuts`: subblock for the definition of cuts to be applied to the daughter (See `at_interface/config/config_template.json` for the available JSON keys and `Constants.hpp` for more details.) + +#### secondary_mother_cuts (3-body-decays) +Cuts on the secondary mothers (SM) of combinations of 2 daughters can have up to 3 entries (JSON list format): cuts for daughter combinations [1 & 2, 1 & 3, 2 & 3]. +E.g. for H3L->p + pi + d, a cut on the SM of p-pi can be applied. +The cuts that test the mother against the PV, e.g. chi2topo, are inverted for the SM to exclude SMs that come from the PV. +(See `at_interface/config/config_template.json` for the available JSON keys and `Constants.hpp` for more details.) ### output_cuts -The optional `output_cuts` block contains AnalysisTree field cuts to be applied to the output candidates before storing them to disk. One can either select a certain range for a cut variable with `from` and `to` or select a specific value with `equal`. It is possible to chain as many cuts as you want. +The optional `output_cuts` block contains AnalysisTree field cuts to be applied to the output candidates before storing them to disk. One can either select a certain range for a cut variable with `from` and `to` or select a specific value with `equal`. It is possible to chain several cuts. ### Cascade decays -The reconstruction of a cascade decay works by adding all consecutive decays in one config file. The order of the decays need to be from last generation to -first generation. Cascade decays with multiple stages as well as combinations of -2- and 3-body-decays can get reconstructed. +For the reconstruction of a cascade decay all consecutive decays are added into one config-file. The order of the decays need to be from last generation to +first generation. +Cascade decays with multiple stages as well as combinations of 2- and 3-body-decays can get reconstructed. +## Example Configs Several example parameter files can be found in the folder `at_interface/configs`. -## Example Configs -In the `at_interface/configs` directory are some example configs which have the following purpose: | File | Particle(s) | `pid_mode` | Comment | -|----------------------------------|--------------------|------------|--------------------------------------------------------------------------------------------------------------------------------| -| `config_dummy.json` | Lambda | `1` | shows all available JSON fields, cuts are unphysical | -| `config_lambda_pidmode1_v1.json` | Lambda | `1` | using KFParticle cuts | -| `config_lambda_pidmode1_v2.json` | Lambda | `1` | using optimized cuts | -| `config_lambda_pidmode0.json` | Lambda | `0` | | -| `config_lambda_pidmode2.json` | Lambda | `2` | using PID frameworks default PID mode | -| `config_lambda_pidmode1_v3.json` | Lambda | `1` | with very loose cuts needed for machine learning applications, saves only mc-true signal candidates using `save_options` block | -| `config_H3L_pidmode1.json` | H3L | `1` | with MC-PID mode (mode 1), example for 3-body decay and secondary mother cuts | -| `config_H3L_pidmode4.json` | H3L | `4` | shows application of minimum purities | -| `config_He5L_pidmode1.json` | He5L | `1` | example for 3-body decay and secondary mother cuts | -| `config_xi_pidmode1.json` | Xi, Lambda | `1` | basic example for the the cascade decay feature | -| `config_omega_pidmode1.json` | Omega, Lambda | `1` | basic example for the the cascade decay feature | -| `config_omegastar_pidmode1.json` | Omega*, Xi, Lambda | `1` | advanced example for the the cascade decay feature including a 3-body decay and secondary mother cuts | +|----------------------------------|--------------------|------------|--------------------------------------- | +| `config_template.json` | - | - | all available JSON fields listed | +| `config_lambda_pidmode1_v1.json` | Lambda | `1` | KFParticle cuts | +| `config_lambda_pidmode1_v2.json` | Lambda | `1` | optimized cuts | +| `config_lambda_pidmode0.json` | Lambda | `0` | | +| `config_lambda_pidmode2.json` | Lambda | `2` | | +| `config_lambda_pidmode1_v3.json` | Lambda | `1` | for machine learning applications | +| `config_H3L_pidmode1.json` | H3L | `1` | 3-body decay | +| `config_H3L_pidmode4.json` | H3L | `4` | 3-body decay, minimum purities applied | +| `config_He5L_pidmode1.json` | He5L | `1` | 3-body decay | +| `config_xi_pidmode1.json` | Xi, Lambda | `1` | cascade decay | +| `config_omega_pidmode1.json` | Omega, Lambda | `1` | cascade decay | +| `config_omegastar_pidmode1.json` | Omega*, Xi, Lambda | `1` | cascade decay, 3-body decay | @@ -175,4 +181,4 @@ filelist.txt must be a text file with names (including paths) to AnalysisTree files which you want to analyze with PFSimple. Each file name should be on the next line, and the last symbol should also be a switch to next line. The example of filelist is in the source directory of -PFSimple (filelist_example.txt) \ No newline at end of file +PFSimple (filelist_example.txt) diff --git a/at_interface/configs/config_H3L_pidmode1.json b/at_interface/configs/config_H3L_pidmode1.json index 79d5a78..45fdeaa 100644 --- a/at_interface/configs/config_H3L_pidmode1.json +++ b/at_interface/configs/config_H3L_pidmode1.json @@ -19,15 +19,15 @@ }, "daughters" : [ { - "pdg_codes" : [2212], + "pdg_code" : [2212], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [-211], + "pdg_code" : [-211], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [1000010020], + "pdg_code" : [1000010020], "cuts" : {"chi2prim" : 10.0} } ], diff --git a/at_interface/configs/config_H3L_pidmode4.json b/at_interface/configs/config_H3L_pidmode4.json index b036dcd..e9193bd 100644 --- a/at_interface/configs/config_H3L_pidmode4.json +++ b/at_interface/configs/config_H3L_pidmode4.json @@ -7,7 +7,7 @@ }, "pid_mode" : 4, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) "pid_purity" : { - "default" : 0.5, + "all_pdgs" : 0.5, "protons" : 0.7, "pions" : 0.7, "kaons" : 0.7, @@ -27,15 +27,15 @@ }, "daughters" : [ { - "pdg_codes" : [2212], + "pdg_code" : [2212], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [-211], + "pdg_code" : [-211], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [1000010020], + "pdg_code" : [1000010020], "cuts" : {"chi2prim" : 10.0} } ], diff --git a/at_interface/configs/config_He5L_pidmode1.json b/at_interface/configs/config_He5L_pidmode1.json index 9c0dd0a..6af012b 100644 --- a/at_interface/configs/config_He5L_pidmode1.json +++ b/at_interface/configs/config_He5L_pidmode1.json @@ -20,15 +20,15 @@ }, "daughters" : [ { - "pdg_codes" : [1000020040], + "pdg_code" : [1000020040], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [-211], + "pdg_code" : [-211], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [2212], + "pdg_code" : [2212], "cuts" : {"chi2prim" : 18.42} } ], diff --git a/at_interface/configs/config_lambda_pidmode0.json b/at_interface/configs/config_lambda_pidmode0.json index 9dedd4c..410d932 100644 --- a/at_interface/configs/config_lambda_pidmode0.json +++ b/at_interface/configs/config_lambda_pidmode0.json @@ -19,11 +19,11 @@ }, "daughters" : [ { - "pdg_codes" : [-211, -1], + "pdg_code" : [-211, -1], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [2212, 1], + "pdg_code" : [2212, 1], "cuts" : {"chi2prim" : 18.42} } ] diff --git a/at_interface/configs/config_lambda_pidmode1_v1.json b/at_interface/configs/config_lambda_pidmode1_v1.json index 7be6cff..d1ce988 100644 --- a/at_interface/configs/config_lambda_pidmode1_v1.json +++ b/at_interface/configs/config_lambda_pidmode1_v1.json @@ -20,11 +20,11 @@ }, "daughters" : [ { - "pdg_codes" : [-211], + "pdg_code" : [-211], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [2212], + "pdg_code" : [2212], "cuts" : {"chi2prim" : 18.42} } ] diff --git a/at_interface/configs/config_lambda_pidmode1_v2.json b/at_interface/configs/config_lambda_pidmode1_v2.json index 3986e45..49174be 100644 --- a/at_interface/configs/config_lambda_pidmode1_v2.json +++ b/at_interface/configs/config_lambda_pidmode1_v2.json @@ -21,11 +21,11 @@ }, "daughters" : [ { - "pdg_codes" : [-211], + "pdg_code" : [-211], "cuts" : {"chi2prim" : 110.00} }, { - "pdg_codes" : [2212], + "pdg_code" : [2212], "cuts" : {"chi2prim" : 26.00, "cos" : 0.99825} } ] diff --git a/at_interface/configs/config_lambda_pidmode1_v3.json b/at_interface/configs/config_lambda_pidmode1_v3.json index c46e44f..39b2a3c 100644 --- a/at_interface/configs/config_lambda_pidmode1_v3.json +++ b/at_interface/configs/config_lambda_pidmode1_v3.json @@ -18,10 +18,10 @@ }, "daughters" : [ { - "pdg_codes" : [-211] + "pdg_code" : [-211] }, { - "pdg_codes" : [2212] + "pdg_code" : [2212] } ] } diff --git a/at_interface/configs/config_lambda_pidmode2.json b/at_interface/configs/config_lambda_pidmode2.json index 3b0d826..141adec 100644 --- a/at_interface/configs/config_lambda_pidmode2.json +++ b/at_interface/configs/config_lambda_pidmode2.json @@ -19,11 +19,11 @@ }, "daughters" : [ { - "pdg_codes" : [-211, -2], + "pdg_code" : [-211, -2], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [2212, 2], + "pdg_code" : [2212, 2], "cuts" : {"chi2prim" : 18.42} } ] diff --git a/at_interface/configs/config_omega_pidmode1.json b/at_interface/configs/config_omega_pidmode1.json index 25b5ee8..751e14c 100644 --- a/at_interface/configs/config_omega_pidmode1.json +++ b/at_interface/configs/config_omega_pidmode1.json @@ -23,11 +23,11 @@ }, "daughters" : [ { - "pdg_codes" : [-211, -1], + "pdg_code" : [-211, -1], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [2212, 1], + "pdg_code" : [2212, 1], "cuts" : {"chi2prim" : 18.42} } ] @@ -46,11 +46,11 @@ }, "daughters" : [ { - "pdg_codes" : [-321], + "pdg_code" : [-321], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [3122] + "pdg_code" : [3122] } ] } diff --git a/at_interface/configs/config_omegastar_pidmode1.json b/at_interface/configs/config_omegastar_pidmode1.json index fe40ff9..8278254 100644 --- a/at_interface/configs/config_omegastar_pidmode1.json +++ b/at_interface/configs/config_omegastar_pidmode1.json @@ -23,11 +23,11 @@ }, "daughters" : [ { - "pdg_codes" : [-211, -1], + "pdg_code" : [-211, -1], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [2212, 1], + "pdg_code" : [2212, 1], "cuts" : {"chi2prim" : 18.42} } ] @@ -47,11 +47,11 @@ }, "daughters" : [ { - "pdg_codes" : [-211, -1], + "pdg_code" : [-211, -1], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [3122] + "pdg_code" : [3122] } ] }, @@ -70,15 +70,15 @@ }, "daughters" : [ { - "pdg_codes" : [3312], + "pdg_code" : [3312], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [211], + "pdg_code" : [211], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [-321], + "pdg_code" : [-321], "cuts" : {"chi2prim" : 18.42} } ], diff --git a/at_interface/configs/config_dummy.json b/at_interface/configs/config_template.json similarity index 93% rename from at_interface/configs/config_dummy.json rename to at_interface/configs/config_template.json index 55146f5..3533598 100644 --- a/at_interface/configs/config_dummy.json +++ b/at_interface/configs/config_template.json @@ -10,7 +10,7 @@ "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) // for 2-4: Pid-framework needs to be applied first /* "pid_purity" : { // this block is only needed in pid_mode > 2 - "default" : 0.5, + "all_pdgs" : 0.5, "protons" : 0.7, "pions" : 0.7, "kaons" : 0.7, @@ -34,15 +34,15 @@ // "distPVline" : 0, // "invmass" : 0 }, - "save_options" : [/*"mass_constraint", "transport_to_pv", "do_not_write_mother"*/] + "save_options" : [/*"mass_constraint", "transport_to_pv", "do_not_save_mother"*/] }, "daughters" : [ { - "pdg_codes" : [-211], + "pdg_code" : [-211], "cuts" : {"chi2prim" : 18.42, /*"cos" : 0*/} }, { - "pdg_codes" : [2212], + "pdg_code" : [2212], "cuts" : {"chi2prim" : 18.42, /*"cos" : 0*/} } ], diff --git a/at_interface/configs/config_xi_pidmode1.json b/at_interface/configs/config_xi_pidmode1.json index 227c82e..4f1a124 100644 --- a/at_interface/configs/config_xi_pidmode1.json +++ b/at_interface/configs/config_xi_pidmode1.json @@ -23,11 +23,11 @@ }, "daughters" : [ { - "pdg_codes" : [-211, -1], + "pdg_code" : [-211, -1], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [2212, 1], + "pdg_code" : [2212, 1], "cuts" : {"chi2prim" : 18.42} } ] @@ -46,11 +46,11 @@ }, "daughters" : [ { - "pdg_codes" : [-211, -1], + "pdg_code" : [-211, -1], "cuts" : {"chi2prim" : 18.42} }, { - "pdg_codes" : [3122] + "pdg_code" : [3122] } ] } diff --git a/at_interface/main_json.cpp b/at_interface/main_json.cpp index b936d0f..2478d62 100644 --- a/at_interface/main_json.cpp +++ b/at_interface/main_json.cpp @@ -108,7 +108,7 @@ int main(int argc, char** argv) { auto daughters_cfg = decay_cfg["daughters"]; std::vector daughters; for (const auto& daughter_cfg : daughters_cfg) { - std::vector pdg_codes = daughter_cfg["pdg_codes"].get>(); + std::vector pdg_codes = daughter_cfg["pdg_code"].get>(); if (pdg_codes.size() > 1) daughters.emplace_back(Daughter(pdg_codes[0], pdg_codes)); @@ -162,7 +162,7 @@ int main(int argc, char** argv) { const auto& options = mother_cfg["save_options"]; if (LIST_CONTAINS(options, "mass_constraint")) decay.SetIsApplyMassConstraint(); if (LIST_CONTAINS(options, "transport_to_pv")) decay.SetIsTransportToPV(); - if (LIST_CONTAINS(options, "do_not_write_mother")) decay.SetIsDoNotWriteMother(); + if (LIST_CONTAINS(options, "do_not_save_mother")) decay.SetIsDoNotWriteMother(); } decays.push_back(decay); From 5237dcea174081fb628d11aa8d6061a8f1fddc91 Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Tue, 3 Jun 2025 14:00:36 +0200 Subject: [PATCH 16/21] Update configs --- README.md | 29 +++++----- at_interface/configs/config_H3L_pidmode1.json | 5 +- at_interface/configs/config_H3L_pidmode4.json | 9 ++-- .../configs/config_He5L_pidmode1.json | 3 +- .../config_lambda_k0short_pidmode1.json | 54 +++++++++++++++++++ .../configs/config_lambda_pidmode0.json | 1 + .../configs/config_lambda_pidmode1_v1.json | 1 + .../configs/config_lambda_pidmode1_v2.json | 1 + .../configs/config_lambda_pidmode1_v3.json | 1 + .../configs/config_lambda_pidmode2.json | 1 + .../configs/config_omega_pidmode1.json | 3 +- .../configs/config_omegastar_pidmode1.json | 5 +- at_interface/configs/config_xi_pidmode1.json | 3 +- 13 files changed, 91 insertions(+), 25 deletions(-) create mode 100644 at_interface/configs/config_lambda_k0short_pidmode1.json diff --git a/README.md b/README.md index af3079a..b4e237e 100644 --- a/README.md +++ b/README.md @@ -144,20 +144,21 @@ Cascade decays with multiple stages as well as combinations of 2- and 3-body-dec ## Example Configs Several example parameter files can be found in the folder `at_interface/configs`. -| File | Particle(s) | `pid_mode` | Comment | -|----------------------------------|--------------------|------------|--------------------------------------- | -| `config_template.json` | - | - | all available JSON fields listed | -| `config_lambda_pidmode1_v1.json` | Lambda | `1` | KFParticle cuts | -| `config_lambda_pidmode1_v2.json` | Lambda | `1` | optimized cuts | -| `config_lambda_pidmode0.json` | Lambda | `0` | | -| `config_lambda_pidmode2.json` | Lambda | `2` | | -| `config_lambda_pidmode1_v3.json` | Lambda | `1` | for machine learning applications | -| `config_H3L_pidmode1.json` | H3L | `1` | 3-body decay | -| `config_H3L_pidmode4.json` | H3L | `4` | 3-body decay, minimum purities applied | -| `config_He5L_pidmode1.json` | He5L | `1` | 3-body decay | -| `config_xi_pidmode1.json` | Xi, Lambda | `1` | cascade decay | -| `config_omega_pidmode1.json` | Omega, Lambda | `1` | cascade decay | -| `config_omegastar_pidmode1.json` | Omega*, Xi, Lambda | `1` | cascade decay, 3-body decay | +| File | Particle(s) | `pid_mode` | Comment | +|-------------------------------------- |--------------------|------------|--------------------------------------- | +| `config_template.json` | - | - | all available JSON fields listed | +| `config_lambda_pidmode1_v1.json` | Lambda | `1` | KFParticle cuts | +| `config_lambda_pidmode1_v2.json` | Lambda | `1` | optimized cuts | +| `config_lambda_pidmode0.json` | Lambda | `0` | | +| `config_lambda_pidmode2.json` | Lambda | `2` | | +| `config_lambda_pidmode1_v3.json` | Lambda | `1` | for machine learning applications | +| `config_H3L_pidmode1.json` | H3L | `1` | 3-body decay | +| `config_H3L_pidmode4.json` | H3L | `4` | 3-body decay, minimum purities applied | +| `config_He5L_pidmode1.json` | He5L | `1` | 3-body decay | +| `config_xi_pidmode1.json` | Xi, Lambda | `1` | cascade decay | +| `config_omega_pidmode1.json` | Omega, Lambda | `1` | cascade decay | +| `config_omegastar_pidmode1.json` | Omega*, Xi, Lambda | `1` | cascade decay, 3-body decay | +| `config_lambda_k0short_pidmode1.json` | Lambda, K0Short | `1` | | diff --git a/at_interface/configs/config_H3L_pidmode1.json b/at_interface/configs/config_H3L_pidmode1.json index 45fdeaa..e416329 100644 --- a/at_interface/configs/config_H3L_pidmode1.json +++ b/at_interface/configs/config_H3L_pidmode1.json @@ -6,6 +6,7 @@ "make_plain_tree" : true }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + // for 2-4: Pid-framework needs to be applied first "decays" : [ { "mother" : { @@ -14,7 +15,7 @@ "cuts" : { "LdL" : 10.0, "dist" : 0.2, - "distSV" : 0.2 + "distSV" : 0.2 //for 3-body decay } }, "daughters" : [ @@ -31,7 +32,7 @@ "cuts" : {"chi2prim" : 10.0} } ], - "secondary_mother_cuts" : { + "secondary_mother_cuts" : { // for 3-body decay // daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 "chi2geo" : [3.0], "chi2topo" : [2.0] diff --git a/at_interface/configs/config_H3L_pidmode4.json b/at_interface/configs/config_H3L_pidmode4.json index e9193bd..f2e31d5 100644 --- a/at_interface/configs/config_H3L_pidmode4.json +++ b/at_interface/configs/config_H3L_pidmode4.json @@ -5,8 +5,9 @@ "n_events" : -1, "make_plain_tree" : true }, - "pid_mode" : 4, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) - "pid_purity" : { + "pid_mode" : 4, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + // for 2-4: Pid-framework needs to be applied first + "pid_purity" : { // this block is only needed in pid_mode > 2 "all_pdgs" : 0.5, "protons" : 0.7, "pions" : 0.7, @@ -22,7 +23,7 @@ "cuts" : { "LdL" : 10.0, "dist" : 0.2, - "distSV" : 0.2 + "distSV" : 0.2 //for 3-body decay } }, "daughters" : [ @@ -39,7 +40,7 @@ "cuts" : {"chi2prim" : 10.0} } ], - "secondary_mother_cuts" : { + "secondary_mother_cuts" : { // for 3-body decay // daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 "chi2geo" : [3.0], "chi2topo" : [2.0] diff --git a/at_interface/configs/config_He5L_pidmode1.json b/at_interface/configs/config_He5L_pidmode1.json index 6af012b..2e1937e 100644 --- a/at_interface/configs/config_He5L_pidmode1.json +++ b/at_interface/configs/config_He5L_pidmode1.json @@ -6,6 +6,7 @@ "make_plain_tree" : true }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + // for 2-4: Pid-framework needs to be applied first "decays" : [ { "mother" : { @@ -32,7 +33,7 @@ "cuts" : {"chi2prim" : 18.42} } ], - "secondary_mother_cuts" : { + "secondary_mother_cuts" : { // for 3-body decay // daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 "chi2geo" : [3.0] } diff --git a/at_interface/configs/config_lambda_k0short_pidmode1.json b/at_interface/configs/config_lambda_k0short_pidmode1.json new file mode 100644 index 0000000..44198cf --- /dev/null +++ b/at_interface/configs/config_lambda_k0short_pidmode1.json @@ -0,0 +1,54 @@ +{ + "io" : { + "input_treename" : "rTree", + "rectracks_branchname" : "VtxTracks", + "n_events" : -1, + "make_plain_tree" : false + }, + "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + // for 2-4: Pid-framework needs to be applied first + "decays" : [ + { + "mother" : { + "name" : "Lambda", + "pdg_code" : 3122, + "cuts" : { + "dist" : 1, + "chi2geo" : 3, + "LdL" : 5 + } + }, + "daughters" : [ + { + "pdg_code" : [-211], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_code" : [2212], + "cuts" : {"chi2prim" : 18.42} + } + ] + }, + { + "mother" : { + "name" : "K0Short", + "pdg_code" : 310, + "cuts" : { + "dist" : 1, + "chi2geo" : 3, + "LdL" : 5 + } + }, + "daughters" : [ + { + "pdg_code" : [-211], + "cuts" : {"chi2prim" : 18.42} + }, + { + "pdg_code" : [211], + "cuts" : {"chi2prim" : 18.42} + } + ] + } + ] +} \ No newline at end of file diff --git a/at_interface/configs/config_lambda_pidmode0.json b/at_interface/configs/config_lambda_pidmode0.json index 410d932..83a02a8 100644 --- a/at_interface/configs/config_lambda_pidmode0.json +++ b/at_interface/configs/config_lambda_pidmode0.json @@ -6,6 +6,7 @@ "make_plain_tree" : true }, "pid_mode" : 0, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + // for 2-4: Pid-framework needs to be applied first "decays" : [ { "mother" : { diff --git a/at_interface/configs/config_lambda_pidmode1_v1.json b/at_interface/configs/config_lambda_pidmode1_v1.json index d1ce988..c3bd596 100644 --- a/at_interface/configs/config_lambda_pidmode1_v1.json +++ b/at_interface/configs/config_lambda_pidmode1_v1.json @@ -7,6 +7,7 @@ "make_plain_tree" : true }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + // for 2-4: Pid-framework needs to be applied first "decays" : [ { "mother" : { diff --git a/at_interface/configs/config_lambda_pidmode1_v2.json b/at_interface/configs/config_lambda_pidmode1_v2.json index 49174be..75c5997 100644 --- a/at_interface/configs/config_lambda_pidmode1_v2.json +++ b/at_interface/configs/config_lambda_pidmode1_v2.json @@ -7,6 +7,7 @@ "make_plain_tree" : true }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + // for 2-4: Pid-framework needs to be applied first "decays" : [ { "mother" : { diff --git a/at_interface/configs/config_lambda_pidmode1_v3.json b/at_interface/configs/config_lambda_pidmode1_v3.json index 39b2a3c..b323a3e 100644 --- a/at_interface/configs/config_lambda_pidmode1_v3.json +++ b/at_interface/configs/config_lambda_pidmode1_v3.json @@ -6,6 +6,7 @@ "make_plain_tree" : false }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + // for 2-4: Pid-framework needs to be applied first "decays" : [ { "mother" : { diff --git a/at_interface/configs/config_lambda_pidmode2.json b/at_interface/configs/config_lambda_pidmode2.json index 141adec..0014495 100644 --- a/at_interface/configs/config_lambda_pidmode2.json +++ b/at_interface/configs/config_lambda_pidmode2.json @@ -6,6 +6,7 @@ "make_plain_tree" : true }, "pid_mode" : 2, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + // for 2-4: Pid-framework needs to be applied first "decays" : [ { "mother" : { diff --git a/at_interface/configs/config_omega_pidmode1.json b/at_interface/configs/config_omega_pidmode1.json index 751e14c..889e277 100644 --- a/at_interface/configs/config_omega_pidmode1.json +++ b/at_interface/configs/config_omega_pidmode1.json @@ -6,7 +6,8 @@ "write_detailed_bg" : true, "make_plain_tree" : true }, - "pid_mode" : 1, + "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + // for 2-4: Pid-framework needs to be applied first "decays" : [ { "mother" : { diff --git a/at_interface/configs/config_omegastar_pidmode1.json b/at_interface/configs/config_omegastar_pidmode1.json index 8278254..4cf46d2 100644 --- a/at_interface/configs/config_omegastar_pidmode1.json +++ b/at_interface/configs/config_omegastar_pidmode1.json @@ -6,7 +6,8 @@ "write_detailed_bg" : true, "make_plain_tree" : true }, - "pid_mode" : 1, + "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + // for 2-4: Pid-framework needs to be applied first "decays" : [ { "mother" : { @@ -82,7 +83,7 @@ "cuts" : {"chi2prim" : 18.42} } ], - "secondary_mother_cuts" : { + "secondary_mother_cuts" : { // for 3-body decay //daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 "chi2geo" : [3.0] } diff --git a/at_interface/configs/config_xi_pidmode1.json b/at_interface/configs/config_xi_pidmode1.json index 4f1a124..674d60d 100644 --- a/at_interface/configs/config_xi_pidmode1.json +++ b/at_interface/configs/config_xi_pidmode1.json @@ -6,7 +6,8 @@ "write_detailed_bg" : true, "make_plain_tree" : true }, - "pid_mode" : 1, + "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + // for 2-4: Pid-framework needs to be applied first "decays" : [ { "mother" : { From 7b08969a4e2ba70aea2c86584386754ca7da9b81 Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Tue, 3 Jun 2025 16:18:08 +0200 Subject: [PATCH 17/21] Changed style of saving options in io block --- README.md | 20 +++++++------ at_interface/configs/config_H3L_pidmode1.json | 2 +- at_interface/configs/config_H3L_pidmode4.json | 2 +- .../configs/config_He5L_pidmode1.json | 2 +- .../config_lambda_k0short_pidmode1.json | 3 +- .../configs/config_lambda_pidmode0.json | 2 +- .../configs/config_lambda_pidmode1_v1.json | 2 +- .../configs/config_lambda_pidmode1_v2.json | 2 +- .../configs/config_lambda_pidmode1_v3.json | 3 +- .../configs/config_lambda_pidmode2.json | 2 +- .../configs/config_omega_pidmode1.json | 3 +- .../configs/config_omegastar_pidmode1.json | 3 +- at_interface/configs/config_template.json | 2 +- at_interface/configs/config_xi_pidmode1.json | 3 +- at_interface/main_json.cpp | 28 +++++++++++-------- 15 files changed, 41 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index b4e237e..38c54e9 100644 --- a/README.md +++ b/README.md @@ -53,14 +53,18 @@ make -j install The program is configured with a JSON config file which contains various settings related to input and output as well as the decays to reconstruct. In the following, the different blocks and fields are explained. In `at_interface/config/config_template.json` all available JSON fields are listed. ### io -| Key | Description | -| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `input_treename` | name of the input AnalysisTree (for standard analysistree `rTree`, after running PID framework `pTree`) | -| `rectracks_branchname` | branchname of reconstructed tracks in input analysistree, default names: `VtxTracks` for standard analyistree, `RecParticles` after running Pid-framework | -| `n_events` | number of events to be processed, set to `-1` to process all events | -| `make_plain_tree` (optional) | normal root tree containing the candidates is written besides the default output tree in AnalysisTree format | -| `save_signal_only` (optional) | save only mc-true signal candidates | -| `write_detailed_bg` (optional) | detailed background information in output variable `generation`* | +| Key | Description | +| --------------------------| --------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `input_treename` | name of the input AnalysisTree (for standard analysistree `rTree`, after running PID framework `pTree`) | +| `rectracks_branchname` | branchname of reconstructed tracks in input analysistree, default names: `VtxTracks` for standard analyistree, `RecParticles` after running Pid-framework | +| `n_events` | number of events to be processed, set to `-1` to process all events | +| `save_options` (optional) | defines save options for the candidates of all decays in this config (see next table) | + +| `save_options` Flag | Description | +| --------------------------| --------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `make_plain_tree` | normal root tree containing the candidates is written besides the default output tree in AnalysisTree format | +| `signal_only` | save only mc-true signal candidates | +| `write_detailed_bg` | detailed background information in output variable `generation`* | *Format of detailed background information in the `generation` variable: diff --git a/at_interface/configs/config_H3L_pidmode1.json b/at_interface/configs/config_H3L_pidmode1.json index e416329..ef1c08b 100644 --- a/at_interface/configs/config_H3L_pidmode1.json +++ b/at_interface/configs/config_H3L_pidmode1.json @@ -3,7 +3,7 @@ "input_treename" : "pTree", "rectracks_branchname" : "RecTracks", "n_events" : -1, - "make_plain_tree" : true + "save_options": ["make_plain_tree"] }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) // for 2-4: Pid-framework needs to be applied first diff --git a/at_interface/configs/config_H3L_pidmode4.json b/at_interface/configs/config_H3L_pidmode4.json index f2e31d5..92a211b 100644 --- a/at_interface/configs/config_H3L_pidmode4.json +++ b/at_interface/configs/config_H3L_pidmode4.json @@ -3,7 +3,7 @@ "input_treename" : "pTree", "rectracks_branchname" : "RecTracks", "n_events" : -1, - "make_plain_tree" : true + "save_options": ["make_plain_tree"] }, "pid_mode" : 4, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) // for 2-4: Pid-framework needs to be applied first diff --git a/at_interface/configs/config_He5L_pidmode1.json b/at_interface/configs/config_He5L_pidmode1.json index 2e1937e..dfd44bd 100644 --- a/at_interface/configs/config_He5L_pidmode1.json +++ b/at_interface/configs/config_He5L_pidmode1.json @@ -3,7 +3,7 @@ "input_treename" : "pTree", "rectracks_branchname" : "RecTracks", "n_events" : -1, - "make_plain_tree" : true + "save_options": ["make_plain_tree"] }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) // for 2-4: Pid-framework needs to be applied first diff --git a/at_interface/configs/config_lambda_k0short_pidmode1.json b/at_interface/configs/config_lambda_k0short_pidmode1.json index 44198cf..ab6b164 100644 --- a/at_interface/configs/config_lambda_k0short_pidmode1.json +++ b/at_interface/configs/config_lambda_k0short_pidmode1.json @@ -2,8 +2,7 @@ "io" : { "input_treename" : "rTree", "rectracks_branchname" : "VtxTracks", - "n_events" : -1, - "make_plain_tree" : false + "n_events" : -1 }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) // for 2-4: Pid-framework needs to be applied first diff --git a/at_interface/configs/config_lambda_pidmode0.json b/at_interface/configs/config_lambda_pidmode0.json index 83a02a8..bf0f27c 100644 --- a/at_interface/configs/config_lambda_pidmode0.json +++ b/at_interface/configs/config_lambda_pidmode0.json @@ -3,7 +3,7 @@ "input_treename" : "rTree", "rectracks_branchname" : "VtxTracks", "n_events" : -1, - "make_plain_tree" : true + "save_options": ["make_plain_tree"] }, "pid_mode" : 0, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) // for 2-4: Pid-framework needs to be applied first diff --git a/at_interface/configs/config_lambda_pidmode1_v1.json b/at_interface/configs/config_lambda_pidmode1_v1.json index c3bd596..7c57b14 100644 --- a/at_interface/configs/config_lambda_pidmode1_v1.json +++ b/at_interface/configs/config_lambda_pidmode1_v1.json @@ -4,7 +4,7 @@ "input_treename" : "rTree", "rectracks_branchname" : "VtxTracks", "n_events" : -1, - "make_plain_tree" : true + "save_options": ["make_plain_tree"] }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) // for 2-4: Pid-framework needs to be applied first diff --git a/at_interface/configs/config_lambda_pidmode1_v2.json b/at_interface/configs/config_lambda_pidmode1_v2.json index 75c5997..c6b3481 100644 --- a/at_interface/configs/config_lambda_pidmode1_v2.json +++ b/at_interface/configs/config_lambda_pidmode1_v2.json @@ -4,7 +4,7 @@ "input_treename" : "rTree", "rectracks_branchname" : "VtxTracks", "n_events" : -1, - "make_plain_tree" : true + "save_options": ["make_plain_tree"] }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) // for 2-4: Pid-framework needs to be applied first diff --git a/at_interface/configs/config_lambda_pidmode1_v3.json b/at_interface/configs/config_lambda_pidmode1_v3.json index b323a3e..8064686 100644 --- a/at_interface/configs/config_lambda_pidmode1_v3.json +++ b/at_interface/configs/config_lambda_pidmode1_v3.json @@ -2,8 +2,7 @@ "io" : { "input_treename" : "rTree", "rectracks_branchname" : "VtxTracks", - "n_events" : -1, - "make_plain_tree" : false + "n_events" : -1 }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) // for 2-4: Pid-framework needs to be applied first diff --git a/at_interface/configs/config_lambda_pidmode2.json b/at_interface/configs/config_lambda_pidmode2.json index 0014495..3c5cbbb 100644 --- a/at_interface/configs/config_lambda_pidmode2.json +++ b/at_interface/configs/config_lambda_pidmode2.json @@ -3,7 +3,7 @@ "input_treename" : "pTree", "rectracks_branchname" : "RecTracks", "n_events" : -1, - "make_plain_tree" : true + "save_options": ["make_plain_tree"] }, "pid_mode" : 2, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) // for 2-4: Pid-framework needs to be applied first diff --git a/at_interface/configs/config_omega_pidmode1.json b/at_interface/configs/config_omega_pidmode1.json index 889e277..6c402b0 100644 --- a/at_interface/configs/config_omega_pidmode1.json +++ b/at_interface/configs/config_omega_pidmode1.json @@ -3,8 +3,7 @@ "input_treename" : "rTree", "rectracks_branchname" : "VtxTracks", "n_events" : -1, - "write_detailed_bg" : true, - "make_plain_tree" : true + "save_options": ["make_plain_tree", "write_detailed_bg"] }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) // for 2-4: Pid-framework needs to be applied first diff --git a/at_interface/configs/config_omegastar_pidmode1.json b/at_interface/configs/config_omegastar_pidmode1.json index 4cf46d2..6172297 100644 --- a/at_interface/configs/config_omegastar_pidmode1.json +++ b/at_interface/configs/config_omegastar_pidmode1.json @@ -3,8 +3,7 @@ "input_treename" : "rTree", "rectracks_branchname" : "VtxTracks", "n_events" : -1, - "write_detailed_bg" : true, - "make_plain_tree" : true + "save_options": ["make_plain_tree", "write_detailed_bg"] }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) // for 2-4: Pid-framework needs to be applied first diff --git a/at_interface/configs/config_template.json b/at_interface/configs/config_template.json index 3533598..1d432d5 100644 --- a/at_interface/configs/config_template.json +++ b/at_interface/configs/config_template.json @@ -5,7 +5,7 @@ "n_events" : -1, "write_detailed_bg" : true, "make_plain_tree" : true, - "save_signal_only" : false + "save_options": ["make_plain_tree", "write_detailed_bg" /*, "signal_only"*/] }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) // for 2-4: Pid-framework needs to be applied first diff --git a/at_interface/configs/config_xi_pidmode1.json b/at_interface/configs/config_xi_pidmode1.json index 674d60d..495768b 100644 --- a/at_interface/configs/config_xi_pidmode1.json +++ b/at_interface/configs/config_xi_pidmode1.json @@ -3,8 +3,7 @@ "input_treename" : "rTree", "rectracks_branchname" : "VtxTracks", "n_events" : -1, - "write_detailed_bg" : true, - "make_plain_tree" : true + "save_options": ["make_plain_tree", "write_detailed_bg"] }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) // for 2-4: Pid-framework needs to be applied first diff --git a/at_interface/main_json.cpp b/at_interface/main_json.cpp index 2478d62..4c27f5b 100644 --- a/at_interface/main_json.cpp +++ b/at_interface/main_json.cpp @@ -160,8 +160,8 @@ int main(int argc, char** argv) { if (mother_cfg.contains("save_options")) { const auto& options = mother_cfg["save_options"]; - if (LIST_CONTAINS(options, "mass_constraint")) decay.SetIsApplyMassConstraint(); - if (LIST_CONTAINS(options, "transport_to_pv")) decay.SetIsTransportToPV(); + if (LIST_CONTAINS(options, "mass_constraint")) decay.SetIsApplyMassConstraint(); + if (LIST_CONTAINS(options, "transport_to_pv")) decay.SetIsTransportToPV(); if (LIST_CONTAINS(options, "do_not_save_mother")) decay.SetIsDoNotWriteMother(); } @@ -191,7 +191,7 @@ int main(int argc, char** argv) { out_converter->SetSimTracksName("SimParticles"); out_converter->SetPFSimpleTask(pf_task); out_converter->SetDecays(decays); - if (config["io"].contains("write_detailed_bg")) out_converter->SetIsWriteDetailedBG(config["io"]["write_detailed_bg"]); + if(LIST_CONTAINS(config["io"]["save_options"], "write_detailed_bg")) out_converter->SetIsWriteDetailedBG(true); std::vector vec_output_cuts = {}; if (config.contains("output_cuts")) @@ -204,7 +204,7 @@ int main(int argc, char** argv) { } } - if (config["io"].contains("save_signal_only") && config["io"]["save_signal_only"]) + if(LIST_CONTAINS(config["io"]["save_options"], "signal_only")) vec_output_cuts.push_back(AnalysisTree::SimpleCut({"Candidates.generation"}, []( std::vector& var ) { return var.at(0) != 0; })); if (vec_output_cuts.size() > 0) @@ -223,7 +223,7 @@ int main(int argc, char** argv) { man->Finish(); man->ClearTasks(); - if (config["io"].contains("make_plain_tree") && config["io"]["make_plain_tree"]) { + if(LIST_CONTAINS(config["io"]["save_options"], "make_plain_tree")) { std::ofstream filelist; filelist.open("filelist.txt"); filelist << output_file; @@ -248,7 +248,10 @@ int main(int argc, char** argv) { } -/* Function to overide a value inside the json config, e.g. decays[0].mother.cuts.LdL=4.0 */ +/* +Function to overide a value inside the json config, e.g. decays[0].mother.cuts.LdL=4.0 +Command line argument usage example for lists: --set 'io.save_options=["signal_only"]' +*/ void set_json_value(json& config, const std::string& path, const std::string& value) { std::cout << "[DEBUG] Setting " << path << " to " << value << std::endl; @@ -261,13 +264,11 @@ void set_json_value(json& config, const std::string& path, const std::string& va for (auto it = tokens_begin; it != tokens_end; ++it) { std::string key = (*it)[1]; std::string index_str = (*it)[2]; - bool is_last = (std::next(it) == tokens_end); if (!index_str.empty()) { - // Key points to an array + // Handle arrays int index = std::stoi(index_str); - if (!(*current)[key].is_array()) { (*current)[key] = json::array(); } @@ -277,13 +278,14 @@ void set_json_value(json& config, const std::string& path, const std::string& va } if (is_last) { - // Set value at the array element json& target = (*current)[key][index]; try { if (value == "true" || value == "false") { target = (value == "true"); } else if (value == "null") { - target = nlohmann::json(); + target = json(); + } else if (!value.empty() && value.front() == '[' && value.back() == ']') { + target = json::parse(value); // Parse list } else if (value.find('.') != std::string::npos) { target = std::stod(value); } else { @@ -303,7 +305,9 @@ void set_json_value(json& config, const std::string& path, const std::string& va if (value == "true" || value == "false") { target = (value == "true"); } else if (value == "null") { - target = nlohmann::json(); + target = json(); + } else if (!value.empty() && value.front() == '[' && value.back() == ']') { + target = json::parse(value); // Parse list } else if (value.find('.') != std::string::npos) { target = std::stod(value); } else { From a5d81a7be522d9a536f2dd7159dcf329254d0a10 Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Thu, 5 Jun 2025 16:52:12 +0200 Subject: [PATCH 18/21] Beautify template config --- at_interface/configs/config_template.json | 76 +++++++++++------------ 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/at_interface/configs/config_template.json b/at_interface/configs/config_template.json index 1d432d5..7895797 100644 --- a/at_interface/configs/config_template.json +++ b/at_interface/configs/config_template.json @@ -1,59 +1,57 @@ { "io" : { - "input_treename" : "rTree", // set to pTree in pid_mode > 2 - "rectracks_branchname" : "VtxTracks", // set to RecTracks in pid_mode > 2 + "input_treename" : "name_tree", // "rTree" for standard analysistree, "pTree" after running PID-framework (for pid_mode > 2) + "rectracks_branchname" : "name_tracks", // "VtxTracks" for standard analyistree, "RecParticles" after running Pid-framework (for pid_mode > 2) "n_events" : -1, - "write_detailed_bg" : true, - "make_plain_tree" : true, - "save_options": ["make_plain_tree", "write_detailed_bg" /*, "signal_only"*/] + "save_options": ["make_plain_tree", "write_detailed_bg" , "signal_only"] + }, + "pid_mode" : number, // pid_mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) + // for pid_mode 2-4: Pid-framework needs to be applied first! + "pid_purity" : { // this block is only needed in pid_mode > 2 + "all_pdgs" : purity_value, + "protons" : purity_value, + "pions" : purity_value, + "kaons" : purity_value, + "deuterons" : purity_value, + "background" : purity_value }, - "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) - // for 2-4: Pid-framework needs to be applied first -/* "pid_purity" : { // this block is only needed in pid_mode > 2 - "all_pdgs" : 0.5, - "protons" : 0.7, - "pions" : 0.7, - "kaons" : 0.7, - "deuterons" : 0.2, - "background" : 0.7 - },*/ "decays" : [ { "mother" : { - "name" : "Lambda", - "pdg_code" : 3122, + "name" : "mother_name", + "pdg_code" : mother_pdg, "cuts" : { - "dist" : 1.0, -// "distSV" : 0, //for 3-body decay - "chi2geo" : 3.0, -// "cosopen" : 0, - "chi2topo" : 5.0, -// "costopo" : 0, - "LdL" : 10.0, -// "L" : 0 -// "distPVline" : 0, -// "invmass" : 0 + "dist" : cut_value, + "distSV" : cut_value, //for 3-body decay only + "chi2geo" : cut_value, + "cosopen" : cut_value, + "chi2topo" : cut_value, + "costopo" : cut_value, + "LdL" : cut_value, + "L" : cut_value, + "distPVline" : cut_value, + "invmass" : cut_value }, - "save_options" : [/*"mass_constraint", "transport_to_pv", "do_not_save_mother"*/] + "save_options" : ["mass_constraint", "transport_to_pv", "do_not_save_mother"] }, "daughters" : [ { - "pdg_code" : [-211], - "cuts" : {"chi2prim" : 18.42, /*"cos" : 0*/} + "pdg_code" : [daughter_1_pdg], + "cuts" : {"chi2prim" : cut_value, "cos" : cut_value} }, { - "pdg_code" : [2212], - "cuts" : {"chi2prim" : 18.42, /*"cos" : 0*/} + "pdg_code" : [daughter_2_pdg], + "cuts" : {"chi2prim" : cut_value, "cos" : cut_value} } ], -/* "secondary_mother_cuts" : { // for 3-body decay - // daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 - "chi2geo" : [3.0], - "cosopen" : [0.2, 0.3, 0.3], - "chi2topo" : [3.0, 2.0], - "costopo" : [0.1] + "secondary_mother_cuts" : { // for 3-body decay only + // up to 3 entries for: daugher 1 & 2, daughter 1 & 3, daughter 2 & 3 + "chi2geo" : [cut_value, cut_value, cut_value], + "cosopen" : [cut_value, cut_value, cut_value], + "chi2topo" : [cut_value, cut_value, cut_value], + "costopo" : [cut_value, cut_value, cut_value] } -*/ + } //add more decays to this list if needed... ] From 9c2300012d1738624eacfca5dc084f6b59db9e70 Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Wed, 18 Jun 2025 10:49:58 +0200 Subject: [PATCH 19/21] Update configs --- at_interface/configs/config_H3L_pidmode1.json | 4 ++-- at_interface/configs/config_H3L_pidmode4.json | 4 ++-- at_interface/configs/config_He5L_pidmode1.json | 4 ++-- .../configs/config_lambda_k0short_pidmode1.json | 4 ++-- at_interface/configs/config_lambda_pidmode0.json | 4 ++-- .../configs/config_lambda_pidmode1_v1.json | 4 ++-- .../configs/config_lambda_pidmode1_v2.json | 4 ++-- .../configs/config_lambda_pidmode1_v3.json | 15 +++++++++++---- at_interface/configs/config_lambda_pidmode2.json | 4 ++-- at_interface/configs/config_omega_pidmode1.json | 4 ++-- .../configs/config_omegastar_pidmode1.json | 4 ++-- at_interface/configs/config_template.json | 4 ++++ at_interface/configs/config_xi_pidmode1.json | 4 ++-- 13 files changed, 37 insertions(+), 26 deletions(-) diff --git a/at_interface/configs/config_H3L_pidmode1.json b/at_interface/configs/config_H3L_pidmode1.json index ef1c08b..ca19a44 100644 --- a/at_interface/configs/config_H3L_pidmode1.json +++ b/at_interface/configs/config_H3L_pidmode1.json @@ -1,7 +1,7 @@ { "io" : { - "input_treename" : "pTree", - "rectracks_branchname" : "RecTracks", + "input_treename" : "pTree", // "rTree" for standard analysistree, "pTree" after running PID-framework (for pid_mode > 2) + "rectracks_branchname" : "RecTracks", // "VtxTracks" for standard analyistree, "RecParticles" after running Pid-framework (for pid_mode > 2) "n_events" : -1, "save_options": ["make_plain_tree"] }, diff --git a/at_interface/configs/config_H3L_pidmode4.json b/at_interface/configs/config_H3L_pidmode4.json index 92a211b..fb7e410 100644 --- a/at_interface/configs/config_H3L_pidmode4.json +++ b/at_interface/configs/config_H3L_pidmode4.json @@ -1,7 +1,7 @@ { "io" : { - "input_treename" : "pTree", - "rectracks_branchname" : "RecTracks", + "input_treename" : "pTree", // "rTree" for standard analysistree, "pTree" after running PID-framework (for pid_mode > 2) + "rectracks_branchname" : "RecTracks", // "VtxTracks" for standard analyistree, "RecParticles" after running Pid-framework (for pid_mode > 2) "n_events" : -1, "save_options": ["make_plain_tree"] }, diff --git a/at_interface/configs/config_He5L_pidmode1.json b/at_interface/configs/config_He5L_pidmode1.json index dfd44bd..c11436b 100644 --- a/at_interface/configs/config_He5L_pidmode1.json +++ b/at_interface/configs/config_He5L_pidmode1.json @@ -1,7 +1,7 @@ { "io" : { - "input_treename" : "pTree", - "rectracks_branchname" : "RecTracks", + "input_treename" : "pTree", // "rTree" for standard analysistree, "pTree" after running PID-framework (for pid_mode > 2) + "rectracks_branchname" : "RecTracks", // "VtxTracks" for standard analyistree, "RecParticles" after running Pid-framework (for pid_mode > 2) "n_events" : -1, "save_options": ["make_plain_tree"] }, diff --git a/at_interface/configs/config_lambda_k0short_pidmode1.json b/at_interface/configs/config_lambda_k0short_pidmode1.json index ab6b164..6a29296 100644 --- a/at_interface/configs/config_lambda_k0short_pidmode1.json +++ b/at_interface/configs/config_lambda_k0short_pidmode1.json @@ -1,7 +1,7 @@ { "io" : { - "input_treename" : "rTree", - "rectracks_branchname" : "VtxTracks", + "input_treename" : "rTree", // "rTree" for standard analysistree, "pTree" after running PID-framework (for pid_mode > 2) + "rectracks_branchname" : "VtxTracks", // "VtxTracks" for standard analyistree, "RecParticles" after running Pid-framework (for pid_mode > 2) "n_events" : -1 }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) diff --git a/at_interface/configs/config_lambda_pidmode0.json b/at_interface/configs/config_lambda_pidmode0.json index bf0f27c..a38f553 100644 --- a/at_interface/configs/config_lambda_pidmode0.json +++ b/at_interface/configs/config_lambda_pidmode0.json @@ -1,7 +1,7 @@ { "io" : { - "input_treename" : "rTree", - "rectracks_branchname" : "VtxTracks", + "input_treename" : "rTree", // "rTree" for standard analysistree, "pTree" after running PID-framework (for pid_mode > 2) + "rectracks_branchname" : "VtxTracks", // "VtxTracks" for standard analyistree, "RecParticles" after running Pid-framework (for pid_mode > 2) "n_events" : -1, "save_options": ["make_plain_tree"] }, diff --git a/at_interface/configs/config_lambda_pidmode1_v1.json b/at_interface/configs/config_lambda_pidmode1_v1.json index 7c57b14..e8174e2 100644 --- a/at_interface/configs/config_lambda_pidmode1_v1.json +++ b/at_interface/configs/config_lambda_pidmode1_v1.json @@ -1,8 +1,8 @@ //(Lambda pid 1, cuts from KFParticle) { "io" : { - "input_treename" : "rTree", - "rectracks_branchname" : "VtxTracks", + "input_treename" : "rTree", // "rTree" for standard analysistree, "pTree" after running PID-framework (for pid_mode > 2) + "rectracks_branchname" : "VtxTracks", // "VtxTracks" for standard analyistree, "RecParticles" after running Pid-framework (for pid_mode > 2) "n_events" : -1, "save_options": ["make_plain_tree"] }, diff --git a/at_interface/configs/config_lambda_pidmode1_v2.json b/at_interface/configs/config_lambda_pidmode1_v2.json index c6b3481..1332a26 100644 --- a/at_interface/configs/config_lambda_pidmode1_v2.json +++ b/at_interface/configs/config_lambda_pidmode1_v2.json @@ -1,8 +1,8 @@ //(Lambda pid 1, cuts optimized) { "io" : { - "input_treename" : "rTree", - "rectracks_branchname" : "VtxTracks", + "input_treename" : "rTree", // "rTree" for standard analysistree, "pTree" after running PID-framework (for pid_mode > 2) + "rectracks_branchname" : "VtxTracks", // "VtxTracks" for standard analyistree, "RecParticles" after running Pid-framework (for pid_mode > 2) "n_events" : -1, "save_options": ["make_plain_tree"] }, diff --git a/at_interface/configs/config_lambda_pidmode1_v3.json b/at_interface/configs/config_lambda_pidmode1_v3.json index 8064686..5d982fb 100644 --- a/at_interface/configs/config_lambda_pidmode1_v3.json +++ b/at_interface/configs/config_lambda_pidmode1_v3.json @@ -1,8 +1,9 @@ { "io" : { - "input_treename" : "rTree", - "rectracks_branchname" : "VtxTracks", - "n_events" : -1 + "input_treename" : "rTree", // "rTree" for standard analysistree, "pTree" after running PID-framework (for pid_mode > 2) + "rectracks_branchname" : "VtxTracks", // "VtxTracks" for standard analyistree, "RecParticles" after running Pid-framework (for pid_mode > 2) + "n_events" : -1, + "save_options": ["signal_only"] }, "pid_mode" : 1, // pid mode: =0: no pid; =1: mc pid; =2: rec pid (default); =3: rec pid (max. purity & purity > min. purity); =4 (purity > min. purity) // for 2-4: Pid-framework needs to be applied first @@ -27,6 +28,12 @@ } ], "output_cuts" : [ - {"var" : "generation", "from" : 0.9, "to" : 1000} + {"var" : "mass", "from" : 1.07, "to" : 1.2}, + {"var" : "x", "from" : -50, "to" : 50}, + {"var" : "y", "from" : -50, "to" : 50}, + {"var" : "distance", "from" : 0, "to" : 100}, + {"var" : "eta", "from" : 1, "to" : 6.5}, + {"var" : "chi2_topo", "from" : 0, "to" : 100000}, + {"var" : "chi2_geo", "from" : 0, "to" : 1000} ] } \ No newline at end of file diff --git a/at_interface/configs/config_lambda_pidmode2.json b/at_interface/configs/config_lambda_pidmode2.json index 3c5cbbb..f73fc69 100644 --- a/at_interface/configs/config_lambda_pidmode2.json +++ b/at_interface/configs/config_lambda_pidmode2.json @@ -1,7 +1,7 @@ { "io" : { - "input_treename" : "pTree", - "rectracks_branchname" : "RecTracks", + "input_treename" : "pTree", // "rTree" for standard analysistree, "pTree" after running PID-framework (for pid_mode > 2) + "rectracks_branchname" : "RecTracks", // "VtxTracks" for standard analyistree, "RecParticles" after running Pid-framework (for pid_mode > 2) "n_events" : -1, "save_options": ["make_plain_tree"] }, diff --git a/at_interface/configs/config_omega_pidmode1.json b/at_interface/configs/config_omega_pidmode1.json index 6c402b0..26c1efe 100644 --- a/at_interface/configs/config_omega_pidmode1.json +++ b/at_interface/configs/config_omega_pidmode1.json @@ -1,7 +1,7 @@ { "io" : { - "input_treename" : "rTree", - "rectracks_branchname" : "VtxTracks", + "input_treename" : "rTree", // "rTree" for standard analysistree, "pTree" after running PID-framework (for pid_mode > 2) + "rectracks_branchname" : "VtxTracks", // "VtxTracks" for standard analyistree, "RecParticles" after running Pid-framework (for pid_mode > 2) "n_events" : -1, "save_options": ["make_plain_tree", "write_detailed_bg"] }, diff --git a/at_interface/configs/config_omegastar_pidmode1.json b/at_interface/configs/config_omegastar_pidmode1.json index 6172297..787444c 100644 --- a/at_interface/configs/config_omegastar_pidmode1.json +++ b/at_interface/configs/config_omegastar_pidmode1.json @@ -1,7 +1,7 @@ { "io" : { - "input_treename" : "rTree", - "rectracks_branchname" : "VtxTracks", + "input_treename" : "rTree", // "rTree" for standard analysistree, "pTree" after running PID-framework (for pid_mode > 2) + "rectracks_branchname" : "VtxTracks", // "VtxTracks" for standard analyistree, "RecParticles" after running Pid-framework (for pid_mode > 2) "n_events" : -1, "save_options": ["make_plain_tree", "write_detailed_bg"] }, diff --git a/at_interface/configs/config_template.json b/at_interface/configs/config_template.json index 7895797..b2dc4f5 100644 --- a/at_interface/configs/config_template.json +++ b/at_interface/configs/config_template.json @@ -54,5 +54,9 @@ } //add more decays to this list if needed... + ], + "output_cuts" : [ + {"var" : "x", "from" : cut_value1, "to" : cut_value2}, + {"var" : "y", "from" : cut_value1, "to" : cut_value2} ] } \ No newline at end of file diff --git a/at_interface/configs/config_xi_pidmode1.json b/at_interface/configs/config_xi_pidmode1.json index 495768b..6f5238a 100644 --- a/at_interface/configs/config_xi_pidmode1.json +++ b/at_interface/configs/config_xi_pidmode1.json @@ -1,7 +1,7 @@ { "io" : { - "input_treename" : "rTree", - "rectracks_branchname" : "VtxTracks", + "input_treename" : "rTree", // "rTree" for standard analysistree, "pTree" after running PID-framework (for pid_mode > 2) + "rectracks_branchname" : "VtxTracks", // "VtxTracks" for standard analyistree, "RecParticles" after running Pid-framework (for pid_mode > 2) "n_events" : -1, "save_options": ["make_plain_tree", "write_detailed_bg"] }, From 29ee40bdf6b232794cd03636dfb0411ee3649df0 Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Wed, 25 Jun 2025 10:51:20 +0200 Subject: [PATCH 20/21] Add root include directories to main_json --- at_interface/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/at_interface/CMakeLists.txt b/at_interface/CMakeLists.txt index 9591d4f..fb94d78 100644 --- a/at_interface/CMakeLists.txt +++ b/at_interface/CMakeLists.txt @@ -29,6 +29,7 @@ target_link_libraries(main KFMan KFParticleSimple KFParticleInterface KFParticle add_executable(main_json main_json.cpp) add_dependencies(main_json KFMan) add_target_property(main_json COMPILE_FLAGS "-DDO_TPCCATRACKER_EFF_PERFORMANCE -DNonhomogeneousField -DCBM -DUSE_TIMERS") +target_include_directories(main_json PRIVATE ${ROOT_INCLUDE_DIRS}) target_link_libraries(main_json KFMan KFParticleSimple KFParticleInterface KFParticle Vc) install(TARGETS KFMan EXPORT KFManTargets From 5fbf7546060f0f78433ed08049e443d714abf28b Mon Sep 17 00:00:00 2001 From: Axel Puntke Date: Wed, 25 Jun 2025 10:54:18 +0200 Subject: [PATCH 21/21] Clang format --- src/Daughter.hpp | 2 +- src/Decay.hpp | 12 +-- src/Mother.cpp | 8 +- src/Mother.hpp | 19 +++-- src/SimpleFinder.cpp | 169 ++++++++++++++++++++----------------------- src/SimpleFinder.hpp | 15 ++-- 6 files changed, 108 insertions(+), 117 deletions(-) diff --git a/src/Daughter.hpp b/src/Daughter.hpp index ea703e0..802a06a 100644 --- a/src/Daughter.hpp +++ b/src/Daughter.hpp @@ -27,7 +27,7 @@ class Daughter { float GetCutChi2Prim() const { return chi2_prim_; } float GetCutCos() const { return cos_; } int GetId() const { return id_; } - + void SetGeneration(int generation) { generation_ = generation; } void SetCutChi2Prim(float value) { chi2_prim_ = value; } void SetCutCos(float value) { cos_ = value; } diff --git a/src/Decay.hpp b/src/Decay.hpp index d43d180..95336c8 100644 --- a/src/Decay.hpp +++ b/src/Decay.hpp @@ -1,11 +1,11 @@ #ifndef KFPARTICLESIMPLE_KFSIMPLE_DECAY_HPP_ #define KFPARTICLESIMPLE_KFSIMPLE_DECAY_HPP_ +#include #include #include #include #include -#include #include "Daughter.hpp" #include "Mother.hpp" @@ -46,14 +46,14 @@ class Decay { void SetMother(const Mother& mother) { mother_ = mother; } int GetNDaughters() const { return daughters_.size(); } - + void SetIsApplyMassConstraint(bool is = true) { is_apply_mass_constraint_ = is; } void SetIsTransportToPV(bool is = true) { is_transport_to_pv_ = is; } void SetIsDoNotWriteMother(bool is = true) { - std::cout << "WARNING!! If the mother particle is not written in the output-tree, MC-matching is not possible for upper-level mothers from cascade decays. "<< std::endl; - is_do_not_write_mother_ = is; + std::cout << "WARNING!! If the mother particle is not written in the output-tree, MC-matching is not possible for upper-level mothers from cascade decays. " << std::endl; + is_do_not_write_mother_ = is; } - + bool GetIsApplyMassConstraint() const { return is_apply_mass_constraint_; } bool GetIsTransportToPV() const { return is_transport_to_pv_; } bool GetIsDoNotWriteMother() const { return is_do_not_write_mother_; } @@ -63,7 +63,7 @@ class Decay { Mother mother_; ///< cuts for mother particle std::vector daughters_{};///< cuts for daughter particles - + bool is_apply_mass_constraint_{false}; bool is_transport_to_pv_{false}; bool is_do_not_write_mother_{false}; diff --git a/src/Mother.cpp b/src/Mother.cpp index 46c0cb2..104ab17 100644 --- a/src/Mother.cpp +++ b/src/Mother.cpp @@ -25,22 +25,22 @@ float Mother::GetMassKFDatabase() const { float massPDG, massPDGsigma; KFParticleDatabase::Instance()->GetMotherMass(pdg_, massPDG, massPDGsigma); - + if (massPDG == mass_kaon_ && pdg_ != 310) throw std::runtime_error("Mass for mother pdg " + to_string(pdg_) + " is not availabe in KFParticleDatabase. Set mass manually with Mother::SetMassPdg(mass)."); - + return massPDG; }; float Mother::GetMassSigmaKFDatabase() const { if (mass_pdg_sigma_ > 0) return mass_pdg_sigma_; - + float massPDG, massPDGsigma; KFParticleDatabase::Instance()->GetMotherMass(pdg_, massPDG, massPDGsigma); if (massPDG == mass_kaon_ && pdg_ != 310) throw std::runtime_error("Mass sigma for mother pdg " + to_string(pdg_) + " is not availabe in KFParticleDatabase. Set mass sigma manually with Mother::SetMassPdgSigma(mass_sigma)."); - + return massPDGsigma; }; diff --git a/src/Mother.hpp b/src/Mother.hpp index 46f5a50..4918e36 100644 --- a/src/Mother.hpp +++ b/src/Mother.hpp @@ -2,8 +2,8 @@ #define KFPARTICLESIMPLE_KFSIMPLE_MOTHERCUTS_HPP_ #include -#include #include +#include #include "Constants.hpp" @@ -17,7 +17,10 @@ class Mother { Mother& operator=(const Mother&) = default; ~Mother() = default; - explicit Mother(Pdg_t pdg) : pdg_(pdg) { mass_pdg_ = -1.0; mass_pdg_sigma_ = -1.0; } + explicit Mother(Pdg_t pdg) : pdg_(pdg) { + mass_pdg_ = -1.0; + mass_pdg_sigma_ = -1.0; + } void SetMassPdg(float mass_pdg) { mass_pdg_ = mass_pdg; } void SetMassPdgSigma(float mass_pdg_sigma) { mass_pdg_sigma_ = mass_pdg_sigma; } @@ -44,7 +47,7 @@ class Mother { for (std::size_t i = 1; i < cos_open_sm.size() + 1; ++i) cos_open_.at(i) = cos_open_sm.at(i - 1); } void SetCutInvMass(float value) { invmass_discrepancy_ = value; } - + void CancelCutDistance() { this->SetCutDistance(huge_value); } void CancelCutDistanceToSV() { this->SetCutDistanceToSV(huge_value); } void CancelCutChi2Geo() { this->SetCutChi2Geo(huge_value); } @@ -58,16 +61,18 @@ class Mother { void CancelCutCosTopoSM() { this->SetCutCosTopoSM({huge_value, huge_value, huge_value}); } void CancelCutCosOpen() { this->SetCutCosOpen(-huge_value); } void CancelCutCosOpenSM() { this->SetCutCosOpenSM({-huge_value, -huge_value, -huge_value}); } - void CancelCutInvMass() { this->SetCutInvMass(huge_value); } + void CancelCutInvMass() { this->SetCutInvMass(huge_value); } void CancelCuts(); Pdg_t GetPdg() const { return pdg_; } float GetMassPdg() { if (mass_pdg_ < 0) mass_pdg_ = GetMassKFDatabase(); - return mass_pdg_; }; + return mass_pdg_; + }; float GetMassPdgSigma() { if (mass_pdg_sigma_ < 0) mass_pdg_sigma_ = GetMassSigmaKFDatabase(); - return mass_pdg_sigma_; } + return mass_pdg_sigma_; + } float GetMassKFDatabase() const; float GetMassSigmaKFDatabase() const; float GetCutDistance() const { return distance_; } @@ -85,7 +90,7 @@ class Mother { Pdg_t pdg_{-1}; float mass_pdg_{-1.0}; float mass_pdg_sigma_{-1.0}; - float mass_kaon_{0.497614}; // default mass value in KFParticleDatabase + float mass_kaon_{0.497614};// default mass value in KFParticleDatabase float distance_{1.f};///< lower value float distance_sv_{1.f}; diff --git a/src/SimpleFinder.cpp b/src/SimpleFinder.cpp index 81c53d2..4e2583d 100644 --- a/src/SimpleFinder.cpp +++ b/src/SimpleFinder.cpp @@ -7,12 +7,12 @@ using std::to_string; void SimpleFinder::Init(std::vector&& tracks, const KFVertex& pv) { output_.clear(); current_candidate_id_ = 0; - + if (!tracks.empty()) last_track_id_ = tracks.at(tracks.size() - 1).Id(); - else + else last_track_id_ = 0; - + tracks_ = tracks; prim_vx_ = pv; } @@ -71,10 +71,10 @@ void SimpleFinder::CalculateParamsInSV(const std::array& tracks, } for (int i = 0; i < 3; i++) - sec_vx_.at(i) = (sec_vx.at(0).at(i) + sec_vx.at(1).at(i) + sec_vx.at(2).at(i)) / 3 ; - + sec_vx_.at(i) = (sec_vx.at(0).at(i) + sec_vx.at(1).at(i) + sec_vx.at(2).at(i)) / 3; + params_.resize(3); - + for (int itrack = 0; itrack < 3; itrack++) { KFParticle particle(tracks.at(itrack)); particle.SetPDG(pids.at(itrack)); @@ -112,7 +112,7 @@ KFParticleSIMD SimpleFinder::ConstructMother(const std::vector& trac std::vector particles_simd{}; for (size_t i = 0; i < n; ++i) { - if(tracks.at(i).Id() <= last_track_id_) + if (tracks.at(i).Id() <= last_track_id_) SetKFParticleEnergy(particles.at(i), pdgs.at(i)); particles.at(i).SetPDG(pdgs.at(i)); particles.at(i).SetId(tracks.at(i).Id());// TODO rm obsolet ID copying? @@ -138,17 +138,15 @@ KFParticleSIMD SimpleFinder::ConstructMother(const std::vector& trac const KFParticleSIMD* vDaughtersPointer[2] = {&particles_simd.at(0), &particles_simd.at(1)}; mother.Construct(vDaughtersPointer, 2, nullptr); - if((tracks.at(0).Id() <= last_track_id_ || tracks.at(1).Id() <= last_track_id_) && print) - { - std::cout << particles_simd.at(0).GetPx()[0] << "\t" << particles_simd.at(0).GetPy()[0] << "\t" << particles_simd.at(0).GetPz()[0] << "\t" << particles_simd.at(0).GetE()[0] << "\n"; - std::cout << particles_simd.at(1).GetPx()[0] << "\t" << particles_simd.at(1).GetPy()[0] << "\t" << particles_simd.at(1).GetPz()[0] << "\t" << particles_simd.at(1).GetE()[0] << "\n"; - std::cout << mother.GetPx()[0] << "\t" << mother.GetPy()[0] << "\t" << mother.GetPz()[0] << "\t" << mother.GetE()[0] << "\n"; - } - + if ((tracks.at(0).Id() <= last_track_id_ || tracks.at(1).Id() <= last_track_id_) && print) { + std::cout << particles_simd.at(0).GetPx()[0] << "\t" << particles_simd.at(0).GetPy()[0] << "\t" << particles_simd.at(0).GetPz()[0] << "\t" << particles_simd.at(0).GetE()[0] << "\n"; + std::cout << particles_simd.at(1).GetPx()[0] << "\t" << particles_simd.at(1).GetPy()[0] << "\t" << particles_simd.at(1).GetPz()[0] << "\t" << particles_simd.at(1).GetE()[0] << "\n"; + std::cout << mother.GetPx()[0] << "\t" << mother.GetPy()[0] << "\t" << mother.GetPz()[0] << "\t" << mother.GetE()[0] << "\n"; + } + } else if (n == 3) { const KFParticleSIMD* vDaughtersPointer[3] = {&particles_simd.at(0), &particles_simd.at(1), &particles_simd.at(2)}; mother.Construct(vDaughtersPointer, 3, nullptr); - } return mother; @@ -239,18 +237,13 @@ bool SimpleFinder::IsGoodDaughter(const KFParticle& track, const Daughter& daugh values_.chi2_prim.at(id) = CalculateChiToPrimaryVertex(track, daughter.GetPdgHypo()); if (values_.chi2_prim.at(id) < daughter.GetCutChi2Prim() || std::isnan(values_.chi2_prim.at(id))) { return false; } - - if (! (track.Id() > last_track_id_)) { - if (TMath::Abs(daughter.GetPdgHypo()) == 3112 || - TMath::Abs(daughter.GetPdgHypo()) == 3312 || - TMath::Abs(daughter.GetPdgHypo()) == 3334 || - TMath::Abs(daughter.GetPdgHypo()) == 11 || - TMath::Abs(daughter.GetPdgHypo()) == 13) { + + if (!(track.Id() > last_track_id_)) { + if (TMath::Abs(daughter.GetPdgHypo()) == 3112 || TMath::Abs(daughter.GetPdgHypo()) == 3312 || TMath::Abs(daughter.GetPdgHypo()) == 3334 || TMath::Abs(daughter.GetPdgHypo()) == 11 || TMath::Abs(daughter.GetPdgHypo()) == 13) { if ((TMath::Sign(1, daughter.GetPdgHypo()) > 0 && track.Q() != -1) || (TMath::Sign(1, daughter.GetPdgHypo()) < 0 && track.Q() != +1)) { return false; } - } - else { + } else { if ((TMath::Sign(1, daughter.GetPdgHypo()) > 0 && track.Q() != +1) || (TMath::Sign(1, daughter.GetPdgHypo()) < 0 && track.Q() != -1)) { return false; } - } + } } return true; @@ -262,7 +255,7 @@ bool SimpleFinder::IsGoodPair(const KFParticle& track1, if (track1.Id() == track2.Id()) { return false; } - std::vector tracks = { track1, track2}; + std::vector tracks = {track1, track2}; if (IsGoodTrackIdsGenerations(tracks) == false) { return false; } int generation1 = track1.Id() > last_track_id_ ? 1 : 0; @@ -272,8 +265,7 @@ bool SimpleFinder::IsGoodPair(const KFParticle& track1, for (int i = 0; i < tracks.size(); i++) generation.push_back(tracks[i].Id() > last_track_id_ ? 1 : 0); - if (std::accumulate(generation.begin(), generation.end(), 0) > 0) - { + if (std::accumulate(generation.begin(), generation.end(), 0) > 0) { KFParticle track1_nonconst = track1; KFParticle track2_nonconst = track2; KFParticleSIMD track1_simd = KFParticleSIMD(track1_nonconst); @@ -281,8 +273,7 @@ bool SimpleFinder::IsGoodPair(const KFParticle& track1, track1_simd.SetPDG(decay.GetDaughters().at(0).GetPdgHypo()); track2_simd.SetPDG(decay.GetDaughters().at(1).GetPdgHypo()); values_.distance = CalculateDistanceBetweenParticles(track1_simd, track2_simd); - } - else + } else values_.distance = CalculateDistanceBetweenParticles(); if (values_.distance > decay.GetMother().GetCutDistance() || std::isnan(values_.distance)) { return false; } @@ -302,8 +293,8 @@ bool SimpleFinder::IsGoodThree(const KFParticle& track1, if (track1.Id() == track2.Id()) { return false; } if (track1.Id() == track3.Id()) { return false; } if (track2.Id() == track3.Id()) { return false; } - - std::vector tracks = { track1, track2, track3 }; + + std::vector tracks = {track1, track2, track3}; if (IsGoodTrackIdsGenerations(tracks) == false) { return false; } values_.distance_sv = CalculateDistanceToSV(); @@ -316,9 +307,9 @@ bool SimpleFinder::IsGoodThree(const KFParticle& track1, } std::vector cos_tmp; - for (int i = 1; i < 4; i++) + for (int i = 1; i < 4; i++) cos_tmp.push_back(values_.cos_open[i]); - + values_.cos_open[0] = *std::min_element(cos_tmp.begin(), cos_tmp.end()); if (values_.cos_open[0] < decay.GetMother().GetCutCosOpen()[0] || std::isnan(values_.cos_open[0])) { return false; } @@ -328,13 +319,13 @@ bool SimpleFinder::IsGoodThree(const KFParticle& track1, bool SimpleFinder::IsGoodMother(const KFParticleSIMD& kf_mother, const Mother& mother, const int id_mother) { values_.chi2_geo[id_mother] = kf_mother.Chi2()[0] / simd_cast(kf_mother.NDF())[0]; if (values_.chi2_geo[id_mother] > mother.GetCutChi2Geo()[id_mother] || std::isnan(values_.chi2_geo[id_mother])) { return false; } - if (values_.chi2_geo[id_mother] < 0. || ! std::isfinite(values_.chi2_geo[id_mother])) { return false; } + if (values_.chi2_geo[id_mother] < 0. || !std::isfinite(values_.chi2_geo[id_mother])) { return false; } return true; } bool SimpleFinder::IsGoodMotherMass(const KFParticleSIMD& kf_mother, const Mother& mother) { KFParticle particle; - KFParticleSIMD(kf_mother).GetKFParticle(particle, 0); + KFParticleSIMD(kf_mother).GetKFParticle(particle, 0); values_.invmassdisc = CalculateInvMassDiscrepancy(particle, mother); if (std::fabs(values_.invmassdisc) > mother.GetCutInvMass()) { return false; } return true; @@ -361,9 +352,9 @@ bool SimpleFinder::IsMotherFromPV(const KFParticleSIMD& kf_mother, const Mother& } KFParticle particle; - KFParticleSIMD(kf_mother).GetKFParticle(particle, 0); + KFParticleSIMD(kf_mother).GetKFParticle(particle, 0); values_.chi2_prim_mother = CalculateChiToPrimaryVertex(particle, mother.GetPdg()); - + return true; } @@ -396,19 +387,18 @@ bool SimpleFinder::IsGoodDecayLength(const KFParticleSIMD& kf_mother, const Moth void SimpleFinder::SaveParticle(KFParticleSIMD& particle_simd, const Decay& decay) { KFParticle particle; - + auto mothertmp = decay.GetMother(); - if(decay.GetIsApplyMassConstraint()) + if (decay.GetIsApplyMassConstraint()) particle_simd.SetNonlinearMassConstraint(float_v(mothertmp.GetMassPdg())); - - if(decay.GetIsTransportToPV()) - { - KFVertex prim_vx_tmp = prim_vx_; - const KFParticleSIMD prim_vx_Simd(prim_vx_tmp); - const float_v point[3] = {prim_vx_Simd.X(), prim_vx_Simd.Y(), prim_vx_Simd.Z()}; - particle_simd.TransportToPoint(point); - } - + + if (decay.GetIsTransportToPV()) { + KFVertex prim_vx_tmp = prim_vx_; + const KFParticleSIMD prim_vx_Simd(prim_vx_tmp); + const float_v point[3] = {prim_vx_Simd.X(), prim_vx_Simd.Y(), prim_vx_Simd.Z()}; + particle_simd.TransportToPoint(point); + } + particle_simd.GetKFParticle(particle, 0); particle.SetPDG(decay.GetMother().GetPdg()); @@ -417,7 +407,7 @@ void SimpleFinder::SaveParticle(KFParticleSIMD& particle_simd, const Decay& deca particle.SetId(track_id); tracks_.emplace_back(particle); current_candidate_id_++; - + if (decay.GetIsDoNotWriteMother() == true) return; OutputContainer mother(particle); @@ -426,7 +416,7 @@ void SimpleFinder::SaveParticle(KFParticleSIMD& particle_simd, const Decay& deca std::vector daughters_generation; for (int i = 0; i < particle.NDaughters(); i++) - if (particle.DaughterIds().at(i) > last_track_id_ ) + if (particle.DaughterIds().at(i) > last_track_id_) daughters_generation.push_back(1); else daughters_generation.push_back(0); @@ -465,7 +455,7 @@ bool SimpleFinder::IsGoodCos(const KFParticleSIMD& mother, const Decay& decay) { float SimpleFinder::CalculateCosOpen(const int id_daughter_1, const int id_daughter_2) const { const auto& par1 = params_.at(id_daughter_1); const auto& par2 = params_.at(id_daughter_2); - const float sp = par1[kPx] * par2[kPx] + par1[kPy] * par2[kPy] + par1[kPz] * par2[kPz]; + const float sp = par1[kPx] * par2[kPx] + par1[kPy] * par2[kPy] + par1[kPz] * par2[kPz]; const float norm = std::sqrt(par1[kPx] * par1[kPx] + par1[kPy] * par1[kPy] + par1[kPz] * par1[kPz]) * std::sqrt(par2[kPx] * par2[kPx] + par2[kPy] * par2[kPy] + par2[kPz] * par2[kPz]); return sp / norm; @@ -485,47 +475,47 @@ bool SimpleFinder::IsGoodTrackIdsGenerations(const std::vector track std::vector> trackIdsGen0; std::vector> tracksLevel; - + tracksLevel.resize(1); for (int i = 0; i < n; i++) tracksLevel.at(0).push_back(tracks[i]); - + int ilevel = 0; - while (tracksLevel.at(ilevel).size() > 0) { + while (tracksLevel.at(ilevel).size() > 0) { int ntracksL = tracksLevel.at(ilevel).size(); - trackIdsGen0.resize(ilevel+1); - tracksLevel.resize(ilevel+2); - + trackIdsGen0.resize(ilevel + 1); + tracksLevel.resize(ilevel + 2); + for (int i = 0; i < ntracksL; i++) { - if( !(tracksLevel.at(ilevel)[i].Id() > last_track_id_)) - trackIdsGen0.at(ilevel).push_back(tracksLevel.at(ilevel)[i].Id()); + if (!(tracksLevel.at(ilevel)[i].Id() > last_track_id_)) + trackIdsGen0.at(ilevel).push_back(tracksLevel.at(ilevel)[i].Id()); else { - for (int idaughter = 0; idaughter < tracksLevel.at(ilevel)[i].DaughterIds().size(); idaughter++) { - int daughterId = tracksLevel.at(ilevel)[i].DaughterIds().at(idaughter); - int index = id2index_.find(daughterId)->second; - tracksLevel.at(ilevel + 1).push_back(tracks_[index]); - } + for (int idaughter = 0; idaughter < tracksLevel.at(ilevel)[i].DaughterIds().size(); idaughter++) { + int daughterId = tracksLevel.at(ilevel)[i].DaughterIds().at(idaughter); + int index = id2index_.find(daughterId)->second; + tracksLevel.at(ilevel + 1).push_back(tracks_[index]); + } } } - ilevel ++; + ilevel++; } - + ilevel = 0; while (trackIdsGen0.size() > ilevel + 1) { - if (trackIdsGen0.at(ilevel+1).size() == 0) - return false; - for (int itrack = 0; itrack < trackIdsGen0.at(ilevel).size(); itrack++) { + if (trackIdsGen0.at(ilevel + 1).size() == 0) + return false; + for (int itrack = 0; itrack < trackIdsGen0.at(ilevel).size(); itrack++) { int jlevel = ilevel + 1; while (trackIdsGen0.size() > jlevel) { - for (int jtrack = 0; jtrack < trackIdsGen0.at(jlevel).size(); jtrack++) { - if (trackIdsGen0.at(ilevel)[itrack] == trackIdsGen0.at(jlevel)[jtrack]) - return false; - } - jlevel ++; + for (int jtrack = 0; jtrack < trackIdsGen0.at(jlevel).size(); jtrack++) { + if (trackIdsGen0.at(ilevel)[itrack] == trackIdsGen0.at(jlevel)[jtrack]) + return false; + } + jlevel++; } } - ilevel ++; + ilevel++; } return true; } @@ -564,7 +554,7 @@ void SimpleFinder::ReconstructDecay(const Decay& decay) { track.at(1).Pz() *= std::abs(charge); } - CalculateParamsInPCA(track.at(0), pdgs.at(0), track.at(1), pdgs.at(1)); + CalculateParamsInPCA(track.at(0), pdgs.at(0), track.at(1), pdgs.at(1)); if (!IsGoodPair(track.at(0), track.at(1), decay)) continue; KFParticleSIMD kf_mother = ConstructMother({track.at(0), track.at(1)}, pdgs, decay, false); @@ -575,8 +565,8 @@ void SimpleFinder::ReconstructDecay(const Decay& decay) { if (!IsMotherFromPV(kf_mother, decay.GetMother(), id_mother)) continue; if (!IsGoodDecayLength(kf_mother, decay.GetMother())) continue; if (!IsGoodCos(kf_mother, decay)) continue; - if (!IsGoodMotherMass(kf_mother, decay.GetMother())) continue; - + if (!IsGoodMotherMass(kf_mother, decay.GetMother())) continue; + FillDaughtersInfo({track.at(0), track.at(1)}, pdgs); SaveParticle(kf_mother, decay); @@ -599,27 +589,27 @@ void SimpleFinder::ReconstructDecay(const Decay& decay) { track.at(2).Pz() *= std::abs(charge); } - CalculateParamsInSV(track, pdgs); - + CalculateParamsInSV(track, pdgs); + if (!IsGoodThree(track.at(0), track.at(1), track.at(2), decay)) continue; - id_mother = 2; - kf_mother = ConstructMother({track.at(0), track.at(2)}, {pdgs.at(0), pdgs.at(2)}, decay); + id_mother = 2; + kf_mother = ConstructMother({track.at(0), track.at(2)}, {pdgs.at(0), pdgs.at(2)}, decay); if (!IsGoodMother(kf_mother, decay.GetMother(), id_mother)) continue; if (IsMotherFromPV(kf_mother, decay.GetMother(), id_mother)) continue; - id_mother = 3; - kf_mother = ConstructMother({track.at(1), track.at(2)}, {pdgs.at(1), pdgs.at(2)}, decay); + id_mother = 3; + kf_mother = ConstructMother({track.at(1), track.at(2)}, {pdgs.at(1), pdgs.at(2)}, decay); if (!IsGoodMother(kf_mother, decay.GetMother(), id_mother)) continue; if (IsMotherFromPV(kf_mother, decay.GetMother(), id_mother)) continue; - id_mother = 0; - kf_mother = ConstructMother({track.at(0), track.at(1), track.at(2)}, pdgs, decay); + id_mother = 0; + kf_mother = ConstructMother({track.at(0), track.at(1), track.at(2)}, pdgs, decay); if (!IsGoodMother(kf_mother, decay.GetMother(), id_mother)) continue; if (!IsMotherFromPV(kf_mother, decay.GetMother(), id_mother)) continue; if (!IsGoodDecayLength(kf_mother, decay.GetMother())) continue; if (!IsGoodCos(kf_mother, decay)) continue; - if (!IsGoodMotherMass(kf_mother, decay.GetMother())) continue; + if (!IsGoodMotherMass(kf_mother, decay.GetMother())) continue; FillDaughtersInfo({track.at(0), track.at(1), track.at(2)}, pdgs); @@ -637,6 +627,3 @@ void SimpleFinder::FillDaughtersInfo(const std::vector& tracks, cons values_.chi2_prim[i] = CalculateChiToPrimaryVertex(tracks.at(i), pdgs.at(i)); } } - - - diff --git a/src/SimpleFinder.hpp b/src/SimpleFinder.hpp index 3ed8657..5d3ea1a 100644 --- a/src/SimpleFinder.hpp +++ b/src/SimpleFinder.hpp @@ -13,11 +13,11 @@ #ifndef KFPARTICLESIMPLE_KFSIMPLE_SIMPLEFINDER_HPP_ #define KFPARTICLESIMPLE_KFSIMPLE_SIMPLEFINDER_HPP_ -#include #include +#include -#include #include +#include #include #include #include @@ -67,14 +67,14 @@ class SimpleFinder { NonLinearCutBase* ml_cuts_{nullptr};///< input information: non-linear cuts class (optional) std::map> indexes_{};///< map of indexes for a given particle specie - std::map id2index_{}; ///< map of track Ids to indexes - Parameters_t params_{}; ///< vector of daughter parameters at current SV estimation - SelectionValues values_{};///< struct with mother and daughters properties used to apply cuts + std::map id2index_{}; ///< map of track Ids to indexes + Parameters_t params_{}; ///< vector of daughter parameters at current SV estimation + SelectionValues values_{}; ///< struct with mother and daughters properties used to apply cuts std::vector output_{};///< output information: vector of candidates int current_candidate_id_{0}; int last_track_id_{0}; - + /** * Find indexes of good daughters * @param cuts daughter particle cuts container @@ -92,7 +92,7 @@ class SimpleFinder { bool IsGoodCos(const KFParticleSIMD& mother, const Decay& decay); bool IsGoodTrackIdsGenerations(const std::vector tracks); - KFParticleSIMD ConstructMother(const std::vector& tracks, const std::vector& pdgs, const Decay& decay, bool print=false); + KFParticleSIMD ConstructMother(const std::vector& tracks, const std::vector& pdgs, const Decay& decay, bool print = false); void CalculateSecondaryVertex(); void CalculateParamsInPCA(const KFParticle& track1, int pid1, const KFParticle& track2, int pid2); @@ -121,4 +121,3 @@ class SimpleFinder { }; #endif//KFPARTICLESIMPLE_KFSIMPLE_SIMPLEFINDER_HPP_ -