EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4DetectorGroupSubsystem.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4DetectorGroupSubsystem.h
1 // Tell emacs that this is a C++ source
2 // -*- C++ -*-.
3 #ifndef G4DETECTORS_PHG4DETECTORGROUPSUBSYSTEM_H
4 #define G4DETECTORS_PHG4DETECTORGROUPSUBSYSTEM_H
5 
6 #include <g4main/PHG4Subsystem.h>
7 
8 #include <map>
9 #include <set>
10 #include <string>
11 #include <utility> // for make_pair, pair
12 
13 class PHCompositeNode;
15 
17 {
18  public:
19  enum FILE_TYPE
20  {
21  none = 0,
22  xml = 1,
23  root = 2
24  };
25 
27  int Init(PHCompositeNode *) final;
28  int InitRun(PHCompositeNode *) final;
29 
31  {
32  return 0;
33  }
34  virtual int InitSubsystem(PHCompositeNode *) { return 0; }
35  void OverlapCheck(const bool chk = true) { m_OverlapCheckFlag = chk; }
36  bool CheckOverlap() const { return m_OverlapCheckFlag; }
38  // Get/Set parameters from macro
39  void set_double_param(const int detid, const std::string &name, const double dval);
40  double get_double_param(const int detid, const std::string &name) const;
41  void set_int_param(const int detid, const std::string &name, const int ival);
42  int get_int_param(const int detid, const std::string &name) const;
43  void set_string_param(const int detid, const std::string &name, const std::string &sval);
44  std::string get_string_param(const int detid, const std::string &name) const;
45 
46  void UseDB(const int i = 1) { m_UseDBFlag = i; }
47  int ReadDB() const { return m_UseDBFlag; }
48  FILE_TYPE get_filetype() const { return m_FileType; }
49  void UseCalibFiles(const FILE_TYPE ftyp) { m_FileType = ftyp; }
50  int SaveParamsToDB();
51  int ReadParamsFromDB(const std::string &name, const int issuper);
52  int SaveParamsToFile(const FILE_TYPE ftyp);
53  int ReadParamsFromFile(const std::string &name, const FILE_TYPE ftyp, const int issuper);
54  void SetCalibrationFileDir(const std::string &calibdir) { m_CalibFileDir = calibdir; }
56 
57  void SetActive(const int detid, const int i);
58  void SetActive(const int i = 1);
59  void SetAbsorberActive(const int detid, const int i);
60  void SetAbsorberActive(const int i = 1);
61  void SetAbsorberTruth(const int detid, const int i);
62  void SetAbsorberTruth(const int i = 1);
63  void BlackHole(const int detid, const int i);
64  void BlackHole(const int i = 1);
65  void SuperDetector(const std::string &name);
66  const std::string SuperDetector() const { return m_SuperDetector; }
67  int GetLayer() const { return m_Layer; }
68  virtual void SetDefaultParameters() = 0; // this one has to be implemented by the daughter
69 
70  protected: // those cannot be executed on the cmd line
71  PHG4DetectorGroupSubsystem(const std::string &name = "GenericSubsystem", const int lyr = 0);
72  // these initialize the defaults and add new entries to the
73  // list of variables. This should not be possible from the macro to
74  // prevent abuse (this makes the list of possible parameters deterministic)
75  void InitializeParameters();
76  void AddDetId(const int i) { m_LayerSet.insert(i); }
77  std::pair<std::set<int>::const_iterator, std::set<int>::const_iterator> GetDetIds() const
78  {
79  return std::make_pair(m_LayerSet.begin(), m_LayerSet.end());
80  }
81  void set_default_double_param(const int detid, const std::string &name, const double dval);
82  void set_default_int_param(const int detid, const std::string &name, const int ival);
83  void set_default_string_param(const int detid, const std::string &name, const std::string &sval);
84  int BeginRunExecuted() const { return m_BeginRunExecutedFlag; }
85  void PrintDefaultParams() const;
86  void PrintMacroParams() const;
87 
88  private:
93  int m_Layer;
97  std::string m_SuperDetector;
98  std::string m_CalibFileDir;
99 
100  std::set<int> m_LayerSet;
101 
102  std::map<int, std::map<const std::string, double>> m_MacroDoubleParamsMap;
103  std::map<int, std::map<const std::string, int>> m_MacroIntegerParamsMap;
104  std::map<int, std::map<const std::string, std::string>> m_MacroStringParamsMap;
105 
106  std::map<int, std::map<const std::string, double>> m_DefaultDoubleParamsMap;
107  std::map<int, std::map<const std::string, int>> m_DefaultIntegerParamsMap;
108  std::map<int, std::map<const std::string, std::string>> m_DefaultStringParamsMap;
109 };
110 
111 #endif