CMS 3D CMS Logo

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

Functions

def binNumber (station, sl)
 
def compareDiff (fileNames, sl, ymin=-15., ymax=15.)
 
def plot (fileName, sl, run, ymin=-5, ymax=5, option="HISTOP", draw=True)
 
def SLcompare (fileName, sls, run, ymin=-5, ymax=5, labels=[])
 

Function Documentation

def plotT0FromHistos.binNumber (   station,
  sl 
)

Definition at line 5 of file plotT0FromHistos.py.

Referenced by DTnoiseDBValidation.beginRun(), DTnoiseDBValidation.bookHisto(), plot(), and npstat::HistoND< Numeric, Axis >.setAxisLabel().

5 def binNumber(station,sl):
6  if sl is 3 and station is 4: return 11
7  if sl is 2 and station is 4: return None
8  start = (station - 1)*3
9  return start + sl
10 
def binNumber(station, sl)
def plotT0FromHistos.compareDiff (   fileNames,
  sl,
  ymin = -15.,
  ymax = 15. 
)

Definition at line 111 of file plotT0FromHistos.py.

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

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

Definition at line 11 of file plotT0FromHistos.py.

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

Referenced by compareDiff(), and SLcompare().

11 def plot(fileName,sl,run,ymin=-5,ymax=5,option="HISTOP",draw=True):
12  path = "DQMData/Run "+str(run)+"/DT/Run summary/DtCalib/TTrigDBValidation/"
13  slType = sl
14  slStr = "SL%d" % slType
15  verbose = True #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 = path+'Wheel%d_%s_TTrig' % (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_TTrigAll","TTrig Run "+str(run),nBins,0,nBins)
35  for st in stations:
36  nSectors = 12
37  if st == 4: nSectors = 14
38  if st == 4 and sl == 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,sl)
45  if verbose: print("Bin from histos:",binHisto)
46  histoName = path+'Wheel%d/TTrigDifference_W%d_Sec%d' % (wh,wh,sec)
47  value = file.Get(histoName).GetBinContent(binHisto)
48 
49  binHistoNew = (st - 1)*60 + (wh + 2)*nSectors + sec
50  if verbose: print("Bin final",binHistoNew,value)
51  histo.SetBinContent(binHistoNew,value)
52 
53  if sec == 1:
54  label = "Wheel %d" % wh
55  if wh == -2: label += " MB%d" % st
56  histo.GetXaxis().SetBinLabel(binHistoNew,label)
57 
58  objects = drawHisto(histo,
59  title="#Deltat_{Trig} (ns)",
60  ymin=ymin,ymax=ymax,option=option,draw=draw)
61 
62  return objects
63 
def plot(fileName, sl, run, ymin=-5, ymax=5, option="HISTOP", draw=True)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
def binNumber(station, sl)
#define str(s)
def drawHisto(histo, title, ymin, ymax, option="HISTOP", draw=True)
def plotT0FromHistos.SLcompare (   fileName,
  sls,
  run,
  ymin = -5,
  ymax = 5,
  labels = [] 
)

Definition at line 64 of file plotT0FromHistos.py.

References plot().

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