ATLAS Offline Software
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"
7 #include "../IO/TipWord_clid.h"
8 #include "../Utilities/trim.h"
9 
11 #include <bitset>
12 #include <sstream>
13 
14 namespace GlobalSim {
15 
16  using namespace GlobalSim::IOBitwise;
17 
19  ISvcLocator *pSvcLocator):
20  AthAlgorithm(name, pSvcLocator) {
21  }
22 
24  ATH_MSG_DEBUG("initialising");
25  CHECK(m_eEmTOBContainer_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 }
et
Extra patterns decribing particle interation process.
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
GlobalSim::IOBitwise::eEmTOB
Class to hold eFexROI TOB bits.
Definition: Global/GlobalSimulation/src/IO/eEmTOB.h:23
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
GlobalSim::IOBitwise::IeEmTOB::s_REta_width
static constexpr std::size_t s_REta_width
Count: Size of R0 thresholds satisfied bitset.
Definition: IeEmTOB.h:42
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
GlobalSim::eEmMultTestBench::execute
virtual StatusCode execute() override
Definition: eEmMultTestBench.cxx:70
eEmMultTestBench.h
GlobalSim::IOBitwise::ICommonTOB::s_phi_width
static constexpr std::size_t s_phi_width
Size of the phi bitset.
Definition: ICommonTOB.h:39
GlobalSim::eEmMultTestBench::m_tobs_fileName
Gaudi::Property< std::string > m_tobs_fileName
Definition: eEmMultTestBench.h:69
GlobalSim::IOBitwise::IeEmTOB::s_UpNotDown_width
static constexpr std::size_t s_UpNotDown_width
Count: Size of UpnotDown bit.
Definition: IeEmTOB.h:46
dq_defect_bulk_create_defects.line
line
Definition: dq_defect_bulk_create_defects.py:27
GlobalSim::IOBitwise::ICommonTOB::s_et_width
static constexpr std::size_t s_et_width
Size of the eT bitset.
Definition: ICommonTOB.h:35
GlobalSim::IOBitwise::CommonTOB
Class to hold common (eta/eta/phi) TOB bits.
Definition: CommonTOB.h:23
GlobalSim::eEmMultTestBench::m_eEmTOBContainer_WriteKey
SG::WriteHandleKey< GlobalSim::IOBitwise::IeEmTOBContainer > m_eEmTOBContainer_WriteKey
Definition: eEmMultTestBench.h:53
GlobalSim::IOBitwise::IeEmTOB::s_RHad_width
static constexpr std::size_t s_RHad_width
Count: Size of hadronic thresholds satisfied bitset.
Definition: IeEmTOB.h:38
GlobalSim
AlgTool that to test whether expected the TIP values generated by data supplied by eEmMultTestBench c...
Definition: CommonSelector.cxx:8
python.getCurrentFolderTag.fn
fn
Definition: getCurrentFolderTag.py:79
GlobalSim::eEmMultTestBench::m_TIPword_fileName
Gaudi::Property< std::string > m_TIPword_fileName
Definition: eEmMultTestBench.h:75
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
GlobalSim::IOBitwise::ICommonTOB::s_eta_width
static constexpr std::size_t s_eta_width
Size of the eta bitset.
Definition: ICommonTOB.h:37
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
GlobalSim::trim
std::string trim(std::string s)
Definition: trim.cxx:7
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
GlobalSim::IOBitwise::IeEmTOB::s_SeedIsMax_width
static constexpr std::size_t s_SeedIsMax_width
Count: Size of Seed supercell is a local maxima bit.
Definition: IeEmTOB.h:48
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::eEmMultTestBench::initialize
virtual StatusCode initialize() override
Definition: eEmMultTestBench.cxx:23
AthAlgorithm
Definition: AthAlgorithm.h:47
GlobalSim::eEmMultTestBench::m_tob_stream
std::ifstream m_tob_stream
Definition: eEmMultTestBench.h:83
GlobalSim::IOBitwise
Definition: CommonSortSelectAlgTool.h:17
GlobalSim::eEmMultTestBench::make_tob
GlobalSim::IOBitwise::IeEmTOB * make_tob(const std::string &s) const
Definition: eEmMultTestBench.cxx:116
PathResolver.h
GlobalSim::IOBitwise::IeEmTOB::s_WsTot_width
static constexpr std::size_t s_WsTot_width
Count: Size of WsTot algorithm thresholds satisfied bitset.
Definition: IeEmTOB.h:40
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
GlobalSim::eEmMultTestBench::m_TIPword_stream
std::unique_ptr< std::ifstream > m_TIPword_stream
Definition: eEmMultTestBench.h:84
GlobalSim::eEmMultTestBench::m_TIPword_WriteKey
SG::WriteHandleKey< TIPword > m_TIPword_WriteKey
Definition: eEmMultTestBench.h:61
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
Definition: PathResolver.cxx:221
GlobalSim::IOBitwise::IeEmTOB::s_Seed_width
static constexpr std::size_t s_Seed_width
Count: Size of Seed eta position in the TOB bitset.
Definition: IeEmTOB.h:44
GlobalSim::IOBitwise::IeEmTOB
Class to hold eFexROI TOB bits.
Definition: IeEmTOB.h:29
GlobalSim::eEmMultTestBench::eEmMultTestBench
eEmMultTestBench(const std::string &name, ISvcLocator *pSvcLocator)
Definition: eEmMultTestBench.cxx:18
GlobalSim::eEmMultTestBench::TIPword_from_file
std::unique_ptr< TIPword > TIPword_from_file() const
Definition: eEmMultTestBench.cxx:104
common
Definition: common.py:1