CMS 3D CMS Logo

Functions
plotResiduals Namespace Reference

Functions

def plot (fileName, sl, dir='DQMData/Run 1/DT/Run summary/DTCalibValidation', option="HISTOPE1", draw=True)
 

Function Documentation

def plotResiduals.plot (   fileName,
  sl,
  dir = 'DQMData/Run 1/DT/Run summary/DTCalibValidation',
  option = "HISTOPE1",
  draw = True 
)

Definition at line 5 of file plotResiduals.py.

References drawHistoAllChambers.drawHisto().

5 def plot(fileName,sl,dir='DQMData/Run 1/DT/Run summary/DTCalibValidation',option="HISTOPE1",draw=True):
6 
7  mean_ymin = -0.02
8  mean_ymax = 0.02
9  sig_ymin = 0.
10  sig_ymax = 0.07
11 
12  slType = sl
13  slStr = "SL%d" % slType
14  verbose = False
15  nSigmas = 2
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  # (Wh-2 MB1 Sec1 ... Wh-2 MB1 Sec12 ... Wh-1 MB1 Sec1 ... Wh-1 MB1 Sec12 ...)
25  # (Wh-2 MB2 Sec1 ... Wh-2 MB2 Sec12 ... Wh-1 MB2 Sec1 ... Wh-1 MB1 Sec12 ...) ...
26  nBins = 250
27  if slType == 2: nBins = 180
28  histoMean = ROOT.TH1F("h_ResMeanAll","Mean of residuals",nBins,0,nBins)
29  histoSigma = ROOT.TH1F("h_ResSigmaAll","Sigma of residuals",nBins,0,nBins)
30  for st in stations:
31  nSectors = 12
32  if st == 4: nSectors = 14
33  if st == 4 and slType == 2: continue
34  if verbose: print "Station",st
35  for wh in wheels:
36  if verbose: print "Wheel",wh
37  for sec in range(1,nSectors+1):
38  if verbose: print "Sector",sec
39  # Get histogram
40  histoName = "%s/Wheel%d/Station%d/Sector%d/hResDist_STEP3_W%d_St%d_Sec%d_%s" % (dir,wh,st,sec,wh,st,sec,slStr)
41  print "Accessing",histoName
42  histo = file.Get(histoName)
43  (histo,fitFunc) = fitResidual(histo,nSigmas,verbose)
44  fitMean = fitFunc.GetParameter(1)
45  fitMeanErr = fitFunc.GetParError(1)
46  fitSigma = fitFunc.GetParameter(2)
47  fitSigmaErr = fitFunc.GetParError(2)
48 
49  binHistoNew = (st - 1)*60 + (wh + 2)*nSectors + sec
50  if verbose: print "Bin in summary histo",binHistoNew
51  histoMean.SetBinContent(binHistoNew,fitMean)
52  histoMean.SetBinError(binHistoNew,fitMeanErr)
53  histoSigma.SetBinContent(binHistoNew,fitSigma)
54  histoSigma.SetBinError(binHistoNew,fitSigmaErr)
55 
56  if sec == 1:
57  label = "Wheel %d" % wh
58  if wh == -2: label += " MB%d" % st
59  histoMean.GetXaxis().SetBinLabel(binHistoNew,label)
60  histoSigma.GetXaxis().SetBinLabel(binHistoNew,label)
61 
62  objectsMean = drawHisto(histoMean,title="Mean of residuals (cm)",
63  ymin=mean_ymin,ymax=mean_ymax,option=option,draw=draw)
64  objectsSigma = drawHisto(histoSigma,title="Sigma of residuals (cm)",
65  ymin=sig_ymin,ymax=sig_ymax,option=option,draw=draw)
66 
67  return (objectsMean,objectsSigma)
68 
def drawHisto(histo, title, ymin, ymax, option="HISTOP", draw=True)
def plot(fileName, sl, dir='DQMData/Run 1/DT/Run summary/DTCalibValidation', option="HISTOPE1", draw=True)
Definition: plotResiduals.py:5