ATLAS Offline Software
print_hole_log.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 __author__ = 'Ryan D. Reece <ryan.reece@cern.ch>'
3 __date__ = '2009-04-20'
4 __doc__ = """
5 NAME
6  print_hole_log.py - Creates a log file of TRT holes.
7 
8 SYNOPSIS
9  print_hole_log.py (no arguments)
10 
11 DESCRIPTION
12  Creates a log file of TRT holes from reading Ryan's
13  trt_eff.root ntuple for TRT straw efficiency studies.
14 
15 AUTHOR
16  %(author)s
17 
18 %(date)s
19 """ % {'author':__author__, 'date':__date__, 'copyright':__copyright__, 'license':__license__}
20 #------------------------------------------------------------------------------
21 
22 import sys
23 import ROOT, ROOT_vector_vector
24 
25 #______________________________________________________________________________
26 def main(argv):
27  f = ROOT.TFile('trt_eff.root', 'READ')
28  t = f.Get('trt_eff')
29 
30  o = file('trt_holes.log', 'w')
31 
32  event_number = 0
33 
34  # loop over tracks
35  nentries = t.GetEntries()
36  for i in xrange(nentries):
37  t.GetEntry(i)
38  if event_number != t.event_number:
39  # new event
40  event_number = t.event_number
41  o.write('======================================================================================\n')
42  o.write(' Run: %10s, LB: %10s, Event: %10s\n' % (t.run_number, t.lumi_block, t.event_number) )
43  o.write('======================================================================================\n')
44  o.write('--------------------------------------------------------------------------------------\n')
45  o.write(' Track pT: %4g, eta: %3f, phi: %3f, d0: %4g, z0: %4g\n' % (t.track_pt, t.track_eta, t.track_phi, t.track_d0, t.track_z0) )
46  o.write(' # pix hits: %3i, # SCT hits: %3i, # TRT hits: %3i\n' % (t.n_pixel_hits, t.n_sct_hits, t.n_trt_hits) )
47  o.write(' # pix holes: %3i, # SCT holes: %3i, # TRT holes: %3i\n' % (t.n_pixel_holes, t.n_sct_holes, t.n_trt_holes) )
48  o.write('------ TRT holes -------------------------------\n')
49  o.write(' # bec phi layer strawlayer straw locR locR_error x y z\n')
50  # loop over holes
51  n_holes = len(t.hole_det)
52  for i in xrange(n_holes):
53  if t.hole_det[i] == 3: # TRT
54  o.write('%(n)3i %(bec)3i %(phi)3i %(layer)3i %(strawlayer)3i %(straw)3i %(locR)8.4g %(locR_error)11.2g %(x)8.4g %(y)8.4g %(z)8.4g\n' % {
55  'n' : i+1,
56  'bec' : t.hole_bec[i],
57  'phi' : t.hole_phi[i],
58  'layer' : t.hole_layer[i],
59  'strawlayer' : t.hole_strawlayer[i],
60  'straw' : t.hole_straw[i],
61  'locR' : t.hole_locR[i],
62  'locR_error' : t.hole_locR_error[i],
63  'x' : t.hole_x[i],
64  'y' : t.hole_y[i],
65  'z' : t.hole_z[i],
66  } )
67 
68 
69 
70 #______________________________________________________________________________
71 if __name__ == '__main__':
72  main(sys.argv[1:])
73 
xrange
void xrange(TH1 *h, bool symmetric)
Definition: computils.cxx:515
print_hole_log.main
def main(argv)
Definition: print_hole_log.py:26
file
TFile * file
Definition: tile_monitor.h:29