CMS 3D CMS Logo

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