JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwEPICSEvent.h
Go to the documentation of this file.
1/*!
2 * \file QwEPICSEvent.h
3 * \brief EPICS data event handling and storage
4 *
5 * Adopted from G0EPICSEvent class.
6 */
7
8#pragma once
9
10// System headers
11#include <map>
12#include <vector>
13#include <string>
14using std::string;
15
16// ROOT headers
17#include "Rtypes.h"
18#include "TString.h"
19#include "TTree.h"
20#ifdef HAS_RNTUPLE_SUPPORT
21#include "ROOT/RNTupleModel.hxx"
22#include "ROOT/RField.hxx"
23#endif // HAS_RNTUPLE_SUPPORT
24
25// Qweak headers
26#include "QwOptions.h"
27
28// Forward declarations
29class QwParityDB;
31
32/**
33 * \class QwEPICSEvent
34 * \ingroup QwAnalysis
35 * \brief EPICS slow controls data management
36 *
37 * Handles EPICS slow controls data including beam parameters, magnet
38 * settings, and other experimental conditions. Provides storage,
39 * retrieval, and database interface for slow controls information.
40 */
42{
43 public:
44
45 /// EPICS data types
47
48
49 /// Default constructor
51 /// Virtual destructor
52 virtual ~QwEPICSEvent();
53
54
55 /// \brief Define the configuration options
56 static void DefineOptions(QwOptions &options);
57 /// \brief Process the configuration options
58 void ProcessOptions(QwOptions &options);
59
60
61 // Add a tag to the list
62 Int_t AddEPICSTag(const string& tag, const string& table = "",
63 EQwEPICSDataType datatype = kEPICSFloat);
64
65 Int_t LoadChannelMap(TString mapfile);
66
67 std::vector<Double_t> ReportAutogains(std::vector<std::string> tag_list = fDefaultAutogainList);
68
69 void ExtractEPICSValues(const string& data, int event);
70
71 /// Find the index of an EPICS variable, or return error
72 Int_t FindIndex(const string& tag) const;
73
74 Double_t GetDataValue(const string& tag) const; // get recent value corr. to tag
75 TString GetDataString(const string& tag) const;
76
77
78 int SetDataValue(const string& tag, const double value, const int event);
79 int SetDataValue(const string& tag, const string& value, const int event);
80 int SetDataValue(int index, const double value, const int event);
81 int SetDataValue(int index, const string& value, const int event);
82
83 Bool_t HasDataLoaded() const { return fIsDataLoaded; };
84
85 Int_t DetermineIHWPPolarity() const;
87
89
90 void PrintAverages() const;
91 void PrintVariableList() const;
92 // void DefineEPICSVariables();
93 void ReportEPICSData() const;
94
95 void ResetCounters();
96
97 void FillDB(QwParityDB *db);
98 void FillSlowControlsData(QwParityDB *db);
99 void FillSlowControlsStrings(QwParityDB *db);
100 void FillSlowControlsSettings(QwParityDB *db);
101
102
103 private:
104
105 // Tree array indices
108
109 // Flag to indicate that the event contains data
111 void SetDataLoaded(Bool_t flag) { fIsDataLoaded = flag; };
112
113 public:
114
115 /// \brief Construct the branch and tree vector
116 void ConstructBranchAndVector(TTree *tree, TString& prefix, QwRootTreeBranchVector &values);
117 /// \brief Fill the tree vector
118 void FillTreeVector(QwRootTreeBranchVector &values) const;
119
120#ifdef HAS_RNTUPLE_SUPPORT
121 /// \brief Construct the RNTuple fields and vector
122 void ConstructNTupleAndVector(std::unique_ptr<ROOT::RNTupleModel>& model, TString& prefix, std::vector<Double_t>& values, std::vector<std::shared_ptr<Double_t>>& fieldPtrs);
123 /// \brief Fill the RNTuple vector
124 void FillNTupleVector(std::vector<Double_t>& values) const;
125#endif // HAS_RNTUPLE_SUPPORT
126
127
128 public:
129
130 static std::vector<std::string> GetDefaultAutogainList() { return fDefaultAutogainList; };
131 static void SetDefaultAutogainList(std::vector<std::string>& input_list);
132
134
135 private:
136
137 /// Default autogain list
138 static std::vector<std::string> fDefaultAutogainList;
139 /// Initialize the default autogain list
140 static void InitDefaultAutogainList();
141
142
143 private:
144
145 static const int kDebug;
146 static const int kEPICS_Error;
147 static const int kEPICS_OK;
148 static const Double_t kInvalidEPICSData;
149 // Int_t maxsize = 300;
150
151 // Flag to disable database accesses for EPICS events
153
154 // Test whether the string is a number string or not
155 Bool_t IsNumber(const string& word) {
156 size_t pos;
157 pos = word.find_first_not_of("0123456789.+-eE"); // white space not allowed
158 if (pos != std::string::npos) return kFALSE;
159 else return kTRUE;
160 }
161
162 struct EPICSVariableRecord { //One EPICS variable record.
164 Bool_t Filled;
165 Double_t Value;
166 TString StringValue;
167 };
168 std::vector<EPICSVariableRecord> fEPICSDataEvent;
169
170
171 /* The next two variables will contain the running sum and sum *
172 * of squares for use in calculating the average and variance. */
174 Bool_t Filled;
176 Double_t Sum;
177 Double_t SquaredSum;
178 Double_t Minimum;
179 Double_t Maximum;
180 TString SavedString;
181 };
182 std::vector<EPICSCumulativeRecord> fEPICSCumulativeData;
183
184
185 Int_t fNumberEPICSEvents; // Number of EPICS events in the run
186 Int_t fNumberEPICSVariables; // Number of defined EPICS variables
187 std::vector<std::string> fEPICSVariableList; // List of defined EPICS variables
188 std::vector<std::string> fEPICSTableList; // List of DB tables to write
189 std::vector<EQwEPICSDataType> fEPICSVariableType;
190
191 std::map<std::string,Int_t> fEPICSVariableMap;
192
193 TList *GetEPICSStringValues();
194
197
200
201
202}; // class QwEPICSEvent
An options class which parses command line, config file and environment.
EQwWienMode
Double Wien configuration.
Definition QwTypes.h:308
Int_t AddEPICSTag(const string &tag, const string &table="", EQwEPICSDataType datatype=kEPICSFloat)
Bool_t fIsDataLoaded
Bool_t HasDataLoaded() const
static void DefineOptions(QwOptions &options)
Define the configuration options.
Int_t DetermineIHWPPolarity() const
void ProcessOptions(QwOptions &options)
Process the configuration options.
std::vector< std::string > fEPICSVariableList
void WriteEPICSStringValues()
std::vector< EPICSVariableRecord > fEPICSDataEvent
void ExtractEPICSValues(const string &data, int event)
void FillSlowControlsSettings(QwParityDB *db)
Int_t LoadChannelMap(TString mapfile)
bool fDisableDatabase
virtual ~QwEPICSEvent()
Virtual destructor.
Double_t fNominalWienAngle
Bool_t IsNumber(const string &word)
static const int kDebug
void FillSlowControlsStrings(QwParityDB *db)
int SetDataValue(const string &tag, const double value, const int event)
void PrintAverages() const
void CalculateRunningValues()
void ReportEPICSData() const
Int_t fExtraHelicityReversal
size_t fTreeArrayIndex
static void SetDefaultAutogainList(std::vector< std::string > &input_list)
static std::vector< std::string > fDefaultAutogainList
Default autogain list.
void FillDB(QwParityDB *db)
std::vector< EQwEPICSDataType > fEPICSVariableType
void SetDataLoaded(Bool_t flag)
EQwWienMode DetermineWienMode() const
void FillSlowControlsData(QwParityDB *db)
std::map< std::string, Int_t > fEPICSVariableMap
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values)
Construct the branch and tree vector.
std::vector< EPICSCumulativeRecord > fEPICSCumulativeData
static void InitDefaultAutogainList()
Initialize the default autogain list.
Int_t FindIndex(const string &tag) const
Find the index of an EPICS variable, or return error.
void FillTreeVector(QwRootTreeBranchVector &values) const
Fill the tree vector.
std::vector< Double_t > ReportAutogains(std::vector< std::string > tag_list=fDefaultAutogainList)
static const int kEPICS_OK
Double_t GetDataValue(const string &tag) const
static const Double_t kInvalidEPICSData
static std::vector< std::string > GetDefaultAutogainList()
Int_t fNumberEPICSVariables
TString GetDataString(const string &tag) const
Bool_t fPrecessionReversal
std::vector< std::string > fEPICSTableList
Int_t fNumberEPICSEvents
void ResetCounters()
EQwEPICSDataType
EPICS data types.
size_t fTreeArrayNumEntries
TList * GetEPICSStringValues()
void PrintVariableList() const
QwEPICSEvent()
Default constructor.
Bool_t fBlinderReversalForRunTwo
static const int kEPICS_Error
Command-line and configuration file options processor.
Definition QwOptions.h:141
A helper class to manage a vector of branch entries for ROOT trees.
Definition QwRootFile.h:53