class menuVersion(JobProperty): """ Defines the menu version to use, usually the same as the release number. This is part of the XML file name. """ statusOn = True allowedType = ['str'] from AthenaCommon.AppMgr import release_metadata StoredValue = release_metadata()['release'] # returns '?' if missing
def GeoModelCfg(configFlags): version = configFlags.GeoModel.AtlasVersion from AthenaCommon.AppMgr import release_metadata rel_metadata = release_metadata() relversion = rel_metadata['release'].split('.') if len(relversion) < 3: relversion = rel_metadata['base release'].split('.') result = ComponentAccumulator() GeoModelSvc = CompFactory.GeoModelSvc gms = GeoModelSvc(AtlasVersion=version, SupportedGeometry=int(relversion[0])) if configFlags.Detector.Simulate: ## Protects GeoModelSvc in the simulation from the AlignCallbacks gms.AlignCallbacks = False result.addService(gms, primary=True) #Get DetDescrCnvSvc (for identifier dictionaries (identifier helpers) from DetDescrCnvSvc.DetDescrCnvSvcConfig import DetDescrCnvSvcCfg result.merge(DetDescrCnvSvcCfg(configFlags)) from EventInfoMgt.TagInfoMgrConfig import TagInfoMgrCfg tim_ca, tagInfoMgr = TagInfoMgrCfg(configFlags) result.addService(tagInfoMgr) result.merge(tim_ca) #TagInfoMgr used by GeoModelSvc but no ServiceHandle. Relies on string-name return result
def TrigIDPhysValMonitoringTool(legacy_monitoring=False): # dataTypes: userDefined = 0, monteCarlo, collisions, cosmics if 'DQMonFlags' not in dir(): from AthenaMonitoring.DQMonFlags import DQMonFlags # noqa: F401 # disable everything outputlist = [] if 'rec' not in dir(): from RecExConfig.RecFlags import rec from TriggerJobOpts.HLTTriggerResultGetter import EDMDecodingVersion from TriggerJobOpts.TriggerFlags import TriggerFlags EDMDecodingVersion() mt_chains = True if (TriggerFlags.EDMDecodingVersion < 3 or legacy_monitoring): mt_chains = False if rec.doInDet: from TrigInDetAnalysisExample.TrigInDetAnalysisExampleConf import TrigTestPhysValMon from AthenaCommon.AppMgr import release_metadata d = release_metadata() def makePhysvalMon(name, pdgid, chainnames, useHighestPT, cosmic=False, useOffline=False, doFS=False): Monname = "TestIDPhysValMon" + name TestIDPhysValMon = TrigTestPhysValMon(name=Monname) TestIDPhysValMon.SliceTag = "HLT/IDMon/" + name TestIDPhysValMon.UseHighestPT = useHighestPT try: TestIDPhysValMon.EnableLumi = False except Exception: pass TestIDPhysValMon.buildNtuple = False TestIDPhysValMon.AnalysisConfig = "Tier0" #T0 Analysis # TestIDPhysValMon.AnalysisConfig = "nTuple" #nTuple Analysis if (useOffline or rec.doTruth is False): TestIDPhysValMon.mcTruth = False TestIDPhysValMon.ntupleChainNames = ['Offline', name] # use default values ? # TestIDPhysValMon.sctHitsOffline = 1 # TestIDPhysValMon.pixHitsOffline = 1 if (doFS is True): TestIDPhysValMon.sctHitsOffline = 6 TestIDPhysValMon.pixHitsOffline = 4 TestIDPhysValMon.blayerHitsOffline = 1 TestIDPhysValMon.pixHolesOffline = 1 elif (rec.doTruth is True): TestIDPhysValMon.mcTruth = True TestIDPhysValMon.ntupleChainNames = ['Truth'] TestIDPhysValMon.sctHitsOffline = -1 TestIDPhysValMon.pixHitsOffline = -1 if (pdgid != 0): TestIDPhysValMon.SelectTruthPdgId = pdgid elif (cosmic): TestIDPhysValMon.mcTruth = False TestIDPhysValMon.ntupleChainNames = ['Offline'] TestIDPhysValMon.sctHitsOffline = -1 TestIDPhysValMon.pixHitsOffline = -1 TestIDPhysValMon.ntupleChainNames += chainnames TestIDPhysValMon.releaseMetaData = d['nightly name'] + " " + d[ 'nightly release'] + " " + d['date'] + " " + d[ 'platform'] + " " + d['release'] #from AthenaCommon.AppMgr import ToolSvc #ToolSvc += TestIDPhysValMon #Monname = "TrigTestPhysValMon/" + Monname return TestIDPhysValMon ############### Electrons ############### name = "Electron" pdgid = 11 useHighestPT = True if mt_chains: chainnames = [ "HLT_e.*idperf.*:key=HLT_IDTrack_Electron_FTF", "HLT_e.*idperf.*:key=HLT_IDTrack_Electron_IDTrig", "HLT_e.*etcut.*:key=HLT_IDTrack_Electron_FTF", "HLT_e.*etcut.*:key=HLT_IDTrack_Electron_IDTrig" ] else: chainnames = [ "HLT_e.*idperf.*:InDetTrigTrackingxAODCnv_Electron_IDTrig", "HLT_e.*idperf.*:InDetTrigTrackingxAODCnv_Electron_FTF" ] outputlist += [makePhysvalMon(name, pdgid, chainnames, useHighestPT)] name = "Electron_offline" pdgid = 11 useHighestPT = True cosmic = False useOffline = True if mt_chains: chainnames = [ "HLT_e.*idperf.*:key=HLT_IDTrack_Electron_FTF", "HLT_e.*idperf.*:key=HLT_IDTrack_Electron_IDTrig", "HLT_e.*etcut.*:key=HLT_IDTrack_Electron_FTF", "HLT_e.*etcut.*:key=HLT_IDTrack_Electron_IDTrig" ] else: chainnames = [ "HLT_e.*idperf.*:InDetTrigTrackingxAODCnv_Electron_IDTrig", "HLT_e.*idperf.*:InDetTrigTrackingxAODCnv_Electron_FTF" ] outputlist += [ makePhysvalMon(name, pdgid, chainnames, useHighestPT, cosmic, useOffline) ] ############### Muons ############### name = "Muon" pdgid = 13 useHighestPT = True if mt_chains: chainnames = [ "HLT_mu.*idperf.*:key=HLT_IDTrack_Muon_FTF:roi=HLT_Roi_L2SAMuon", "HLT_mu.*idperf.*:key=HLT_IDTrack_Muon_IDTrig:roi=HLT_Roi_L2SAMuonForEF", "HLT_mu.*i.*:key=HLT_IDTrack_MuonIso_FTF:roi=HLT_Roi_MuonIso", "HLT_mu.*i.*:key=HLT_IDTrack_MuonIso_IDTrig:roi=HLT_Roi_MuonIso" ] else: chainnames = [ "HLT_mu.*idperf.*:InDetTrigTrackingxAODCnv_Muon_IDTrig", "HLT_mu.*idperf.*:InDetTrigTrackingxAODCnv_Muon_FTF" ] outputlist += [makePhysvalMon(name, pdgid, chainnames, useHighestPT)] name = "Muon_offline" pdgid = 13 useHighestPT = True cosmic = False useOffline = True if mt_chains: chainnames = [ "HLT_mu.*idperf.*:key=HLT_IDTrack_Muon_FTF:roi=HLT_Roi_L2SAMuon", "HLT_mu.*idperf.*:key=HLT_IDTrack_Muon_IDTrig:roi=HLT_Roi_L2SAMuon" ] else: chainnames = [ "HLT_mu.*idperf.*:InDetTrigTrackingxAODCnv_Muon_IDTrig", "HLT_mu.*idperf.*:InDetTrigTrackingxAODCnv_Muon_FTF" ] outputlist += [ makePhysvalMon(name, pdgid, chainnames, useHighestPT, cosmic, useOffline) ] ############### Taus ############### name = "Tau" pdgid = 15 useHighestPT = True if mt_chains: chainnames = [ "HLT_tau.*idperf.*tracktwo.*:key=HLT_IDTrack_TauCore_FTF:roi=HLT_Roi_TauCore", "HLT_tau.*idperf.*tracktwo.*:key=HLT_IDTrack_TauIso_FTF:roi=HLT_Roi_TauIso_TauID", "HLT_tau.*idperf.*tracktwo.*:key=HLT_IDTrack_Tau_IDTrig:roi=HLT_Roi_TauIso_TauID" ] else: chainnames = [ "HLT_tau.*idperf.*:key=InDetTrigTrackingxAODCnv_Tau_IDTrig:roi=forID3", "HLT_tau.*idperf.*:key=InDetTrigTrackingxAODCnv_Tau_FTF:roi=forID", "HLT_tau.*idperf.*:key=InDetTrigTrackingxAODCnv_TauCore_FTF:roi=forID1", "HLT_tau.*idperf.*:key=InDetTrigTrackingxAODCnv_TauIso_FTF:roi=forID3" ] outputlist += [makePhysvalMon(name, pdgid, chainnames, useHighestPT)] ############### Taus ############### name = "Tau_offline" pdgid = 15 useHighestPT = True cosmic = False useOffline = True if mt_chains: chainnames = [ "HLT_tau.*idperf.*tracktwo.*:key=HLT_IDTrack_TauCore_FTF:roi=HLT_Roi_TauCore", "HLT_tau.*idperf.*tracktwo.*:key=HLT_IDTrack_TauIso_FTF:roi=HLT_Roi_TauIso", "HLT_tau.*idperf.*tracktwo.*:key=HLT_IDTrack_Tau_IDTrig", "HLT_tau.*idperf.*tracktwo.*:key=HLT_IDTrack_Tau_FTF" ] else: chainnames = [ "HLT_tau.*idperf.*:key=InDetTrigTrackingxAODCnv_Tau_IDTrig:roi=forID3", "HLT_tau.*idperf.*:key=InDetTrigTrackingxAODCnv_Tau_FTF:roi=forID", "HLT_tau.*idperf.*:key=InDetTrigTrackingxAODCnv_TauCore_FTF:roi=forID1", "HLT_tau.*idperf.*:key=InDetTrigTrackingxAODCnv_TauIso_FTF:roi=forID3" ] outputlist += [ makePhysvalMon(name, pdgid, chainnames, useHighestPT, cosmic, useOffline) ] ############### Bjets ############### name = "Bjet_offline" pdgid = 5 useHighestPT = False cosmic = False useOffline = True if mt_chains: chainnames = [ ":key=HLT_IDTrack_FS_FTF", "HLT_j.*b.*perf_split:key=HLT_IDTrack_Bjet_FTF", "HLT_j.*b.*perf_split:key=HLT_IDTrack_Bjet_IDTrig" ] else: chainnames = [ "HLT_j.*b.*perf_split:key=InDetTrigTrackingxAODCnv_BjetPrmVtx_FTF:roi=TrigSuperRoi", "HLT_j.*b.*perf_split:InDetTrigTrackingxAODCnv_Bjet_IDTrig", "HLT_j.*b.*perf_split:InDetTrigTrackingxAODCnv_Bjet_FTF", "HLT_mu.*b.*perf_dr05:key=InDetTrigTrackingxAODCnv_BjetPrmVtx_FTF:roi=TrigSuperRoi", "HLT_mu.*b.*perf_dr05:InDetTrigTrackingxAODCnv_Bjet_IDTrig", "HLT_mu.*b.*perf_dr05:InDetTrigTrackingxAODCnv_Bjet_FTF" ] outputlist += [ makePhysvalMon(name, pdgid, chainnames, useHighestPT, cosmic, useOffline) ] if not mt_chains: ############### Bjets ############### name = "Bjet" pdgid = 5 useHighestPT = False chainnames = [ "HLT_j.*b.*perf_split:key=InDetTrigTrackingxAODCnv_BjetPrmVtx_FTF:roi=TrigSuperRoi", "HLT_j.*b.*perf_split:InDetTrigTrackingxAODCnv_Bjet_IDTrig", "HLT_j.*b.*perf_split:InDetTrigTrackingxAODCnv_Bjet_FTF", "HLT_mu.*b.*perf_dr05:key=InDetTrigTrackingxAODCnv_BjetPrmVtx_FTF:roi=TrigSuperRoi", "HLT_mu.*b.*perf_dr05:InDetTrigTrackingxAODCnv_Bjet_IDTrig", "HLT_mu.*b.*perf_dr05:InDetTrigTrackingxAODCnv_Bjet_FTF" ] outputlist += [ makePhysvalMon(name, pdgid, chainnames, useHighestPT) ] ############### Bphys ############### name = "Bphys" pdgid = 0 # Doesn't make sense useHighestPT = False chainnames = [ "HLT_.*Bmumux.*:InDetTrigTrackingxAODCnv_Bphysics_IDTrig", "HLT_.*Bmumux.*:InDetTrigTrackingxAODCnv_Bphysics_FTF" ] outputlist += [ makePhysvalMon(name, pdgid, chainnames, useHighestPT) ] ############### Bphys ############### name = "Bphys_offline" pdgid = 0 # Doesn't make sense useHighestPT = False cosmic = False useOffline = True chainnames = [ "HLT_.*Bmumux.*:InDetTrigTrackingxAODCnv_Bphysics_IDTrig", "HLT_.*Bmumux.*:InDetTrigTrackingxAODCnv_Bphysics_FTF" ] outputlist += [ makePhysvalMon(name, pdgid, chainnames, useHighestPT, cosmic, useOffline) ] ############### Cosmics ############### name = "Cosmic" useHighestPT = False pdgid = 0 # Not used for cosmic chainnames = [ 'HLT_.*id.*cosmic.*:InDetTrigTrackingxAODCnvIOTRT_CosmicsN_EFID', 'HLT_.*id.*cosmic.*:InDetTrigTrackingxAODCnv_CosmicsN_EFID' ] outputlist += [ makePhysvalMon(name, pdgid, chainnames, useHighestPT, cosmic=True) ] return outputlist
# "HLT_e.*_etcut.*:HLT_IDTrack_Electron_FTF", # "HLT_e.*_etcut.*:HLT_IDTrack_Electron_IDTrig", "HLT_e.*:HLT_IDTrack_Electron_FTF", "HLT_e.*:HLT_IDTrack_Electron_IDTrig", "HLT_tau.*_idperf.*:HLT_IDTrack_Tau_FTF", "HLT_tau.*_idperf.*:HLT_IDTrack_Tau_FTF:roi=HLT_TAURoI" "HLT_tau.*_idperf.*:HLT_IDTrack_TauCore_FTF", "HLT_tau.*_idperf.*:HLT_IDTrack_TauIso_FTF", "HLT_tau.*_idperf.*:HLT_IDTrack_TauCore_FTF:roi=HLT_Roi_TauCore", "HLT_tau.*_idperf.*:HLT_IDTrack_TauIso_FTF:roi=HLT_Roi_TauIso", "HLT_tau.*_idperf.*:HLT_IDTrack_Tau_IDTrig", "HLT_tau.*_idperf.*:HLT_IDTrack_Tau_IDTrig:roi=HLT_TAURoI", "HLT_tau.*_idperf.*:HLT_IDTrack_Tau_IDTrig:roi=HLT_Roi_TauIso", "HLT_mb.*:HLT_IDTrack_MinBias_FTF", ] from AthenaCommon.AppMgr import release_metadata d = release_metadata() TestMonTool.releaseMetaData = d['nightly name'] + " " + d[ 'nightly release'] + " " + d['date'] + " " + d['platform'] + " " + d[ 'release'] TestMonTool.outputFileName = "TrkNtuple.root" HLTMonManager.AthenaMonTools += [TestMonTool] print(TestMonTool) print("configured everything") # include("AthAnalysisBaseComps/SuppressLogging.py") #Optional include to suppress as much athena output as possible. Keep at bottom of joboptions so that it doesn't suppress the logging of the things you have configured above MessageSvc.infoLimit = 100000000
def TrigIDPhysValMonitoringTool(): from AthenaCommon.Constants import INFO,ERROR,FALSE,TRUE,DEBUG,VERBOSE # dataTypes: userDefined = 0, monteCarlo, collisions, cosmics if not 'DQMonFlags' in dir(): from AthenaMonitoring.DQMonFlags import DQMonFlags dataType = DQMonFlags.monManDataType() if not 'rec' in dir(): from RecExConfig.RecFlags import rec outputlist = [] if rec.doInDet: from TrigInDetAnalysisExample.TrigInDetAnalysisExampleConf import TrigTestPhysValMon from AthenaCommon.AppMgr import release_metadata d = release_metadata() def makePhysvalMon(name, pdgid, chainnames, useHighestPT, cosmic = False): Monname = "TestIDPhysValMon" + name TestIDPhysValMon = TrigTestPhysValMon(name=Monname) TestIDPhysValMon.SliceTag = "HLT/IDMon/" + name TestIDPhysValMon.OutputLevel = INFO TestIDPhysValMon.UseHighestPT = useHighestPT try: TestIDPhysValMon.EnableLumi = False except: pass TestIDPhysValMon.buildNtuple = False TestIDPhysValMon.AnalysisConfig = "Tier0" #T0 Analysis # TestIDPhysValMon.AnalysisConfig = "nTuple" #nTuple Analysis if (rec.doTruth == True): TestIDPhysValMon.mcTruth = True TestIDPhysValMon.ntupleChainNames = ['Truth'] TestIDPhysValMon.sctHitsOffline = -1 TestIDPhysValMon.pixHitsOffline = -1 if (pdgid != 0): TestIDPhysValMon.SelectTruthPdgId = pdgid elif (cosmic): TestIDPhysValMon.mcTruth = False TestIDPhysValMon.ntupleChainNames = ['Offline'] TestIDPhysValMon.sctHitsOffline = -1 TestIDPhysValMon.pixHitsOffline = -1 else: TestIDPhysValMon.mcTruth = False TestIDPhysValMon.ntupleChainNames = ['Offline',name] # use default values ? # TestIDPhysValMon.sctHitsOffline = 1 # TestIDPhysValMon.pixHitsOffline = 1 TestIDPhysValMon.ntupleChainNames += chainnames TestIDPhysValMon.releaseMetaData = d['nightly name'] + " " + d['nightly release'] + " " + d['date'] + " " + d['platform'] + " " + d['release'] from AthenaCommon.AppMgr import ToolSvc ToolSvc += TestIDPhysValMon Monname = "TrigTestPhysValMon/" + Monname return Monname ############### Electrons ############### name = "Electron" pdgid = 11 useHighestPT = True chainnames = [ "HLT_e.*idperf.*:InDetTrigTrackingxAODCnv_Electron_IDTrig", "HLT_e.*idperf.*:InDetTrigTrackingxAODCnv_Electron_FTF" ] outputlist += [makePhysvalMon(name, pdgid, chainnames, useHighestPT )] ############### Muons ############### name = "Muon" pdgid = 13 useHighestPT = True chainnames = [ "HLT_mu.*idperf.*:InDetTrigTrackingxAODCnv_Muon_IDTrig", "HLT_mu.*idperf.*:InDetTrigTrackingxAODCnv_Muon_FTF" ] outputlist += [makePhysvalMon(name, pdgid, chainnames, useHighestPT )] ############### Taus ############### name = "Tau" pdgid = 15 useHighestPT = True chainnames = [ "HLT_tau.*idperf.*:key=InDetTrigTrackingxAODCnv_Tau_IDTrig:roi=forID3", "HLT_tau.*idperf.*:key=InDetTrigTrackingxAODCnv_Tau_FTF:roi=forID", "HLT_tau.*idperf.*:key=InDetTrigTrackingxAODCnv_TauCore_FTF:roi=forID1", "HLT_tau.*idperf.*:key=InDetTrigTrackingxAODCnv_TauIso_FTF:roi=forID3" ] outputlist += [makePhysvalMon(name, pdgid, chainnames, useHighestPT )] ############### Bjets ############### name = "Bjet" pdgid = 5 useHighestPT = False chainnames = [ "HLT_j.*b.*perf_split:key=InDetTrigTrackingxAODCnv_BjetPrmVtx_FTF:roi=TrigSuperRoi", "HLT_j.*b.*perf_split:InDetTrigTrackingxAODCnv_Bjet_IDTrig", "HLT_j.*b.*perf_split:InDetTrigTrackingxAODCnv_Bjet_FTF", "HLT_mu.*b.*perf_dr05:key=InDetTrigTrackingxAODCnv_BjetPrmVtx_FTF:roi=TrigSuperRoi", "HLT_mu.*b.*perf_dr05:InDetTrigTrackingxAODCnv_Bjet_IDTrig", "HLT_mu.*b.*perf_dr05:InDetTrigTrackingxAODCnv_Bjet_FTF" ] outputlist += [makePhysvalMon(name, pdgid, chainnames, useHighestPT )] ############### Bphys ############### name = "Bphys" pdgid = 0 # Doesn't make sense useHighestPT = False chainnames = [ "HLT_.*Bmumux.*:InDetTrigTrackingxAODCnv_Bphysics_IDTrig", "HLT_.*Bmumux.*:InDetTrigTrackingxAODCnv_Bphysics_FTF" ] outputlist += [makePhysvalMon(name, pdgid, chainnames, useHighestPT )] ############### Cosmics ############### name = "Cosmic" useHighestPT = False pdgid = 0 # Not used for cosmic chainnames = [ 'HLT_.*id.*cosmic.*:InDetTrigTrackingxAODCnvIOTRT_CosmicsN_EFID', 'HLT_.*id.*cosmic.*:InDetTrigTrackingxAODCnv_CosmicsN_EFID' ] outputlist += [makePhysvalMon(name, pdgid, chainnames, useHighestPT, cosmic=True)] return outputlist
DetFlags.ID_setOff() DetFlags.Muon_setOff() DetFlags.Tile_setOff() elif (DDversion == "ATLAS-H6-2003-00"): GeoModelSvc.AtlasVersion = "ATLAS-H6-2003-00" DetFlags.HEC_setOff() DetFlags.em_setOff() elif (DDversion == "ATLAS-H6-2002-00"): GeoModelSvc.AtlasVersion = "ATLAS-H6-2002-00" DetFlags.FCal_setOff() elif (DDversion == "ATLAS-TBEC-00"): GeoModelSvc.AtlasVersion = "ATLAS-TBEC-00" DetFlags.HEC_setOff() DetFlags.FCal_setOff() else: GeoModelSvc.AtlasVersion = DDversion # Set the SupportedGeometry flag from AthenaCommon.AppMgr import release_metadata rel_metadata = release_metadata() relversion = rel_metadata['release'].split('.') if len(relversion) < 3: relversion = rel_metadata['base release'].split('.') print "SetGeometryVersion.py obtained major release version %s" % relversion[0] GeoModelSvc.SupportedGeometry = int(relversion[0])
def createTriggerFlags(): flags = AthConfigFlags() # enables L1 simulation flags.addFlag('Trigger.doLVL1', lambda prevFlags: prevFlags.Input.isMC) # enables L1 topological trigger simulation flags.addFlag('Trigger.doL1Topo', True) # writes additional info from Topo simulation flags.addFlag('Trigger.writeL1TopoValData', True) # need proper documentation flags.addFlag('Trigger.useL1CaloCalibration', False) # need proper documentation flags.addFlag('Trigger.useRun1CaloEnergyScale', False) # enable HLT part of the trigger flags.addFlag('Trigger.doHLT', True) # changes decoding of L1 so that allways all configured chains are enabled, testing mode flags.addFlag("Trigger.L1Decoder.forceEnableAllChains", False) # Enable Run-3 LVL1 simulation and/or decoding flags.addFlag('Trigger.enableL1Phase1', False) # Enable usage of new L1 menu flags.addFlag('Trigger.readLVL1FromJSON', True) # Enable Run-2 L1Calo simulation and/or decoding (possible even if enablePhase1 is True) flags.addFlag('Trigger.enableL1CaloLegacy', True) # Enable Inner Detector flags.addFlag('Trigger.doID', True) # Enable muon system flags.addFlag('Trigger.doMuon', True) # Enable calorimeters flags.addFlag('Trigger.doCalo', True) # if 1, Run1 decoding version is set; if 2, Run2; if 3, Run 3 def EDMDecodingVersion(flags): log.debug("Attempting to determine EDMDecodingVersion.") version = 3 if flags.Input.Format == "BS": log.debug("EDMDecodingVersion: Input format is ByteStream") inputFileName = flags.Input.Files[0] if not inputFileName and flags.Common.isOnline(): log.debug( "EDMDecodingVersion: Online reconstruction, no input file. Return default version, i.e. AthenaMT." ) return version log.debug("EDMDecodingVersion: Checking ROD version.") import eformat from libpyeformat_helper import SubDetector bs = eformat.istream(inputFileName) rodVersionM = -1 rodVersionL = -1 # Find the first HLT ROBFragment in the first event for robf in bs[0]: if robf.rob_source_id().subdetector_id( ) == SubDetector.TDAQ_HLT: rodVersionM = robf.rod_minor_version() >> 8 rodVersionL = robf.rod_minor_version() & 0xFF log.debug( "EDMDecodingVersion: HLT ROD minor version from input file is {:d}.{:d}" .format(rodVersionM, rodVersionL)) break if rodVersionM >= 1: version = 3 return version log.info( "EDMDecodingVersion: Could not determine ROD version -- falling back to run-number-based determination" ) # Use run number to determine decoding version runNumber = flags.Input.RunNumber[0] log.debug( "EDMDecodingVersion: Read run number {}.".format(runNumber)) boundary_run12 = 230000 boundary_run23 = 368000 if runNumber <= 0: log.warning( "EDMDecodingVersion: Cannot determine decoding version because run number {} is invalid. Leaving the default version." .format(runNumber)) elif runNumber < boundary_run12: # Run-1 data version = 1 elif runNumber < boundary_run23: # Run-2 data version = 2 else: # Run-3 data version = 3 else: log.debug( "EDMDecodingVersion: Input format is POOL -- determine from input file collections." ) # POOL files: decide based on HLT output type present in file if "HLTResult_EF" in flags.Input.Collections: version = 1 elif "TrigNavigation" in flags.Input.Collections: version = 2 elif "HLTNav_Summary" in flags.Input.Collections: version = 3 elif flags.Input.Format == "POOL": # If running Trigger on RDO input (without previous trigger result), choose Run-3 version = 3 log.info("Determined EDMDecodingVersion to be {}.".format({ 1: "Run 1", 2: "Run 2", 3: "AthenaMT" }[version])) return version flags.addFlag('Trigger.EDMDecodingVersion', lambda prevFlags: EDMDecodingVersion(prevFlags)) # enables additional algorithms colecting MC truth infrmation (this is only used by IDso maybe we need Trigger.ID.doTruth only?) flags.addFlag('Trigger.doTruth', False) # only enable services for analysis and BS -> ESD processing (we need better name) flags.addFlag('Trigger.doTriggerConfigOnly', False) # Enables collection and export of detailed monitoring data of the HLT execution flags.addFlag('Trigger.CostMonitoring.doCostMonitoring', False) flags.addFlag('Trigger.CostMonitoring.chain', 'HLT_costmonitor_CostMonDS_L1All') flags.addFlag('Trigger.CostMonitoring.outputCollection', 'HLT_TrigCostContainer') flags.addFlag('Trigger.CostMonitoring.monitorAllEvents', False) # enable Bcm inputs simulation flags.addFlag('Trigger.L1.doBcm', True) # enable muon inputs simulation flags.addFlag('Trigger.L1.doMuons', True) # version of CTP data, int value up to 4 flags.addFlag('Trigger.L1.CTPVersion', 4) # list of thresholds (not sure if we want to use new flags to generate L1, leaving out for now?) # partition name used to determine online vs offline BS result writing import os flags.addFlag('Trigger.Online.partitionName', os.getenv('TDAQ_PARTITION') or '') # shortcut to check if job is running in a partition (i.e. partition name is not empty) flags.addFlag( 'Trigger.Online.isPartition', lambda prevFlags: len(prevFlags.Trigger.Online.partitionName) > 0) # write BS output file flags.addFlag('Trigger.writeBS', False) # Write transient BS before executing HLT algorithms (for running on MC RDO with clients which require BS inputs) flags.addFlag('Trigger.doTransientByteStream', False) # list of EDM objects to be written to AOD flags.addFlag('Trigger.AODEDMSet', 'AODSLIM') # list of objects to be written to ESD flags.addFlag('Trigger.ESDEDMSet', 'ESD') # tag to be used for condutions used by HLT code flags.addFlag('Trigger.OnlineCondTag', 'CONDBR2-HLTP-2018-01') # geometry version used by HLT online flags.addFlag('Trigger.OnlineGeoTag', 'ATLAS-R2-2016-01-00-01') # configuration tune for various years of Run2 (why string?) flags.addFlag('Trigger.run2Config', '2018') # comissionig options # one of: 'HltOnly', # 'Lvl1Only', # 'FullTrigger', # 'NoTrigger' flags.addFlag('Trigger.dataTakingConditions', 'FullTrigger') # use or not frontier proxies flags.addFlag('Trigger.triggerUseFrontier', False) # the configuration source # see https://twiki.cern.ch/twiki/bin/view/Atlas/TriggerConfigFlag flags.addFlag('Trigger.triggerConfig', 'FILE') # name of the trigger menu flags.addFlag('Trigger.triggerMenuSetup', 'LS2_v1') # name of the trigger menu flags.addFlag('Trigger.generateMenuDiagnostics', False) # version of the menu from AthenaCommon.AppMgr import release_metadata flags.addFlag('Trigger.menuVersion', lambda prevFlags: release_metadata()['release']) # generate or not the HLT configuration flags.addFlag('Trigger.generateHLTMenu', False) # HLT XML file name flags.addFlag( 'Trigger.HLTMenuFile', lambda prevFlags: 'HLTMenu_' + prevFlags.Trigger .triggerMenuSetup + '_' + prevFlags.Trigger.menuVersion + '.xml') # generate or not the L1 configuration flags.addFlag('Trigger.generateL1Menu', False) def _deriveL1ConfigName(prevFlags): import re log = logging.getLogger('TrigConfigSvcCfg') pattern = re.compile(r'_v\d+|DC14') menuName = prevFlags.Trigger.triggerMenuSetup patternPos = pattern.search(menuName) if patternPos: menuName = menuName[:patternPos.end()] else: log.info( 'Can\'t find pattern to shorten menu name, either non-existent in name or not implemented.' ) return "LVL1config_" + menuName + "_" + prevFlags.Trigger.menuVersion + ".xml" # L1 XML file name flags.addFlag('Trigger.LVL1ConfigFile', _deriveL1ConfigName) # L1 Json file name flags.addFlag( 'Trigger.L1MenuFile', lambda prevFlags: 'L1Menu_' + prevFlags.Trigger. triggerMenuSetup + '_' + prevFlags.Trigger.menuVersion + '.json') # L1 topo XML file name def _deriveTopoConfigName(prevFlags): import re menuSetup = prevFlags.Trigger.triggerMenuSetup m = re.match(r'(.*v\d).*', menuSetup) if m: menuSetup = m.groups()[0] return "L1Topoconfig_" + menuSetup + "_" + prevFlags.Trigger.menuVersion + ".xml" flags.addFlag('Trigger.LVL1TopoConfigFile', _deriveTopoConfigName) # trigger reconstruction # enables the correction for pileup in cell energy calibration (should it be moved to some place where other calo flags are defined?) flags.addFlag('Trigger.calo.doOffsetCorrection', True) # helper to switch between versions def __tunes(default, ver2016, ver2017): from collections import defaultdict return lambda year: defaultdict(lambda: default, ( ('2016', ver2016), ('2017', ver2017)))[year] # Particle ID tune flags.addFlag( 'Trigger.egamma.pidVersion', lambda prevFlags: __tunes( default='ElectronPhotonSelectorTools/trigger/rel21_mc16a/', ver2016='ElectronPhotonSelectorTools/trigger/rel21_mc16a/', ver2017='ElectronPhotonSelectorTools/trigger/rel21_20170214/') (prevFlags.Trigger.run2Config)) # cluster correction version, allowed value is: None or v12phiflip_noecorrnogap flags.addFlag( 'Trigger.egamma.clusterCorrectionVersion', lambda prevFlags: __tunes( default=None, ver2016=None, ver2017='v12phiflip_noecorrnogap') (prevFlags.Trigger.run2Config)) # tune of MVA flags.addFlag( 'Trigger.egamma.calibMVAVersion', lambda prevFlags: __tunes(default='egammaMVACalib/online/v3', ver2016='egammaMVACalib/online/v3', ver2017='egammaMVACalib/online/v6') (prevFlags.Trigger.run2Config)) # muons flags.addFlag('Trigger.muon.doEFRoIDrivenAccess', False) # muon offline reco flags varaint for trigger def __muon(): from MuonConfig.MuonConfigFlags import createMuonConfigFlags return createMuonConfigFlags() flags.addFlagsCategory('Trigger.Offline', __muon, prefix=True) from TriggerJobOpts.MenuConfigFlags import createMenuFlags flags.join(createMenuFlags()) return flags
def _do_peeking(self): """ the real function doing all the work of peeking at the APR file @return a dict of peeked-at data """ import uuid stdout_fname = ('athfile-%i-%s.log.txt' % (os.getpid(), uuid.uuid4())) stdout = open(stdout_fname, "w") print >> stdout, "Extracting in-file metadata without athena sub-process from file", self.f.GetName( ) print >> stdout, "=" * 80 stdout.flush() pool = self.f.Get("##Params") import re pool_token = re.compile(r'[[]NAME=(?P<name>.*?)[]]' r'[[]VALUE=(?P<value>.*?)[]]').match params = [] for i in xrange(pool.GetEntries()): if pool.GetEntry(i) > 0: match = pool_token(pool.FindLeaf("db_string").GetValueString()) if not match: continue d = match.groupdict() params.append((d['name'], d['value'])) if d['name'].lower() == 'fid': guid = d['value'] meta = self.f.Get('MetaData') from AthenaPython.FilePeekerLib import toiter from PyCool import coral attribute_methods = dir(coral.Attribute) methnames = [ 'data<std::__cxx11::basic_string<char> >', 'data<std::basic_string<char> >', 'data<std::string>' ] for m in methnames: if m in attribute_methods: attribute_getdata = m break else: raise Exception("Can't find data method in Attribute") def attr_str_data(attr): return getattr(attr, attribute_getdata)() nb = meta.GetEntry(0) esiName = 'Stream' esiTypeName = 'EventStreamInfo' for l in meta.GetListOfLeaves(): if l.GetTypeName().startswith(esiTypeName): esiTypeName = l.GetTypeName() esiName = l.GetName() break if esiTypeName != 'EventStreamInfo_p3': print >> stdout, "old schema is not supported:", esiTypeName return {} import cppyy esic = cppyy.gbl.EventStreamInfoPTCnv_p3() esi = getattr(meta, esiName) if esiName.startswith(esiTypeName): esiName = esiName[len(esiTypeName) + 1:] peeked_data = {} if guid: peeked_data['file_guid'] = guid peeked_data['run_type'] = ['N/A'] print >> stdout, peeked_data peeked_data['nentries'] = esic.getNumberOfEvents(esi) peeked_data['lumi_block'] = list(esic.lumiBlockNumbers(esi)) peeked_data['run_number'] = list(esic.runNumbers(esi)) peeked_data['stream_names'] = list(esic.processingTags(esi)) item_list = list((cgen.getNameFromClid(i.first), i.second) for i in esic.itemList(esi)) #reorder items to match that of StoreGate if ('DataHeader', esiName) in item_list: item_list.remove(('DataHeader', esiName)) item_list.append(('DataHeader', esiName)) peeked_data['eventdata_items'] = item_list etc = cppyy.gbl.EventTypePTCnv_p3() def bit_mask(self): raw_bit_mask = etc.bit_mask(self) bit_mask_typecodes = [ ('IS_DATA', 'IS_SIMULATION'), ('IS_ATLAS', 'IS_TESTBEAM'), ('IS_PHYSICS', 'IS_CALIBRATION'), ] def decode_bitmask(idx): if len(raw_bit_mask) <= idx: return bit_mask_typecodes[idx][0] isa_idx = raw_bit_mask[idx] return bit_mask_typecodes[idx][isa_idx] bm = map(decode_bitmask, xrange(len(bit_mask_typecodes))) return tuple(bm) def _get_detdescr_tags(evt_type): ddt = evt_type.get_detdescr_tags().split() # det_descr_tags is of the form: # [ 'key1', 'val1', 'key2', 'val2', ... ] ddt = dict(zip( ddt[0::2], # select 'key?' ddt[1::2])) # select 'val?' return ddt etp = esic.eventTypes(esi) if etp.size() > 0: et = etp[0] peeked_data['evt_type'] = bit_mask(et) #ddt = _get_detdescr_tags(et) #peeked_data['det_descr_tags'] = ddt peeked_data['mc_channel_number'] = [et.m_mc_channel_number] peeked_data['evt_number'] = [et.m_mc_event_number] #print >> stdout, 'mc_event_number', et.m_mc_event_number print >> stdout, 'mc_event_weights.size:', et.m_mc_event_weights.size( ) print >> stdout, 'mc_event_weights value', et.m_mc_event_weights[0] print >> stdout, 'user_type', et.m_user_type # handle event-less files if peeked_data['nentries'] == 0: peeked_data['stream_names'] = [esiName] # more event-less files handling - APR-from-BS-event-less files # see bug#98568 if len(peeked_data['run_number']) == 0 and meta.FindBranch( 'ByteStreamMetadata'): bsmd = cppyy.gbl.ByteStreamMetadataPTCnv_p1() # peeked_data['nentries'] = [bsmd.getNumEvents(meta.ByteStreamMetadata[0])] peeked_data['lumi_block'] = [ bsmd.getLumiBlock(meta.ByteStreamMetadata[0]) ] peeked_data['run_number'] = [ bsmd.getRunNumber(meta.ByteStreamMetadata[0]) ] # peeked_data['stream_names'] = [bsmd.getStream(meta.ByteStreamMetadata[0])] peeked_data['beam_type'] = [ bsmd.getBeamType(meta.ByteStreamMetadata[0]) ] peeked_data['beam_energy'] = [ bsmd.getBeamEnergy(meta.ByteStreamMetadata[0]) ] bs_metadata = {} for md in bsmd.getFreeMetaDataStrings(meta.ByteStreamMetadata[0]): if md.startswith('Event type:'): k = 'evt_type' v = [] if 'is sim' in md: v.append('IS_SIMULATION') else: v.append('IS_DATA') if 'is atlas' in md: v.append('IS_ATLAS') else: v.append('IS_TESTBEAM') if 'is physics' in md: v.append('IS_PHYSICS') else: v.append('IS_CALIBRATION') bs_metadata[k] = tuple(v) elif md.startswith('GeoAtlas:'): k = 'geometry' v = md.split('GeoAtlas:')[1].strip() bs_metadata[k] = v elif md.startswith('IOVDbGlobalTag:'): k = 'conditions_tag' v = md.split('IOVDbGlobalTag:')[1].strip() bs_metadata[k] = v elif '=' in md: k, v = md.split('=') bs_metadata[k] = v pass # ATMETADATA-6: without FreeMetaDataStrings this must be BS file from SFO bs_metadata['Stream'] = bsmd.getStream(meta.ByteStreamMetadata[0]) bs_metadata['Project'] = bsmd.getProject( meta.ByteStreamMetadata[0]) if len(bs_metadata.get('evt_type', '')) == 0: 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 peeked_data['evt_type'] = bs_metadata.get('evt_type', []) peeked_data['geometry'] = bs_metadata.get('geometry', None) peeked_data['conditions_tag'] = bs_metadata.get( 'conditions_tag', None) peeked_data['bs_metadata'] = bs_metadata pass cnv = cppyy.gbl.IOVMetaDataContainerPTCnv_p1() obj = cppyy.gbl.IOVMetaDataContainer() def process_metadata(obj, metadata_name): print >> stdout, 'processing container [%s]' % obj.folderName() data = [] payloads = obj.payloadContainer() payloads_sz = payloads.size() if hasattr(payloads, 'at'): # HACK for bug #77976 _tmp = payloads payloads = [] for ii in range(payloads_sz): payloads.append(_tmp.at(ii)) pass for ii, payload in zip(range(payloads_sz), payloads): #print >> stdout, "-->",ii,payload,type(payload),'\n' if not payload: print >> stdout, "**error** null-pointer ?" continue # names chan_names = [] sz = payload.name_size() print >> stdout, '==names== (sz: %s)' % sz for idx in xrange(sz): chan = payload.chanNum(idx) chan_name = payload.chanName(chan) #print >> stdout, '--> (%s, %s)' % (idx, chan_name) chan_names.append(chan_name) if 1: # we don't really care about those... # iovs sz = payload.iov_size() print >> stdout, '==iovs== (sz: %s)' % sz for idx in xrange(sz): chan = payload.chanNum(idx) iov_range = payload.iovRange(chan) iov_start = iov_range.start() iov_stop = iov_range.stop() if 0: print >> stdout, '(%s, %s) => (%s, %s) valid=%s runEvt=%s' % ( iov_start.run(), iov_start.event(), iov_stop.run(), iov_stop.event(), iov_start.isValid(), iov_start.isRunEvent()) # attrs attrs = [] # can't use a dict as spec.name() isn't unique sz = payload.size() print >> stdout, '==attrs== (sz: %s)' % sz for idx in xrange(sz): chan = payload.chanNum(idx) attr_list = payload.attributeList(chan) attr_data = [] for a in list(toiter(attr_list.begin(), attr_list.end())): spec = a.specification() a_type = spec.typeName() if a_type.find('string') >= 0: a_data = attr_str_data(a) # a_data = getattr(a, 'data<std::basic_string<char> >') () try: a_data = eval(a_data, {}, {}) except Exception: # swallow and keep as a string pass # print >> stdout, spec.name(),a_data else: a_data = getattr(a, 'data<%s>' % a_type)() #print >> stdout, "%s: %s %s" (spec.name(), a_data, type(a_data) ) attr_data.append((spec.name(), a_data)) attrs.append(dict(attr_data)) #print >> stdout, attrs[-1] if len(attrs) == len(chan_names): data.append(dict(zip(chan_names, attrs))) else: if len(attrs): if len(attrs) == 1: data.append(attrs[0]) else: data.append(attrs) else: data.append(chan_names) pass # loop over payloads... return data metadata = {} def maybe_get(o, idx, default=None): try: return o[idx] except IndexError: return default def maybe_float(o): try: return float(o) except ValueError: return o # FIXME - read metadata_items from MetaDataHdr metadata_items = [] for l in meta.GetListOfLeaves(): clName = l.GetTypeName().split('_p')[0] flName = l.GetName() if l.GetTypeName() == 'IOVMetaDataContainer_p1': k = l.GetName() pers = getattr(meta, k) cnv.persToTrans(pers, obj) if 0: try: obj.payloadContainer().at(0).dump() except Exception: print >> stdout, l.GetName() pass v = process_metadata(obj, k) #print >> stdout, obj.folderName(),v flName = obj.folderName() metadata[obj.folderName()] = maybe_get(v, -1) # if flName[:15] == 'TriggerMenuAux.' and clName[:6] == 'vector': continue if flName[:11] in ['TriggerMenu', 'CutBookkeep', 'IncompleteC' ] and clName[:6] != 'xAOD::': continue metadata_items.append((clName, flName)) if clName == 'EventStreamInfo': metadata_items.append(('DataHeader', ';00;MetaDataSvc')) peeked_data['metadata'] = metadata peeked_data['metadata_items'] = metadata_items # try to make unique Stream Tags set (but not for eventless files) if '/TRIGGER/HLT/Menu' in metadata and peeked_data['nentries'] > 0: ti = set() for d in metadata.get('/TRIGGER/HLT/Menu'): ti.add(d['StreamInfo']) # build stream_tags from /TRIGGER/HLT/Menu metadata stream_tags = [] for item in ti: i = item.split(',') stream_tags.append({ 'obeys_lbk': bool(i[2]), 'stream_name': i[0], 'stream_type': i[1] }) peeked_data['stream_tags'] = stream_tags # AtlasRelease - reproduce AthFile behavior from AthenaCommon.AppMgr import release_metadata rel_metadata = release_metadata() project = rel_metadata['project name'] version = rel_metadata['release'] release = project + '-' + version ## -- taginfo taginfo = {} if '/TagInfo' in metadata: taginfo = metadata['/TagInfo'].copy() # but not for eventless files if peeked_data['nentries'] > 0: taginfo['AtlasRelease'] = release peeked_data['tag_info'] = taginfo if taginfo: peeked_data['det_descr_tags'] = taginfo peeked_data['geometry'] = taginfo.get('GeoAtlas', None) peeked_data['conditions_tag'] = taginfo.get('IOVDbGlobalTag', None) peeked_data['beam_type'] = [taginfo.get('beam_type', 'N/A')] peeked_data['beam_energy'] = [ maybe_float(taginfo.get('beam_energy', 'N/A')) ] if not 'evt_type' in peeked_data: # must be eventless MC file if '/Simulation/Parameters' in metadata: peeked_data['evt_type'] = [ 'IS_SIMULATION', 'IS_ATLAS', 'IS_PHYSICS' ] peeked_data['run_number'] = [ metadata['/Simulation/Parameters'].get('RunNumber', '') ] else: peeked_data['evt_type'] = [] if not 'geometry' in peeked_data: peeked_data['geometry'] = None if not 'conditions_tag' in peeked_data: peeked_data['conditions_tag'] = None if not 'det_descr_tags' in peeked_data: peeked_data['det_descr_tags'] = {} ## -- summary print >> stdout, ':::::: summary ::::::' print >> stdout, ' - nbr events: %s' % peeked_data['nentries'] print >> stdout, ' - run numbers: %s' % peeked_data['run_number'] #print >> stdout, ' - evt numbers: %s' % peeked_data['evt_number'] print >> stdout, ' - lumiblocks: %s' % peeked_data['lumi_block'] print >> stdout, ' - evt types: ', peeked_data['evt_type'] print >> stdout, ' - item list: %s' % len( peeked_data['eventdata_items']) #print >> stdout, ' - item list: ', peeked_data['eventdata_items'] print >> stdout, ' - processing tags: %s' % peeked_data['stream_names'] #print >> stdout, ' - stream tags: %s' % peeked_data['stream_tags'] print >> stdout, ' - geometry: %s' % peeked_data['geometry'] print >> stdout, ' - conditions tag: %s' % peeked_data['conditions_tag'] #print >> stdout, ' - metadata items: %s' % len(peeked_data['metadata_items']) print >> stdout, ' - tag-info: %s' % peeked_data['tag_info'].keys() #print >> stdout, ' - item list: ' % peeked_data['eventdata_items'] stdout.flush() stdout.close() #os.remove(stdout.name) return peeked_data