File indexing completed on 2025-12-17 09:22:13
0001 #ifndef G4TPC_PHG4TPCPADPLANEREADOUT_H
0002 #define G4TPC_PHG4TPCPADPLANEREADOUT_H
0003
0004 #include "PHG4TpcPadPlane.h"
0005 #include "TpcClusterBuilder.h"
0006
0007 #include <g4main/PHG4HitContainer.h>
0008
0009 #include <gsl/gsl_rng.h>
0010
0011 #include <array>
0012 #include <climits>
0013 #include <cmath>
0014 #include <string> // for string
0015 #include <vector>
0016 #include <map>
0017
0018 typedef std::map<TrkrDefs::hitsetkey, std::vector<TrkrDefs::hitkey>> hitMaskTpc;
0019
0020 class PHCompositeNode;
0021 class PHG4TpcGeomContainer;
0022 class PHG4TpcGeom;
0023 class TH2;
0024 class TF1;
0025 class TNtuple;
0026 class TrkrHitSetContainer;
0027 class TrkrHitTruthAssoc;
0028
0029 class PHG4TpcPadPlaneReadout : public PHG4TpcPadPlane
0030 {
0031 public:
0032 PHG4TpcPadPlaneReadout(const std::string &name = "PHG4TpcPadPlaneReadout");
0033
0034 ~PHG4TpcPadPlaneReadout() override;
0035
0036 int InitRun(PHCompositeNode *topNode) override;
0037
0038 void UseGain(const int flagToUseGain);
0039 void SetUseModuleGainWeights(const int flag) { m_use_module_gain_weights = flag; }
0040 void SetModuleGainWeightsFileName(const std::string &name) { m_tpc_module_gain_weights_file = name; }
0041 void ReadGain();
0042 void SetUsePolyaGEMGain(const int flagPolya) { m_usePolya = flagPolya; }
0043 void SetUseLangauGEMGain(const int flagLangau) { m_useLangau = flagLangau; }
0044 void SetLangauParsFileName(const std::string &name) { m_tpc_langau_pars_file = name; }
0045
0046
0047 using PHG4TpcPadPlane::MapToPadPlane;
0048
0049 void MapToPadPlane(TpcClusterBuilder &tpc_truth_clusterer, TrkrHitSetContainer *single_hitsetcontainer, TrkrHitSetContainer *hitsetcontainer, TrkrHitTruthAssoc * , const double x_gem, const double y_gem, const double t_gem, const unsigned int side, PHG4HitContainer::ConstIterator hiter, TNtuple * , TNtuple * ) override;
0050
0051 void SetDefaultParameters() override;
0052 void UpdateInternalParameters() override;
0053
0054 void SetMaskChannelsFromFile()
0055 {
0056 m_maskFromFile = true;
0057 }
0058 void SetDeadChannelMapName(const std::string& dcmap)
0059 {
0060 m_maskDeadChannels = true;
0061 m_deadChannelMapName = dcmap;
0062 }
0063 void SetHotChannelMapName(const std::string& hmap)
0064 {
0065 m_maskHotChannels = true;
0066 m_hotChannelMapName = hmap;
0067 }
0068
0069 private:
0070
0071 void populate_zigzag_phibins(const unsigned int side, const unsigned int layernum, const double phi, const double cloud_sig_rp, std::vector<int> &phibin_pad, std::vector<double> &phibin_pad_share);
0072
0073 void sampaTimeDistribution(double tzero, std::vector<int> &adc_tbin, std::vector<double> &adc_tbin_share);
0074 double sampaShapingResponseFunction(double tzero, double t) const;
0075
0076 double check_phi(const unsigned int side, const double phi, const double radius);
0077
0078 void makeChannelMask(hitMaskTpc& aMask, const std::string& dbName, const std::string& totalChannelsToMask);
0079
0080 PHG4TpcGeomContainer *GeomContainer = nullptr;
0081 PHG4TpcGeom *LayerGeom = nullptr;
0082
0083 double neffelectrons_threshold {std::numeric_limits<double>::quiet_NaN()};
0084
0085 std::array<double, 3> MinRadius{};
0086 std::array<double, 3> MaxRadius{};
0087
0088 static constexpr int NSides {2};
0089 static constexpr int NSectors {12};
0090 static const int NRSectors {3};
0091
0092 double sigmaT {std::numeric_limits<double>::quiet_NaN()};
0093 std::array<double, 2> sigmaL{};
0094 double phi_bin_width{};
0095
0096 int NTBins {std::numeric_limits<int>::max()};
0097 int m_NHits {0};
0098
0099 int m_flagToUseGain {0};
0100
0101
0102
0103 bool m_use_module_gain_weights {false};
0104 std::string m_tpc_module_gain_weights_file;
0105
0106
0107 static constexpr double _nsigmas {5};
0108
0109 double Ts {55.0};
0110
0111 double averageGEMGain {std::numeric_limits<double>::quiet_NaN()};
0112 double polyaTheta {std::numeric_limits<double>::quiet_NaN()};
0113
0114 std::array<std::vector<double>, NSides> sector_min_Phi;
0115 std::array<std::vector<double>, NSides> sector_max_Phi;
0116
0117
0118 double getSingleEGEMAmplification();
0119 double getSingleEGEMAmplification(double weight);
0120 static double getSingleEGEMAmplification(TF1 *f);
0121 bool m_usePolya {false};
0122
0123 bool m_useLangau {false};
0124 std::string m_tpc_langau_pars_file;
0125
0126 gsl_rng *RandomGenerator {nullptr};
0127
0128 std::array<TH2 *, 2> h_gain{nullptr};
0129
0130 double m_module_gain_weight[2][3][12] {
0131 {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
0132 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
0133 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}},
0134 {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
0135 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
0136 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}};
0137
0138 TF1 *flangau[2][3][12] {{{nullptr}}};
0139
0140 hitMaskTpc m_deadChannelMap;
0141 hitMaskTpc m_hotChannelMap;
0142
0143 bool m_maskDeadChannels {false};
0144 bool m_maskHotChannels {false};
0145 bool m_maskFromFile {false};
0146 std::string m_deadChannelMapName;
0147 std::string m_hotChannelMapName;
0148 };
0149
0150 #endif