ATLAS Offline Software
Loading...
Searching...
No Matches
eEmMultTestBench.cxx
Go to the documentation of this file.
1// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3#include "eEmMultTestBench.h"
4#include "../IO/eEmTOB.h"
5#include "../IO/CommonTOB.h"
7#include "../Utilities/trim.h"
8
10#include <bitset>
11#include <sstream>
12
13namespace GlobalSim {
14
15 using namespace GlobalSim::IOBitwise;
16
17 eEmMultTestBench::eEmMultTestBench(const std::string& name,
18 ISvcLocator *pSvcLocator):
19 AthAlgorithm(name, pSvcLocator) {
20 }
21
23 ATH_MSG_DEBUG("initialising");
25 CHECK( m_TIPword_WriteKey.initialize());
26
27 // initialisation is from a file of test vectors
28
30 "DATAPATH");
31 if (fn.empty()) {
32 ATH_MSG_FATAL("Failure to find tob file " << m_tobs_fileName
33 << " on " << "$DATAPATH");
34 return StatusCode::FAILURE;
35 }
36
37 m_tob_stream = std::ifstream (fn);
38
39 if (!m_tob_stream) {
40 ATH_MSG_FATAL("Failure to open tob stream " << fn);
41 return StatusCode::FAILURE;
42 }
43
44 if(!m_tob_stream) {
45 ATH_MSG_FATAL("Failure to initialise TOB stream " << fn);
46 return StatusCode::FAILURE;
47 }
48
50 "DATAPATH");
51 if (fn.empty()) {
52 ATH_MSG_FATAL("Failure to find TIP file " << m_TIPword_fileName
53 << " on " << "$DATAPATH");
54 return StatusCode::FAILURE;
55 }
56
57 m_TIPword_stream = std::make_unique<std::ifstream> (fn);
58 if(!(*m_TIPword_stream)) {
59 std::stringstream ss;
60 ATH_MSG_FATAL("Failure to initialise TIP word stream " << fn );
61 return StatusCode::FAILURE;
62 }
63
64
65 return StatusCode::SUCCESS;
66 }
67
68
70 ATH_MSG_DEBUG("executing");
71
72
73 auto padded_line = std::string();
74 auto tobs = std::make_unique<GlobalSim::IOBitwise::eEmTOBContainer>();
75
76 while (true) {
77 std::getline(m_tob_stream, padded_line);
78 auto line = trim(padded_line);
79
80 if(!m_tob_stream) {
81 ATH_MSG_ERROR("input stream bad state " << m_tobs_fileName);
82 return StatusCode::FAILURE;
83 }
84
85 if(line == "EOE") {break;}
86
87 if (line.starts_with("//")){continue;}
88 tobs->push_back(make_tob(line));
89
90 }
91
93 auto h_write_tobs = WH_TOB(m_eEmTOBContainer_WriteKey);
94 CHECK(h_write_tobs.record(std::move(tobs)));
95
96 auto h_write_TIPword = SG::WriteHandle<TIPword>(m_TIPword_WriteKey);
97 auto twp = TIPword_from_file();
98 CHECK(h_write_TIPword.record(std::move(twp)));
99
100 return StatusCode::SUCCESS;
101 }
102
103 std::unique_ptr<TIPword> eEmMultTestBench::TIPword_from_file() const{
104
105 auto line = std::string();
106 using TIP = std::bitset<ITIPwriterAlgTool::s_nbits_TIP>;
107 std::getline(*m_TIPword_stream, line);
108 auto twp = std::make_unique<TIP>(std::stoul(trim(std::move(line))));
109 return twp;
110 }
111
112
113
114 eEmTOB*
115 eEmMultTestBench::make_tob(const std::string& trimmed_line) const {
116 ATH_MSG_INFO("in make_tob> line: " <<trimmed_line);
117
118 std::stringstream ss(trimmed_line);
119 std::string et, eta, phi, RHad, WsTot, REta, seed, UpNotDown, SeedIsMax;
120 ss >> et;
121
122 const auto& s_et_width = CommonTOB::s_et_width;
123 const auto& s_eta_width = CommonTOB::s_eta_width;
124 const auto& s_phi_width = CommonTOB::s_phi_width;
125
126 auto common = CommonTOB(std::bitset<s_et_width>(et),
127 std::bitset<s_eta_width>(eta),
128 std::bitset<s_phi_width>(phi));
129
130
131 const auto& s_RHad_width = eEmTOB::s_RHad_width;
132 const auto& s_REta_width = eEmTOB::s_REta_width;
133 const auto& s_WsTot_width = eEmTOB::s_WsTot_width;
134 const auto& s_Seed_width = eEmTOB::s_Seed_width;
135 const auto& s_UpNotDown_width = eEmTOB::s_UpNotDown_width;
136 const auto& s_SeedIsMax_width = eEmTOB::s_SeedIsMax_width;
137
138
139 return
140 new eEmTOB(common,
141 std::bitset(std::bitset<s_RHad_width>(RHad)),
142 std::bitset(std::bitset<s_REta_width>(REta)),
143 std::bitset(std::bitset<s_WsTot_width>(WsTot)),
144 std::bitset(std::bitset<s_Seed_width>(seed)),
145 std::bitset(std::bitset<s_UpNotDown_width>(UpNotDown)),
146 std::bitset(std::bitset<s_SeedIsMax_width>(SeedIsMax)));
147
148 }
149
150}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t ss
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
static constexpr std::size_t s_eta_width
Size of the eta bitset.
Definition CommonTOB.h:30
static constexpr std::size_t s_et_width
Size of the eT bitset.
Definition CommonTOB.h:28
static constexpr std::size_t s_phi_width
Size of the phi bitset.
Definition CommonTOB.h:32
eEmMultTestBench(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteHandleKey< GlobalSim::IOBitwise::eEmTOBContainer > m_eEmTOBContainer_WriteKey
Gaudi::Property< std::string > m_TIPword_fileName
GlobalSim::IOBitwise::eEmTOB * make_tob(const std::string &s) const
virtual StatusCode initialize() override
Gaudi::Property< std::string > m_tobs_fileName
SG::WriteHandleKey< TIPword > m_TIPword_WriteKey
std::unique_ptr< std::ifstream > m_TIPword_stream
std::unique_ptr< TIPword > TIPword_from_file() const
virtual StatusCode execute() override
static constexpr std::size_t s_SeedIsMax_width
Count: Size of Seed supercell is a local maxima bit.
static constexpr std::size_t s_REta_width
Count: Size of R0 thresholds satisfied bitset.
static constexpr std::size_t s_RHad_width
Count: Size of hadronic thresholds satisfied bitset.
static constexpr std::size_t s_WsTot_width
Count: Size of WsTot algorithm thresholds satisfied bitset.
static constexpr std::size_t s_UpNotDown_width
Count: Size of UpnotDown bit.
static constexpr std::size_t s_Seed_width
Count: Size of Seed eta position in the TOB bitset.
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
AlgTool that to test whether expected the TIP values generated by data supplied by eEmMultTestBench c...
std::string trim(std::string s)
Definition trim.cxx:7
Extra patterns decribing particle interation process.