QwAnalysis
QwEPICSEvent Class Reference

#include <QwEPICSEvent.h>

Data Structures

struct  EPICSCumulativeRecord
 
struct  EPICSVariableRecord
 

Public Types

enum  EQwEPICSDataType { kEPICSString, kEPICSFloat, kEPICSInt }
 EPICS data types. More...
 

Public Member Functions

 QwEPICSEvent ()
 Default constructor. More...
 
virtual ~QwEPICSEvent ()
 Virtual destructor. More...
 
void ProcessOptions (QwOptions &options)
 Process the configuration options. More...
 
Int_t AddEPICSTag (const string &tag, const string &table="", EQwEPICSDataType datatype=kEPICSFloat)
 
Int_t LoadChannelMap (TString mapfile)
 
std::vector< Double_t > ReportAutogains (std::vector< std::string > tag_list=fDefaultAutogainList)
 
void ExtractEPICSValues (const string &data, int event)
 
Int_t FindIndex (const string &tag) const
 Find the index of an EPICS variable, or return error. More...
 
Double_t GetDataValue (const string &tag) const
 
TString GetDataString (const string &tag) const
 
int SetDataValue (const string &tag, const double value, const int event)
 
int SetDataValue (const string &tag, const string &value, const int event)
 
int SetDataValue (int index, const double value, const int event)
 
int SetDataValue (int index, const string &value, const int event)
 
Bool_t HasDataLoaded () const
 
Int_t DetermineIHWPPolarity () const
 
EQwWienMode DetermineWienMode () const
 
void CalculateRunningValues ()
 
void PrintAverages () const
 
void PrintVariableList () const
 
void ReportEPICSData () const
 
void ResetCounters ()
 
void FillDB (QwParityDB *db)
 
void FillSlowControlsData (QwParityDB *db)
 
void FillSlowControlsStrigs (QwParityDB *db)
 
void FillSlowControlsSettings (QwParityDB *db)
 
void ConstructBranchAndVector (TTree *tree, TString &prefix, std::vector< Double_t > &values)
 Construct the branch and tree vector. More...
 
void FillTreeVector (std::vector< Double_t > &values) const
 Fill the tree vector. More...
 
void WriteEPICSStringValues ()
 

Static Public Member Functions

static void DefineOptions (QwOptions &options)
 Define the configuration options. More...
 
static std::vector< std::string > GetDefaultAutogainList ()
 
static void SetDefaultAutogainList (std::vector< std::string > &input_list)
 

Private Member Functions

void SetDataLoaded (Bool_t flag)
 
Bool_t IsNumber (const string &word)
 
TList * GetEPICSStringValues ()
 

Static Private Member Functions

static void InitDefaultAutogainList ()
 Initialize the default autogain list. More...
 

Private Attributes

size_t fTreeArrayIndex
 
size_t fTreeArrayNumEntries
 
Bool_t fIsDataLoaded
 
bool fDisableDatabase
 
std::vector< EPICSVariableRecordfEPICSDataEvent
 
std::vector
< EPICSCumulativeRecord
fEPICSCumulativeData
 
Int_t fNumberEPICSEvents
 
Int_t fNumberEPICSVariables
 
std::vector< std::string > fEPICSVariableList
 
std::vector< std::string > fEPICSTableList
 
std::vector< EQwEPICSDataTypefEPICSVariableType
 
std::map< std::string, Int_t > fEPICSVariableMap
 
Bool_t fBlinderReversalForRunTwo
 
Bool_t fPrecessionReversal
 
Double_t fNominalWienAngle
 
Int_t fExtraHelicityReversal
 

Static Private Attributes

static std::vector< std::string > fDefaultAutogainList
 Default autogain list. More...
 
static const int kDebug = 0
 
static const int kEPICS_Error = -1
 
static const int kEPICS_OK = 1
 
static const Double_t kInvalidEPICSData = -999999.0
 

Detailed Description

Definition at line 26 of file QwEPICSEvent.h.

Member Enumeration Documentation

EPICS data types.

Enumerator
kEPICSString 
kEPICSFloat 
kEPICSInt 

Definition at line 31 of file QwEPICSEvent.h.

Constructor & Destructor Documentation

QwEPICSEvent::QwEPICSEvent ( )

Default constructor.

Definition at line 47 of file QwEPICSEvent.cc.

References InitDefaultAutogainList(), kDebug, PrintVariableList(), and SetDataLoaded().

49 {
50  SetDataLoaded(kFALSE);
52  if (kDebug == 1) PrintVariableList();
53 }
static void InitDefaultAutogainList()
Initialize the default autogain list.
Double_t fNominalWienAngle
Definition: QwEPICSEvent.h:176
static const int kDebug
Definition: QwEPICSEvent.h:123
Bool_t fBlinderReversalForRunTwo
Definition: QwEPICSEvent.h:173
void PrintVariableList() const
void SetDataLoaded(Bool_t flag)
Definition: QwEPICSEvent.h:96
Bool_t fPrecessionReversal
Definition: QwEPICSEvent.h:174

+ Here is the call graph for this function:

QwEPICSEvent::~QwEPICSEvent ( )
virtual

Virtual destructor.

Definition at line 56 of file QwEPICSEvent.cc.

57 {
58 }

Member Function Documentation

Int_t QwEPICSEvent::AddEPICSTag ( const string &  tag,
const string &  table = "",
EQwEPICSDataType  datatype = kEPICSFloat 
)

Definition at line 221 of file QwEPICSEvent.cc.

References fEPICSTableList, fEPICSVariableList, fEPICSVariableMap, fEPICSVariableType, and fNumberEPICSVariables.

Referenced by LoadChannelMap().

225 {
226  fEPICSVariableList.push_back(tag);
227  fEPICSVariableMap[tag] = fEPICSVariableList.size() - 1;
228  fEPICSTableList.push_back(table);
229  fEPICSVariableType.push_back(datatype);
231  return 0;
232 }
Int_t fNumberEPICSVariables
Definition: QwEPICSEvent.h:164
std::vector< EQwEPICSDataType > fEPICSVariableType
Definition: QwEPICSEvent.h:167
std::vector< std::string > fEPICSTableList
Definition: QwEPICSEvent.h:166
std::map< std::string, Int_t > fEPICSVariableMap
Definition: QwEPICSEvent.h:169
std::vector< std::string > fEPICSVariableList
Definition: QwEPICSEvent.h:165

+ Here is the caller graph for this function:

void QwEPICSEvent::CalculateRunningValues ( )

Definition at line 235 of file QwEPICSEvent.cc.

References fEPICSCumulativeData, fEPICSDataEvent, fEPICSVariableList, fEPICSVariableType, fNumberEPICSEvents, fNumberEPICSVariables, kDebug, kEPICSFloat, and kEPICSInt.

Referenced by main().

236 {
237  if (kDebug == 1) std::cout <<"Here we are in 'CalculateRunningValues'!!"<<std::endl;
238  if (kDebug == 1) std::cout<<"fNumberEPICSVariables = "<<fNumberEPICSVariables<<std::endl<<std::endl;
239 
240  Bool_t anyFilled = kFALSE;
241  for (size_t tagindex = 0; tagindex < fEPICSDataEvent.size(); tagindex++) {
242  anyFilled |= fEPICSDataEvent[tagindex].Filled;
243  }
244  if (! anyFilled) return;
245 
246  for (size_t tagindex = 0; tagindex < fEPICSVariableType.size(); tagindex++) {
247  if (fEPICSVariableType[tagindex] == kEPICSFloat ||
248  fEPICSVariableType[tagindex] == kEPICSInt) {
249 
250  if (fEPICSDataEvent[tagindex].Filled) {
251 
252  if (! fEPICSCumulativeData[tagindex].Filled) {
253  fEPICSCumulativeData[tagindex].NumberRecords = 0;
254  fEPICSCumulativeData[tagindex].Sum = 0.0;
255  fEPICSCumulativeData[tagindex].SquaredSum = 0.0;
256  fEPICSCumulativeData[tagindex].Maximum =
257  fEPICSDataEvent[tagindex].Value;
258  fEPICSCumulativeData[tagindex].Minimum =
259  fEPICSDataEvent[tagindex].Value;
260  fEPICSCumulativeData[tagindex].Filled = kTRUE;
261  }
262  fEPICSCumulativeData[tagindex].NumberRecords++;
263  fEPICSCumulativeData[tagindex].Sum +=
264  fEPICSDataEvent[tagindex].Value;
265  fEPICSCumulativeData[tagindex].SquaredSum +=
266  (fEPICSDataEvent[tagindex].Value)*(fEPICSDataEvent[tagindex].Value);
267  if (fEPICSDataEvent[tagindex].Value
268  > fEPICSCumulativeData[tagindex].Maximum) {
269  fEPICSCumulativeData[tagindex].Maximum =
270  fEPICSDataEvent[tagindex].Value;
271  }
272  if (fEPICSDataEvent[tagindex].Value
273  < fEPICSCumulativeData[tagindex].Minimum) {
274  fEPICSCumulativeData[tagindex].Minimum =
275  fEPICSDataEvent[tagindex].Value;
276  }
277  if (kDebug == 1) std::cout << "This event has "<<fEPICSVariableList[tagindex]
278  << " equal to "<< fEPICSDataEvent[tagindex].Value
279  << " giving a running average of "
280  << fEPICSCumulativeData[tagindex].Sum /
281  fEPICSCumulativeData[tagindex].NumberRecords
282  << std::endl;
283  } else {
284  if (kDebug == 1) std::cout << fEPICSVariableList[tagindex]
285  << " seems to be not filled."<<std::endl;
286  }
287  }
288 
289  ////////////////////////////////
290  else {
291  // This is a string value.
292  // Just check to see if the EPICS string has changed;
293  // if it is the same, increment the counter.
294 
295  if (! fEPICSCumulativeData[tagindex].Filled) {
296  fEPICSCumulativeData[tagindex].NumberRecords = 0;
297  fEPICSCumulativeData[tagindex].SavedString =
298  fEPICSDataEvent[tagindex].StringValue;
299  fEPICSCumulativeData[tagindex].Filled = kTRUE;
300  }
301  if (fEPICSCumulativeData[tagindex].SavedString
302  == fEPICSDataEvent[tagindex].StringValue ) {
303  fEPICSCumulativeData[tagindex].NumberRecords++;
304  }
305  }
306  }
308  //////////////////////
309 
310  if (kDebug == 1) std::cout << "fNumberEPICSEvents = " << fNumberEPICSEvents << std::endl;
311 }
static const int kDebug
Definition: QwEPICSEvent.h:123
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
std::vector< EPICSVariableRecord > fEPICSDataEvent
Definition: QwEPICSEvent.h:146
std::vector< std::string > fEPICSVariableList
Definition: QwEPICSEvent.h:165

