ATLAS Offline Software
Loading...
Searching...
No Matches
CommonSortSelectAlgTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "./CommonSelector.h"
7#include "./eEmSelector.h"
8#include "../IO//CommonTOB.h"
9
10#include <fstream>
11
12namespace GlobalSim {
13
15 const std::string& name,
16 const IInterface* parent) :
17 base_class(type, name, parent) {
18 }
19
20
21 // Initialize function running before first event
23
24 CHECK(m_inTOBContainerKey.initialize());
25 CHECK(m_outTOBContainerKey.initialize());
26
27 // create the selector function object
28 m_c_selector = std::make_unique<CommonSelector>(m_et_low_str,
34 );
35
36 return StatusCode::SUCCESS;
37 }
38
39
40 StatusCode CommonSortSelectAlgTool::run(const EventContext& ctx) const {
41 auto tobs =
43 ctx);
44
45 CHECK(tobs.isValid());
46
47 // copy selected tobs to the output container
48
49 auto out_tobs =
50 std::make_unique<IOBitwise::CommonTOBContainer>(tobs->size());
51
52
53 auto tmp_tobs =
54 std::vector<IOBitwise::CommonTOB*>(tobs->size());
55
56 std::transform(std::begin(*tobs),
57 std::end(*tobs),
58 std::back_inserter(tmp_tobs),
59 [](const auto& tobptr) {
60 return new IOBitwise::CommonTOB(*tobptr);
61 });
62
63 std::copy_if(std::begin(tmp_tobs),
64 std::end(tmp_tobs),
65 std::back_inserter(*out_tobs),
66 [&selector=m_c_selector](const auto& tob) {
67 return selector->select(*tob);});
68
69
70 ATH_MSG_DEBUG("no of TOBS in, selected: " << tobs->size()
71 << " " << out_tobs->size());
72
73 std::size_t maxTOBs{m_maxTOBs};
74 out_tobs->resize(std::min(maxTOBs, out_tobs->size()));
75
76 std::sort(std::begin(*out_tobs),
77 std::end(*out_tobs),
78 [](const auto& l, const auto& r) {
79 return l->et_bits().to_ulong() < r->et_bits().to_ulong();
80 });
81
83 h_out(m_outTOBContainerKey, ctx);
84
85 CHECK(h_out.record(std::move(out_tobs)));
86
87 return StatusCode::SUCCESS;
88 }
89
91 std::stringstream ss;
92 ss <<name () << ": " <<m_menu_name << ' '
93 << "CommonSortSelectAlgTool read, select, and sort CommonTOBS\n"
94 << m_c_selector->to_string() << '\n';
95 return ss.str();
96 }
97
98}
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t ss
virtual StatusCode initialize() override
Initialize function running before first event.
Gaudi::Property< std::string > m_phi_low_str
virtual std::string toString() const override
Gaudi::Property< std::string > m_menu_name
Gaudi::Property< std::string > m_eta_high_str
Gaudi::Property< std::string > m_eta_low_str
Gaudi::Property< std::string > m_et_high_str
std::unique_ptr< ICommonSelector > m_c_selector
virtual StatusCode run(const EventContext &) const override
SG::WriteHandleKey< GlobalSim::IOBitwise::CommonTOBContainer > m_outTOBContainerKey
Gaudi::Property< std::string > m_et_low_str
Gaudi::Property< std::string > m_phi_high_str
Gaudi::Property< std::size_t > m_maxTOBs
SG::ReadHandleKey< GlobalSim::IOBitwise::CommonTOBContainer > m_inTOBContainerKey
CommonSortSelectAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
int r
Definition globals.cxx:22
AlgTool that to test whether expected the TIP values generated by data supplied by eEmMultTestBench c...
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.