def AssembleIO(): #-------------------------------------------------------------- # Reduce the event loop spam a bit #-------------------------------------------------------------- if os.path.exists("%s/athfile-cache.ascii.gz" % (os.getcwd())): print "Old athfile-cache found. Will delete it otherwise athena just freaks out. This little boy" os.system("rm %s/athfile-cache.ascii.gz" % (os.getcwd())) from GaudiSvc.GaudiSvcConf import THistSvc from AthenaCommon.JobProperties import jobproperties import AthenaPoolCnvSvc.ReadAthenaPool from AthenaCommon.AthenaCommonFlags import athenaCommonFlags as acf from AthenaServices.AthenaServicesConf import AthenaEventLoopMgr from AthenaCommon.AppMgr import ServiceMgr from RecExConfig import AutoConfiguration from PathResolver import PathResolver from XAMPPbase.Utils import ReadListFromFile ServiceMgr += AthenaEventLoopMgr(EventPrintoutInterval=5000) ServiceMgr += THistSvc() OutFileName = "AnalysisOutput.root" if not "outFile" in globals( ) else outFile ServiceMgr.THistSvc.Output += [ "XAMPP DATAFILE='{}' OPT='RECREATE'".format(OutFileName) ] ROOTFiles = [] if "inputFile" in globals(): print "Use the following %s as input" % (inputFile) ROOTFiles = [] ResolvedInFile = PathResolver.FindCalibFile(inputFile) ReolvedInDir = PathResolver.FindCalibDirectory(inputFile) if os.path.isfile(ResolvedInFile): if IsTextFile(ResolvedInFile): ROOTFiles = ReadListFromFile(ResolvedInFile) else: ROOTFiles.append(ResolvedInFile) elif os.path.isdir(ReolvedInDir): for DirEnt in os.listdir(ReolvedInDir): if DirEnt.endswith(".root"): ROOTFiles.append(DirEnt) else: raise RuntimeError("Invalid input " + inputFile) if len(ROOTFiles) == 0: raise RuntimeError("No ROOT files could be loaded as input") ServiceMgr.EventSelector.InputCollections = ROOTFiles acf.FilesInput = ROOTFiles if len(ROOTFiles) > 0: AutoConfiguration.ConfigureSimulationOrRealData() if "nevents" in globals(): print "Only run on %i events" % (int(nevents)) theApp.EvtMax = int(nevents) if "nskip" in globals(): print "Skip the first %i events" % (int(nskip)) ServiceMgr.EventSelector.SkipEvents = int(nksip) if isData(): print "INFO: We're running over data today" elif isAF2(): print "INFO: Please fasten your seatbelt the journey will be on Atlas fast "
def AssembleIO(stream="TRIGGERSFTESTER"): #-------------------------------------------------------------- # Reduce the event loop spam a bit #-------------------------------------------------------------- if os.path.exists("%s/athfile-cache.ascii.gz" % (os.getcwd())): print( "INFO: Old athfile-cache found. Will delete it otherwise athena just freaks out. This little boy" ) os.system("rm %s/athfile-cache.ascii.gz" % (os.getcwd())) from GaudiSvc.GaudiSvcConf import THistSvc from AthenaCommon.JobProperties import jobproperties import AthenaPoolCnvSvc.ReadAthenaPool from AthenaCommon.AthenaCommonFlags import athenaCommonFlags as acf from AthenaServices.AthenaServicesConf import AthenaEventLoopMgr from AthenaCommon.AppMgr import ServiceMgr from PathResolver import PathResolver ServiceMgr += AthenaEventLoopMgr(EventPrintoutInterval=5000) ServiceMgr += THistSvc() OutFileName = "SFTest.root" if not "outFile" in globals() else outFile ServiceMgr.THistSvc.Output += [ "%s DATAFILE='%s' OPT='RECREATE'" % (stream, OutFileName) ] ROOTFiles = [] if "inputFile" in globals(): print("Use the following %s as input" % (inputFile)) ROOTFiles = [] ResolvedInFile = PathResolver.FindCalibFile(inputFile) ReolvedInDir = PathResolver.FindCalibDirectory(inputFile) if os.path.isfile(ResolvedInFile): print("INFO: Found file %s" % (inputFile)) ROOTFiles.append(ResolvedInFile) elif os.path.isdir(ReolvedInDir): for DirEnt in os.listdir(ReolvedInDir): if DirEnt.rfind(".root") != -1: if DirEnt.find(ReolvedInDir) != -1: ROOTFiles.append(DirEnt) else: ROOTFiles.append("%s/%s" % (ReolvedInDir, DirEnt)) else: raise RuntimeError("Invalid input " + inputFile) if len(ROOTFiles) == 0: raise RuntimeError("No ROOT files could be loaded as input") ServiceMgr.EventSelector.InputCollections = ROOTFiles acf.FilesInput = ROOTFiles if "nevents" in globals(): print("Only run on %i events" % (int(nevents))) theApp.EvtMax = int(nevents) if "nskip" in globals(): print("Skip the first %i events" % (int(nskip))) ServiceMgr.EventSelector.SkipEvents = int(nksip)
def AssembleIO(access_mode=0): athArgs = getAthenaArgs() #-------------------------------------------------------------- # Reduce the event loop spam a bit #-------------------------------------------------------------- from AthenaCommon.Logging import logging recoLog = logging.getLogger('XAMPP I/O') recoLog.info('****************** STARTING the job *****************') if os.path.exists("%s/athfile-cache.ascii.gz" % (os.getcwd())): recoLog.info("Old athfile-cache found. Will delete it otherwise athena just freaks out. This little boy.") os.system("rm %s/athfile-cache.ascii.gz" % (os.getcwd())) from GaudiSvc.GaudiSvcConf import THistSvc from AthenaCommon.JobProperties import jobproperties import AthenaRootComps.ReadAthenaxAODHybrid svcMgr.EventSelector.AccessMode = access_mode ### https://gitlab.cern.ch/atlas/athena/blob/21.2/PhysicsAnalysis/POOLRootAccess/POOLRootAccess/TEvent.h ### Infromation taken from here... recoLog.info("Set the access mode to %d. The access mode determines how athena reads out the xAOD." % (access_mode)) recoLog.info("Thereby the numbering scheme is as follows") recoLog.info( " -2 = kTreeAccess (direct access), -1 = kPoolAccess (horrible slow), 0 = kBranchAccess, 1 = kClassAccess(please try in case of problems)." ) from AthenaCommon.AthenaCommonFlags import athenaCommonFlags as acf from AthenaServices.AthenaServicesConf import AthenaEventLoopMgr from AthenaCommon.AppMgr import ServiceMgr from ClusterSubmission.Utils import ReadListFromFile, ResolvePath, IsROOTFile from XAMPPbase.Utils import IsTextFile ServiceMgr += AthenaEventLoopMgr(EventPrintoutInterval=1000000) ServiceMgr += THistSvc() ServiceMgr.THistSvc.Output += ["XAMPP DATAFILE='{}' OPT='RECREATE'".format(athArgs.outFile)] recoLog.info("Will save the job's output to " + athArgs.outFile) if isData(): recoLog.info("We're running over data today") elif isAF2(): recoLog.info("Please fasten your seatbelt the journey will be on Atlas fast ") else: recoLog.info("Fullsimulation. Make sure that you wear your augmented reality glasses")
def setupCostExtras(config=''): log = logging.getLogger('setupCostExtras') from AthenaCommon.AppMgr import theApp from AthenaCommon.AppMgr import ServiceMgr as svcMgr if not hasattr(svcMgr, "AthenaEventLoopMgr"): from AthenaServices.AthenaServicesConf import AthenaEventLoopMgr svcMgr += AthenaEventLoopMgr() svcMgr.AthenaEventLoopMgr.EventPrintoutInterval = 100 log.info('Set AthenaEventLoopMgr.EventPrintoutInterval = 100') if not hasattr(svcMgr, "AtRndmGenSvc"): from AthenaServices.AthenaServicesConf import AtRndmGenSvc svcMgr += AtRndmGenSvc() svcMgr.AtRndmGenSvc.OutputLevel = 4 log.info('Set AtRndmGenSvc.OutputLevel = 4') if not hasattr(svcMgr, "AtRanluxGenSvc"): from AthenaServices.AthenaServicesConf import AtRanluxGenSvc svcMgr += AtRanluxGenSvc() svcMgr.AtRanluxGenSvc.OutputLevel = 4 log.info('Set AtRanluxGenSvc.OutputLevel = 4') if config.count('TIME') > 0: log.info('Configure TrigTimerSvc...') from TrigTimeAlgs.TrigTimeAlgsConf import TrigTimerSvc if not hasattr(svcMgr, 'TrigTimerSvc'): svcMgr += TrigTimerSvc() svcMgr.TrigTimerSvc.IncludeName = ".+" svcMgr.TrigTimerSvc.ExcludeName = "()" svcMgr.TrigTimerSvc.OutputLevel = 4 log.info('Setup detailed timing:') print svcMgr.TrigTimerSvc
"TTREE DATAFILE='" + runArgs.outputNTUP_LARNOISEFile + "' OPT='RECREATE'" ] if hasattr(runArgs, "outputNTUP_HECNOISEFile"): from LArCafJobs.LArCafJobsConf import LArHECNoise topSequence += LArHECNoise('LArHECNoise') svcMgr.THistSvc.Output += [ "HEC DATAFILE='" + runArgs.outputNTUP_HECNOISEFile + "' OPT='RECREATE'" ] #little hack while autoConfiguration=everything is still not the default... if hasattr(runArgs, "inputESDFile") and not hasattr(runArgs, "inputFile"): athenaCommonFlags.FilesInput.set_Value_and_Lock(runArgs.inputESDFile) from AthenaServices.AthenaServicesConf import AthenaEventLoopMgr svcMgr += AthenaEventLoopMgr() svcMgr.AthenaEventLoopMgr.EventPrintoutInterval = 100 theAuditorSvc = svcMgr.AuditorSvc theAuditorSvc.Auditors += ["ChronoAuditor"] #svcMgr.ChronoStatSvc.ChronoDestinationCout = True svcMgr.ChronoStatSvc.PrintUserTime = True svcMgr.ChronoStatSvc.PrintSystemTime = True svcMgr.ChronoStatSvc.PrintEllapsedTime = True #svcMgr.ChronoStatSvc.NumberOfSkippedEventsForMemStat = 1 #svcMgr.ChronoStatSvc.AsciiStatsOutputFile = "chronoStats.ascii" #svcMgr.AthenaPoolCnvSvc.UseDetailChronoStat = True
def AssembleIO(): #-------------------------------------------------------------- # Reduce the event loop spam a bit #-------------------------------------------------------------- from AthenaCommon.Logging import logging recoLog = logging.getLogger('MuonAnalysis I/O') recoLog.info('****************** STARTING the job *****************') if os.path.exists("%s/athfile-cache.ascii.gz" % (os.getcwd())): recoLog.info( "Old athfile-cache found. Will delete it otherwise athena just freaks out. This little boy." ) os.system("rm %s/athfile-cache.ascii.gz" % (os.getcwd())) from GaudiSvc.GaudiSvcConf import THistSvc from AthenaCommon.JobProperties import jobproperties import AthenaPoolCnvSvc.ReadAthenaPool from AthenaCommon.AthenaCommonFlags import athenaCommonFlags as acf from AthenaServices.AthenaServicesConf import AthenaEventLoopMgr from AthenaCommon.AppMgr import ServiceMgr from ClusterSubmission.Utils import ReadListFromFile, ResolvePath, IsROOTFile from MuonAnalysis.Utils import IsTextFile ServiceMgr += AthenaEventLoopMgr(EventPrintoutInterval=1000000) ServiceMgr += THistSvc() OutFileName = "AnalysisOutput.root" if not "outFile" in globals( ) else outFile ServiceMgr.THistSvc.Output += [ "MuonAnalysis DATAFILE='{}' OPT='RECREATE'".format(OutFileName) ] recoLog.info("Will save the job's output to " + OutFileName) ROOTFiles = [] if "inputFile" in globals(): recoLog.info("Use the following %s as input" % (inputFile)) ROOTFiles = [] ResolvedInFile = ResolvePath(inputFile) if inputFile.startswith('root://'): ROOTFiles.append(inputFile) elif ResolvedInFile and os.path.isfile(ResolvedInFile): if IsTextFile(ResolvedInFile): ROOTFiles = ReadListFromFile(ResolvedInFile) else: ROOTFiles.append(ResolvedInFile) elif ResolvedInFile and os.path.isdir(ResolvedInFile): for DirEnt in os.listdir(ResolvedInFile): if IsROOTFile(DirEnt): if DirEnt.find(ResolvedInFile) != -1: ROOTFiles.append(DirEnt) else: ROOTFiles.append("%s/%s" % (ResolvedInFile, DirEnt)) else: raise RuntimeError("Invalid input " + inputFile) if len(ROOTFiles) == 0: raise RuntimeError("No ROOT files could be loaded as input") ServiceMgr.EventSelector.InputCollections = ROOTFiles acf.FilesInput = ROOTFiles if "nevents" in globals(): recoLog.info("Only run on %i events" % (int(nevents))) theApp.EvtMax = int(nevents) if "nskip" in globals(): recoLog.info("Skip the first %i events" % (int(nskip))) ServiceMgr.EventSelector.SkipEvents = int(nskip) """if isData(): recoLog.info("We're running over data today")
#------------------------------------------------------------------------------ from AthenaCommon.AppMgr import ServiceMgr import AthenaPoolCnvSvc.ReadAthenaPool ServiceMgr.EventSelector.InputCollections = inputFiles print ServiceMgr.EventSelector.InputCollections if 'EvtMax' in dir(): theApp.EvtMax = EvtMax else: theApp.EvtMax = -1 #------------------------------------------------------------------------------ if not hasattr(ServiceMgr, 'AthenaEventLoopMg'): from AthenaServices.AthenaServicesConf import AthenaEventLoopMgr ServiceMgr += AthenaEventLoopMgr(EventPrintoutInterval = 100) if 'dumpSG' in dir(): StoreGateSvc = Service('StoreGateSvc') StoreGateSvc.Dump = dumpSG #------------------------------------------------------------------------------ muon_sf = CfgMgr.CP__MuonTriggerScaleFactors('muonTrigSFs', OutputLevel = INFO) #muon_sf.filename = "/pc2012-data2/rustem/testarea/AtlasMuon/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/share/muon_trigger_eff_jun30.root" ToolSvc += muon_sf #------------------------------------------------------------------------------ def getTestMuon(input_name):
# If not defined the defaults given above are used for var in loadInDetRec_Options: if var in dir(): loadInDetRec_Options[var] = eval(var) print "Starting loadInDet_Rec" #-------------------------------------------------------------- # Import config #-------------------------------------------------------------- from AthenaCommon.AthenaCommonFlags import athenaCommonFlags from RecExConfig.RecFlags import rec from RecExConfig.RecAlgsFlags import recAlgs from AthenaServices.AthenaServicesConf import AthenaEventLoopMgr ServiceMgr += AthenaEventLoopMgr() ServiceMgr.AthenaEventLoopMgr.EventPrintoutInterval = 100 #-------------------------------------------------------------------------------- #Setup jobProperties - Override Autoconfiguration of the BField. Needed for MC BOFF- #-------------------------------------------------------------------------------- from AthenaCommon.BeamFlags import jobproperties from AthenaCommon.BFieldFlags import jobproperties if not loadInDetRec_Options["realData"] and loadInDetRec_Options[ "Cosmics"]: # and not loadInDetRec_Options["BField"] PF: I think this causes the wrong setup in Cosmics MC print "INFO::Setting Up Manually for MC Cosmics" jobproperties.Beam.numberOfCollisions.set_Value_and_Lock(0.0) jobproperties.Beam.beamType.set_Value_and_Lock("cosmics") jobproperties.BField.solenoidOn.set_Value_and_Lock( loadInDetRec_Options["BField"]) jobproperties.BField.barrelToroidOn.set_Value_and_Lock(
class WasteTimeAlg(PyAlgorithm): def execute(self): printfunc("waste some time") for i in range(200000): foo = i * i / (i + 1) / (i + 2) return 1 waste = WasteTimeAlg() import ROOT ROOT.SetOwnership(waste, 0) include("AthenaServices/SimplePOSIXTimeKeeperOptions.py") from AthenaCommon.AlgSequence import AlgSequence from AthenaCommon.Configurable import ConfigurablePyAlgorithm top = AlgSequence() top += ConfigurablePyAlgorithm('WasteTimeAlg') from AthenaCommon.AppMgr import ServiceMgr from AthenaServices.AthenaServicesConf import SimplePOSIXTimeKeeperSvc, AthenaEventLoopMgr ServiceMgr += SimplePOSIXTimeKeeperSvc() ServiceMgr.SimplePOSIXTimeKeeperSvc.OutputLevel = 1 ServiceMgr.SimplePOSIXTimeKeeperSvc.AllocTime = 6 ServiceMgr += AthenaEventLoopMgr(TimeKeeper="SimplePOSIXTimeKeeperSvc") #from GaudiSvc.GaudiSvcConf import MessageSvc #ServiceMgr.MessageSvc.OutputLevel = 2