ATLAS Offline Software
Classes | Functions | Variables
validator Namespace Reference

Classes

class  Validator
 

Functions

def GoToDirectory (directory)
 
def SameHist (refHist, testHist)
 
def SimilarHist (refHist, testHist)
 
def main (argv)
 

Variables

list LABELS = []
 

Function Documentation

◆ GoToDirectory()

def validator.GoToDirectory (   directory)

Definition at line 19 of file validator.py.

19 def GoToDirectory(directory):
20  cwd = os.getcwd()
21  print os.getcwd()
22  newdir = cwd + "/" + directory
23  if not os.path.isdir( newdir ):
24  print "Creating folder " + newdir
25  os.makedirs( newdir )
26  os.chdir(newdir)
27 
28 

◆ main()

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

Definition at line 276 of file validator.py.

276 def main( argv ):
277  """
278  Main function to be executed when starting the code.
279  """
280 
281  parser = argparse.ArgumentParser( description = 'Distribution Plotter' )
282  parser.add_argument( '-s', '--structDirs', default = True, action = "store_true", help = ' if true, it creates directories following the same structure as in the root file to store the pdf plots')
283  parser.add_argument( '-r', '--reference', help = 'The reference' )
284  parser.add_argument( '-t', '--test', help = 'The test' )
285  parser.add_argument( '-t2', '--test2', default ='', help = 'The additional test' )
286  parser.add_argument( '-d', '--directory', default = "/", help = 'Print cutflow fror systematic variations' )
287  parser.add_argument( '-e', '--exclude', default = "_bin_", help = 'histograms whose names contain the provided strings are not examined')
288  parser.add_argument( '-n', '--normalize', default = False, action = "store_true", help = 'normalize histograms with larger stats for better comparison')
289  parser.add_argument( '-l', '--labels', default ='', help = 'Add text to legend for ref/test/test2, split with commas' )
290 
291  args = parser.parse_args()
292 
293 
294  #ROOT.gROOT.Macro("rootlogon.C")
295  ROOT.gROOT.SetBatch()
296  #ROOT.gROOT.LoadMacro("./AtlasUtils.C")
297  ROOT.gROOT.LoadMacro("./AtlasStyle.C")
298  ROOT.TH1.SetDefaultSumw2(ROOT.kTRUE)
299 
300  SetAtlasStyle()
301 
302  LABELS = []
303  if args.labels is '':
304  LABELS = [ 'Ref','Test' ]
305  if args.test2 is not '':
306  LABELS.append( 'Test2' )
307  else:
308  LABELS = args.labels.split(",")
309  #print LABELS
310 
311  # if you want to pass labels to legend directly from the file name...:
312  #LABELS.append( args.test.split('.')[2]+' '+args.test.split('.')[3] )
313  #
314 
315  validator = Validator( args.structDirs, args.exclude, SameHist, args.normalize )
316  if args.test2 == '':
317  allFiles = [ os.path.abspath(args.reference), os.path.abspath(args.test) ]
318  else:
319  allFiles = [ os.path.abspath(args.reference), os.path.abspath(args.test), os.path.abspath(args.test2) ]
320  #======================================================================
321 

◆ SameHist()

def validator.SameHist (   refHist,
  testHist 
)

Definition at line 29 of file validator.py.

29 def SameHist(refHist, testHist):
30  chi2 = 0
31  for x in range(refHist.GetNbinsX()):
32  for y in range(refHist.GetNbinsY()):
33  for z in range(refHist.GetNbinsZ()):
34  if refHist.GetBinContent(x,y,z) != testHist.GetBinContent(x,y,z): return False
35  return True
36 

◆ SimilarHist()

def validator.SimilarHist (   refHist,
  testHist 
)

Definition at line 37 of file validator.py.

37 def SimilarHist(refHist, testHist):
38  for x in range(refHist.GetNbinsX()):
39  for y in range(refHist.GetNbinsY()):
40  for z in range(refHist.GetNbinsZ()):
41  if abs(refHist.GetBinContent(x,y,z) - testHist.GetBinContent(x,y,z)) > 0.01: return False
42  return True
43 
44 
45 
46 

Variable Documentation

◆ LABELS

list validator.LABELS = []

Definition at line 17 of file validator.py.

SetAtlasStyle
void SetAtlasStyle()
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/Macro/AtlasStyle.h:17
Validator
Definition: Validator.h:20
validator.GoToDirectory
def GoToDirectory(directory)
Definition: validator.py:19
validator.SameHist
def SameHist(refHist, testHist)
Definition: validator.py:29
validator.main
def main(argv)
Definition: validator.py:276
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
validator.SimilarHist
def SimilarHist(refHist, testHist)
Definition: validator.py:37