CMS 3D CMS Logo

Functions
plotVDriftFromHistos Namespace Reference

Functions

def binNumber (station, sector)
 
def compare (fileNames, sl)
 
def plot (fileName, sl, option="HISTOP", draw=True)
 

Function Documentation

def plotVDriftFromHistos.binNumber (   station,
  sector 
)

Definition at line 4 of file plotVDriftFromHistos.py.

Referenced by plot().

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

Definition at line 62 of file plotVDriftFromHistos.py.

References plot().

62 def compare(fileNames,sl):
63  option = "HISTOP"
64  colors = (2,4,12,44,55)
65  markers = (24,25,26,27)
66 
67  idx = 0
68  canvas = None
69  objects = None
70  histos = []
71  for fileName in fileNames:
72  draw = False
73  if not idx: draw = True
74 
75  objs = plot(fileName,sl,option,draw)
76  if not idx:
77  canvas = objs[0]
78  objects = objs[2]
79  histos.append(objs[1])
80 
81  canvas.cd()
82  if idx:
83  histos[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
84  histos[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
85  histos[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
86 
87  histos[-1].Draw(option + "SAME")
88 
89  idx += 1
90 
91  return (canvas,histos,objects)
92 
def plot(fileName, sl, option="HISTOP", draw=True)
def compare(fileNames, sl)
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 def plot(fileName,sl,option="HISTOP",draw=True):
9 
10  slType = sl
11  slStr = "SL%d" % slType
12  verbose = False
13 
14  ROOT.TH1.AddDirectory(False)
15 
16  file = ROOT.TFile(fileName,'read')
17 
18  wheels = (-2,-1,0,1,2)
19  stations = (1,2,3,4)
20 
21  histosWheel = {}
22  for wh in wheels:
23  histoName = 'Wheel%d_%s_VDrift' % (wh,slStr)
24  print "Accessing",histoName
25  histosWheel[wh] = file.Get(histoName)
26 
27  # (Wh-2 MB1 Sec1 ... Wh-2 MB1 Sec12 ... Wh-1 MB1 Sec1 ... Wh-1 MB1 Sec12 ...)
28  # (Wh-2 MB2 Sec1 ... Wh-2 MB2 Sec12 ... Wh-1 MB2 Sec1 ... Wh-1 MB1 Sec12 ...) ...
29  nBins = 250
30  if slType == 2: nBins = 180
31  histo = ROOT.TH1F("h_VDriftAll","VDrift",nBins,0,nBins)
32  for st in stations:
33  nSectors = 12
34  if st == 4: nSectors = 14
35  if st == 4 and slType == 2: continue
36  if verbose: print "Station",st
37  for wh in wheels:
38  if verbose: print "Wheel",wh
39  for sec in range(1,nSectors+1):
40  if verbose: print "Sector",sec
41  binHisto = binNumber(st,sec)
42  if verbose: print "Bin from histos:",binHisto
43  value = histosWheel[wh].GetBinContent(binHisto)
44  # From cm/ns to micron/ns
45  value *= 10000.
46 
47  binHistoNew = (st - 1)*60 + (wh + 2)*nSectors + sec
48  if verbose: print "Bin final",binHistoNew
49  histo.SetBinContent(binHistoNew,value)
50 
51  if sec == 1:
52  label = "Wheel %d" % wh
53  if wh == -2: label += " MB%d" % st
54  histo.GetXaxis().SetBinLabel(binHistoNew,label)
55 
56  objects = drawHisto(histo,
57  title="v_{drift} (#mum/ns)",
58  ymin=53,ymax=57,option=option,draw=draw)
59 
60  return objects
61 
def plot(fileName, sl, option="HISTOP", draw=True)
def binNumber(station, sector)
def drawHisto(histo, title, ymin, ymax, option="HISTOP", draw=True)