ATLAS Offline Software
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 
11 namespace 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 
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 
77  std::string CommonSortSelectAlgTool::toString() const {
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 }
beamspotman.r
def r
Definition: beamspotman.py:672
GlobalSim::CommonSortSelectAlgTool::m_et_high_str
Gaudi::Property< std::string > m_et_high_str
Definition: CommonSortSelectAlgTool.h:69
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
GlobalSim::CommonSortSelectAlgTool::m_phi_high_str
Gaudi::Property< std::string > m_phi_high_str
Definition: CommonSortSelectAlgTool.h:93
GlobalSim::CommonSortSelectAlgTool::m_eta_low_str
Gaudi::Property< std::string > m_eta_low_str
Definition: CommonSortSelectAlgTool.h:75
GlobalSim::CommonSortSelectAlgTool::m_phi_low_str
Gaudi::Property< std::string > m_phi_low_str
Definition: CommonSortSelectAlgTool.h:87
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
CommonSelector.h
ReadBchFromCrest.begin
begin
Definition: ReadBchFromCrest.py:80
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:157
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
GlobalSim::CommonSortSelectAlgTool::run
virtual StatusCode run(const EventContext &) const override
Definition: CommonSortSelectAlgTool.cxx:39
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
GlobalSim
AlgTool that to test whether expected the TIP values generated by data supplied by eEmMultTestBench c...
Definition: CommonSelector.cxx:8
GlobalSim::CommonSortSelectAlgTool::m_maxTOBs
Gaudi::Property< std::size_t > m_maxTOBs
Definition: CommonSortSelectAlgTool.h:100
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AnalysisUtils::copy_if
Out copy_if(In first, const In &last, Out res, const Pred &p)
Definition: IFilterUtils.h:30
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
GlobalSim::CommonSortSelectAlgTool::toString
virtual std::string toString() const override
Definition: CommonSortSelectAlgTool.cxx:77
eEmSelector.h
GlobalSim::CommonSortSelectAlgTool::m_menu_name
Gaudi::Property< std::string > m_menu_name
Definition: CommonSortSelectAlgTool.h:106
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
GlobalSim::CommonSortSelectAlgTool::m_et_low_str
Gaudi::Property< std::string > m_et_low_str
Definition: CommonSortSelectAlgTool.h:63
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
python.selector.AtlRunQuerySelectorLhcOlc.selector
selector
Definition: AtlRunQuerySelectorLhcOlc.py:610
GlobalSim::CommonSortSelectAlgTool::m_outTOBContainerKey
SG::WriteHandleKey< GlobalSim::IOBitwise::ICommonTOBContainer > m_outTOBContainerKey
Definition: CommonSortSelectAlgTool.h:56
CommonSortSelectAlgTool.h
GlobalSim::CommonSortSelectAlgTool::m_inTOBContainerKey
SG::ReadHandleKey< GlobalSim::IOBitwise::ICommonTOBContainer > m_inTOBContainerKey
Definition: CommonSortSelectAlgTool.h:48
GlobalSim::CommonSortSelectAlgTool::initialize
virtual StatusCode initialize() override
Initialize function running before first event.
Definition: CommonSortSelectAlgTool.cxx:21
GlobalSim::CommonSortSelectAlgTool::m_c_selector
std::unique_ptr< ICommonSelector > m_c_selector
Definition: CommonSortSelectAlgTool.h:45
GlobalSim::CommonSortSelectAlgTool::m_eta_high_str
Gaudi::Property< std::string > m_eta_high_str
Definition: CommonSortSelectAlgTool.h:81
GlobalSim::CommonSortSelectAlgTool::CommonSortSelectAlgTool
CommonSortSelectAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: CommonSortSelectAlgTool.cxx:13