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