CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
plotVDriftFromHistos Namespace Reference

Functions

def binNumber
 
def compare
 
def plot
 

Function Documentation

def plotVDriftFromHistos.binNumber (   station,
  sector 
)

Definition at line 4 of file plotVDriftFromHistos.py.

Referenced by plot().

4 
5 def binNumber(station,sector):
6  start = (station - 1)*12
7  return start + sector
def plotVDriftFromHistos.compare (   fileNames,
  sl 
)

Definition at line 62 of file plotVDriftFromHistos.py.

References plot().

62 
63 def compare(fileNames,sl):
64  option = "HISTOP"
65  colors = (2,4,12,44,55)
66  markers = (24,25,26,27)
67 
68  idx = 0
69  canvas = None
70  objects = None
71  histos = []
72  for fileName in fileNames:
73  draw = False
74  if not idx: draw = True
75 
76  objs = plot(fileName,sl,option,draw)
77  if not idx:
78  canvas = objs[0]
79  objects = objs[2]
80  histos.append(objs[1])
81 
82  canvas.cd()
83  if idx:
84  histos[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
85  histos[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
86  histos[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
87 
88  histos[-1].Draw(option + "SAME")
89 
90  idx += 1
91 
92  return (canvas,histos,objects)
def plotVDriftFromHistos.plot (   fileName,
  sl,
  option = "HISTOP",
  draw = True 
)

Definition at line 8 of file plotVDriftFromHistos.py.

References binNumber(), and drawHistoAllChambers.drawHisto().

Referenced by compare().

8 
9 def plot(fileName,sl,option="HISTOP",draw=True):
10 
11  slType = sl
12  slStr = "SL%d" % slType
13  verbose = False
14 
15  ROOT.TH1.AddDirectory(False)
16 
17  file = ROOT.TFile(fileName,'read')
18 
19  wheels = (-2,-1,0,1,2)
20  stations = (1,2,3,4)
21 
22  histosWheel = {}
23  for wh in wheels:
24  histoName = 'Wheel%d_%s_VDrift' % (wh,slStr)
25  print "Accessing",histoName
26  histosWheel[wh] = file.Get(histoName)
27 
28  # (Wh-2 MB1 Sec1 ... Wh-2 MB1 Sec12 ... Wh-1 MB1 Sec1 ... Wh-1 MB1 Sec12 ...)
29  # (Wh-2 MB2 Sec1 ... Wh-2 MB2 Sec12 ... Wh-1 MB2 Sec1 ... Wh-1 MB1 Sec12 ...) ...
30  nBins = 250
31  if slType == 2: nBins = 180
32  histo = ROOT.TH1F("h_VDriftAll","VDrift",nBins,0,nBins)
33  for st in stations:
34  nSectors = 12
35  if st == 4: nSectors = 14
36  if st == 4 and slType == 2: continue
37  if verbose: print "Station",st
38  for wh in wheels:
39  if verbose: print "Wheel",wh
40  for sec in range(1,nSectors+1):
41  if verbose: print "Sector",sec
42  binHisto = binNumber(st,sec)
43  if verbose: print "Bin from histos:",binHisto
44  value = histosWheel[wh].GetBinContent(binHisto)
45  # From cm/ns to micron/ns
46  value *= 10000.
47 
48  binHistoNew = (st - 1)*60 + (wh + 2)*nSectors + sec
49  if verbose: print "Bin final",binHistoNew
50  histo.SetBinContent(binHistoNew,value)
51 
52  if sec == 1:
53  label = "Wheel %d" % wh
54  if wh == -2: label += " MB%d" % st
55  histo.GetXaxis().SetBinLabel(binHistoNew,label)
56 
57  objects = drawHisto(histo,
58  title="v_{drift} (#mum/ns)",
59  ymin=53,ymax=57,option=option,draw=draw)
60 
61  return objects