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
9#include <fstream>
10
11namespace GlobalSim {
12
14 const std::string& name,
15 const IInterface* parent) :
16 base_class(type, name, parent) {
17 }
18
19
20 // Initialize function running before first event
22
23 CHECK(m_inTOBContainerKey.initialize());
24 CHECK(m_outTOBContainerKey.initialize());
25
26 // create the selector function object
27 m_c_selector = std::make_unique<CommonSelector>(m_et_low_str,
33 );
34
35 return StatusCode::SUCCESS;
36 }
37
38
39 StatusCode CommonSortSelectAlgTool::run(const EventContext& ctx) const {
40 auto tobs =
42 ctx);
43
44 CHECK(tobs.isValid());
45
46 // copy selected tobs to the output container
47
48 auto out_tobs =
49 std::make_unique<IOBitwise::ICommonTOBContainer>(tobs->size());
50
51 std::copy_if(std::cbegin(*tobs),
52 std::cend(*tobs),
53 std::back_inserter(*out_tobs),
54 [&selector=m_c_selector](const auto& tob) {
55 return selector->select(*tob);});
56
57 ATH_MSG_DEBUG("no of TOBS in, selected: " << tobs->size()
58 << " " << out_tobs->size());
59
60 std::size_t maxTOBs{m_maxTOBs};
61 out_tobs->resize(std::min(maxTOBs, out_tobs->size()));
62
63 std::sort(std::begin(*out_tobs),
64 std::end(*out_tobs),
65 [](const auto& l, const auto& r) {
66 return l->et_bits().to_ulong() < r->et_bits().to_ulong();
67 });
68
70 h_out(m_outTOBContainerKey, ctx);
71
72 CHECK(h_out.record(std::move(out_tobs)));
73
74 return StatusCode::SUCCESS;
75 }
76
78 std::stringstream ss;
79 ss <<name () << ": " <<m_menu_name << ' '
80 << "CommonSortSelectAlgTool read, select, and sort CommonTOBS\n"
81 << m_c_selector->to_string() << '\n';
82 return ss.str();
83 }
84
85}
#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
SG::ReadHandleKey< GlobalSim::IOBitwise::ICommonTOBContainer > m_inTOBContainerKey
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
SG::WriteHandleKey< GlobalSim::IOBitwise::ICommonTOBContainer > m_outTOBContainerKey
Gaudi::Property< std::string > m_et_high_str
std::unique_ptr< ICommonSelector > m_c_selector
virtual StatusCode run(const EventContext &) const override
Gaudi::Property< std::string > m_et_low_str
Gaudi::Property< std::string > m_phi_high_str
Gaudi::Property< std::size_t > m_maxTOBs
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.