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