File indexing completed on 2025-08-03 08:15:49
0001 #ifndef TRACKRECO_TPCGAINDEBUG_H
0002 #define TRACKRECO_TPCGAINDEBUG_H
0003
0004
0005
0006
0007
0008
0009
0010 #include <fun4all/SubsysReco.h>
0011 #include <trackbase/TrkrDefs.h>
0012
0013 #include <TMatrixFfwd.h>
0014 #include <TMatrixT.h>
0015 #include <TMatrixTUtils.h>
0016 #include <string>
0017 #include <map>
0018 #include <set>
0019
0020 class PHCompositeNode;
0021 class PHTimer;
0022 class TrkrCluster;
0023 class TFile;
0024 class TH1F;
0025 class TH1I;
0026 class TNtuple;
0027 class TTree;
0028 class SvtxTrack;
0029 class SvtxTrackMap;
0030 class SvtxVertexMap;
0031
0032 class TPCGainDebug : public SubsysReco
0033 {
0034 public:
0035 TPCGainDebug(const std::string &name = "TPCGAINDEBUG",
0036 const std::string &filename = "tpc_gain_debug.root",
0037 const int runnumber = 25926
0038 );
0039 ~TPCGainDebug() override;
0040
0041 int Init(PHCompositeNode *topNode) override;
0042 int InitRun(PHCompositeNode *topNode) override;
0043 int process_event(PHCompositeNode *topNode) override;
0044 int End(PHCompositeNode *topNode) override;
0045 int ResetEvent(PHCompositeNode *) override;
0046
0047 void save_ntuple(bool b) { _save_ntuple = b; }
0048 void save_debugHist(bool b) { _save_debugHist= b; }
0049 void save_sharkFin(bool b) { _save_sharkFin= b; }
0050 void do_gain(bool b) { _do_gain= b; }
0051 void debugNtuple_adcThreshold(float b) { AllHitADCThreshold = b; }
0052 void do_pedSigmaCut(float b) { _do_pedSigmaCut = b; }
0053 void set_adcSigmaThreshold(unsigned short b) { adcSigmaThreshold = b; }
0054 void skipNevent(int b) { startevt = b; }
0055 void event_range(int a, int b) { startevt = a; endevt = b; }
0056 void set_eventOffset(int a) { _eventOffset = a;}
0057
0058
0059
0060 private:
0061 int _ievent;
0062 unsigned int _iseed;
0063 float m_fSeed;
0064 bool _save_ntuple;
0065 bool _do_gain;
0066 bool _save_debugHist;
0067 bool _do_pedSigmaCut;
0068 bool _save_sharkFin;
0069 bool _isSharkFin;
0070
0071
0072 std::string _filename;
0073 const int _runnumber;
0074 TFile *_tfile;
0075 PHTimer *_timer;
0076 float AllHitADCThreshold;
0077
0078 TTree *gaintree = nullptr;
0079 TTree *_ntp_hit= nullptr;
0080 TH1F *h1F_tbin;
0081 TH1F *h1F_tbin_prev;
0082 TH1F *h1F_tbin_next;
0083 TH1I *h1I_event_shark;
0084
0085 double AdcClockPeriod = 53.0;
0086 int startevt = 0;
0087 int endevt = 999999;
0088 int _eventOffset = 0;
0089
0090
0091
0092
0093 unsigned short adcThreshold = 50;
0094 unsigned short adcSigmaThreshold = 5;
0095 unsigned short adcSigmaThreshold_phisize = 4;
0096 unsigned short clusterPhibinArea = 4;
0097 unsigned short clusterTbinArea = 5;
0098 unsigned short seedPhibinDistance = 4;
0099 unsigned short seedTbinDistance = 4;
0100
0101 struct ihit{
0102 short adc = 0;
0103 unsigned short phibin = 0;
0104 unsigned short tbin = 0;
0105 };
0106
0107 struct igain{
0108 short adc = 0;
0109 unsigned short phibin = 0;
0110 unsigned short tbin = 0;
0111 float pathlength = 0;
0112 int phisize= 0;
0113 };
0114
0115 struct ADCInfo{
0116 float maxADC = 0;
0117 float tbin = 0;
0118 bool isSignal = 0;
0119
0120 };
0121
0122 const int maxside = 2;
0123 const int maxsector = 12;
0124 const int maxlayer = 60;
0125
0126 const int sampleMax = 360;
0127 const int binWidthForPedEst = 4;
0128
0129 std::vector<std::vector<ihit>> hpl_seed;
0130
0131
0132
0133
0134 void clearHitsPerLayer(){
0135 for(int i=0; i<maxlayer; i++){
0136 hpl_seed[i].clear();
0137
0138 }
0139 }
0140
0141 void resizeHitsPerLayer(){
0142 hpl_seed.resize(maxlayer);
0143
0144 }
0145
0146
0147
0148 int m_run;
0149 int m_event;
0150 std::vector<int> m_side;
0151 std::vector<int> m_sector;
0152 std::vector<int> m_layer;
0153 std::vector<int> m_phibin;
0154 std::vector<int> m_tbin;
0155 std::vector<float> m_adcsum;
0156 std::vector<float> m_pathlength;
0157 std::vector<int> m_phisize;
0158
0159
0160
0161
0162 int a_side;
0163 int a_sector;
0164 int a_layer;
0165 int a_phibin;
0166 float a_phi;
0167 float a_pedmean;
0168 float a_pedwidth;
0169 bool a_isSharkFin;
0170 std::vector<int> a_tbin;
0171 std::vector<float> a_adc;
0172 std::vector<float> a_x;
0173 std::vector<float> a_y;
0174 std::vector<float> a_z;
0175
0176
0177
0178
0179
0180 int sf_side = 0;
0181 int sf_layer = 0;
0182 int sf_phibin = 0;
0183
0184
0185 void fillOutputNtuplesAllhits(PHCompositeNode *topNode);
0186 void CalculateGain(PHCompositeNode *topNode);
0187
0188 double SignalShape_PowerLawExp(double *x, double *par);
0189 double SignalShape_PowerLawDoubleExp(double *x, double *par);
0190
0191 };
0192
0193 #endif