+ Here is the caller graph for this function:

void QwEPICSEvent::ConstructBranchAndVector ( TTree *  tree,
TString &  prefix,
std::vector< Double_t > &  values 
)

Construct the branch and tree vector.

Definition at line 161 of file QwEPICSEvent.cc.

References QwLog::endl(), fEPICSVariableList, fEPICSVariableType, fTreeArrayIndex, fTreeArrayNumEntries, kEPICSFloat, kEPICSInt, kEPICSString, and QwError.

162 {
163  fTreeArrayIndex = values.size();
164  Int_t treeindex = fTreeArrayIndex;
165  for (size_t tagindex = 0; tagindex < fEPICSVariableType.size(); tagindex++) {
166  if (fEPICSVariableType[tagindex] == kEPICSString ||
167  fEPICSVariableType[tagindex] == kEPICSFloat ||
168  fEPICSVariableType[tagindex] == kEPICSInt) {
169 
170  // Add element to vector
171  values.push_back(0.0);
172 
173  // Determine branch name
174  TString name = fEPICSVariableList[tagindex];
175  name.ReplaceAll(':','_'); // remove colons before creating branch
176  TString name_type = name + "/D";
177 
178  // Create branch
179  tree->Branch(name, &(values[treeindex]), name_type);
180  treeindex++;
181 
182  } else {
183 
184  TString name = fEPICSVariableList[tagindex];
185  QwError << "Unrecognized type for EPICS variable " << name << QwLog::endl;
186 
187  }
188  }
189  fTreeArrayNumEntries = values.size() - fTreeArrayIndex;
190 }
size_t fTreeArrayIndex
Definition: QwEPICSEvent.h:91
std::vector< EQwEPICSDataType > fEPICSVariableType
Definition: QwEPICSEvent.h:167
size_t fTreeArrayNumEntries
Definition: QwEPICSEvent.h:92
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
std::vector< std::string > fEPICSVariableList
Definition: QwEPICSEvent.h:165
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

void QwEPICSEvent::DefineOptions ( QwOptions options)
static

Define the configuration options.

Defines configuration options using QwOptions functionality.

Parameters
optionsOptions object

Definition at line 69 of file QwEPICSEvent.cc.

References QwOptions::AddOptions(), and default_bool_value.

Referenced by QwOptions::DefineOptions().

70 {
71  // Option to disable EPICS database accesses
72  options.AddOptions("Default options")
73  ("disable-db-epics",
74  po::value<bool>()->default_bool_value(false),
75  "disable EPICS database access");
76 }
#define default_bool_value(b)
Definition: QwOptions.h:51
po::options_description_easy_init AddOptions(const std::string &blockname="Specialized options")
Add an option to a named block or create new block.
Definition: QwOptions.h:164

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Int_t QwEPICSEvent::DetermineIHWPPolarity ( ) const

Definition at line 1338 of file QwEPICSEvent.cc.

References QwLog::endl(), fExtraHelicityReversal, GetDataString(), QwDebug, and QwWarning.

Referenced by QwBlinder::Update().

1338  {
1339  Int_t ihwppolarity = 0;
1340  if (GetDataString("IGL1I00DI24_24M")=="OUT"){
1341  ihwppolarity = 1;
1342  } else if (GetDataString("IGL1I00DI24_24M")=="IN"){
1343  ihwppolarity = -1;
1344  } else {
1345  QwWarning << "IHWP state is not well defined: "
1346  << GetDataString("IGL1I00DI24_24M")
1347  << QwLog::endl;
1348  }
1349  QwDebug << "QwEPICSEvent::DetermineIHWPPolarity: "
1350  << "raw IHWP polarity is: "
1351  << ihwppolarity << QwLog::endl;
1352  ihwppolarity = fExtraHelicityReversal * ihwppolarity;
1353  QwDebug << "QwEPICSEvent::DetermineIHWPPolarity: "
1354  << "IHWP polarity after extra reversal is: "
1355  << ihwppolarity << QwLog::endl;
1356  return ihwppolarity;
1357 }
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
TString GetDataString(const string &tag) const
Int_t fExtraHelicityReversal
Definition: QwEPICSEvent.h:177
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EQwWienMode QwEPICSEvent::DetermineWienMode ( ) const

Definition at line 1359 of file QwEPICSEvent.cc.

References fNominalWienAngle, GetDataValue(), kWienBackward, kWienForward, kWienHorizTrans, kWienIndeterminate, and kWienVertTrans.

Referenced by ExtractEPICSValues(), and QwBlinder::Update().

1359  {
1360  EQwWienMode wienmode = kWienIndeterminate;
1361 
1362  Double_t launchangle = 0.0;
1363 
1364  Double_t vwienangle = GetDataValue("VWienAngle");
1365  Double_t phiangle = GetDataValue("Phi_FG");
1366  Double_t hwienangle = GetDataValue("HWienAngle");
1367  Double_t hoffset = 0.0;
1368  if (fabs(vwienangle)<10.0 && fabs(phiangle)<10.0){
1369  hoffset = 0.0;
1370  } else if (fabs(vwienangle)>80.0 && fabs(phiangle)>80.0
1371  && fabs(vwienangle+phiangle)<10. ){
1372  hoffset = -90.0;
1373  } else if (fabs(vwienangle)>80.0 && fabs(phiangle)>80.0
1374  && fabs(vwienangle+phiangle)>170. ){
1375  hoffset = +90.0;
1376  } else if (fabs(vwienangle)>80.0 && fabs(phiangle)<10.0) {
1377  wienmode = kWienVertTrans;
1378  }
1379  if (wienmode == kWienIndeterminate){
1380  launchangle = hoffset+hwienangle;
1381  Double_t long_proj =
1382  cos((launchangle-fNominalWienAngle)*TMath::DegToRad());
1383  if (long_proj > 0.5){
1384  wienmode = kWienForward;
1385  } else if (long_proj < -0.5){
1386  wienmode = kWienBackward;
1387  } else if (fabs(long_proj)<0.25){
1388  wienmode = kWienHorizTrans;
1389  }
1390  }
1391  return wienmode;
1392 }
Double_t GetDataValue(const string &tag) const
Double_t fNominalWienAngle
Definition: QwEPICSEvent.h:176
EQwWienMode
Double Wien configuration.
Definition: QwTypes.h:302

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwEPICSEvent::ExtractEPICSValues ( const string &  data,
int  event 
)

Definition at line 314 of file QwEPICSEvent.cc.

References DetermineWienMode(), fEPICSDataEvent, fEPICSVariableList, FindIndex(), fIsDataLoaded, QwParameterFile::HasVariablePair(), Qw::in, kDebug, kEPICS_Error, QwParameterFile::ReadNextLine(), SetDataLoaded(), SetDataValue(), QwParameterFile::TrimWhitespace(), and WienModeName().

Referenced by QwEventBuffer::FillEPICSData().

315 {
316  /* This routine will decode the input string, which holds the *
317  * epics buffer and extract the EPICS values from it. */
318 
319  if (kDebug == 1) std::cout <<"Here we are, entering 'ExtractEPICSValues'!!"<<std::endl;
320 
321  for (size_t tagindex = 0; tagindex < fEPICSVariableList.size(); tagindex++) {
322  fEPICSDataEvent[tagindex].Filled = kFALSE;
323  }
324 
325  // Convert the input stream into a stringstream so we can
326  // do manipulation on it just like reading a file
327  std::stringstream ss(data, std::stringstream::in | std::stringstream::out);
328  QwParameterFile file(ss);
329  while (file.ReadNextLine()) {
330  file.TrimWhitespace();
331  string varname, varvalue;
332  if (file.HasVariablePair(" \t\n", varname, varvalue)) {
333  Int_t tagindex = FindIndex(varname);
334  if (tagindex != kEPICS_Error) {
335  SetDataValue(tagindex, varvalue, event);
336  SetDataLoaded(kTRUE);
337  }
338  }
339  }
340  if (fIsDataLoaded) {
341  // Determine the WienMode and save it.
342  SetDataValue("WienMode",WienModeName(DetermineWienMode()),event);
343  }
344 }
static const double in
Definition: QwUnits.h:66
Bool_t fIsDataLoaded
Definition: QwEPICSEvent.h:95
static const int kDebug
Definition: QwEPICSEvent.h:123
Int_t FindIndex(const string &tag) const
Find the index of an EPICS variable, or return error.
int SetDataValue(const string &tag, const double value, const int event)
EQwWienMode DetermineWienMode() const
std::vector< EPICSVariableRecord > fEPICSDataEvent
Definition: QwEPICSEvent.h:146
void SetDataLoaded(Bool_t flag)
Definition: QwEPICSEvent.h:96
static const int kEPICS_Error
Definition: QwEPICSEvent.h:124
std::vector< std::string > fEPICSVariableList
Definition: QwEPICSEvent.h:165
std::string WienModeName(EQwWienMode type)
Definition: QwTypes.cc:145

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwEPICSEvent::FillDB ( QwParityDB db)

Definition at line 707 of file QwEPICSEvent.cc.

References QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), fDisableDatabase, FillSlowControlsData(), FillSlowControlsSettings(), FillSlowControlsStrigs(), QwParityDB::GetRunletID(), QwDatabase::Query(), and QwError.

