HwDetLabel.cxx
Go to the documentation of this file.
2 #include <iostream>
3 #include "TH1.h"
4 #include "TLine.h"
5 #include "TText.h"
6 using namespace om;
7 
8 static const int gsNfebX = 16;
9 static const int gsNfebY = 4;
10 static const int gsNpixelX = 4;
11 static const int gsNpixelY = 8;
12 
13 HwDetLabel::HwDetLabel(bool show_feb_boundaries) :
14  fShowFEBBoundaries(show_feb_boundaries),
15  fNdiblock(0),
16  fNdcm(0)
17 { }
18 
19 //......................................................................
20 
21 void HwDetLabel::Config(const TH1* h)
22 {
23  int ndb = h->GetXaxis()->GetXmax()/gsNpixelX/gsNfebX;
24  int ndcm = h->GetYaxis()->GetXmax()/gsNpixelY/gsNfebY;
25 
26  if ( (ndb != fNdiblock) || (ndcm != fNdcm) ) {
27  fNdiblock = ndb;
28  fNdcm = ndcm;
29  this->Clear();
30  this->MakeVerticalLines();
31  this->MakeHorizontalLines();
32  this->MakeDBLabels();
33  this->MakeDCMLabels();
34  }
35 }
36 
37 //......................................................................
38 
40 {
41  std::list<TLine*>::const_iterator line(fLine.begin());
42  std::list<TLine*>::const_iterator lineend(fLine.end());
43  for (; line!=lineend; ++line) delete *line;
44  fLine.clear();
45 
46  std::list<TText*>::const_iterator text(fText.begin());
47  std::list<TText*>::const_iterator textend(fText.end());
48  for (; text!=textend; ++text) delete *text;
49  fText.clear();
50 }
51 
52 //......................................................................
53 
55 {
56  this->Clear();
57 }
58 
59 //......................................................................
60 
62 {
63  std::list<TLine*>::const_iterator line(fLine.begin());
64  std::list<TLine*>::const_iterator lineend(fLine.end());
65  for (; line!=lineend; ++line) (*line)->Draw();
66 
67  std::list<TText*>::const_iterator text(fText.begin());
68  std::list<TText*>::const_iterator textend(fText.end());
69  for (; text!=textend; ++text) (*text)->Draw();
70 }
71 
72 //......................................................................
73 
75 {
76  int i;
77  TLine* l;
78  for (i=0; i<=fNdcm*gsNfebY; ++i) {
79  //
80  // If the index is an FEB boundary and we've been asked not to
81  // show the FEB boundaries, skip to the next iteration
82  //
83  if ((i%gsNfebY)!=0 && fShowFEBBoundaries==false) continue;
84 
85  //
86  // Make the line. Make the DCM boundaries thicker
87  //
88  l = new TLine(0, i*gsNpixelY,
89  fNdiblock*gsNpixelX*gsNfebX, i*gsNpixelY);
90  if ((i%gsNfebY)==0) l->SetLineWidth(3);
91  else l->SetLineWidth(1);
92 
93  l->SetLineColor(kBlack);
94  l->SetBit(kCannotPick);
95  fLine.push_back(l);
96  }
97 }
98 
99 //......................................................................
100 
102 {
103  int i;
104  TLine* l;
105  for (i=0; i<=fNdiblock*gsNfebX; ++i) {
106  //
107  // If we are on an FEB boundary and we've been asked not to draw
108  // them, skip to the next iteration
109  //
110  if ((i%gsNfebX)==1 && fShowFEBBoundaries==false) continue;
111 
112  //
113  // Draw the line. Make the DCM boundary thicker.
114  //
115  l = new TLine(i*gsNpixelX, 0,
116  i*gsNpixelX, fNdcm*gsNpixelY*gsNfebY);
117  if ((i%gsNfebX)==0) l->SetLineWidth(3);
118  else l->SetLineWidth(1);
119  l->SetLineColor(kBlack);
120  l->SetBit(kCannotPick);
121  fLine.push_back(l);
122  }
123 }
124 
125 //......................................................................
126 
128 {
129  int i;
130  TText* t;
131  char buff[16];
132  for (i=0; i<fNdiblock; ++i) {
133  sprintf(buff,"DB%.2d",fNdiblock-i);
134  t = new TText((i+0.5)*gsNpixelX*gsNfebX,
135  1.02*gsNpixelY*gsNfebY*fNdcm,
136  buff);
137  t->SetTextAlign(22);
138  t->SetTextSize(0.03);
139  t->SetBit(kCannotPick);
140  fText.push_back(t);
141  }
142 }
143 
144 //......................................................................
145 
147 {
148  int i;
149  TText* t;
150  char buff[16];
151  for (i=0; i<fNdcm; ++i) {
152  sprintf(buff,"DCM%.2d",fNdcm-i);
153  t = new TText(-0.005*gsNpixelX*gsNfebX*fNdiblock,
154  gsNpixelY*gsNfebY*(i+0.5),
155  buff);
156  t->SetTextAlign(32);
157  t->SetTextSize(0.03);
158  // t->SetTextAngle(90);
159  t->SetBit(kCannotPick);
160  fText.push_back(t);
161  }
162 }
163 
164 ////////////////////////////////////////////////////////////////////////
HwDetLabel(bool show_feb_boundaries=true)
Definition: HwDetLabel.cxx:13
static const int gsNfebY
Definition: HwDetLabel.cxx:9
void MakeHorizontalLines()
Definition: HwDetLabel.cxx:74
std::list< TLine * > fLine
Collection of line lables.
Definition: HwDetLabel.h:28
void MakeDBLabels()
Definition: HwDetLabel.cxx:127
bool fShowFEBBoundaries
Should we mark off the FEB boundaries?
Definition: HwDetLabel.h:25
std::list< TText * > fText
Collection of text labels.
Definition: HwDetLabel.h:29
static const int gsNpixelY
Definition: HwDetLabel.cxx:11
void MakeVerticalLines()
Definition: HwDetLabel.cxx:101
static const int gsNfebX
Definition: HwDetLabel.cxx:8
void MakeDCMLabels()
Definition: HwDetLabel.cxx:146
void Config(const TH1 *h)
Definition: HwDetLabel.cxx:21
static const int gsNpixelX
Definition: HwDetLabel.cxx:10
Online Monitoring package header.