Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:17:02

0001 #ifndef CALORECO_RAWTOWERCALIBRATION_H
0002 #define CALORECO_RAWTOWERCALIBRATION_H
0003 
0004 #include <fun4all/SubsysReco.h>
0005 
0006 #include <phparameter/PHParameters.h>
0007 
0008 #include <iostream>
0009 #include <limits>
0010 #include <string>
0011 
0012 class CDBTTree;
0013 class PHCompositeNode;
0014 class RawTowerContainer;
0015 class TowerInfoContainer;
0016 class RawTowerGeomContainer;
0017 
0018 //! calibrate ADC value to measured energy deposition in calorimeter towers
0019 //! default input DST node is TOWER_RAW_DETECTOR
0020 //! default output DST node is TOWER_CALIB_DETECTOR
0021 class RawTowerCalibration : public SubsysReco
0022 {
0023  public:
0024   RawTowerCalibration(const std::string &name = "RawTowerCalibration");
0025   ~RawTowerCalibration() override;
0026 
0027   int InitRun(PHCompositeNode *topNode) override;
0028   int process_event(PHCompositeNode *topNode) override;
0029   int End(PHCompositeNode *topNode) override;
0030   void Detector(const std::string &d)
0031   {
0032     m_Detector = d;
0033     _tower_calib_params.set_name(d);
0034   }
0035   void TowerType(const int type)
0036   {
0037     _tower_type = type;
0038   }
0039 
0040   enum enu_calib_algorithm
0041   {
0042     //! directly pass the energy of raw tower to calibrated tower. Zero suppression is applied
0043     kNo_calibration = 0,
0044 
0045     //! simple calibration with pedstal subtraction and a global energy scale (sampling fraction) correction
0046     kSimple_linear_calibration = 1,
0047 
0048     //! input calibration file for tower by tower calibration. Use GetCalibrationParameters() to set the calibration parameters
0049     kTower_by_tower_calibration = 2,
0050 
0051     // use conditions DB file/wrapper (non-xml) file for most gain tracing correction factors
0052     kDbfile_tbt_gain_corr = 3
0053   };
0054   enum ProcessTowerType
0055   {
0056     kRawTowerOnly = 0,
0057     kTowerInfoOnly = 1,
0058     kBothTowers = 2
0059   };
0060 
0061   enu_calib_algorithm get_calib_algorithm() const
0062   {
0063     return _calib_algorithm;
0064   }
0065 
0066   void set_calib_algorithm(enu_calib_algorithm calibAlgorithm)
0067   {
0068     _calib_algorithm = calibAlgorithm;
0069   }
0070 
0071   double get_calib_const_GeV_ADC() const
0072   {
0073     return _calib_const_GeV_ADC;
0074   }
0075 
0076   void set_calib_const_GeV_ADC(double calibConstGeVAdc)
0077   {
0078     _calib_const_GeV_ADC = calibConstGeVAdc;
0079   }
0080 
0081   void set_variable_GeV_ADC(const bool value)
0082   {
0083     _GeV_ADC_file = value;
0084   }
0085 
0086   const std::string &get_calib_tower_node_prefix() const
0087   {
0088     return _calib_tower_node_prefix;
0089   }
0090 
0091   void set_calib_tower_node_prefix(const std::string &calibTowerNodePrefix)
0092   {
0093     _calib_tower_node_prefix = calibTowerNodePrefix;
0094   }
0095 
0096   double get_pedstal_ADC() const
0097   {
0098     return _pedstal_ADC;
0099   }
0100 
0101   void set_pedstal_ADC(double pedstalAdc)
0102   {
0103     _pedstal_ADC = pedstalAdc;
0104   }
0105 
0106   void set_variable_pedestal(const bool value)
0107   {
0108     _pedestal_file = value;
0109   }
0110 
0111   const std::string &get_raw_tower_node_prefix() const
0112   {
0113     return _raw_tower_node_prefix;
0114   }
0115 
0116   void set_raw_tower_node_prefix(const std::string &rawTowerNodePrefix)
0117   {
0118     _raw_tower_node_prefix = rawTowerNodePrefix;
0119   }
0120 
0121   void set_zero_suppression_GeV(double)
0122   {
0123     std::cout << "RawTowerCalibration::set_zero_suppression_GeV is deprecated!" << std::endl
0124               << "  See discussion at https://github.com/sPHENIX-Collaboration/coresoftware/pull/867" << std::endl
0125               << std::endl;
0126   }
0127 
0128   //! Get the parameters for update. Useful fields are listed in SetDefaultParameters();
0129   PHParameters &GetCalibrationParameters()
0130   {
0131     return _tower_calib_params;
0132   }
0133 
0134   void set_CalibrationFileName(const char *inCalFname)
0135   {
0136     m_CalibrationFileName = inCalFname;
0137   }
0138   void set_UseConditionsDB(const bool setUseCondDB)
0139   {
0140     m_UseConditionsDB = setUseCondDB;
0141   }
0142 
0143   void set_towerinfo(RawTowerCalibration::ProcessTowerType UseTowerInfo)
0144   {
0145     m_UseTowerInfo = UseTowerInfo;
0146   }
0147 
0148   void set_usetowerinfo_v2(bool usetowerinfov2)
0149   {
0150     m_UseTowerInfoV2 = usetowerinfov2;
0151   }
0152 
0153  protected:
0154   void CreateNodes(PHCompositeNode *topNode);
0155 
0156   RawTowerContainer *_calib_towers{nullptr};
0157   RawTowerContainer *_raw_towers{nullptr};
0158 
0159   TowerInfoContainer *_calib_towerinfos{nullptr};
0160   TowerInfoContainer *_raw_towerinfos{nullptr};
0161 
0162   RawTowerGeomContainer *rawtowergeom{nullptr};
0163 
0164   enu_calib_algorithm _calib_algorithm;
0165 
0166   std::string m_Detector;
0167   std::string RawTowerNodeName;
0168   std::string RawTowerInfoNodeName;
0169   std::string CaliTowerNodeName;
0170   std::string CaliTowerInfoNodeName;
0171   std::string TowerGeomNodeName;
0172 
0173   std::string _calib_tower_node_prefix;
0174   std::string _raw_tower_node_prefix;
0175 
0176   //! pedstal in unit of ADC
0177   double _pedstal_ADC{std::numeric_limits<double>::quiet_NaN()};
0178 
0179   //! pedestal from file
0180   bool _pedestal_file{false};
0181 
0182   //! calibration constant in unit of GeV per ADC
0183   double _calib_const_GeV_ADC{std::numeric_limits<double>::quiet_NaN()};
0184 
0185   //! GeV per ADC from file
0186   bool _GeV_ADC_file{false};
0187 
0188   //! tower type to act on
0189   int _tower_type{-1};
0190 
0191   //! Tower by tower calibration parameters
0192   PHParameters _tower_calib_params;
0193 
0194   std::string m_CalibrationFileName;
0195   bool m_UseConditionsDB{false};
0196   bool m_UseTowerInfoV2{false};
0197 
0198   CDBTTree *m_CDBTTree{nullptr};
0199   RawTowerCalibration::ProcessTowerType m_UseTowerInfo{RawTowerCalibration::ProcessTowerType::kBothTowers};  // 0 just produce RawTowers, 1 just produce TowerInfo objects, and 2 produce both
0200 };
0201 
0202 #endif