CMS 3D CMS Logo

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

Functions

def plot
 

Function Documentation

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

Definition at line 5 of file plotResidualsCosmics.py.

References drawHistoAllChambers.drawHisto().

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