708 {
709  // Sunday, January 16 22:09:16 EST 2011, jhlee
710  // don't change disbale database flag
711  // just disable FillSlowControlsSettings(db) when fDisableDatabase is off
712 
713  bool hold_fDisableDatabase = fDisableDatabase;
714 
715  try {
716  db->Connect();
717  mysqlpp::Query query= db->Query();
718  query << "SELECT slow_controls_settings_id FROM slow_controls_settings WHERE";
719  query << " runlet_id = " << mysqlpp::quote << db->GetRunletID();
720 
721  mysqlpp::StoreQueryResult res = query.store();
722 
723  if (res.num_rows() != 0) {
724  QwError << "This runlet already has slow controls entries in the database!" << QwLog::endl;
725  QwError << "The following slow_controls_settings_id values already exist in the database: ";
726  for (size_t i=0; i<res.num_rows(); i++) {
727  QwError << res[i][0] << " ";
728  }
729  QwError << QwLog::endl;
730  QwError << "Slow controls values from this replay will NOT be stored in the database." << QwLog::endl;
731 
732  fDisableDatabase=true;
733  }
734 
735  db->Disconnect();
736  }
737  catch (const mysqlpp::Exception& er) {
738  QwError << er.what() << QwLog::endl;
739  QwError << "Unable to determine if there are other slow controls entries in the database for this run. THERE MAY BE DUPLICATES." << QwLog::endl;
740  db->Disconnect();
741  }
742 
743 
744  if (! fDisableDatabase) {
748  }
749  fDisableDatabase=hold_fDisableDatabase;
750 }
UInt_t GetRunletID()
Definition: QwParityDB.h:70
bool fDisableDatabase
Definition: QwEPICSEvent.h:130
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
void FillSlowControlsSettings(QwParityDB *db)
void FillSlowControlsStrigs(QwParityDB *db)
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
void FillSlowControlsData(QwParityDB *db)
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

void QwEPICSEvent::FillSlowControlsData ( QwParityDB db)

Definition at line 753 of file QwEPICSEvent.cc.

References QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), fEPICSCumulativeData, fEPICSTableList, fEPICSVariableList, fEPICSVariableType, QwParityDB::GetRunletID(), QwParityDB::GetSlowControlDetectorID(), kEPICSFloat, kEPICSInt, QwDatabase::Query(), QwDebug, and QwError.

Referenced by FillDB().

754 {
755 
756  QwDebug << " -------------------------------------------------------------------------- " << QwLog::endl;
757  QwDebug << " QwEPICSEvent::FillSlowControlsData(QwParityDB *db) " << QwLog::endl;
758  QwDebug << " -------------------------------------------------------------------------- " << QwLog::endl;
759 
760  Double_t mean, average_of_squares, variance, sigma;
761  Int_t n_records;
762 
763  mean = 0.0;
764  average_of_squares = 0.0;
765  variance = 0.0;
766  sigma = 0.0;
767  n_records = 0;
768  // Figure out if the target table has this runlet_id in it already,
769  // if not, create a new entry with the current runlet_id.
770 
771  UInt_t runlet_id = db->GetRunletID();
772 
773  std::vector<QwParitySSQLS::slow_controls_data> entrylist;
774 
775  UInt_t sc_detector_id;
776 
777  string table = "slow_controls_data";
778 
779  // QwError << "Step 1 Entering the loop " << QwLog::endl;
780  // Loop over EPICS variables
781  for (size_t tagindex = 0; tagindex < fEPICSVariableList.size(); tagindex++) {
782 
783  // Look for variables to write into this table
784  if (fEPICSTableList[tagindex] == table) {
785  QwParitySSQLS::slow_controls_data tmp_row(0);
786 
787  // Now get the current sc_detector_id for the above runlet_id.
788  sc_detector_id = db->GetSlowControlDetectorID(fEPICSVariableList[tagindex]);
789 
790  tmp_row.runlet_id = runlet_id;
791  tmp_row.sc_detector_id = sc_detector_id;
792 
793  if (!sc_detector_id) continue;
794 
795 
796  // Calculate average and error
797  if (fEPICSVariableType[tagindex] == kEPICSFloat
798  || fEPICSVariableType[tagindex] == kEPICSInt) {
799  if (fEPICSCumulativeData[tagindex].NumberRecords > 0){
800 
801  mean = (fEPICSCumulativeData[tagindex].Sum)/
802  ((Double_t) fEPICSCumulativeData[tagindex].NumberRecords);
803  average_of_squares = (fEPICSCumulativeData[tagindex].SquaredSum)/
804  ((Double_t) fEPICSCumulativeData[tagindex].NumberRecords);
805  variance = average_of_squares - (mean * mean);
806  if (variance < 0.0){
807  sigma = sqrt(-1.0 * variance);
808  } else {
809  sigma = sqrt(variance);
810  }
811  n_records = fEPICSCumulativeData[tagindex].NumberRecords;
812 
813  // Build the row and submit it to the list
814  tmp_row.n = n_records;
815  tmp_row.value = mean;
816  tmp_row.error = sigma;
817  tmp_row.min_value = fEPICSCumulativeData[tagindex].Minimum;
818  tmp_row.max_value = fEPICSCumulativeData[tagindex].Maximum;
819 
820  entrylist.push_back(tmp_row);
821  }
822  }
823  }
824  }
825 
826 
827  db->Connect();
828  // Check the entrylist size, if it isn't zero, start to query..
829  if( entrylist.size() ) {
830  QwDebug << "QwEPICSEvent::FillSlowControlsData::Writing to database now" << QwLog::endl;
831  mysqlpp::Query query= db->Query();
832 
833  // query.insert(entrylist.begin(), entrylist.end());
834 
835  //QwDebug << "Query: " << query.str() << QwLog::endl;
836 
837  // query.execute();
838 
839  ///////////////////////////////
840  try {
841  query.insert(entrylist.begin(), entrylist.end());
842  QwDebug << "Query: " << query.str() << QwLog::endl;
843  query.execute();
844  QwDebug << "Done executing MySQL query" << QwLog::endl;
845  } catch (const mysqlpp::Exception &er) {
846  QwError << "MySQL exception: " << er.what() << QwLog::endl;
847  }
848  ///////////////////////////////
849 
850  } else {
851  QwDebug << "QwEPICSEvent::FillSlowControlsData :: This is the case when the entrylist contains nothing " << QwLog::endl;
852  }
853  db->Disconnect();
854 }
UInt_t GetRunletID()
Definition: QwParityDB.h:70
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
std::vector< EPICSCumulativeRecord > fEPICSCumulativeData
Definition: QwEPICSEvent.h:160
std::vector< EQwEPICSDataType > fEPICSVariableType
Definition: QwEPICSEvent.h:167
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
std::vector< std::string > fEPICSTableList
Definition: QwEPICSEvent.h:166
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
std::vector< std::string > fEPICSVariableList
Definition: QwEPICSEvent.h:165
UInt_t GetSlowControlDetectorID(const string &name)
Definition: QwParityDB.cc:706
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwEPICSEvent::FillSlowControlsSettings ( QwParityDB db)

Definition at line 929 of file QwEPICSEvent.cc.

References QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), fEPICSCumulativeData, fEPICSDataEvent, fEPICSVariableList, FindIndex(), fNumberEPICSEvents, fPrecessionReversal, QwParityDB::GetRunletID(), kEPICS_Error, QwDatabase::Query(), QwDebug, QwError, QwWarning, and WienModeIndex().

Referenced by FillDB().

