CMS 3D CMS Logo

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

Functions

def plot
 

Function Documentation

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

Definition at line 7 of file plotResiduals.py.

References drawHistoAllChambers.drawHisto(), print(), and sistrip::SpyUtilities.range().

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