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