930 {
931  QwParitySSQLS::slow_controls_settings tmp_row(0);
932  std::vector<QwParitySSQLS::slow_controls_settings> entrylist;
933 
934  tmp_row.slow_helicity_plate = mysqlpp::null;
935  tmp_row.wien_reversal = mysqlpp::null;
936  tmp_row.helicity_length = mysqlpp::null;
937  tmp_row.charge_feedback = mysqlpp::null;
938  tmp_row.position_feedback = mysqlpp::null;
939  tmp_row.qtor_current = mysqlpp::null;
940  tmp_row.target_position = mysqlpp::null;
941 
942  UInt_t runlet_id = db->GetRunletID();
943  tmp_row.runlet_id = runlet_id;
944  Int_t tagindex;
945 
946  // Add as many blocks as needed in the following for all slow_controls_settings.
947 
948  ////////////////////////////////////////////////////////////
949 
950  // For QTOR current
951  tagindex = FindIndex("qw:qt_mps_i_dcct");
952  if (tagindex != kEPICS_Error) {
953  QwDebug << "tagindex for = qw:qt_mps_i_dcct" << tagindex << QwLog::endl;
954  if (! fEPICSCumulativeData[tagindex].Filled) {
955  // No data for this run.
956  tmp_row.qtor_current = mysqlpp::null;
957  } else if (fEPICSCumulativeData[tagindex].NumberRecords <= 0) {
958  // No events in this variable
959  QwWarning << "The value of "
960  << fEPICSVariableList[tagindex]
961  << " had no events during this run. "
962  << "Send NULL word to the database."
963  << QwLog::endl;
964  tmp_row.qtor_current = mysqlpp::null;
965  } else {
966  Double_t qtorcurrent = (fEPICSCumulativeData[tagindex].Sum)/
967  ((Double_t) fEPICSCumulativeData[tagindex].NumberRecords);
968  QwDebug << "Send the value of "
969  << fEPICSVariableList[tagindex]
970  << ", "
971  << qtorcurrent
972  << ", to the database."
973  << QwLog::endl;
974  tmp_row.qtor_current = qtorcurrent;
975  }
976  }
977 
978  ////////////////////////////////////////////////////////////
979 
980  // For target position
981  tagindex = FindIndex("QWtgt_name");
982  if (tagindex != kEPICS_Error) {
983  QwDebug << "tagindex for = QWtgt_name" << tagindex << QwLog::endl;
984  if (! fEPICSCumulativeData[tagindex].Filled) {
985  // No data for this run.
986  tmp_row.target_position = mysqlpp::null;
987  } else if (fEPICSCumulativeData[tagindex].NumberRecords
988  != fNumberEPICSEvents) {
989  // Target position changed
990  QwWarning << "The value of "
991  << fEPICSVariableList[tagindex]
992  << " changed during this run. "
993  << "Send NULL word to the database."
994  << QwLog::endl;
995  tmp_row.target_position = mysqlpp::null;
996  }
997  if(fEPICSDataEvent[tagindex].StringValue.Contains("***") ){
998  QwWarning << "The value of "
999  << fEPICSVariableList[tagindex]
1000  << " is not defined."
1001  << "Send NULL word to the database."
1002  << QwLog::endl;
1003  tmp_row.target_position =mysqlpp::null;
1004  } else {
1005  // Target position did not change.
1006  // Store the position as a text string.
1007  QwDebug << "Send the value of "
1008  << fEPICSVariableList[tagindex]
1009  << ", "
1010  << fEPICSDataEvent[tagindex].StringValue.Data()
1011  << ", to the database."
1012  << QwLog::endl;
1013  tmp_row.target_position = fEPICSDataEvent[tagindex].StringValue.Data();
1014  }
1015  }
1016 
1017  ////////////////////////////////////////////////////////////
1018 
1019  // For insertable Half Wave Plate Setting
1020  tagindex = FindIndex("IGL1I00DI24_24M");
1021  if (tagindex != kEPICS_Error) {
1022  QwDebug << "tagindex for IGL1I00DI24_24M = " << tagindex << QwLog::endl;
1023 
1024  if (! fEPICSCumulativeData[tagindex].Filled) {
1025  // No data for this run.
1026  tmp_row.slow_helicity_plate = mysqlpp::null;
1027  } else if (fEPICSCumulativeData[tagindex].NumberRecords
1028  != fNumberEPICSEvents) {
1029  // Insertable Half Wave Plate Setting position changed
1030  QwWarning << "The value of "
1031  << fEPICSVariableList[tagindex]
1032  << " changed during the run."
1033  << "Send NULL word to the database."
1034  << QwLog::endl;
1035  tmp_row.slow_helicity_plate = mysqlpp::null;
1036  }
1037  if(fEPICSDataEvent[tagindex].StringValue.Contains("***") ){
1038  QwWarning << "The value of "
1039  << fEPICSVariableList[tagindex]
1040  << " is not defined."
1041  << "Send NULL word to the database."
1042  << QwLog::endl;
1043  tmp_row.slow_helicity_plate =mysqlpp::null;
1044  } else {
1045  // Insertable Half Wave Plate Setting position did not change
1046  // Insertable Half Wave Plate Setting setting is stored as a string with possible values
1047  // "OUT" and "IN".
1048  QwDebug << "Send the value of "
1049  << fEPICSVariableList[tagindex]
1050  << ", "
1051  << fEPICSDataEvent[tagindex].StringValue.Data()
1052  << ", to the database."
1053  << QwLog::endl;
1054  tmp_row.slow_helicity_plate = fEPICSDataEvent[tagindex].StringValue.Data();
1055  }
1056  }
1057 
1058  // For IHWP2 Setting
1059  // IGL1I00DIOFLRD: Passive IHWP readback (13056=IN,8960=OUT)
1060  tagindex = FindIndex("IGL1I00DIOFLRD");
1061  if (tagindex != kEPICS_Error) {
1062  QwDebug << "tagindex for IGL1I00DIOFLRD = " << tagindex << QwLog::endl;
1063 
1064  if (! fEPICSCumulativeData[tagindex].Filled) {
1065  // No data for this run.
1066  tmp_row.passive_helicity_plate = mysqlpp::null;
1067  } else if (fEPICSCumulativeData[tagindex].NumberRecords
1068  != fNumberEPICSEvents) {
1069  // IHWP2 Setting position changed
1070  QwWarning << "The value of "
1071  << fEPICSVariableList[tagindex]
1072  << " changed during the run."
1073  << "Send NULL word to the database."
1074  << QwLog::endl;
1075  tmp_row.passive_helicity_plate = mysqlpp::null;
1076  } else {
1077  Double_t ihwp2_readback = (fEPICSCumulativeData[tagindex].Sum)/
1078  ((Double_t) fEPICSCumulativeData[tagindex].NumberRecords);
1079  if (fabs(ihwp2_readback-13056)<1){
1080  // IHWP2 is IN
1081  QwDebug << "Send the value of "
1082  << fEPICSVariableList[tagindex]
1083  << ", "
1084  << fEPICSDataEvent[tagindex].StringValue.Data()
1085  << ", to the database."
1086  << QwLog::endl;
1087  tmp_row.passive_helicity_plate = "in";
1088  } else if (fabs(ihwp2_readback-8960)<1){
1089  // IHWP2 is OUT
1090  QwDebug << "Send the value of "
1091  << fEPICSVariableList[tagindex]
1092  << ", "
1093  << fEPICSDataEvent[tagindex].StringValue.Data()
1094  << ", to the database."
1095  << QwLog::endl;
1096  tmp_row.passive_helicity_plate = "out";
1097  } else {
1098  QwWarning << "The value of "
1099  << fEPICSVariableList[tagindex]
1100  << " is not defined."
1101  << "Send NULL word to the database."
1102  << QwLog::endl;
1103  tmp_row.passive_helicity_plate =mysqlpp::null;
1104  }
1105  }
1106  }
1107 
1108  // For Wien Setting
1109  tagindex = FindIndex("WienMode");
1110  if (tagindex != kEPICS_Error) {
1111  QwDebug << "tagindex for WienMode = " << tagindex << QwLog::endl;
1112 
1113  if (! fEPICSCumulativeData[tagindex].Filled) {
1114  // No data for this run.
1115  tmp_row.wien_reversal = mysqlpp::null;
1116  } else if (fEPICSCumulativeData[tagindex].NumberRecords
1117  != fNumberEPICSEvents) {
1118  // WienMode changed
1119  QwWarning << "The value of "
1120  << fEPICSVariableList[tagindex]
1121  << " changed during the run."
1122  << "Send NULL word to the database."
1123  << QwLog::endl;
1124  tmp_row.wien_reversal = mysqlpp::null;
1125  }
1126  if(fEPICSDataEvent[tagindex].StringValue.Contains("***") ){
1127  QwWarning << "The value of "
1128  << fEPICSVariableList[tagindex]
1129  << " is not defined."
1130  << "Send NULL word to the database."
1131  << QwLog::endl;
1132  tmp_row.wien_reversal =mysqlpp::null;
1133  } else {
1134  // WienMode is stored as an enum of the following labels:
1135  TString wien_enum[5] = {"indeterminate",
1136  "normal","reverse",
1137  "transverse_vertical",
1138  "transverse_horizontal"};
1139  QwDebug << "Send the value of "
1140  << fEPICSVariableList[tagindex]
1141  << ", "
1142  << fEPICSDataEvent[tagindex].StringValue.Data()
1143  << ", to the database."
1144  << QwLog::endl;
1145  tmp_row.wien_reversal = wien_enum[WienModeIndex(fEPICSDataEvent[tagindex].StringValue)].Data();
1146  }
1147  }
1148 
1149  // For the precession reversal
1150  // This just uses the flag from the channel map to determine if the precession
1151  // is normal or reversed.
1152  if (fPrecessionReversal){
1153  tmp_row.precession_reversal = "reverse";
1154  } else {
1155  tmp_row.precession_reversal = "normal";
1156  }
1157 
1158  // For charge feedback
1159 
1160  tagindex = FindIndex("qw:ChargeFeedback");
1161  if (tagindex != kEPICS_Error) {
1162  //std::cout << "tagindex for qw:ChargeFeedback = " << tagindex << std::endl;
1163 
1164  if (! fEPICSCumulativeData[tagindex].Filled) {
1165  // No data for this run.
1166  tmp_row.charge_feedback = mysqlpp::null;
1167 
1168  } else if (fEPICSCumulativeData[tagindex].NumberRecords
1169  != fNumberEPICSEvents) {
1170  // charge feedback status changed
1171  QwWarning << "The value of "
1172  << fEPICSVariableList[tagindex]
1173  << " changed during the run."
1174  << "Send NULL word to the database."
1175  << QwLog::endl;
1176  tmp_row.charge_feedback = mysqlpp::null;
1177  }
1178 
1179  if(fEPICSDataEvent[tagindex].StringValue.Contains("***") ){
1180  QwWarning << "The value of "
1181  << fEPICSVariableList[tagindex]
1182  << " is not defined."
1183  << "Send NULL word to the database."
1184  << QwLog::endl;
1185  tmp_row.charge_feedback =mysqlpp::null;
1186  }
1187 
1188  else {
1189  // charge feedback setting did not change
1190  // charge feedback setting is stored as a string with possible values
1191  // "on" and "off".
1192  QwDebug << "Send the value of "
1193  << fEPICSVariableList[tagindex]
1194  << ", "
1195  << fEPICSDataEvent[tagindex].StringValue.Data()
1196  << ", to the database."
1197  << QwLog::endl;
1198  TString tmpval = fEPICSDataEvent[tagindex].StringValue;
1199  tmpval.ToLower();
1200  tmp_row.charge_feedback = tmpval.Data();
1201  }
1202  }
1203 
1204  ////////////////////////////////////////////////////////////
1205 
1206 
1207 
1208  entrylist.push_back(tmp_row);
1209 
1210  db->Connect();
1211  // Check the entrylist size, if it isn't zero, start to query..
1212  if( entrylist.size() ) {
1213  QwDebug << "QwEPICSEvent::FillSlowControlsSettings Writing to database now" << QwLog::endl;
1214  mysqlpp::Query query= db->Query();
1215  // query.insert(entrylist.begin(), entrylist.end());
1216  // QwDebug << "Query: " << query.str() << QwLog::endl;
1217  // query.execute();
1218  ///////////////////////////////
1219  try {
1220  query.insert(entrylist.begin(), entrylist.end());
1221  QwDebug << "Query: " << query.str() << QwLog::endl;
1222  query.execute();
1223  QwDebug << "Done executing MySQL query" << QwLog::endl;
1224  } catch (const mysqlpp::Exception &er) {
1225  QwError << "MySQL exception: " << er.what() << QwLog::endl;
1226  }
1227  ///////////////////////////////
1228 
1229 
1230  } else {
1231  QwDebug << "QwEPICSEvent::FillSlowControlsSettings :: This is the case when the entrylist contains nothing " << QwLog::endl;
1232  }
1233  db->Disconnect();
1234  QwDebug << "Leaving QwEPICSEvent::FillSlowControlsStrings()" << QwLog::endl;
1235 }
UInt_t GetRunletID()
Definition: QwParityDB.h:70
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
Int_t FindIndex(const string &tag) const
Find the index of an EPICS variable, or return error.
Int_t fNumberEPICSEvents
Definition: QwEPICSEvent.h:163
std::vector< EPICSCumulativeRecord > fEPICSCumulativeData
Definition: QwEPICSEvent.h:160
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
std::vector< EPICSVariableRecord > fEPICSDataEvent
Definition: QwEPICSEvent.h:146
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
static const int kEPICS_Error
Definition: QwEPICSEvent.h:124
Bool_t fPrecessionReversal
Definition: QwEPICSEvent.h:174
EQwWienMode WienModeIndex(TString name)
Definition: QwTypes.cc:151
std::vector< std::string > fEPICSVariableList
Definition: QwEPICSEvent.h:165
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwEPICSEvent::FillSlowControlsStrigs ( QwParityDB db)

Definition at line 857 of file QwEPICSEvent.cc.

References QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), fEPICSDataEvent, fEPICSTableList, fEPICSVariableList, fEPICSVariableType, QwParityDB::GetRunletID(), QwParityDB::GetSlowControlDetectorID(), kEPICSString, QwDatabase::Query(), QwDebug, QwError, and QwWarning.

Referenced by FillDB().

858 {
859  std::vector<QwParitySSQLS::slow_controls_strings> entrylist;
860  UInt_t sc_detector_id;
861  UInt_t runlet_id = db->GetRunletID();
862  string table = "polarized_source";
863 
864  // QwError << "Step 1 Entering the loop " << QwLog::endl;
865  // Loop over EPICS variables
866  for (size_t tagindex = 0; tagindex < fEPICSVariableList.size(); tagindex++) {
867  // Look for variables to write into this table
868 
869  if (fEPICSTableList[tagindex] == table) {
870  QwParitySSQLS::slow_controls_strings tmp_row(0);
871 
872  // Now get the current sc_detector_id for the above runlet_id.
873  sc_detector_id = db->GetSlowControlDetectorID(fEPICSVariableList[tagindex]);
874 
875  tmp_row.runlet_id = runlet_id;
876  tmp_row.sc_detector_id = sc_detector_id;
877 
878  if (!sc_detector_id) continue;
879 
880  if (fEPICSVariableType[tagindex] == kEPICSString) {
881 
882  if (fEPICSDataEvent[tagindex].Filled) {
883  if(fEPICSDataEvent[tagindex].StringValue.Contains("***") ){
884  QwWarning<<"fEPICSDataEvent[tagindex].StringValue.Data() is not defined, tmp_row.value is set to an empty string."<<QwLog::endl;
885  tmp_row.value ="";
886  }
887  else {
888  //std::cout<<" Just a test value: "<<fEPICSDataEvent[tagindex].StringValue.Data()<<QwLog::endl;
889  tmp_row.value = fEPICSDataEvent[tagindex].StringValue.Data();
890  }
891  // Only add rows for filled variables
892  entrylist.push_back(tmp_row);
893  }
894  }
895  }
896  }
897 
898  db->Connect();
899  // Check the entrylist size, if it isn't zero, start to query.
900  if( entrylist.size() ) {
901  QwDebug << "QwEPICSEvent::FillSlowControlsStrigs Writing to database now" << QwLog::endl;
902  mysqlpp::Query query= db->Query();
903 // query.insert(entrylist.begin(), entrylist.end());
904 
905 // QwDebug << "Query: " << query.str() << QwLog::endl;
906 
907 // query.execute();
908 
909 
910  ///////////////////////////////
911  try {
912  query.insert(entrylist.begin(), entrylist.end());
913  QwDebug << "Query: " << query.str() << QwLog::endl;
914  query.execute();
915  QwDebug << "Done executing MySQL query for FillSlowControlsStrings"
916  << QwLog::endl;
917  } catch (const mysqlpp::Exception &er) {
918  QwError << "MySQL exception: " << er.what() << QwLog::endl;
919  }
920  ///////////////////////////////
921 
922  } else {
923  QwDebug << "QwEPICSEvent::FillSlowControlsData :: This is the case when the entrylist contains nothing " << QwLog::endl;
924  }
925  db->Disconnect();
926 }
UInt_t GetRunletID()
Definition: QwParityDB.h:70
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
std::vector< EQwEPICSDataType > fEPICSVariableType
Definition: QwEPICSEvent.h:167
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
std::vector< std::string > fEPICSTableList
Definition: QwEPICSEvent.h:166
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
std::vector< EPICSVariableRecord > fEPICSDataEvent
Definition: QwEPICSEvent.h:146
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
std::vector< std::string > fEPICSVariableList
Definition: QwEPICSEvent.h:165
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45
UInt_t GetSlowControlDetectorID(const string &name)
Definition: QwParityDB.cc:706
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwEPICSEvent::FillTreeVector ( std::vector< Double_t > &  values) const

Fill the tree vector.

Definition at line 193 of file QwEPICSEvent.cc.

References QwLog::endl(), fEPICSDataEvent, fEPICSVariableList, fEPICSVariableType, fTreeArrayIndex, kEPICSFloat, kEPICSInt, kEPICSString, and QwError.

194 {
195  Int_t treeindex = fTreeArrayIndex;
196  for (size_t tagindex = 0; tagindex < fEPICSVariableType.size(); tagindex++) {
197  switch (fEPICSVariableType[tagindex]) {
198  case kEPICSFloat:
199  case kEPICSInt: {
200  // Add value to vector
201  values[treeindex] = fEPICSDataEvent[tagindex].Value;
202  treeindex++;
203  break;
204  }
205  case kEPICSString: {
206  // Add value to vector
207  values[treeindex] = static_cast<Double_t>(fEPICSDataEvent[tagindex].StringValue.Hash());
208  treeindex++;
209  break;
210  }
211  default: {
212  TString name = fEPICSVariableList[tagindex];
213  QwError << "Unrecognized type for EPICS variable " << name << QwLog::endl;
214  break;
215  }
216  }
217  }
218 }
size_t fTreeArrayIndex
Definition: QwEPICSEvent.h:91
std::vector< EQwEPICSDataType > fEPICSVariableType
Definition: QwEPICSEvent.h:167
std::vector< EPICSVariableRecord > fEPICSDataEvent
Definition: QwEPICSEvent.h:146
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
std::vector< std::string > fEPICSVariableList
Definition: QwEPICSEvent.h:165
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

Int_t QwEPICSEvent::FindIndex ( const string &  tag) const

Find the index of an EPICS variable, or return error.

Definition at line 347 of file QwEPICSEvent.cc.

References fEPICSVariableMap, and kEPICS_Error.

Referenced by ExtractEPICSValues(), FillSlowControlsSettings(), GetDataString(), GetDataValue(), and SetDataValue().

348 {
349  // Find a match for the tag
350  std::map<std::string,Int_t>::const_iterator match = fEPICSVariableMap.find(tag);
351 
352  if (match != fEPICSVariableMap.end())
353  // A match was found
354  return match->second;
355 
356  else
357  // Otherwise return error
358  return kEPICS_Error;
359 }
std::map< std::string, Int_t > fEPICSVariableMap
Definition: QwEPICSEvent.h:169
static const int kEPICS_Error
Definition: QwEPICSEvent.h:124

+ Here is the caller graph for this function:

TString QwEPICSEvent::GetDataString ( const string &  tag) const

Definition at line 374 of file QwEPICSEvent.cc.

References fEPICSDataEvent, fEPICSVariableType, FindIndex(), kEPICS_Error, and kEPICSString.

Referenced by DetermineIHWPPolarity(), and QwBlinder::Update().

375 {
376  Int_t tagindex = FindIndex(tag);
377  if (tagindex != kEPICS_Error) {
378  if (fEPICSVariableType[tagindex]==kEPICSString
379  && fEPICSDataEvent[tagindex].Filled) {
380  return(fEPICSDataEvent[tagindex].StringValue);
381  }
382  }
383  return TString("");
384 }
Int_t FindIndex(const string &tag) const
Find the index of an EPICS variable, or return error.
std::vector< EQwEPICSDataType > fEPICSVariableType
Definition: QwEPICSEvent.h:167
std::vector< EPICSVariableRecord > fEPICSDataEvent
Definition: QwEPICSEvent.h:146
static const int kEPICS_Error
Definition: QwEPICSEvent.h:124

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Double_t QwEPICSEvent::GetDataValue ( const string &  tag) const

Definition at line 362 of file QwEPICSEvent.cc.

References fEPICSDataEvent, FindIndex(), kEPICS_Error, and kInvalidEPICSData.

Referenced by DetermineWienMode(), main(), ReportAutogains(), and QwBlinder::Update().

363 {
364  Double_t data_value = kInvalidEPICSData;
365  Int_t tagindex = FindIndex(tag);
366  if (tagindex != kEPICS_Error) {
367  if (fEPICSDataEvent[tagindex].Filled) {
368  data_value = fEPICSDataEvent[tagindex].Value;
369  }
370  }
371  return data_value;
372 }
Int_t FindIndex(const string &tag) const
Find the index of an EPICS variable, or return error.
static const Double_t kInvalidEPICSData
Definition: QwEPICSEvent.h:126
std::vector< EPICSVariableRecord > fEPICSDataEvent
Definition: QwEPICSEvent.h:146
static const int kEPICS_Error
Definition: QwEPICSEvent.h:124

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static std::vector<std::string> QwEPICSEvent::GetDefaultAutogainList ( )
inlinestatic

Definition at line 108 of file QwEPICSEvent.h.

References fDefaultAutogainList.

108 { return fDefaultAutogainList; };
static std::vector< std::string > fDefaultAutogainList
Default autogain list.
Definition: QwEPICSEvent.h:116
TList * QwEPICSEvent::GetEPICSStringValues ( )
private

Definition at line 1237 of file QwEPICSEvent.cc.

References fEPICSDataEvent, fEPICSVariableList, fEPICSVariableType, and kEPICSString.

1238 {
1239  Bool_t local_debug = false;
1240 
1241  TList *string_list = new TList;
1242  string_list->SetOwner(true);
1243 
1244  std::size_t tagindex = 0;
1245 
1246  for (tagindex=0; tagindex<fEPICSVariableList.size(); tagindex++)
1247  {
1248  if (fEPICSVariableType[tagindex] == kEPICSString) {
1249 
1250  TString epics_string = fEPICSVariableList[tagindex];
1251  epics_string += "---";
1252 
1253  if (fEPICSDataEvent[tagindex].Filled) {
1254  epics_string += fEPICSDataEvent[tagindex].StringValue;
1255  }
1256  else {
1257  epics_string += "empty";
1258  }
1259  if(local_debug) {
1260  std::cout << "QwEPICSEvent::GetEPICSStringValues() "
1261  << epics_string
1262  << std::endl;
1263  }
1264  string_list -> Add(new TObjString(epics_string));
1265  }
1266  }
1267 
1268  return string_list;
1269 }
std::vector< EQwEPICSDataType > fEPICSVariableType
Definition: QwEPICSEvent.h:167
std::vector< EPICSVariableRecord > fEPICSDataEvent
Definition: QwEPICSEvent.h:146
std::vector< std::string > fEPICSVariableList
Definition: QwEPICSEvent.h:165
Bool_t QwEPICSEvent::HasDataLoaded ( ) const
inline

