ARTEMIS-CRIB
 
Loading...
Searching...
No Matches
TTreePeriodicEventStore.h
Go to the documentation of this file.
1/**
2 * @file TTreePeriodicEventStore.h
3 * @brief Declaration of TTreePeriodicEventStore for periodic event handling in a TTree
4 * @author Kodai Okawa<okawa@cns.s.u-tokyo.ac.jp>
5 * @date 2024-07-16 15:16:56
6 * @note last modified: 2025-01-08 20:03:50
7 * @details
8 */
9
10#ifndef CRIB_TTREEPERIODICEVENTSTORE_H_
11#define CRIB_TTREEPERIODICEVENTSTORE_H_
12
13#include "IEventStore.h"
14#include "TProcessor.h"
15
16namespace art {
17class TEventHeader;
18} // namespace art
19
20class TTree;
21
22namespace art::crib {
23/**
24 * @class TTreePeriodicEventStore
25 * @brief A processor class that implements periodic event reading from a TTree.
26 *
27 * This class inherits from TProcessor and IEventStore to provide a mechanism
28 * for initializing, reading, and processing events periodically from a ROOT
29 * TTree. The user can configure the input file name, tree name, and number of
30 * events to process through various parameters.
31 *
32 * ### Example Steering File
33 *
34 * ```yaml
35 * Processor:
36 * - name: MyTTreePeriodicEventStore
37 * type: art::crib::TTreePeriodicEventStore
38 * parameter:
39 * FileName: temp.root # [TString] The name of input file
40 * MaxEventNum: 0 # [Long_t] The maximum event number to be analyzed.
41 * OutputTransparency: 0 # [Bool_t] Output is persistent if false (default)
42 * TreeName: tree # [TString] The name of input tree
43 * Verbose: 1 # [Int_t] verbose level (default 1 : non quiet)
44 * ```
45 */
47 public:
48 /**
49 * @brief Constructor.
50 */
52
53 /**
54 * @brief Destructor.
55 */
56 ~TTreePeriodicEventStore() override;
57
58 /**
59 * @brief Initializes the TTreePeriodicEventStore with the given event collection.
60 *
61 * @param col Pointer to a TEventCollection that holds shared objects
62 * and conditions among processors.
63 *
64 */
65 void Init(TEventCollection *col) override;
66
67 /**
68 * @brief Processes one event from the TTree.
69 */
70 void Process() override;
71
72 /**
73 * @brief Returns the run number of the current event.
74 * @return The run number if available, otherwise 0.
75 */
76 Int_t GetRunNumber() const override;
77
78 /**
79 * @brief Returns the run name as a C-style string.
80 * @return A const char pointer to the run name, or an empty string if unavailable.
81 */
82 const char *GetRunName() const override;
83
84 /**
85 * @brief Returns the run name as a std::string.
86 * @return The run name, or an empty string if unavailable.
87 */
88 std::string GetStrRunName() const;
89
90 private:
91 TString fFileName{"temp.root"}; ///< The name (or pattern) of the input file(s). Default is "temp.root".
92 TString fTreeName{"tree"}; ///< The name of the TTree to be processed. Default is "tree".
93 TTree *fTree{nullptr}; ///<! Pointer to the TTree object that holds event data.
94 Long_t fEventNum{0}; ///< The current event number within the run.
95 Long_t fMaxEventNum{0}; ///< The maximum number of events to process.
96 Long_t fTreeEventNum{0}; ///< The total number of events in the TTree.
97 Long_t fCurrentNum{0}; ///< The current entry index in the TTree.
98
99 TEventHeader *fEventHeader{nullptr}; ///<! Pointer to the TEventHeader object read from the TTree.
100
101 ClassDefOverride(TTreePeriodicEventStore, 3); ///< ROOT class definition macro.
102};
103} // namespace art::crib
104
105#endif // end of #ifdef CRIB_TTREEPERIODICEVENTSTORE_H_
A processor class that implements periodic event reading from a TTree.
void Init(TEventCollection *col) override
Initializes the TTreePeriodicEventStore with the given event collection.
ClassDefOverride(TTreePeriodicEventStore, 3)
ROOT class definition macro.
TString fFileName
The name (or pattern) of the input file(s). Default is "temp.root".
Int_t GetRunNumber() const override
Returns the run number of the current event.
Long_t fCurrentNum
The current entry index in the TTree.
Long_t fEventNum
The current event number within the run.
TString fTreeName
The name of the TTree to be processed. Default is "tree".
Long_t fTreeEventNum
The total number of events in the TTree.
void Process() override
Processes one event from the TTree.
TEventHeader * fEventHeader
! Pointer to the TEventHeader object read from the TTree.
TTree * fTree
! Pointer to the TTree object that holds event data.
std::string GetStrRunName() const
Returns the run name as a std::string.
Long_t fMaxEventNum
The maximum number of events to process.
const char * GetRunName() const override
Returns the run name as a C-style string.
return to the guide