GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TParsingDiagnostics.h
Go to the documentation of this file.
1#ifndef TPARSINGDIAGNOSTICS_H
2#define TPARSINGDIAGNOSTICS_H
3
4/** \addtogroup Sorting
5 * @{
6 */
7
8////////////////////////////////////////////////////////////////////////////////
9///
10/// \class TParsingDiagnostics
11///
12/// This class gathers various diagnostics calculated during the sorting from
13/// a raw file to a fragment tree and analysis tree and provides convenient
14/// methods of printing and/or visualizing them.
15///
16////////////////////////////////////////////////////////////////////////////////
17
18#include <iostream>
19#include <iomanip>
20#include <string>
21#include <vector>
22#include <unordered_map>
23
24#ifndef __CINT__
25#include <memory>
26#endif
27
28#include "TObject.h"
29#include "TH1F.h"
30
31#include "TSingleton.h"
32#include "TPPG.h"
33#include "TFragment.h"
34
35class TParsingDiagnosticsData : public TObject {
36public:
38 explicit TParsingDiagnosticsData(const std::shared_ptr<const TFragment>& frag);
42 TParsingDiagnosticsData& operator=(TParsingDiagnosticsData&&) noexcept = default;
44
45 void Update(const std::shared_ptr<const TFragment>& frag);
46 using TObject::Print;
47 void Print(UInt_t address) const;
48
49 // getters
50 UInt_t MinChannelId() const { return fMinChannelId; }
51 UInt_t MaxChannelId() const { return fMaxChannelId; }
52
53 Long_t NumberOfHits() const { return fNumberOfHits; }
54
55 int64_t DeadTime() const { return fDeadTime; }
56 int64_t MinTimeStamp() const { return fMinTimeStamp; }
57 int64_t MaxTimeStamp() const { return fMaxTimeStamp; }
58
59private:
60 UInt_t fMinChannelId{0}; ///< minimum channel id per channel address
61 UInt_t fMaxChannelId{0}; ///< maximum channel id per channel address
62
63 Long_t fNumberOfHits{0}; ///< number of hits per channel address
64
65 int64_t fDeadTime{0}; ///< deadtime per channel address
66 int64_t fMinTimeStamp{0}; ///< minimum timestamp per channel address
67 int64_t fMaxTimeStamp{0}; ///< maximum timestamp per channel address
68
69 /// \cond CLASSIMP
70 ClassDefOverride(TParsingDiagnosticsData, 1) // NOLINT(readability-else-after-return)
71 /// \endcond
72};
73
74class TParsingDiagnostics : public TSingleton<TParsingDiagnostics> {
75public:
76 friend class TSingleton<TParsingDiagnostics>;
77
81 TParsingDiagnostics& operator=(const TParsingDiagnostics&) = default;
82 TParsingDiagnostics& operator=(TParsingDiagnostics&&) noexcept = default;
84
85private:
86 // fragment tree diagnostics (should these all be static?)
87 // detector type unordered_maps
88 std::unordered_map<Short_t, Long_t> fNumberOfGoodFragments; ///< unordered_map of number of good fragments per detector type
89 std::unordered_map<Short_t, Long_t> fNumberOfBadFragments; ///< unordered_map of number of bad fragments per detector type
90
91 // channel address unordered_maps
92 std::unordered_map<UInt_t, TParsingDiagnosticsData> fChannelAddressData; ///< unordered_map of data per channel address
93
94 time_t fMinDaqTimeStamp{0}; ///< minimum daq timestamp
95 time_t fMaxDaqTimeStamp{0}; ///< maximum daq timestamp
96
97 Int_t fMinNetworkPacketNumber{0x7fffffff}; ///< minimum network packet id
98 Int_t fMaxNetworkPacketNumber{0}; ///< maximum network packet id
99
101
102 // ppg diagnostics
103 ULong64_t fPPGCycleLength{0};
104
105 TH1F* fIdHist{nullptr}; ///< histogram of event survival
106
107public:
108//"setter" functions
109#ifndef __CINT__
110 void GoodFragment(const std::shared_ptr<const TFragment>&);
111#endif
112 void GoodFragment(Short_t detType)
113 {
114 fNumberOfGoodFragments[detType]++;
115 }
116 void BadFragment(Short_t detType) { fNumberOfBadFragments[detType]++; }
117
118 void ReadPPG(TPPG*);
119
120 // getter functions
121 Long_t NumberOfGoodFragments(Short_t detType)
122 {
123 if(fNumberOfGoodFragments.find(detType) != fNumberOfGoodFragments.end()) {
124 return fNumberOfGoodFragments[detType];
125 }
126 return 0;
127 }
128 Long_t NumberOfBadFragments(Short_t detType)
129 {
130 if(fNumberOfBadFragments.find(detType) != fNumberOfBadFragments.end()) {
131 return fNumberOfBadFragments[detType];
132 }
133 return 0;
134 }
135
136 ULong64_t PPGCycleLength() const { return fPPGCycleLength; }
137
138 // other functions
139 void WriteToFile(const char*) const;
140
141 void Copy(TObject&) const override;
142 void Clear(Option_t* opt = "all") override;
143 void Print(Option_t* opt = "") const override;
144 void Draw(Option_t* opt = "") override;
145
146 /// \cond CLASSIMP
147 ClassDefOverride(TParsingDiagnostics, 2); // NOLINT(readability-else-after-return)
148 /// \endcond
149};
150/*! @} */
151#endif
Definition TPPG.h:132
TParsingDiagnosticsData(const TParsingDiagnosticsData &)=default
int64_t fMinTimeStamp
minimum timestamp per channel address
UInt_t fMaxChannelId
maximum channel id per channel address
void Update(const std::shared_ptr< const TFragment > &frag)
int64_t fDeadTime
deadtime per channel address
TParsingDiagnosticsData(TParsingDiagnosticsData &&) noexcept=default
UInt_t fMinChannelId
minimum channel id per channel address
void Print(UInt_t address) const
Long_t fNumberOfHits
number of hits per channel address
int64_t fMaxTimeStamp
maximum timestamp per channel address
void Copy(TObject &) const override
time_t fMaxDaqTimeStamp
maximum daq timestamp
ULong64_t PPGCycleLength() const
Int_t fMinNetworkPacketNumber
minimum network packet id
time_t fMinDaqTimeStamp
minimum daq timestamp
void Print(Option_t *opt="") const override
void Clear(Option_t *opt="all") override
TParsingDiagnostics(TParsingDiagnostics &&) noexcept=default
Long_t NumberOfGoodFragments(Short_t detType)
void GoodFragment(Short_t detType)
void Draw(Option_t *opt="") override
TH1F * fIdHist
histogram of event survival
void WriteToFile(const char *) const
std::unordered_map< UInt_t, TParsingDiagnosticsData > fChannelAddressData
unordered_map of data per channel address
Long_t NumberOfBadFragments(Short_t detType)
Int_t fMaxNetworkPacketNumber
maximum network packet id
std::unordered_map< Short_t, Long_t > fNumberOfBadFragments
unordered_map of number of bad fragments per detector type
void BadFragment(Short_t detType)
void GoodFragment(const std::shared_ptr< const TFragment > &)
std::unordered_map< Short_t, Long_t > fNumberOfGoodFragments
unordered_map of number of good fragments per detector type