File indexing completed on 2025-08-05 08:20:27
0001
0002
0003
0004
0005
0006 #include "MvtxMon.h"
0007
0008
0009
0010
0011
0012
0013 #include <onlmon/OnlMon.h> // for OnlMon
0014 #include <onlmon/OnlMonDB.h>
0015 #include <onlmon/OnlMonServer.h>
0016
0017 #include <Event/msg_profile.h>
0018
0019 #include <TH1.h>
0020 #include <TH2.h>
0021 #include <TH2Poly.h>
0022 #include <TH3.h>
0023 #include <TLatex.h>
0024 #include <TLine.h>
0025 #include <TList.h>
0026 #include <TString.h>
0027
0028 #include <Event/Event.h>
0029 #include <Event/packet.h>
0030
0031 #include <cmath>
0032 #include <cstdio> // for printf
0033 #include <fstream>
0034 #include <iostream>
0035 #include <numeric>
0036 #include <sstream>
0037 #include <string> // for allocator, string, char_traits
0038 #include <utility>
0039
0040 enum
0041 {
0042 TRGMESSAGE = 1,
0043 FILLMESSAGE = 2
0044 };
0045
0046 MvtxMon::MvtxMon(const std::string& name)
0047 : OnlMon(name)
0048 {
0049
0050
0051 return;
0052 }
0053
0054 MvtxMon::~MvtxMon()
0055 {
0056
0057 delete [] plist;
0058 return;
0059 }
0060
0061 int MvtxMon::Init()
0062 {
0063 plist = new Packet*[2];
0064
0065 const char* mvtxcalib = getenv("MVTXCALIB");
0066 if (!mvtxcalib)
0067 {
0068 std::cout << "MVTXCALIB environment variable not set" << std::endl;
0069 exit(1);
0070 }
0071 std::string fullfile = std::string(mvtxcalib) + "/" + "MvtxMonData.dat";
0072 std::ifstream calib(fullfile);
0073 calib.close();
0074
0075
0076 printf("doing the Init\n");
0077 OnlMonServer* se = OnlMonServer::instance();
0078
0079
0080 mvtxmon_ChipStaveOcc = new TH2D("OCC_ChipStaveOcc", "Average Occupancy: Stave Number and Chip Number", NCHIP, -0.5, NCHIP - 0.5, NSTAVE, -0.5, NSTAVE - 0.5);
0081 mvtxmon_ChipStave1D = new TH1D("OCC_ChipStave1D", "Average Occupancy per Chip", NCHIP * NSTAVE, -0.5, NCHIP * NSTAVE - 0.5);
0082 mvtxmon_ChipFiredHis = new TH1D("OCC_ChipFiredFLX", "Number of Chips Fired per Felix per RCDAQ event Distribution", NCHIP * NSTAVE / 6 +1 , -0.5, NCHIP * NSTAVE / 6 + 0.5);
0083 mvtxmon_EvtHitChip = new TH1D("OCC_HitChipPerStrobe", "Number of Hits Per Strobe Per Chip Distribution", 51, -0.5, 50.5);
0084 mvtxmon_EvtHitDis = new TH1D("OCC_HitFLXPerStrobe", "Number of Hits Per Strobe Distribution", 501, -0.5, 2000.5);
0085
0086 mvtxmon_ChipStaveOcc->SetStats(false);
0087 mvtxmon_ChipStave1D->SetStats(false);
0088 mvtxmon_ChipFiredHis->SetStats(false);
0089 mvtxmon_EvtHitChip->SetStats(false);
0090 mvtxmon_EvtHitDis->SetStats(false);
0091
0092 mvtxmon_ChipStave1D->GetXaxis()->SetTitle("Chip");
0093 mvtxmon_ChipStave1D->GetYaxis()->SetTitle("Occupancy");
0094
0095 mvtxmon_ChipFiredHis->GetXaxis()->SetTitle("Number of Chips");
0096 mvtxmon_ChipFiredHis->GetYaxis()->SetTitle("Counts");
0097
0098 mvtxmon_EvtHitChip->GetXaxis()->SetTitle("Number of Hits");
0099 mvtxmon_EvtHitChip->GetYaxis()->SetTitle("Counts");
0100
0101 mvtxmon_EvtHitDis->GetXaxis()->SetTitle("Number of Hits");
0102 mvtxmon_EvtHitDis->GetYaxis()->SetTitle("Counts");
0103
0104 se->registerHisto(this, mvtxmon_ChipStaveOcc);
0105 se->registerHisto(this, mvtxmon_ChipStave1D);
0106 se->registerHisto(this, mvtxmon_ChipFiredHis);
0107 se->registerHisto(this, mvtxmon_EvtHitChip);
0108 se->registerHisto(this, mvtxmon_EvtHitDis);
0109
0110 mRCDAQevt = new TH1I("RCDAQ_evt", "Number of RCDAQ events processed", 6, -0.5, 5.5);
0111 mRCDAQevt->GetXaxis()->SetTitle("FELIX server");
0112 mRCDAQevt->GetYaxis()->SetTitle("Counts");
0113 mRCDAQevt->SetStats(false);
0114 se->registerHisto(this, mRCDAQevt);
0115
0116
0117 hStrobesDMA = new TH1I("hStrobesDMA", "Minimum number of stobes processed per DMA", 12, -0.5, 11.5);
0118 hStrobesDMA->GetXaxis()->SetTitle("DMA");
0119 hStrobesDMA->GetYaxis()->SetTitle("Counts");
0120 hStrobesDMA->SetStats(false);
0121 se->registerHisto(this, hStrobesDMA);
0122
0123 hDMAstatus = new TH1I("hDMAstatus", "Is DMA receiving Strobes", 12, -0.5, 11.5);
0124 hDMAstatus->GetXaxis()->SetTitle("DMA");
0125 hDMAstatus->GetYaxis()->SetTitle("Alive");
0126 hDMAstatus->SetStats(false);
0127 se->registerHisto(this, hDMAstatus);
0128
0129 for (int i = 0; i < NFlags+1; i++)
0130 {
0131 mvtxmon_LaneStatusOverview[i] = new TH2Poly();
0132 mvtxmon_LaneStatusOverview[i]->SetName(Form("FEE_LaneStatus_Overview_Flag%s", mLaneStatusFlag[i].c_str()));
0133 TString title = Form("Fraction of lanes into %s", mLaneStatusFlag[i].c_str());
0134
0135 title += "; ; ";
0136 mvtxmon_LaneStatusOverview[i]->SetTitle(title);
0137 createPoly(mvtxmon_LaneStatusOverview[i]);
0138 se->registerHisto(this, mvtxmon_LaneStatusOverview[i]);
0139 }
0140
0141
0142
0143
0144
0145
0146
0147 for (int i = 0; i < NFlags; i++) {
0148 mLaneStatus[i] = new TH2I(Form("FEE_LaneStatus_Flag_%s", mLaneStatusFlag[i].c_str()), Form("Lane Status Flag: %s", mLaneStatusFlag[i].c_str()), 9, -0.5, 8.5, 48, -0.5, 47.5);
0149 mLaneStatus[i]->GetXaxis()->SetTitle("Chip");
0150 mLaneStatus[i]->GetYaxis()->SetTitle("Stave");
0151 mLaneStatus[i]->SetStats(false);
0152
0153
0154
0155
0156
0157 se->registerHisto(this, mLaneStatus[i]);
0158
0159 mLaneStatusCumulative[i] = new TH2I(Form("FEE_LaneStatusFromSOX_Flag_%s", mLaneStatusFlag[i].c_str()), Form("Lane Status Flags since SOX: %s", mLaneStatusFlag[i].c_str()), 9, -0.5, 8.5, 48, -0.5, 47.5);
0160 mLaneStatusCumulative[i]->GetXaxis()->SetTitle("Chip");
0161 mLaneStatusCumulative[i]->GetYaxis()->SetTitle("Stave");
0162 mLaneStatusCumulative[i]->SetStats(false);
0163
0164
0165
0166
0167
0168 se->registerHisto(this, mLaneStatusCumulative[i]);
0169 }
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197 hErrorPlots = new TH1D("General_DecErrors", "Decoding Errors", NError, 0.5, NError + 0.5);
0198 hErrorPlots->GetYaxis()->SetTitle("Counts");
0199 hErrorPlots->GetXaxis()->SetTitle("Error ID");
0200 hErrorPlots->SetMinimum(0);
0201 hErrorPlots->SetFillColor(kRed);
0202 hErrorPlots->SetStats(false);
0203
0204 se->registerHisto(this, hErrorPlots);
0205
0206 hErrorPlotsTime = new TH1D("General_DecErrorsTime", "Rolling History Of Decoding Errors", 50, 0.5, 50.5);
0207 hErrorPlotsTime->GetYaxis()->SetTitle("Number of Errors");
0208 hErrorPlotsTime->GetXaxis()->SetTitle("Time");
0209 hErrorPlotsTime->SetMinimum(0);
0210 hErrorPlotsTime->SetFillColor(kRed);
0211 hErrorPlotsTime->SetStats(false);
0212
0213 se->registerHisto(this, hErrorPlotsTime);
0214
0215
0216 hErrorFile = new TH2D("General_DecErrorsEndpoint", "Decoding Errors vs Packet ID", 6 * 2, 0, 6 * 2 + 1, NError, 0.5, NError + 0.5);
0217 hErrorFile->GetYaxis()->SetTitle("Error ID");
0218 hErrorFile->GetXaxis()->SetTitle("2*FLX+endpoint");
0219 hErrorFile->GetZaxis()->SetTitle("Counts");
0220 hErrorFile->SetMinimum(0);
0221 hErrorFile->SetStats(false);
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235 for (int i = 1; i < 6; i++)
0236 {
0237 auto l = new TLine(i * 2 + 0.2 + ((i - 3) * 0.12), 0.5, i * 2 + 0.2 + ((i - 3) * 0.12), hErrorFile->GetNbinsY() + 0.5);
0238 hErrorFile->GetListOfFunctions()->Add(l);
0239 }
0240
0241 se->registerHisto(this, hErrorFile);
0242
0243 for (int aLayer = 0; aLayer < 3; aLayer++)
0244 {
0245 hOccupancyPlot[aLayer] = new TH1D(Form("OCC_Occupancy1D_Layer%d", aLayer), Form("MVTX Layer %d, Occupancy Distribution", aLayer), 151, -5, 0.05);
0246 hOccupancyPlot[aLayer]->GetYaxis()->SetTitle("Counts");
0247 hOccupancyPlot[aLayer]->GetXaxis()->SetTitle("log10(Pixel Occupancy)");
0248 hOccupancyPlot[aLayer]->SetStats(false);
0249 se->registerHisto(this, hOccupancyPlot[aLayer]);
0250
0251
0252 hChipStaveOccupancy[aLayer] = new TH2D(Form("OCC_OccupancyChipStave_Layer_%d", aLayer), Form("MVTX Layer%d, Occupancy vs Chip and Stave", aLayer), 9, -.5, 9 - .5, NStaves[aLayer], -.5, NStaves[aLayer] - .5);
0253 hChipStaveOccupancy[aLayer]->GetYaxis()->SetTitle("Stave Number");
0254 hChipStaveOccupancy[aLayer]->GetXaxis()->SetTitle("Chip Number");
0255 hChipStaveOccupancy[aLayer]->GetZaxis()->SetTitle("Number of Hits");
0256 hChipStaveOccupancy[aLayer]->SetStats(false);
0257 se->registerHisto(this, hChipStaveOccupancy[aLayer]);
0258
0259 TString tmp = Form("MVTX Layer %d", aLayer);
0260 tmp += ", Number of noisy pixels (>20\% stobes in event) per RCDAQ event";
0261
0262
0263 hChipStaveNoisy[aLayer] = new TH2D(Form("FHR_NoisyChipStave_Layer%d", aLayer), tmp, 9, -.5, 9 - .5, NStaves[aLayer], -.5, NStaves[aLayer] - .5);
0264 hChipStaveNoisy[aLayer]->GetYaxis()->SetTitle("Stave Number");
0265 hChipStaveNoisy[aLayer]->GetXaxis()->SetTitle("Chip Number");
0266 hChipStaveNoisy[aLayer]->GetZaxis()->SetTitle("Number of Noisy Pixels");
0267 hChipStaveNoisy[aLayer]->SetStats(false);
0268 se->registerHisto(this, hChipStaveNoisy[aLayer]);
0269 }
0270
0271 hChipHitmap = new TH3I("MVTXMON_chipHitmap", "MVTXMON_chipHitmap", 1024, -.5, 1023.5, 512, -.5, 511.5, 8 * 9 * 6, -.5, 8 * 9 * 6 - 0.5);
0272
0273 hChipHitmap->GetXaxis()->SetTitle("Col");
0274 hChipHitmap->GetYaxis()->SetTitle("Row");
0275
0276
0277
0278 hChipStrobes = new TH1I("General_hChipStrobes", "Chip Strobes vs Chip*Stave", 8 * 9 * 6, -.5, 8 * 9 * 6 - 0.5);
0279 hChipStrobes->GetXaxis()->SetTitle("Chip");
0280 hChipStrobes->GetYaxis()->SetTitle("Counts");
0281 hChipStrobes->SetStats(false);
0282 se->registerHisto(this, hChipStrobes);
0283
0284 hChipL1 = new TH1I("General_ChipL1", "L1 triggers vs Chip*Stave", 8 * 9 * 6, -.5, 8 * 9 * 6 - 0.5);
0285 hChipL1->GetXaxis()->SetTitle("Chip");
0286 hChipL1->GetYaxis()->SetTitle("Counts");
0287 hChipL1->SetStats(false);
0288 se->registerHisto(this, hChipL1);
0289
0290 hFeeStrobes = new TH1I("General_hfeeStrobes", "Chip Strobes vs FeeId", NFees,0,NFees);
0291 hFeeStrobes->GetXaxis()->SetTitle("FEE ID");
0292 hFeeStrobes->GetYaxis()->SetTitle("Number of MVTX strobes");
0293 hFeeStrobes->SetStats(0);
0294 se->registerHisto(this, hFeeStrobes);
0295
0296 hFeeL1 = new TH1I("General_feeL1", "L1 triggers vs FeeId", NFees,0,NFees);
0297 hFeeL1->GetXaxis()->SetTitle("FEE ID");
0298 hFeeL1->GetYaxis()->SetTitle("L1 Triggers");
0299 hFeeL1->SetStats(0);
0300 se->registerHisto(this, hFeeL1);
0301
0302 hFeeRDHErrors = new TH1I("RDHErrors_hfeeRDHErrors", "RDH Errors vs FeeId", NFees,0,NFees);
0303 hFeeRDHErrors->GetXaxis()->SetTitle("FEE ID");
0304 hFeeRDHErrors->GetYaxis()->SetTitle("Number of MVTX RDH Errors");
0305 hFeeRDHErrors->SetStats(0);
0306 se->registerHisto(this, hFeeRDHErrors);
0307
0308
0309 mErrorVsFeeid = new TH2I("FHR_ErrorVsFeeid", "Decoder error vs FeeID", 3 * StaveBoundary[3], 0, 3 * StaveBoundary[3], NError, 0.5, NError + 0.5);;
0310 mErrorVsFeeid->GetXaxis()->SetTitle("FEE ID");
0311 mErrorVsFeeid->GetYaxis()->SetTitle("Error ID");
0312 mErrorVsFeeid->SetStats(false);
0313 se->registerHisto(this, mErrorVsFeeid);
0314
0315 mGeneralOccupancy = new TH2Poly();
0316 mGeneralOccupancy->SetTitle("General Occupancy; ; ");
0317 mGeneralOccupancy->SetName("MVTXMON_General_Occupancy");
0318
0319
0320 mGeneralOccupancy->SetStats(false);
0321
0322 mGeneralNoisyPixel = new TH2Poly();
0323 mGeneralNoisyPixel->SetTitle("Unmasked Noisy Pixel Number; ; ");
0324 mGeneralNoisyPixel->SetName("MVTXMON_General_Noisy_Pixel");
0325 mGeneralNoisyPixel->GetXaxis()->SetTitle("");
0326 mGeneralNoisyPixel->GetYaxis()->SetTitle("");
0327 mGeneralNoisyPixel->SetStats(false);
0328 mGeneralNoisyPixel->SetMinimum(-1);
0329 mGeneralNoisyPixel->SetMaximum(1200);
0330
0331 createPoly(mGeneralOccupancy);
0332 createPoly(mGeneralNoisyPixel);
0333 se->registerHisto(this, mGeneralOccupancy);
0334 se->registerHisto(this, mGeneralNoisyPixel);
0335
0336 for (int mLayer = 0; mLayer < 3; mLayer++)
0337 {
0338 mDeadChipPos[mLayer] = new TH2D(Form("MVTXMON_Occupancy_Layer%d_Layer%dDeadChipPos", mLayer, mLayer), Form("DeadChipPos on Layer %d", mLayer), 9, -0.5, 9 - 0.5, NStaves[mLayer], -0.5, NStaves[mLayer] - 0.5);
0339 mDeadChipPos[mLayer]->GetXaxis()->SetTitle("Chip Number");
0340 mDeadChipPos[mLayer]->GetYaxis()->SetTitle("Stave Number");
0341 mDeadChipPos[mLayer]->SetStats(false);
0342
0343
0344
0345
0346
0347 mDeadChipPos[mLayer]->SetStats(false);
0348
0349
0350 se->registerHisto(this, mDeadChipPos[mLayer]);
0351
0352 }
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364 Reset();
0365 return 0;
0366 }
0367
0368 int MvtxMon::BeginRun(const int )
0369 {
0370
0371
0372 return 0;
0373 }
0374
0375 int MvtxMon::process_event(Event* evt)
0376 {
0377 std::cout<<"event "<<evtcnt<<std::endl;
0378 evtcnt++;
0379 mRCDAQevt->Fill(this->MonitorServerId());
0380
0381 OnlMonServer* se = OnlMonServer::instance();
0382
0383
0384
0385 for (int iLayer = 0; iLayer < 3; iLayer++)
0386 {
0387 for (int iStave = 0; iStave < NStaves[iLayer]; iStave++)
0388 {
0389 for (int iChip = 0; iChip < 9; iChip++)
0390 {
0391 mHitPerChip[iLayer][iStave][iChip] = 0;
0392 mNoisyPixelNumber[iLayer][iStave][iChip] = 0;
0393 }
0394 }
0395 }
0396
0397
0398 mLaneStatus[0]->Reset("ICESM");
0399 mLaneStatus[1]->Reset("ICESM");
0400 mLaneStatus[2]->Reset("ICESM");
0401 mvtxmon_LaneStatusOverview[0]->Reset("ICESM");
0402 mvtxmon_LaneStatusOverview[1]->Reset("ICESM");
0403 mvtxmon_LaneStatusOverview[2]->Reset("ICESM");
0404 mvtxmon_LaneStatusOverview[3]->Reset("ICESM");
0405 hOccupancyPlot[0]->Reset("ICESM");
0406 hOccupancyPlot[1]->Reset("ICESM");
0407 hOccupancyPlot[2]->Reset("ICESM");
0408 hChipStaveNoisy[0]->Reset("ICESM");
0409 hChipStaveNoisy[1]->Reset("ICESM");
0410 hChipStaveNoisy[2]->Reset("ICESM");
0411
0412
0413
0414 hDMAstatus->SetBinContent((this->MonitorServerId() * 2) + 1, 0);
0415 hDMAstatus->SetBinContent((this->MonitorServerId() * 2) + 2, 0);
0416
0417
0418 int nChipStrobes[8 * 9 * 6] = {0};
0419
0420
0421 int nDecError = 0;
0422
0423 int npackets = evt->getPacketList(plist, 2);
0424
0425 if (npackets > 2)
0426 {
0427 delete plist[0];
0428 delete plist[1];
0429 return 0;
0430 }
0431
0432 for (int i = 0; i < npackets; i++)
0433 {
0434
0435 if ((plist[i]->getIdentifier() < 2001) || (plist[i]->getIdentifier() > 2052))
0436 {
0437 delete plist[i];
0438 continue;
0439 }
0440 if (Verbosity() > 1)
0441 {
0442 plist[i]->identify();
0443 }
0444 int num_feeId = plist[i]->iValue(-1, "NR_LINKS");
0445 if (Verbosity() > 1)
0446 {
0447 std::cout << "Number of feeid in RCDAQ events: " << num_feeId << " for packet "
0448 << plist[i]->getIdentifier() << std::endl;
0449 }
0450 if (num_feeId > 0)
0451 {
0452 int min_strobes = 1000000000;
0453 int sum_strobes = 0;
0454 for (int i_fee{0}; i_fee < num_feeId; ++i_fee)
0455 {
0456 auto feeId = plist[i]->iValue(i_fee, "FEEID");
0457 int cur_strobes = plist[i]->iValue(feeId, "NR_STROBES");
0458 if (cur_strobes < min_strobes) min_strobes = cur_strobes;
0459 sum_strobes += cur_strobes;
0460 }
0461 if(plist[i]->getIdentifier()%10 == 1) hStrobesDMA->SetBinContent((this->MonitorServerId() * 2) +1, hStrobesDMA->GetBinContent((this->MonitorServerId() * 2) +1) + min_strobes);
0462 if(plist[i]->getIdentifier()%10 == 2) hStrobesDMA->SetBinContent((this->MonitorServerId() * 2) +2, hStrobesDMA->GetBinContent((this->MonitorServerId() * 2) +2) + min_strobes);
0463
0464 if(sum_strobes > 0){
0465 if(plist[i]->getIdentifier()%10 == 1) hDMAstatus->SetBinContent((this->MonitorServerId() * 2) +1, 1);
0466 if(plist[i]->getIdentifier()%10 == 2) hDMAstatus->SetBinContent((this->MonitorServerId() * 2) +2, 1);
0467 }
0468
0469 for (int i_fee{0}; i_fee < num_feeId; ++i_fee)
0470 {
0471 auto feeId = plist[i]->iValue(i_fee, "FEEID");
0472 auto link = DecodeFeeid(feeId);
0473 auto num_strobes = plist[i]->iValue(feeId, "NR_STROBES");
0474 auto num_RDHErrors = plist[i]->iValue(feeId, "RDH_ERRORS");
0475 ntriggers = num_strobes;
0476 auto num_L1Trgs = plist[i]->iValue(feeId, "NR_PHYS_TRG");
0477 for (int iL1 = 0; iL1 < num_L1Trgs; ++iL1)
0478 {
0479
0480 hChipL1->Fill((StaveBoundary[link.layer] + link.stave % 20) * 9 + 3 * link.gbtid + 0);
0481 hChipL1->Fill((StaveBoundary[link.layer] + link.stave % 20) * 9 + 3 * link.gbtid + 1);
0482 hChipL1->Fill((StaveBoundary[link.layer] + link.stave % 20) * 9 + 3 * link.gbtid + 2);
0483 hFeeL1->Fill((StaveBoundary[link.layer] + link.stave % 20) * 3 + link.gbtid);
0484 }
0485
0486 for (int irdhe = 0; irdhe < num_RDHErrors; ++irdhe)
0487 {
0488 hFeeRDHErrors->Fill((StaveBoundary[link.layer] + link.stave % 20) * 3 + link.gbtid);
0489 }
0490
0491 for (int i_strb{0}; i_strb < num_strobes; ++i_strb)
0492 {
0493 auto strb_bco = plist[i]->lValue(feeId, i_strb, "TRG_IR_BCO");
0494 auto num_hits = plist[i]->iValue(feeId, i_strb, "TRG_NR_HITS");
0495 if (Verbosity() > 4)
0496 {
0497 if (link.layer == 0)
0498 {
0499 std::cout << "evtno: "
0500 << ", Fee: " << feeId;
0501 std::cout << " Layer: " << link.layer << " Stave: " << link.stave;
0502 std::cout << " GBT: " << link.gbtid << ", bco: 0x" << std::hex << strb_bco << std::dec;
0503 std::cout << ", n_hits: " << num_hits << std::endl;
0504 }
0505 }
0506 hChipStrobes->Fill((StaveBoundary[link.layer] + link.stave % 20) * 9 + 3 * link.gbtid + 0);
0507 hChipStrobes->Fill((StaveBoundary[link.layer] + link.stave % 20) * 9 + 3 * link.gbtid + 1);
0508 hChipStrobes->Fill((StaveBoundary[link.layer] + link.stave % 20) * 9 + 3 * link.gbtid + 2);
0509 hFeeStrobes->Fill((StaveBoundary[link.layer] + link.stave % 20) * 3 + link.gbtid);
0510 nChipStrobes[(StaveBoundary[link.layer] + link.stave % 20) * 9 + 3 * link.gbtid + 0]++;
0511 nChipStrobes[(StaveBoundary[link.layer] + link.stave % 20) * 9 + 3 * link.gbtid + 1]++;
0512 nChipStrobes[(StaveBoundary[link.layer] + link.stave % 20) * 9 + 3 * link.gbtid + 2]++;
0513
0514 for (int i_hit{0}; i_hit < num_hits; ++i_hit)
0515 {
0516 auto chip_id = plist[i]->iValue(feeId, i_strb, i_hit, "HIT_CHIP_ID");
0517 auto chip_row = plist[i]->iValue(feeId, i_strb, i_hit, "HIT_ROW");
0518 auto chip_col = plist[i]->iValue(feeId, i_strb, i_hit, "HIT_COL");
0519
0520 mHitPerChip[link.layer][link.stave % 20][3 * link.gbtid + chip_id]++;
0521 hChipHitmap->Fill(chip_col, chip_row, (StaveBoundary[link.layer] + link.stave % 20) * 9 + 3 * link.gbtid + chip_id);
0522
0523
0524 hChipStaveOccupancy[link.layer]->Fill(3 * link.gbtid + chip_id, link.stave % 20);
0525
0526 }
0527 }
0528
0529 int ifee_plot = 3 * StaveBoundary[link.layer] + 3 * link.stave + link.gbtid;
0530 auto lane_error = plist[i]->iValue(feeId, "tdt_lanestatus_error");
0531
0532
0533 while (lane_error != -1)
0534 {
0535
0536
0537 for (unsigned int ilane = 0; ilane < NLanesMax; ilane++)
0538 {
0539 unsigned int laneValue = lane_error >> (2 * ilane) & 0x3;
0540
0541 if (laneValue)
0542 {
0543
0544
0545
0546 mLaneStatus[laneValue - 1]->Fill(ilane, StaveBoundary[link.layer] + link.stave);
0547 mLaneStatusCumulative[laneValue - 1]->Fill(ilane, StaveBoundary[link.layer] + link.stave);
0548
0549
0550 mStatusFlagNumber[laneValue - 1][link.layer][link.stave][ilane]++;
0551
0552 }
0553 }
0554
0555 lane_error = plist[i]->iValue(feeId, "tdt_lanestatus_error");
0556 }
0557
0558 auto decoder_error = plist[i]->lValue(feeId, "decoder_error");
0559 while (decoder_error != -1)
0560 {
0561
0562 int error = decoder_error & 0xFFFFFFFF;
0563 hErrorPlots->Fill(error);
0564 nDecError++;
0565
0566 hErrorFile->Fill((this->MonitorServerId() * 2) + i + 0.5, error);
0567 mErrorVsFeeid->Fill(ifee_plot,error);
0568 decoder_error = plist[i]->lValue(feeId, "decoder_error");
0569 }
0570 }
0571 }
0572 delete plist[i];
0573 }
0574
0575 for(int bin = 1; bin < 50 ; bin ++){
0576 hErrorPlotsTime->SetBinContent(bin,hErrorPlotsTime->GetBinContent(bin+1));
0577 }
0578 hErrorPlotsTime->SetBinContent(50,nDecError);
0579
0580
0581 int firedChips = 0;
0582 int firedPixels = 0;
0583 int sumstrobes = 0;
0584 int nstrobes = 0;
0585 for (int l = 0; l < NLAYERS; l++)
0586 {
0587 for (int s = 0; s < NStaves[l]; s++)
0588 {
0589 for (int j = 0; j < NCHIP; j++)
0590 {
0591 if (mHitPerChip[l][s][j] > 0)
0592 {
0593 firedChips++;
0594 mvtxmon_EvtHitChip->Fill(mHitPerChip[l][s][j] / nChipStrobes[(StaveBoundary[l] + s) * 9 + j]);
0595 firedPixels += mHitPerChip[l][s][j];
0596 sumstrobes += nChipStrobes[(StaveBoundary[l] + s) * 9 + j];
0597 nstrobes++;
0598 }
0599 }
0600 }
0601 }
0602 mvtxmon_ChipFiredHis->Fill(firedChips);
0603 mvtxmon_EvtHitDis->Fill((double) firedPixels / ((double) sumstrobes / (double) nstrobes));
0604
0605
0606
0607
0608
0609 double chip_occ[9]{};
0610 double pixelOccupancy, chipOccupancy;
0611
0612 for (int iLayer = 0; iLayer < 3; iLayer++)
0613 {
0614 for (int iStave = 0; iStave < NStaves[iLayer]; iStave++)
0615 {
0616 for (int iChip = 0; iChip < 9; iChip++)
0617 {
0618 chip_occ[iChip] = 0;
0619 chipOccupancy = hChipHitmap->Integral(0, -1, 0, -1, (StaveBoundary[iLayer] + iStave) * 9 + iChip + 1, (StaveBoundary[iLayer] + iStave) * 9 + iChip + 1);
0620 double chipOccupancyNorm = -1;
0621 if(hChipStrobes->GetBinContent((StaveBoundary[iLayer] + iStave) * 9 + iChip + 1) > 0) chipOccupancyNorm = chipOccupancy / hChipStrobes->GetBinContent((StaveBoundary[iLayer] + iStave) * 9 + iChip + 1) / 1024 / 512;
0622 if (chipOccupancyNorm > 0)
0623 {
0624 mvtxmon_ChipStave1D->SetBinContent((StaveBoundary[iLayer] + iStave) * 9 + iChip + 1, chipOccupancyNorm);
0625 chip_occ[iChip] = chipOccupancyNorm;
0626 }
0627
0628 for (int iCol = 0; iCol < NCols; iCol++)
0629 {
0630 for (int iRow = 0; iRow < NRows; iRow++)
0631 {
0632 pixelOccupancy = hChipHitmap->GetBinContent(iCol + 1, iRow + 1, (StaveBoundary[iLayer] + iStave) * 9 + iChip + 1);
0633 if (pixelOccupancy > 0)
0634 {
0635 hOccupancyPlot[iLayer]->Fill(log10(pixelOccupancy / (double)(hChipStrobes->GetBinContent((StaveBoundary[iLayer] + iStave) * 9 + iChip + 1))));
0636 if (pixelOccupancy / (double) (hChipStrobes->GetBinContent((StaveBoundary[iLayer] + iStave) * 9 + iChip + 1)) > mOccupancyCutForNoisyPixel)
0637 {
0638 mNoisyPixelNumber[iLayer][iStave][iChip]++;
0639 }
0640 }
0641 }
0642 }
0643 }
0644
0645 mGeneralOccupancy->SetBinContent(mapstave[iLayer][iStave], *(std::max_element(chip_occ, chip_occ + 9)));
0646 }
0647 }
0648
0649
0650 for (int iLayer = 0; iLayer < 3; iLayer++)
0651 {
0652 for (int iStave = 0; iStave < NStaves[iLayer]; iStave++)
0653 {
0654 for (int iChip = 0; iChip < 9; iChip++)
0655 {
0656 double noisy = std::accumulate(mNoisyPixelNumber[iLayer][iStave], mNoisyPixelNumber[iLayer][iStave] + 9,0);
0657 mGeneralNoisyPixel->SetBinContent(mapstave[iLayer][iStave], noisy);
0658 if (mNoisyPixelNumber[iLayer][iStave][iChip] > 0)
0659 {
0660 hChipStaveNoisy[iLayer]->SetBinContent(iChip + 1, iStave + 1, mNoisyPixelNumber[iLayer][iStave][iChip]);
0661 }
0662 }
0663 }
0664 }
0665
0666
0667 for (int iLayer = 0; iLayer < 3; iLayer++)
0668 {
0669 for (int iStave = 0; iStave < NStaves[iLayer]; iStave++)
0670 {
0671 for (int iFlag = 0; iFlag < 3; iFlag++)
0672 {
0673 for (int iChip = 0; iChip < 9; iChip++)
0674 {
0675 if (mStatusFlagNumber[iFlag][iLayer][iStave][iChip] > 0)
0676 {
0677 mvtxmon_LaneStatusOverview[iFlag]->SetBinContent(mapstave[iLayer][iStave], mvtxmon_LaneStatusOverview[iFlag]->GetBinContent(mapstave[iLayer][iStave]) + 1);
0678 mvtxmon_LaneStatusOverview[3]->SetBinContent(mapstave[iLayer][iStave], mvtxmon_LaneStatusOverview[iFlag]->GetBinContent(mapstave[iLayer][iStave]) + 1);
0679 }
0680 }
0681 mvtxmon_LaneStatusOverview[iFlag]->SetBinContent(mapstave[iLayer][iStave], static_cast<double>(mvtxmon_LaneStatusOverview[iFlag]->GetBinContent(mapstave[iLayer][iStave])) / 9);
0682 }
0683 }
0684 }
0685
0686
0687 for (int iLayer = 0; iLayer < 3; iLayer++)
0688 {
0689 for (int iStave = 0; iStave < NStaves[iLayer]; iStave++)
0690 {
0691 for (int iChip = 0; iChip < 9; iChip++)
0692 {
0693 if (!mHitPerChip[iLayer][iStave][iChip])
0694 {
0695 if (mDeadChipPos[iLayer]->GetBinContent(mDeadChipPos[iLayer]->GetXaxis()->FindBin(iChip), mDeadChipPos[iLayer]->GetYaxis()->FindBin(iStave)) > 0.5)
0696 {
0697 mDeadChipPos[iLayer]->SetBinContent(mDeadChipPos[iLayer]->GetXaxis()->FindBin(iChip), mDeadChipPos[iLayer]->GetYaxis()->FindBin(iStave), 1);
0698 }
0699 }
0700 else
0701 {
0702 mDeadChipPos[iLayer]->SetBinContent(mDeadChipPos[iLayer]->GetXaxis()->FindBin(iChip), mDeadChipPos[iLayer]->GetYaxis()->FindBin(iStave), 0);
0703 }
0704 }
0705 }
0706 }
0707
0708
0709
0710
0711
0712
0713 std::ostringstream msg;
0714 msg << "Filling Histos";
0715 se->send_message(this, MSG_SOURCE_UNSPECIFIED, MSG_SEV_INFORMATIONAL, msg.str(), FILLMESSAGE);
0716 idummy = 0;
0717 return 0;
0718 }
0719
0720 int MvtxMon::Reset()
0721 {
0722
0723 hChipHitmap->Reset("ICESM");
0724
0725 for (int mLayer = 0; mLayer < 3; mLayer++)
0726 {
0727 for (int binx = 0; binx < mDeadChipPos[mLayer]->GetNbinsX(); binx++)
0728 {
0729 for (int biny = 0; biny < mDeadChipPos[mLayer]->GetNbinsY(); biny++)
0730 {
0731 mDeadChipPos[mLayer]->SetBinContent(binx + 1, biny + 1, 1);
0732 }
0733 }
0734 }
0735
0736 for (int iLayer = 0; iLayer < 3; iLayer++)
0737 {
0738 for (int iStave = 0; iStave < NStaves[iLayer]; iStave++)
0739 {
0740 for (int iChip = 0; iChip < 9; iChip++)
0741 {
0742 for (int iFlag = 0; iFlag < 3; iFlag++) {
0743 mStatusFlagNumber[iFlag][iLayer][iStave][iChip] = 0;
0744 }
0745 }
0746 }
0747 }
0748
0749
0750 evtcnt = 0;
0751 idummy = 0;
0752 return 0;
0753 }
0754
0755 void MvtxMon::getStavePoint(int layer, int stave, double* px, double* py)
0756 {
0757 float stepAngle = M_PI * 2 / NStaves[layer];
0758 float midAngle = StartAngle[layer] + (stave * stepAngle);
0759 float staveRotateAngle = M_PI / 2 - (stave * stepAngle);
0760 px[1] = MidPointRad[layer] * std::cos(midAngle);
0761
0762
0763
0764
0765 py[1] = MidPointRad[layer] * std::sin(midAngle);
0766
0767 px[0] = 7.7 * std::cos(staveRotateAngle) + px[1];
0768 py[0] = -7.7 * std::sin(staveRotateAngle) + py[1];
0769 px[2] = -7.7 * std::cos(staveRotateAngle) + px[1];
0770 py[2] = 7.7 * std::sin(staveRotateAngle) + py[1];
0771 px[3] = 5.623 * std::sin(staveRotateAngle) + px[1];
0772 py[3] = 5.623 * std::cos(staveRotateAngle) + py[1];
0773 }
0774
0775 void MvtxMon::createPoly(TH2Poly* h)
0776 {
0777 for (int ilayer = 0; ilayer < NLAYERS; ilayer++)
0778 {
0779 for (int istave = 0; istave < NStaves[ilayer]; istave++)
0780 {
0781 double* px = new double[4];
0782 double* py = new double[4];
0783 getStavePoint(ilayer, istave, px, py);
0784 for (int icoo = 0; icoo < 4; icoo++)
0785 {
0786 px[icoo] *= 3.;
0787 py[icoo] *= 3.;
0788 }
0789 h->AddBin(4, px, py);
0790 }
0791 }
0792 }