Definition at line 68 of file QwEPICSEvent.h.

References fIsDataLoaded.

Referenced by main().

68 { return fIsDataLoaded; };
Bool_t fIsDataLoaded
Definition: QwEPICSEvent.h:95

+ Here is the caller graph for this function:

void QwEPICSEvent::InitDefaultAutogainList ( )
staticprivate

Initialize the default autogain list.

Definition at line 386 of file QwEPICSEvent.cc.

References fDefaultAutogainList.

Referenced by QwEPICSEvent().

387 {
388  // Clear the vector first
389  fDefaultAutogainList.clear();
390 
391  // Add default autogain channels
392  fDefaultAutogainList.push_back("IPM3C17.XIFG");
393  fDefaultAutogainList.push_back("IPM3C17.YIFG");
394  fDefaultAutogainList.push_back("IBC3C17.XIFG");
395  fDefaultAutogainList.push_back("IBC3C17.YIFG");
396  fDefaultAutogainList.push_back("IPM3C18.XIFG");
397  fDefaultAutogainList.push_back("IPM3C18.YIFG");
398  fDefaultAutogainList.push_back("IPM3C19.XIFG");
399  fDefaultAutogainList.push_back("IPM3C19.YIFG");
400  fDefaultAutogainList.push_back("IPM3C03.YIFG");
401  fDefaultAutogainList.push_back("IPM3P01.XIFG");
402  fDefaultAutogainList.push_back("IPM3P01.YIFG");
403  fDefaultAutogainList.push_back("IPM3P02A.XIFG");
404  fDefaultAutogainList.push_back("IPM3P02A.YIFG");
405  fDefaultAutogainList.push_back("IPM3P03A.XIFG");
406  fDefaultAutogainList.push_back("IPM3P03A.YIFG");
407  fDefaultAutogainList.push_back("IPM3P02B.XIFG");
408  fDefaultAutogainList.push_back("IPM3P02B.YIFG");
409  fDefaultAutogainList.push_back("IPM3C20.XIFG");
410  fDefaultAutogainList.push_back("IPM3C20.YIFG");
411  fDefaultAutogainList.push_back("IPM3C21.XIFG");
412  fDefaultAutogainList.push_back("IPM3C21.YIFG");
413  fDefaultAutogainList.push_back("IPM3H02.XIFG");
414  fDefaultAutogainList.push_back("IPM3H02.YIFG");
415  fDefaultAutogainList.push_back("IPM3H04.XIFG");
416  fDefaultAutogainList.push_back("IPM3H04.YIFG");
417  fDefaultAutogainList.push_back("IPM3H07A.XIFG");
418  fDefaultAutogainList.push_back("IPM3H07A.YIFG");
419  fDefaultAutogainList.push_back("IPM3H07B.XIFG");
420  fDefaultAutogainList.push_back("IPM3H07B.YIFG");
421  fDefaultAutogainList.push_back("IPM3H07C.XIFG");
422  fDefaultAutogainList.push_back("IPM3H07C.YIFG");
423  fDefaultAutogainList.push_back("IPM3H09.XIFG");
424  fDefaultAutogainList.push_back("IPM3H09.YIFG");
425  fDefaultAutogainList.push_back("IPM3H09B.XIFG");
426  fDefaultAutogainList.push_back("IPM3H09B.YIFG");
427 }
static std::vector< std::string > fDefaultAutogainList
Default autogain list.
Definition: QwEPICSEvent.h:116

+ Here is the caller graph for this function:

Bool_t QwEPICSEvent::IsNumber ( const string &  word)
inlineprivate

Definition at line 133 of file QwEPICSEvent.h.

Referenced by SetDataValue().

133  {
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  }

+ Here is the caller graph for this function:

Int_t QwEPICSEvent::LoadChannelMap ( TString  mapfile)

Definition at line 90 of file QwEPICSEvent.cc.

References AddEPICSTag(), QwLog::endl(), fBlinderReversalForRunTwo, fEPICSVariableList, fEPICSVariableType, fExtraHelicityReversal, fNominalWienAngle, fNumberEPICSVariables, fPrecessionReversal, kDebug, kEPICSFloat, kEPICSInt, kEPICSString, QwDebug, QwError, ResetCounters(), and QwParameterFile::TrimComment().

Referenced by main().

91 {
92  Int_t lineread = 0;
93 
95  fEPICSVariableList.clear();
96  fEPICSVariableType.clear();
97 
100  fPrecessionReversal = kFALSE;
101 
102  // Open the file
103  QwParameterFile mapstr(mapfile.Data());
104  std::string varname, varvalue;
105  while (mapstr.ReadNextLine()) {
106  lineread++;
107 
108  mapstr.TrimComment(); // Remove everything after a '!' character.
109  mapstr.TrimWhitespace(); // Get rid of leading and trailing spaces.
110  if (mapstr.LineIsEmpty()) continue;
111 
112  if (mapstr.HasVariablePair("=",varname,varvalue)){
113  QwDebug << "QwEPICSEvent::LoadChannelMap: keyword,value pair:"
114  << varname << "," << varvalue << QwLog::endl;
115  if (varname == "NominalWienAngle"){
116  fNominalWienAngle = atof(varvalue.c_str());
117  } else if (varname == "BlinderReversalForRunTwo"){
121  }
122  } else if (varname == "PrecessionReversal"){
123  if (! fPrecessionReversal){
124  fPrecessionReversal = kTRUE;
126  }
127  } else {
128  QwError << "QwEPICSEvent::LoadChannelMap: "
129  << "Unknown keyword,variable pair: "
130  << varname << "," << varvalue << QwLog::endl;
131  exit(1);
132  }
133  continue;
134  }
135 
136  varname = mapstr.GetTypedNextToken<std::string>();
137  std::string dbtable = mapstr.GetTypedNextToken<std::string>();
138  TString datatype = mapstr.GetTypedNextToken<TString>();
139  datatype.ToLower();
140 
141  if (datatype == "") {
142  AddEPICSTag(varname,dbtable);
143  } else {
144  EQwEPICSDataType datatypeid = kEPICSString;
145  if (datatype == "string") datatypeid = kEPICSString;
146  if (datatype == "float") datatypeid = kEPICSFloat;
147  if (datatype == "int") datatypeid = kEPICSInt;
148  AddEPICSTag(varname,dbtable,datatypeid);
149  }
150  }
151  if (kDebug == 1) std::cout << "fNumberEPICSVariables = " << fNumberEPICSVariables << std::endl << std::endl;
152  if (kDebug == 1) std::cout << "line read in the parameter file =" << lineread << std::endl;
153 
154  ResetCounters();
155  mapstr.Close(); // Close the file (ifstream)
156  return 0;
157 }
EQwEPICSDataType
EPICS data types.
Definition: QwEPICSEvent.h:31
Double_t fNominalWienAngle
Definition: QwEPICSEvent.h:176
void TrimComment(const char commentchar)
static const int kDebug
Definition: QwEPICSEvent.h:123
Int_t fNumberEPICSVariables
Definition: QwEPICSEvent.h:164
std::vector< EQwEPICSDataType > fEPICSVariableType
Definition: QwEPICSEvent.h:167
Bool_t fBlinderReversalForRunTwo
Definition: QwEPICSEvent.h:173
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
void ResetCounters()
Int_t fExtraHelicityReversal
Definition: QwEPICSEvent.h:177
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
Bool_t fPrecessionReversal
Definition: QwEPICSEvent.h:174
Int_t AddEPICSTag(const string &tag, const string &table="", EQwEPICSDataType datatype=kEPICSFloat)
std::vector< std::string > fEPICSVariableList
Definition: QwEPICSEvent.h:165
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwEPICSEvent::PrintAverages ( ) const

Definition at line 496 of file QwEPICSEvent.cc.

References fEPICSCumulativeData, fEPICSDataEvent, fEPICSVariableList, fEPICSVariableType, fNumberEPICSEvents, kEPICSFloat, kEPICSInt, and kEPICSString.

497 {
498  Double_t mean = 0.0;
499  Double_t average_of_squares = 0.0;
500  Double_t variance = 0.0;
501  Double_t sigma = 0.0;
502 
503  std::cout <<"##### EPICS Event Summary from PrintAverages() #####\n"
504  <<"Total number of EPICS events in this run == "
505  <<fNumberEPICSEvents <<".\n\n"
506  << std::setw(20) << std::setiosflags(std::ios::left) <<"Name"
507  <<"\tMean Sigma "
508  <<"Minimum Maximum"<<std::endl;
509  std::cout << "*****Non-string EPICS Variables*****" << std::endl;
510  for (size_t tagindex = 0; tagindex < fEPICSVariableList.size(); tagindex++) {
511  if (fEPICSVariableType[tagindex] == kEPICSFloat ||
512  fEPICSVariableType[tagindex] == kEPICSInt) {
513 
514  mean = 0.0;
515  variance = 0.0;
516  sigma = 0.0;
517  if (fEPICSCumulativeData[tagindex].NumberRecords > 0){
518  mean = (fEPICSCumulativeData[tagindex].Sum)/
519  ((Double_t) fEPICSCumulativeData[tagindex].NumberRecords);
520  average_of_squares = (fEPICSCumulativeData[tagindex].SquaredSum)/
521  ((Double_t) fEPICSCumulativeData[tagindex].NumberRecords);
522  variance = average_of_squares - (mean * mean);
523  if (variance < 0.0){
524  sigma = sqrt(-1.0 * variance);
525  } else {
526  sigma = sqrt(variance);
527  }
528 
529  std::cout << std::setw(20) << std::setiosflags(std::ios::left)
530  <<fEPICSVariableList[tagindex]<<"\t"
531  << std::setprecision(5) << std::setw(10)
532  <<mean<<" " << std::setw(10)<<sigma<<" " << std::setw(10)
533  <<fEPICSCumulativeData[tagindex].Minimum<<" " << std::setw(10)
534  <<fEPICSCumulativeData[tagindex].Maximum<<std::endl;
535  } else {
536  std::cout << std::setw(20) << std::setiosflags(std::ios::left)
537  <<fEPICSVariableList[tagindex]<<"\t"
538  << std::setprecision(5) << std::setw(10)
539  << "...No data..."
540  << std::endl;
541  }
542  }
543  }
544 
545  std::cout << "*****String EPICS Variables are below, if any*****" << std::endl;
546  for (size_t tagindex = 0; tagindex < fEPICSVariableList.size(); tagindex++) {
547  if (fEPICSVariableType[tagindex] == kEPICSString) {
548  if (fEPICSDataEvent[tagindex].Filled) {
549  std::cout << std::setw(20) << std::setiosflags(std::ios::left)
550  <<"tagindex for variable "<< fEPICSVariableList[tagindex]<<"\t is "
551  <<tagindex<<"\tand status is\t\t"
552  <<fEPICSDataEvent[tagindex].StringValue;
553 
554  if (fEPICSCumulativeData[tagindex].NumberRecords!= fNumberEPICSEvents){
555  std::cout << "\t*****\tThis variable changed during the run. Only "
556  << (Double_t(fEPICSCumulativeData[tagindex].NumberRecords)
557  *100.0 / Double_t(fNumberEPICSEvents))
558  << "% of the events has this value.";
559  }
560  std::cout <<std::endl;
561  } else {
562  std::cout << std::setw(20) << std::setiosflags(std::ios::left)
563  <<fEPICSVariableList[tagindex]<<"\t"
564  <<"No data..."<<std::endl;
565  }
566  }
567  }
568 }
Int_t fNumberEPICSEvents
Definition: QwEPICSEvent.h:163
std::vector< EPICSCumulativeRecord > fEPICSCumulativeData
Definition: QwEPICSEvent.h:160
std::vector< EQwEPICSDataType > fEPICSVariableType
Definition: QwEPICSEvent.h:167
std::vector< EPICSVariableRecord > fEPICSDataEvent
Definition: QwEPICSEvent.h:146
std::vector< std::string > fEPICSVariableList
Definition: QwEPICSEvent.h:165
void QwEPICSEvent::PrintVariableList ( ) const

