EICrecon
JANA based reconstruction for the EPIC detector
Loading...
Searching...
No Matches
SubDivideCollection.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// Copyright (C) 2024 Simon Gardner
3
4#pragma once
5
6#include <spdlog/spdlog.h>
7#include <DD4hep/Detector.h>
8#include <algorithms/algorithm.h>
9#include <string>
10#include <string_view>
11
15
16namespace eicrecon {
17
18template <class T>
20 algorithms::Algorithm<typename algorithms::Input<const typename T::collection_type>,
21 typename algorithms::Output<std::vector<typename T::collection_type>>>;
22
23template <typename T>
25 public WithPodConfig<SubDivideCollectionConfig<T>> {
26
27public:
28 SubDivideCollection(std::string_view name)
30 name, {"inputCollection"}, {"outputCollection"}, "Sub-Divide collection"}
32
33 void init() final {};
34
36 const typename SubDivideCollectionAlgorithm<T>::Output& output) const final {
37
38 const auto [entries] = input;
39 auto [subdivided_entries] = output;
40
41 for (auto out : subdivided_entries) {
42 out->setSubsetCollection();
43 }
44
45 for (const auto& entry : *entries) {
46
47 auto div_indices = this->m_cfg.function(entry);
48
49 for (auto index : div_indices) {
50 subdivided_entries[index]->push_back(entry);
51 }
52 }
53
54 //Log how the hits were divided between the collection names
55 this->debug("Divided {} hits between {} collections", entries->size(),
56 subdivided_entries.size());
57 //How many hits in each output collection
58 for (std::size_t i = 0; i < subdivided_entries.size(); i++) {
59 this->debug("Collection {} takes {} hits", i, subdivided_entries[i]->size());
60 }
61 };
62};
63
64} // namespace eicrecon
Definition SubDivideCollection.h:25
void process(const typename SubDivideCollectionAlgorithm< T >::Input &input, const typename SubDivideCollectionAlgorithm< T >::Output &output) const final
Definition SubDivideCollection.h:35
void init() final
Definition SubDivideCollection.h:33
SubDivideCollection(std::string_view name)
Definition SubDivideCollection.h:28
Definition WithPodConfig.h:22
SubDivideCollectionConfig< T > m_cfg
Definition WithPodConfig.h:37
-client
Definition CalorimeterClusterRecoCoG.cc:37
algorithms::Algorithm< typename algorithms::Input< const typename T::collection_type >, typename algorithms::Output< std::vector< typename T::collection_type > > > SubDivideCollectionAlgorithm
Definition SubDivideCollection.h:21