CMS 3D CMS Logo

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

Functions

def binNumber
 
def compare
 
def plot
 

Function Documentation

def plotVDriftFromHistos.binNumber (   station,
  sector 
)

Definition at line 6 of file plotVDriftFromHistos.py.

Referenced by plot().

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

Definition at line 64 of file plotVDriftFromHistos.py.

References plot().

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

Definition at line 10 of file plotVDriftFromHistos.py.

References binNumber(), drawHistoAllChambers.drawHisto(), print(), and sistrip::SpyUtilities.range().

Referenced by compare().

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