dumpTree.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import sys
4 import os.path
5 import os
6 import ROOT
7 from optparse import OptionParser
8 import xml.etree.ElementTree as ET
9 from array import array
10 from math import cos, sin
11 
12 import pyGeoEff
13 
14 def loop( evt, tgeo, tout ):
15 
16  offset = [ 0., 5.5, 411. ]
17  collarLo = [ -320., -120., 30. ]
18  collarHi = [ 320., 120., 470. ]
19 
20  # Initialize geometric efficiency module.
21  geoEff = pyGeoEff.geoEff(args.seed)
22  # Multiple of 64 doesn't waste bits
23  geoEff.setNthrows(4992)
24  # Use neutrino decay position, rather than fixed neutrino direction as symmetry axis
25  geoEff.setUseFixedBeamDir(False)
26 
27  # Average neutrino decay position in beam coordinates as a function of vertex x (from Luke): Will be used to set the decay position event-by-event.
28  OffAxisPoints = array('f', [-2, 0.5, 3, 5.5, 8, 10.5, 13, 15.5, 18, 20.5, 23, 25.5, 28, 30.5])
29  meanPDPZ = array('f', [ 93.6072, 93.362, 90.346, 85.6266, 81.1443, 76.6664, 73.0865, 69.8348, 67.5822, 65.005, 62.4821, 60.8336, 59.1433, 57.7352])
30  gDecayZ = ROOT.TGraph(14, OffAxisPoints, meanPDPZ)
31 
32  # Get beam parameters
33  try :
34  GNuMIFluxTree = ET.parse(os.environ["GNUMIXML"])
35  beamLineRotation = float(GNuMIFluxTree.getroot()[0].findall('beamdir')[0].findall('rotation')[0].text)
36  posText = GNuMIFluxTree.getroot()[0].findall('beampos')[0].text
37  posText = posText.replace("(", "")
38  posText = posText.replace(")", "")
39  posText = posText.replace("=", ",")
40  posText = posText.split(",")
41  beamRefDetCoord = [ float(posText[i]) for i in range(3)]
42  detRefBeamCoord = [ float(posText[i]) for i in range(3,6)]
43  except Exception, e:
44  print(str(e))
45  print("dumpTree.py WARNING!!! Error reading GNUMIXML file. Set GNUMIXML enviornment variable to point at GNuMI flux configuration xml file. Exitting!")
46  exit(-1)
47 
48  # 30 cm veto
49  geoEff.setVetoSizes([30])
50  # 20, 30 and 40 MeV threshold
51  geoEff.setVetoEnergyThresholds([20, 30, 40])
52  # Active detector dimensions
53  geoEff.setActiveX(collarLo[0]-30, collarHi[0]+30)
54  geoEff.setActiveY(collarLo[1]-30, collarHi[1]+30)
55  geoEff.setActiveZ(collarLo[2]-30, collarHi[2]+30)
56  # Range for translation throws. Use full active volume but fix X.
57  geoEff.setRangeX(-1, -1)
58  geoEff.setRandomizeX(False)
59  geoEff.setRangeY(collarLo[1]-30, collarHi[1]+30)
60  geoEff.setRangeZ(collarLo[2]-30, collarHi[2]+30)
61  # Set offset between MC coordinate system and volumes defined above.
62  geoEff.setOffsetX(offset[0])
63  geoEff.setOffsetY(offset[1])
64  geoEff.setOffsetZ(offset[2])
65 
66  event = ROOT.TG4Event()
67  events.SetBranchAddress("Event",ROOT.AddressOf(event))
68 
69  N = events.GetEntries()
70 
71  print "Starting loop over %d entries" % N
72  ient = 0 # This is unnecessary
73  iwritten = 0
74  for ient in range(N):
75 
76  if ient % 100 == 0:
77  print "Event %d of %d..." % (ient,N)
78  events.GetEntry(ient)
79 
80  for ivtx,vertex in enumerate(event.Primaries):
81 
82  ## initialize output variables
83  t_ievt[0] = ient;
84  t_vtx[0]=0.0; t_vtx[1]=0.0; t_vtx[2]=0.0;
85  t_p3lep[0]=0.0; t_p3lep[1]=0.0; t_p3lep[2]=0.0;
86  t_lepDeath[0]=0.0; t_lepDeath[1]=0.0; t_lepDeath[2]=0.0;
87  t_lepPdg[0] = 0
88  t_lepKE[0] = 0.
89  t_muonExitPt[0] = 0.0; t_muonExitPt[1] = 0.0; t_muonExitPt[2] = 0.0;
90  t_muonExitMom[0] = 0.0; t_muonExitMom[1] = 0.0; t_muonExitMom[2] = 0.0;
91  t_muonReco[0] = -1;
92  t_muon_endVolName.replace(0, ROOT.std.string.npos, "")
93  t_muGArLen[0]=0.0;
94  t_hadTot[0] = 0.
95  t_hadP[0] = 0.
96  t_hadN[0] = 0.
97  t_hadPip[0] = 0.
98  t_hadPim[0] = 0.
99  t_hadPi0[0] = 0.
100  t_hadOther[0] = 0.
101  t_hadCollar[0] = 0.
102  t_nFS[0] = 0
103  ## done
104 
105  # now ID numucc
106  reaction=vertex.Reaction
107 
108  # set the vertex location for output
109  for i in range(3):
110  t_vtx[i] = vertex.Position[i] / 10. - offset[i] # cm
111 
112  # fiducial vertex pre-cut
113  #if abs(t_vtx[0]) > 310. or abs(t_vtx[1]) > 110. or t_vtx[2] < 40. or t_vtx[2] > 360.:
114  # continue
115 
116  # Use vertex to determine mean decay point
117  decayZbeamCoord = gDecayZ.Eval(vertex.Position[0] / 1000 - detRefBeamCoord[0])*100 # in cm
118  decayZdetCoord = (-1*detRefBeamCoord[2]*100+decayZbeamCoord)*cos(beamLineRotation) - (-1*detRefBeamCoord[1]*100*sin(beamLineRotation)) + beamRefDetCoord[2]*100
119  decayYdetCoord = (-1*detRefBeamCoord[1]*100*cos(beamLineRotation)) + (-1*detRefBeamCoord[2]*100+decayZbeamCoord)*sin(beamLineRotation) + beamRefDetCoord[1]*100
120  decayXdetCoord = -1*detRefBeamCoord[0]*100 + beamRefDetCoord[0]*100
121 
122  geoEff.setDecayPos(decayXdetCoord, decayYdetCoord, decayZdetCoord)
123  geoEff.setVertex(vertex.Position[0] / 10., vertex.Position[1] / 10.,vertex.Position[2] / 10.)
124 
125  # Renew throws every 100th event written to the output file.
126  if (iwritten % 100) == 0 :
127  geoEff.throwTransforms()
128  t_geoEffThrowsY.clear()
129  for i in geoEff.getCurrentThrowTranslationsY() :
130  t_geoEffThrowsY.push_back(i)
131  t_geoEffThrowsZ.clear()
132  for i in geoEff.getCurrentThrowTranslationsZ() :
133  t_geoEffThrowsZ.push_back(i)
134  t_geoEffThrowsPhi.clear()
135  for i in geoEff.getCurrentThrowRotations() :
136  t_geoEffThrowsPhi.push_back(i)
137  tGeoEfficiencyThrowsOut.Fill()
138 
139  ileptraj = -1
140  nfsp = 0
141  nHadrons = 0
142  # get the lepton kinematics from the edepsim file
143  fsParticleIdx = {}
144  for ipart,particle in enumerate(vertex.Particles):
145  e = particle.Momentum[3]
146  p = (particle.Momentum[0]**2 + particle.Momentum[1]**2 + particle.Momentum[2]**2)**0.5
147  m = (e**2 - p**2)**0.5
148  t_fsPdg[nfsp] = particle.PDGCode
149  t_fsPx[nfsp] = particle.Momentum[0]
150  t_fsPy[nfsp] = particle.Momentum[1]
151  t_fsPz[nfsp] = particle.Momentum[2]
152  t_fsE[nfsp] = e
153  fsParticleIdx[particle.TrackId] = nfsp
154  nfsp += 1
155  pdg = particle.PDGCode
156  if abs(pdg) in [11,12,13,14]:
157  ileptraj = particle.TrackId
158  t_lepPdg[0] = pdg
159  # set the muon momentum for output
160  for i in range(3): t_p3lep[i] = particle.Momentum[i]
161  t_lepKE[0] = e - m
162 
163  assert ileptraj != -1, "There isn't a lepton??"
164  t_nFS[0] = nfsp
165 
166  # If there is a muon, determine how to reconstruct its momentum and charge
167  if abs(t_lepPdg[0]) == 13:
168  leptraj = event.Trajectories[ileptraj]
169  for p in leptraj.Points:
170  pt = p.Position
171  node = tgeo.FindNode( pt.X(), pt.Y(), pt.Z() )
172  volName = node.GetName()
173  active = False
174  if "LAr" in volName or "PixelPlane" in volName or "sPlane" in volName: # in active volume, update exit points
175  t_muonExitPt[0] = pt.X() / 10. - offset[0]
176  t_muonExitPt[1] = pt.Y() / 10. - offset[1]
177  t_muonExitPt[2] = pt.Z() / 10. - offset[2]
178  t_muonExitMom[0] = p.Momentum.x()
179  t_muonExitMom[1] = p.Momentum.y()
180  t_muonExitMom[2] = p.Momentum.z()
181  else:
182  t_muonExitPt[0] = pt.X() / 10. - offset[0]
183  t_muonExitPt[1] = pt.Y() / 10. - offset[1]
184  t_muonExitPt[2] = pt.Z() / 10. - offset[2]
185  break
186 
187  endpt = leptraj.Points[-1].Position
188 
189  node = tgeo.FindNode( endpt.X(), endpt.Y(), endpt.Z() )
190 
191  t_lepDeath[0] = endpt.X()/10. - offset[0]
192  t_lepDeath[1] = endpt.Y()/10. - offset[1]
193  t_lepDeath[2] = endpt.Z()/10. - offset[2]
194 
195  endVolName = node.GetName()
196  t_muon_endVolName.replace(0, ROOT.std.string.npos, endVolName)
197  if "LArActive" in endVolName: t_muonReco[0] = 1 # contained
198  elif "ECal" in endVolName: t_muonReco[0] = 3 # ECAL stopper
199  else: t_muonReco[0] = 0 # endpoint not in active material, but might still be reconstructed by curvature if GAr length > 0
200 
201  # look for muon hits in the gas TPC
202  hits = []
203  for key in event.SegmentDetectors:
204  if key.first in ["TPC_Drift1", "TPC_Drift2"]:
205  hits += key.second
206 
207  tot_length = 0.0
208  for hit in hits:
209  if hit.PrimaryId == ileptraj: # hit is due to the muon
210  # TG4HitSegment::TrackLength includes all delta-rays, which spiral in gas TPC and give ridiculously long tracks
211  hStart = ROOT.TVector3( hit.Start[0]/10.-offset[0], hit.Start[1]/10.-offset[1], hit.Start[2]/10.-offset[2] )
212  hStop = ROOT.TVector3( hit.Stop[0]/10.-offset[0], hit.Stop[1]/10.-offset[1], hit.Stop[2]/10.-offset[2] )
213  tot_length += (hStop-hStart).Mag()
214 
215  # look for muon hits in the ECAL
216  ehits = []
217  for key in event.SegmentDetectors:
218  if key.first in ["BarrelECal_vol", "EndcapECal_vol"]:
219  ehits += key.second
220 
221  etot_length = 0.0
222  for hit in ehits:
223  if hit.PrimaryId == ileptraj: # hit is due to the muon
224  # TG4HitSegment::TrackLength includes all delta-rays, which spiral in gas TPC and give ridiculously long tracks
225  hStart = ROOT.TVector3( hit.Start[0]/10.-offset[0], hit.Start[1]/10.-offset[1], hit.Start[2]/10.-offset[2] )
226  hStop = ROOT.TVector3( hit.Stop[0]/10.-offset[0], hit.Stop[1]/10.-offset[1], hit.Stop[2]/10.-offset[2] )
227  etot_length += (hStop-hStart).Mag()
228 
229  t_muGArLen[0] = tot_length
230  t_muECalLen[0] = etot_length
231 
232  if tot_length > 50.: t_muonReco[0] = 2 # tracker
233 
234  # hadronic containment -- find hits in ArgonCube
235  hits = []
236  for key in event.SegmentDetectors:
237  if key.first == "ArgonCube":
238  hits += key.second
239 
240  # Truth-matching energy -- make dictionary of trajectory --> primary pdg
241  traj_to_pdg = {}
242  # For pi0s, stop at the photons to determine the visible energy due to gamma1/gamma2
243  tid_to_gamma = {}
244  gamma_tids = []
245  for traj in event.Trajectories:
246  mom = traj.ParentId
247  tid = traj.TrackId
248  if event.Trajectories[mom].PDGCode == 111 and event.Trajectories[tid].PDGCode == 22 and event.Trajectories[mom].ParentId == -1:
249  gamma_tids.append(tid)
250  while mom != -1:
251  tid = mom
252  mom = event.Trajectories[mom].ParentId
253  if mom in gamma_tids:
254  tid_to_gamma[tid] = mom
255  traj_to_pdg[traj] = event.Trajectories[tid].PDGCode
256 
257  collar_energy = 0.
258  total_energy = 0.
259 
260  geoEff_EDepPosition = []
261  geoEff_EDepEnergy = []
262 
263  track_length = [0. for i in range(nfsp)]
264  dEdX = [[] for i in range(nfsp)]
265  this_step = [[0.,0.] for i in range(nfsp)]
266  end_point = [None for i in range(nfsp)]
267  int_energy = [0. for i in range(nfsp)]
268  trk_calo = [0. for i in range(nfsp)]
269  gamma_energy = {}
270  for g in gamma_tids:
271  gamma_energy[g] = 0.
272  for hit in hits:
273  hStart = ROOT.TVector3( hit.Start[0]/10.-offset[0], hit.Start[1]/10.-offset[1], hit.Start[2]/10.-offset[2] )
274  hStop = ROOT.TVector3( hit.Stop[0]/10.-offset[0], hit.Stop[1]/10.-offset[1], hit.Stop[2]/10.-offset[2] )
275 
276  # Don't use edep-sim's PrimaryId, which thinks you want to associate absoltely everything with the primary
277  # Instead, get the actual contributors (usually only one) and take the biggest
278  tid = hit.Contrib[0]
279 
280  traj = event.Trajectories[tid]
281  if traj.ParentId == -1: # primary particle
282  idx = fsParticleIdx[hit.PrimaryId]
283  trk_calo[idx] += hit.EnergyDeposit
284  end_point[idx] = hStop
285  dx = (hStop-hStart).Mag()
286  track_length[idx] += dx
287  this_step[idx][1] += dx
288  this_step[idx][0] += hit.EnergyDeposit
289  if this_step[idx][1] > 0.5:
290  dEdX[idx].append( (this_step[idx][0], this_step[idx][1], hStart) ) # MeV/cm
291  this_step[idx] = [0., 0.]
292  else: # non-primary energy
293  for k,ep in enumerate(end_point):
294  if ep is None: continue
295  if (hStart-ep).Mag() < 10.:
296  int_energy[k] += hit.EnergyDeposit
297 
298  if tid in tid_to_gamma:
299  gamma_energy[tid_to_gamma[tid]] += hit.EnergyDeposit
300 
301  if hit.PrimaryId != ileptraj: # here we do want to associate stuff to the lepton
302  hStart = ROOT.TVector3( hit.Start[0]/10.-offset[0], hit.Start[1]/10.-offset[1], hit.Start[2]/10.-offset[2] )
303  total_energy += hit.EnergyDeposit
304 
305  # check if hit is in collar region
306  if hStart.x() < collarLo[0] or hStart.x() > collarHi[0] or hStart.y() < collarLo[1] or hStart.y() > collarHi[1] or hStart.z() < collarLo[2] or hStart.z() > collarHi[2]:
307  collar_energy += hit.EnergyDeposit
308 
309  # Set up arrays for geometric efficiency
310  for dim in range(3) :
311  geoEff_EDepPosition.append((hit.Start[dim] + hit.Stop[dim])/2./10.)
312  geoEff_EDepEnergy.append(hit.EnergyDeposit)
313 
314  # Determine primary particle
315  pdg = traj_to_pdg[traj]
316  if pdg in [11, -11, 13, -13]: continue # lepton
317  elif pdg == 2212: t_hadP[0] += hit.EnergyDeposit
318  elif pdg == 2112: t_hadN[0] += hit.EnergyDeposit
319  elif pdg == 211: t_hadPip[0] += hit.EnergyDeposit
320  elif pdg == -211: t_hadPim[0] += hit.EnergyDeposit
321  elif pdg == 111: t_hadPi0[0] += hit.EnergyDeposit
322  else: t_hadOther[0] += hit.EnergyDeposit
323 
324  t_hadTot[0] = total_energy
325  t_hadCollar[0] = collar_energy
326 
327  geoEff.setHitSegEdeps(geoEff_EDepEnergy)
328  geoEff.setHitSegPoss(geoEff_EDepPosition)
329 
330  geoEffThrowResultsList = geoEff.getHadronContainmentThrows()
331 
332  t_geoEffThrowResults.clear()
333  for i in range(len(geoEffThrowResultsList)) :
334  iVec = ROOT.std.vector('vector< uint64_t >')()
335  for j in range (len(geoEffThrowResultsList[i])) :
336  jVec = ROOT.std.vector('uint64_t')()
337  for k in range(len(geoEffThrowResultsList[i][j])) :
338  jVec.push_back(geoEffThrowResultsList[i][j][k])
339  iVec.push_back(jVec)
340  t_geoEffThrowResults.push_back(iVec)
341 
342  for i in range(nfsp):
343  t_fsTrkLen[i] = track_length[i]
344  # Average of anything in the last 3cm of track
345  t_fsTrkEnddEdX[i] = 0.
346  t_fsTrkFrontdEdX[i] = 0.
347  totlen = 0.
348  j = len(dEdX[i])-1
349  while j >= 0:
350  totlen += dEdX[i][j][1]
351  t_fsTrkEnddEdX[i] += dEdX[i][j][0]
352  j -= 1
353  if totlen > 3.: break
354  if totlen > 0.: t_fsTrkEnddEdX[i] /= totlen
355 
356  totlen = 0.
357  for k in range(j+1):
358  totlen += dEdX[i][k][1]
359  t_fsTrkFrontdEdX[i] += dEdX[i][k][0]
360  if totlen > 0.: t_fsTrkFrontdEdX[i] /= totlen
361 
362  t_fsTrkEndpointBall[i] = int_energy[i]
363  t_fsTrkCalo[i] = trk_calo[i]
364 
365  t_fsGamma1[i] = 0.
366  t_fsGamma2[i] = 0.
367 
368  # Photons
369  for t in gamma_tids:
370  mom = event.Trajectories[t].ParentId
371  if t_fsGamma1[mom] == 0.: t_fsGamma1[mom] = gamma_energy[t]
372  elif t_fsGamma2[mom] == 0.: t_fsGamma2[mom] = gamma_energy[t]
373  else:
374  print "Pi0 has more than two photons wtf"
375 
376 
377  tout.Fill()
378  iwritten += 1
379  ient += 1 # This is unnecessary
380 
381 
382 if __name__ == "__main__":
383 
384  ROOT.gROOT.SetBatch(1)
385 
386  parser = OptionParser()
387  parser.add_option('--infile', help='Input file name', default="edep.root")
388  parser.add_option('--outfile', help='Output file name', default="out.root")
389  parser.add_option('--seed', help='Seed for geometric efficiency throws', default=0, type = "int")
390 
391  (args, dummy) = parser.parse_args()
392 
393  # make an output ntuple
394  fout = ROOT.TFile( args.outfile, "RECREATE" )
395  tout = ROOT.TTree( "tree","tree" )
396  t_ievt = array('i',[0])
397  tout.Branch('ievt',t_ievt,'ievt/I')
398  t_Ev = array('f', [0.])
399  tout.Branch('Ev',t_Ev,'Ev/F')
400  t_p3lep = array('f',3*[0.0])
401  tout.Branch('p3lep',t_p3lep,'p3lep[3]/F')
402  t_vtx = array('f',3*[0.0])
403  tout.Branch('vtx',t_vtx,'vtx[3]/F')
404  t_lepDeath = array('f',3*[0.0])
405  tout.Branch('lepDeath',t_lepDeath,'lepDeath[3]/F')
406  t_lepPdg = array('i',[0])
407  tout.Branch('lepPdg',t_lepPdg,'lepPdg/I')
408  t_lepKE = array('f',[0])
409  tout.Branch('lepKE',t_lepKE,'lepKE/F')
410  t_muonExitPt = array('f',3*[0.0])
411  tout.Branch('muonExitPt',t_muonExitPt,'muonExitPt[3]/F')
412  t_muonExitMom = array('f',3*[0.0])
413  tout.Branch('muonExitMom',t_muonExitMom,'muonExitMom[3]/F')
414  t_muonReco = array('i',[0])
415  tout.Branch('muonReco',t_muonReco,'muonReco/I')
416  t_muon_endVolName = ROOT.std.string()
417  tout.Branch('muon_endVolName', t_muon_endVolName)
418  t_muGArLen = array('f',[0])
419  tout.Branch('muGArLen',t_muGArLen,'muGArLen/F')
420  t_muECalLen = array('f',[0])
421  tout.Branch('muECalLen',t_muECalLen,'muECalLen/F')
422  t_hadTot = array('f', [0.] )
423  tout.Branch('hadTot', t_hadTot, 'hadTot/F' )
424  t_hadP = array('f', [0.] )
425  tout.Branch('hadP', t_hadP, 'hadP/F' )
426  t_hadN = array('f', [0.] )
427  tout.Branch('hadN', t_hadN, 'hadN/F' )
428  t_hadPip = array('f', [0.] )
429  tout.Branch('hadPip', t_hadPip, 'hadPip/F' )
430  t_hadPim = array('f', [0.] )
431  tout.Branch('hadPim', t_hadPim, 'hadPim/F' )
432  t_hadPi0 = array('f', [0.] )
433  tout.Branch('hadPi0', t_hadPi0, 'hadPi0/F' )
434  t_hadOther = array('f', [0.] )
435  tout.Branch('hadOther', t_hadOther, 'hadOther/F' )
436  t_hadCollar = array('f', [0.] )
437  tout.Branch('hadCollar', t_hadCollar, 'hadCollar/F' )
438  t_nFS = array('i',[0])
439  tout.Branch('nFS',t_nFS,'nFS/I')
440  t_fsPdg = array('i',100*[0])
441  tout.Branch('fsPdg',t_fsPdg,'fsPdg[nFS]/I')
442  t_fsPx = array('f',100*[0.])
443  tout.Branch('fsPx',t_fsPx,'fsPx[nFS]/F')
444  t_fsPy = array('f',100*[0.])
445  tout.Branch('fsPy',t_fsPy,'fsPy[nFS]/F')
446  t_fsPz = array('f',100*[0.])
447  tout.Branch('fsPz',t_fsPz,'fsPz[nFS]/F')
448  t_fsE = array('f',100*[0.])
449  tout.Branch('fsE',t_fsE,'fsE[nFS]/F')
450  t_fsTrkLen = array('f',100*[0.])
451  tout.Branch('fsTrkLen',t_fsTrkLen,'fsTrkLen[nFS]/F')
452  t_fsTrkFrontdEdX = array('f',100*[0.])
453  tout.Branch('fsTrkFrontdEdX',t_fsTrkFrontdEdX,'fsTrkFrontdEdX[nFS]/F')
454  t_fsTrkEnddEdX = array('f',100*[0.])
455  tout.Branch('fsTrkEnddEdX',t_fsTrkEnddEdX,'fsTrkEnddEdX[nFS]/F')
456  t_fsTrkEndpointBall = array('f', 100*[0.])
457  tout.Branch('fsTrkEndpointBall',t_fsTrkEndpointBall,'fsTrkEndpointBall[nFS]/F')
458  t_fsGamma1 = array('f',100*[0.])
459  tout.Branch('fsGamma1',t_fsGamma1,'fsGamma1[nFS]/F')
460  t_fsGamma2 = array('f',100*[0.])
461  tout.Branch('fsGamma2',t_fsGamma2,'fsGamma2[nFS]/F')
462  t_fsTrkCalo = array('f',100*[0.])
463  tout.Branch('fsTrkCalo',t_fsTrkCalo,'fsTrkCalo[nFS]/F')
464 
465  # Geometric efficiency stuff
466  t_geoEffThrowResults = ROOT.std.vector('std::vector< std::vector < uint64_t > >')()
467  tout.Branch('geoEffThrowResults', t_geoEffThrowResults)
468 
469  # Separate TTree to store translations and rotations of throws
470  tGeoEfficiencyThrowsOut = ROOT.TTree( "geoEffThrows","geoEffThrows")
471  t_geoEffThrowsY = ROOT.std.vector('float')()
472  tGeoEfficiencyThrowsOut.Branch("geoEffThrowsY", t_geoEffThrowsY)
473  t_geoEffThrowsZ = ROOT.std.vector('float')()
474  tGeoEfficiencyThrowsOut.Branch("geoEffThrowsZ", t_geoEffThrowsZ)
475  t_geoEffThrowsPhi = ROOT.std.vector('float')()
476  tGeoEfficiencyThrowsOut.Branch("geoEffThrowsPhi", t_geoEffThrowsPhi)
477 
478  events = ROOT.TChain( "EDepSimEvents", "main event tree" )
479  #dspt = ROOT.TChain( "DetSimPassThru/gRooTracker", "other thing" )
480 
481  tf = ROOT.TFile( args.infile )
482  tf.MakeProject("EDepSimEvents","*","RECREATE++")
483 
484  events = tf.Get( "EDepSimEvents" )
485  tgeo = tf.Get("EDepSimGeometry")
486  loop( events, tgeo, tout )
487 
488  fout.cd()
489  tout.Write()
490  tGeoEfficiencyThrowsOut.Write()
491 
492 
493 
494 
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
def loop(evt, tgeo, tout)
Definition: dumpTree.py:14
T abs(T value)
auto array(Array const &a)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:228
static QCString str