File indexing completed on 2026-04-04 08:16:14
0001 #ifndef TPC_TPCMON_H
0002 #define TPC_TPCMON_H
0003
0004 #include <onlmon/OnlMon.h>
0005
0006 #include <tpc/TpcMap.h> //this needs to be pointed to coresoftware - not sure how to do that on EBDCXX...
0007
0008 #include <cmath>
0009 #include <map>
0010 #include <memory>
0011 #include <string>
0012 #include <vector>
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() = default;
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 weird_counter = 0;
0034
0035 static const int N_rBins = 4;
0036 const int N_thBins = 12;
0037 const double rBin_edges[N_rBins + 1] = {0.0, 0.256, 0.504, 0.752, 1.00};
0038
0039 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};
0040
0041
0042 static const int N_rBins_XY = 66;
0043 const double r_bins[N_rBins_XY + 1] = {217.83,
0044 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,
0045 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,
0046 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,
0047 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};
0048
0049 static const int N_phi_binx_XY_R1 = 1152;
0050 static const int N_phi_binx_XY_R2 = 1536;
0051 static const int N_phi_binx_XY_R3 = 2304;
0052
0053 static const int N_z_bins = 3350;
0054
0055 TH2 *NorthSideADC_clusterXY_R1 = nullptr;
0056 TH2 *NorthSideADC_clusterXY_R2 = nullptr;
0057 TH2 *NorthSideADC_clusterXY_R3 = nullptr;
0058
0059 TH2 *SouthSideADC_clusterXY_R1 = nullptr;
0060 TH2 *SouthSideADC_clusterXY_R2 = nullptr;
0061 TH2 *SouthSideADC_clusterXY_R3 = nullptr;
0062
0063 TH2 *NorthSideADC_clusterXY_R1_LASER = nullptr;
0064 TH2 *NorthSideADC_clusterXY_R2_LASER = nullptr;
0065 TH2 *NorthSideADC_clusterXY_R3_LASER = nullptr;
0066
0067 TH2 *SouthSideADC_clusterXY_R1_LASER = nullptr;
0068 TH2 *SouthSideADC_clusterXY_R2_LASER = nullptr;
0069 TH2 *SouthSideADC_clusterXY_R3_LASER = nullptr;
0070
0071 TH2 *NorthSideADC_clusterXY_R1_u5 = nullptr;
0072 TH2 *NorthSideADC_clusterXY_R2_u5 = nullptr;
0073 TH2 *NorthSideADC_clusterXY_R3_u5 = nullptr;
0074
0075 TH2 *SouthSideADC_clusterXY_R1_u5 = nullptr;
0076 TH2 *SouthSideADC_clusterXY_R2_u5 = nullptr;
0077 TH2 *SouthSideADC_clusterXY_R3_u5 = nullptr;
0078
0079 TH2 *NorthSideADC_clusterXY_R1_unw = nullptr;
0080 TH2 *NorthSideADC_clusterXY_R2_unw = nullptr;
0081 TH2 *NorthSideADC_clusterXY_R3_unw = nullptr;
0082
0083 TH2 *SouthSideADC_clusterXY_R1_unw = nullptr;
0084 TH2 *SouthSideADC_clusterXY_R2_unw = nullptr;
0085 TH2 *SouthSideADC_clusterXY_R3_unw = nullptr;
0086
0087 TH2 *NorthSideADC_clusterZY = nullptr;
0088 TH2 *SouthSideADC_clusterZY = nullptr;
0089
0090 TH2 *NorthSideADC_clusterZY_unw = nullptr;
0091 TH2 *SouthSideADC_clusterZY_unw = nullptr;
0092
0093 TH2 *NorthSideADC = nullptr;
0094 TH2 *SouthSideADC = nullptr;
0095
0096 TH2 *ADC_vs_SAMPLE = nullptr;
0097 TH2 *PEDEST_SUB_ADC_vs_SAMPLE = nullptr;
0098 TH2 *ADC_vs_SAMPLE_large = nullptr;
0099 TH2 *PEDEST_SUB_ADC_vs_SAMPLE_R1 = nullptr;
0100 TH2 *PEDEST_SUB_ADC_vs_SAMPLE_R2 = nullptr;
0101 TH2 *PEDEST_SUB_ADC_vs_SAMPLE_R3 = nullptr;
0102
0103 TH1 *sample_size_hist = nullptr;
0104 TH1 *Check_Sum_Error = nullptr;
0105 TH1 *Parity_Error = nullptr;
0106 TH1 *Check_Sums = nullptr;
0107 TH1 *Stuck_Channels = nullptr;
0108 TH1 *Channels_in_Packet = nullptr;
0109 TH1 *Channels_Always = nullptr;
0110 TH1 *LVL_1_TAGGER_per_EBDC = nullptr;
0111
0112 TH2 *Num_non_ZS_channels_vs_SAMPA = nullptr;
0113 TH2 *ZS_Trigger_ADC_vs_Sample = nullptr;
0114 TH2 *First_ADC_vs_First_Time_Bin = nullptr;
0115
0116 TH2 *MAXADC = nullptr;
0117
0118 TH1 *RAWADC_1D_R1 = nullptr;
0119 TH1 *MAXADC_1D_R1 = nullptr;
0120 TH1 *PEDEST_SUB_1D_R1 = nullptr;
0121 TH1 *COUNTS_vs_SAMPLE_1D_R1 = nullptr;
0122
0123 TH1 *RAWADC_1D_R2 = nullptr;
0124 TH1 *MAXADC_1D_R2 = nullptr;
0125 TH1 *PEDEST_SUB_1D_R2 = nullptr;
0126 TH1 *COUNTS_vs_SAMPLE_1D_R2 = nullptr;
0127
0128 TH1 *RAWADC_1D_R3 = nullptr;
0129 TH1 *MAXADC_1D_R3 = nullptr;
0130 TH1 *PEDEST_SUB_1D_R3 = nullptr;
0131 TH1 *COUNTS_vs_SAMPLE_1D_R3 = nullptr;
0132
0133 TH2 *Layer_ChannelPhi_ADC_weighted = nullptr;
0134 TH1 *NEvents_vs_EBDC = nullptr;
0135
0136 TH1 *NStreaks_vs_EventNo = nullptr;
0137
0138 TH1 *Packet_Type_Fraction_HB = nullptr;
0139 TH1 *Packet_Type_Fraction_NORM = nullptr;
0140 TH1 *Packet_Type_Fraction_ELSE = nullptr;
0141 TH2 *Packet_Type_vs_sample_ADC = nullptr;
0142
0143 TH1 *Noise_Channel_Plots = nullptr;
0144 TH2 *DC_vs_SAMPA = nullptr;
0145 TH2 *DC_SAMPA_vs_TIME = nullptr;
0146
0147 TpcMap M;
0148
0149 int starting_BCO;
0150 int starting_BCO_DC;
0151 int rollover_value;
0152 int rollover_value_DC;
0153 int current_BCOBIN;
0154
0155 int serverid;
0156
0157 int stuck_channel_count[256][26] = {{0}};
0158
0159 void Locate(int id, float *rbin, float *thbin);
0160 int ebdc_from_serverid(int server_id);
0161 int Index_from_Module(int sec_id, int fee_id);
0162 int Module_ID(int fee_id);
0163 int Max_Nine(int one, int two, int three, int four, int five, int six, int seven, int eight, int nine);
0164 bool side(int server_id);
0165 std::pair<float, float> calculateMedianAndStdDev(const std::vector<int> &values);
0166 float calculateRawStdDev(const std::vector<int> &values);
0167 };
0168
0169 #endif