File indexing completed on 2025-08-05 08:15:37
0001
0002
0003 #ifndef FILLSPACECHARGEMAPS_FILLSPACECHARGEMAPS_H
0004 #define FILLSPACECHARGEMAPS_FILLSPACECHARGEMAPS_H
0005
0006 #include <fun4all/SubsysReco.h>
0007
0008 #include <cmath> // for sin, asin, cos, floor, M_PI
0009 #include <map>
0010 #include <set>
0011 #include <string>
0012 #include <vector>
0013
0014
0015 class Fun4AllHistoManager;
0016 class PHCompositeNode;
0017 class TFile;
0018 class TH1;
0019 class TH2;
0020 class TH3;
0021 class TTree;
0022
0023 class fillSpaceChargeMaps : public SubsysReco
0024 {
0025 public:
0026 fillSpaceChargeMaps(const std::string &name = "fillSpaceChargeMaps", const std::string &filename = "Hist.root");
0027
0028 virtual ~fillSpaceChargeMaps();
0029
0030
0031
0032
0033
0034
0035 int Init(PHCompositeNode * ) override;
0036
0037
0038
0039
0040
0041
0042 int InitRun(PHCompositeNode * ) override;
0043
0044
0045
0046
0047 int process_event(PHCompositeNode *topNode) override;
0048
0049
0050 int End(PHCompositeNode * ) override;
0051
0052 void SetFrequency(int freq);
0053 void SetBeamXing(const std::vector<int> &beamXs);
0054 void SetEvtStart(int newEvtStart);
0055 void SetUseIBFMap(bool useIBFMap = true);
0056 void SetGain(float ampGain = 2e3);
0057 void SetIBF(float ampIBFfrac = 0.004);
0058 void SetCollSyst(int coll_syst = 0);
0059 void SetAvg(int fAvg = 0);
0060 void UseSliming(int fSliming = 0);
0061 void UseFieldMaps(int shiftElectrons = 0);
0062
0063 private:
0064 std::vector<double> getNewWeights(TH3 *_h_SC_ibf, TH2 *_h_modules_anode, TH2 *_h_modules_measuredibf, double _hit_r, double _hit_phi, double dr_bin, double dphi_bin, bool _fUseIBFMap);
0065 bool IsOverFrame(double r, double phi);
0066 std::vector<double> putOnPlane(double r, double phi);
0067
0068 Fun4AllHistoManager *hm = nullptr;
0069 std::string _filename;
0070 std::set<std::string> _node_postfix;
0071 std::map<int, int> _timestamps;
0072 std::vector<int> _keys;
0073 TFile *outfile = nullptr;
0074 float _ampGain = 2e3;
0075 float _ampIBFfrac = 0.02;
0076 int _collSyst = 0;
0077 int _shiftElectrons = 0;
0078
0079 double _freqKhz = 22;
0080
0081 std::vector<int> _beamxing;
0082
0083
0084 int _evtstart = 0;
0085 int _fAvg = 0;
0086 int _fSliming = 0;
0087 TTree *_rawHits = nullptr;
0088 int _isOnPlane = 0;
0089 float _hit_z = 0;
0090 float _hit_r = 0;
0091 float _hit_phi = 0;
0092 float _hit_eion = 0;
0093 float _ibf_vol = 0;
0094 float _amp_ele_vol = 0;
0095 float _event_timestamp = 0;
0096 float _event_bunchXing = 0;
0097
0098 bool _fUseIBFMap = false;
0099 TH2 *_h_modules_anode = nullptr;
0100 TH2 *_h_modules_measuredibf = nullptr;
0101 TH1 *_h_hits = nullptr;
0102 TH1 *_h_R = nullptr;
0103 TH2 *_h_DC_E = nullptr;
0104 TH2 *_h_SC_XY = nullptr;
0105 static const int nFrames = 30;
0106 TH3 *_h_SC_prim[nFrames] = {nullptr};
0107 TH3 *_h_SC_ibf[nFrames] = {nullptr};
0108
0109
0110
0111
0112 float f = 0.5;
0113 float ns = 1e-9, s = 1.0;
0114 float mm = 1.0, cm = 10.0, m = 1000.0;
0115 float kHz = 1e3, MHz = 1e6;
0116 float V = 1.0;
0117
0118
0119
0120
0121 float ionMobility = 1.65 * cm * cm / V / s;
0122 float vIon = ionMobility * 400 * V / cm;
0123
0124 float mbRate = _freqKhz * kHz;
0125 float xingRate = 9.383 * MHz;
0126
0127
0128
0129
0130
0131 double Ne_dEdx = 1.56 / cm;
0132 double CF4_dEdx = 7.00 / cm;
0133 double Ne_NTotal = 43 / cm;
0134 double CF4_NTotal = 100 / cm;
0135
0136
0137 double Tpc_NTot = 0.50 * Ne_NTotal + 0.50 * CF4_NTotal;
0138 double Tpc_dEdx = 0.50 * Ne_dEdx + 0.50 * CF4_dEdx;
0139
0140
0141 double Tpc_ElectronsPerGeV = Tpc_NTot / Tpc_dEdx * 1e6;
0142 double phi_dead_bins[24] = {6.5314 - 2 * M_PI, 6.545 - 2 * M_PI,
0143 0.7718, 0.7854,
0144 1.2954, 1.309,
0145 1.819, 1.8326,
0146 2.3426, 2.3562,
0147 2.8662, 2.8798,
0148 3.3898, 3.4034,
0149 3.9134, 3.927,
0150 4.437, 4.4506,
0151 4.9606, 4.9742,
0152 5.4842, 5.4978,
0153 6.0078, 6.0214};
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164 float _mbRate = 0;
0165 float _xingRate = 0;
0166 float _mean = 0;
0167 };
0168
0169 #endif