Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
InvMassDPhiInc2TestBenchAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 
8 #include <algorithm>
9 
10 namespace GlobalSim {
11 
12 
14  ISvcLocator *pSvcLocator):
15  AthAlgorithm(name, pSvcLocator) {
16  }
17 
18 
19 
20 
22  ATH_MSG_DEBUG("initialising");
26 
27  // initialisation is either from a file of test vectors
28  // or by filling in values by hand in this Algorithm
29 
30  if (m_testsFileName1.empty()){
31  ATH_MSG_INFO("Initialisation is manual");
32  CHECK(init_manual());
33  } else {
34  ATH_MSG_ERROR("initialisation from file not yet implemented");
35  return StatusCode::FAILURE;
36  }
37 
38 
39  if (m_testTobs1.empty()) {
40  ATH_MSG_INFO("no events with testTobs1");
41  return StatusCode::FAILURE;
42  }
43 
44 
45  if (m_testTobs1.size() != m_testTobs2.size()) {
46  auto ss = std::stringstream();
47  ss << "number events with testTobs2 ["
48  << m_testTobs1.size()
49  << "] != number events with testTobs2 ["
50  << m_testTobs2.size()
51  << ']';
52  ATH_MSG_INFO(ss.str());
53  return StatusCode::FAILURE;
54  }
55 
56  for (std::size_t i =0; i != m_testTobs2.size(); ++i) {
57  if (m_testTobs1[i].size() != m_testTobs2[i].size()) {
58  ATH_MSG_ERROR("Number of input test tobs differ for event " << i);
59  return StatusCode::FAILURE;
60  }
61  }
62 
63  if (m_expectedResults.size() != m_testTobs1.size()) {
64  ATH_MSG_ERROR("Number of expected results and number of sets of input tobs differ");
65  return StatusCode::FAILURE;
66 
67  }
68 
69  ATH_MSG_INFO("Number of events stored " << m_expectedResults.size());
70 
71  return StatusCode::SUCCESS;
72  }
73 
78  return StatusCode::SUCCESS;
79  }
80 
82  return StatusCode::SUCCESS;
83  }
84 
85 
87  return StatusCode::SUCCESS;
88  }
89 
91  return StatusCode::SUCCESS;
92  }
93 
96 
97 
98  // store an event of GenericTobs 1, GenericTobs 2 and expected values
99  // initialised from python. All inputs are binary strings.
100 
101  if (m_testRepeat < 1) {
102  ATH_MSG_ERROR("Invalid repeat of input data requested: " << m_testRepeat);
103  return StatusCode::FAILURE;
104  }
105 
106  // apply the repeat value
107  {
108  auto container = GenericTobContainer();
109  container.reserve(m_testRepeat*(m_testTobs1_in.size()));
110 
111  for (std::size_t i = 0; i != m_testRepeat; ++i) {
112  std::transform(std::cbegin(m_testTobs1_in),
113  std::cend(m_testTobs1_in),
114  std::back_inserter(container),
115  [](const auto& bs){
116  return std::make_shared<GenericTob>(bs);});
117 
118  }
119  m_testTobs1.push_back(container);
120  }
121 
122  {
123  auto container = GenericTobContainer();
124  container.reserve(m_testRepeat*(m_testTobs2_in.size()));
125 
126  for (std::size_t i = 0; i != m_testRepeat; ++i) {
127  std::transform(std::cbegin(m_testTobs2_in),
128  std::cend(m_testTobs2_in),
129  std::back_inserter(container),
130  [](const auto& bs){
131  return std::make_shared<GenericTob>(bs);});
132 
133  }
134  m_testTobs2.push_back(container);
135  }
136 
138 
139 
140 
141  {
142  auto ss = std::stringstream();
143 
144  ss << "bitstrings tobs1 [" << m_testTobs1_in.size()<< "]\n";
145  for (const auto& bs : m_testTobs1_in) {
146  ss << bs << '\n';
147  }
148  ATH_MSG_DEBUG(ss.str());
149  }
150 
151  {
152  auto ss = std::stringstream();
153  std::size_t i_ev{0};
154 
155  ss << "nevents tobs1 " << m_testTobs1.size()<< '\n';
156  for (const auto& ev : m_testTobs1) {
157  ss << "ev " << i_ev++ << '\n';
158  for (const auto& gt : ev) {
159  ss << *gt << '\n';
160  }
161  ATH_MSG_DEBUG(ss.str());
162  }
163  }
164 
165  {
166  auto ss = std::stringstream();
167  std::size_t i_ev{0};
168 
169  ss << "nevents tobs2 " << m_testTobs2.size() << '\n';
170  for (const auto& ev : m_testTobs2) {
171  ss << "ev " << i_ev++ << '\n';
172  for (const auto& gt : ev) {
173  ss << *gt << '\n';
174  }
175  ATH_MSG_DEBUG(ss.str());
176  }
177  }
178 
179  return StatusCode::SUCCESS;
180  }
181 
182 
183  StatusCode
185  ATH_MSG_DEBUG("executing");
186 
187  // Write out a 2 vectors of GenericTob bits streams per event.
188  // over running the number of such vectors is an error
189 
190  if (m_dataIndex == m_testTobs1.size()) {
191  ATH_MSG_ERROR("Attempting to read beyond stored data");
192  return StatusCode::FAILURE;
193  }
194 
195  {
196  auto h_write =
198  auto tobs =
199  std::make_unique<GenericTobContainer>(m_testTobs1[m_dataIndex]);
200  CHECK(h_write.record(std::move(tobs)));
201  }
202 
203 
204  {
205  auto h_write =
207  auto tobs =
208  std::make_unique<GenericTobContainer>(m_testTobs2[m_dataIndex]);
209  CHECK(h_write.record(std::move(tobs)));
210  }
211 
212 
213  {
214  auto h_write =
216 
217  auto expectations =
218  std::make_unique<Result>(m_expectedResults[m_dataIndex]);
219 
220 
221  CHECK(h_write.record(std::move(expectations)));
222  }
223 
224  ++m_dataIndex;
225 
226  return StatusCode::SUCCESS;
227  }
228 
229 
230 }
GlobalSim::InvMassDPhiInc2TestBenchAlg::init_manual
StatusCode init_manual()
Definition: InvMassDPhiInc2TestBenchAlg.cxx:95
GlobalSim::InvMassDPhiInc2TestBenchAlg::InvMassDPhiInc2TestBenchAlg
InvMassDPhiInc2TestBenchAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: InvMassDPhiInc2TestBenchAlg.cxx:13
GlobalSim::InvMassDPhiInc2TestBenchAlg::m_testTobs1
std::vector< GlobalSim::GenericTobContainer > m_testTobs1
Definition: InvMassDPhiInc2TestBenchAlg.h:100
GlobalSim::InvMassDPhiInc2TestBenchAlg::m_testTobs2_in
Gaudi::Property< std::vector< std::string > > m_testTobs2_in
Definition: InvMassDPhiInc2TestBenchAlg.h:106
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
GlobalSim::InvMassDPhiInc2TestBenchAlg::initialize
virtual StatusCode initialize() override
Definition: InvMassDPhiInc2TestBenchAlg.cxx:21
GlobalSim::InvMassDPhiInc2TestBenchAlg::init_tobs1_from_file
StatusCode init_tobs1_from_file()
Definition: InvMassDPhiInc2TestBenchAlg.cxx:81
GlobalSim::InvMassDPhiInc2TestBenchAlg::m_testTobs2
std::vector< GlobalSim::GenericTobContainer > m_testTobs2
Definition: InvMassDPhiInc2TestBenchAlg.h:114
GlobalSim::InvMassDPhiInc2TestBenchAlg::m_tobs2_WriteKey
SG::WriteHandleKey< GenericTobContainer > m_tobs2_WriteKey
Definition: InvMassDPhiInc2TestBenchAlg.h:47
GlobalSim::InvMassDPhiInc2TestBenchAlg::m_testTobs1_in
Gaudi::Property< std::vector< std::string > > m_testTobs1_in
Definition: InvMassDPhiInc2TestBenchAlg.h:92
GlobalSim::InvMassDPhiInc2TestBenchAlg::execute
virtual StatusCode execute() override
Definition: InvMassDPhiInc2TestBenchAlg.cxx:184
GlobalSim::InvMassDPhiInc2TestBenchAlg::m_expectations_WriteKey
SG::WriteHandleKey< Result > m_expectations_WriteKey
Definition: InvMassDPhiInc2TestBenchAlg.h:54
GlobalSim::InvMassDPhiInc2TestBenchAlg::init_tobs2_from_file
StatusCode init_tobs2_from_file()
Definition: InvMassDPhiInc2TestBenchAlg.cxx:86
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
GlobalSim
AlgTool to obtain a selection of eFex RoIs read in from the event store.
Definition: dump.h:8
ev
int ev
Definition: globals.cxx:25
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
GlobalSim::InvMassDPhiInc2TestBenchAlg::m_expResults_in
Gaudi::Property< std::string > m_expResults_in
Definition: InvMassDPhiInc2TestBenchAlg.h:119
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
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
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
AthAlgorithm
Definition: AthAlgorithm.h:47
GlobalSim::InvMassDPhiInc2TestBenchAlg::init_expected_results_from_file
StatusCode init_expected_results_from_file()
Definition: InvMassDPhiInc2TestBenchAlg.cxx:90
GlobalSim::InvMassDPhiInc2TestBenchAlg::m_testsFileName1
Gaudi::Property< std::string > m_testsFileName1
Definition: InvMassDPhiInc2TestBenchAlg.h:67
InvMassDPhiInc2TestBenchAlg.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
GlobalSim::InvMassDPhiInc2TestBenchAlg::m_testRepeat
Gaudi::Property< int > m_testRepeat
Definition: InvMassDPhiInc2TestBenchAlg.h:129
GlobalSim::GenericTobContainer
std::vector< std::shared_ptr< GenericTob > > GenericTobContainer
Definition: GenericTob.h:68
GlobalSim::InvMassDPhiInc2TestBenchAlg::m_expectedResults
std::vector< std::string > m_expectedResults
Definition: InvMassDPhiInc2TestBenchAlg.h:136
GlobalSim::InvMassDPhiInc2TestBenchAlg::m_dataIndex
std::size_t m_dataIndex
Definition: InvMassDPhiInc2TestBenchAlg.h:61
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
GlobalSim::InvMassDPhiInc2TestBenchAlg::m_tobs1_WriteKey
SG::WriteHandleKey< GenericTobContainer > m_tobs1_WriteKey
Definition: InvMassDPhiInc2TestBenchAlg.h:39
GlobalSim::InvMassDPhiInc2TestBenchAlg::init_from_file
StatusCode init_from_file()
Definition: InvMassDPhiInc2TestBenchAlg.cxx:74