CMS 3D CMS Logo

Functions | Variables
plot_utils Namespace Reference

Functions

def drawEtaValues ()
 
def setTDRStyle ()
 

Variables

 _LABELS2COMPS
 
 COMPOUNDS
 
 DETECTORS
 
 hist_label_to_num
 
 Plot_params
 
 plots
 
 sDETS
 

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 230 of file plot_utils.py.

References funct.cos(), JetChargeProducer_cfi.exp, funct.sin(), and funct.tan().

231  """Function to draw the eta.
232 
233  Function to draw the eta references on top of an already existing
234  TCanvas. The lines and labels drawn are collected inside a list and
235  the list is returned to the user to extend the live of the objects
236  contained, otherwise no lines and labels will be drawn, since they
237  will be garbage-collected as soon as this function returns.
238  """
239 
240  # Add eta labels
241  keep_alive = []
242  etas = [-3.4, -3.0, -2.8, -2.6, -2.4, -2.2,
243  -2.0, -1.8, -1.6, -1.4, -1.2, -1., -0.8, -0.6, -0.4, -0.2, 0., 0.2,
244  0.4, 0.6, 0.8, 1., 1.2, 1.4, 1.6, 1.8, 2., 2.2, 2.4, 2.6, 2.8, 3.0,
245  3.4]
246 
247  etax = 2940.
248  etay = 1240.
249  lineL = 100.
250  offT = 10.
251 
252  for ieta in etas:
253  th = 2*atan(exp(-ieta))
254  talign = 21
255 
256  #IP
257  lineh = TLine(-20.,0.,20.,0.)
258  lineh.Draw()
259  linev = TLine(0.,-10.,0.,10.)
260  linev.Draw()
261  keep_alive.append(lineh)
262  keep_alive.append(linev)
263 
264  x1 = 0
265  y1 = 0
266  if ieta>-1.6 and ieta<1.6:
267  x1 = etay/tan(th)
268  y1 = etay
269  elif ieta <=-1.6:
270  x1 = -etax
271  y1 = -etax*tan(th)
272  talign = 11
273  elif ieta>=1.6:
274  x1 = etax
275  y1 = etax*tan(th)
276  talign = 31
277  x2 = x1+lineL*cos(th)
278  y2 = y1+lineL*sin(th)
279  xt = x2
280  yt = y2+offT
281 
282  line1 = TLine(x1,y1,x2,y2)
283  line1.Draw()
284  keep_alive.append(line1)
285 
286  text = "%3.1f" % ieta
287  t1 = TLatex(xt, yt, '%s' % ('#eta = 0' if ieta == 0 else text))
288  t1.SetTextSize(0.03)
289  t1.SetTextAlign(talign)
290  t1.Draw()
291  keep_alive.append(t1)
292  return keep_alive
293 
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
def drawEtaValues()
Definition: plot_utils.py:230
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
def plot_utils.setTDRStyle ( )
Function to setup a TDR-like style

Definition at line 124 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().

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

Variable Documentation

plot_utils._LABELS2COMPS
private

Definition at line 34 of file plot_utils.py.

plot_utils.COMPOUNDS

Definition at line 60 of file plot_utils.py.

plot_utils.DETECTORS

Definition at line 77 of file plot_utils.py.

plot_utils.hist_label_to_num

Definition at line 115 of file plot_utils.py.

plot_utils.Plot_params

Definition at line 9 of file plot_utils.py.

plot_utils.sDETS

Definition at line 102 of file plot_utils.py.