ATLAS Offline Software
Functions
MuonValidation_CreatePullProfiles Namespace Reference

Functions

def CreateProfile (infile, HistDir, HistName, Var, doAverage=False)
 
def main (args)
 

Function Documentation

◆ CreateProfile()

def MuonValidation_CreatePullProfiles.CreateProfile (   infile,
  HistDir,
  HistName,
  Var,
  doAverage = False 
)

Definition at line 13 of file MuonValidation_CreatePullProfiles.py.

13 def CreateProfile( infile, HistDir, HistName, Var, doAverage = False ):
14  hist = infile.Get(HistDir).Get(HistName)
15  if not hist:
16  return
17  prof_ave, prof_std, projHists = GetProfilesFromTH2( hist, doAverage = doAverage )
18 
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' )
23 
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' )
28 
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
34 
35 #---------------------------------------------------------------------------
36 

◆ main()

def MuonValidation_CreatePullProfiles.main (   args)

Definition at line 37 of file MuonValidation_CreatePullProfiles.py.

37 def main( args ):
38  doAverage = False
39  if len( args ) > 1:
40  filename = args[1]
41  if len(args) > 2 and args[2] == 'doAverage':
42  doAverage = True
43  else:
44  print( 'Usage: python {0} filename [doAverage]'.format( args[0] ) )
45  return
46 
47  if not os.path.exists( filename ):
48  print ( 'File not found: ' + filename )
49  return
50 
51  infile = ROOT.TFile.Open( filename, 'update' )
52 
53  MuonTypes = [ 'All', 'Prompt' ] #, 'InFlight', 'NonIsolated' ]
54  Variables = [ 'phi', 'theta', 'qOverP', 'd0', 'z0' ]
55 
56  for MuonType in MuonTypes:
57  if not infile.Get( 'Muons/' + MuonType ):
58  print( 'INFO TDirectory not found: Muons/' + MuonType )
59  continue
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 )
65  if not Dir:
66  print( 'INFO TDirectory not found: ' + DirName )
67  continue
68  for var in Variables:
69  HistName = '_'.join( DirName.split('/') ) + '_Pull_{0}_vs_pt'.format(var)
70  if not Dir.Get( HistName ):
71  print( 'INFO Histogram not found: ' + HistName )
72  continue
73  CreateProfile( infile, DirName, HistName, var, doAverage = doAverage )
74  infile.Close()
75 
76 #---------------------------------------------------------------------------
77 
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
vtune_athena.format
format
Definition: vtune_athena.py:14
MuonValidation_CreatePullProfiles.main
def main(args)
Definition: MuonValidation_CreatePullProfiles.py:37
MuonValidation_CreateResolutionProfiles.GetProfilesFromTH2
def GetProfilesFromTH2(hist, doAverage)
Definition: MuonValidation_CreateResolutionProfiles.py:31
Get
T * Get(TFile &f, const std::string &n, const std::string &dir="", const chainmap_t *chainmap=0, std::vector< std::string > *saved=0)
get a histogram given a path, and an optional initial directory if histogram is not found,...
Definition: comparitor.cxx:179
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
MuonValidation_CreatePullProfiles.CreateProfile
def CreateProfile(infile, HistDir, HistName, Var, doAverage=False)
Definition: MuonValidation_CreatePullProfiles.py:13