File indexing completed on 2025-08-03 08:21:03
0001 #ifndef MVTX_MVTXMON_H
0002 #define MVTX_MVTXMON_H
0003
0004 #include <onlmon/OnlMon.h>
0005
0006 #include <TPaveText.h>
0007 #include <TString.h>
0008
0009 #include <cmath>
0010 #include <map>
0011
0012 class Event;
0013 class TH1;
0014 class TH2;
0015 class TH1I;
0016 class TH2I;
0017 class TH3I;
0018 class TH1D;
0019 class TH2D;
0020 class TH2Poly;
0021 class map;
0022 class pair;
0023
0024 class MvtxRawHit;
0025 class Packet;
0026
0027 class MvtxMon : public OnlMon
0028 {
0029 public:
0030 MvtxMon(const std::string& name);
0031 virtual ~MvtxMon();
0032
0033 int process_event(Event* evt);
0034 int Init();
0035 int BeginRun(const int runno);
0036 int Reset();
0037
0038 protected:
0039 int evtcnt = 0;
0040 int idummy = 0;
0041
0042 static constexpr int NSTAVE = 48;
0043 static constexpr int NCHIP = 9;
0044 static constexpr int NLAYERS = 3;
0045 static constexpr int NFees = 48 * 3;
0046 static constexpr int NTrigger = 13;
0047 static constexpr int NLanesMax = 9;
0048 static constexpr int NCols = 1024;
0049 static constexpr int NRows = 512;
0050 int mHitPerChip[NLAYERS][NSTAVE][NCHIP] = {};
0051 static constexpr int NFlags = 3;
0052
0053 int mMaxGeneralAxisRange = -3;
0054 int mMinGeneralAxisRange = -12;
0055
0056 std::string mLaneStatusFlag[NFlags+1] = {"WARNING", "ERROR", "FAULT", "PROBLEM"};
0057
0058 const int StaveBoundary[4] = {0, 12, 28, 48};
0059 const int LayerBoundaryFEE[NLAYERS - 1] = {35, 83};
0060
0061 TH2* mvtxmon_ChipStaveOcc = nullptr;
0062 TH1* mvtxmon_ChipStave1D = nullptr;
0063 TH1* mvtxmon_ChipFiredHis = nullptr;
0064 TH1* mvtxmon_EvtHitChip = nullptr;
0065 TH1* mvtxmon_EvtHitDis = nullptr;
0066 TH2* mvtxmon_HitMap[NSTAVE][NCHIP] = {{nullptr}};
0067 TH2Poly* mvtxmon_GeneralOccupancy = nullptr;
0068
0069 TH2Poly* mvtxmon_LaneStatusOverview[NFlags+1] = {nullptr};
0070
0071 TH1I* mRCDAQevt = nullptr;
0072
0073 TH1I* hChipStrobes = nullptr;
0074 TH1I* hChipL1 = nullptr;
0075 TH1I* hFeeStrobes = nullptr;
0076 TH1I* hFeeL1 = nullptr;
0077 TH1I* hFeeRDHErrors = nullptr;
0078
0079 TH2I* mTriggerVsFeeId = nullptr;
0080 TH1I* mTrigger = nullptr;
0081 TH2I* mLaneInfo = nullptr;
0082 TH2I* mLaneStatus[NFlags] = {nullptr};
0083 TH2I* mLaneStatusCumulative[NFlags] = {nullptr};
0084
0085
0086 TString mTriggerType[NTrigger] = {"ORBIT", "HB", "HBr", "HC", "PHYSICS", "PP", "CAL", "SOT", "EOT", "SOC", "EOC", "TF", "INT"};
0087
0088
0089 TH1I* hStrobesDMA = nullptr;
0090 TH1I* hDMAstatus = nullptr;
0091 TH1D* hErrorPlots = nullptr;
0092 TH2D* hErrorFile = nullptr;
0093 TH1D* hOccupancyPlot[NLAYERS] = {nullptr};
0094 TH2I* hEtaPhiHitmap[NLAYERS] = {nullptr};
0095 TH2D* hChipStaveOccupancy[NLAYERS] = {nullptr};
0096 TH3I* hChipHitmap = nullptr;
0097
0098 TH1D* hErrorPlotsTime = nullptr;
0099
0100
0101
0102 TH2I* mErrorVsFeeid = nullptr;
0103 TH2Poly* mGeneralOccupancy = nullptr;
0104 TH2Poly* mGeneralNoisyPixel = nullptr;
0105 TH2D* mDeadChipPos[NLAYERS] = {nullptr};
0106
0107
0108
0109 TH2D* mChipStaveOccupancy[NLAYERS] = {nullptr};
0110 TH1D* mOccupancyPlot[NLAYERS] = {nullptr};
0111 TH2D* hChipStaveNoisy[NLAYERS] = {nullptr};
0112
0113 float mOccupancyCutForNoisyPixel = 0.01;
0114 int mNoisyPixelNumber[3][20][9] = {{{0}}};
0115
0116 int mStatusFlagNumber[3][3][20][9] = {{{{0}}}};
0117
0118 static constexpr int NError = 29;
0119 static constexpr int NErrorExtended = 19;
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133 TString ErrorType[NError] = {"1: rawDataError-skip", "2: Wrong dataOffset value", "3: Previous event was already completed", "4: Bad GBT counter in the FLX packet", "5: Expected all active lanes for links", "6: TDT packet done before TDH", "7: DDW found but not stop bit", "8: Trigger header not found before chip data", "9: chip data is too short", "10: Invalid ALPIDE byte",
0134 "11: APE_STRIP_START", "12: APE_DET_TIMEOUT", "13: APE_OOT", "14: APE_PROTOCOL_ERROR", "15: APE_LANE_FIFO_OVERFLOW_ERROR", "16: APE_FSM_ERROR", "17: APE_PENDING_DETECTOR_EVENT_LIMIT", "18: APE_PENDING_LANE_EVENT_LIMIT", "19: APE_O2N_ERROR", "20: APE_RATE_MISSING_TRG_ERROR", "21: APE_PE_DATA_MISSING", "22: APE_OOT_DATA_MISSING", "23: Unknown APE code", "24: Error laneId != chipID",
0135 "25: No data short would fit", "26: data short before region header", "27: No data long would fit", "28: data long before region header", "29: Wrong bit before DATA LONG bit map"};
0136
0137 const int NFiles = 6;
0138 int ntriggers = 0;
0139
0140 const int NStaves[3] = {12, 16, 20};
0141 const float StartAngle[3] = {16.997 / 360 * (M_PI * 2.), 17.504 / 360 * (M_PI * 2.), 17.337 / 360 * (M_PI * 2.)};
0142 const float MidPointRad[3] = {23.49, 31.586, 39.341};
0143
0144 const int mapstave[3][20] = {{6, 5, 4, 3, 2, 1, 12, 11, 10, 9, 8, 7, 0, 0, 0, 0, 0, 0, 0, 0}, {20, 19, 18, 17, 16, 15, 14, 13, 28, 27, 26, 25, 24, 23, 22, 21, 0, 0, 0, 0}, {38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39}};
0145
0146 typedef struct linkId
0147 {
0148 uint32_t layer = 0xFF;
0149 uint32_t stave = 0xFF;
0150 uint32_t gbtid = 0xFF;
0151 } LinkId_t;
0152
0153 LinkId_t DecodeFeeid(const uint16_t& feeid)
0154 {
0155 LinkId_t ret = {};
0156 ret.layer = (feeid >> 12) & 0x7;
0157 ret.stave = feeid & 0x1F;
0158 ret.gbtid = (feeid >> 8) & 0x3;
0159 return ret;
0160 }
0161
0162 private:
0163 unsigned short decode_row(int hit) { return hit >> 16; }
0164 unsigned short decode_col(int hit) { return hit & 0xffff; }
0165 void getStavePoint(int layer, int stave, double* px, double* py);
0166 void drawLayerName(TH2* histo2D);
0167 void createPoly(TH2Poly* h);
0168
0169 Packet** plist = nullptr;
0170
0171
0172
0173
0174
0175
0176
0177 };
0178
0179 #endif