5 from array
import array
8 from MuonValidation_CreateResolutionProfiles
import *
14 hist = infile.Get(HistDir).
Get(HistName)
19 prof_ave.SetName( hist.GetName().
replace(
'_vs_',
'_ProfMean_vs_' ) )
20 prof_ave.SetTitle( Var +
' Pull vs pt (Mean)' )
21 prof_ave.SetXTitle(
'Transverse Momentum [GeV]' )
22 prof_ave.SetYTitle( Var +
' Pull Mean' )
24 prof_std.SetName( hist.GetName().
replace(
'_vs_',
'_ProfStDev_vs_' ) )
25 prof_std.SetTitle( Var +
' Pull vs pt (StDev)' )
26 prof_std.SetXTitle(
'Transverse Momentum [GeV]' )
27 prof_std.SetYTitle( Var +
' Pull StdDev' )
29 if not infile.Get( HistDir ).WriteTObject( prof_ave, prof_ave.GetName(),
"Overwrite" ):
30 print(
'WARNING Failed to write histogram to file: ' + HistDir +
'/' + prof_ave.GetName() )
31 if not infile.Get( HistDir ).WriteTObject( prof_std, prof_std.GetName(),
"Overwrite" ):
32 print(
'WARNING Failed to write histogram to file: ' + HistDir +
'/' + prof_std.GetName() )
33 del prof_ave, prof_std
41 if len(args) > 2
and args[2] ==
'doAverage':
44 print(
'Usage: python {0} filename [doAverage]'.
format( args[0] ) )
47 if not os.path.exists( filename ):
48 print (
'File not found: ' + filename )
51 infile = ROOT.TFile.Open( filename,
'update' )
53 MuonTypes = [
'All',
'Prompt' ]
54 Variables = [
'phi',
'theta',
'qOverP',
'd0',
'z0' ]
56 for MuonType
in MuonTypes:
57 if not infile.Get(
'Muons/' + MuonType ):
58 print(
'INFO TDirectory not found: Muons/' + MuonType )
60 AuthDir = infile.Get(
'Muons/{0}/matched'.
format( MuonType ) )
61 Authors = [ i.GetName()
for i
in AuthDir.GetListOfKeys()
if AuthDir.Get( i.GetName() ).InheritsFrom(
'TDirectory' ) ]
62 for Author
in Authors:
63 DirName =
'Muons/{0}/matched/{1}/Pulls'.
format( MuonType, Author )
64 Dir = infile.Get( DirName )
66 print(
'INFO TDirectory not found: ' + DirName )
69 HistName =
'_'.
join( DirName.split(
'/') ) +
'_Pull_{0}_vs_pt'.
format(var)
70 if not Dir.Get( HistName ):
71 print(
'INFO Histogram not found: ' + HistName )
73 CreateProfile( infile, DirName, HistName, var, doAverage = doAverage )
78 if __name__ ==
"__main__":