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/IeEmTOB.h"
5#include "../IO/eEmTOB.h"
6#include "../IO/CommonTOB.h"
8#include "../Utilities/trim.h"
9
11#include <bitset>
12#include <sstream>
13
14namespace GlobalSim {
15
16 using namespace GlobalSim::IOBitwise;
17
18 eEmMultTestBench::eEmMultTestBench(const std::string& name,
19 ISvcLocator *pSvcLocator):
20 AthAlgorithm(name, pSvcLocator) {
21 }
22
24 ATH_MSG_DEBUG("initialising");
26 CHECK( m_TIPword_WriteKey.initialize());
27
28 // initialisation is from a file of test vectors
29
31 "DATAPATH");
32 if (fn.empty()) {
33 ATH_MSG_FATAL("Failure to find tob file " << m_tobs_fileName
34 << " on " << "$DATAPATH");
35 return StatusCode::FAILURE;
36 }
37
38 m_tob_stream = std::ifstream (fn);
39
40 if (!m_tob_stream) {
41 ATH_MSG_FATAL("Failure to open tob stream " << fn);
42 return StatusCode::FAILURE;
43 }
44
45 if(!m_tob_stream) {
46 ATH_MSG_FATAL("Failure to initialise TOB stream " << fn);
47 return StatusCode::FAILURE;
48 }
49
51 "DATAPATH");
52 if (fn.empty()) {
53 ATH_MSG_FATAL("Failure to find TIP file " << m_TIPword_fileName
54 << " on " << "$DATAPATH");
55 return StatusCode::FAILURE;
56 }
57
58 m_TIPword_stream = std::make_unique<std::ifstream> (fn);
59 if(!(*m_TIPword_stream)) {
60 std::stringstream ss;
61 ATH_MSG_FATAL("Failure to initialise TIP word stream " << fn );
62 return StatusCode::FAILURE;
63 }
64
65
66 return StatusCode::SUCCESS;
67 }
68
69
71 ATH_MSG_DEBUG("executing");
72
73
74 auto padded_line = std::string();
75 auto tobs = std::make_unique<GlobalSim::IOBitwise::IeEmTOBContainer>();
76
77 while (true) {
78 std::getline(m_tob_stream, padded_line);
79 auto line = trim(padded_line);
80
81 if(!m_tob_stream) {
82 ATH_MSG_ERROR("input stream bad state " << m_tobs_fileName);
83 return StatusCode::FAILURE;
84 }
85
86 if(line == "EOE") {break;}
87
88 if (line.starts_with("//")){continue;}
89 tobs->push_back(make_tob(line));
90
91 }
92
94 auto h_write_tobs = WH_TOB(m_eEmTOBContainer_WriteKey);
95 CHECK(h_write_tobs.record(std::move(tobs)));
96
97 auto h_write_TIPword = SG::WriteHandle<TIPword>(m_TIPword_WriteKey);
98 auto twp = TIPword_from_file();
99 CHECK(h_write_TIPword.record(std::move(twp)));
100
101 return StatusCode::SUCCESS;
102 }
103
104 std::unique_ptr<TIPword> eEmMultTestBench::TIPword_from_file() const{
105
106 auto line = std::string();
107 using TIP = std::bitset<ITIPwriterAlgTool::s_nbits_TIP>;
108 std::getline(*m_TIPword_stream, line);
109 auto twp = std::make_unique<TIP>(std::stoul(trim(std::move(line))));
110 return twp;
111 }
112
113
114
115 IeEmTOB*
116 eEmMultTestBench::make_tob(const std::string& trimmed_line) const {
117 ATH_MSG_INFO("in make_tob> line: " <<trimmed_line);
118
119 std::stringstream ss(trimmed_line);
120 std::string et, eta, phi, RHad, WsTot, REta, seed, UpNotDown, SeedIsMax;
121 ss >> et;
122
123 const auto& s_et_width = ICommonTOB::s_et_width;
124 const auto& s_eta_width = ICommonTOB::s_eta_width;
125 const auto& s_phi_width = ICommonTOB::s_phi_width;
126
127 auto common = CommonTOB(std::bitset<s_et_width>(et),
128 std::bitset<s_eta_width>(eta),
129 std::bitset<s_phi_width>(phi));
130
131
132 const auto& s_RHad_width = IeEmTOB::s_RHad_width;
133 const auto& s_REta_width = IeEmTOB::s_REta_width;
134 const auto& s_WsTot_width = IeEmTOB::s_WsTot_width;
135 const auto& s_Seed_width = IeEmTOB::s_Seed_width;
136 const auto& s_UpNotDown_width = IeEmTOB::s_UpNotDown_width;
137 const auto& s_SeedIsMax_width = IeEmTOB::s_SeedIsMax_width;
138
139
140 return
141 new eEmTOB(common,
142 std::bitset(std::bitset<s_RHad_width>(RHad)),
143 std::bitset(std::bitset<s_REta_width>(REta)),
144 std::bitset(std::bitset<s_WsTot_width>(WsTot)),
145 std::bitset(std::bitset<s_Seed_width>(seed)),
146 std::bitset(std::bitset<s_UpNotDown_width>(UpNotDown)),
147 std::bitset(std::bitset<s_SeedIsMax_width>(SeedIsMax)));
148
149 }
150
151}
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 ICommonTOB.h:37
static constexpr std::size_t s_phi_width
Size of the phi bitset.
Definition ICommonTOB.h:39
static constexpr std::size_t s_et_width
Size of the eT bitset.
Definition ICommonTOB.h:35
Class to hold common (eta/eta/phi) TOB bits.
Definition CommonTOB.h:23
Class to hold eFexROI TOB bits.
Definition IeEmTOB.h:29
static constexpr std::size_t s_RHad_width
Count: Size of hadronic thresholds satisfied bitset.
Definition IeEmTOB.h:38
static constexpr std::size_t s_UpNotDown_width
Count: Size of UpnotDown bit.
Definition IeEmTOB.h:46
static constexpr std::size_t s_WsTot_width
Count: Size of WsTot algorithm thresholds satisfied bitset.
Definition IeEmTOB.h:40
static constexpr std::size_t s_SeedIsMax_width
Count: Size of Seed supercell is a local maxima bit.
Definition IeEmTOB.h:48
static constexpr std::size_t s_REta_width
Count: Size of R0 thresholds satisfied bitset.
Definition IeEmTOB.h:42
static constexpr std::size_t s_Seed_width
Count: Size of Seed eta position in the TOB bitset.
Definition IeEmTOB.h:44
eEmMultTestBench(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< std::string > m_TIPword_fileName
virtual StatusCode initialize() override
Gaudi::Property< std::string > m_tobs_fileName
GlobalSim::IOBitwise::IeEmTOB * make_tob(const std::string &s) const
SG::WriteHandleKey< TIPword > m_TIPword_WriteKey
std::unique_ptr< std::ifstream > m_TIPword_stream
std::unique_ptr< TIPword > TIPword_from_file() const
SG::WriteHandleKey< GlobalSim::IOBitwise::IeEmTOBContainer > m_eEmTOBContainer_WriteKey
virtual StatusCode execute() override
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.