ATLAS Offline Software
Loading...
Searching...
No Matches
CommonSortSelectAlgTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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
41 CommonSortSelectAlgTool::run(const std::unique_ptr<IDataCollector>& dc,
42 const EventContext& ctx) const {
43
44 if (dc){dc->collect(*this, "start");}
45
46 auto tobs =
48 ctx);
49
50 CHECK(tobs.isValid());
51
52 // copy selected tobs to the output container
53
54 auto out_tobs =
55 std::make_unique<IOBitwise::CommonTOBContainer>(tobs->size());
56
57
58 auto tmp_tobs =
59 std::vector<IOBitwise::CommonTOB*>(tobs->size());
60
61 std::transform(std::begin(*tobs),
62 std::end(*tobs),
63 std::back_inserter(tmp_tobs),
64 [](const auto& tobptr) {
65 return new IOBitwise::CommonTOB(*tobptr);
66 });
67
68 std::copy_if(std::begin(tmp_tobs),
69 std::end(tmp_tobs),
70 std::back_inserter(*out_tobs),
71 [&selector=m_c_selector](const auto& tob) {
72 return selector->select(*tob);});
73
74
75 ATH_MSG_DEBUG("no of TOBS in, selected: " << tobs->size()
76 << " " << out_tobs->size());
77
78 std::size_t maxTOBs{m_maxTOBs};
79 out_tobs->resize(std::min(maxTOBs, out_tobs->size()));
80
81 std::sort(std::begin(*out_tobs),
82 std::end(*out_tobs),
83 [](const auto& l, const auto& r) {
84 return l->et_bits().to_ulong() < r->et_bits().to_ulong();
85 });
86
88 h_out(m_outTOBContainerKey, ctx);
89
90 CHECK(h_out.record(std::move(out_tobs)));
91
92 if (dc){dc->collect(*this, "end");}
93
94 return StatusCode::SUCCESS;
95 }
96
98 std::stringstream ss;
99 ss <<name () << ": " <<m_menu_name << ' '
100 << "CommonSortSelectAlgTool read, select, and sort CommonTOBS\n"
101 << m_c_selector->to_string() << '\n';
102 return ss.str();
103 }
104
105}
#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 StatusCode run(const std::unique_ptr< IDataCollector > &, const EventContext &) const override
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
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 to read in LArStripNeighborhoods, and run the eRatio Algorithm.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.