def __init__(self, StreamName, FileName, tupleName=None, asAlg=False): # Initialize the base class: AugmentedStreamBase.__init__(self, StreamName) # Check if the user specified a tree name or not: if tupleName == None: tupleName = StreamName # event-by-event stream import AthenaCommon.CfgMgr as CfgMgr from AthenaRootComps.WriteAthenaRoot import createNtupleOutputStream from AthenaRootComps.AthenaRootCompsConf import Athena__RootOutputStreamTool as AthenaRootOutputStreamTool from AthenaRootComps.AthenaRootCompsConf import Athena__RootNtupleOutputMetadataTool as RootNtupleOutputMetadataTool self.Stream = createNtupleOutputStream(StreamName, FileName, tupleName, asAlg) metadataTool = RootNtupleOutputMetadataTool(StreamName + "Meta") metadataTool.OutputFile = FileName metadataTool.StreamName = StreamName metadataTool.TupleName = tupleName theApp.serviceMgr().ToolSvc += metadataTool self.Stream.HelperTools = [metadataTool] return
def NewPoolRootStream(self, StreamName, FileName="default", asAlg=False): theStream = self.NewStream(StreamName, FileName, type='pool', asAlg=asAlg) from AthenaCommon.AppMgr import theApp svcMgr = theApp.serviceMgr() theApp.CreateSvc += ["xAODMaker::EventFormatSvc"] theStream.AddMetaDataItem("xAOD::EventFormat#EventFormat") from AthenaCommon import CfgMgr streamMarkUpTool = CfgMgr.xAODMaker__FileMetaDataMarkUpTool( StreamName + "_FileMetaDataMarkUpTool") streamMarkUpTool.Key = StreamName theStream.Stream.HelperTools += [streamMarkUpTool] theStream.Stream.WritingTool.SubLevelBranchName = "<key>" svcMgr.AthenaPoolCnvSvc.PoolAttributes += [ "DatabaseName = '" + FileName + "'; COMPRESSION_LEVEL = '5'" ] svcMgr.AthenaPoolCnvSvc.PoolAttributes += [ "DatabaseName = '" + FileName + "'; ContainerName = 'TTree=CollectionTree'; TREE_AUTO_FLUSH = '-10000000'" ] svcMgr.AthenaPoolCnvSvc.PoolAttributes += [ "DatabaseName = '" + FileName + "'; ContainerName = 'TTree=CollectionTree'; CONTAINER_SPLITLEVEL = '1'" ] svcMgr.AthenaPoolCnvSvc.PoolAttributes += [ "DatabaseName = '" + FileName + "'; ContainerName = 'TTree=Aux.'; CONTAINER_SPLITLEVEL = '1'" ] return theStream
def dump(outputFilename): log.info( "Start dumping configuration for further use in the trigger configuration database" ) dumper = Dumper.getDumperInstance(outputFilename) from AthenaCommon.AppMgr import ToolSvc, ServiceMgr, theApp svcMgr = theApp.serviceMgr() toolSvc = svcMgr.ToolSvc topAlgs = theApp.TopAlg auditorSvc = svcMgr.AuditorSvc # Dump the ApplicationMgr dumper.append(theApp, algtype='Algorithm', dumpChildren=False) # Dump the Tools dumper.append(toolSvc, algtype='Service', dumpChildren=False) for alg in toolSvc.getAllChildren(): dumper.append(alg, algtype='PublicTool', dumpChildren=True) # Dump the Auditors dumper.append(auditorSvc, algtype='Service', dumpChildren=False) for alg in auditorSvc.getAllChildren(): dumper.append(alg, algtype='Auditor', dumpChildren=True) # Dump the Services dumper.append(svcMgr, algtype='Service', dumpChildren=False) for alg in svcMgr.getAllChildren(): if alg.getName() in ('AuditorSvc', 'ToolSvc'): continue dumper.append(alg, algtype='Service', dumpChildren=True) # Dump the top Algorithms from AthenaCommon.ConfigurableDb import getConfigurable from AthenaCommon.Configurable import Configurable for algNameClass in topAlgs: algClass, algName = algNameClass.split('/')[0:2] alg = None if algName in Configurable.allConfigurables: alg = Configurable.allConfigurables[algName] if alg.getFullName() != algNameClass: alg = None if alg == None: from AthenaCommon import CfgMgr cfg_class = getConfigurable(algClass, assumeCxxClass=True) stmt = 'alg = CfgMgr.%s("%s")' % (cfg_class.__name__, algName) try: exec stmt except Exception, exc: print "ERROR:\t\tTop algorithm: %s/%s was not assigned: %s" % ( algClass, algName) print exc if alg: dumper.append(alg, algtype='TopAlg', dumpChildren=True) else: print "Top algorithm: %s/%s was not assigned" % (algClass, algName)
def __init__(self, StreamName, FileName): AugmentedStreamBase.__init__(self, StreamName) #General setup from AthenaCommon.AppMgr import theApp svcMgr = theApp.serviceMgr() from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() # BS OutputStream Tool from ByteStreamCnvSvc.ByteStreamCnvSvcConf import ByteStreamEventStorageOutputSvc, ByteStreamOutputStreamCopyTool self.bsCopyTool = ByteStreamOutputStreamCopyTool( "OutputStreamBSCopyTool") svcMgr.ToolSvc += self.bsCopyTool #default output directory import commands cmd = 'pwd' (statusCode, outDir) = commands.getstatusoutput(cmd) outDir += "/" # BS output Svc from ByteStreamCnvSvc.ByteStreamCnvSvcConf import ByteStreamEventStorageOutputSvc self.bsOutputSvc = ByteStreamEventStorageOutputSvc( "BSESOutputSvc" + StreamName, OutputDirectory=outDir, SimpleFileName=FileName) svcMgr += self.bsOutputSvc # Set BS OutputSvc/InputSvc to BS OutputStream Tool self.bsCopyTool.ByteStreamOutputSvc = self.bsOutputSvc self.bsCopyTool.ByteStreamInputSvc = svcMgr.ByteStreamInputSvc # create AthenaOutputStream for BS Copy and add it to topSequence from AthenaServices.AthenaServicesConf import AthenaOutputStream self.Stream = AthenaOutputStream(StreamName, WritingTool=self.bsCopyTool) #topSequence += self.Stream #<-- coherent with asAlg=False in OutputStreamAthenaPool.py theApp.addOutputStream(self.Stream) return
#************************************************************** # # jopOptions file for reading ByteStream # #============================================================== from os import system,popen from subprocess import check_output from subprocess import CalledProcessError import six from AthenaCommon.AppMgr import theApp svcMgr = theApp.serviceMgr() from AthenaCommon.Logging import logging tbstat_log = logging.getLogger( 'jobOptions_TileTBStat.py' ) #--- Output printout level ----------------------------------- #output threshold (1=VERBOSE, 2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL) if not 'OutputLevel' in dir(): OutputLevel = 4 svcMgr.MessageSvc.OutputLevel = OutputLevel svcMgr.MessageSvc.defaultLimit = 1000000 svcMgr.MessageSvc.Format = "% F%60W%S%7W%R%T %0W%M" svcMgr.MessageSvc.useColors = False if not 'RunNumber' in dir(): RunNumber = 0
#topSequence += PassNoneFilter import AthenaCommon.CfgMgr as CfgMgr from AthenaRootComps.WriteAthenaRoot import createNtupleOutputStream from AthenaRootComps.AthenaRootCompsConf import Athena__RootOutputStreamTool as AthenaRootOutputStreamTool from AthenaRootComps.AthenaRootCompsConf import Athena__RootNtupleOutputMetadataTool as RootNtupleOutputMetadataTool StreamName = "StreamNTUP" FileName = "testNTUP.root" tupleName = "test" Eventless = createNtupleOutputStream(StreamName, FileName, tupleName, False) metadataTool = RootNtupleOutputMetadataTool(StreamName + "Meta") metadataTool.OutputFile = FileName metadataTool.StreamName = StreamName metadataTool.TupleName = tupleName theApp.serviceMgr().ToolSvc += metadataTool Eventless.HelperTools = [metadataTool] Eventless.ForceRead = True Eventless.RequireAlgs += ["PassNoneFilter"] #Eventless.RequireAlgs += ["PassAllFilter"] #from NTUPtoNTUPCore import NTUPUtils #MNSMgr = NTUPUtils.MNSMgr() #Eventless = MNSMgr.NewNTUPStream("StreamNTUP","testNTUP.root","test") #Eventless.GetStream().ForceRead = True #Eventless.AddRequireAlgs("PassNoneFilter") #athOutSeq += Eventless #-------------------------------------------------------------- # Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL) #--------------------------------------------------------------
def dump(self) : # Set the output file document = None file = None if self.__dict__.has_key('OutputFile') and self.OutputFile != '' : # Dump the algorithms to the file file = open(self.OutputFile, 'w') # Test the xml type of the output if self.OutputFile[-4:] == '.xml' : import xml.dom.minidom impl = xml.dom.minidom.getDOMImplementation() document = impl.createDocument(None, "setup", None) else: import sys file = sys.stdout # Get the algorithms from AthenaCommon.AppMgr import ToolSvc,ServiceMgr,theApp from AthenaCommon.AlgSequence import AlgSequence #toolSvc = CfgMgr.ToolSvc() svcMgr = theApp.serviceMgr() toolSvc = svcMgr.ToolSvc topAlgs = theApp.TopAlg auditors = svcMgr.AuditorSvc # Dump the ApplicationMgr if document : topElement = document.documentElement topElement.appendChild(self.algtoXML(theApp, document, dumpChildren=False)) else : file.write(self.algtoStr(theApp, ntabs=1, dumpChildren=False)) # Dump the Tools if document : topElement = document.documentElement topElement.appendChild(self.algtoXML(toolSvc, document,'Service',dumpChildren=False)) else : file.write(self.algtoStr(toolSvc, ntabs=1, dumpChildren=False)) for alg in toolSvc.getAllChildren(): if document: topElement = document.documentElement topElement.appendChild(self.algtoXML(alg, document, 'PublicTool')) else : file.write(self.algtoStr(alg)) # Dump the Auditors if document : topElement = document.documentElement topElement.appendChild(self.algtoXML(auditors, document,'Service',dumpChildren=False)) else : file.write(self.algtoStr(auditors, ntabs=1, dumpChildren=False)) for alg in auditors.getAllChildren(): if document: topElement = document.documentElement topElement.appendChild(self.algtoXML(alg, document, 'Auditor')) else : file.write(self.algtoStr(alg)) # Dump the Services if document : topElement = document.documentElement topElement.appendChild(self.algtoXML(svcMgr, document,'Service',dumpChildren=False)) else : file.write(self.algtoStr(svcMgr, ntabs=1, dumpChildren=False)) for alg in svcMgr.getAllChildren(): if alg.getName() not in ('AuditorSvc','ToolSvc') : if document: topElement = document.documentElement topElement.appendChild(self.algtoXML(alg, document, 'Service')) else : file.write(self.algtoStr(alg)) # Dump the top Algorithms from AthenaCommon.ConfigurableDb import getConfigurable, cfgDb from AthenaCommon import CfgMgr from AthenaCommon.Configurable import Configurable for algNameClass in topAlgs: alg = None algName = algNameClass.split('/')[1] algClass = algNameClass.split('/')[0] if Configurable.allConfigurables.has_key(algName) : alg = Configurable.allConfigurables[algName] if alg.getFullName() != algNameClass: alg = None if not alg : cfg_class = getConfigurable(algClass, assumeCxxClass=True) Configurable.allConfigurables.has_key('TrigSteer_L2') stmt = 'alg = CfgMgr.%s("%s")' % (cfg_class.__name__,algName) try : exec stmt except Exception, exc: print "ERROR:\t\tTop algorithm: %s/%s was not assigned: %s" % (algClass,algName) print exc if alg : if document: topElement = document.documentElement topElement.appendChild(self.algtoXML(alg, document, 'TopAlg')) else : file.write(self.algtoStr(alg)) else : print "Top algorithm: %s/%s was not assigned" % (algClass,algName)
#--------------------------------------------------------------- # Write RDO to BS # -------------------------------------------------------------- from AthenaCommon.AppMgr import theApp from AthenaCommon.AppMgr import ServiceMgr from AthenaCommon.AppMgr import ToolSvc svcMgr = theApp.serviceMgr() # Conversion Service instance from ByteStreamCnvSvc.ByteStreamCnvSvcConf import ByteStreamCnvSvc svcMgr += ByteStreamCnvSvc() # OutputSvc from ByteStreamCnvSvc.ByteStreamCnvSvcConf import ByteStreamEventStorageOutputSvc svcMgr += ByteStreamEventStorageOutputSvc() # Properties ByteStreamCnvSvc = svcMgr.ByteStreamCnvSvc ByteStreamCnvSvc.IsSimulation = True ByteStreamCnvSvc.ByteStreamOutputSvc ="ByteStreamEventStorageOutputSvc" # SCT cabling from SCT_Cabling.SCT_CablingConf import SCT_CablingSvc ServiceMgr+=SCT_CablingSvc() IOVDbSvc = Service("IOVDbSvc") from IOVDbSvc.CondDB import conddb conddb.addFolderSplitMC("SCT","/SCT/DAQ/Configuration/ROD","/SCT/DAQ/Configuration/ROD") conddb.addFolderSplitMC("SCT","/SCT/DAQ/Configuration/MUR","/SCT/DAQ/Configuration/MUR")