Analysis Software
Documentation for sPHENIX simulation 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 SetSupportActive(const int detid, const int i = 1);
64  void SetSupportActive(const int i = 1);
65 
66  void BlackHole(const int detid, const int i);
67  void BlackHole(const int i = 1);
68  void SuperDetector(const std::string &name);
69  const std::string SuperDetector() const { return m_SuperDetector; }
70  int GetLayer() const { return m_Layer; }
71  virtual void SetDefaultParameters() = 0; // this one has to be implemented by the daughter
72 
73  protected: // those cannot be executed on the cmd line
74  PHG4DetectorGroupSubsystem(const std::string &name = "GenericSubsystem", const int lyr = 0);
75  // these initialize the defaults and add new entries to the
76  // list of variables. This should not be possible from the macro to
77  // prevent abuse (this makes the list of possible parameters deterministic)
78  void InitializeParameters();
79  void AddDetId(const int i) { m_LayerSet.insert(i); }
80  std::pair<std::set<int>::const_iterator, std::set<int>::const_iterator> GetDetIds() const
81  {
82  return std::make_pair(m_LayerSet.begin(), m_LayerSet.end());
83  }
84  void set_default_double_param(const int detid, const std::string &name, const double dval);
85  void set_default_int_param(const int detid, const std::string &name, const int ival);
86  void set_default_string_param(const int detid, const std::string &name, const std::string &sval);
87  int BeginRunExecuted() const { return m_BeginRunExecutedFlag; }
88  void PrintDefaultParams() const;
89  void PrintMacroParams() const;
90 
91  private:
95  bool m_OverlapCheckFlag = false;
96  int m_Layer = 0;
97  int m_UseDBFlag = 0;
102 
103  std::set<int> m_LayerSet;
104 
105  std::map<int, std::map<const std::string, double>> m_MacroDoubleParamsMap;
106  std::map<int, std::map<const std::string, int>> m_MacroIntegerParamsMap;
107  std::map<int, std::map<const std::string, std::string>> m_MacroStringParamsMap;
108 
109  std::map<int, std::map<const std::string, double>> m_DefaultDoubleParamsMap;
110  std::map<int, std::map<const std::string, int>> m_DefaultIntegerParamsMap;
111  std::map<int, std::map<const std::string, std::string>> m_DefaultStringParamsMap;
112 };
113 
114 #endif