5 #include <onlmon/OnlMonClient.h>
6 #include <onlmon/RunDBodbc.h>
41 memset(
TC, 0,
sizeof(
TC));
42 memset(
Pad, 0,
sizeof(
Pad));
44 tm->SetMarkerStyle(8);
45 tm->SetMarkerColor(1);
57 for (
int q = 0; q < 12; q++)
77 if (!strcmp(name,
"PktSizeMon0"))
80 TC[0] =
new TCanvas(name,
"Packet Size Monitor", -1, 0, xsize / 2, ysize);
89 else if (!strcmp(name,
"PktSizeMon1"))
92 TC[1] =
new TCanvas(name,
"Packet Size History", -xsize / 2, 0, xsize / 2, ysize);
93 gSystem->ProcessEvents();
94 Pad[1] =
new TPad(
"pktpad1",
"who needs this?", 0.1, 0.05, 0.9, 0.9, 0);
97 transparent[1] =
new TPad(
"transparent1",
"this does not show", 0, 0, 1, 1);
108 if (what ==
"ALL" || what ==
"FIRST")
113 if (what ==
"HISTORY")
120 std::cout <<
PHWHERE <<
" Unimplemented Drawing option: " << what << std::endl;
128 for (
int w = 0; w < 12; w++)
133 if (!gROOT->FindObject(
"PktSizeMon0"))
138 TH1 *pktsize_hist = cl->
getHisto(
"PKTSIZEMON_0",
"pktsize_hist");
146 Pads[0] =
new TPad(
"",
"", 0, 0.66, 0.25, 1, 0);
147 Pads[1] =
new TPad(
"",
"", 0.25, 0.66, 0.5, 1, 0);
148 Pads[2] =
new TPad(
"",
"", 0.5, 0.66, 0.75, 1, 0);
149 Pads[3] =
new TPad(
"",
"", 0.75, 0.66, 1, 1, 0);
150 Pads[4] =
new TPad(
"",
"", 0, 0.33, 0.25, 0.66, 0);
151 Pads[5] =
new TPad(
"",
"", 0.25, 0.33, 0.5, 0.66, 0);
152 Pads[6] =
new TPad(
"",
"", 0.5, 0.33, 0.75, 0.66, 0);
153 Pads[7] =
new TPad(
"",
"", 0.75, 0.33, 1, 0.66, 0);
154 Pads[8] =
new TPad(
"",
"", 0, 0, .25, 0.33, 0);
155 Pads[9] =
new TPad(
"",
"", 0.25, 0, 0.5, 0.33, 0);
156 Pads[10] =
new TPad(
"",
"", 0.5, 0, 0.75, 0.33, 0);
157 Pads[11] =
new TPad(
"",
"", 0.75, 0, 1, 0.33, 0);
159 Frames[0] =
new TH2F(
"h2",
"MBD", 2, 1000, 1003, 2, 0, 10000);
160 Frames[1] =
new TH2F(
"h2",
"MVTX", 2, 2000, 2200, 2, 0, 10000);
161 Frames[2] =
new TH2F(
"h2",
"INTT", 2, 3000, 3200, 2, 0, 10000);
162 Frames[3] =
new TH2F(
"h2",
"TPC", 2, 4230, 4232, 2, 0, 10000);
163 Frames[4] =
new TH2F(
"h2",
"TPOT", 2, 5000, 5200, 2, 0, 10000);
164 Frames[5] =
new TH2F(
"h2",
"CEMC", 2, 6000, 6126, 2, 0, 10000);
165 Frames[6] =
new TH2F(
"h2",
"IHCAL", 2, 7000, 7008, 2, 0, 10000);
166 Frames[7] =
new TH2F(
"h2",
"OHCAL", 2, 8000, 8008, 2, 0, 10000);
167 Frames[8] =
new TH2F(
"h2",
"SEPD", 2, 9000, 9002, 2, 0, 10000);
168 Frames[9] =
new TH2F(
"h2",
"ZDC", 2, 12000, 12002, 2, 0, 10000);
169 Frames[10] =
new TH2F(
"h2",
"Local lvl.1", 2, 13999, 14001, 2, 0, 10000);
170 Frames[11] =
new TH2F(
"h2",
"Global lvl.1", 2, 14000, 14002, 2, 0, 10000);
175 Pads[
n]->SetLeftMargin(.125);
183 Frames[
x]->GetXaxis()->SetTitle(
"Packet ID");
184 Frames[
x]->GetXaxis()->CenterTitle(
true);
185 Frames[
x]->GetYaxis()->SetTitle(
"Packet size (bytes)");
186 Frames[
x]->GetYaxis()->CenterTitle(
true);
192 std::map <int, double> packet;
193 for (
int i = 1;
i <= pktsize_hist->GetNbinsX();
i++)
195 int a = pktsize_hist->GetBinError(
i);
196 double b = pktsize_hist->GetBinContent(
i);
198 if (a > 999 && a < 1003)
201 tm->DrawMarker(a, packet[a]);
203 else if (a < 1000 || (a > 1002 && a < 2000))
205 std::cout<<
"unknown packet id: " << (
a) <<
'\n';
207 if (a > 1999 && a < 2201)
210 tm->DrawMarker(a, packet[a]);
212 else if (a > 2200 && a < 3000)
214 std::cout<<
"unknown packet id: " << (
a) <<
'\n';
216 if (a > 2999 && a < 3201)
219 tm->DrawMarker(a, packet[a]);
221 else if (a > 3200 && a < 4231)
223 std::cout<<
"unknown packet id: " << (
a) <<
'\n';
228 tm->DrawMarker(a, packet[a]);
230 else if (a > 4231 && a < 5000)
232 std::cout<<
"unknown packet id: " << (
a) <<
'\n';
234 if (a > 4999 && a < 5201)
237 tm->DrawMarker(a, packet[a]);
239 else if (a > 5200 && a < 6000)
241 std::cout<<
"unknown packet id: " << (
a) <<
'\n';
243 if (a > 5999 && a < 6127)
246 tm->DrawMarker(a, packet[a]);
248 else if (a > 6126 && a < 7000)
250 std::cout<<
"unknown packet id: " << (
a) <<
'\n';
252 if (a > 6999 && a < 7009)
255 tm->DrawMarker(a, packet[a]);
257 else if ( a > 7008 && a < 8000)
259 std::cout<<
"unknown packet id: " << (
a) <<
'\n';
261 if (a > 7999 && a < 8009)
264 tm->DrawMarker(a, packet[a]);
266 else if (a > 8008 && a < 9001)
268 std::cout<<
"unknown packet id: " << (
a) <<
'\n';
273 tm->DrawMarker(a, packet[a]);
275 else if (a > 9001 && a < 12001)
277 std::cout<<
"unknown packet id: " << (
a) <<
'\n';
282 tm->DrawMarker(a, packet[a]);
284 else if (a > 12001 && a < 14000)
286 std::cout<<
"unknown packet id: " << (
a) <<
'\n';
291 tm->DrawMarker(a, packet[a]);
296 tm->DrawMarker(a, packet[a]);
300 std::cout<<
"unknown packet id: " << (
a) <<
'\n';
309 if (!gROOT->FindObject(
"PktSizeMon0"))
314 TH1 *pktsize_hist = cl->
getHisto(
"PKTSIZEMON_0",
"pktsize_hist");
323 PrintRun.SetTextFont(62);
324 PrintRun.SetTextSize(0.03);
326 PrintRun.SetTextAlign(23);
327 std::ostringstream runnostream;
328 time_t evttime = cl->
EventTime(
"CURRENT");
331 runnostream <<
"Packet Size Display Run " << runnumber
332 <<
", Time: " << ctime(&evttime);
334 PrintRun.DrawText(0.5, 0.98, runnostream.str().c_str());
336 runnostream <<
"Based on " << pktsize_hist->GetBinContent(0) <<
" Events";
337 PrintRun.DrawText(0.5, 0.94, runnostream.str().c_str());
340 htmp->SetStats(kFALSE);
341 htmp->GetXaxis()->SetNoExponent();
342 htmp->GetXaxis()->SetTitle(
"Packet Id");
349 outtxt.SetTextFont(62);
350 outtxt.SetTextSize(0.02);
351 outtxt.SetTextColor(1);
352 outtxt.SetTextAlign(13);
355 ArrowHead.SetMarkerSize(1.5);
356 ArrowHead.SetMarkerColor(2);
357 ArrowHead.SetMarkerStyle(26);
361 std::map<int, std::map<unsigned int, float> >::const_iterator iter;
362 std::map<unsigned int, float>::const_iterator
piter;
365 int foundnoisypacket = 0;
368 marker.SetMarkerStyle(22);
369 marker.SetMarkerSize(2);
370 marker.SetMarkerColor(2);
371 for (piter = iter->second.begin(); piter != iter->second.end(); ++
piter)
377 float linetopend = 9;
378 marker.DrawMarker((
double) (piter->first), piter->second);
379 std::ostringstream pktid;
380 pktid << std::setprecision(3) << piter->first <<
"(" << piter->second <<
" w)";
381 int xpos = ((piter->first) / 1000) * 1000;
384 xpos = ((piter->first) / 100) * 100;
390 else if (xpos == 7000)
392 xpos = ((piter->first) / 100) * 100;
398 else if (xpos == 24000)
400 xpos = ((piter->first) / 100) * 100;
406 float arrowoffset = linetopend + 6;
407 ta.DrawLine(xpos, 0, xpos,
MAXSIZEDISP + linetopend);
408 ArrowHead.DrawMarker(xpos,
MAXSIZEDISP + arrowoffset);
409 outtxt.DrawText(xpos, ypos, pktid.str().c_str());
411 foundnoisypacket = 1;
416 if (!foundnoisypacket)
419 outtxt.SetTextSize(0.05);
420 outtxt.SetTextColor(3);
421 outtxt.SetTextAlign(22);
422 outtxt.DrawText(0.5, 0.7,
"Congratulations");
423 outtxt.DrawText(0.5, 0.5,
"No");
424 outtxt.DrawText(0.5, 0.3,
"Noisy Packets");
427 granlabel.SetTextAlign(12);
428 granlabel.SetTextAngle(90);
429 std::map<std::string, std::pair<unsigned int, unsigned int> >::const_iterator graniter;
432 granlabel.SetTextSize(0.03);
433 int xpos = ((graniter->second.first) / 1000) * 1000;
438 granlabel.SetTextSize(0.015);
439 xpos = ((graniter->second.first) / 100) * 100;
442 granlabel.DrawText(xpos,
MAXSIZEDISP + 20,
"VTXP");
446 granlabel.DrawText(xpos,
MAXSIZEDISP + 70,
"VTXS");
449 else if (xpos == 7000)
451 xpos = ((graniter->second.first) / 100) * 100;
452 granlabel.SetTextSize(0.015);
455 granlabel.DrawText(xpos,
MAXSIZEDISP + 20,
"TOFE");
459 granlabel.DrawText(xpos,
MAXSIZEDISP + 70,
"TOFW");
462 else if (xpos == 21000)
464 xpos = ((graniter->second.first) / 100) * 100;
465 granlabel.SetTextSize(0.015);
472 granlabel.DrawText(xpos,
MAXSIZEDISP + 70,
"MPCEX");
489 std::map<int, std::map<unsigned int, float> >::iterator iter;
493 iter->second.clear();
497 std::map<unsigned int, float> newmap;
501 for (
int i = 1;
i <= pktsize_hist->GetNbinsX();
i++)
503 unsigned int packetid = (
unsigned int) pktsize_hist->GetBinError(
i);
504 iter->second[
packetid] = pktsize_hist->GetBinContent(
i);
513 int iret =
Draw(what);
519 for (TCanvas *canvas :
TC)
521 if (canvas ==
nullptr)
539 for (
int i = 21101;
i <= 21106;
i++)
545 for (
int i = 21301;
i <= 21308;
i++)
550 for (
int i = 21351;
i <= 21358;
i++)
558 for (
int i = 24001;
i < 24061;
i++)
563 for (
int i = 24101;
i < 24141;
i++)
567 int iret =
Draw(what);
588 if (!gROOT->FindObject(
"PktSizeMon1"))
593 TH1 *pktsize_hist = cl->
getHisto(
"PKTSIZEMON_0",
"pktsize_hist");
628 int firstrun = *(
runlist.begin());
638 PrintRun.SetTextFont(62);
639 PrintRun.SetTextSize(0.03);
641 PrintRun.SetTextAlign(23);
643 std::ostringstream runnostream;
644 time_t evttime = cl->
EventTime(
"CURRENT");
645 runnostream <<
"Packet Size History Run " << runnumber
646 <<
", Time: " << ctime(&evttime);
648 PrintRun.DrawText(0.5, 0.98, runnostream.str().c_str());
651 htmp->SetStats(kFALSE);
652 htmp->GetXaxis()->SetNoExponent();
653 htmp->GetXaxis()->SetTitle(
"Run");
654 htmp->GetXaxis()->SetLabelSize(0.025);
660 std::set<unsigned int>::const_iterator iter;
676 std::set<int>::const_iterator iter;
681 std::map<unsigned int, float> pkts;
696 std::map<unsigned int, float>::const_iterator iter =
knownbig.find(packetid);
699 if (iter->second > size)
709 std::map<unsigned int, float> pkts;
717 std::map<std::string, std::pair<unsigned int, unsigned int> >::const_iterator graniter;
729 std::cout <<
"Size before cleanup: " <<
packetmap.size() << std::endl;
739 std::cout <<
"Size after cleanup: " <<
packetmap.size() << std::endl;
746 std::map<int, std::map<unsigned int, float> >::iterator iter;
755 std::cout <<
"Could not find run " << runno <<
" in list of runs" << std::endl;
762 if (what ==
"PACKETS" || what ==
"ALL")
764 std::map<int, std::map<unsigned int, float> >::const_iterator iter;
765 std::map<unsigned int, float>::const_iterator
piter;
768 for (piter = iter->second.begin(); piter != iter->second.end(); ++
piter)
770 std::cout <<
"Run " << iter->first
771 <<
", packetid: " << piter->first
772 <<
", size: " << piter->second
777 if (what ==
"RUNS" || what ==
"ALL")
779 std::set<int>::const_iterator riter;
780 std::cout <<
"List of runs in Run set: " << std::endl;
783 std::cout <<
"Run " << *riter << std::endl;
791 std::map<unsigned int, float>::const_iterator
piter;
792 for (piter = packetsize.begin(); piter != packetsize.end(); ++
piter)
805 std::map<int, std::map<unsigned int, float> >::const_iterator iter;
806 std::map<unsigned int, float>::const_iterator
piter;
810 for (piter = iter->second.begin(); piter != iter->second.end(); ++
piter)
823 std::set<unsigned int>::const_iterator
piter;
824 std::map<int, std::map<unsigned int, float> >::const_iterator siter;
825 std::map<unsigned int, float>::const_iterator psizeiter;
831 psizeiter = siter->second.find(*piter);
832 if (psizeiter != siter->second.end())
836 size = psizeiter->second;
840 if (psizeiter->second > 200 && fabs(psizeiter->second - size) > size / 5.)
844 std::cout <<
"Adding noisy packet " << *piter
845 <<
" old size " << size
846 <<
" current size " << psizeiter->second
847 <<
" current Run " << siter->first
852 size = psizeiter->second;
865 std::map<int, std::map<unsigned int, float> >::const_iterator siter;
866 std::map<unsigned int, float>::const_iterator psizeiter;
867 std::vector<double> runno, meansize;
871 psizeiter = siter->second.find(ipkt);
872 if (psizeiter != siter->second.end())
874 runno.push_back((
double) siter->first);
875 meansize.push_back(psizeiter->second);
878 double *
x =
new double[runno.size()];
879 double *
y =
new double[runno.size()];
880 for (
unsigned int i = 0;
i < runno.size();
i++)
885 icol += icnt - (icnt / 9) * 9;
887 gr.SetMarkerStyle(imarker);
888 gr.SetMarkerColor(icol);
889 gr.SetLineColor(icol);
891 gr.DrawGraph(runno.size(),
x,
y,
"LP");
893 tr.SetMarkerStyle(imarker);
894 tr.SetMarkerColor(icol);
895 tr.DrawMarker(x[0], (
MAXSIZEDISP - 100) - 20 * icnt);
896 std::ostringstream pktstring;
898 tx.SetTextColor(icol);
899 tx.SetTextSize(0.03);
900 double txtXcoord = x[0] + (
lastrun - x[0]) / 70;
902 tx.DrawText(txtXcoord, (
MAXSIZEDISP - 100) - 20 * icnt, pktstring.str().c_str());