CMS 3D CMS Logo

Functions
plotTTrigFromHistos Namespace Reference

Functions

def binNumber (station, sector)
 
def compare (fileNames, sl, ymin=300, ymax=360, labels=[])
 
def compareDiff (fileNames, sl, ymin=-15., ymax=15.)
 
def plot (fileName, sl, ymin=300, ymax=360, option="HISTOP", draw=True)
 

Function Documentation

def plotTTrigFromHistos.binNumber (   station,
  sector 
)

Definition at line 5 of file plotTTrigFromHistos.py.

Referenced by plot().

5 def binNumber(station,sector):
6  start = (station - 1)*12
7  return start + sector
8 
def binNumber(station, sector)
def plotTTrigFromHistos.compare (   fileNames,
  sl,
  ymin = 300,
  ymax = 360,
  labels = [] 
)

Definition at line 61 of file plotTTrigFromHistos.py.

References plot().

61 def compare(fileNames,sl,ymin=300,ymax=360,labels=[]):
62  option = "HISTOP"
63  colors = (2,4,12,44,55,38,27,46)
64  markers = (24,25,26,27,28,30,32,5)
65 
66  idx = 0
67  canvas = None
68  objects = None
69  histos = []
70  for fileName in fileNames:
71  draw = False
72  if not idx: draw = True
73 
74  objs = plot(fileName,sl,ymin,ymax,option,draw)
75  histos.append(objs[1])
76  histos[-1].SetName( "%s_%d" % (histos[-1].GetName(),idx) )
77  if not idx:
78  canvas = objs[0]
79  objects = objs[2]
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  legend = ROOT.TLegend(0.4,0.7,0.95,0.8)
92  for idx in range( len(histos) ):
93  histo = histos[idx]
94  label = histo.GetName()
95  if len(labels): label = labels[idx]
96  legend.AddEntry(histo,label,"LP")
97 
98  idx += 1
99 
100  canvas.cd()
101  legend.SetFillColor( canvas.GetFillColor() )
102  legend.Draw("SAME")
103 
104  objects.append(legend)
105 
106  return (canvas,histos,objects)
107 
def plot(fileName, sl, ymin=300, ymax=360, option="HISTOP", draw=True)
def compare(fileNames, sl, ymin=300, ymax=360, labels=[])
def plotTTrigFromHistos.compareDiff (   fileNames,
  sl,
  ymin = -15.,
  ymax = 15. 
)

Definition at line 108 of file plotTTrigFromHistos.py.

References drawHistoAllChambers.drawHisto(), HcalObjRepresent.Fill(), plot(), and HcalObjRepresent.Reset().

108 def compareDiff(fileNames,sl,ymin=-15.,ymax=15.):
109  option = "HISTOP"
110  colors = (2,4,9,12,38,44,46,55)
111  markers = (24,25,26,27,28,30,32,5)
112 
113  idx = 0
114  canvases = [None,None]
115  objects = None
116  histoRef = None
117  histos = []
118  histosDist = []
119  for fileName in fileNames:
120  objs = plot(fileName,sl,300,360,'',False)
121  histos.append( objs[1].Clone(objs[1].GetName() + "_diff") )
122  histos[-1].SetName( "%s_%d" % (histos[-1].GetName(),idx) )
123  if not idx:
124  histoRef = objs[1]
125  histos[-1].Reset()
126  else:
127  histos[-1].Add(histoRef,-1.)
128 
129  draw = False
130  if not idx: draw = True
131 
132  objs = drawHisto(histos[-1],
133  title="t_{Trig} difference (ns)",
134  ymin=ymin,ymax=ymax,option=option,draw=draw)
135 
136  if not idx:
137  canvases[0] = objs[0]
138  objects = objs[2]
139 
140  if idx:
141  canvases[0].cd()
142  histos[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
143  histos[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
144  histos[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
145 
146  histos[-1].Draw(option + "SAME")
147 
148  histosDist.append( ROOT.TH1F(histos[-1].GetName() + "_dist","tTrig distribution",200,ymin,ymax) )
149  for ibin in range(1,histos[-1].GetNbinsX()+1):
150  histosDist[-1].Fill( histos[-1].GetBinContent(ibin) )
151 
152  histosDist[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
153  histosDist[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
154  histosDist[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
155 
156  idx += 1
157 
158 
159  canvases[1] = ROOT.TCanvas("c_tTrigDist")
160  canvases[1].SetGridy()
161  canvases[1].SetFillColor(0)
162  canvases[1].cd()
163  option = "HISTO"
164  idx = 0
165  for histo in histosDist:
166  if not idx:
167  histo.GetXaxis().SetTitle("t_{Trig} difference (ns)")
168  histo.GetYaxis().SetTitle("Number of chambers")
169  histo.Draw(option)
170  else:
171  histo.Draw(option + "SAME")
172  idx += 1
173 
174  return (canvases,histos,histosDist,objects)
175 
def plot(fileName, sl, ymin=300, ymax=360, option="HISTOP", draw=True)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
def compareDiff(fileNames, sl, ymin=-15., ymax=15.)
void Reset(std::vector< TH2F > &depth)
def drawHisto(histo, title, ymin, ymax, option="HISTOP", draw=True)
def plotTTrigFromHistos.plot (   fileName,
  sl,
  ymin = 300,
  ymax = 360,
  option = "HISTOP",
  draw = True 
)

Definition at line 9 of file plotTTrigFromHistos.py.

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

Referenced by compare(), and compareDiff().

9 def plot(fileName,sl,ymin=300,ymax=360,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_TTrig' % (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_TTrigAll","TTrig",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 
46  binHistoNew = (st - 1)*60 + (wh + 2)*nSectors + sec
47  if verbose: print("Bin final",binHistoNew)
48  histo.SetBinContent(binHistoNew,value)
49 
50  if sec == 1:
51  label = "Wheel %d" % wh
52  if wh == -2: label += " MB%d" % st
53  histo.GetXaxis().SetBinLabel(binHistoNew,label)
54 
55  objects = drawHisto(histo,
56  title="t_{Trig} (ns)",
57  ymin=ymin,ymax=ymax,option=option,draw=draw)
58 
59  return objects
60 
def binNumber(station, sector)
def plot(fileName, sl, ymin=300, ymax=360, option="HISTOP", draw=True)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
def drawHisto(histo, title, ymin, ymax, option="HISTOP", draw=True)