13 #include <onlmon/OnlMon.h>
14 #include <onlmon/OnlMonDB.h>
15 #include <onlmon/OnlMonServer.h>
17 #include <Event/msg_profile.h>
28 #include <Event/Event.h>
29 #include <Event/packet.h>
64 const char *mvtxcalib = getenv(
"MVTXCALIB");
67 std::cout <<
"MVTXCALIB environment variable not set" << std::endl;
71 std::ifstream calib(fullfile);
75 printf(
"doing the Init\n");
81 mvtxmon_ChipFiredHis=
new TH1D(
"MVTXMON_RawData_ChipFiredHis",
"Number of Chips Fired per Felix per RCDAQ event Distribution",
NCHIP*NSTAVE/6,-0.5,
NCHIP*NSTAVE/6 - 0.5);
82 mvtxmon_EvtHitChip=
new TH1D(
"MVTXMON_RawData_EvtHitChip",
"Number of Hits Per Strobe Per Chip Distribution",101,-0.5,100.5);
83 mvtxmon_EvtHitDis =
new TH1D(
"MVTXMON_RawData_EvtHitDis",
"Number of Hits Per Strobe Distribution",7201,-0.5,7200.5);
110 mRCDAQevt =
new TH1I(
"RCDAQ_evt",
"Number of RCDAQ events processed", 6,-0.5,5.5);
111 mRCDAQevt->GetXaxis()->SetTitle(
"FELIX server");
112 mRCDAQevt->GetYaxis()->SetTitle(
"Counts");
137 mTrigger =
new TH1I(
"MVTXMON_FEE_TriggerFlag",
"Trigger vs counts", NTrigger, 0.5, NTrigger + 0.5);
138 mTrigger->GetXaxis()->SetTitle(
"Trigger ID");
139 mTrigger->GetYaxis()->SetTitle(
"Counts");
158 auto l =
new TLine(lay, 0, lay,
mLaneStatus[
i]->GetNbinsY());
167 for (
const int& lay : LayerBoundaryFEE) {
176 mLaneStatusSummary[
i] =
new TH1I(Form(
"MVTXMON_LaneStatusSummary_LaneStatusSummaryL%i",
i), Form(
"Lane Status Summary L%i",
i), 3, 0, 3);
186 mLaneStatusSummaryIB =
new TH1I(
"MVTXMON_LaneStatusSummary_LaneStatusSummary",
"Lane Status Summary", 3, 0, 3);
205 pt[
i] =
new TPaveText(0.20, 0.80 -
i * 0.05, 0.85, 0.85 -
i * 0.05,
"NDC");
206 pt[
i]->SetTextSize(0.04);
207 pt[
i]->SetTextAlign(12);
208 pt[
i]->SetFillColor(0);
209 pt[
i]->SetTextColor(2);
215 hErrorFile =
new TH2D(
"MVTXMON_General_ErrorFile",
"Decoding Errors vs Packet ID", 6*8, 0, 6*8+1, NError, 0.5, NError + 0.5);
217 hErrorFile->GetXaxis()->SetTitle(
"Packet ID");
222 for (
int i = 1;
i < 6;
i++) {
223 auto l =
new TLine(
i*8+0.5+((
i-3)*0.15), 0.5,
i*8+0.5+((
i-3)*0.15),
hErrorFile->GetNbinsY()+0.5);
229 for (
int aLayer = 0; aLayer < 3; aLayer++) {
230 hOccupancyPlot[aLayer] =
new TH1D(Form(
"MVTXMON_Occupancy_Layer%dOccupancy", aLayer), Form(
"MVTX Layer %d, Occupancy Distribution", aLayer), 301, -3, 0.05);
232 hOccupancyPlot[aLayer]->GetXaxis()->SetTitle(
"log10(Pixel Occupancy)");
236 hChipStaveOccupancy[aLayer] =
new TH2D(Form(
"MVTXMON_Occupancy_Layer%d_Layer%dChipStave", aLayer, aLayer), Form(
"MVTX Layer%d, Occupancy vs Chip and Stave", aLayer), 9, -.5, 9 - .5,
NStaves[aLayer], -.5,
NStaves[aLayer] - .5);
243 TString
tmp = Form(
"MVTX Layer %d", aLayer);
244 tmp +=
", Number of noisy pixels (>20\% stobes in event) per RCDAQ event";
246 hChipStaveNoisy[aLayer] =
new TH2D(Form(
"MVTXMON_Noisy_Layer%d_ChipStave", aLayer), tmp, 9, -.5, 9 - .5,
NStaves[aLayer], -.5,
NStaves[aLayer] - .5);
254 hChipHitmap =
new TH3I(Form(
"MVTXMON_chipHitmapFLX%d", this->
MonitorServerId()), Form(
"MVTXMON_chipHitmapFLX%d", this->
MonitorServerId()), 1024, -.5, 1023.5, 512, -.5, 511.5,8*9*6,-.5,8*9*6-0.5);
255 hChipHitmap_evt =
new TH3I(Form(
"MVTXMON_chipHitmapFLX%d_evt", this->
MonitorServerId()), Form(
"MVTXMON_chipHitmapFLX%d_evt", this->
MonitorServerId()), 1024, -.5, 1023.5, 512, -.5, 511.5,8*9*6,-.5,8*9*6-0.5);
261 hChipStrobes =
new TH1I(
"hChipStrobes",
"Chip Strobes vs Chip*Stave", 8*9*6,-.5,8*9*6-0.5);
267 hChipL1 =
new TH1I(
"hChipL1",
"L1 triggers vs Chip*Stave", 8*9*6,-.5,8*9*6-0.5);
268 hChipL1->GetXaxis()->SetTitle(
"Chip*Stave");
269 hChipL1->GetYaxis()->SetTitle(
"Counts");
299 for (
int mLayer = 0; mLayer < 3; mLayer++) {
300 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);
301 mDeadChipPos[mLayer] ->GetXaxis()->SetTitle(
"Chip Number");
302 mDeadChipPos[mLayer] ->GetYaxis()->SetTitle(
"Stave Number");
304 mAliveChipPos[mLayer] =
new TH2D(Form(
"MVTXMON_Occupancy_Layer%d_Layer%dAliveChipPos", mLayer, mLayer), Form(
"Fraction of RCDAQ events a chip received data on Layer %d", mLayer), 9, -0.5, 9 - 0.5,
NStaves[mLayer], -0.5,
NStaves[mLayer] - 0.5);
312 for (
int binx = 0; binx <
mDeadChipPos[mLayer]->GetNbinsX(); binx++) {
313 for (
int biny = 0; biny <
mDeadChipPos[mLayer]->GetNbinsY(); biny++) {
319 mOccupancyPlot[mLayer] =
new TH1D(Form(
"MVTXMON_Occupancy_Layer%dOccupancy_LOG", mLayer), Form(
"MVTX Layer %d Noise pixels occupancy distribution", mLayer), 301, -3, 0.05);
328 mTotalDeadChipPos =
new TH2D(Form(
"MVTXMON_Occupancy_TotalDeadChipPos"), Form(
"TotalDeadChipPos "), 9, -0.5, 9 - 0.5,
NStaves[2], -0.5,
NStaves[2] - 0.5);
333 mTotalAliveChipPos =
new TH2D(Form(
"MVTXMON_Occupancy_TotalAliveChipPos"), Form(
"TotalAliveChipPos "), 9, -0.5, 9 - 0.5,
NStaves[2], -0.5,
NStaves[2] - 0.5);
360 for(
int l = 0; l <
NLAYERS; l++){
369 int nChipStrobes[8*9*6] = {0};
379 for (
int i = 0;
i < npackets;
i++)
382 if ( (
plist[
i]->getIdentifier() < 2001) || (
plist[
i]->getIdentifier() > 2052) )
393 std::cout <<
"Number of feeid in RCDAQ events: " << num_feeId <<
" for packet "
398 for (
int i_fee{0}; i_fee < num_feeId; ++i_fee)
402 auto num_strobes =
plist[
i]->
iValue(feeId,
"NR_STROBES");
404 auto num_L1Trgs =
plist[
i]->
iValue(feeId,
"NR_PHYS_TRG");
405 for (
int iL1 = 0; iL1 < num_L1Trgs; ++iL1 )
414 for (
int i_strb{0}; i_strb < num_strobes; ++i_strb)
416 auto strb_bco =
plist[
i]->
lValue(feeId, i_strb,
"TRG_IR_BCO");
418 auto num_hits =
plist[
i]->
iValue(feeId, i_strb,
"TRG_NR_HITS");
422 std::cout <<
"evtno: " <<
", Fee: " << feeId;
423 std::cout <<
" Layer: " << link.layer <<
" Stave: " << link.stave;
424 std::cout <<
" GBT: " << link.gbtid <<
", bco: 0x" << std::hex << strb_bco << std::dec;
425 std::cout <<
", n_hits: " << num_hits << std::endl;
431 nChipStrobes[(
StaveBoundary[link.layer]+link.stave%20)*9 + 3 * link.gbtid + 0]++;
432 nChipStrobes[(
StaveBoundary[link.layer]+link.stave%20)*9 + 3 * link.gbtid + 1]++;
433 nChipStrobes[(StaveBoundary[link.layer]+link.stave%20)*9 + 3 * link.gbtid + 2]++;
438 for (
int i_hit{0}; i_hit < num_hits; ++i_hit)
441 auto chip_id =
plist[
i]->
iValue(feeId, i_strb, i_hit,
"HIT_CHIP_ID");
442 auto chip_row =
plist[
i]->
iValue(feeId, i_strb, i_hit,
"HIT_ROW");
443 auto chip_col =
plist[
i]->
iValue(feeId, i_strb, i_hit,
"HIT_COL");
445 mHitPerChip[link.layer][link.stave%20][3 * link.gbtid + chip_id]++;
446 hChipHitmap->Fill(chip_col,chip_row,(StaveBoundary[link.layer]+link.stave%20)*9 + 3 * link.gbtid + chip_id);
448 hChipHitmap_evt->Fill(chip_col,chip_row,(StaveBoundary[link.layer]+link.stave%20)*9 + 3 * link.gbtid + chip_id);
468 for(
int l = 0; l <
NLAYERS; l++){
482 mvtxmon_EvtHitDis->Fill((
double)firedPixels/((
double)sumstrobes/(
double)nstrobes));
484 double pixelOccupancy, chipOccupancy;
485 for (
int iLayer = 0; iLayer < 3; iLayer++) {
486 for (
int iStave = 0; iStave <
NStaves[iLayer]; iStave++) {
487 for (
int iChip = 0; iChip < 9; iChip++) {
493 int nTrg = nChipStrobes[(
StaveBoundary[iLayer]+iStave)*9+iChip];
494 for (
int iCol = 0; iCol <
NCols; iCol++) {
495 for (
int iRow = 0; iRow <
NRows; iRow++) {
497 if (pixelOccupancy > 0) {
510 for (
int iLayer = 0; iLayer < 3; iLayer++) {
511 for (
int iStave = 0; iStave <
NStaves[iLayer]; iStave++) {
512 for (
int iChip = 0; iChip < 9; iChip++) {
520 for (
int iLayer = 0; iLayer < 3; iLayer++) {
521 for (
int iStave = 0; iStave <
NStaves[iLayer]; iStave++) {
522 for (
int iChip = 0; iChip < 9; iChip++) {
537 int packet_init = 2001;
539 for (
int iPkt = 0; iPkt < 8; iPkt++ ){
577 std::ostringstream
msg;
578 msg <<
"Filling Histos";
597 float staveRotateAngle = M_PI / 2 - (stave * stepAngle);
605 px[0] = 7.7 * std::cos(staveRotateAngle) + px[1];
606 py[0] = -7.7 * std::sin(staveRotateAngle) + py[1];
607 px[2] = -7.7 * std::cos(staveRotateAngle) + px[1];
608 py[2] = 7.7 * std::sin(staveRotateAngle) + py[1];
609 px[3] = 5.623 * std::sin(staveRotateAngle) + px[1];
610 py[3] = 5.623 * std::cos(staveRotateAngle) + py[1];
614 for (
int ilayer = 0; ilayer <
NLAYERS; ilayer++) {
615 for (
int istave = 0; istave <
NStaves[ilayer]; istave++) {
616 double* px =
new double[4];
617 double* py =
new double[4];
619 for (
int icoo = 0; icoo < 4; icoo++) {
623 h->AddBin(4, px, py);