File indexing completed on 2025-08-05 08:20:31
0001 #ifndef TPC_TPCMON_H
0002 #define TPC_TPCMON_H
0003
0004 #include <onlmon/OnlMon.h>
0005
0006 #include <map>
0007 #include <tpc/TpcMap.h> //this needs to be pointed to coresoftware - not sure how to do that on EBDCXX...
0008 #include <memory>
0009 #include <string>
0010 #include <cmath>
0011 #include <vector>
0012
0013
0014 class Event;
0015 class TH1;
0016 class TH2;
0017 class TTree;
0018
0019 class TpcMon : public OnlMon
0020 {
0021 public:
0022 TpcMon(const std::string &name);
0023 virtual ~TpcMon();
0024
0025 int process_event(Event *evt);
0026 int Init();
0027 int BeginRun(const int runno);
0028 int Reset();
0029
0030 protected:
0031 int evtcnt = 0;
0032 int evtcnt5 = 0;
0033 int idummy = 0;
0034 int weird_counter = 0;
0035
0036 static const int N_rBins = 4;
0037 const int N_thBins = 12;
0038 const double rBin_edges[N_rBins+1] = {0.0, 0.256, 0.504, 0.752, 1.00};
0039
0040 const int FEE_transform[26] = {10, 11, 0, 2, 1, 25, 23, 24, 22, 21, 20, 6, 7, 3, 13, 12, 5, 4, 9, 8, 14, 16, 15, 17, 19, 18};
0041
0042
0043 static const int N_rBins_XY = 66;
0044 const double r_bins[N_rBins_XY + 1] = {217.83,
0045 223.83, 229.83, 235.83, 241.83, 247.83, 253.83, 259.83, 265.83, 271.83, 277.83, 283.83, 289.83, 295.83, 301.83, 306.83,
0046 311.05, 317.92, 323.31, 329.27, 334.63, 340.59, 345.95, 351.91, 357.27, 363.23, 368.59, 374.55, 379.91, 385.87, 391.23, 397.19, 402.49,
0047 411.53, 421.70, 431.90, 442.11, 452.32, 462.52, 472.73, 482.94, 493.14, 503.35, 513.56, 523.76, 533.97, 544.18, 554.39, 564.59, 574.76,
0048 583.67, 594.59, 605.57, 616.54, 627.51, 638.48, 649.45, 660.42, 671.39, 682.36, 693.33, 704.30, 715.27, 726.24, 737.21, 748.18, 759.11};
0049
0050 static const int N_phi_binx_XY_R1 = 1152;
0051 static const int N_phi_binx_XY_R2 = 1536;
0052 static const int N_phi_binx_XY_R3 = 2304;
0053
0054 static const int N_z_bins = 3350;
0055
0056 TH2 *NorthSideADC_clusterXY_R1 = nullptr;
0057 TH2 *NorthSideADC_clusterXY_R2 = nullptr;
0058 TH2 *NorthSideADC_clusterXY_R3 = nullptr;
0059
0060 TH2 *SouthSideADC_clusterXY_R1 = nullptr;
0061 TH2 *SouthSideADC_clusterXY_R2 = nullptr;
0062 TH2 *SouthSideADC_clusterXY_R3 = nullptr;
0063
0064 TH2 *NorthSideADC_clusterXY_R1_LASER = nullptr;
0065 TH2 *NorthSideADC_clusterXY_R2_LASER = nullptr;
0066 TH2 *NorthSideADC_clusterXY_R3_LASER = nullptr;
0067
0068 TH2 *SouthSideADC_clusterXY_R1_LASER = nullptr;
0069 TH2 *SouthSideADC_clusterXY_R2_LASER = nullptr;
0070 TH2 *SouthSideADC_clusterXY_R3_LASER = nullptr;
0071
0072 TH2 *NorthSideADC_clusterXY_R1_u5 = nullptr;
0073 TH2 *NorthSideADC_clusterXY_R2_u5 = nullptr;
0074 TH2 *NorthSideADC_clusterXY_R3_u5 = nullptr;
0075
0076 TH2 *SouthSideADC_clusterXY_R1_u5 = nullptr;
0077 TH2 *SouthSideADC_clusterXY_R2_u5 = nullptr;
0078 TH2 *SouthSideADC_clusterXY_R3_u5 = nullptr;
0079
0080 TH2 *NorthSideADC_clusterXY_R1_unw = nullptr;
0081 TH2 *NorthSideADC_clusterXY_R2_unw = nullptr;
0082 TH2 *NorthSideADC_clusterXY_R3_unw = nullptr;
0083
0084 TH2 *SouthSideADC_clusterXY_R1_unw = nullptr;
0085 TH2 *SouthSideADC_clusterXY_R2_unw = nullptr;
0086 TH2 *SouthSideADC_clusterXY_R3_unw = nullptr;
0087
0088 TH2 *NorthSideADC_clusterZY = nullptr;
0089 TH2 *SouthSideADC_clusterZY = nullptr;
0090
0091 TH2 *NorthSideADC_clusterZY_unw = nullptr;
0092 TH2 *SouthSideADC_clusterZY_unw = nullptr;
0093
0094 TH2 *NorthSideADC = nullptr;
0095 TH2 *SouthSideADC = nullptr;
0096
0097 TH2 *ADC_vs_SAMPLE = nullptr;
0098 TH2 *PEDEST_SUB_ADC_vs_SAMPLE = nullptr;
0099 TH2 *ADC_vs_SAMPLE_large = nullptr;
0100 TH2 *PEDEST_SUB_ADC_vs_SAMPLE_R1 = nullptr;
0101 TH2 *PEDEST_SUB_ADC_vs_SAMPLE_R2 = nullptr;
0102 TH2 *PEDEST_SUB_ADC_vs_SAMPLE_R3 = nullptr;
0103
0104 TH1 *sample_size_hist = nullptr;
0105 TH1 *Check_Sum_Error = nullptr;
0106 TH1 *Parity_Error = nullptr;
0107 TH1 *Check_Sums = nullptr;
0108 TH1 *Stuck_Channels = nullptr;
0109 TH1 *Channels_in_Packet = nullptr;
0110 TH1 *Channels_Always = nullptr;
0111 TH1 *LVL_1_TAGGER_per_EBDC = nullptr;
0112
0113 TH2 *Num_non_ZS_channels_vs_SAMPA = nullptr;
0114 TH2 *ZS_Trigger_ADC_vs_Sample = nullptr;
0115 TH2 *First_ADC_vs_First_Time_Bin = nullptr;
0116
0117 TH2 *MAXADC = nullptr;
0118
0119 TH1 *RAWADC_1D_R1= nullptr;
0120 TH1 *MAXADC_1D_R1 = nullptr;
0121 TH1 *PEDEST_SUB_1D_R1 = nullptr;
0122 TH1 *COUNTS_vs_SAMPLE_1D_R1 = nullptr;
0123
0124 TH1 *RAWADC_1D_R2= nullptr;
0125 TH1 *MAXADC_1D_R2 = nullptr;
0126 TH1 *PEDEST_SUB_1D_R2 = nullptr;
0127 TH1 *COUNTS_vs_SAMPLE_1D_R2 = nullptr;
0128
0129 TH1 *RAWADC_1D_R3= nullptr;
0130 TH1 *MAXADC_1D_R3 = nullptr;
0131 TH1 *PEDEST_SUB_1D_R3 = nullptr;
0132 TH1 *COUNTS_vs_SAMPLE_1D_R3 = nullptr;
0133
0134 TH2 *Layer_ChannelPhi_ADC_weighted = nullptr;
0135 TH1 *NEvents_vs_EBDC = nullptr;
0136
0137 TH1 *NStreaks_vs_EventNo = nullptr;
0138
0139 TH1 *Packet_Type_Fraction_HB = nullptr;
0140 TH1 *Packet_Type_Fraction_NORM = nullptr;
0141 TH1 *Packet_Type_Fraction_ELSE = nullptr;
0142 TH2 *Packet_Type_vs_sample_ADC = nullptr;
0143
0144 TH1 *Noise_Channel_Plots = nullptr;
0145 TH2 *DC_vs_SAMPA = nullptr;
0146 TH2 *DC_SAMPA_vs_TIME = nullptr;
0147
0148 TpcMap M;
0149
0150 int starting_BCO;
0151 int starting_BCO_DC;
0152 int rollover_value;
0153 int rollover_value_DC;
0154 int current_BCOBIN;
0155
0156 int serverid;
0157
0158 int stuck_channel_count [256][26] = {0};
0159
0160 void Locate(int id, float *rbin, float *thbin);
0161 int ebdc_from_serverid(int server_id);
0162 int Index_from_Module(int sec_id, int fee_id);
0163 int Module_ID(int fee_id);
0164 int Max_Nine(int one, int two, int three, int four, int five, int six, int seven, int eight, int nine);
0165 bool side(int server_id);
0166 std::pair<float, float> calculateMedianAndStdDev(const std::vector<int>& values);
0167 float calculateRawStdDev(const std::vector<int>& values);
0168 };
0169
0170 #endif