ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4DetectorSubsystem.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4DetectorSubsystem.h
1 // Tell emacs that this is a C++ source
2 // -*- C++ -*-.
3 #ifndef G4DETECTORS_PHG4DETECTORSUBSYSTEM_H
4 #define G4DETECTORS_PHG4DETECTORSUBSYSTEM_H
5 
6 #include <g4main/PHG4Subsystem.h>
7 
8 #include <map>
9 #include <string>
10 
11 class PHCompositeNode;
12 class PHParameters;
14 
16 {
17  public:
18  enum FILE_TYPE
19  {
20  none = 0,
21  xml = 1,
22  root = 2
23  };
24 
25  ~PHG4DetectorSubsystem() override {}
26 
27  int Init(PHCompositeNode *) final;
28  int InitRun(PHCompositeNode *) final;
29 
30  virtual int InitRunSubsystem(PHCompositeNode *) { return 0; }
31  virtual int InitSubsystem(PHCompositeNode *) { return 0; }
32 
33  void OverlapCheck(const bool chk = true) { overlapcheck = chk; }
34  bool CheckOverlap() const { return overlapcheck; }
35 
36  PHParameters *GetParams() const { return params; }
37 
38  // Get/Set parameters from macro
39  void set_double_param(const std::string &name, const double dval);
40  double get_double_param(const std::string &name) const;
41  void set_int_param(const std::string &name, const int ival);
42  int get_int_param(const std::string &name) const;
43  void set_string_param(const std::string &name, const std::string &sval);
44  std::string get_string_param(const std::string &name) const;
45 
46  void UseDB(const int i = 1) { usedb = i; }
47  int ReadDB() const { return usedb; }
48  FILE_TYPE get_filetype() const { return filetype; }
49 
50  void UseCalibFiles(const FILE_TYPE ftyp) { filetype = ftyp; }
51  int SaveParamsToDB();
52  int ReadParamsFromDB(const std::string &name, const int issuper);
53  int SaveParamsToFile(const FILE_TYPE ftyp);
54  int ReadParamsFromFile(const std::string &name, const FILE_TYPE ftyp, const int issuper);
55  void SetCalibrationFileDir(const std::string &calibdir) { calibfiledir = calibdir; }
56 
58 
59  void SetActive(const int i = 1);
60  void SetAbsorberActive(const int i = 1);
61  void SetAbsorberTruth(const int i = 1);
62  void BlackHole(const int i = 1);
63  void SetSupportActive(const int i = 1);
64 
65  void SuperDetector(const std::string &name);
66  const std::string SuperDetector() const { return superdetector; }
67 
68  int GetLayer() const { return layer; }
69  virtual void SetDefaultParameters() = 0; // this one has to be implemented by the daughter
70  protected: // those cannot be executed on the cmd line
71  PHG4DetectorSubsystem(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 set_default_double_param(const std::string &name, const double dval);
77  void set_default_int_param(const std::string &name, const int ival);
78  void set_default_string_param(const std::string &name, const std::string &sval);
79  int BeginRunExecuted() const { return beginrunexecuted; }
80 
81  private:
82  PHParameters *params = nullptr;
85  bool overlapcheck = false;
86  int layer = -1;
87  int usedb = 0;
90  std::string superdetector = "NONE";
91  std::string calibfiledir = "./";
92 
93  std::map<const std::string, double> dparams;
94  std::map<const std::string, int> iparams;
95  std::map<const std::string, std::string> cparams;
96 
97  std::map<const std::string, double> default_double;
98  std::map<const std::string, int> default_int;
99  std::map<const std::string, std::string> default_string;
100 };
101 
102 #endif