CMS 3D CMS Logo

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

Functions

def binNumber
 
def compareDiff
 
def plot
 
def SLcompare
 

Function Documentation

def plotT0FromHistos.binNumber (   station,
  sl 
)

Definition at line 6 of file plotT0FromHistos.py.

Referenced by DTnoiseDBValidation.beginRun(), DTnoiseDBValidation.bookHisto(), and plot().

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

Definition at line 112 of file plotT0FromHistos.py.

References hippyaddtobaddatafiles.cd(), drawHistoAllChambers.drawHisto(), HcalObjRepresent.Fill(), plot(), sistrip::SpyUtilities.range(), and HcalObjRepresent.Reset().

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

Definition at line 12 of file plotT0FromHistos.py.

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

Referenced by compareDiff(), and SLcompare().

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

Definition at line 65 of file plotT0FromHistos.py.

References plot(), and sistrip::SpyUtilities.range().

65 
66 def SLcompare(fileName,sls,run,ymin=-5,ymax=5,labels=[]):
67  option = "HISTOP"
68  colors = (2,4,12,44,55,38,27,46)
69  markers = (24,25,26,27,28,30,32,5)
70 
71  idx = 0
72  canvas = None
73  objects = None
74  histos = []
75  for sl in sls:
76  draw = False
77  if not idx: draw = True
78 
79  objs = plot(fileName,sl,run,ymin,ymax,option,draw)
80  histos.append(objs[1])
81  histos[-1].SetName( "SL %d" % sl)
82  if not idx:
83  canvas = objs[0]
84  objects = objs[2]
85 
86  canvas.cd()
87  if idx:
88  histos[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
89  histos[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
90  histos[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
91 
92  histos[-1].Draw(option + "SAME")
93 
94  idx += 1
95 
96  legend = ROOT.TLegend(0.4,0.7,0.95,0.8)
97  for idx in range( len(histos) ):
98  histo = histos[idx]
99  label = histo.GetName()
100  if len(labels): label = labels[idx]
101  legend.AddEntry(histo,label,"LP")
102 
103  idx += 1
104 
105  canvas.cd()
106  legend.SetFillColor( canvas.GetFillColor() )
107  legend.Draw("SAME")
108 
109  objects.append(legend)
110 
111  return (canvas,histos,objects)
const uint16_t range(const Frame &aFrame)