CMS 3D CMS Logo

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.

00006                                                                                                       :
00007 
00008     slType = sl
00009     slStr = "SL%d" % slType
00010     verbose = False
00011     nSigmas = 2
00012 
00013     ROOT.TH1.AddDirectory(False)
00014 
00015     file = ROOT.TFile(fileName,'read')
00016 
00017     wheels = (-2,-1,0,1,2)
00018     stations = (1,2,3,4)
00019 
00020     # (Wh-2 MB1 Sec1 ... Wh-2 MB1 Sec12 ... Wh-1 MB1 Sec1 ... Wh-1 MB1 Sec12 ...)
00021     # (Wh-2 MB2 Sec1 ... Wh-2 MB2 Sec12 ... Wh-1 MB2 Sec1 ... Wh-1 MB1 Sec12 ...) ...  
00022     nBins = 250
00023     if slType == 2: nBins = 180
00024     histoMean = ROOT.TH1F("h_ResMeanAll","Mean of residuals",nBins,0,nBins)
00025     histoSigma = ROOT.TH1F("h_ResSigmaAll","Sigma of residuals",nBins,0,nBins)
00026     for st in stations:
00027         nSectors = 12
00028         if st == 4: nSectors = 14
00029         if st == 4 and slType == 2: continue 
00030         if verbose: print "Station",st
00031         for wh in wheels:
00032             if verbose: print "Wheel",wh 
00033             for sec in range(1,nSectors+1):
00034                 if verbose: print "Sector",sec
00035                 # Get histogram
00036                 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) 
00037                 print "Accessing",histoName
00038                 histo = file.Get(histoName)
00039                 (histo,fitFunc) = fitResidual(histo,nSigmas,verbose)
00040                 fitMean = fitFunc.GetParameter(1)
00041                 fitMeanErr = fitFunc.GetParError(1)
00042                 fitSigma = fitFunc.GetParameter(2)
00043                 fitSigmaErr = fitFunc.GetParError(2)
00044 
00045                 binHistoNew = (st - 1)*60 + (wh + 2)*nSectors + sec
00046                 if verbose: print "Bin in summary histo",binHistoNew
00047                 histoMean.SetBinContent(binHistoNew,fitMean)
00048                 histoMean.SetBinError(binHistoNew,fitMeanErr)
00049                 histoSigma.SetBinContent(binHistoNew,fitSigma)
00050                 histoSigma.SetBinError(binHistoNew,fitSigmaErr)  
00051 
00052                 if sec == 1:
00053                     label = "Wheel %d" % wh
00054                     if wh == -2: label += " MB%d" % st  
00055                     histoMean.GetXaxis().SetBinLabel(binHistoNew,label) 
00056                     histoSigma.GetXaxis().SetBinLabel(binHistoNew,label)
00057 
00058     objectsMean = drawHisto(histoMean,title="Mean of residuals (cm)",
00059                                       ymin=-0.1,ymax=0.1,option=option,draw=draw)
00060     objectsSigma = drawHisto(histoSigma,title="Sigma of residuals (cm)",
00061                                       ymin=0.,ymax=0.15,option=option,draw=draw)
00062 
00063     return (objectsMean,objectsSigma)