Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:21:09

0001 //////////////////////////////////////////////////////////////
0002 //
0003 // SpinDBInput class
0004 // Author      : D. Loomis, D. Neff (from Y. Fukao PHENIX class)
0005 // Description : Utility to write data into the spin database
0006 // Created     : 2024-05-12
0007 //
0008 //////////////////////////////////////////////////////////////
0009 
0010 #ifndef USPIN_SPINDBINPUT_H
0011 #define USPIN_SPINDBINPUT_H
0012 
0013 #include <stdio.h>
0014 #include <sstream>
0015 
0016 namespace odbc
0017 {
0018   class Connection;
0019   class Statement;
0020   class ResultSet;
0021 };  // namespace odbc
0022 
0023 class SpinDBContent;
0024 
0025 class SpinDBInput
0026 {
0027  public:
0028   SpinDBInput() { Initialize(); }
0029   virtual ~SpinDBInput();
0030   void Initialize();
0031   int IsConnected();
0032   int CheckRunRow(int runnum, int qa_level, const std::string &opt = "");
0033   int CreateRunRow(int runnum, int qa_level);
0034   int DeleteRunRow(int runnum, int qa_level);
0035   int InitializeRunRow(SpinDBContent &spin_cont);
0036   int UpdateDBContent(SpinDBContent &spin_cont);
0037   int SetDefaultQA(SpinDBContent &spin_cont);
0038   int UpdateValue(int runnum, int qa_level, const std::string &name, int value);
0039   int UpdateValue(int runnum, int qa_level, const std::string &name, float value);
0040   int UpdateValue(int runnum, int qa_level, const std::string &name, double value);
0041   int UpdateArray(int runnum, int qa_level, const std::string &name, int *value, int nvalue);
0042   int UpdateArray(int runnum, int qa_level, const std::string &name, float *value, int nvalue);
0043   int UpdateArray(int runnum, int qa_level, const std::string &name, double *value, int nvalue);
0044   int UpdateArray(int runnum, int qa_level, const std::string &name, unsigned int *value, int nvalue);
0045   int UpdateArray(int runnum, int qa_level, const std::string &name, long long *value, int nvalue);
0046   int InitializeValue(int runnum, int qa_level, const std::string &name);
0047   int InitializeArray(int runnum, int qa_level, const std::string &name, int nvalue);
0048 
0049  private:
0050   static constexpr std::string DB_NAME{"spinDB_write"};
0051   static constexpr std::string TABLE_NAME{"spin"};
0052   static constexpr int ERROR_VALUE{-999};
0053 
0054   odbc::Connection *con{nullptr};
0055   int run_check;
0056   int qa_check;
0057 
0058   int UpdateValue(int runnum, int qa_level, const std::string &cmd);
0059   template <class T>
0060   int UpdateValueTemp(int runnum, int qa_level, const std::string &name, T value);
0061   template <class T>
0062   int UpdateArrayTemp(int runnum, int qa_level, const std::string &name, T *value, int nvalue);
0063 };
0064 
0065 #endif /* USPIN_SPINDBINPUT_H */