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

◆ drawEtaValues()

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(), JetChargeProducer_cfi.exp, isotrackApplyRegressor.range, funct.sin(), and funct.tan().

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

◆ setTDRStyle()

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().

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

Variable Documentation

◆ _LABELS2COMPS

plot_utils._LABELS2COMPS
private

Definition at line 38 of file plot_utils.py.

◆ COMPOUNDS

plot_utils.COMPOUNDS

Definition at line 64 of file plot_utils.py.

◆ DETECTORS

plot_utils.DETECTORS

Definition at line 81 of file plot_utils.py.

◆ hist_label_to_num

plot_utils.hist_label_to_num

Definition at line 119 of file plot_utils.py.

◆ Plot_params

plot_utils.Plot_params

Definition at line 9 of file plot_utils.py.

◆ plots

plot_utils.plots

Definition at line 17 of file plot_utils.py.

◆ sDETS

plot_utils.sDETS

Definition at line 106 of file plot_utils.py.