CMS 3D CMS Logo

Functions

plotVDriftFromHistos Namespace Reference

Functions

def binNumber
def compare
def plot

Function Documentation

def plotVDriftFromHistos::binNumber (   station,
  sector 
)

Definition at line 4 of file plotVDriftFromHistos.py.

00005                              :
00006     start = (station - 1)*12
00007     return start + sector
 
def plotVDriftFromHistos::compare (   fileNames,
  sl 
)

Definition at line 62 of file plotVDriftFromHistos.py.

00063                          :
00064     option = "HISTOP"
00065     colors = (2,4,12,44,55)
00066     markers = (24,25,26,27)
00067 
00068     idx = 0
00069     canvas = None
00070     objects = None
00071     histos = []
00072     for fileName in fileNames:
00073         draw = False
00074         if not idx: draw = True
00075 
00076         objs = plot(fileName,sl,option,draw)
00077         if not idx:
00078             canvas = objs[0]
00079             objects = objs[2]
00080         histos.append(objs[1])
00081         
00082         canvas.cd()
00083         if idx:
00084             histos[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
00085             histos[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
00086             histos[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
00087 
00088             histos[-1].Draw(option + "SAME")
00089 
00090         idx += 1
00091 
00092     return (canvas,histos,objects)
def plotVDriftFromHistos::plot (   fileName,
  sl,
  option = "HISTOP",
  draw = True 
)

Definition at line 8 of file plotVDriftFromHistos.py.

00009                                                :
00010 
00011     slType = sl
00012     slStr = "SL%d" % slType
00013     verbose = False
00014 
00015     ROOT.TH1.AddDirectory(False)
00016 
00017     file = ROOT.TFile(fileName,'read')
00018 
00019     wheels = (-2,-1,0,1,2)
00020     stations = (1,2,3,4)
00021 
00022     histosWheel = {}
00023     for wh in wheels:
00024         histoName = 'Wheel%d_%s_VDrift' % (wh,slStr)
00025         print "Accessing",histoName
00026         histosWheel[wh] = file.Get(histoName)
00027 
00028     # (Wh-2 MB1 Sec1 ... Wh-2 MB1 Sec12 ... Wh-1 MB1 Sec1 ... Wh-1 MB1 Sec12 ...)
00029     # (Wh-2 MB2 Sec1 ... Wh-2 MB2 Sec12 ... Wh-1 MB2 Sec1 ... Wh-1 MB1 Sec12 ...) ...  
00030     nBins = 250
00031     if slType == 2: nBins = 180
00032     histo = ROOT.TH1F("h_VDriftAll","VDrift",nBins,0,nBins)
00033     for st in stations:
00034         nSectors = 12
00035         if st == 4: nSectors = 14 
00036         if st == 4 and slType == 2: continue 
00037         if verbose: print "Station",st
00038         for wh in wheels:
00039             if verbose: print "Wheel",wh 
00040             for sec in range(1,nSectors+1):
00041                 if verbose: print "Sector",sec
00042                 binHisto = binNumber(st,sec)
00043                 if verbose: print "Bin from histos:",binHisto 
00044                 value = histosWheel[wh].GetBinContent(binHisto)
00045                 # From cm/ns to micron/ns
00046                 value *= 10000.
00047  
00048                 binHistoNew = (st - 1)*60 + (wh + 2)*nSectors + sec
00049                 if verbose: print "Bin final",binHistoNew
00050                 histo.SetBinContent(binHistoNew,value) 
00051   
00052                 if sec == 1:
00053                     label = "Wheel %d" % wh
00054                     if wh == -2: label += " MB%d" % st  
00055                     histo.GetXaxis().SetBinLabel(binHistoNew,label) 
00056 
00057     objects = drawHisto(histo,
00058                         title="v_{drift} (#mum/ns)",
00059                         ymin=53,ymax=57,option=option,draw=draw)
00060 
00061     return objects