File indexing completed on 2023-03-17 10:42:21
0001 from __future__ import print_function
0002 from __future__ import absolute_import
0003 import ROOT
0004 from .fitResidual import fitResidual
0005 from .drawHistoAllChambers import drawHisto
0006
0007 def plot(fileName,sl,dir='DQMData/Run 1/DT/Run summary/DTCalibValidation',option="HISTOPE1",draw=True):
0008
0009 mean_ymin = -0.02
0010 mean_ymax = 0.02
0011 sig_ymin = 0.
0012 sig_ymax = 0.07
0013
0014 slType = sl
0015 slStr = "SL%d" % slType
0016 verbose = False
0017 nSigmas = 2
0018
0019 ROOT.TH1.AddDirectory(False)
0020
0021 file = ROOT.TFile(fileName,'read')
0022
0023 wheels = (-2,-1,0,1,2)
0024 stations = (1,2,3,4)
0025
0026
0027
0028 nBins = 250
0029 if slType == 2: nBins = 180
0030 histoMean = ROOT.TH1F("h_ResMeanAll","Mean of residuals",nBins,0,nBins)
0031 histoSigma = ROOT.TH1F("h_ResSigmaAll","Sigma of residuals",nBins,0,nBins)
0032 for st in stations:
0033 nSectors = 12
0034 if st == 4: nSectors = 14
0035 if st == 4 and slType == 2: continue
0036 if verbose: print("Station",st)
0037 for wh in wheels:
0038 if verbose: print("Wheel",wh)
0039 for sec in range(1,nSectors+1):
0040 if verbose: print("Sector",sec)
0041
0042 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)
0043 print("Accessing",histoName)
0044 histo = file.Get(histoName)
0045 (histo,fitFunc) = fitResidual(histo,nSigmas,verbose)
0046 fitMean = fitFunc.GetParameter(1)
0047 fitMeanErr = fitFunc.GetParError(1)
0048 fitSigma = fitFunc.GetParameter(2)
0049 fitSigmaErr = fitFunc.GetParError(2)
0050
0051 binHistoNew = (st - 1)*60 + (wh + 2)*nSectors + sec
0052 if verbose: print("Bin in summary histo",binHistoNew)
0053 histoMean.SetBinContent(binHistoNew,fitMean)
0054 histoMean.SetBinError(binHistoNew,fitMeanErr)
0055 histoSigma.SetBinContent(binHistoNew,fitSigma)
0056 histoSigma.SetBinError(binHistoNew,fitSigmaErr)
0057
0058 if sec == 1:
0059 label = "Wheel %d" % wh
0060 if wh == -2: label += " MB%d" % st
0061 histoMean.GetXaxis().SetBinLabel(binHistoNew,label)
0062 histoSigma.GetXaxis().SetBinLabel(binHistoNew,label)
0063
0064 objectsMean = drawHisto(histoMean,title="Mean of residuals (cm)",
0065 ymin=mean_ymin,ymax=mean_ymax,option=option,draw=draw)
0066 objectsSigma = drawHisto(histoSigma,title="Sigma of residuals (cm)",
0067 ymin=sig_ymin,ymax=sig_ymax,option=option,draw=draw)
0068
0069 return (objectsMean,objectsSigma)