Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
InttMonDraw.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file InttMonDraw.cc
1 #include "InttMonDraw.h"
2 
4 {
5  //Chip-Channel
6  {"chip_hitmap", (struct Option_s)
7  {
11  }
12  },
13 
14  {"chip_nll", (struct Option_s)
15  {
19  }
20  },
21 
22 
23  //Ladder-Chip
24  {"ladder_hitmap", (struct Option_s)
25  {
29  }
30  },
31 };
32 
33 
35 {
36  return;
37 }
38 
39 
41 {
42  return;
43 }
44 
45 //=== Inherited Functions ===//
47 {
48  return 0;
49 }
50 
52 {
53  bool b = false;
54  bool found = false;
55 
56  std::string temp = "";
57  for(std::size_t s = 0; s < what.length(); ++s)
58  {
59  temp += (char)std::tolower(what[s]);
60  }
61 
62  for(Options_t::iterator itr = OPTIONS.begin(); itr != OPTIONS.end(); ++itr)
63  {
64  b = false;
65 
66  if(temp == "all")b = true;
67  if(temp == itr->first)b = true;
68 
69  if(!b)continue;
70 
71  found = true;
72  (*(itr->second.head))(itr->first);
73  }
74 
75  if(!found)
76  {
77  std::cout << "Option \"" << what << "\" not found" << std::endl;
78  std::cout << "Try \"all\" or one of the following (case insensitive)" << std::endl;
79  for(Options_t::iterator itr = OPTIONS.begin(); itr != OPTIONS.end(); ++itr)
80  {
81  std::cout << "\t" << itr->first << std::endl;
82 
83  return 1;
84  }
85  }
86 
87  return 0;
88 }
89 
91 {
93  if(Draw(what))return 1;
94 
95  TSeqCollection* canvases = gROOT->GetListOfCanvases();
96  TCanvas* canvas = nullptr;
97  std::string pngfile;
98 
99  bool b = false;
100  bool found = false;
101 
102  std::string temp = "";
103  std::string name = "";
104  for(std::size_t s = 0; s < what.length(); ++s)
105  {
106  temp += (char)std::tolower(what[s]);
107  }
108  for(Options_t::iterator itr = OPTIONS.begin(); itr != OPTIONS.end(); ++itr)
109  {
110  b = false;
111 
112  if(temp == "all")b = true;
113  if(temp == itr->first)b = true;
114 
115  if(!b)continue;
116 
117  found = true;
118 
119  canvas = nullptr;
120  name = Form("Intt_%s_Global_Canvas", (itr->first).c_str());
121  for(TIter t_itr = canvases->begin(); t_itr != canvases->end(); ++t_itr)
122  {
123  if(std::string((*t_itr)->GetName()).find(name) == std::string::npos)continue;
124 
125  canvas = (TCanvas*)(*t_itr);
126  break;
127  }
128 
129  if(!canvas)continue;
130 
131  pngfile = cl->htmlRegisterPage(*this, canvas->GetTitle(), itr->first, "png");
132  cl->CanvasToPng(canvas, pngfile);
133  }
134 
135  if(!found)
136  {
137  std::cout << "Option \"" << what << "\" not found" << std::endl;
138  std::cout << "Try \"all\" or one of the following (case insensitive)" << std::endl;
139  for(Options_t::iterator itr = OPTIONS.begin(); itr != OPTIONS.end(); ++itr)
140  {
141  std::cout << "\t" << itr->first << std::endl;
142  }
143  }
144 
145  std::string logfile = cl->htmlRegisterPage(*this, "EXPERTS/Log", "log", "html");
146  std::ofstream log_out(logfile.c_str());
147  log_out << "<HTML><HEAD><TITLE>Log file for run " << cl->RunNumber();
148  log_out << "</TITLE></HEAD>" << std::endl;
149  log_out << "<P>[Implement me]" << std::endl;
150  log_out.close();
151 
152  std::string stsfile = cl->htmlRegisterPage(*this, "EXPERTS/Status", "status", "html");
153  std::ofstream sts_out(stsfile.c_str());
154  sts_out << "<HTML><HEAD><TITLE>Status file for run " << cl->RunNumber();
155  sts_out << "</TITLE></HEAD>" << std::endl;
156  sts_out << "<P>[Implement me]" << std::endl;
157  sts_out.close();
158 
159  cl->SaveLogFile(*this);
160 
161  return 0;
162 }
163 
165 {
167  if(Draw(what))return 1;
168 
169  TSeqCollection* canvases = gROOT->GetListOfCanvases();
170  TCanvas* canvas = nullptr;
172 
173  bool b = false;
174  bool found = false;
175 
176  std::string temp = "";
177  std::string name = "";
178  for(std::size_t s = 0; s < what.length(); ++s)
179  {
180  temp += (char)std::tolower(what[s]);
181  }
182  for(Options_t::iterator itr = OPTIONS.begin(); itr != OPTIONS.end(); ++itr)
183  {
184  b = false;
185 
186  if(temp == "all")b = true;
187  if(temp == itr->first)b = true;
188 
189  if(!b)continue;
190 
191  found = true;
192 
193  canvas = nullptr;
194  name = Form("Intt_%s_Global_Canvas", (itr->first).c_str());
195  for(TIter t_itr = canvases->begin(); t_itr != canvases->end(); ++t_itr)
196  {
197  if(std::string((*t_itr)->GetName()).find(name) == std::string::npos)continue;
198 
199  canvas = (TCanvas*)(*t_itr);
200  break;
201  }
202 
203  if(!canvas)continue;
204 
205  filename = ThisName + "_" + itr->first + "_" + cl->RunNumber() + "." + type;
206  cl->CanvasToPng(canvas, filename);
207  }
208 
209  if(!found)
210  {
211  std::cout << "Option \"" << what << "\" not found" << std::endl;
212  std::cout << "Try \"all\" or one of the following (case insensitive)" << std::endl;
213  for(Options_t::iterator itr = OPTIONS.begin(); itr != OPTIONS.end(); ++itr)
214  {
215  std::cout << "\t" << itr->first << std::endl;
216  }
217  }
218 
219  return 0;
220 }
221 
222 void InttMonDraw::DrawPad(TPad* base, TPad* pad)
223 {
224  pad->SetFillStyle(4000); //transparent
225  pad->Range(0.0, 0.0, 1.0, 1.0);
226  pad->SetTopMargin(T_MARGIN);
227  pad->SetBottomMargin(B_MARGIN);
228  pad->SetLeftMargin(L_MARGIN);
229  pad->SetRightMargin(R_MARGIN);
230 
231  base->cd();
232  pad->Draw();
233  pad->cd();
234 }
235 
236 //GlobalChip-Channel idiom
238 {
239  DrawGlobalChipMap(option);
240 }
241 
243 {
244  double x_lower = KEY_FRAC + Y_LABEL_FRAC;
245  double y_lower = 0.0;
246  double x_upper = 1.0;
247  double y_upper = 1.0;
248 
250  struct INTT::Indexes_s indexes;
251 
252  TStyle* style;
253  TCanvas* cnvs;
254  TPad* disp_pad;
255  TPad* hist_pad;
256  TPad* grid_pad;
257  TPad* ylbl_pad;
258  TPad* xlbl_pad;
259  TPad* exec_pad;
260 
261  TH2D* client_hists[4] = {nullptr};
262 
263  name = Form("Intt_%s_Global_Style", option.c_str());
264  style = (TStyle*)gROOT->FindObject(name.c_str());
265  if(!style)
266  {
267  style = new TStyle
268  (
269  name.c_str(),
270  name.c_str()
271  );
272  style->SetOptStat(0);
273  style->SetOptTitle(0);
274  //...
275  }
276  style->cd();
277 
278  name = Form("Intt_%s_Global_Canvas", option.c_str());
279  cnvs = (TCanvas*)gROOT->FindObject(name.c_str());
280  if(!cnvs)
281  {
282  cnvs = new TCanvas
283  (
284  name.c_str(),
285  name.c_str(),
286  0,
287  0,
288  CNVS_WIDTH,
290  );
291  //cnvs->...
292  //...
293  }
294 
295  name = Form("Intt_%s_Global_DispPad", option.c_str());
296  disp_pad = (TPad*)gROOT->FindObject(name.c_str());
297  if(!disp_pad)
298  {
299  disp_pad = new TPad
300  (
301  name.c_str(),
302  name.c_str(),
303  x_lower,
304  0.0,
305  x_upper,
306  DISP_FRAC
307  );
308  DrawPad(cnvs, disp_pad);
309 
310  TText* disp_text = new TText
311  (
312  0.5,
313  0.80,
314  Form("Layer: %2d Ladder: %2d (%s) Chip: %2d", INTT::LAYER_OFFSET, 0, "South", INTT::CHIP_OFFSET)
315  );
316  disp_text->SetName(Form("Intt_%s_Global_DispText", option.c_str()));
317  disp_text->SetTextAlign(22);
318  disp_text->SetTextSize(DISP_TEXT_SIZE);
319  disp_text->Draw();
320 
322  TText* run_text = new TText
323  (
324  0.5,
325  0.50,
326  Form("Run: %08d", cl->RunNumber())
327  );
328  run_text->SetName(Form("Intt_%s_Global_RunText", option.c_str()));
329  run_text->SetTextAlign(22);
330  run_text->SetTextSize(DISP_TEXT_SIZE);
331  run_text->Draw();
332 
333  std::time_t now = std::time(nullptr);
334  struct std::tm* time_s = std::localtime(&now);
335  TText* time_text = new TText
336  (
337  0.5,
338  0.20,
339  Form("%02d/%02d/%4d (mm/dd/yyy)", time_s->tm_mon + 1, time_s->tm_mday, time_s->tm_year + 1900)
340  );
341  time_text->SetName(Form("Intt_%s_Global_TimeText", option.c_str()));
342  time_text->SetTextAlign(22);
343  time_text->SetTextSize(DISP_TEXT_SIZE);
344  time_text->Draw();
345  }
346 
347  Options_t::const_iterator itr = OPTIONS.find(option);
348  if(itr == OPTIONS.end())return;
349  (*(itr->second.global))(option, client_hists);
350 
351  for(indexes.lyr = 0; indexes.lyr < INTT::LAYER; ++indexes.lyr)
352  {
353  y_lower = (INTT::LAYER - indexes.lyr - (1.0 - X_LABEL_FRAC)) / INTT::LAYER * (1.0 - TOP_FRAC - DISP_FRAC) + DISP_FRAC;
354  y_upper = (INTT::LAYER - indexes.lyr - 0.0) / INTT::LAYER * (1.0 - TOP_FRAC - DISP_FRAC) + DISP_FRAC;
355 
356  name = Form("Intt_%s_Global_HistPad_%d", option.c_str(), indexes.lyr);
357  hist_pad = (TPad*)gROOT->FindObject(name.c_str());
358  if(!hist_pad)
359  {
360  hist_pad = new TPad
361  (
362  name.c_str(),
363  name.c_str(),
364  x_lower,
365  y_lower,
366  x_upper,
367  y_upper
368  );
369  DrawPad(cnvs, hist_pad);
370  }
371 
372  hist_pad->cd();
373  client_hists[indexes.lyr]->DrawCopy("COLZ");
374 
375  name = Form("Intt_%s_Global_GridPad_%d", option.c_str(), indexes.lyr);
376  grid_pad = (TPad*)gROOT->FindObject(name.c_str());
377  if(!grid_pad)
378  {
379  grid_pad = new TPad
380  (
381  name.c_str(),
382  name.c_str(),
383  x_lower,
384  y_lower,
385  x_upper,
386  y_upper
387  );
388  DrawPad(cnvs, grid_pad);
389 
390  int i;
391  double temp;
392 
393  for(i = 0; i < 2 * INTT::LADDER[indexes.lyr] + 1; ++i)
394  {
395  temp = L_MARGIN + (i / 2.0) * (1.0 - L_MARGIN - R_MARGIN) / INTT::LADDER[indexes.lyr];
396 
397  TLine* line = new TLine(temp, B_MARGIN, temp, 1.0 - T_MARGIN);
398  line->SetLineStyle((i % 2) ? 3 : 1);
399  line->SetLineWidth((i % 2) ? 1 : 2);
400  line->Draw();
401  }
402 
403  for(i = 0; i < INTT::CHIP + 1; ++i)
404  {
405  temp = B_MARGIN + i * (1.0 - T_MARGIN - B_MARGIN) / INTT::CHIP;
406 
407  TLine* line = new TLine(L_MARGIN, temp, 1.0 - R_MARGIN, temp);
408  line->SetLineStyle((i % (INTT::CHIP / 2)) ? 3 : 1);
409  line->SetLineWidth((i % (INTT::CHIP / 2)) ? 1 : 2);
410  line->Draw();
411  }
412  }
413 
414  name = Form("Intt_%s_Global_YLblPad_%d", option.c_str(), indexes.lyr);
415  ylbl_pad = (TPad*)gROOT->FindObject(name.c_str());
416  if(!ylbl_pad)
417  {
418  ylbl_pad = new TPad
419  (
420  name.c_str(),
421  name.c_str(),
422  x_lower - Y_LABEL_FRAC,
423  y_lower,
424  x_lower,
425  y_upper
426  );
427  DrawPad(cnvs, ylbl_pad);
428 
429  TText* label = new TText
430  (
431  0.25,
432  0.5,
433  Form("B%01dL%01d", indexes.lyr / 2, indexes.lyr % 2)
434  );
435  label->SetTextSize(Y_LABEL_TEXT_SIZE);
436  label->SetTextAlign(22);
437  label->SetTextAngle(90);
438  label->Draw();
439 
440  int i = 0;
441  for(i = 0; i < INTT::ARM; ++i)
442  {
443  label = new TText
444  (
445  0.75,
446  0.25 + 0.5 * i,
447  Form("%s", i ? "North" : "South")
448  );
449  label->SetTextSize(Y_LABEL_TEXT_SIZE / 2.0);
450  label->SetTextAlign(22);
451  label->SetTextAngle(90);
452  label->Draw();
453  }
454  }
455 
456  name = Form("Intt_%s_Global_XLblPad_%d", option.c_str(), indexes.lyr);
457  xlbl_pad = (TPad*)gROOT->FindObject(name.c_str());
458  if(!xlbl_pad)
459  {
460  xlbl_pad = new TPad
461  (
462  name.c_str(),
463  name.c_str(),
464  x_lower,
465  y_lower - X_LABEL_FRAC / INTT::LAYER * (1.0 - TOP_FRAC - DISP_FRAC),
466  x_upper,
467  y_lower
468  );
469  DrawPad(cnvs, xlbl_pad);
470 
471  int i;
472  double temp;
473 
474  for(i = 0; i < INTT::LADDER[indexes.lyr]; ++i)
475  {
476  temp = L_MARGIN + (i + 0.5) * (1.0 - L_MARGIN - R_MARGIN) / INTT::LADDER[indexes.lyr];
477  TText* label = new TText
478  (
479  temp,
480  0.75,
481  Form("L%02d", i)
482  );
483  label->SetTextSize(X_LABEL_TEXT_SIZE);
484  label->SetTextAlign(22);
485  label->Draw();
486  }
487  }
488 
489  name = Form("Intt_%s_Global_ExecPad_%d", option.c_str(), indexes.lyr);
490  exec_pad = (TPad*)gROOT->FindObject(name.c_str());
491  if(!exec_pad)
492  {
493  exec_pad = new TPad
494  (
495  name.c_str(),
496  name.c_str(),
497  x_lower + (x_upper - x_lower) * L_MARGIN,
498  y_lower + (y_upper - y_lower) * B_MARGIN,
499  x_upper - (x_upper - x_lower) * R_MARGIN,
500  y_upper - (y_upper - y_lower) * T_MARGIN
501  );
502  DrawPad(cnvs, exec_pad);
503  exec_pad->AddExec
504  (
505  Form("Intt_%s_Global_Exec_%d",option.c_str(), indexes.lyr),
506  Form("InttMonDraw::InttGlobalChipExec(\"%s\", %d)", option.c_str(), indexes.lyr)
507  );
508  }
509  }
510 
511  cnvs->Show();
512  cnvs->SetEditable(0);
513 }
514 
516 {
517  int bin_x = gPad->AbsPixeltoX(gPad->GetEventX()) * (2 * INTT::LADDER[layer]);
518  int bin_y = gPad->AbsPixeltoY(gPad->GetEventY()) * (INTT::CHIP);
520 
521  if(bin_x < 0)bin_x = 0;
522  if(bin_y < 0)bin_y = 0;
523 
524  if(bin_x >= 2 * INTT::LADDER[layer])bin_x = 2 * INTT::LADDER[layer] - 1;
525  if(bin_y >= INTT::CHIP)bin_y = INTT::CHIP - 1;
526 
527  INTT::Indexes_s indexes;
528  indexes.lyr = layer;
529  INTT::GetIndexesFromGlobalChipBinXY(bin_x, bin_y, indexes);
530 
531  name = Form("Intt_%s_Global_DispText", option.c_str());
532  TText* disp_text = (TText*)gROOT->FindObject(name.c_str());
533  if(disp_text)disp_text->SetTitle(Form("Layer: %2d Ladder: %2d (%s) Chip: %2d", indexes.lyr + INTT::LAYER_OFFSET, indexes.ldr, indexes.arm ? "North" : "South", indexes.chp + INTT::CHIP_OFFSET));
534 
535  name = Form("Intt_%s_Global_DispPad", option.c_str());
536  TPad* disp_pad = (TPad*)gROOT->FindObject(name.c_str());
537  if(disp_pad)disp_pad->Update();
538 
539  if(gPad->GetEvent() != 11)return; //left click
540 
541  DrawLocalChannelMap(option, indexes);
542 }
543 
545 {
546  double x_lower = 0.0;
547  double y_lower = DISP_FRAC;
548  double x_upper = 1.0;
549  double y_upper = 1.0;
550 
552 
553  TStyle* style;
554  TCanvas* cnvs;
555  TPad* disp_pad;
556  TPad* hist_pad;
557  TPad* grid_pad;
558  TPad* exec_pad;
559 
560  TH2D* client_hists[1] = {nullptr};
561  Options_t::const_iterator itr = OPTIONS.find(option);
562  if(itr == OPTIONS.end())return;
563  (*(itr->second.local))(option, client_hists, indexes);
564 
565  name = Form("Intt_%s_Local_Style_Lyr%02d_Ldr%02d_Arm%02d_Chp%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm, indexes.chp);
566  style = (TStyle*)gROOT->FindObject(name.c_str());
567  if(!style)
568  {
569  style = new TStyle
570  (
571  name.c_str(),
572  name.c_str()
573  );
574  style->SetOptStat(0);
575  style->SetOptTitle(0);
576  //...
577  }
578  style->cd();
579 
580  name = Form("Intt_%s_Local_Canvas_Lyr%02d_Ldr%02d_Arm%02d_Chp%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm, indexes.chp);
581  cnvs = (TCanvas*)gROOT->FindObject(name.c_str());
582  if(!cnvs)
583  {
584  cnvs = new TCanvas
585  (
586  name.c_str(),
587  name.c_str(),
588  0,
589  0,
590  CNVS_WIDTH,
592  );
593  }
594 
595  name = Form("Intt_%s_Local_DispPad_Lyr%02d_Ldr%02d_Arm%02d_Chp%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm, indexes.chp);
596  disp_pad = (TPad*)gROOT->FindObject(name.c_str());
597  if(!disp_pad)
598  {
599  disp_pad = new TPad
600  (
601  name.c_str(),
602  name.c_str(),
603  x_lower,
604  0.0,
605  x_upper,
606  DISP_FRAC
607  );
608  DrawPad(cnvs, disp_pad);
609  TText* disp_text = new TText
610  (
611  0.5,
612  0.5,
613  Form("Channel: %3d ADC: %d", 0, 0)
614  );
615  disp_text->SetName(Form("Intt_%s_Local_DispText_Lyr%02d_Ldr%02d_Arm%02d_Chp%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm, indexes.chp));
616  disp_text->SetTextAlign(22);
617  disp_text->SetTextSize(DISP_TEXT_SIZE);
618  disp_text->Draw();
619  }
620 
621  name = Form("Intt_%s_Local_HistPad_Lyr%02d_Ldr%02d_Arm%02d_Chp%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm, indexes.chp);
622  hist_pad = (TPad*)gROOT->FindObject(name.c_str());
623  if(!hist_pad)
624  {
625  hist_pad = new TPad
626  (
627  name.c_str(),
628  name.c_str(),
629  x_lower,
630  y_lower,
631  x_upper,
632  y_upper
633  );
634  DrawPad(cnvs, hist_pad);
635  }
636 
637  hist_pad->cd();
638  if(client_hists[0])
639  {
640  client_hists[0]->DrawCopy("COLZ");
641  delete client_hists[0];
642  }
643 
644  name = Form("Intt_%s_Local_GridPad_%d", option.c_str(), indexes.lyr);
645  grid_pad = (TPad*)gROOT->FindObject(name.c_str());
646  if(!grid_pad)
647  {
648  grid_pad = new TPad
649  (
650  name.c_str(),
651  name.c_str(),
652  x_lower,
653  y_lower,
654  x_upper,
655  y_upper
656  );
657  DrawPad(cnvs, grid_pad);
658 
659  int i;
660  double temp;
661 
662  for(i = 0; i < INTT::CHANNEL + 1; ++i)
663  {
664  temp = L_MARGIN + i * (1.0 - L_MARGIN - R_MARGIN) / INTT::CHANNEL;
665 
666  TLine* line = new TLine(temp, B_MARGIN, temp, 1.0 - T_MARGIN);
667  line->SetLineStyle(3);
668  line->SetLineWidth(1);
669  line->Draw();
670  }
671 
672  for(i = 0; i < INTT::ADC + 1; ++i)
673  {
674  temp = B_MARGIN + i * (1.0 - T_MARGIN - B_MARGIN) / INTT::ADC;
675 
676  TLine* line = new TLine(L_MARGIN, temp, 1.0 - R_MARGIN, temp);
677  line->SetLineStyle(3);
678  line->SetLineWidth(1);
679  line->Draw();
680  }
681  }
682 
683  name = Form("Intt_%s_Local_ExecPad_Lyr%02d_Ldr%02d_Arm%02d_Chp%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm, indexes.chp);
684  exec_pad = (TPad*)gROOT->FindObject(name.c_str());
685  if(!exec_pad)
686  {
687  exec_pad = new TPad
688  (
689  name.c_str(),
690  name.c_str(),
691  x_lower + (x_upper - x_lower) * L_MARGIN,
692  y_lower + (y_upper - y_lower) * B_MARGIN,
693  x_upper - (x_upper - x_lower) * R_MARGIN,
694  y_upper - (y_upper - y_lower) * T_MARGIN
695  );
696  DrawPad(cnvs, exec_pad);
697  exec_pad->AddExec
698  (
699  Form("Intt_%s_Local_Exec_Lyr%02d_Ldr%02d_Arm%02d_Chp%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm, indexes.chp),
700  Form("InttMonDraw::InttLocalChannelExec(\"%s\", %d, %d, %d, %d)", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm, indexes.chp)
701  );
702  }
703 }
704 
705 void InttMonDraw::InttLocalChannelExec(const std::string& option, int layer, int ladder, int northsouth, int chip)
706 {
707  int bin_x = gPad->AbsPixeltoX(gPad->GetEventX()) * INTT::CHANNEL;
708  int bin_y = gPad->AbsPixeltoY(gPad->GetEventY()) * INTT::ADC;
710 
711  if(bin_x < 0)bin_x = 0;
712  if(bin_y < 0)bin_y = 0;
713 
714  if(bin_x >= INTT::CHANNEL - 1)bin_x = INTT::CHANNEL - 1;
715  if(bin_y >= INTT::ADC - 1)bin_y = INTT::ADC - 1;
716 
717  INTT::Indexes_s indexes;
718  indexes.lyr = layer;
719  indexes.ldr = ladder;
720  indexes.arm = northsouth;
721  indexes.chp = chip;
722  INTT::GetIndexesFromLocalChannelBinXY(bin_x, bin_y, indexes);
723 
724  name = Form("Intt_%s_Local_DispText_Lyr%02d_Ldr%02d_Arm%02d_Chp%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm, indexes.chp);
725  TText* disp_text = (TText*)gROOT->FindObject(name.c_str());
726  if(disp_text)disp_text->SetTitle(Form("Channel: %3d ADC: %d", indexes.chn, indexes.adc));
727 
728  name = Form("Intt_%s_Local_DispPad_Lyr%02d_Ldr%02d_Arm%02d_Chp%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm, indexes.chp);
729  TPad* disp_pad = (TPad*)gROOT->FindObject(name.c_str());
730  if(disp_pad)disp_pad->Update();
731 }
732 
733 //GlobalLadder-Chip idiom
735 {
736  DrawGlobalLadderMap(option);
737 }
738 
740 {
741  double x_lower = KEY_FRAC + Y_LABEL_FRAC;
742  double y_lower = 0.0;
743  double x_upper = 1.0;
744  double y_upper = 1.0;
745 
747  struct INTT::Indexes_s indexes;
748 
749  TStyle* style;
750  TCanvas* cnvs;
751  TPad* disp_pad;
752  TPad* hist_pad;
753  TPad* grid_pad;
754  TPad* ylbl_pad;
755  TPad* xlbl_pad;
756  TPad* exec_pad;
757 
758  TH2D* client_hists[4] = {nullptr};
759 
760  name = Form("Intt_%s_Global_Style", option.c_str());
761  style = (TStyle*)gROOT->FindObject(name.c_str());
762  if(!style)
763  {
764  style = new TStyle
765  (
766  name.c_str(),
767  name.c_str()
768  );
769  style->SetOptStat(0);
770  style->SetOptTitle(0);
771  //...
772  }
773  style->cd();
774 
775  name = Form("Intt_%s_Global_Canvas", option.c_str());
776  cnvs = (TCanvas*)gROOT->FindObject(name.c_str());
777  if(!cnvs)
778  {
779  cnvs = new TCanvas
780  (
781  name.c_str(),
782  name.c_str(),
783  0,
784  0,
785  CNVS_WIDTH,
787  );
788  //cnvs->...
789  //...
790  }
791 
792  name = Form("Intt_%s_Global_DispPad", option.c_str());
793  disp_pad = (TPad*)gROOT->FindObject(name.c_str());
794  if(!disp_pad)
795  {
796  disp_pad = new TPad
797  (
798  name.c_str(),
799  name.c_str(),
800  x_lower,
801  0.0,
802  x_upper,
803  DISP_FRAC
804  );
805  DrawPad(cnvs, disp_pad);
806 
807  TText* disp_text = new TText
808  (
809  0.5,
810  0.80,
811  Form("Layer: %2d Ladder: %2d (%s)", INTT::LAYER_OFFSET, 0, "South")
812  );
813  disp_text->SetName(Form("Intt_%s_Global_DispText", option.c_str()));
814  disp_text->SetTextAlign(22);
815  disp_text->SetTextSize(DISP_TEXT_SIZE);
816  disp_text->Draw();
817 
819  TText* run_text = new TText
820  (
821  0.5,
822  0.50,
823  Form("Run: %08d", cl->RunNumber())
824  );
825  run_text->SetName(Form("Intt_%s_Global_RunText", option.c_str()));
826  run_text->SetTextAlign(22);
827  run_text->SetTextSize(DISP_TEXT_SIZE);
828  run_text->Draw();
829 
830  std::time_t now = std::time(nullptr);
831  struct std::tm* time_s = std::localtime(&now);
832  TText* time_text = new TText
833  (
834  0.5,
835  0.20,
836  Form("%02d/%02d/%4d (mm/dd/yyy)", time_s->tm_mon + 1, time_s->tm_mday, time_s->tm_year + 1900)
837  );
838  time_text->SetName(Form("Intt_%s_Global_TimeText", option.c_str()));
839  time_text->SetTextAlign(22);
840  time_text->SetTextSize(DISP_TEXT_SIZE);
841  time_text->Draw();
842  }
843 
844  Options_t::const_iterator itr = OPTIONS.find(option);
845  if(itr == OPTIONS.end())return;
846  (*(itr->second.global))(option, client_hists);
847 
848  for(indexes.lyr = 0; indexes.lyr < INTT::LAYER; ++indexes.lyr)
849  {
850  y_lower = (INTT::LAYER - indexes.lyr - (1.0 - X_LABEL_FRAC)) / INTT::LAYER * (1.0 - TOP_FRAC - DISP_FRAC) + DISP_FRAC;
851  y_upper = (INTT::LAYER - indexes.lyr - 0.0) / INTT::LAYER * (1.0 - TOP_FRAC - DISP_FRAC) + DISP_FRAC;
852 
853  name = Form("Intt_%s_Global_HistPad_%d", option.c_str(), indexes.lyr);
854  hist_pad = (TPad*)gROOT->FindObject(name.c_str());
855  if(!hist_pad)
856  {
857  hist_pad = new TPad
858  (
859  name.c_str(),
860  name.c_str(),
861  x_lower,
862  y_lower,
863  x_upper,
864  y_upper
865  );
866  DrawPad(cnvs, hist_pad);
867  }
868 
869  hist_pad->cd();
870  client_hists[indexes.lyr]->DrawCopy("COL");
871 
872  name = Form("Intt_%s_Global_GridPad_%d", option.c_str(), indexes.lyr);
873  grid_pad = (TPad*)gROOT->FindObject(name.c_str());
874  if(!grid_pad)
875  {
876  grid_pad = new TPad
877  (
878  name.c_str(),
879  name.c_str(),
880  x_lower,
881  y_lower,
882  x_upper,
883  y_upper
884  );
885  DrawPad(cnvs, grid_pad);
886 
887  int i;
888  double temp;
889 
890  for(i = 0; i < INTT::LADDER[indexes.lyr] + 1; ++i)
891  {
892  temp = L_MARGIN + i * (1.0 - L_MARGIN - R_MARGIN) / INTT::LADDER[indexes.lyr];
893  TLine* line = new TLine(temp, B_MARGIN, temp, 1.0 - T_MARGIN);
894  line->SetLineStyle(1);
895  line->SetLineWidth(2);
896  line->Draw();
897  }
898 
899  for(i = 0; i < 2; ++i)
900  {
901  temp = B_MARGIN + i * (1.0 - T_MARGIN - B_MARGIN) / 2;
902  TLine* line = new TLine(L_MARGIN, temp, 1.0 - R_MARGIN, temp);
903  line->SetLineStyle(1);
904  line->SetLineWidth(2);
905  line->Draw();
906  }
907  }
908 
909  name = Form("Intt_%s_Global_YLblPad_%d", option.c_str(), indexes.lyr);
910  ylbl_pad = (TPad*)gROOT->FindObject(name.c_str());
911  if(!ylbl_pad)
912  {
913  ylbl_pad = new TPad
914  (
915  name.c_str(),
916  name.c_str(),
917  x_lower - Y_LABEL_FRAC,
918  y_lower,
919  x_lower,
920  y_upper
921  );
922  DrawPad(cnvs, ylbl_pad);
923 
924  TText* label = new TText
925  (
926  0.25,
927  0.5,
928  Form("B%01dL%01d", indexes.lyr / 2, indexes.lyr % 2)
929  );
930  label->SetTextSize(Y_LABEL_TEXT_SIZE);
931  label->SetTextAlign(22);
932  label->SetTextAngle(90);
933  label->Draw();
934 
935  int i = 0;
936  for(i = 0; i < INTT::ARM; ++i)
937  {
938  label = new TText
939  (
940  0.75,
941  0.25 + 0.5 * i,
942  Form("%s", i ? "North" : "South")
943  );
944  label->SetTextSize(Y_LABEL_TEXT_SIZE / 2.0);
945  label->SetTextAlign(22);
946  label->SetTextAngle(90);
947  label->Draw();
948  }
949  }
950 
951  name = Form("Intt_%s_Global_XLblPad_%d", option.c_str(), indexes.lyr);
952  xlbl_pad = (TPad*)gROOT->FindObject(name.c_str());
953  if(!xlbl_pad)
954  {
955  xlbl_pad = new TPad
956  (
957  name.c_str(),
958  name.c_str(),
959  x_lower,
960  y_lower - X_LABEL_FRAC / INTT::LAYER * (1.0 - TOP_FRAC - DISP_FRAC),
961  x_upper,
962  y_lower
963  );
964  DrawPad(cnvs, xlbl_pad);
965 
966  int i;
967  double temp;
968 
969  for(i = 0; i < INTT::LADDER[indexes.lyr]; ++i)
970  {
971  temp = L_MARGIN + (i + 0.5) * (1.0 - L_MARGIN - R_MARGIN) / INTT::LADDER[indexes.lyr];
972  TText* label = new TText
973  (
974  temp,
975  0.75,
976  Form("L%02d", i)
977  );
978  label->SetTextSize(X_LABEL_TEXT_SIZE);
979  label->SetTextAlign(22);
980  label->Draw();
981  }
982  }
983 
984  name = Form("Intt_%s_Global_ExecPad_%d", option.c_str(), indexes.lyr);
985  exec_pad = (TPad*)gROOT->FindObject(name.c_str());
986  if(!exec_pad)
987  {
988  exec_pad = new TPad
989  (
990  name.c_str(),
991  name.c_str(),
992  x_lower + (x_upper - x_lower) * L_MARGIN,
993  y_lower + (y_upper - y_lower) * B_MARGIN,
994  x_upper - (x_upper - x_lower) * R_MARGIN,
995  y_upper - (y_upper - y_lower) * T_MARGIN
996  );
997  DrawPad(cnvs, exec_pad);
998  exec_pad->AddExec
999  (
1000  Form("Intt_%s_Global_Exec_%d",option.c_str(), indexes.lyr),
1001  Form("InttMonDraw::InttGlobalLadderExec(\"%s\", %d)", option.c_str(), indexes.lyr)
1002  );
1003  }
1004  }
1005 
1006  cnvs->Show();
1007  cnvs->SetEditable(0);
1008 }
1009 
1011 {
1012  int bin_x = gPad->AbsPixeltoX(gPad->GetEventX()) * INTT::LADDER[layer];
1013  int bin_y = gPad->AbsPixeltoY(gPad->GetEventY()) * INTT::ARM;
1014  std::string name;
1015 
1016  if(bin_x < 0)bin_x = 0;
1017  if(bin_y < 0)bin_y = 0;
1018 
1019  if(bin_x >= INTT::LADDER[layer])bin_x = INTT::LADDER[layer] - 1;
1020  if(bin_y >= INTT::ARM)bin_y = INTT::ARM - 1;
1021 
1022  INTT::Indexes_s indexes;
1023  indexes.lyr = layer;
1024  INTT::GetIndexesFromGlobalLadderBinXY(bin_x, bin_y, indexes);
1025 
1026  name = Form("Intt_%s_Global_DispText", option.c_str());
1027  TText* disp_text = (TText*)gROOT->FindObject(name.c_str());
1028  if(disp_text)disp_text->SetTitle(Form("Layer: %2d Ladder: %2d (%s)", indexes.lyr + INTT::LAYER_OFFSET, indexes.ldr, indexes.arm ? "North" : "South"));
1029 
1030  name = Form("Intt_%s_Global_DispPad", option.c_str());
1031  TPad* disp_pad = (TPad*)gROOT->FindObject(name.c_str());
1032  if(disp_pad)disp_pad->Update();
1033 
1034  if(gPad->GetEvent() != 11)return; //left click
1035 
1036  DrawLocalChipMap(option, indexes);
1037 }
1038 
1039 void InttMonDraw::DrawLocalChipMap(std::string const& option, struct INTT::Indexes_s indexes)
1040 {
1041  double x_lower = 0.0;
1042  double y_lower = DISP_FRAC;
1043  double x_upper = 1.0;
1044  double y_upper = 1.0;
1045 
1046  std::string name;
1047 
1048  TStyle* style;
1049  TCanvas* cnvs;
1050  TPad* disp_pad;
1051  TPad* hist_pad;
1052  TPad* grid_pad;
1053  TPad* exec_pad;
1054 
1055  TH2D* client_hists[1] = {nullptr};
1056  Options_t::const_iterator itr = OPTIONS.find(option);
1057  if(itr == OPTIONS.end())return;
1058  (*(itr->second.local))(option, client_hists, indexes);
1059 
1060  name = Form("Intt_%s_Local_Style_Lyr%02d_Ldr%02d_Arm%02d_Chp%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm, indexes.chp);
1061  style = (TStyle*)gROOT->FindObject(name.c_str());
1062  if(!style)
1063  {
1064  style = new TStyle
1065  (
1066  name.c_str(),
1067  name.c_str()
1068  );
1069  style->SetOptStat(0);
1070  style->SetOptTitle(0);
1071  //...
1072  }
1073  style->cd();
1074 
1075  name = Form("Intt_%s_Local_Canvas_Lyr%02d_Ldr%02d_Arm%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm);
1076  cnvs = (TCanvas*)gROOT->FindObject(name.c_str());
1077  if(!cnvs)
1078  {
1079  cnvs = new TCanvas
1080  (
1081  name.c_str(),
1082  name.c_str(),
1083  0,
1084  0,
1085  CNVS_WIDTH,
1086  CNVS_HEIGHT
1087  );
1088  }
1089 
1090  name = Form("Intt_%s_Local_DispPad_Lyr%02d_Ldr%02d_Arm%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm);
1091  disp_pad = (TPad*)gROOT->FindObject(name.c_str());
1092  if(!disp_pad)
1093  {
1094  disp_pad = new TPad
1095  (
1096  name.c_str(),
1097  name.c_str(),
1098  x_lower,
1099  0.0,
1100  x_upper,
1101  DISP_FRAC
1102  );
1103  DrawPad(cnvs, disp_pad);
1104  TText* disp_text = new TText
1105  (
1106  0.5,
1107  0.5,
1108  Form("(%s) Chip: %2d Channel: %3d", "South", 0, INTT::CHIP_OFFSET)
1109  );
1110  disp_text->SetName(Form("Intt_%s_Local_DispText_Lyr%02d_Ldr%02d_Arm%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm));
1111  disp_text->SetTextAlign(22);
1112  disp_text->SetTextSize(DISP_TEXT_SIZE);
1113  disp_text->Draw();
1114  }
1115 
1116  name = Form("Intt_%s_Local_HistPad_Lyr%02d_Ldr%02d_Arm%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm);
1117  hist_pad = (TPad*)gROOT->FindObject(name.c_str());
1118  if(!hist_pad)
1119  {
1120  hist_pad = new TPad
1121  (
1122  name.c_str(),
1123  name.c_str(),
1124  x_lower,
1125  y_lower,
1126  x_upper,
1127  y_upper
1128  );
1129  DrawPad(cnvs, hist_pad);
1130  }
1131 
1132  hist_pad->cd();
1133  if(client_hists[0])
1134  {
1135  client_hists[0]->DrawCopy("COLZ");
1136  delete client_hists[0];
1137  }
1138 
1139  name = Form("Intt_%s_Local_GridPad_Lyr%d_Ldr%02d_Arm%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm);
1140  grid_pad = (TPad*)gROOT->FindObject(name.c_str());
1141  if(!grid_pad)
1142  {
1143  grid_pad = new TPad
1144  (
1145  name.c_str(),
1146  name.c_str(),
1147  x_lower,
1148  y_lower,
1149  x_upper,
1150  y_upper
1151  );
1152  DrawPad(cnvs, grid_pad);
1153 
1154  int i;
1155  double temp;
1156 
1157  for(i = 0; i < 2 * INTT::CHANNEL + 1; ++i)
1158  {
1159  temp = L_MARGIN + (i / 2.0) * (1.0 - R_MARGIN - L_MARGIN) / INTT::CHANNEL;
1160 
1161  TLine* line = new TLine(temp, B_MARGIN, temp, 1.0 - T_MARGIN);
1162  line->SetLineStyle(i == INTT::CHANNEL ? 1 : 3);
1163  line->SetLineWidth(i == INTT::CHANNEL ? 2 : 1);
1164  line->Draw();
1165  }
1166 
1167  for(i = 0; i < INTT::CHIP / 2 + 1; ++i)
1168  {
1169  temp = B_MARGIN + 2 * i * (1.0 - T_MARGIN - B_MARGIN) / INTT::CHIP;
1170 
1171  TLine* line = new TLine(L_MARGIN, temp, 1.0 - R_MARGIN, temp);
1172  line->SetLineStyle(i == INTT::CHIP / 2 ? 1 : 3);
1173  line->SetLineWidth(i == INTT::CHIP / 2 ? 2 : 1);
1174  line->Draw();
1175  }
1176  }
1177 
1178  name = Form("Intt_%s_Local_ExecPad_Lyr%02d_Ldr%02d_Arm%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm);
1179  exec_pad = (TPad*)gROOT->FindObject(name.c_str());
1180  if(!exec_pad)
1181  {
1182  exec_pad = new TPad
1183  (
1184  name.c_str(),
1185  name.c_str(),
1186  x_lower + (x_upper - x_lower) * L_MARGIN,
1187  y_lower + (y_upper - y_lower) * B_MARGIN,
1188  x_upper - (x_upper - x_lower) * R_MARGIN,
1189  y_upper - (y_upper - y_lower) * T_MARGIN
1190  );
1191  DrawPad(cnvs, exec_pad);
1192  exec_pad->AddExec
1193  (
1194  Form("Intt_%s_Local_Exec_Lyr%02d_Ldr%02d_Arm%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm),
1195  Form("InttMonDraw::InttLocalChipExec(\"%s\", %d, %d, %d)", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm)
1196  );
1197  }
1198 }
1199 
1200 void InttMonDraw::InttLocalChipExec(const std::string& option, int layer, int ladder, int arm)
1201 {
1202  int bin_x = gPad->AbsPixeltoX(gPad->GetEventX()) * 2 * INTT::CHANNEL;
1203  int bin_y = gPad->AbsPixeltoY(gPad->GetEventY()) * INTT::CHIP / 2;
1204  std::string name;
1205 
1206  if(bin_x < 0)bin_x = 0;
1207  if(bin_y < 0)bin_y = 0;
1208 
1209  if(bin_x >= 2 * INTT::CHANNEL - 1)bin_x = 2 * INTT::CHANNEL - 1;
1210  if(bin_y >= INTT::CHIP / 2 - 1)bin_y = INTT::CHIP / 2 - 1;
1211 
1212  INTT::Indexes_s indexes;
1213  indexes.lyr = layer;
1214  indexes.ldr = ladder;
1215  indexes.arm = arm;
1216  INTT::GetIndexesFromLocalChipBinXY(bin_x, bin_y, indexes);
1217  //indexes.chp = indexes.arm * (INTT::CHIP / 2 - 1) - (2 * indexes.arm - 1) * bin_y + ((indexes.arm + bin_x / INTT::CHANNEL) % 2) * (INTT::CHIP / 2);
1218  //indexes.chn = bin_x % INTT::CHANNEL;
1219 
1220  name = Form("Intt_%s_Local_DispText_Lyr%02d_Ldr%02d_Arm%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm);
1221  TText* disp_text = (TText*)gROOT->FindObject(name.c_str());
1222  if(disp_text)disp_text->SetTitle(Form("Chip: %2d Channel: %3d", indexes.chp + INTT::CHIP_OFFSET, indexes.chn));
1223 
1224  name = Form("Intt_%s_Local_DispPad_Lyr%02d_Ldr%02d_Arm%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm);
1225  TPad* disp_pad = (TPad*)gROOT->FindObject(name.c_str());
1226  if(disp_pad)disp_pad->Update();
1227 }
1228 
1229 //idiom specific methods/implementations
1230 //GlobalChip/LocalChannel methods/implementations
1231 void InttMonDraw::PrepGlobalChipHists_Hitmap(std::string const& option, TH2D** client_hists)
1232 {
1233  int bin;
1234  double temp;
1235  double min = DBL_MAX;
1236  double max = -DBL_MAX;
1237  int prev_felix = -1;
1238  int felix = 0;
1239  int felix_channel = 0;
1240  struct INTT_Felix::Ladder_s ldr_struct;
1241 
1242  int bin_x;
1243  int bin_y;
1244  std::string name;
1245 
1246  struct INTT::Indexes_s indexes;
1247 
1249  TH1D* server_hist = nullptr;
1250 
1251  for(indexes.lyr = 0; indexes.lyr < INTT::LAYER; ++indexes.lyr)
1252  {
1253  name = Form("Intt_%s_Global_Hist_%d", option.c_str(), indexes.lyr);
1254  client_hists[indexes.lyr] = (TH2D*)gROOT->FindObject(name.c_str());
1255  if(!client_hists[indexes.lyr])
1256  {
1257  client_hists[indexes.lyr] = new TH2D
1258  (
1259  name.c_str(),
1260  name.c_str(),
1261  2 * INTT::LADDER[indexes.lyr],
1262  -0.5,
1263  2 * INTT::LADDER[indexes.lyr] - 0.5,
1264  INTT::CHIP,
1265  -0.5,
1266  INTT::CHIP - 0.5
1267  );
1268  client_hists[indexes.lyr]->GetXaxis()->SetNdivisions(INTT::LADDER[indexes.lyr], true);
1269  client_hists[indexes.lyr]->GetYaxis()->SetNdivisions(INTT::CHIP, true);
1270 
1271  client_hists[indexes.lyr]->GetXaxis()->SetLabelSize(0.0);
1272  client_hists[indexes.lyr]->GetYaxis()->SetLabelSize(0.0);
1273 
1274  client_hists[indexes.lyr]->GetXaxis()->SetTickLength(0.0);
1275  client_hists[indexes.lyr]->GetYaxis()->SetTickLength(0.0);
1276  }
1277 
1278  client_hists[indexes.lyr]->Reset();
1279  }
1280 
1281  indexes.lyr = 0;
1282  indexes.ldr = 0;
1283  indexes.arm = 0;
1284  indexes.chp = 0;
1285  indexes.chn = 0;
1286  indexes.adc = 0;
1287 
1288  prev_felix = -1;
1289  felix = 0;
1290  felix_channel = 0;
1291  while(felix < INTT::FELIX)
1292  {
1293  if(prev_felix != felix)
1294  {
1295  server_hist = (TH1D*)cl->getHisto(Form("INTTMON_%d", felix), "InttMap");
1296  prev_felix = felix;
1297  }
1298 
1299  INTT_Felix::FelixMap(felix, felix_channel, ldr_struct);
1300  indexes.lyr = ldr_struct.barrel * 2 + ldr_struct.layer;
1301  indexes.ldr = ldr_struct.ladder;
1302  indexes.arm = felix / 4;
1303  INTT::GetGlobalChipBinXYFromIndexes(bin_x, bin_y, indexes);
1304 
1305  //for debugging
1306  //if(server_hist)temp = 0;
1307  //temp = indexes.chp + 1;
1308  //bin = client_hists[indexes.lyr]->GetBin(bin_x, bin_y);
1309  //client_hists[indexes.lyr]->SetBinContent(bin, temp);
1310 
1311  //actual implementation
1312  INTT::GetFelixBinFromIndexes(bin, felix_channel, indexes);
1313  temp = server_hist ? server_hist->GetBinContent(bin) : 0;
1314  bin = client_hists[indexes.lyr]->GetBin(bin_x, bin_y);
1315  temp += client_hists[indexes.lyr]->GetBinContent(bin);
1316  client_hists[indexes.lyr]->SetBinContent(bin, temp);
1317 
1318  ++indexes.adc;
1319  if(indexes.adc < INTT::ADC)continue;
1320  indexes.adc = 0;
1321 
1322  ++indexes.chn;
1323  if(indexes.chn < INTT::CHANNEL)continue;
1324  indexes.chn = 0;
1325 
1326  ++indexes.chp;
1327  if(indexes.chp < INTT::CHIP)continue;
1328  indexes.chp = 0;
1329 
1330  ++felix_channel;
1331  if(felix_channel < INTT::FELIX_CHANNEL)continue;
1332  felix_channel = 0;
1333 
1334  ++felix;
1335  }
1336 
1337  for(indexes.lyr = 0; indexes.lyr < INTT::LAYER; ++indexes.lyr)
1338  {
1339  if(client_hists[indexes.lyr]->GetMinimum() < min)min = client_hists[indexes.lyr]->GetMinimum();
1340  if(client_hists[indexes.lyr]->GetMaximum() > max)max = client_hists[indexes.lyr]->GetMaximum();
1341  }
1342 
1343  for(indexes.lyr = 0; indexes.lyr < INTT::LAYER; ++indexes.lyr)
1344  {
1345  client_hists[indexes.lyr]->SetMinimum(min);
1346  client_hists[indexes.lyr]->SetMaximum(max);
1347  }
1348 }
1349 
1350 void InttMonDraw::PrepLocalChannelHists_Hitmap(std::string const& option, TH2D** client_hists, struct INTT::Indexes_s& indexes)
1351 {
1352  int bin;
1353  double temp;
1354  int prev_felix = -1;
1355  int felix = 0;
1356  int felix_channel = 0;
1357  struct INTT_Felix::Ladder_s ldr_struct;
1358 
1359  int bin_x;
1360  int bin_y;
1361  std::string name;
1362 
1364  TH1D* server_hist = nullptr;
1365 
1366  name = Form("Intt_%s_Local_Hist_Lyr%02d_Ldr%02d_Arm%02d_Chp%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm, indexes.chp);
1367  client_hists[0] = (TH2D*)gROOT->FindObject(name.c_str());
1368  if(!client_hists[0])
1369  {
1370  client_hists[0] = new TH2D
1371  (
1372  name.c_str(),
1373  name.c_str(),
1374  INTT::CHANNEL,
1375  -0.5,
1376  INTT::CHANNEL - 0.5,
1377  INTT::ADC,
1378  -0.5,
1379  INTT::ADC - 0.5
1380  );
1381 
1382  client_hists[0]->GetXaxis()->SetNdivisions(INTT::CHANNEL, true);
1383  client_hists[0]->GetYaxis()->SetNdivisions(INTT::ADC, true);
1384 
1385  client_hists[0]->GetXaxis()->SetLabelSize(0.0);
1386  client_hists[0]->GetYaxis()->SetLabelSize(0.0);
1387 
1388  client_hists[0]->GetXaxis()->SetTickLength(0.0);
1389  client_hists[0]->GetYaxis()->SetTickLength(0.0);
1390  }
1391  client_hists[0]->Reset();
1392 
1393  indexes.chn = 0;
1394  indexes.adc = 0;
1395 
1396  prev_felix = -1;
1397  felix = 0;
1398  felix_channel = 0;
1399  while(felix < INTT::FELIX)
1400  {
1401  if(prev_felix != felix)
1402  {
1403  server_hist = (TH1D*)cl->getHisto(Form("INTTMON_%d", felix), "InttMap");
1404  prev_felix = felix;
1405  }
1406 
1407  INTT_Felix::FelixMap(felix, felix_channel, ldr_struct);
1408  if(2 * ldr_struct.barrel + ldr_struct.layer == indexes.lyr && ldr_struct.ladder == indexes.ldr && felix / 4 == indexes.arm)
1409  {
1410  INTT::GetLocalChannelBinXYFromIndexes(bin_x, bin_y, indexes);
1411 
1412  //for debugging
1413  //client_hist->SetBinContent(client_hist->GetBin(bin_x, bin_y), indexes.chn);
1414  //client_hist->SetBinContent(client_hist->GetBin(bin_x, bin_y), indexes.adc);
1415 
1416  INTT::GetFelixBinFromIndexes(bin, felix_channel, indexes);
1417  temp = server_hist ? server_hist->GetBinContent(bin) : 0;
1418  bin = client_hists[0]->GetBin(bin_x, bin_y);
1419  temp += client_hists[0]->GetBinContent(bin);
1420  client_hists[0]->SetBinContent(bin, temp);
1421  }
1422 
1423  ++indexes.adc;
1424  if(indexes.adc < INTT::ADC)continue;
1425  indexes.adc = 0;
1426 
1427  ++indexes.chn;
1428  if(indexes.chn < INTT::CHANNEL)continue;
1429  indexes.chn = 0;
1430 
1431  ++felix_channel;
1432  if(felix_channel < INTT::FELIX_CHANNEL)continue;
1433  felix_channel = 0;
1434 
1435  ++felix;
1436  }
1437 }
1438 
1439 void InttMonDraw::PrepGlobalChipHists_NLL(std::string const& option, TH2D** client_hists)
1440 {
1441  int bin;
1442  double temp;
1443  double min = DBL_MAX;
1444  double max = -DBL_MAX;
1445  int prev_felix = -1;
1446  int felix = 0;
1447  int felix_channel = 0;
1448  struct INTT_Felix::Ladder_s ldr_struct;
1449 
1450  int bin_x;
1451  int bin_y;
1452  std::string name;
1453 
1454  struct INTT::Indexes_s indexes;
1455  double adc_counts[INTT::ADC] = {0};
1456 
1458  TH1D* server_hist = nullptr;
1459 
1460  for(indexes.lyr = 0; indexes.lyr < INTT::LAYER; ++indexes.lyr)
1461  {
1462  name = Form("Intt_%s_Global_Hist_%d", option.c_str(), indexes.lyr);
1463  client_hists[indexes.lyr] = (TH2D*)gROOT->FindObject(name.c_str());
1464  if(!client_hists[indexes.lyr])
1465  {
1466  client_hists[indexes.lyr] = new TH2D
1467  (
1468  name.c_str(),
1469  name.c_str(),
1470  2 * INTT::LADDER[indexes.lyr],
1471  -0.5,
1472  2 * INTT::LADDER[indexes.lyr] - 0.5,
1473  INTT::CHIP,
1474  -0.5,
1475  INTT::CHIP - 0.5
1476  );
1477  client_hists[indexes.lyr]->GetXaxis()->SetNdivisions(INTT::LADDER[indexes.lyr], true);
1478  client_hists[indexes.lyr]->GetYaxis()->SetNdivisions(INTT::CHIP, true);
1479 
1480  client_hists[indexes.lyr]->GetXaxis()->SetLabelSize(0.0);
1481  client_hists[indexes.lyr]->GetYaxis()->SetLabelSize(0.0);
1482 
1483  client_hists[indexes.lyr]->GetXaxis()->SetTickLength(0.0);
1484  client_hists[indexes.lyr]->GetYaxis()->SetTickLength(0.0);
1485  }
1486 
1487  client_hists[indexes.lyr]->Reset();
1488  }
1489 
1490  indexes.lyr = 0;
1491  indexes.ldr = 0;
1492  indexes.arm = 0;
1493  indexes.chp = 0;
1494  indexes.chn = 0;
1495  indexes.adc = 0;
1496 
1497  prev_felix = -1;
1498  felix = 0;
1499  felix_channel = 0;
1500  while(felix < INTT::FELIX)
1501  {
1502  if(prev_felix != felix)
1503  {
1504  server_hist = (TH1D*)cl->getHisto(Form("INTTMON_%d", felix), "InttMap");
1505  prev_felix = felix;
1506  }
1507 
1508  INTT::GetFelixBinFromIndexes(bin, felix_channel, indexes);
1509  temp = server_hist ? server_hist->GetBinContent(bin) : 0;
1510  adc_counts[indexes.adc] += temp;
1511 
1512  ++indexes.adc;
1513  if(indexes.adc < INTT::ADC)continue;
1514  indexes.adc = 0;
1515 
1516  ++indexes.chn;
1517  if(indexes.chn < INTT::CHANNEL)continue;
1518  indexes.chn = 0;
1519 
1520  ++indexes.chp;
1521  if(indexes.chp < INTT::CHIP)continue;
1522  indexes.chp = 0;
1523 
1524  ++felix_channel;
1525  if(felix_channel < INTT::FELIX_CHANNEL)continue;
1526  felix_channel = 0;
1527 
1528  ++felix;
1529  }
1530 
1531  for(indexes.adc = 0; indexes.adc < INTT::ADC; ++indexes.adc)
1532  {
1533  adc_counts[indexes.adc] /= INTT::CHANNELS;
1534  }
1535 
1536  indexes.lyr = 0;
1537  indexes.ldr = 0;
1538  indexes.arm = 0;
1539  indexes.chp = 0;
1540  indexes.chn = 0;
1541  indexes.adc = 0;
1542 
1543  prev_felix = -1;
1544  felix = 0;
1545  felix_channel = 0;
1546  while(felix < INTT::FELIX)
1547  {
1548  if(prev_felix != felix)
1549  {
1550  server_hist = (TH1D*)cl->getHisto(Form("INTTMON_%d", felix), "InttMap");
1551  prev_felix = felix;
1552  }
1553 
1554  INTT_Felix::FelixMap(felix, felix_channel, ldr_struct);
1555  indexes.lyr = ldr_struct.barrel * 2 + ldr_struct.layer;
1556  indexes.ldr = ldr_struct.ladder;
1557  indexes.arm = felix / 4;
1558  INTT::GetGlobalChipBinXYFromIndexes(bin_x, bin_y, indexes);
1559 
1560  INTT::GetFelixBinFromIndexes(bin, felix_channel, indexes);
1561  temp = server_hist ? server_hist->GetBinContent(bin) : 0;
1562 
1563  //NLL of having temp counts from a poisson distribution with expectation adc_counts[indexes.adc]
1564  temp = adc_counts[indexes.adc] ? lgamma(temp + 1) - temp * log(adc_counts[indexes.adc]) + adc_counts[indexes.adc] : 0;
1565 
1566  bin = client_hists[indexes.lyr]->GetBin(bin_x, bin_y);
1567  temp += client_hists[indexes.lyr]->GetBinContent(bin);
1568  client_hists[indexes.lyr]->SetBinContent(bin, temp);
1569 
1570  ++indexes.adc;
1571  if(indexes.adc < INTT::ADC)continue;
1572  indexes.adc = 0;
1573 
1574  ++indexes.chn;
1575  if(indexes.chn < INTT::CHANNEL)continue;
1576  indexes.chn = 0;
1577 
1578  ++indexes.chp;
1579  if(indexes.chp < INTT::CHIP)continue;
1580  indexes.chp = 0;
1581 
1582  ++felix_channel;
1583  if(felix_channel < INTT::FELIX_CHANNEL)continue;
1584  felix_channel = 0;
1585 
1586  ++felix;
1587  }
1588 
1589  for(indexes.lyr = 0; indexes.lyr < INTT::LAYER; ++indexes.lyr)
1590  {
1591  if(client_hists[indexes.lyr]->GetMinimum() < min)min = client_hists[indexes.lyr]->GetMinimum();
1592  if(client_hists[indexes.lyr]->GetMaximum() > max)max = client_hists[indexes.lyr]->GetMaximum();
1593  }
1594 
1595  for(indexes.lyr = 0; indexes.lyr < INTT::LAYER; ++indexes.lyr)
1596  {
1597  client_hists[indexes.lyr]->SetMinimum(min);
1598  client_hists[indexes.lyr]->SetMaximum(max);
1599  }
1600 }
1601 
1602 //GlobalLadder/LocalChip methods/implementations
1603 void InttMonDraw::PrepGlobalLadderHists_Interface(std::string const& option, TH2D** client_hists)
1604 {
1605  struct INTT::Indexes_s indexes;
1606  std::string name;
1607 
1608  for(indexes.lyr = 0; indexes.lyr < INTT::LAYER; ++indexes.lyr)
1609  {
1610  name = Form("Intt_%s_Global_Hist_%d", option.c_str(), indexes.lyr);
1611  client_hists[indexes.lyr] = (TH2D*)gROOT->FindObject(name.c_str());
1612  if(!client_hists[indexes.lyr])
1613  {
1614  client_hists[indexes.lyr] = new TH2D
1615  (
1616  name.c_str(),
1617  name.c_str(),
1618  INTT::LADDER[indexes.lyr],
1619  -0.5,
1620  INTT::LADDER[indexes.lyr] - 0.5,
1621  INTT::ARM,
1622  -0.5,
1623  INTT::ARM - 0.5
1624  );
1625  client_hists[indexes.lyr]->GetXaxis()->SetNdivisions(INTT::LADDER[indexes.lyr], true);
1626  client_hists[indexes.lyr]->GetYaxis()->SetNdivisions(INTT::ARM, true);
1627 
1628  client_hists[indexes.lyr]->GetXaxis()->SetLabelSize(0.0);
1629  client_hists[indexes.lyr]->GetYaxis()->SetLabelSize(0.0);
1630 
1631  client_hists[indexes.lyr]->GetXaxis()->SetTickLength(0.0);
1632  client_hists[indexes.lyr]->GetYaxis()->SetTickLength(0.0);
1633 
1634  client_hists[indexes.lyr]->SetMinimum(-1.0);
1635  client_hists[indexes.lyr]->SetMaximum(20.0);
1636  }
1637 
1638  client_hists[indexes.lyr]->Reset();
1639 
1640  for(int n = 0; n < client_hists[indexes.lyr]->GetNcells(); ++n)
1641  {
1642  client_hists[indexes.lyr]->SetBinContent(n, 0);
1643  }
1644  }
1645 }
1646 
1647 void InttMonDraw::PrepLocalChipHists_Hitmap(std::string const& option, TH2D** client_hists, struct INTT::Indexes_s& indexes)
1648 {
1649  int bin;
1650  double temp;
1651  int prev_felix = -1;
1652  int felix = 0;
1653  int felix_channel = 0;
1654  struct INTT_Felix::Ladder_s ldr_struct;
1655 
1656  int bin_x;
1657  int bin_y;
1658  std::string name;
1659 
1661  TH1D* server_hist = nullptr;
1662 
1663  name = Form("Intt_%s_Local_ClientHist_Lyr%02d_Ldr%02d_Arm%02d", option.c_str(), indexes.lyr, indexes.ldr, indexes.arm);
1664  client_hists[0] = (TH2D*)gROOT->FindObject(name.c_str());
1665  if(!client_hists[0])
1666  {
1667  client_hists[0] = new TH2D
1668  (
1669  name.c_str(),
1670  name.c_str(),
1671  2 * INTT::CHANNEL,
1672  -0.5,
1673  2 * INTT::CHANNEL - 0.5,
1674  INTT::CHIP / 2,
1675  -0.5,
1676  INTT::CHIP / 2 - 0.5
1677  );
1678 
1679  client_hists[0]->GetXaxis()->SetNdivisions(2 * INTT::CHANNEL, true);
1680  client_hists[0]->GetYaxis()->SetNdivisions(INTT::CHIP / 2, true);
1681 
1682  client_hists[0]->GetXaxis()->SetLabelSize(0.0);
1683  client_hists[0]->GetYaxis()->SetLabelSize(0.0);
1684 
1685  client_hists[0]->GetXaxis()->SetTickLength(0.0);
1686  client_hists[0]->GetYaxis()->SetTickLength(0.0);
1687  }
1688 
1689  client_hists[0]->Reset();
1690 
1691  indexes.chp = 0;
1692  indexes.chn = 0;
1693  indexes.adc = 0;
1694 
1695  prev_felix = -1;
1696  felix = 0;
1697  felix_channel = 0;
1698  while(felix < INTT::FELIX)
1699  {
1700  if(prev_felix != felix)
1701  {
1702  server_hist = (TH1D*)cl->getHisto(Form("INTTMON_%d", felix), "InttMap");
1703  prev_felix = felix;
1704  }
1705 
1706  INTT_Felix::FelixMap(felix, felix_channel, ldr_struct);
1707  if(2 * ldr_struct.barrel + ldr_struct.layer == indexes.lyr && ldr_struct.ladder == indexes.ldr && felix / 4 == indexes.arm)
1708  {
1709  INTT::GetLocalChipBinXYFromIndexes(bin_x, bin_y, indexes);
1710 
1711  //for debugging
1712  //temp = server_hist ? server_hist->GetBinContent(bin) : 0;
1713  //client_hists[0]->SetBinContent(client_hists[0]->GetBin(bin_x, bin_y), indexes.chp);
1714 
1715  INTT::GetFelixBinFromIndexes(bin, felix_channel, indexes);
1716  temp = server_hist ? server_hist->GetBinContent(bin) : 0;
1717  INTT::GetLocalChipBinXYFromIndexes(bin_x, bin_y, indexes);
1718  bin = client_hists[0]->GetBin(bin_x, bin_y);
1719  temp += client_hists[0]->GetBinContent(bin);
1720  client_hists[0]->SetBinContent(bin, temp);
1721  }
1722 
1723  ++indexes.adc;
1724  if(indexes.adc < INTT::ADC)continue;
1725  indexes.adc = 0;
1726 
1727  ++indexes.chn;
1728  if(indexes.chn < INTT::CHANNEL)continue;
1729  indexes.chn = 0;
1730 
1731  ++indexes.chp;
1732  if(indexes.chp < INTT::CHIP)continue;
1733  indexes.chp = 0;
1734 
1735  ++felix_channel;
1736  if(felix_channel < INTT::FELIX_CHANNEL)continue;
1737  felix_channel = 0;
1738 
1739  ++felix;
1740  }
1741 }