Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:30:44

0001 #! /usr/bin/env python
0002 
0003 from __future__ import print_function
0004 import sys
0005 import material
0006 import ROOT
0007 
0008 def usage():
0009   print("Usage...")
0010 
0011 def plot():
0012   if (len(sys.argv) < 2) or (sys.argv[1] not in ("r", "z", "eta")):
0013     usage()
0014     sys.exit(1)
0015   dir_name  = sys.argv[1]
0016   direction = material.Element.directions[dir_name]
0017   dir_label = material.Element.dir_labels[dir_name]
0018   layers = sys.argv[2:]
0019 
0020   elements = []
0021   for layer in layers:
0022     elements += material.parse(file("layers/" + layer))
0023   if len(elements) == 0:
0024     sys.exit(1)
0025 
0026   positions = set()
0027   for element in elements:
0028     positions.add(element.position[direction])
0029   positions = sorted(positions)
0030 
0031   data   = ROOT.TFile("TrackerRecMaterial.root")
0032   canvas = ROOT.TCanvas("material", "", 800, 600)
0033   if dir_name == "r":
0034     modules = ROOT.TH1F("modules", "material along R",   1200,    0, 120)
0035   elif dir_name == "z":
0036     modules = ROOT.TH1F("modules", "material along Z",   6000, -300, 300)
0037   else:
0038     modules = ROOT.TH1F("modules", "material along Eta",   60,   -3,   3)
0039   for position in positions:
0040     modules.SetBinContent(modules.GetXaxis().FindBin(position), 1)
0041   modules.SetLineColor(ROOT.kBlack)
0042   modules.SetFillStyle(1001)
0043   modules.SetFillColor(ROOT.kBlack)
0044   modules.SetMaximum(1)
0045   modules.Draw()
0046   dedx   = dict( (layer, data.Get("%s_dedx_vs_%s"   % (layer, dir_name))) for layer in layers )
0047   radlen = dict( (layer, data.Get("%s_radlen_vs_%s" % (layer, dir_name))) for layer in layers )
0048   for layer in layers:
0049     dedx[layer].SetLineColor(ROOT.kRed)
0050     dedx[layer].Draw("same")
0051     radlen[layer].SetLineColor(ROOT.kGreen)
0052     radlen[layer].Draw("same")
0053 
0054   canvas.Update()
0055 
0056   while(canvas):
0057     pass
0058 
0059 
0060 if __name__ == "__main__":
0061   plot()