ATLAS Offline Software
Functions
normalizator Namespace Reference

Functions

def browseDir (dir)
 
def main (argv)
 

Function Documentation

◆ browseDir()

def normalizator.browseDir (   dir)

Definition at line 15 of file normalizator.py.

15 def browseDir( dir ):
16  #print dir.GetPath().split(':', 1)[-1]
17  path = dir.GetPath().split(':/', 1)[-1]
18  pathdir = dir #.GetDirectory(path)
19  #print pathdir.GetPath()
20  keylist = dir.GetListOfKeys()
21 
22  for key in keylist:
23  obj = key.ReadObj()
24 
25  #2D histograms cannot be compared, tprofiles and efficiencies should not be normalized; skip
26  if obj.IsA().InheritsFrom(ROOT.TH2.Class()) or obj.IsA().InheritsFrom(ROOT.TProfile.Class()) or "fficiency" in obj.GetName() or 'RecoFraction' in obj.GetName() or 'purity' in obj.GetName() or "PtResol" in obj.GetName() or "PtScale" in obj.GetName() or "Prof" in obj.GetName() or "Fit" in obj.GetName():
27  continue
28 
29  if obj.IsA().InheritsFrom(ROOT.TH1.Class()) :
30  #normalize
31  #print '----- ', obj.GetName()
32  ii = 1.*obj.Integral()
33  hname = obj.GetName()
34  if ii>0:
35  obj.Scale(1./ii)
36  #print ' ',hname
37  pathdir.WriteTObject( obj , hname , "WriteDelete" )
38  continue
39 
40  if obj.IsA().InheritsFrom(ROOT.TDirectory.Class()):
41  #print obj.GetName()
42  browseDir(obj)
43 
44 
45 
46 #======================================================================

◆ main()

def normalizator.main (   argv)
Main function to be executed when starting the code.

Definition at line 47 of file normalizator.py.

47 def main( argv ):
48  """
49  Main function to be executed when starting the code.
50  """
51 
52  if len( argv ) < 2:
53  print( 'No filename given' )
54  print( 'Usage: python '+argv[0]+' physval_filename' )
55  exit(1)
56 
57  filename = argv[1]
58  if not os.path.exists( filename ):
59  print ( 'File not found: ' + filename )
60  exit(1)
61 
62  try:
63  infile = ROOT.TFile.Open( filename, 'update' )
64  except:
65  print( 'Cannot open file: {0}'.format( filename ) )
66  exit(1)
67 
68  ROOT.gROOT.SetBatch()
69 
70  infile.cd("Muons")
71  topDir = infile.GetDirectory("Muons")
72 
73  browseDir(topDir)
74  infile.Close()
75 
76 #======================================================================
77 
vtune_athena.format
format
Definition: vtune_athena.py:14
normalizator.browseDir
def browseDir(dir)
Definition: normalizator.py:15
calibdata.exit
exit
Definition: calibdata.py:236
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
normalizator.main
def main(argv)
Definition: normalizator.py:47
Trk::split
@ split
Definition: LayerMaterialProperties.h:38