ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimOutputHeaderTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef FPGATrackSim_READOUTPUTHEADERTOOL_H
6#define FPGATrackSim_READOUTPUTHEADERTOOL_H
7
14
16
17#include "GaudiKernel/ITHistSvc.h"
18
19#include "TFile.h"
20#include "TTree.h"
21
22#include <numeric>
23#include <atomic>
24
27
29{
30
31public:
32
33 FPGATrackSimOutputHeaderTool(const std::string&, const std::string&, const IInterface*);
34 virtual ~FPGATrackSimOutputHeaderTool() = default;
35 virtual StatusCode initialize() override;
36 virtual StatusCode finalize() override;
37
38 // Helpers to add branches for reading or writing.. Make this completely generic.
39 FPGATrackSimLogicalEventInputHeader* addInputBranch(const std::string& branchName, bool write = true);
40 FPGATrackSimLogicalEventOutputHeader* addOutputBranch(const std::string& branchName, bool write = true);
41
42 // Helper function; part of initialize that actually sets up the branches for reading.
43 StatusCode configureReadBranches();
44
45 // Actually read or write the corresponding objects.
46 StatusCode readData(bool &last);
47 StatusCode writeData();
48
49 // Not sure I understand why this is done like this.
50 std::string fileName() { return std::accumulate(m_inpath.value().begin(), m_inpath.value().end(), std::string{}); }
51
52 // Not sure this is needed, but it was in the interface.
53 TTree* getEventTree() { return m_EventTree; }
54
56
57private:
58 // JO configuration (Converted to Gaudi::Property).
59
60 // This is a vector because it allows us to read multiple files.
61 // Only relevant for reading, writing multiple files isn't supported.
62 Gaudi::Property<std::vector<std::string>> m_inpath {this, "InFileName", {"."}, "input file paths"};
63
64 // RECREATE and HEADER are both "write" options. RECREATE (re)creates the output ROOT file.
65 // HEADER does not, it assumes some other tool or service has opened the file.
66 Gaudi::Property<std::string> m_rwoption {this, "RWstatus", std::string("READ"), "define read or write file option: READ, RECREATE, HEADER"};
67
68 // Name of the output tree to create, can be overridden.
69 Gaudi::Property<std::string> m_treeName {this, "OutputTreeName", "FPGATrackSimLogicalEventTree", "Name of the output TTree to create."};
70
71 // Service handle for the histogram service.
72 ServiceHandle<ITHistSvc> m_tHistSvc {this, "THistSvc", "THistSvc"};
73
74 // Max output events
75 Gaudi::Property<int> m_eventLimit {this, "EventLimit", 10000 , "Maximum Number of Events to Output"};
76
77 // For event level output control
78 Gaudi::Property<bool> m_requireActivation {this, "RequireActivation", false , "Only output if activated on event, good for doing a single region in a large file"};
79
80 // internal counters
81 std::atomic<unsigned> m_event = 0;
82 std::atomic<unsigned> m_totevent = 0;
83 std::atomic<unsigned> m_file = 0;
84 bool m_activated{false}; // static so if any instance is active they all are
85
86 // These were protected in the interface but I don't think they have to be.
87 std::vector<FPGATrackSimLogicalEventInputHeader*> m_eventInputHeaders;
88 std::vector<FPGATrackSimLogicalEventOutputHeader*> m_eventOutputHeaders;
89
90 std::vector<std::string> m_branchNameIns;
91 std::vector<std::string> m_branchNameOuts;
92
93 TFile *m_infile = nullptr;
94 TTree *m_EventTree = nullptr;
95
96 StatusCode openFile(std::string const & path);
97
98};
99
100#endif // FPGATrackSim_READOUTPUTHEADERTOOL_H
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
virtual ~FPGATrackSimOutputHeaderTool()=default
FPGATrackSimLogicalEventOutputHeader * addOutputBranch(const std::string &branchName, bool write=true)
std::vector< std::string > m_branchNameIns
Gaudi::Property< std::string > m_treeName
Gaudi::Property< std::string > m_rwoption
std::vector< std::string > m_branchNameOuts
std::vector< FPGATrackSimLogicalEventInputHeader * > m_eventInputHeaders
virtual StatusCode initialize() override
FPGATrackSimOutputHeaderTool(const std::string &, const std::string &, const IInterface *)
std::vector< FPGATrackSimLogicalEventOutputHeader * > m_eventOutputHeaders
Gaudi::Property< std::vector< std::string > > m_inpath
StatusCode openFile(std::string const &path)
FPGATrackSimLogicalEventInputHeader * addInputBranch(const std::string &branchName, bool write=true)