CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
plot_utils Namespace Reference

Functions

def drawEtaValues
 
def setTDRStyle
 

Variables

dictionary _LABELS2COMPS
 
tuple COMPOUNDS = OrderedDict()
 
tuple DETECTORS = OrderedDict()
 
tuple hist_label_to_num = OrderedDict()
 
tuple Plot_params
 
dictionary plots = {}
 
tuple sDETS = OrderedDict()
 

Function Documentation

def plot_utils.drawEtaValues ( )
Function to draw the eta.

Function to draw the eta references on top of an already existing
TCanvas. The lines and labels drawn are collected inside a list and
the list is returned to the user to extend the live of the objects
contained, otherwise no lines and labels will be drawn, since they
will be garbage-collected as soon as this function returns.

Definition at line 248 of file plot_utils.py.

References funct.cos(), funct.exp(), sistrip::SpyUtilities.range(), funct.sin(), and funct.tan().

249 def drawEtaValues():
250  """Function to draw the eta.
251 
252  Function to draw the eta references on top of an already existing
253  TCanvas. The lines and labels drawn are collected inside a list and
254  the list is returned to the user to extend the live of the objects
255  contained, otherwise no lines and labels will be drawn, since they
256  will be garbage-collected as soon as this function returns.
257  """
258 
259  # Add eta labels
260  keep_alive = []
261  etas = [ 0.2*i for i in range(-17,18) ]
262 
263  etax = 2850.
264  etay = 1240.
265  lineL = 110.
266  offT = 10.
267 
268  for ieta in etas:
269  th = 2*atan(exp(-ieta))
270  talign = 21
271 
272  #IP
273  lineh = TLine(-20.,0.,20.,0.)
274  lineh.Draw()
275  linev = TLine(0.,-10.,0.,10.)
276  linev.Draw()
277  keep_alive.append(lineh)
278  keep_alive.append(linev)
279 
280  x1 = 0
281  y1 = 0
282  if ieta>-1.6 and ieta<1.6:
283  x1 = etay/tan(th)
284  y1 = etay
285  elif ieta <=-1.6:
286  x1 = -etax
287  y1 = -etax*tan(th)
288  talign = 11
289  elif ieta>=1.6:
290  x1 = etax
291  y1 = etax*tan(th)
292  talign = 31
293  x2 = x1+lineL*cos(th)
294  y2 = y1+lineL*sin(th)
295  xt = x2
296  yt = y2+offT
297 
298  line1 = TLine(x1,y1,x2,y2)
299  line1.Draw()
300  keep_alive.append(line1)
301 
302  text = "%3.1f" % ieta
303  t1 = TLatex(xt, yt, '%s' % ('#eta = 0' if ieta == 0 else text))
304  t1.SetTextSize(0.03)
305  t1.SetTextAlign(talign)
306  t1.Draw()
307  keep_alive.append(t1)
308  return keep_alive
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
const uint16_t range(const Frame &aFrame)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
def drawEtaValues
Definition: plot_utils.py:248
def plot_utils.setTDRStyle ( )
Function to setup a TDR-like style

Definition at line 129 of file plot_utils.py.

References plotscripts.tdrStyle.

Referenced by BDHadronTrackMonitoringAnalyzer.bookHistograms(), BDHadronTrackMonitoringHarvester.dqmEndJob(), FlavourHistograms< T >.plot(), FlavourHistograms2D< T, G >.plot(), and IPTagPlotter< Container, Base >.psPlot().

