Class Reference for E1039 Core & Analysis Software
RunParamBase.h
Go to the documentation of this file.
1 #ifndef __RUN_PARAM_BASE_H__
2 #define __RUN_PARAM_BASE_H__
3 #include <iostream>
4 #include <map>
5 #include <vector>
6 #include <string>
7 #include <tuple>
8 #include "ParamRunRange.h"
9 class DbSvc;
10 
11 class RunParamBase {
12  std::string m_dir_base;
13  std::string m_type;
14  std::string m_label;
15  std::string m_header;
16  std::string m_map_id;
17  ParamRunRange m_range;
18 
19  public:
20  RunParamBase(const std::string type, const std::string label, const std::string header);
21  virtual ~RunParamBase() {;}
22 
23  void SetBaseDir(const std::string dir_base) { m_dir_base = dir_base; }
24  std::string GetBaseDir() { return m_dir_base; }
25  std::string GetParamID() { return m_type+"_"+m_label; }
26 
27  std::string GetMapID() { return m_map_id; }
28  void SetMapID(const std::string map_id) { m_map_id = map_id; }
29  void SetMapIDbyFile(const std::string map_id);
30  void SetMapIDbyDB (const std::string map_id);
31  void SetMapIDbyFile(const int run);
32  void SetMapIDbyDB (const int run);
33 
34  void ReadFromFile();
35  void WriteToFile();
36  void ReadFromLocalFile(const std::string fn_tsv);
37  void WriteToLocalFile(const std::string fn_tsv);
38 
39  void ReadFromDB();
40  void WriteToDB ();
41  void WriteRangeToDB();
42 
43  virtual void Print(std::ostream& os);
44 
45  protected:
46  std::string RangeFileName();
47  std::string MapFileName();
48  std::string SchemaName();
49  std::string MapTableName();
50 
51  typedef std::vector<std::string> LineList;
52  virtual int ReadFileCont(LineList& lines);
53  virtual int WriteFileCont(std::ostream& os);
54 
55  virtual void ReadDbTable(DbSvc& db);
56  virtual void WriteDbTable(DbSvc& db);
57 };
58 
59 class ChanMapBase : public RunParamBase {
60  protected:
61  typedef std::tuple<short, short, short> RocBoardChan_t;
62 
65  size_t operator()(const RocBoardChan_t& a) const {
66  size_t a0 = std::get<0>(a);
67  size_t a1 = std::get<1>(a);
68  size_t a2 = std::get<2>(a);
69  return (a0 << 32) | (a1 << 16) | a2;
70  }
71  };
72 
73  public:
74  ChanMapBase(const std::string label, const std::string header) : RunParamBase("chan_map", label, header) {;}
75  virtual ~ChanMapBase() {;}
76 };
77 
78 class CalibParamBase : public RunParamBase {
79  public:
80  CalibParamBase(const std::string label, const std::string header) : RunParamBase("calib", label, header) {;}
81  virtual ~CalibParamBase() {;}
82 };
83 
84 class GeomParamBase : public RunParamBase {
85  public:
86  GeomParamBase(const std::string label, const std::string header) : RunParamBase("geom", label, header) {;}
87  virtual ~GeomParamBase() {;}
88 };
89 
90 #endif // __RUN_PARAM_BASE_H__
CalibParamBase(const std::string label, const std::string header)
Definition: RunParamBase.h:80
virtual ~CalibParamBase()
Definition: RunParamBase.h:81
virtual ~ChanMapBase()
Definition: RunParamBase.h:75
ChanMapBase(const std::string label, const std::string header)
Definition: RunParamBase.h:74
std::tuple< short, short, short > RocBoardChan_t
Definition: RunParamBase.h:61
Standard interface with SQL database.
Definition: DbSvc.h:15
virtual ~GeomParamBase()
Definition: RunParamBase.h:87
GeomParamBase(const std::string label, const std::string header)
Definition: RunParamBase.h:86
std::string GetParamID()
Definition: RunParamBase.h:25
void SetMapID(const std::string map_id)
Definition: RunParamBase.h:28
void WriteToDB()
void WriteRangeToDB()
void ReadFromDB()
virtual void WriteDbTable(DbSvc &db)
virtual void Print(std::ostream &os)
RunParamBase(const std::string type, const std::string label, const std::string header)
Definition: RunParamBase.cc:11
void WriteToFile()
Definition: RunParamBase.cc:58
std::string MapFileName()
std::vector< std::string > LineList
Definition: RunParamBase.h:51
void SetMapIDbyFile(const std::string map_id)
Definition: RunParamBase.cc:21
void SetBaseDir(const std::string dir_base)
Definition: RunParamBase.h:23
virtual int WriteFileCont(std::ostream &os)
virtual ~RunParamBase()
Definition: RunParamBase.h:21
void SetMapIDbyDB(const std::string map_id)
Definition: RunParamBase.cc:31
void WriteToLocalFile(const std::string fn_tsv)
Definition: RunParamBase.cc:85
std::string SchemaName()
virtual void ReadDbTable(DbSvc &db)
void ReadFromLocalFile(const std::string fn_tsv)
Definition: RunParamBase.cc:63
std::string GetMapID()
Definition: RunParamBase.h:27
std::string MapTableName()
void ReadFromFile()
Definition: RunParamBase.cc:53
std::string GetBaseDir()
Definition: RunParamBase.h:24
std::string RangeFileName()
virtual int ReadFileCont(LineList &lines)
Hash of RocBoardChan_t for unordered_map.
Definition: RunParamBase.h:64
size_t operator()(const RocBoardChan_t &a) const
Definition: RunParamBase.h:65