Definition at line 571 of file QwEPICSEvent.cc.

References QwLog::endl(), fEPICSVariableList, and QwMessage.

Referenced by QwEPICSEvent().

572 {
573  // Prints all valid Epics variables on the terminal while creating a rootfile.
574  for (size_t tagindex = 0; tagindex < fEPICSVariableList.size(); tagindex++) {
575  QwMessage << "fEPICSVariableList[" << tagindex << "] == "
576  << fEPICSVariableList[tagindex] << QwLog::endl;
577  }
578 }
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
std::vector< std::string > fEPICSVariableList
Definition: QwEPICSEvent.h:165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwEPICSEvent::ProcessOptions ( QwOptions options)

Process the configuration options.

Parse the configuration options and store in class fields

Parameters
optionsOptions object

Definition at line 83 of file QwEPICSEvent.cc.

References fDisableDatabase, and QwOptions::GetValue().

Referenced by main().

84 {
85  // Option to disable EPICS database accesses
86  fDisableDatabase = options.GetValue<bool>("disable-db-epics");
87 }
bool fDisableDatabase
Definition: QwEPICSEvent.h:130
T GetValue(const std::string &key)
Get a templated value.
Definition: QwOptions.h:240

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< Double_t > QwEPICSEvent::ReportAutogains ( std::vector< std::string >  tag_list = fDefaultAutogainList)

Definition at line 581 of file QwEPICSEvent.cc.

References GetDataValue().

582 {
583  std::vector<Double_t> autogain_values;
584  std::vector<std::string>::iterator ptr_tag;
585 
586  autogain_values.clear(); //clear the vector first
587 
588  /* Iterate through the input vector of the variable names *
589  * and fill the output vector with the values. */
590  ptr_tag = tag_list.begin();
591  while (ptr_tag < tag_list.end()) {
592  autogain_values.push_back(GetDataValue(*ptr_tag));
593  ptr_tag++;
594  }
595 
596  return autogain_values;
597 }
Double_t GetDataValue(const string &tag) const

+ Here is the call graph for this function:

void QwEPICSEvent::ReportEPICSData ( ) const

Definition at line 601 of file QwEPICSEvent.cc.

References fEPICSCumulativeData, fEPICSDataEvent, fEPICSVariableList, fEPICSVariableType, fNumberEPICSEvents, kEPICSFloat, kEPICSInt, and kEPICSString.

602 {
603  Double_t mean = 0.0;
604  Double_t average_of_squares = 0.0;
605  Double_t variance = 0.0;
606  Double_t sigma = 0.0;
607 
608 
609  std::ofstream output;
610  TString theEPICSDataFile;
611  theEPICSDataFile = getenv("QW_TMP");
612  theEPICSDataFile += "/QwEPICSData.txt";// puts QwEPICSData.txt in QwAnalysis_DB_01.00.0000/scratch/tmp/ diretory.
613  output.open(theEPICSDataFile,std::ofstream::out);
614 
615  if (output.is_open()) {
616 
617 
618  output <<"##### EPICS Event Summary #####\n"
619  <<"Total number of EPICS events in this run == "
620  <<fNumberEPICSEvents <<".\n\n"
621  << std::setw(20) << std::setiosflags(std::ios::left) <<"Name"
622  <<"\tMean Sigma "
623  <<"Minimum Maximum"<<std::endl;
624  for (size_t tagindex = 0; tagindex < fEPICSVariableList.size(); tagindex++) {
625  if (fEPICSVariableType[tagindex] == kEPICSFloat ||
626  fEPICSVariableType[tagindex] == kEPICSInt) {
627  mean = 0.0;
628  variance = 0.0;
629  sigma = 0.0;
630  if (fEPICSCumulativeData[tagindex].NumberRecords > 0){
631  mean = (fEPICSCumulativeData[tagindex].Sum)/
632  ((Double_t) fEPICSCumulativeData[tagindex].NumberRecords);
633  average_of_squares = (fEPICSCumulativeData[tagindex].SquaredSum)/
634  ((Double_t) fEPICSCumulativeData[tagindex].NumberRecords);
635  variance = average_of_squares - (mean * mean);
636  if (variance < 0.0){
637  sigma = sqrt(-1.0 * variance);
638  } else {
639  sigma = sqrt(variance);
640  }
641 
642  output << std::setw(20) << std::setiosflags(std::ios::left)
643  <<fEPICSVariableList[tagindex]<<"\t"
644  << std::setprecision(5) << std::setw(10)
645  <<mean<<" " << std::setw(10)<<sigma<<" " << std::setw(10)
646  <<fEPICSCumulativeData[tagindex].Minimum<<" " << std::setw(10)
647  <<fEPICSCumulativeData[tagindex].Maximum<<std::endl;
648  } else {
649  output << std::setw(20) << std::setiosflags(std::ios::left)
650  <<fEPICSVariableList[tagindex]<<"\t"
651  << std::setprecision(5) << std::setw(10)
652  << "-No data-"
653  << std::endl;
654  }
655  }
656 
657  }
658  for (size_t tagindex = 0; tagindex < fEPICSVariableList.size(); tagindex++) {
659  if (fEPICSVariableType[tagindex] == kEPICSString) {
660  if (fEPICSDataEvent[tagindex].Filled) {
661  output << std::setw(20) << std::setiosflags(std::ios::left)
662  <<fEPICSVariableList[tagindex]<<"\t"
663  <<fEPICSDataEvent[tagindex].StringValue<<std::endl;
664  } else {
665  output << std::setw(20) << std::setiosflags(std::ios::left)
666  <<fEPICSVariableList[tagindex]<<"\t"
667  <<"No data..."<<std::endl;
668  }
669  }
670  }
671 
672  } output.close();
673 }
Int_t fNumberEPICSEvents
Definition: QwEPICSEvent.h:163
std::vector< EPICSCumulativeRecord > fEPICSCumulativeData
Definition: QwEPICSEvent.h:160
std::vector< EQwEPICSDataType > fEPICSVariableType
Definition: QwEPICSEvent.h:167
std::vector< EPICSVariableRecord > fEPICSDataEvent
Definition: QwEPICSEvent.h:146
std::vector< std::string > fEPICSVariableList
Definition: QwEPICSEvent.h:165
void QwEPICSEvent::ResetCounters ( )

Definition at line 675 of file QwEPICSEvent.cc.

References fEPICSCumulativeData, fEPICSDataEvent, fEPICSVariableList, fEPICSVariableType, fIsDataLoaded, fNumberEPICSEvents, and fNumberEPICSVariables.

Referenced by LoadChannelMap().

676 {
677  fIsDataLoaded = kFALSE;
678  /* Verify that the variable list and variable type vectors
679  are the same size, and agree with fNumberEPICSVariables. */
680  Int_t listlength = fEPICSVariableList.size();
681  Int_t typelength = fEPICSVariableType.size();
682  if (typelength != fNumberEPICSVariables ||
683  listlength != fNumberEPICSVariables) {
684  std::cerr << "The EPICS variable label and type arrays are not the same size!\n"
685  << "EPICS readback may be corrupted!"<<std::endl;
686  }
687  /* Reset the sizes of the fEPICSDataEvent and
688  fEPICSCumulativeData vectors. */
691  for (size_t tagindex = 0; tagindex < fEPICSVariableList.size(); tagindex++) {
692  fEPICSDataEvent[tagindex].Filled = kFALSE;
693  fEPICSDataEvent[tagindex].EventNumber = 0;
694  fEPICSDataEvent[tagindex].Value = 0.0;
695  fEPICSDataEvent[tagindex].StringValue = "";
696  fEPICSCumulativeData[tagindex].Filled = kFALSE;
697  fEPICSCumulativeData[tagindex].NumberRecords = 0;
698  fEPICSCumulativeData[tagindex].Sum = 0.0;
699  fEPICSCumulativeData[tagindex].SquaredSum = 0.0;
700  fEPICSCumulativeData[tagindex].Minimum = 0.0;
701  fEPICSCumulativeData[tagindex].Maximum = 0.0;
702  }
703  fNumberEPICSEvents = 0;
704 }
Bool_t fIsDataLoaded
Definition: QwEPICSEvent.h:95
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
std::vector< EPICSVariableRecord > fEPICSDataEvent
Definition: QwEPICSEvent.h:146
std::vector< std::string > fEPICSVariableList
Definition: QwEPICSEvent.h:165

+ Here is the caller graph for this function:

void QwEPICSEvent::SetDataLoaded ( Bool_t  flag)
inlineprivate

Definition at line 96 of file QwEPICSEvent.h.

References fIsDataLoaded.

Referenced by ExtractEPICSValues(), and QwEPICSEvent().

96 { fIsDataLoaded = flag; };
Bool_t fIsDataLoaded
Definition: QwEPICSEvent.h:95

