CMS 3D CMS Logo

Functions
plotResidualsCosmics Namespace Reference

Functions

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

Function Documentation

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

Definition at line 7 of file plotResidualsCosmics.py.

References drawHistoAllChambers.drawHisto(), edm.print(), and FastTimerService_cff.range.

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