#!/usr/bin/env python2 # Execute RunOAAnalysis on the test samples that we have. # Make sure that RunOAAnalysis finishes without problems. import os, sys, os.path, commands runs = ["2011_comet_cosmics", "sideways-muon-2GeV-TPC1"] for name in runs: inname = name + "_reco.root" outname = name + "_anal.root" dumpFile = name + "_dumpFile.txt" if not os.path.exists(inname): print "MISSING INPUT" sys.exit(0) # remove the output if it exists. if os.path.exists(outname): os.remove(outname) status = os.system("RunOAAnalysis.exe -o %s %s >& %s" % (outname, inname,dumpFile)) if status != 0: os.system("cat " + dumpFile) sys.exit(status) eventDump = commands.getoutput('cat ' + dumpFile) # Look for strings that should or shouldn't be in the file. valid = True # check that we read and wrote all events. if eventDump.find('Total Events Read: 100') == -1: print "Didn't Read all the events" valid = False if eventDump.find('Total Events Written: 0') == -1: print "Didn't write all the events" valid = False # check that there were no exceptions. if eventDump.find('Uncaught exception') != -1: print "Found uncaught exception" valid = False if not valid: print eventDump print "Failed to finish RunReconGlobal.exe cleanly." print "" print "FAIL" sys.exit(0)