20 <input>muon-KLMValidation.root</input>
21 <contact>Laura.Salutari@uniroma3.it</contact>
22 <description>Create validation plots
for BKLM</description>
30ROOT.gROOT.SetBatch(ROOT.kTRUE)
32from ROOT
import TFile, TChain, TH1F, TNamed, gStyle, PyConfig
33PyConfig.IgnoreCommandLineOptions =
True
37CONTACT_PERSON = {
'Name':
'Laura Salutari',
38 'Email':
'Laura.Salutari@uniroma3.it'}
43 Create validation plots for BKLM.
45 print('Creating the BKLM validation plots...')
47 parser = argparse.ArgumentParser()
49 parser.add_argument(
'-i',
'--input-file', dest=
'input_file',
50 default=
'../muon-KLMValidation.root',
51 help=
'Root file with Ext/Muid/BKLM/EKLM validation data.'
53 parser.add_argument(
'-o',
'--output-file', dest=
'output_file',
54 default=
'BKLMMuon.root',
55 help=
'Root file with BKLM validation histograms.')
57 args = parser.parse_args()
60 file_chain = TChain(
'tree')
61 file_chain.Add(args.input_file)
65 number_entries = file_chain.GetEntries()
66 except AttributeError:
67 print(f
'Could not load input file(s) {args.input_file}.')
69 if number_entries == 0:
70 print(f
'Data tree is empty or does not exist in file(s) {args.input_file}. Exit.')
74 output_root_file = TFile(args.output_file,
'recreate')
78 draw_bklmhists(file_chain)
81 output_root_file.Write()
82 output_root_file.Close()
84 print(
'BKLM validation plots created.')
88def draw_bklmhists(file_chain):
90 Draw the KLMHit2d-related distributions.
93 contact = 'Laura Salutari (Laura.Salutari@uniroma3.it)'
97 subdetector_selection =
'KLMHit2ds.m_Subdetector==1'
99 inRPC = TH1F(
'InRPC',
'InRPC for KLMHit2ds', 2, -0.5, 1.5)
100 file_chain.Draw(
'KLMHit2ds.inRPC()>>InRPC', subdetector_selection)
101 inRPC.GetXaxis().SetTitle(
'0=scintillator 1=RPC')
102 inRPC.GetListOfFunctions().Add(TNamed(
'Description',
'Flag indicating if a muon hit is in scintillator (0) or RPC (1)'))
103 inRPC.GetListOfFunctions().Add(TNamed(
'Check',
'Mostly in RPC.'))
104 inRPC.GetListOfFunctions().Add(TNamed(
'Contact', contact))
105 inRPC.GetListOfFunctions().Add(TNamed(
'MetaOptions',
'shifter,pvalue-warn=0.50,pvalue-error=0.10'))
106 inRPC.SetMinimum(0.0)
109 section = TH1F(
'Forward',
'Section for KLMHit2ds', 2, -0.5, 1.5)
110 file_chain.Draw(
'KLMHit2ds.getSection()>>Forward', subdetector_selection)
111 section.GetXaxis().SetTitle(
'0=backward 1=forward')
112 section.GetListOfFunctions().Add(TNamed(
'Description',
113 'Flag indicating if a muon hit is in backward (0) or forward (1) BKLM'))
114 section.GetListOfFunctions().Add(TNamed(
'Check',
'More hits in the backward.'))
115 section.GetListOfFunctions().Add(TNamed(
'Contact', contact))
116 section.GetListOfFunctions().Add(TNamed(
'MetaOptions',
'shifter,pvalue-warn=0.50,pvalue-error=0.10'))
117 section.SetMinimum(0.0)
120 isOnTrack = TH1F(
'IsOnTrack',
'IsOnTrack for KLMHit2ds', 2, -0.5, 1.5)
121 file_chain.Draw(
'KLMHit2ds.isOnTrack()>>IsOnTrack', subdetector_selection)
122 isOnTrack.GetXaxis().SetTitle(
'0=not associated with Track 1=associated with Track')
123 isOnTrack.GetListOfFunctions().Add(TNamed(
'Description',
124 'Flag indicating if a muon hit is associated with a CDC Track by Muid'))
125 isOnTrack.GetListOfFunctions().Add(TNamed(
'Check',
'Mostly associated.'))
126 isOnTrack.GetListOfFunctions().Add(TNamed(
'Contact', contact))
127 isOnTrack.GetListOfFunctions().Add(TNamed(
'MetaOptions',
'shifter,pvalue-warn=0.50,pvalue-error=0.10'))
128 isOnTrack.SetMinimum(0.0)
131 sector = TH1F(
'Sector',
'Sector for KLMHit2ds', 10, -0.5, 9.5)
132 file_chain.Draw(
'KLMHit2ds.getSector()>>Sector', subdetector_selection)
133 sector.GetXaxis().SetTitle(
'Sector #')
134 sector.GetListOfFunctions().Add(TNamed(
'Description',
'Sector number of muon hit'))
135 sector.GetListOfFunctions().Add(TNamed(
'Check',
'Roughly flat in sectors 1-8.'))
136 sector.GetListOfFunctions().Add(TNamed(
'Contact', contact))
137 sector.GetListOfFunctions().Add(TNamed(
'MetaOptions',
'shifter,pvalue-warn=1.00,pvalue-error=0.01'))
138 sector.SetMinimum(0.0)
141 layer = TH1F(
'Layer',
'Layer for KLMHit2ds', 17, -0.5, 16.5)
142 file_chain.Draw(
'KLMHit2ds.getLayer()>>Layer', subdetector_selection)
143 layer.GetXaxis().SetTitle(
'Layer #')
144 layer.GetListOfFunctions().Add(TNamed(
'Description',
'Layer number of muon hit'))
145 layer.GetListOfFunctions().Add(TNamed(
'Check',
146 'First peak at layer 1 and second (higher) peak at layer 2, with tail above those.'))
147 layer.GetListOfFunctions().Add(TNamed(
'Contact', contact))
148 layer.GetListOfFunctions().Add(TNamed(
'MetaOptions',
'shifter,pvalue-warn=1.0,pvalue-error=0.01'))
149 layer.SetMinimum(0.0)
152 phistrip = TH1F(
'PhiStrip',
'PhiStrip for KLMHit2ds', 50, -0.5, 49.5)
153 file_chain.Draw(
'KLMHit2ds.getPhiStripAve()>>PhiStrip',
154 subdetector_selection)
155 phistrip.GetXaxis().SetTitle(
'Phi strip #')
156 phistrip.GetListOfFunctions().Add(TNamed(
'Description',
'Strip number in phi plane of muon hit'))
157 phistrip.GetListOfFunctions().Add(TNamed(
'Check',
158 'Roughly flat for 1-36 (all layers) and then for 37-48 (layers 6-15).'))
159 phistrip.GetListOfFunctions().Add(TNamed(
'Contact', contact))
160 phistrip.GetListOfFunctions().Add(TNamed(
'MetaOptions',
'shifter,pvalue-warn=1.00,pvalue-error=0.01'))
161 phistrip.SetMinimum(0.0)
164 zstrip = TH1F(
'ZStrip',
'ZStrip for KLMHit2ds', 60, -0.5, 59.5)
165 file_chain.Draw(
'KLMHit2ds.getZStripAve()>>ZStrip', subdetector_selection)
166 zstrip.GetXaxis().SetTitle(
'Z strip #')
167 zstrip.GetListOfFunctions().Add(TNamed(
'Description',
'Strip number in z plane of muon hit'))
168 zstrip.GetListOfFunctions().Add(TNamed(
'Check',
169 'Downward-sloping for 1-48 (all layers), shoulder for 49-54 (layers 1-2).'))
170 zstrip.GetListOfFunctions().Add(TNamed(
'Contact', contact))
171 zstrip.GetListOfFunctions().Add(TNamed(
'MetaOptions',
'shifter,pvalue-warn=1.00,pvalue-error=0.01'))
172 zstrip.SetMinimum(0.0)
175 timeRPC = TH1F(
'TimeRPC',
'Hit time for KLMHit2ds in RPCs', 175, 5, 30)
176 file_chain.Draw(
'KLMHit2ds.getTime()>>TimeRPC',
177 subdetector_selection +
' && KLMHit2ds.inRPC()==1')
178 timeRPC.GetXaxis().SetTitle(
't (ns)')
179 timeRPC.GetListOfFunctions().Add(TNamed(
'Description',
'Time of muon hit in RPCs'))
180 timeRPC.GetListOfFunctions().Add(TNamed(
'Check',
'Narrow peak at 0 ns.'))
181 timeRPC.GetListOfFunctions().Add(TNamed(
'Contact', contact))
182 timeRPC.GetListOfFunctions().Add(TNamed(
'MetaOptions',
'shifter,pvalue-warn=1.00,pvalue-error=0.01'))
185 timeSci = TH1F(
'TimeSci',
'Hit time for KLMHit2ds in scintillators', 80, -5, 35)
186 file_chain.Draw(
'KLMHit2ds.getTime()>>TimeSci',
187 subdetector_selection +
' && KLMHit2ds.inRPC()==0')
188 timeSci.GetXaxis().SetTitle(
't (ns)')
189 timeSci.GetListOfFunctions().Add(TNamed(
'Description',
'Time of muon hit in scintillators'))
190 timeSci.GetListOfFunctions().Add(TNamed(
'Check',
191 'Peaks approximately around 0, 3, 8, 12, 15 and 20 ns.'))
192 timeSci.GetListOfFunctions().Add(TNamed(
'Contact', contact))
193 timeSci.GetListOfFunctions().Add(TNamed(
'MetaOptions',
'shifter,pvalue-warn=1.00,pvalue-error=0.01'))
196 nPE = TH1F(
'nGenPE',
'Generated PE in BKLM', 200, 0.0, 200)
197 file_chain.Draw(
'KLMDigits.getNGeneratedPhotoelectrons()>>nGenPE',
198 'KLMDigits.m_Subdetector==1 && KLMDigits.getLayer() < 3')
199 nPE.GetXaxis().SetTitle(
'# generated PE')
200 nPE.GetListOfFunctions().Add(TNamed(
'Description',
'Number of generated photoelectrons in BKLM'))
201 nPE.GetListOfFunctions().Add(TNamed(
'Check',
'Peak around 50.'))
202 nPE.GetListOfFunctions().Add(TNamed(
'Contact', contact))
203 nPE.GetListOfFunctions().Add(TNamed(
'MetaOptions',
''))
208 edep = TH1F(
'EnergyDeposit',
'Energy deposition for KLMHit2ds', 260, -1.0, 25.0)
209 file_chain.Draw(
'KLMHit2ds.getEnergyDeposit()*1000.0>>EnergyDeposit',
210 subdetector_selection)
211 edep.GetXaxis().SetTitle(
'E (keV)')
212 edep.GetListOfFunctions().Add(TNamed(
'Description',
'dE/dx energy deposition of muon hit'))
213 edep.GetListOfFunctions().Add(TNamed(
'Check',
'Peak near 3 keV.'))
214 edep.GetListOfFunctions().Add(TNamed(
'Contact', contact))
215 edep.GetListOfFunctions().Add(TNamed(
'MetaOptions',
'expert,pvalue-warn=1.00,pvalue-error=0.01'))
220if __name__ ==
'__main__':