test
CMS 3D CMS Logo

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

Functions

def plot
 

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