diff --git a/Tools/PyUtils/bin/checkPlugins.py b/Tools/PyUtils/bin/checkPlugins.py index 49ccfa1fd98666cf8eff39cb3c130f077610182c..a11c87d91d422cc36b555a444e71ac290459b19c 100755 --- a/Tools/PyUtils/bin/checkPlugins.py +++ b/Tools/PyUtils/bin/checkPlugins.py @@ -24,6 +24,10 @@ _suppression_dct = { 'libAtlasSTLAddReflexDict.so'), 'RooStats': ('libHistFactory.so', 'libRooStats.so'), + 'vector<unsigned int>': ('libSTLRflx.so', + 'libSTLAddRflx.so'), + 'vector<double>': ('libSTLRflx.so', + 'libSTLAddRflx.so'), } def _currentProject(): @@ -183,13 +187,13 @@ if __name__ == "__main__": print ":: checking dict. duplicates..." dups = dsoDb.dictDuplicates( pedantic = options.isPedantic ) # restrict to just this project - currProj = _currentProject() - restrictedDups = {} - for label, libPaths in dups.items(): - paths = [l for l in libPaths if ('/%s/' % currProj) in l] - if paths: - restrictedDups[label] = paths - dups = restrictedDups + #currProj = _currentProject() + #restrictedDups = {} + #for label, libPaths in dups.items(): + # paths = [l for l in libPaths if ('/%s/' % currProj) in l] + # if paths: + # restrictedDups[label] = paths + #dups = restrictedDups sc = 0 suppression_log = [] diff --git a/Tools/PyUtils/bin/checkxAOD.py b/Tools/PyUtils/bin/checkxAOD.py index cb61781b84d4a5920bce76769b20dc038715b2b7..744e70a21d5569b3a4046748926f7579eb619b9a 100755 --- a/Tools/PyUtils/bin/checkxAOD.py +++ b/Tools/PyUtils/bin/checkxAOD.py @@ -2,14 +2,14 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration # -# $Id: checkxAOD.py 648762 2015-02-22 09:27:18Z schaffer $ +# $Id: checkxAOD.py 648761 2015-02-22 09:26:47Z schaffer $ # # This is a modified version of PyUtils/bin/checkFile.py. It has been taught # how to sum up the sizes of all the branches belonging to a single xAOD # object/container. # -__version__ = "$Revision: 648762 $" +__version__ = "$Revision: 648761 $" __author__ = "Sebastien Binet <binet@cern.ch>, " \ "Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch>" diff --git a/Tools/PyUtils/bin/diffTAGTree.py b/Tools/PyUtils/bin/diffTAGTree.py index 6b9a3debd486661b95ea63f97cfa55681226ecf7..4418cd04c1eaca945a4f366428eb0de25146ddb3 100755 --- a/Tools/PyUtils/bin/diffTAGTree.py +++ b/Tools/PyUtils/bin/diffTAGTree.py @@ -18,25 +18,41 @@ __version__ = "$Revision: 1.3 $" __author__ = "Graeme Andrew Stewart" +import argparse import sys import os +import logging sys.argv += [ '-b' ] # tell ROOT to not use graphics from ROOT import TFile, TTree sys.argv.pop() -setIgnoreLeaves=("Token","StreamESD_ref","StreamRDO_ref","StreamAOD_ref","RecoTimeRAWtoESD","RecoTimeESDtoAOD") - -def diffTTree(tOld,tNew,details=None): - nOld = tOld.GetEntriesFast() - nNew = tNew.GetEntriesFast() - n=min(nOld,nNew) - - if nOld != nNew: - msg="Different number of entries: %i vs %i. Comparing first %i" % \ - (nOld,nNew,n) - print msg - if details is not None: details.write(msg+"\n") +global msg +msg = logging.getLogger('diffTAGTree') +hdlr = logging.StreamHandler(sys.stdout) +frmt = logging.Formatter("%(levelname)s %(message)s") +hdlr.setFormatter(frmt) +msg.addHandler(hdlr) +msg.setLevel(logging.INFO) + +setIgnoreLeaves=("Token","StreamESD_ref","StreamRDO_ref","StreamAOD_ref","RecoTimeRAWtoESD","RecoTimeESDtoAOD","RandomNumber") + +def getEventDict(tagHandle, name): + duplicates = False + indexDict = {} + n=tagHandle.GetEntriesFast() + for i in range(n): + tagHandle.GetEntry(i) + idx = "{0}-{1}".format(tagHandle.RunNumber, tagHandle.EventNumber) + msg.debug("New file entry in {0} file {1} is #{2}".format(name, idx, i)) + if idx in indexDict.keys(): + duplicates = True + msg.error("Error - found duplicated event in file {0}: {1} appears at evt no. {2} and {3}!".format(name, idx, indexDict[idx], i)) + else: + indexDict[idx] = i + return indexDict, duplicates + +def diffTTree(tOld,tNew): leavesOld=tOld.GetListOfLeaves() leavesNew=tNew.GetListOfLeaves() @@ -53,97 +69,64 @@ def diffTTree(tOld,tNew,details=None): if not name in setIgnoreLeaves: checkLeavesNew.add(name) - #print checkLeavesOld checkLeaves=checkLeavesOld & checkLeavesNew diffLeaves=checkLeavesOld ^ checkLeavesNew if len(diffLeaves): - msg="The following variables exist in only one tree, not compared:\n" - for d in diffLeaves: - msg+=d+"\n" - print msg - if details is not None: details.write(msg) + msg.warning("The following variables exist in only one tree, not compared: {0}".format(" ".join(diffLeaves))) nGood=0 nBad=0 diffSummary=dict() # To cope with events being out of order in the new TAG file - # (which can happen when running through prodsys) build up - # a cache for the new TAG file, mapping run/event numbers -> index - newRunEventDict=dict() # Hold information about the run/event numbers vs entry index here - cachedIndex=0 # How far we looked through the new file already - + # (which can happen when running through prodsys or using AthenaMP) build up + # a cache for each TAG file, mapping run/event numbers -> index + # Also do a sanity check for duplicated events + newRunEventDict, ndups=getEventDict(tNew, 'new') + oldRunEventDict, odups=getEventDict(tOld, 'old') + if ndups or odups: + msg.error("There are serious problems with these tag files, but script will compare content of events") + + # Some cross checks on the events we have + nk=set(newRunEventDict.keys()) + ok=set(oldRunEventDict.keys()) + mismatches = nk ^ ok + if len(mismatches) > 0: + msg.error("Inconsistent events in TAG files, these run-event pairs are only in one of the files: {0}".format(mismatches)) + # Loop over events in the old file - for iEntry in range(n): + for idx, iEntry in oldRunEventDict.iteritems(): tOld.GetEntry(iEntry) try: - evOld=tOld.EventNumber - runOld=tOld.RunNumber - # Simple index combining run and event - runEventIndex = "%d-%d" % (runOld, evOld) -# print "Trying to match %i-%i" % (runOld, evOld) - if runEventIndex in newRunEventDict: -# print "Cache hit!" - tNew.GetEntry(newRunEventDict[runEventIndex]) - evNew=tNew.EventNumber - runNew=tNew.RunNumber - else: - for sEntry in range(cachedIndex, n): - tNew.GetEntry(sEntry) - evNew=tNew.EventNumber - runNew=tNew.RunNumber - newRunEventDict["%d-%d" % (runNew, evNew)] = sEntry -# print "Cached %i-%i" % (runNew, evNew) - cachedIndex = sEntry + 1 - if evNew == evOld and runNew == runOld: - break - if evOld != evNew or runOld != runNew: - msg="Run/Event numbers don't match: found no partner for RunNbr: %i, EventNbr: %i\n" % (runOld, evOld) - msg+="\nStop comparison now." - print msg - if details is not None: - details.write(msg+"\n") - break - except AttributeError: - pass - + evt=tOld.EventNumber + run=tOld.RunNumber + tNew.GetEntry(newRunEventDict[idx]) + msg.debug("Found {0} at entry {1} in old file, {2} in new file".format(idx, iEntry, newRunEventDict[idx])) + except KeyError, e: + msg.error("Run-Event number {0} was not found in the new TAG file") + nBad+=1 + continue + foundDiff=False for name in checkLeaves: - #exec "vOld=tOld."+name vOld=getattr(tOld,name) vNew=getattr(tNew,name) if vOld != vNew: foundDiff=True - try: #Get Run/Event number - evt=tNew.EventNumber - rn=tNew.RunNumber - - evtO=tOld.EventNumber - rnO=tOld.RunNumber - - evId="(Run %i, Evt %i)" % (rn, evt) - evId+="(Run %i, Evt %i)" % (rnO, evtO) - except: - evId="" - - #print "Event #",iEntry,"Difference:",name, - diffmsg="Event #%i %s Difference: %s %s -> %s" %\ - (iEntry,evId,name,str(vOld),str(vNew)) - #print vOld,"vs",vNew, + diffmsg="Run {1}, Event {0} (old#{2}, new#{3}) Difference: {4} {5} -> {6}".format(evt, run, iEntry, newRunEventDict[idx], + name, str(vOld),str(vNew)) try: d=100.0*(vNew-vOld)/vOld diffmsg+=" (%.3f%%)" % d except: pass - if details is not None: - details.write(diffmsg+"\n") else: print diffmsg - if diffSummary.has_key(name): + if name in diffSummary: diffSummary[name]+=1 else: diffSummary[name]=1 @@ -152,31 +135,32 @@ def diffTTree(tOld,tNew,details=None): else: nGood+=1 - msg="Found %i identical events and %i different events" % (nGood,nBad) - print msg - if details is not None: - details.write(msg+"\n") + message = "Found %i identical events and %i different (or missing) events" % (nGood,nBad) + if nBad > 0: + msg.error(message) + else: + msg.info(message) for n,v in diffSummary.iteritems(): - msg="\tName: %s: %i Events differ" % (n,v) - print msg - if details is not None: - details.write(msg+"\n") + msg.warning("Name: %s: %i Events differ" % (n,v)) return (nGood,nBad) if __name__=='__main__': - if len(sys.argv)<3 or len(sys.argv)>4 or sys.argv[1]=="-help": - print "Usage:",sys.argv[0],"File1 File2 <treename>" - sys.exit(-1) + parser = argparse.ArgumentParser(description = "Examine a pair of tag files for any differences") + parser.add_argument('--debug', help='Set debugging output on', action='store_true') + parser.add_argument('--tree', help='Alternative tree to check (default is POOLCollectionTree)', + default='POOLCollectionTree') + parser.add_argument('tagFile', help='TAG files to check', nargs=2) - fnOld=sys.argv[1] - fnNew=sys.argv[2] - if len(sys.argv)>3: - treename=sys.argv[3] - else: - treename="POOLCollectionTree" + args = vars(parser.parse_args(sys.argv[1:])) + + fnOld=args['tagFile'][0] + fnNew=args['tagFile'][1] + treename=args['tree'] + if args['debug']: + msg.setLevel(logging.DEBUG) if not os.access(fnOld,os.R_OK): print "Can't access file",fnOld @@ -206,3 +190,7 @@ if __name__=='__main__': ndiff=diffTTree(tOld,tNew) + if ndiff[1] != 0: + sys.exit(1) + + sys.exit(0) diff --git a/Tools/PyUtils/bin/issues b/Tools/PyUtils/bin/issues new file mode 100755 index 0000000000000000000000000000000000000000..2e7c32b8f3ba66fd1cd1897362d1d8b2a79eec59 --- /dev/null +++ b/Tools/PyUtils/bin/issues @@ -0,0 +1,41 @@ +#!/usr/bin/python +import os, sys,urllib2, getopt +'''Package to query a web service which returns coverity defects as plain text. +It infers the package name from the working directory, or this may be specified on the command line''' + +def getPackage(): + directory=os.getcwd() + return directory.split("/")[-1] + +def getDefects(pkg): + format="plain" #return plain text + baseUrl="http://atlas-computing.web.cern.ch/atlas-computing/projects/qa/CoverityResult/cgi-bin/defects" + query="?package="+pkg+"&format="+format + url=baseUrl+query + textData=None + request=urllib2.Request(url,textData) + try: + u=urllib2.urlopen(request, timeout=2) + except urllib2.URLError, e: + return "I'm sorry, the server timed out" + textString = u.read() + return textString + +def main(argv): + package=getPackage() + try: + opts, args = getopt.getopt(argv,"hp:",["package="]) + except getopt.GetoptError: + print 'issues -p <package>' + sys.exit(2) + for opt, arg in opts: + if opt == '-h': + print '"issues" will determine the package from the working directory; otherwise you may use "issues -p package"' + sys.exit() + elif opt in ("-p", "--package"): + package = arg + print getDefects(package) + return 0 + +if __name__=="__main__": + sys.exit(main(sys.argv[1:])) diff --git a/Tools/PyUtils/cmt/requirements b/Tools/PyUtils/cmt/requirements index bc16bca082862d7d41ba4362274651016f302424..bf532683318014fc707c936b3e5ea8f8c023e300 100755 --- a/Tools/PyUtils/cmt/requirements +++ b/Tools/PyUtils/cmt/requirements @@ -75,6 +75,7 @@ apply_pattern declare_scripts files="\ getTagDiff.py \ gprof2dot \ icython.py \ + issues \ lstags \ magnifyPoolFile.py \ merge-poolfiles.py \ diff --git a/Tools/PyUtils/python/AthFile/impl.py b/Tools/PyUtils/python/AthFile/impl.py index 0f0b2abf3e482e039a74ec52c95a5d956b5233d0..da650f577c409428851ec184f3bb19572ea2ca6e 100644 --- a/Tools/PyUtils/python/AthFile/impl.py +++ b/Tools/PyUtils/python/AthFile/impl.py @@ -7,7 +7,7 @@ from __future__ import with_statement -__version__ = "$Revision: 635800 $" +__version__ = "$Revision: 662725 $" __author__ = "Sebastien Binet" __doc__ = "implementation of AthFile-server behind a set of proxies to isolate environments" @@ -1405,6 +1405,19 @@ class FilePeeker(object): bs_metadata[key_name] = v # for bwd/fwd compat... -- END + # fix for ATEAM-122 + if len(bs_metadata.get('evt_type','')) == 0 : # see: ATMETADATA-6 + evt_type = ['IS_DATA', 'IS_ATLAS'] + if bs_metadata.get('Stream', '').startswith('physics_'): + evt_type.append('IS_PHYSICS') + elif bs_metadata.get('Stream', '').startswith('calibration_'): + evt_type.append('IS_CALIBRATION') + elif bs_metadata.get('Project', '').endswith('_calib'): + evt_type.append('IS_CALIBRATION') + else: + evt_type.append('Unknown') + bs_metadata['evt_type'] = evt_type + file_infos['file_guid'] = bs_metadata.get('GUID', _uuid()) file_infos['evt_type'] = bs_metadata.get('evt_type', []) file_infos['geometry'] = bs_metadata.get('geometry', None) diff --git a/Tools/PyUtils/python/Helpers.py b/Tools/PyUtils/python/Helpers.py index a99ac1b618910ca69b6146627ddc421de0d6a42f..af5fa6d716f6a7630d1c21a28dba6ef1874d8170 100755 --- a/Tools/PyUtils/python/Helpers.py +++ b/Tools/PyUtils/python/Helpers.py @@ -21,25 +21,26 @@ def ROOT6Setup(): """ Fill ROOT include path list for entries for all packages found in CMTPATH """ - log.debug( "\n --------- addROOTIncludePaths!" ) - log.debug( "Expanding CMTPATH:\n" + str( os.environ['CMTPATH'] ) + '\n' ) - import glob - import PyUtils.RootUtils as ru - interp = ru.import_root().gInterpreter - plist = os.environ['CMTPATH'].split(':') - for p in plist: - if p.find('AtlasCore')>0: - path_for_eigen = os.path.join (p, 'InstallArea', os.environ['CMTCONFIG'],'include') - interp.AddIncludePath( path_for_eigen ) - # MN disabling to use the patchs from release setup now - # if p.find('GAUDI')<0: - # idir = os.path.join (p, 'InstallArea', 'include') - # for ii in glob.glob (os.path.join (idir, '*')): - # interp.AddIncludePath (ii) - try: - interp.AddIncludePath( os.environ['G4INCLUDE'] ) - except KeyError: - pass + + # Most projects make their headers available to root under + # root-include-path. But DetCommon does not. + if 'CMTPATH' in os.environ: + import glob + import PyUtils.RootUtils as ru + interp = ru.import_root().gInterpreter + for p in os.environ['CMTPATH'].split(':'): + if p.find('DetCommon')>=0: + idir = os.path.join (p, 'InstallArea', 'include') + for ii in glob.glob (os.path.join (idir, '*')): + interp.AddIncludePath (ii) + + + # Also need to make Geant headers available. + if 'G4INCLUDE' in os.environ: + import PyUtils.RootUtils as ru + interp = ru.import_root().gInterpreter + interp.AddIncludePath( os.environ['G4INCLUDE'] ) + def cppyyFakeCintex(): diff --git a/Tools/PyUtils/python/RootUtils.py b/Tools/PyUtils/python/RootUtils.py index b6092915332562db176ca7551350208456a03c0f..271649f6eab4692c2c7f7ca08f0a1597c1006d11 100644 --- a/Tools/PyUtils/python/RootUtils.py +++ b/Tools/PyUtils/python/RootUtils.py @@ -8,7 +8,7 @@ from __future__ import with_statement __doc__ = "a few utils to ease the day-to-day work with ROOT" -__version__ = "$Revision: 644959 $" +__version__ = "$Revision: 664272 $" __author__ = "Sebastien Binet" __all__ = [ @@ -162,6 +162,17 @@ def _pythonize_tfile(): return +def _getLeaf (l): + tname = l.GetTypeName() + ndat = l.GetNdata() + if tname in ['UInt_t', 'Int_t', 'ULong64_t', 'Long64_t']: + return [l.GetValueLong64(i) for i in range(ndat)] + if tname in ['Float_t', 'Double_t']: + return [l.GetValue(i) for i in range(ndat)] + if tname in ['Char_t']: + return l.GetValueString() + return None + class RootFileDumper(object): """ A helper class to dump in more or less human readable form the content of @@ -262,12 +273,22 @@ class RootFileDumper(object): #print hdr #tree.GetBranch(br_name).GetEntry(ientry) py_name = [br_name] - - val = getattr(tree, br_name) + + br = tree.GetBranch (br_name) + if br.GetClassName() != '': + val = getattr(tree, br_name) + else: + vals = [_getLeaf (l) for l in br.GetListOfLeaves()] + if len(vals) == 0: + val = None + elif len(vals) == 1: + val = vals + else: + val = tuple(vals) if not (val is None): #print "-->",val,br_name try: - vals = _pythonize(val, py_name) + vals = _pythonize(val, py_name, True) except Exception, err: print "**err** for branch [%s] val=%s (type=%s)" % ( br_name, val, type(val), diff --git a/Tools/PyUtils/python/scripts/__init__.py b/Tools/PyUtils/python/scripts/__init__.py index 5d846ba39015a3eb7d25d29fc9b6c7cdb643ed34..d1729d5cf2aa90c9cecdfe6d0ee2105f958c3582 100644 --- a/Tools/PyUtils/python/scripts/__init__.py +++ b/Tools/PyUtils/python/scripts/__init__.py @@ -24,7 +24,8 @@ acmdlib.register('filter-files', 'PyUtils.scripts.filter_files:main') acmdlib.register('cmt.new-pkg', 'PyUtils.scripts.cmt_newpkg:main') acmdlib.register('cmt.new-alg', 'PyUtils.scripts.cmt_newalg:main') -acmdlib.register('cmt.new-metadataalg', 'PyUtils.scripts.cmt_newmetadataalg:main') +acmdlib.register('cmt.new-analysisalg', 'PyUtils.scripts.cmt_newanalysisalg:main') acmdlib.register('cmt.new-pyalg', 'PyUtils.scripts.cmt_newpyalg:main') +acmdlib.register('cmt.new-jobo', 'PyUtils.scripts.cmt_newjobo:main') ## diff --git a/Tools/PyUtils/python/scripts/cmt_newalg.py b/Tools/PyUtils/python/scripts/cmt_newalg.py index 81f528e5955711c1d113dcec4a712856986b786d..32d682f7883525933d54ce8c406f41c20fbdd44a 100644 --- a/Tools/PyUtils/python/scripts/cmt_newalg.py +++ b/Tools/PyUtils/python/scripts/cmt_newalg.py @@ -26,6 +26,7 @@ class Templates: #define %(guard)s 1 #include "AthenaBaseComps/AthAlgorithm.h" +#include "GaudiKernel/ToolHandle.h" //included under assumption you'll want to use some tools! Remove if you don't! %(namespace_begin)s diff --git a/Tools/PyUtils/python/scripts/cmt_newmetadataalg.py b/Tools/PyUtils/python/scripts/cmt_newanalysisalg.py similarity index 90% rename from Tools/PyUtils/python/scripts/cmt_newmetadataalg.py rename to Tools/PyUtils/python/scripts/cmt_newanalysisalg.py index 18b313d6035a1449f5f6c7716163cd53b24f0556..753ed716ca129e3b2fd0475cdae1a7c809f56657 100644 --- a/Tools/PyUtils/python/scripts/cmt_newmetadataalg.py +++ b/Tools/PyUtils/python/scripts/cmt_newanalysisalg.py @@ -1,6 +1,6 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -# @file PyUtils.scripts.cmt_newmetadataalg +# @file PyUtils.scripts.cmt_newanalysisalg # @purpose streamline and ease the creation of new athena algs # @author Will Buttinger # @date September 2014 @@ -9,9 +9,9 @@ from __future__ import with_statement -__version__ = "$Revision: 621307 $" +__version__ = "$Revision: 655341 $" __author__ = "Will Buttinger" -__doc__ = "streamline and ease the creation of new metadata algorithms" +__doc__ = "streamline and ease the creation of new AthAnalysisAlgorithm" ### imports ------------------------------------------------------------------- import os @@ -25,11 +25,11 @@ class Templates: #ifndef %(guard)s #define %(guard)s 1 -#include "AthenaBaseComps/AthMetadataAlgorithm.h" +#include "AthAnalysisBaseComps/AthAnalysisAlgorithm.h" %(namespace_begin)s -class %(klass)s: public ::AthMetadataAlgorithm { +class %(klass)s: public ::AthAnalysisAlgorithm { public: %(klass)s( const std::string& name, ISvcLocator* pSvcLocator ); virtual ~%(klass)s(); @@ -53,7 +53,7 @@ class %(klass)s: public ::AthMetadataAlgorithm { %(namespace_begin)s -%(klass)s::%(klass)s( const std::string& name, ISvcLocator* pSvcLocator ) : AthMetadataAlgorithm( name, pSvcLocator ){ +%(klass)s::%(klass)s( const std::string& name, ISvcLocator* pSvcLocator ) : AthAnalysisAlgorithm( name, pSvcLocator ){ //declareProperty( "Property", m_nProperty ); //example property declaration @@ -95,17 +95,17 @@ StatusCode %(klass)s::beginInputFile() { ### functions ----------------------------------------------------------------- @acmdlib.command( - name='cmt.new-metadataalg' + name='cmt.new-analysisalg' ) @acmdlib.argument( 'algname', help="name of the new alg" ) def main(args): - """create a new metadataalgorithm inside the current package. Call from within the package directory + """create a new AthAnalysisAlgorithm inside the current package. Call from within the package directory ex: - $ acmd cmt new-metadataalg MyAlg + $ acmd cmt new-analysisalg MyAlg """ sc = 0 @@ -115,7 +115,7 @@ def main(args): cwd = os.getcwd() #check that cmt dir exists (i.e. this is a package) if not os.path.isdir(cwd+"/cmt"): - print "ERROR you must call new-metadataalg from within the package you want to add the algorithm to" + print "ERROR you must call new-analysisalg from within the package you want to add the algorithm to" return -1 full_pkg_name = os.path.basename(cwd) print textwrap.dedent("""\ @@ -131,10 +131,10 @@ def main(args): if not line.startswith("use "): continue lastUse=lineCount uu = line.split(" ") - if uu[1].startswith("AthenaBaseComps"): foundBaseComps=True + if uu[1].startswith("AthAnalysisBaseComps"): foundBaseComps=True if not foundBaseComps: - print "::: INFO Adding AthenaBaseComps to requirements file" + print "::: INFO Adding AthAnalysisBaseComps to requirements file" #must add a use statement to the requirements file #put inside private blocks lineCount=0 @@ -143,7 +143,7 @@ def main(args): lineCount+=1 if lineCount==lastUse+1: if not inPrivate: print "private" - print "use AthenaBaseComps AthenaBaseComps-* Control" + print "use AthAnalysisBaseComps AthAnalysisBaseComps-* Control" if not inPrivate: print "end_private" if line.startswith("private"): inPrivate=True elif line.startswith("end_private"): inPrivate=False diff --git a/Tools/PyUtils/python/scripts/cmt_newjobo.py b/Tools/PyUtils/python/scripts/cmt_newjobo.py new file mode 100644 index 0000000000000000000000000000000000000000..b09e3ac2fd68880746a50099490d3b5a4ca688bd --- /dev/null +++ b/Tools/PyUtils/python/scripts/cmt_newjobo.py @@ -0,0 +1,89 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# @file PyUtils.scripts.cmt_newalg +# @purpose streamline and ease the creation of a skeleton joboption +# @author Will Buttinger +# @date March 2015 + +#Note - this code could use a serious rewrite, I just hacked it together to get something working + +from __future__ import with_statement + +__version__ = "$Revision: 655341 $" +__author__ = "Will Buttinger" +__doc__ = "streamline and ease the creation of new skeleton joboption for analysis" + +### imports ------------------------------------------------------------------- +import os +import textwrap +import commands +import PyUtils.acmdlib as acmdlib +import fileinput + +class Templates: + jobo_template = """\ +#Skeleton joboption for a simple analysis job + +theApp.EvtMax=10 #says how many events to run over. Set to -1 for all events + +import AthenaPoolCnvSvc.ReadAthenaPool #sets up reading of POOL files (e.g. xAODs) +svcMgr.EventSelector.InputCollections=["%(inFile)s"] #insert your list of input files here + +algseq = CfgMgr.AthSequencer("AthAlgSeq") #gets the main AthSequencer +algseq += CfgMgr.%(klass)s() #adds an instance of your alg to it + + + + +include("AthAnalysisBaseComps/SuppressLogging.py") #Optional include to suppress as much athena output as possible +""" + + + +### functions ----------------------------------------------------------------- +@acmdlib.command( + name='cmt.new-jobo' + ) +@acmdlib.argument( + 'joboName', + help="name of the joboption" + ) +@acmdlib.argument( + 'alg', + default='MyAlg', + help='name of the algorithm to add to sequence' + ) +@acmdlib.argument( + '--inFile', + default='my.pool.root', + help='name of an input file to add to EventSelector' + ) +def main(args): + """create a new algorithm inside the current package. Call from within the package directory + + ex: + $ acmd cmt new-jobo myJobo MyAlg + """ + + full_jobo_name = args.joboName + full_alg_name = args.alg + + print textwrap.dedent("""\ + ::: create jobo [%(full_jobo_name)s] for alg [%(full_alg_name)s]""" %locals()) + + #following code borrowed from gen_klass + jobo = getattr(Templates, 'jobo_template') + + d = dict( klass=args.alg, + inFile=args.inFile, + ) + fname = args.joboName+'.py' + #first check doesn't exist + if os.path.isfile(fname): + print "::: ERROR %s already exists" % fname + return -1 + o_hdr = open(fname, 'w') + o_hdr.writelines(jobo%d) + o_hdr.flush() + o_hdr.close() + diff --git a/Tools/PyUtils/python/scripts/cmt_newpkg.py b/Tools/PyUtils/python/scripts/cmt_newpkg.py index 9711a9060cc51646364cf233bb50b996d355ddc6..a525797c84cc6fb82142abec1982f97ea2b967bc 100644 --- a/Tools/PyUtils/python/scripts/cmt_newpkg.py +++ b/Tools/PyUtils/python/scripts/cmt_newpkg.py @@ -7,7 +7,7 @@ from __future__ import with_statement -__version__ = "$Revision: 279982 $" +__version__ = "$Revision: 655341 $" __author__ = "Sebastien Binet" __doc__ = "streamline and ease the creation of new cmt packages" @@ -89,15 +89,13 @@ def main(args): branches src src/components doc python share - private - ## default is to make component library + ## default is to make component library. See: https://twiki.cern.ch/twiki/bin/view/Main/LearningAthena#Libraries_in_CMT for alternatives library %(pkg_name)s *.cxx components/*.cxx - apply_pattern component_library + apply_pattern declare_joboptions files="*.py" apply_pattern declare_python_modules files="*.py" - end_private """%locals()) print "::: creating package [%(full_pkg_name)s]... [done]" % locals()