Belle II Software  release-08-01-10
EKLMMuonPlot.py
1 #!/usr/bin/env python3
2 
3 
10 
11 """
12 <header>
13  <input>muon-KLMValidation.root</input>
14  <contact>Laura Salutari (Laura.Salutari@uniroma3.it)</contact>
15  <description>Creation of EKLM muon validation plots.</description>
16 </header>
17 """
18 
19 import ROOT
20 from ROOT import TNamed
21 
22 ROOT.gROOT.SetBatch(True)
23 input_file = ROOT.TFile('../muon-KLMValidation.root')
24 tree = input_file.Get('tree')
25 output_file = ROOT.TFile('EKLMMuon.root', 'recreate')
26 contact = 'Laura Salutari (Laura.Salutari@uniroma3.it)'
27 
28 
29 # Shifter Plots
30 
31 subdetector_selection = 'KLMHit2ds.m_Subdetector==2'
32 
33 h2dtres = ROOT.TH1F('muon_h2dtres', 'EKLM muon 2d hits time resolution',
34  80, -20, 20)
35 h2dtres.SetXTitle('ns')
36 h2dtres.SetYTitle('Events')
37 tree.Draw('KLMHit2ds.m_Time+(EventT0.hasEventT0()?EventT0.getEventT0():0)-KLMHit2ds.m_MCTime>>muon_h2dtres', subdetector_selection)
38 functions = h2dtres.GetListOfFunctions()
39 functions.Add(TNamed('Description', 'Time resolution'))
40 functions.Add(TNamed('Check', 'No bias.'))
41 functions.Add(TNamed('Contact', contact))
42 functions.Add(TNamed('MetaOptions', 'shifter'))
43 
44 section = ROOT.TH1F('Forward', 'Section for KLMHit2ds', 2, 0.5, 2.5)
45 section.GetXaxis().SetTitle('1=backward 2=forward')
46 section.GetYaxis().SetTitle('Events')
47 tree.Draw('KLMHit2ds.getSection()>>Forward', subdetector_selection)
48 functions = section.GetListOfFunctions()
49 functions.Add(TNamed('Description',
50  'Flag indicating if a muon hit is in backward(1) or forward(2) EKLM'))
51 functions.Add(TNamed('Check', 'More hits in backward.'))
52 functions.Add(TNamed('Contact', contact))
53 functions.Add(TNamed('MetaOptions', 'shifter'))
54 
55 sector = ROOT.TH1F('Sector', 'Sector for KLMHit2ds', 6, -0.5, 5.5)
56 sector.GetXaxis().SetTitle('Sector #')
57 sector.GetYaxis().SetTitle('Events')
58 tree.Draw('KLMHit2ds.getSector()>>Sector', subdetector_selection)
59 functions = sector.GetListOfFunctions()
60 functions.Add(TNamed('Description', 'Sector number of muon hit'))
61 functions.Add(TNamed('Check', 'More hits in sector 1, then mostly flat.'))
62 functions.Add(TNamed('Contact', contact))
63 functions.Add(TNamed('MetaOptions', 'shifter'))
64 
65 layer = ROOT.TH1F('Layer', 'Layer for KLMHit2ds', 16, -0.5, 15.5)
66 layer.GetXaxis().SetTitle('Layer #')
67 layer.GetYaxis().SetTitle('Events')
68 tree.Draw('KLMHit2ds.getLayer()>>Layer', subdetector_selection)
69 functions = layer.GetListOfFunctions()
70 functions.Add(TNamed('Description', 'Layer number of muon hit'))
71 functions.Add(TNamed('Check', 'Number of events decreases with number of layer.'))
72 functions.Add(TNamed('Contact', contact))
73 functions.Add(TNamed('MetaOptions', 'shifter'))
74 
75 time = ROOT.TH1F('Time', 'Hit time for KLMHit2ds', 80, -5.0, 35.0)
76 time.GetXaxis().SetTitle('t (ns)')
77 time.GetYaxis().SetTitle('Events')
78 tree.Draw('KLMHit2ds.getTime()>>Time', subdetector_selection)
79 functions = time.GetListOfFunctions()
80 functions.Add(TNamed('Description', 'Time of muon hit in EKLM'))
81 functions.Add(TNamed('Check', 'Mean around 16 ns.'))
82 functions.Add(TNamed('Contact', contact))
83 functions.Add(TNamed('MetaOptions', 'shifter'))
84 
85 # Expert Plots
86 
87 nPE = ROOT.TH1F('nGenPE', 'Generated PE in EKLM', 100, 0.0, 200)
88 nPE.GetXaxis().SetTitle('# generated PE')
89 nPE.GetYaxis().SetTitle('Events')
90 tree.Draw('KLMDigits.getNGeneratedPhotoelectrons()>>nGenPE',
91  'KLMDigits.getSubdetector()==2')
92 functions = nPE.GetListOfFunctions()
93 functions.Add(TNamed('Description', 'Number of generated photoelectrons in EKLM.'))
94 functions.Add(TNamed('Check', 'Mean around 37.'))
95 functions.Add(TNamed('Contact', contact))
96 functions.Add(TNamed('MetaOptions', 'expert'))
97 
98 edep = ROOT.TH1F('edep', 'Energy deposition for KLMDigits', 150, 0.0, 15)
99 edep.GetXaxis().SetTitle('E (MeV)')
100 edep.GetYaxis().SetTitle('Events')
101 tree.Draw('KLMHit2ds.getEnergyDeposit()>>edep', subdetector_selection)
102 functions = edep.GetListOfFunctions()
103 functions.Add(TNamed('Description', 'dE/dx energy deposition of muon hit'))
104 functions.Add(TNamed('Check', 'Peak around 3 MeV, with mean 3.7 MeV.'))
105 functions.Add(TNamed('Contact', contact))
106 functions.Add(TNamed('MetaOptions', 'expert'))
107 
108 output_file.cd()
109 h2dtres.Write()
110 section.Write()
111 sector.Write()
112 layer.Write()
113 time.Write()
114 nPE.Write()
115 edep.Write()
116 output_file.Close()