10#include "trg/klm/modules/klmtrigger/ntuples_full.h"
13#include "trg/klm/modules/klmtrigger/KLM_Trig.h"
14#include "trg/klm/modules/klmtrigger/IO_csv.h"
15#include "trg/klm/modules/klmtrigger/bit_operations.h"
18#include <unordered_map>
26using namespace Belle2::KLM_TRG_definitions;
39 void klmtrg_layer_counter_t::clear_layersUsed()
44 void klmtrg_layer_counter_t::add_layersUsed(
int layersUsed)
46 m_layersUsed.emplace_back(layersUsed);
49 void klmtrg_layer_counter_t::set_NLayerTrigger(
int NlayerTrigger)
51 m_NlayerTrigger = NlayerTrigger;
54 void klmtrg_layer_counter_t::run(
const KLM_Digit_compact_ts& hits)
58 m_sections_trig.clear();
61 auto hits1 = nt::algorithms::join_vectors(
64 nt::comparators::on_common_args,
65 [&](
auto e1,
const auto&) {
66 e1.layer = e1.layer * 2 + e1.plane;
71 __CSV__WRITE__(hits1);
74 auto grouped = nt_group(
81 auto bit_mask = to_bit_mask<layer>(e1);
83 ax_maker(layer_count) = countBits(bit_mask),
84 ax_maker(layer_mask) = bit_mask
89 __CSV__WRITE__(grouped);
91 nt::algorithms::filter(grouped, [&](
const auto & e) {
return e.layer_count >= m_NlayerTrigger; });
97 m_sections_trig = nt_group(
98 grouped[0].subdetector,
102 [&](
const auto & e1) {
103 auto bit_mask = to_bit_mask<sector>(e1);
104 n_sections_trig nsector = countBits(bit_mask);
106 sector_mask(bit_mask),
112 __CSV__WRITE__(m_sections_trig);
116 m_summary1 = nt_group(
117 m_sections_trig[0].subdetector
120 [](
const auto & e1) {
121 auto bit_mask = countBits(to_bit_mask<section>(e1));
122 n_sections_trig nsector = nt::algorithms::sum(e1, [](
auto&& e) {
return e.n_sections_trig; });
126 back2back(bit_mask == 2)
132 __CSV__WRITE__(m_summary1);
137 int klmtrg_layer_counter_t::get_n_sections_trig(
int subdetector)
139 for (
const auto& e : m_summary1) {
140 if (e.subdetector == subdetector) {
141 return e.n_sections_trig;
147 int klmtrg_layer_counter_t::get_triggermask(
int subdetector,
int section)
149 for (
const auto& e : m_sections_trig) {
150 if (e.subdetector == subdetector && e.section == section) {
151 return e.sector_mask;
157 int klmtrg_layer_counter_t::get_BKLM_back_to_back_flag(
int subdetector)
159 for (
const auto& e : m_summary1) {
160 if (e.subdetector == subdetector) {
Abstract base class for different kinds of events.