Class Reference for E1039 Core & Analysis Software
PHG4DetectorSubsystem.h
Go to the documentation of this file.
1 #ifndef PHG4DetectorSubsystem_h
2 #define PHG4DetectorSubsystem_h
3 
4 #include <g4main/PHG4Subsystem.h>
5 
6 #include <map>
7 #include <vector>
8 #include <string>
9 
10 class PHParameters;
12 
14 {
15  public:
16 
17  enum FILE_TYPE {none = 0, xml = 1, root = 2};
18 
20 
21  // stupid rootcint does not support final keyword
22 #ifndef __CINT__
23  int Init(PHCompositeNode *) final;
24  int InitRun(PHCompositeNode *) final;
25 #else
26  int Init(PHCompositeNode *);
27  int InitRun(PHCompositeNode *);
28 #endif
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_vdouble_param(const std::string &name, const std::vector<double> vdval);
42  void set_vdouble_param(const std::string &name, const double dvals[], const unsigned int n);
43  std::vector<double> get_vdouble_param(const std::string &name) const;
44  void set_int_param(const std::string &name, const int ival);
45  int get_int_param(const std::string &name) const;
46  void set_string_param(const std::string &name, const std::string &sval);
47  std::string get_string_param(const std::string &name) const;
48 
49  void UseDB(const int i = 1) {usedb = i;}
50  int ReadDB() const {return usedb;}
51  FILE_TYPE get_filetype() const {return filetype;}
52 
53  void UseCalibFiles(const FILE_TYPE ftyp) {filetype = ftyp;}
54  int SaveParamsToDB();
55  int ReadParamsFromDB(const std::string &name, const int issuper);
56 // int SaveParamsToFile(const FILE_TYPE ftyp);
57 // int ReadParamsFromFile(const std::string &name, const FILE_TYPE ftyp, const int issuper);
58  void SetCalibrationFileDir(const std::string &calibdir) {calibfiledir = calibdir;}
59 
61 
62  void SetActive(const int i = 1);
63  void SetAbsorberActive(const int i = 1);
64  void SetAbsorberTruth(const int i = 1);
65  void BlackHole(const int i=1);
66  void SuperDetector(const std::string &name);
67  const std::string SuperDetector() const {return superdetector;}
68 
69  int GetLayer() const {return layer;}
70  virtual void SetDefaultParameters() = 0; // this one has to be implemented by the daughter
71  protected: // those cannot be executed on the cmd line
72 
73  PHG4DetectorSubsystem(const std::string &name = "GenericSubsystem", const int lyr = 0);
74  // these initialize the defaults and add new entries to the
75  // list of variables. This should not be possible from the macro to
76  // prevent abuse (this makes the list of possible parameters deterministic)
77  void InitializeParameters();
78  void set_default_double_param( const std::string &name, const double dval);
79  void set_default_vdouble_param( const std::string &name, const std::vector<double> &dval);
80  void set_default_int_param( const std::string &name, const int ival);
81  void set_default_string_param( const std::string &name, const std::string &sval);
82  int BeginRunExecuted() const {return beginrunexecuted;}
83 
84  private:
85  //PHParameters *params;
86  PHParametersContainer *paramscontainer;
87  PHCompositeNode *savetopNode;
88  bool overlapcheck;
89  int layer;
90  int usedb;
91  int beginrunexecuted;
92  FILE_TYPE filetype;
93  std::string superdetector;
94  std::string calibfiledir;
95 
96  std::map<const std::string, double> dparams;
97  std::map<const std::string, std::vector<double> > vdparams;
98  std::map<const std::string, int> iparams;
99  std::map<const std::string, std::string> cparams;
100 
101  std::map<const std::string, double> default_double;
102  std::map<const std::string, std::vector<double> > default_vdouble;
103  std::map<const std::string, int> default_int;
104  std::map<const std::string, std::string> default_string;
105 
106 };
107 
108 #endif
void SetActive(const int i=1)
void set_default_vdouble_param(const std::string &name, const std::vector< double > &dval)
void set_vdouble_param(const std::string &name, const std::vector< double > vdval)
void UseDB(const int i=1)
const std::string SuperDetector() const
int InitRun(PHCompositeNode *) final
void set_double_param(const std::string &name, const double dval)
int ReadParamsFromDB(const std::string &name, const int issuper)
void set_default_double_param(const std::string &name, const double dval)
int Init(PHCompositeNode *) final
void BlackHole(const int i=1)
void OverlapCheck(const bool chk=true)
void SetCalibrationFileDir(const std::string &calibdir)
FILE_TYPE get_filetype() const
virtual int InitSubsystem(PHCompositeNode *)
std::vector< double > get_vdouble_param(const std::string &name) const
void set_string_param(const std::string &name, const std::string &sval)
void set_default_string_param(const std::string &name, const std::string &sval)
void set_int_param(const std::string &name, const int ival)
double get_double_param(const std::string &name) const
void SetAbsorberTruth(const int i=1)
PHParameters * GetParams() const
int get_int_param(const std::string &name) const
void UseCalibFiles(const FILE_TYPE ftyp)
virtual int InitRunSubsystem(PHCompositeNode *)
std::string get_string_param(const std::string &name) const
virtual void SetDefaultParameters()=0
void SetAbsorberActive(const int i=1)
PHG4DetectorSubsystem(const std::string &name="GenericSubsystem", const int lyr=0)
void set_default_int_param(const std::string &name, const int ival)
PHParameters * params
Definition: PHG4Subsystem.h:56