Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:17:47

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef G4DETECTORS_PHG4DETECTORSUBSYSTEM_H
0004 #define G4DETECTORS_PHG4DETECTORSUBSYSTEM_H
0005 
0006 #include <g4main/PHG4Subsystem.h>
0007 
0008 #include <map>
0009 #include <string>
0010 
0011 class PHCompositeNode;
0012 class PHParameters;
0013 class PHParametersContainer;
0014 
0015 class PHG4DetectorSubsystem : public PHG4Subsystem
0016 {
0017  public:
0018   enum FILE_TYPE
0019   {
0020     none = 0,
0021     xml = 1,
0022     root = 2
0023   };
0024 
0025   ~PHG4DetectorSubsystem() override = default;
0026 
0027   int Init(PHCompositeNode *) final;
0028   int InitRun(PHCompositeNode *) final;
0029 
0030   virtual int InitRunSubsystem(PHCompositeNode *) { return 0; }
0031   virtual int InitSubsystem(PHCompositeNode *) { return 0; }
0032 
0033   void OverlapCheck(const bool chk = true) { overlapcheck = chk; }
0034   bool CheckOverlap() const { return overlapcheck; }
0035 
0036   PHParameters *GetParams() const { return params; }
0037 
0038   // Get/Set parameters from macro
0039   void set_double_param(const std::string &name, const double dval);
0040   double get_double_param(const std::string &name) const;
0041   void set_int_param(const std::string &name, const int ival);
0042   int get_int_param(const std::string &name) const;
0043   void set_string_param(const std::string &name, const std::string &sval);
0044   std::string get_string_param(const std::string &name) const;
0045 
0046   void UseDB(const int i = 1) { usedb = i; }
0047   int ReadDB() const { return usedb; }
0048   void UseCDB(const std::string &domain)
0049   {
0050     usedb = 1;
0051     m_Domain = domain;
0052   }
0053 
0054   FILE_TYPE get_filetype() const { return filetype; }
0055 
0056   void UseCalibFiles(const FILE_TYPE ftyp) { filetype = ftyp; }
0057   int ReadParamsFromCDB(const std::string &domain);
0058   int SaveParamsToFile(const FILE_TYPE ftyp);
0059   int ReadParamsFromFile(const std::string &name, const FILE_TYPE ftyp, const int issuper);
0060   void SetCalibrationFileDir(const std::string &calibdir) { calibfiledir = calibdir; }
0061 
0062   void UpdateParametersWithMacro();
0063 
0064   void SetActive(const int i = 1);
0065   void SetAbsorberActive(const int i = 1);
0066   void SetAbsorberTruth(const int i = 1);
0067   void BlackHole(const int i = 1);
0068   void SetSupportActive(const int i = 1);
0069 
0070   void SuperDetector(const std::string &name);
0071   const std::string &SuperDetector() const { return superdetector; }
0072 
0073   int GetLayer() const { return layer; }
0074   virtual void SetDefaultParameters() = 0;  // this one has to be implemented by the daughter
0075  protected:                                 // those cannot be executed on the cmd line
0076   PHG4DetectorSubsystem(const std::string &name = "GenericSubsystem", const int lyr = 0);
0077   // these initialize the defaults and add new entries to the
0078   // list of variables. This should not be possible from the macro to
0079   // prevent abuse (this makes the list of possible parameters deterministic)
0080   void InitializeParameters();
0081   void set_default_double_param(const std::string &name, const double dval);
0082   void set_default_int_param(const std::string &name, const int ival);
0083   void set_default_string_param(const std::string &name, const std::string &sval);
0084   int BeginRunExecuted() const { return beginrunexecuted; }
0085 
0086  private:
0087   PHParameters *params {nullptr};
0088   PHParametersContainer *paramscontainer {nullptr};
0089   PHCompositeNode *savetopNode {nullptr};
0090   bool overlapcheck {false};
0091   int layer {-1};
0092   int usedb {0};
0093   int beginrunexecuted {0};
0094   FILE_TYPE filetype {PHG4DetectorSubsystem::none};
0095   std::string superdetector {"NONE"};
0096   std::string calibfiledir {"./"};
0097   std::string m_Domain;
0098 
0099   std::map<const std::string, double> dparams;
0100   std::map<const std::string, int> iparams;
0101   std::map<const std::string, std::string> cparams;
0102 
0103   std::map<const std::string, double> default_double;
0104   std::map<const std::string, int> default_int;
0105   std::map<const std::string, std::string> default_string;
0106 };
0107 
0108 #endif