Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:18:12

0001 #ifndef G4CALO_RAWTOWERDIGITIZER_H
0002 #define G4CALO_RAWTOWERDIGITIZER_H
0003 
0004 #include <fun4all/SubsysReco.h>
0005 
0006 #include <phparameter/PHParameters.h>
0007 
0008 #include <gsl/gsl_rng.h>
0009 
0010 #include <cmath>
0011 #include <string>
0012 
0013 class CDBTTree;
0014 class PHCompositeNode;
0015 class RawTower;
0016 class TowerInfo;
0017 class TowerInfoContainer;
0018 class RawTowerContainer;
0019 class RawTowerGeomContainer;
0020 class RawTowerDeadMap;
0021 
0022 //! simple tower digitizer which sum all cell to produce photon yield and pedstal noises
0023 //! default input DST node is TOWER_SIM_DETECTOR
0024 //! default output DST node is TOWER_RAW_DETECTOR
0025 class RawTowerDigitizer : public SubsysReco
0026 {
0027  public:
0028   RawTowerDigitizer(const std::string &name = "RawTowerDigitizer");
0029   ~RawTowerDigitizer() override;
0030 
0031   int InitRun(PHCompositeNode *topNode) override;
0032   int process_event(PHCompositeNode *topNode) override;
0033   void Detector(const std::string &d)
0034   {
0035     m_Detector = d;
0036     _tower_params.set_name(d);
0037   }
0038   void TowerType(const int type) { m_TowerType = type; }
0039   void set_seed(const unsigned int iseed);
0040   unsigned int get_seed() const { return m_Seed; }
0041   enum enu_digi_algorithm
0042   {
0043     //! directly pass the energy of sim tower to digitized tower
0044     kNo_digitization = 0,
0045     //! wrong spelling, kept for macro compatibility
0046     kNo_digitalization = 0,
0047 
0048     //! simple digitization with photon statistics, single amplitude ADC conversion and pedestal
0049     kSimple_photon_digitization = 1,
0050     //! wrong spelling, kept for macro compatibility
0051     kSimple_photon_digitalization = 1,
0052 
0053     //! digitization with photon statistics on SiPM with an effective pixel N, ADC conversion and pedestal
0054     kSiPM_photon_digitization = 2
0055   };
0056 
0057   enum ProcessTowerType
0058   {
0059     kRawTowerOnly = 0,
0060     kTowerInfoOnly = 1,
0061     kBothTowers = 2
0062   };
0063 
0064   enu_digi_algorithm
0065   get_digi_algorithm() const
0066   {
0067     return m_DigiAlgorithm;
0068   }
0069 
0070   void
0071   set_digi_algorithm(enu_digi_algorithm digiAlgorithm)
0072   {
0073     m_DigiAlgorithm = digiAlgorithm;
0074   }
0075 
0076   double
0077   get_pedstal_central_ADC() const
0078   {
0079     return m_PedstalCentralADC;
0080   }
0081 
0082   void
0083   set_pedstal_central_ADC(const double pedstalCentralAdc)
0084   {
0085     m_PedstalCentralADC = pedstalCentralAdc;
0086   }
0087 
0088   double
0089   get_pedstal_width_ADC() const
0090   {
0091     return m_PedstalWidthADC;
0092   }
0093 
0094   void
0095   set_pedstal_width_ADC(const double pedstalWidthAdc)
0096   {
0097     m_PedstalWidthADC = pedstalWidthAdc;
0098   }
0099 
0100   double
0101   get_photonelec_ADC() const
0102   {
0103     return m_PhotonElecADC;
0104   }
0105 
0106   void
0107   set_photonelec_ADC(const double photonelecAdc)
0108   {
0109     m_PhotonElecADC = photonelecAdc;
0110   }
0111 
0112   double
0113   get_photonelec_yield_visible_GeV() const
0114   {
0115     return m_PhotonElecYieldVisibleGeV;
0116   }
0117 
0118   void
0119   set_photonelec_yield_visible_GeV(const double photonelecYieldVisibleGeV)
0120   {
0121     m_PhotonElecYieldVisibleGeV = photonelecYieldVisibleGeV;
0122   }
0123 
0124   double
0125   get_zero_suppression_ADC() const
0126   {
0127     return m_ZeroSuppressionADC;
0128   }
0129 
0130   void
0131   set_zero_suppression_ADC(const double zeroSuppressionAdc)
0132   {
0133     m_ZeroSuppressionADC = zeroSuppressionAdc;
0134   }
0135 
0136   void
0137   set_variable_zero_suppression(const bool value)
0138   {
0139     m_ZeroSuppressionFile = value;
0140   }
0141 
0142   void
0143   set_variable_pedestal(const bool value)
0144   {
0145     m_pedestalFile = value;
0146   }
0147 
0148   PHParameters &
0149   GetParameters()
0150   {
0151     return _tower_params;
0152   }
0153 
0154   const std::string
0155   &get_raw_tower_node_prefix() const
0156   {
0157     return m_RawTowerNodePrefix;
0158   }
0159 
0160   void
0161   set_raw_tower_node_prefix(const std::string &rawTowerNodePrefix)
0162   {
0163     m_RawTowerNodePrefix = rawTowerNodePrefix;
0164   }
0165 
0166   const std::string
0167   &get_sim_tower_node_prefix() const
0168   {
0169     return m_SimTowerNodePrefix;
0170   }
0171 
0172   void
0173   set_sim_tower_node_prefix(const std::string &simTowerNodePrefix)
0174   {
0175     m_SimTowerNodePrefix = simTowerNodePrefix;
0176   }
0177 
0178   // ! SiPM effective pixel per tower, only used with kSiPM_photon_digitalization
0179   void set_sipm_effective_pixel(const unsigned int &d) { m_SiPMEffectivePixel = d; }
0180 
0181   // ! SiPM effective pixel per tower, only used with kSiPM_photon_digitalization
0182   unsigned int get_sipm_effective_pixel() { return m_SiPMEffectivePixel; }
0183 
0184   // calo calib decal stuff JEF Feb 2022
0185   void set_DoTowerDecal(const bool doTowerDecal,
0186                         const char *decalFileName = "",
0187                         const bool doInverse = false)
0188   {
0189     m_DoDecal = doTowerDecal;
0190     m_DecalInverse = doInverse;
0191     set_DecalFileName(decalFileName);
0192   }
0193 
0194   void set_DecalFileName(const char *inCalFname)
0195   {
0196     m_DecalFileName = inCalFname;
0197   }
0198 
0199   void set_UseConditionsDB(const bool setUseCondDB)
0200   {
0201     m_UseConditionsDB = setUseCondDB;
0202   }
0203 
0204   void set_towerinfo(RawTowerDigitizer::ProcessTowerType UseTowerInfo)
0205   {
0206     m_UseTowerInfo = UseTowerInfo;
0207   }
0208 
0209  private:
0210   void CreateNodes(PHCompositeNode *topNode);
0211 
0212   //! simple digitization with photon statistics, ADC conversion and pedstal
0213   //! \param  sim_tower simulation tower input
0214   //! \return a new RawTower object contain digitalized value of ADC output in RawTower::get_energy()
0215   RawTower *simple_photon_digitization(RawTower *sim_tower);
0216   TowerInfo *simple_photon_digitization(TowerInfo *sim_tower);
0217 
0218   //! digitization with photon statistics on SiPM with an effective pixel N, ADC conversion and pedestal
0219   //! this function use the effective pixel to count for the effect that the sipm is not evenly lit
0220   RawTower *sipm_photon_digitization(RawTower *sim_tower);
0221   TowerInfo *sipm_photon_digitization(TowerInfo *sim_tower);
0222 
0223   enu_digi_algorithm m_DigiAlgorithm {kNo_digitization};
0224 
0225   RawTowerContainer *m_SimTowers {nullptr};
0226   RawTowerContainer *m_RawTowers {nullptr};
0227 
0228   TowerInfoContainer *m_SimTowerInfos {nullptr};
0229   TowerInfoContainer *m_RawTowerInfos {nullptr};
0230 
0231   RawTowerGeomContainer *m_RawTowerGeom {nullptr};
0232   RawTowerDeadMap *m_DeadMap {nullptr};
0233 
0234   std::string m_Detector {"NONE"};
0235 
0236   std::string m_SimTowerNodePrefix {"SIM"};
0237   std::string m_RawTowerNodePrefix {"RAW"};
0238 
0239   //! photon electron yield per GeV of visible energy
0240   double m_PhotonElecYieldVisibleGeV {std::numeric_limits<double>::quiet_NaN()};
0241 
0242   //! photon electron per ADC unit
0243   double m_PhotonElecADC {std::numeric_limits<double>::quiet_NaN()};
0244 
0245   //! pedstal central in unit of ADC
0246   double m_PedstalCentralADC {std::numeric_limits<double>::quiet_NaN()};
0247 
0248   //! pedstal width in unit of ADC
0249   double m_PedstalWidthADC {std::numeric_limits<double>::quiet_NaN()};
0250 
0251   //! pedestal from file
0252   bool m_pedestalFile {false};
0253 
0254   //! zero suppression in unit of ADC
0255   double m_ZeroSuppressionADC {-1000};
0256 
0257   //! zero suppression from file
0258   bool m_ZeroSuppressionFile {false};
0259 
0260   //! tower type to act on
0261   int m_TowerType {-1};
0262 
0263   unsigned int m_Seed {0};
0264 
0265   // ! SiPM effective pixel per tower, only used with kSiPM_photon_digitalization
0266   // ! sPHENIX EMCal default, 4x Hamamatsu S12572-015P MPPC [sPHENIX TDR]
0267   unsigned int m_SiPMEffectivePixel {40000 * 4};
0268 
0269   PHParameters _tower_params;
0270 
0271   gsl_rng *m_RandomGenerator {nullptr};
0272 
0273   // calo calibs decal stuff JEF Feb 2022
0274   bool m_DoDecal {false};
0275   bool m_DecalInverse {false};
0276   bool m_Decal {true};
0277   std::string m_DecalFileName;
0278   bool m_UseConditionsDB {false};
0279   CDBTTree *m_CDBTTree {nullptr};
0280 
0281   RawTowerDigitizer::ProcessTowerType m_UseTowerInfo {RawTowerDigitizer::ProcessTowerType::kBothTowers};  // 0 just produce RawTowers, 1 just produce TowerInfo objects, and 2 produce both
0282 };
0283 
0284 #endif /* G4CALO_RAWTOWERDIGITIZER_H */