16 hist = infile.GetDirectory(HistDir).
Get(HistName)
17 if hist.GetEntries() < 10:
18 print(
'INFO Skipping Fit. NumEntries = {0}: '.
format(hist.GetEntries()) + HistName )
20 gaus2 = ROOT.TF1(
"gaus2",
"gaus", -2, 2 )
21 gaus5 = ROOT.TF1(
"gaus",
"gaus", -5, 5 )
22 if int(hist.Fit(gaus2,
"RQ")) != 0:
23 print(
'WARNING fit failed for ' + HistName )
25 hist.GetListOfFunctions().Add(gaus5)
26 f1 = hist.GetFunction(
"gaus")
27 f1.SetParameters( hist.GetFunction(
"gaus2").GetParameters() )
28 hist.GetListOfFunctions().Remove( gaus2 )
29 f1.SetLineColor(ROOT.kRed)
30 print(
'INFO Overwriting histogram: ' + HistDir +
'/' + HistName )
31 hist.GetDirectory().WriteTObject( hist, HistName,
"Overwrite" )
38 print(
'Usage: python {0} filename'.
format( args[0] ) )
41 if not os.path.exists( filename ):
42 print (
'File not found: ' + filename )
45 infile = ROOT.TFile.Open( filename,
'update' )
47 MuonTypes = [
'All',
'Prompt',
'InFlight',
'NonIsolated' ]
48 PullTypes = [
'',
'ID',
'MS' ]
49 Variables = [
'phi',
'theta',
'qOverP',
'd0',
'z0' ]
51 for MuonType
in MuonTypes:
52 if not infile.Get(
'Muons/' + MuonType ):
53 print(
'INFO TDirectory not found: Muons/' + MuonType )
55 AuthDir = infile.Get(
'Muons/{0}/matched'.
format( MuonType ) )
56 Authors = [ i.GetName()
for i
in AuthDir.GetListOfKeys()
if AuthDir.Get( i.GetName() ).InheritsFrom(
'TDirectory' ) ]
57 for Author
in Authors:
58 DirName =
'Muons/{0}/matched/{1}/Pulls'.
format( MuonType, Author )
59 Dir = infile.Get( DirName )
61 print(
'INFO TDirectory not found: ' + DirName )
63 for PullType, var
in itertools.product( PullTypes, Variables ):
64 HistName =
'_'.
join( DirName.split(
'/') ) +
'_Pull{0}_'.
format(PullType) + var
65 if not Dir.Get( HistName ):
66 print(
'INFO Histogram not found: ' + HistName )
73 if __name__ ==
"__main__":