ATLAS Offline Software
Loading...
Searching...
No Matches
normalizator Namespace Reference

Functions

 browseDir (dir)
 main (argv)

Function Documentation

◆ browseDir()

normalizator.browseDir ( dir)

Definition at line 15 of file normalizator.py.

15def 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#======================================================================
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

◆ main()

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

Definition at line 47 of file normalizator.py.

47def 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
void print(char *figname, TCanvas *c1)
int main()
Definition hello.cxx:18