-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotBackgroundFilesFromText.py
More file actions
329 lines (272 loc) · 25.4 KB
/
plotBackgroundFilesFromText.py
File metadata and controls
329 lines (272 loc) · 25.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#### this code mixes the background tracks and signal tracks per bunch crossing
#### run: python3 plotBackgroundFilesFromText.py -l <event file in text mode>
import os
import sys
import time
import pprint
import math, array
from ROOT import *
from collections import OrderedDict
import argparse
#### add diagonal vertex cut
#def checkVtxCut(vtxx, vtxz):
#if((-45.0 < vtxx <= -25.5 ) and (3800 < vtxz <= 4200)):
#return True
#elif((-55.0 < vtxx <= -35.0) and (4200 < vtxz <= 4500)):
#return True
#elif((-60.0 < vtxx <= -45.0) and (4500 < vtxz <= 5000)):
#return True
#elif((-70 < vtxx <= -50.0) and (5000 < vtxz <= 5500)):
#return True
#elif((-75 < vtxx <= -60.0) and (5500 < vtxz <= 6000)):
#return True
#elif((-80 < vtxx <= -65.0) and (5500 < vtxz <= 6000)):
#return True
#elif((-90 < vtxx <= -70.0) and (6000 < vtxz <= 6500)):
#return True
#elif((-100.0 < vtxx <= -80.0) and (6500 < vtxz <= 7000)):
#return True
#else:
#return False
### anything below x, remove it cut
def checkVtxCut(vtxx, vtxz):
if((vtxx <= -25.5 ) and (3800 < vtxz <= 4200)):
return True
elif((vtxx <= -35.0) and (4200 < vtxz <= 4500)):
return True
elif((vtxx <= -45.0) and (4500 < vtxz <= 5000)):
return True
elif((vtxx <= -50.0) and (5000 < vtxz <= 5500)):
return True
elif((vtxx <= -60.0) and (5500 < vtxz <= 6000)):
return True
elif((vtxx <= -65.0) and (5500 < vtxz <= 6000)):
return True
elif((vtxx <= -70.0) and (6000 < vtxz <= 6500)):
return True
elif((vtxx <= -80.0) and (6500 < vtxz <= 7000)):
return True
else:
return False
def energyBins(nbins):
#//// variable binned in X axis histograms
logmin = -6;
logmax = 1;
logbinwidth = (logmax-logmin)/float(nbins);
xpoints = []
for i in range(0, nbins+1):
#print((logmin + i*logbinwidth), pow( 10,(logmin + i*logbinwidth) ))
xpoints.append(pow( 10,(logmin + i*logbinwidth) ))
xpoints.append(2*pow( 10,1))
return xpoints
def main():
parser = argparse.ArgumentParser(description='Code to get 2D plots')
parser.add_argument('-l', action="store", dest="inFile", type=str, default="ePlusLaserBackground_list_root_7671ee4c_First3BX_trackInfo.txt")
args = parser.parse_args()
inDir = '/Users/arkasantra/arka/Sasha_Work/OutputFile'
bkgFileName = open(inDir+'/'+args.inFile)
withoutText = args.inFile.split('.txt')[0]
rootFile = withoutText+".root"
if 'ePlusLaserBkgNewSamples' in args.inFile:
nbx = 298.0
elif 'gPlusLaserBkgNewSamples' in args.inFile:
nbx = 80.0
elif 'fast_9f6b6590_al_window' in args.inFile:
nbx = 23.4
elif 'fast_9f6b6590_34_35' in args.inFile:
nbx = 16.56
elif 'ePlusLaserKaptonWindow_hics_background_fast_9f6b6590_0_16' in args.inFile:
nbx = 120.0
elif 'hics_background_fast_9f6b6590_17_33' in args.inFile:
nbx = 141.38
elif 'ePlusLaserKaptonWindow' in args.inFile:
nbx = 278.0
elif 'ePlusLaserBackground' in args.inFile:
nbx = 2.13
else:
nbx = 1.0
print('BX selected: ',nbx)
outFile = TFile(inDir+'/'+rootFile, "RECREATE")
outFile.cd()
nbins = 450
xbins = energyBins(nbins)
xarray = array.array('d',xbins)
#print(xarray, " ", len(xarray))
allHistoDict = {}
for i in range(0, 16):
#### gamma
allHistoDict.update({"tracking_planes_background_track_x_gamma_"+str(i):TH1D("tracking_planes_background_track_x_gamma_"+str(i),"tracking_planes_background_track_x_gamma_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_x_gamma_sumE_"+str(i):TH1D("tracking_planes_background_track_x_gamma_sumE_"+str(i),"tracking_planes_background_track_x_gamma_sumE_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_x_gamma_1GeVCut_"+str(i):TH1D("tracking_planes_background_track_x_gamma_1GeVCut_"+str(i),"tracking_planes_background_track_x_gamma_1GeVCut_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_e_gamma_log_"+str(i):TH1D("tracking_planes_background_track_e_gamma_log_"+str(i),"tracking_planes_background_track_e_gamma_log_"+str(i),nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtx_z_track_e_gamma_log_"+str(i):TH2D("tracking_planes_background_vtx_z_track_e_gamma_log_"+str(i),"tracking_planes_background_vtx_z_track_e_gamma_log_"+str(i),4000, -5000, 15000, nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtx_x_track_e_gamma_log_"+str(i):TH2D("tracking_planes_background_vtx_x_track_e_gamma_log_"+str(i),"tracking_planes_background_vtx_x_track_e_gamma_log_"+str(i),6000, -3000, 3000, nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtxz_vtxx_gamma_"+str(i):TH2D("tracking_planes_background_vtxz_vtxx_gamma_"+str(i), "tracking_planes_background_vtxz_vtxx_gamma_"+str(i), 4000, -5000, 15000, 6000, -3000, 3000)})
#### positrons
allHistoDict.update({"tracking_planes_background_track_x_positrons_"+str(i):TH1D("tracking_planes_background_track_x_positrons_"+str(i),"tracking_planes_background_track_x_positrons_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_x_positrons_sumE_"+str(i):TH1D("tracking_planes_background_track_x_positrons_sumE_"+str(i),"tracking_planes_background_track_x_positrons_sumE_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_x_positrons_1GeVCut_"+str(i):TH1D("tracking_planes_background_track_x_positrons_1GeVCut_"+str(i),"tracking_planes_background_track_x_positrons_1GeVCut_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_e_positrons_log_"+str(i):TH1D("tracking_planes_background_track_e_positrons_log_"+str(i),"tracking_planes_background_track_e_positrons_log_"+str(i),nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtx_z_track_e_positrons_log_"+str(i):TH2D("tracking_planes_background_vtx_z_track_e_positrons_log_"+str(i),"tracking_planes_background_vtx_z_track_e_positrons_log_"+str(i),4000, -5000, 15000, nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtx_x_track_e_positrons_log_"+str(i):TH2D("tracking_planes_background_vtx_x_track_e_positrons_log_"+str(i),"tracking_planes_background_vtx_x_track_e_positrons_log_"+str(i),6000, -3000, 3000, nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtxz_vtxx_positrons_"+str(i):TH2D("tracking_planes_background_vtxz_vtxx_positrons_"+str(i), "tracking_planes_background_vtxz_vtxx_positrons_"+str(i), 4000, -5000, 15000, 6000, -3000, 3000)})
#### electrons
allHistoDict.update({"tracking_planes_background_track_x_electrons_"+str(i):TH1D("tracking_planes_background_track_x_electrons_"+str(i),"tracking_planes_background_track_x_electrons_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_x_electrons_sumE_"+str(i):TH1D("tracking_planes_background_track_x_electrons_sumE_"+str(i),"tracking_planes_background_track_x_electrons_sumE_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_x_electrons_1GeVCut_"+str(i):TH1D("tracking_planes_background_track_x_electrons_1GeVCut_"+str(i),"tracking_planes_background_track_x_electrons_1GeVCut_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_e_electrons_log_"+str(i):TH1D("tracking_planes_background_track_e_electrons_log_"+str(i),"tracking_planes_background_track_e_electrons_log_"+str(i),nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtx_z_track_e_electrons_log_"+str(i):TH2D("tracking_planes_background_vtx_z_track_e_electrons_log_"+str(i),"tracking_planes_background_vtx_z_track_e_electrons_log_"+str(i),4000, -5000, 15000, nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtx_x_track_e_electrons_log_"+str(i):TH2D("tracking_planes_background_vtx_x_track_e_electrons_log_"+str(i),"tracking_planes_background_vtx_x_track_e_electrons_log_"+str(i),6000, -3000, 3000, nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtxz_vtxx_electrons_"+str(i):TH2D("tracking_planes_background_vtxz_vtxx_electrons_"+str(i), "tracking_planes_background_vtxz_vtxx_electrons_"+str(i), 4000, -5000, 15000, 6000, -3000, 3000)})
#### protons
allHistoDict.update({"tracking_planes_background_track_x_protons_"+str(i):TH1D("tracking_planes_background_track_x_protons_"+str(i),"tracking_planes_background_track_x_protons_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_x_protons_sumE_"+str(i):TH1D("tracking_planes_background_track_x_protons_sumE_"+str(i),"tracking_planes_background_track_x_protons_sumE_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_x_protons_1GeVCut_"+str(i):TH1D("tracking_planes_background_track_x_protons_1GeVCut_"+str(i),"tracking_planes_background_track_x_protons_1GeVCut_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_e_protons_log_"+str(i):TH1D("tracking_planes_background_track_e_protons_log_"+str(i),"tracking_planes_background_track_e_protons_log_"+str(i),nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtx_z_track_e_protons_log_"+str(i):TH2D("tracking_planes_background_vtx_z_track_e_protons_log_"+str(i),"tracking_planes_background_vtx_z_track_e_protons_log_"+str(i),4000, -5000, 15000, nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtx_x_track_e_protons_log_"+str(i):TH2D("tracking_planes_background_vtx_x_track_e_protons_log_"+str(i),"tracking_planes_background_vtx_x_track_e_protons_log_"+str(i),6000, -3000, 3000, nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtxz_vtxx_protons_"+str(i):TH2D("tracking_planes_background_vtxz_vtxx_protons_"+str(i), "tracking_planes_background_vtxz_vtxx_protons_"+str(i), 4000, -5000, 15000, 6000, -3000, 3000)})
#### neutrons
allHistoDict.update({"tracking_planes_background_track_x_neutrons_"+str(i):TH1D("tracking_planes_background_track_x_neutrons_"+str(i),"tracking_planes_background_track_x_neutrons_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_x_neutrons_sumE_"+str(i):TH1D("tracking_planes_background_track_x_neutrons_sumE_"+str(i),"tracking_planes_background_track_x_neutrons_sumE_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_x_neutrons_1GeVCut_"+str(i):TH1D("tracking_planes_background_track_x_neutrons_1GeVCut_"+str(i),"tracking_planes_background_track_x_neutrons_1GeVCut_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_e_neutrons_log_"+str(i):TH1D("tracking_planes_background_track_e_neutrons_log_"+str(i),"tracking_planes_background_track_e_neutrons_log_"+str(i),nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtx_z_track_e_neutrons_log_"+str(i):TH2D("tracking_planes_background_vtx_z_track_e_neutrons_log_"+str(i),"tracking_planes_background_vtx_z_track_e_neutrons_log_"+str(i),4000, -5000, 15000, nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtx_x_track_e_neutrons_log_"+str(i):TH2D("tracking_planes_background_vtx_x_track_e_neutrons_log_"+str(i),"tracking_planes_background_vtx_x_track_e_neutrons_log_"+str(i),6000, -3000, 3000, nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtxz_vtxx_neutrons_"+str(i):TH2D("tracking_planes_background_vtxz_vtxx_neutrons_"+str(i), "tracking_planes_background_vtxz_vtxx_neutrons_"+str(i), 4000, -5000, 15000, 6000, -3000, 3000)})
#### muons
allHistoDict.update({"tracking_planes_background_track_x_muons_"+str(i):TH1D("tracking_planes_background_track_x_muons_"+str(i),"tracking_planes_background_track_x_muons_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_x_muons_sumE_"+str(i):TH1D("tracking_planes_background_track_x_muons_sumE_"+str(i),"tracking_planes_background_track_x_muons_sumE_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_x_muons_1GeVCut_"+str(i):TH1D("tracking_planes_background_track_x_muons_1GeVCut_"+str(i),"tracking_planes_background_track_x_muons_1GeVCut_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_e_muons_log_"+str(i):TH1D("tracking_planes_background_track_e_muons_log_"+str(i),"tracking_planes_background_track_e_muons_log_"+str(i),nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtx_z_track_e_muons_log_"+str(i):TH2D("tracking_planes_background_vtx_z_track_e_muons_log_"+str(i),"tracking_planes_background_vtx_z_track_e_muons_log_"+str(i),4000, -5000, 15000, nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtx_x_track_e_muons_log_"+str(i):TH2D("tracking_planes_background_vtx_x_track_e_muons_log_"+str(i),"tracking_planes_background_vtx_x_track_e_muons_log_"+str(i),6000, -3000, 3000, nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtxz_vtxx_muons_"+str(i):TH2D("tracking_planes_background_vtxz_vtxx_muons_"+str(i), "tracking_planes_background_vtxz_vtxx_muons_"+str(i), 4000, -5000, 15000, 6000, -3000, 3000)})
#### pions
allHistoDict.update({"tracking_planes_background_track_x_pions_"+str(i):TH1D("tracking_planes_background_track_x_pions_"+str(i),"tracking_planes_background_track_x_pions_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_x_pions_sumE_"+str(i):TH1D("tracking_planes_background_track_x_pions_sumE_"+str(i),"tracking_planes_background_track_x_pions_sumE_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_x_pions_1GeVCut_"+str(i):TH1D("tracking_planes_background_track_x_pions_1GeVCut_"+str(i),"tracking_planes_background_track_x_pions_1GeVCut_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_e_pions_log_"+str(i):TH1D("tracking_planes_background_track_e_pions_log_"+str(i),"tracking_planes_background_track_e_pions_log_"+str(i),nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtx_z_track_e_pions_log_"+str(i):TH2D("tracking_planes_background_vtx_z_track_e_pions_log_"+str(i),"tracking_planes_background_vtx_z_track_e_pions_log_"+str(i),4000, -5000, 15000, nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtx_x_track_e_pions_log_"+str(i):TH2D("tracking_planes_background_vtx_x_track_e_pions_log_"+str(i),"tracking_planes_background_vtx_x_track_e_pions_log_"+str(i),6000, -3000, 3000, nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtxz_vtxx_pions_"+str(i):TH2D("tracking_planes_background_vtxz_vtxx_pions_"+str(i), "tracking_planes_background_vtxz_vtxx_pions_"+str(i), 4000, -5000, 15000, 6000, -3000, 3000)})
#### pions 0
allHistoDict.update({"tracking_planes_background_track_x_pi0_"+str(i):TH1D("tracking_planes_background_track_x_pi0_"+str(i),"tracking_planes_background_track_x_pi0_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_x_pi0_sumE_"+str(i):TH1D("tracking_planes_background_track_x_pi0_sumE_"+str(i),"tracking_planes_background_track_x_pi0_sumE_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_x_pi0_1GeVCut_"+str(i):TH1D("tracking_planes_background_track_x_pi0_1GeVCut_"+str(i),"tracking_planes_background_track_x_pi0_1GeVCut_"+str(i),1300, -650.0, 650.0)})
allHistoDict.update({"tracking_planes_background_track_e_pi0_log_"+str(i):TH1D("tracking_planes_background_track_e_pi0_log_"+str(i),"tracking_planes_background_track_e_pi0_log_"+str(i),nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtx_z_track_e_pi0_log_"+str(i):TH2D("tracking_planes_background_vtx_z_track_e_pi0_log_"+str(i),"tracking_planes_background_vtx_z_track_e_pi0_log_"+str(i),4000, -5000, 15000, nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtx_x_track_e_pi0_log_"+str(i):TH2D("tracking_planes_background_vtx_x_track_e_pi0_log_"+str(i),"tracking_planes_background_vtx_x_track_e_pi0_log_"+str(i),6000, -3000, 3000, nbins+1, xarray)})
allHistoDict.update({"tracking_planes_background_vtxz_vtxx_pi0_"+str(i):TH2D("tracking_planes_background_vtxz_vtxx_pi0_"+str(i), "tracking_planes_background_vtxz_vtxx_pi0_"+str(i), 4000, -5000, 15000, 6000, -3000, 3000)})
lineCounter = 0
### write the bkg as it is
for lines in bkgFileName.readlines():
if '#' in lines:
continue
lineCounter += 1
if(lineCounter%100000==0): print("processed: ", lineCounter)
#if(lineCounter > 200000):break
lines = lines.rstrip()
eachWord = lines.split()
bxNumber = int(eachWord[0])
trackId = int(eachWord[2])
pdgId = int(eachWord[1])
staveId = int(eachWord[3])-1000
xPos = float(eachWord[4])
yPos = float(eachWord[5])
energyVal = float(eachWord[6])
weight = float(eachWord[7])
vtx_x = float(eachWord[8])
vtx_y = float(eachWord[9])
vtx_z = float(eachWord[10])
failVtxCut = checkVtxCut(vtx_x, vtx_z)
#if(vtx_x < -25.5 and (vtx_z > 3600 and vtx_z < 4600)): continue
#if(failVtxCut): continue
###electrons
if(pdgId == 11 and trackId!=1):
allHistoDict["tracking_planes_background_track_x_electrons_"+str(staveId)].Fill(xPos, weight)
if(energyVal>1.0):
allHistoDict["tracking_planes_background_track_x_electrons_1GeVCut_"+str(staveId)].Fill(xPos, weight)
allHistoDict["tracking_planes_background_track_x_electrons_sumE_"+str(staveId)].Fill(xPos, energyVal*weight)
allHistoDict["tracking_planes_background_track_e_electrons_log_"+str(staveId)].Fill(energyVal, weight)
allHistoDict["tracking_planes_background_vtx_z_track_e_electrons_log_"+str(staveId)].Fill(vtx_z, energyVal, weight)
allHistoDict["tracking_planes_background_vtx_x_track_e_electrons_log_"+str(staveId)].Fill(vtx_x, energyVal, weight)
allHistoDict["tracking_planes_background_vtxz_vtxx_electrons_"+str(staveId)].Fill(vtx_z, vtx_x, weight)
###protons and anti-protons
if((pdgId == 2212 or pdgId == -2212) and trackId!=1):
allHistoDict["tracking_planes_background_track_x_protons_"+str(staveId)].Fill(xPos, weight)
if(energyVal>1.0):
allHistoDict["tracking_planes_background_track_x_protons_1GeVCut_"+str(staveId)].Fill(xPos, weight)
allHistoDict["tracking_planes_background_track_x_protons_sumE_"+str(staveId)].Fill(xPos, energyVal*weight)
allHistoDict["tracking_planes_background_track_e_protons_log_"+str(staveId)].Fill(energyVal, weight)
allHistoDict["tracking_planes_background_vtx_z_track_e_protons_log_"+str(staveId)].Fill(vtx_z, energyVal, weight)
allHistoDict["tracking_planes_background_vtx_x_track_e_protons_log_"+str(staveId)].Fill(vtx_x, energyVal, weight)
allHistoDict["tracking_planes_background_vtxz_vtxx_protons_"+str(staveId)].Fill(vtx_z, vtx_x, weight)
### neutrons
if(pdgId == 2112 and trackId!=1):
allHistoDict["tracking_planes_background_track_x_neutrons_"+str(staveId)].Fill(xPos, weight)
if(energyVal>1.0):
allHistoDict["tracking_planes_background_track_x_neutrons_1GeVCut_"+str(staveId)].Fill(xPos, weight)
allHistoDict["tracking_planes_background_track_x_neutrons_sumE_"+str(staveId)].Fill(xPos, energyVal*weight)
allHistoDict["tracking_planes_background_track_e_neutrons_log_"+str(staveId)].Fill(energyVal, weight)
allHistoDict["tracking_planes_background_vtx_z_track_e_neutrons_log_"+str(staveId)].Fill(vtx_z, energyVal, weight)
allHistoDict["tracking_planes_background_vtx_x_track_e_neutrons_log_"+str(staveId)].Fill(vtx_x, energyVal, weight)
allHistoDict["tracking_planes_background_vtxz_vtxx_neutrons_"+str(staveId)].Fill(vtx_z, vtx_x, weight)
### muons and anti-muons
if((pdgId == 13 or pdgId == -13) and trackId!=1):
allHistoDict["tracking_planes_background_track_x_muons_"+str(staveId)].Fill(xPos, weight)
if(energyVal>1.0):
allHistoDict["tracking_planes_background_track_x_muons_1GeVCut_"+str(staveId)].Fill(xPos, weight)
allHistoDict["tracking_planes_background_track_x_muons_sumE_"+str(staveId)].Fill(xPos, energyVal*weight)
allHistoDict["tracking_planes_background_track_e_muons_log_"+str(staveId)].Fill(energyVal, weight)
allHistoDict["tracking_planes_background_vtx_z_track_e_muons_log_"+str(staveId)].Fill(vtx_z, energyVal, weight)
allHistoDict["tracking_planes_background_vtx_x_track_e_muons_log_"+str(staveId)].Fill(vtx_x, energyVal, weight)
allHistoDict["tracking_planes_background_vtxz_vtxx_muons_"+str(staveId)].Fill(vtx_z, vtx_x, weight)
### pi+ or pi-
if((pdgId == 211 or pdgId == -211) and trackId!=1):
allHistoDict["tracking_planes_background_track_x_pions_"+str(staveId)].Fill(xPos, weight)
if(energyVal>1.0):
allHistoDict["tracking_planes_background_track_x_pions_1GeVCut_"+str(staveId)].Fill(xPos, weight)
allHistoDict["tracking_planes_background_track_x_pions_sumE_"+str(staveId)].Fill(xPos, energyVal*weight)
allHistoDict["tracking_planes_background_track_e_pions_log_"+str(staveId)].Fill(energyVal, weight)
allHistoDict["tracking_planes_background_vtx_z_track_e_pions_log_"+str(staveId)].Fill(vtx_z, energyVal, weight)
allHistoDict["tracking_planes_background_vtx_x_track_e_pions_log_"+str(staveId)].Fill(vtx_x, energyVal, weight)
allHistoDict["tracking_planes_background_vtxz_vtxx_pions_"+str(staveId)].Fill(vtx_z, vtx_x, weight)
### pi0
if((pdgId == 111 or pdgId == -111) and trackId!=1):
allHistoDict["tracking_planes_background_track_x_pi0_"+str(staveId)].Fill(xPos, weight)
if(energyVal>1.0):
allHistoDict["tracking_planes_background_track_x_pi0_1GeVCut_"+str(staveId)].Fill(xPos, weight)
allHistoDict["tracking_planes_background_track_x_pi0_sumE_"+str(staveId)].Fill(xPos, energyVal*weight)
allHistoDict["tracking_planes_background_track_e_pi0_log_"+str(staveId)].Fill(energyVal, weight)
allHistoDict["tracking_planes_background_vtx_z_track_e_pi0_log_"+str(staveId)].Fill(vtx_z, energyVal, weight)
allHistoDict["tracking_planes_background_vtx_x_track_e_pi0_log_"+str(staveId)].Fill(vtx_x, energyVal, weight)
allHistoDict["tracking_planes_background_vtxz_vtxx_pi0_"+str(staveId)].Fill(vtx_z, vtx_x, weight)
### positrons
if(pdgId == -11 and trackId!=1):
allHistoDict["tracking_planes_background_track_x_positrons_"+str(staveId)].Fill(xPos, weight)
if(energyVal>1.0):
allHistoDict["tracking_planes_background_track_x_positrons_1GeVCut_"+str(staveId)].Fill(xPos, weight)
allHistoDict["tracking_planes_background_track_x_positrons_sumE_"+str(staveId)].Fill(xPos, energyVal*weight)
allHistoDict["tracking_planes_background_track_e_positrons_log_"+str(staveId)].Fill(energyVal, weight)
allHistoDict["tracking_planes_background_vtx_z_track_e_positrons_log_"+str(staveId)].Fill(vtx_z, energyVal, weight)
allHistoDict["tracking_planes_background_vtx_x_track_e_positrons_log_"+str(staveId)].Fill(vtx_x, energyVal, weight)
allHistoDict["tracking_planes_background_vtxz_vtxx_positrons_"+str(staveId)].Fill(vtx_z, vtx_x, weight)
### photon
if(pdgId == 22 and trackId!=1):
allHistoDict["tracking_planes_background_track_x_gamma_"+str(staveId)].Fill(xPos, weight)
if(energyVal>1.0):
allHistoDict["tracking_planes_background_track_x_gamma_1GeVCut_"+str(staveId)].Fill(xPos, weight)
allHistoDict["tracking_planes_background_track_x_gamma_sumE_"+str(staveId)].Fill(xPos, energyVal*weight)
allHistoDict["tracking_planes_background_track_e_gamma_log_"+str(staveId)].Fill(energyVal, weight)
allHistoDict["tracking_planes_background_vtx_z_track_e_gamma_log_"+str(staveId)].Fill(vtx_z, energyVal, weight)
allHistoDict["tracking_planes_background_vtx_x_track_e_gamma_log_"+str(staveId)].Fill(vtx_x, energyVal, weight)
allHistoDict["tracking_planes_background_vtxz_vtxx_gamma_"+str(staveId)].Fill(vtx_z, vtx_x, weight)
for keys in allHistoDict:
allHistoDict[keys].Scale(1./nbx)
allHistoDict[keys].Write()
outFile.Close()
if __name__=="__main__":
start = time.time()
main()
print("--- The time taken: ", time.time() - start, " s")