ATLAS Offline Software
Loading...
Searching...
No Matches
TOBTextWriter.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3 */
4#ifndef GLOBALSIM_TOBTEXTWRITER_H
5#define GLOBALSIM_TOBTEXTWRITER_H
6
7/*
8 Writes a container of TOBs back out as a hex text file, in the same shape as
9 the firmware test vectors: one line per event, one token per TOB, each token
10 the whole word in hex (spec width / 4 characters).
11
12 The bit layout is chosen by name at configuration time through the BitSpec
13 property, and looked up in a registry of packing functions kept in the .cxx.
14 The writer itself holds no knowledge of field positions, and no knowledge of
15 which specs exist: adding a TOB type is one line in that registry, with no
16 new component and no new class.
17
18 Lines are written as the events arrive, so the algorithm is non-reentrant and
19 refuses to run if an event reaches it out of order: with more than one event
20 in flight the correspondence between line N and event N no longer holds, and
21 nothing else about the output would look wrong. Run these jobs with a single
22 concurrent event.
23*/
24
28
29#include <cstdint>
30#include <fstream>
31#include <functional>
32#include <string>
33
34namespace GlobalSim {
35
36 class TOBTextWriter : public AthAlgorithm {
37 public:
39
40 virtual StatusCode initialize() override;
41 virtual StatusCode execute(const EventContext& ctx) override;
42 virtual StatusCode finalize() override;
43
44 private:
46 this, "Input", "", "Container of TOBs to write out"};
47
48 Gaudi::Property<std::string> m_specName{
49 this, "BitSpec", "",
50 "Name of the BitSpec giving the bit layout, e.g. topoc_pu_type"};
51
52 Gaudi::Property<std::string> m_outFile{
53 this, "OutputFile", "globalsim_tobs.hex.txt",
54 "Output file: one line per event, space-separated hex words"};
55
56 // Taken from the registry in initialize(). The width is kept only so that
57 // the startup message reports the token size, which is the quickest way to
58 // spot an instance pointed at the wrong spec.
59 std::function<std::string(const SG::AuxElement&)> m_pack;
60 std::size_t m_width{0};
61
62 std::ofstream m_out;
63
64 // Guards line N == event N. The first event seen sets the start, so a job
65 // that skips events is still accepted; any gap after that is an error.
66 uint64_t m_nextEvt{0};
67 uint64_t m_nWritten{0};
68 };
69
70} // namespace GlobalSim
71
72#endif // GLOBALSIM_TOBTEXTWRITER_H
Property holding a SG store/key/clid from which a ReadHandle is made.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Gaudi::Property< std::string > m_outFile
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
std::function< std::string(const SG::AuxElement &)> m_pack
SG::ReadHandleKey< xAOD::BaseContainer > m_inKey
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
virtual StatusCode initialize() override
virtual StatusCode finalize() override
Gaudi::Property< std::string > m_specName
Property holding a SG store/key/clid from which a ReadHandle is made.
AlgTool to read in LArStripNeighborhoods, and run the BDT Algorithm.
Definition BitSpec.h:23
AuxElement(SG::AuxVectorData *container, size_t index)
Base class for elements of a container that can have aux data.