130 def setTDRStyle():
131  """Function to setup a TDR-like style"""
132 
133  tdrStyle = TStyle("tdrStyle","Style for P-TDR")
134 
135  # For the canvas:
136  tdrStyle.SetCanvasBorderMode(0)
137  tdrStyle.SetCanvasColor(kWhite)
138  tdrStyle.SetCanvasDefH(600) #Height of canvas
139  tdrStyle.SetCanvasDefW(600) #Width of canvas
140  tdrStyle.SetCanvasDefX(0) #Position on screen
141  tdrStyle.SetCanvasDefY(0)
142 
143  # For the Pad:
144  tdrStyle.SetPadBorderMode(0)
145  tdrStyle.SetPadColor(kWhite)
146  tdrStyle.SetPadGridX(False)
147  tdrStyle.SetPadGridY(False)
148  tdrStyle.SetGridColor(kWhite)
149  tdrStyle.SetGridStyle(3)
150  tdrStyle.SetGridWidth(1)
151  tdrStyle.SetPadTickX(True)
152  tdrStyle.SetPadTickY(True)
153 
154  # For the frame:
155  tdrStyle.SetFrameBorderMode(0)
156  tdrStyle.SetFrameBorderSize(1)
157  tdrStyle.SetFrameFillColor(0)
158  tdrStyle.SetFrameFillStyle(0)
159  tdrStyle.SetFrameLineColor(1)
160  tdrStyle.SetFrameLineStyle(1)
161  tdrStyle.SetFrameLineWidth(0)
162 
163  # For the histo:
164  tdrStyle.SetHistLineColor(1)
165  tdrStyle.SetHistLineStyle(0)
166  tdrStyle.SetHistLineWidth(1)
167  tdrStyle.SetEndErrorSize(1)
168  #tdrStyle.SetErrorX(0.)
169  tdrStyle.SetMarkerStyle(20)
170 
171  #For the fit/function:
172  tdrStyle.SetOptFit(0)
173  tdrStyle.SetFitFormat("5.4g")
174  tdrStyle.SetFuncColor(2)
175  tdrStyle.SetFuncStyle(1)
176  tdrStyle.SetFuncWidth(1)
177 
178  #For the date:
179  tdrStyle.SetOptDate(0)
180 
181  # For the statistics box:
182  tdrStyle.SetOptFile(0)
183  tdrStyle.SetOptStat(0); # To display the mean and RMS: SetOptStat("mr")
184  tdrStyle.SetStatColor(kWhite)
185  tdrStyle.SetStatFont(42)
186  tdrStyle.SetStatFontSize(0.025)
187  tdrStyle.SetStatTextColor(1)
188  tdrStyle.SetStatFormat("6.4g")
189  tdrStyle.SetStatBorderSize(1)
190  tdrStyle.SetStatH(0.1)
191  tdrStyle.SetStatW(0.15)
192 
193  # Margins:
194  tdrStyle.SetPadTopMargin(0.05)
195  tdrStyle.SetPadBottomMargin(0.1)
196  tdrStyle.SetPadLeftMargin(0.12)
197  tdrStyle.SetPadRightMargin(0.05)
198 
199  # For the Global title:
200  tdrStyle.SetOptTitle(1)
201  tdrStyle.SetTitleFont(42)
202  tdrStyle.SetTitleColor(1)
203  tdrStyle.SetTitleTextColor(1)
204  tdrStyle.SetTitleFillColor(10)
205  tdrStyle.SetTitleFontSize(0.0525)
206  tdrStyle.SetTitleH(0); # Set the height of the title box
207  tdrStyle.SetTitleW(0); # Set the width of the title box
208  tdrStyle.SetTitleX(0.5); # Set the position of the title box
209  tdrStyle.SetTitleY(1.0); # Set the position of the title box
210  tdrStyle.SetTitleStyle(1001);
211  tdrStyle.SetTitleBorderSize(0);
212  tdrStyle.SetTitleAlign(23)
213 
214  # For the axis titles:
215  tdrStyle.SetTitleColor(1, "XYZ")
216  tdrStyle.SetTitleFont(42, "XYZ")
217  tdrStyle.SetTitleSize(0.05, "XY")
218  tdrStyle.SetTitleSize(0.035, "Z")
219  tdrStyle.SetTitleXOffset(1.0)
220  tdrStyle.SetTitleYOffset(1.0)
221 
222  # For the axis labels:
223  tdrStyle.SetLabelColor(1, "XYZ")
224  tdrStyle.SetLabelFont(42, "XYZ")
225  tdrStyle.SetLabelOffset(5e-3, "XYZ")
226  tdrStyle.SetLabelSize(0.03, "XYZ")
227 
228  # For the axis:
229  tdrStyle.SetAxisColor(1, "XYZ")
230  tdrStyle.SetStripDecimals(kTRUE)
231  tdrStyle.SetTickLength(0.03, "XYZ")
232  tdrStyle.SetNdivisions(510, "XYZ")
233  tdrStyle.SetPadTickX(1) # To get tick marks on the opposite side of the frame
234  tdrStyle.SetPadTickY(1)
235 
236  # Change for log plots:
237  tdrStyle.SetOptLogx(0)
238  tdrStyle.SetOptLogy(0)
239  tdrStyle.SetOptLogz(0)
240 
241  # Miscellaneous
242  tdrStyle.SetLegendBorderSize(0)
243 
244  # Postscript options:
245  tdrStyle.SetPaperSize(20.,20.)
246 
247  tdrStyle.cd()
def setTDRStyle
Definition: plot_utils.py:129

Variable Documentation

dictionary plot_utils._LABELS2COMPS
Initial value:
1 = {'BeamPipe': 'BEAM',
2  'Tracker': 'Tracker',
3  'Pixel': ['PixelBarrel', 'PixelForwardZplus', 'PixelForwardZminus'],
4  'PixBar': 'PixelBarrel',
5  'PixFwd': ['PixelForwardZplus', 'PixelForwardZminus', 'PixelForward'],
6  'PixFwdMinus': 'PixelForwardZminus',
7  'PixFwdPlus': 'PixelForwardZplus',
8  'TIB': 'TIB',
9  'TOB': 'TOB',
10  'TIDB': 'TIDB',
11  'TIDF': 'TIDF',
12  'TEC': 'TEC',
13  'InnerServices': ['TIBTIDServicesF', 'TIBTIDServicesB'],
14  'TkStrct': ['TrackerOuterCylinder', 'TrackerBulkhead'],
15  'Phase2PixelBarrel': 'Phase2PixelBarrel',
16  'Phase2OTBarrel': 'Phase2OTBarrel',
17  'Phase2PixelEndcap': 'Phase2PixelEndcap',
18  'Phase2OTForward': 'Phase2OTForward'}

Definition at line 38 of file plot_utils.py.

tuple plot_utils.COMPOUNDS = OrderedDict()

Definition at line 64 of file plot_utils.py.

tuple plot_utils.DETECTORS = OrderedDict()

Definition at line 81 of file plot_utils.py.

tuple plot_utils.hist_label_to_num = OrderedDict()

Definition at line 119 of file plot_utils.py.

tuple plot_utils.Plot_params
Initial value:
1 = namedtuple('Params',
2  ['plotNumber',
3  'abscissa', 'ordinate',
4  'ymin', 'ymax',
5  'xmin', 'xmax',
6  'quotaName', 'iDrawEta',
7  'histoMin', 'histoMax',
8  'zLog', 'iRebin'])

Definition at line 9 of file plot_utils.py.

dictionary plot_utils.plots = {}

Definition at line 17 of file plot_utils.py.

tuple plot_utils.sDETS = OrderedDict()

Definition at line 106 of file plot_utils.py.