CMS 3D CMS Logo

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

◆ binNumber()

def plotT0FromHistos.binNumber (   station,
  sl 
)

Definition at line 6 of file plotT0FromHistos.py.

Referenced by DTnoiseDBValidation.beginRun(), npstat::HistoND< Numeric, Axis >.binBox(), npstat::HistoND< Numeric, Axis >.binCenter(), npstat::HistoND< Numeric, Axis >.binVolume(), DTnoiseDBValidation.bookHisto(), MuonTestSummary.doEnergyTests(), and plot().

6 def binNumber(station,sl):
7  if sl == 3 and station == 4: return 11
8  if sl == 2 and station == 4: return None
9  start = (station - 1)*3
10  return start + sl
11 
def binNumber(station, sl)

◆ compareDiff()

def plotT0FromHistos.compareDiff (   fileNames,
  sl,
  ymin = -15.,
  ymax = 15. 
)

Definition at line 112 of file plotT0FromHistos.py.

References SiStripClientConfig_Tier0_cff.Add, hippyaddtobaddatafiles.cd(), drawHistoAllChambers.drawHisto(), HcalObjRepresent.Fill(), plot(), FastTimerService_cff.range, and HcalObjRepresent.Reset().

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

◆ plot()

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(), FastTimerService_cff.range, and str.

Referenced by compareDiff(), and SLcompare().

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

◆ SLcompare()

def plotT0FromHistos.SLcompare (   fileName,
  sls,
  run,
  ymin = -5,
  ymax = 5,
  labels = [] 
)

Definition at line 65 of file plotT0FromHistos.py.

References plot(), and FastTimerService_cff.range.

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