+ Here is the caller graph for this function:

int QwEPICSEvent::SetDataValue ( const string &  tag,
const double  value,
const int  event 
)

Definition at line 436 of file QwEPICSEvent.cc.

References FindIndex().

Referenced by ExtractEPICSValues(), and SetDataValue().

437 {
438  Int_t tagindex = FindIndex(tag);
439  return (SetDataValue(tagindex, value, event));
440 }
Int_t FindIndex(const string &tag) const
Find the index of an EPICS variable, or return error.
int SetDataValue(const string &tag, const double value, const int event)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int QwEPICSEvent::SetDataValue ( const string &  tag,
const string &  value,
const int  event 
)

Definition at line 442 of file QwEPICSEvent.cc.

References FindIndex(), and SetDataValue().

443 {
444  Int_t tagindex = FindIndex(tag);
445  return (SetDataValue(tagindex, value, event));
446 }
Int_t FindIndex(const string &tag) const
Find the index of an EPICS variable, or return error.
int SetDataValue(const string &tag, const double value, const int event)

+ Here is the call graph for this function:

int QwEPICSEvent::SetDataValue ( int  index,
const double  value,
const int  event 
)

Definition at line 448 of file QwEPICSEvent.cc.

References fEPICSDataEvent, kEPICS_Error, and kInvalidEPICSData.

449 {
450  if (index == kEPICS_Error) return kEPICS_Error;
451  if (index < 0) return kEPICS_Error;
452 
453  if (value != kInvalidEPICSData) {
454  fEPICSDataEvent[index].EventNumber = event;
455  fEPICSDataEvent[index].Value = value;
456  fEPICSDataEvent[index].StringValue = "";
457  fEPICSDataEvent[index].Filled = kTRUE;
458  return 0;
459  }
460  return kEPICS_Error;
461 }
static const Double_t kInvalidEPICSData
Definition: QwEPICSEvent.h:126
std::vector< EPICSVariableRecord > fEPICSDataEvent
Definition: QwEPICSEvent.h:146
static const int kEPICS_Error
Definition: QwEPICSEvent.h:124
int QwEPICSEvent::SetDataValue ( int  index,
const string &  value,
const int  event 
)

Definition at line 463 of file QwEPICSEvent.cc.

References fEPICSDataEvent, fEPICSVariableType, IsNumber(), kEPICS_Error, kEPICSFloat, kEPICSInt, kEPICSString, kInvalidEPICSData, and SetDataValue().

464 {
465  if (index == kEPICS_Error) return kEPICS_Error;
466  if (index < 0) return kEPICS_Error;
467 
468  Double_t tmpvalue = kInvalidEPICSData;
469  switch (fEPICSVariableType[index]) {
470  case kEPICSString:
471  fEPICSDataEvent[index].EventNumber = event;
472  fEPICSDataEvent[index].Value = 0.0;
473  fEPICSDataEvent[index].StringValue = value;
474  fEPICSDataEvent[index].Filled = kTRUE;
475  return 0;
476  break;
477 
478  case kEPICSFloat:
479  if (IsNumber(value)) {
480  tmpvalue = Double_t(atof(value.c_str()));
481  }
482  return SetDataValue(index, tmpvalue, event);
483  break;
484 
485  case kEPICSInt:
486  if(IsNumber(value)) {
487  tmpvalue = Double_t(atol(value.c_str()));
488  }
489  return SetDataValue(index, tmpvalue, event);
490  break;
491  }
492 
493  return kEPICS_Error;
494 }
Bool_t IsNumber(const string &word)
Definition: QwEPICSEvent.h:133
std::vector< EQwEPICSDataType > fEPICSVariableType
Definition: QwEPICSEvent.h:167
int SetDataValue(const string &tag, const double value, const int event)
static const Double_t kInvalidEPICSData
Definition: QwEPICSEvent.h:126
std::vector< EPICSVariableRecord > fEPICSDataEvent
Definition: QwEPICSEvent.h:146
static const int kEPICS_Error
Definition: QwEPICSEvent.h:124

+ Here is the call graph for this function:

void QwEPICSEvent::SetDefaultAutogainList ( std::vector< std::string > &  input_list)
static

Definition at line 429 of file QwEPICSEvent.cc.

References fDefaultAutogainList.

430 {
431  fDefaultAutogainList.clear(); //clear the vector first
432  fDefaultAutogainList = input_list;
433 }
static std::vector< std::string > fDefaultAutogainList
Default autogain list.
Definition: QwEPICSEvent.h:116
void QwEPICSEvent::WriteEPICSStringValues ( )

Definition at line 1271 of file QwEPICSEvent.cc.

References QwLog::endl(), fEPICSDataEvent, fEPICSVariableList, fEPICSVariableType, kEPICSString, and QwDebug.

1272 {
1273  QwDebug << "Entering QwEPICSEvent::WriteEPICSStringValues()" << QwLog::endl;
1274 
1275  Bool_t local_debug = false;
1276 
1277  TSeqCollection *file_list = gROOT->GetListOfFiles();
1278 
1279  if (file_list) {
1280 
1281  Int_t size = file_list->GetSize();
1282  for (Int_t i=0; i<size; i++)
1283  {
1284  TFile *file = (TFile*) file_list->At(i);
1285 
1286  if(local_debug) {
1287  std::cout << "QwEPICSEvent::WriteEPICSStringValue()"
1288  << file->GetName()
1289  << std::endl;
1290  }
1291 
1292  TTree *slow_tree = (TTree*) file->Get("Slow_Tree");
1293 
1294  for (std::size_t tagindex=0; tagindex<fEPICSVariableList.size(); tagindex++)
1295  {
1296  // only String
1297  if (fEPICSVariableType[tagindex] == kEPICSString) {
1298 
1299  TString name = fEPICSVariableList[tagindex];
1300  name.ReplaceAll(':','_'); // remove colons before creating branch
1301  TString name_type = name + "/C";\
1302 
1303  Char_t epics_char[128];
1304  TString epics_string;
1305 
1306  TBranch *new_branch = slow_tree->Branch(name, epics_char, name_type);
1307 
1308  if (fEPICSDataEvent[tagindex].Filled) {
1309  epics_string = fEPICSDataEvent[tagindex].StringValue;
1310  }
1311  else {
1312  epics_string = "empty";
1313  }
1314 
1315  if(local_debug) {
1316  std::cout << "QwEPICSEvent::WriteEPICSStringValue()\n";
1317  std::cout << name << " " << epics_string << std::endl;
1318  std::cout <<"\n";
1319  }
1320 
1321  sprintf(epics_char, "%s", epics_string.Data());
1322  new_branch->Fill();
1323  }
1324 
1325  }
1326 
1327  file -> Write("", TObject::kOverwrite);
1328  }
1329  }
1330 
1331  QwDebug << "Leaving QwEPICSEvent::WriteEPICSStringValues() normally" << QwLog::endl;
1332 
1333  return;
1334 
1335 }
std::vector< EQwEPICSDataType > fEPICSVariableType
Definition: QwEPICSEvent.h:167
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
std::vector< EPICSVariableRecord > fEPICSDataEvent
Definition: QwEPICSEvent.h:146
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
std::vector< std::string > fEPICSVariableList
Definition: QwEPICSEvent.h:165

+ Here is the call graph for this function:

Field Documentation

Bool_t QwEPICSEvent::fBlinderReversalForRunTwo
private

Definition at line 173 of file QwEPICSEvent.h.

Referenced by LoadChannelMap().

std::vector< std::string > QwEPICSEvent::fDefaultAutogainList
staticprivate

Default autogain list.

Definition at line 116 of file QwEPICSEvent.h.

Referenced by GetDefaultAutogainList(), InitDefaultAutogainList(), and SetDefaultAutogainList().

bool QwEPICSEvent::fDisableDatabase
private

Definition at line 130 of file QwEPICSEvent.h.

Referenced by FillDB(), and ProcessOptions().

std::vector<EPICSCumulativeRecord> QwEPICSEvent::fEPICSCumulativeData
private
std::vector<std::string> QwEPICSEvent::fEPICSTableList
private

Definition at line 166 of file QwEPICSEvent.h.

Referenced by AddEPICSTag(), FillSlowControlsData(), and FillSlowControlsStrigs().

std::map<std::string,Int_t> QwEPICSEvent::fEPICSVariableMap
private

Definition at line 169 of file QwEPICSEvent.h.

Referenced by AddEPICSTag(), and FindIndex().

Int_t QwEPICSEvent::fExtraHelicityReversal
private

Definition at line 177 of file QwEPICSEvent.h.

Referenced by DetermineIHWPPolarity(), and LoadChannelMap().

Bool_t QwEPICSEvent::fIsDataLoaded
private

Definition at line 95 of file QwEPICSEvent.h.

Referenced by ExtractEPICSValues(), HasDataLoaded(), ResetCounters(), and SetDataLoaded().

Double_t QwEPICSEvent::fNominalWienAngle
private

Definition at line 176 of file QwEPICSEvent.h.

Referenced by DetermineWienMode(), and LoadChannelMap().

Int_t QwEPICSEvent::fNumberEPICSEvents
private
Int_t QwEPICSEvent::fNumberEPICSVariables
private

Definition at line 164 of file QwEPICSEvent.h.

Referenced by AddEPICSTag(), CalculateRunningValues(), LoadChannelMap(), and ResetCounters().

Bool_t QwEPICSEvent::fPrecessionReversal
private

Definition at line 174 of file QwEPICSEvent.h.

Referenced by FillSlowControlsSettings(), and LoadChannelMap().

size_t QwEPICSEvent::fTreeArrayIndex
private

Definition at line 91 of file QwEPICSEvent.h.

Referenced by ConstructBranchAndVector(), and FillTreeVector().

size_t QwEPICSEvent::fTreeArrayNumEntries
private

Definition at line 92 of file QwEPICSEvent.h.

Referenced by ConstructBranchAndVector().

const int QwEPICSEvent::kDebug = 0
staticprivate
const int QwEPICSEvent::kEPICS_Error = -1
staticprivate
const int QwEPICSEvent::kEPICS_OK = 1
staticprivate

Definition at line 125 of file QwEPICSEvent.h.

const Double_t QwEPICSEvent::kInvalidEPICSData = -999999.0
staticprivate

Definition at line 126 of file QwEPICSEvent.h.

Referenced by GetDataValue(), and SetDataValue().


The documentation for this class was generated from the following files: