Commit a8fe55e4 authored by Dan Andrei Ciubotaru's avatar Dan Andrei Ciubotaru Committed by Adam Edward Barton
Browse files

Replaced the InputFilePeeker with MetaReader in Trigger

parent 37e78cd5
......@@ -153,19 +153,19 @@ topSequence = AlgSequence()
##################################### GRL Tools ##########################################
# Good Run List (GRL)
if doGRL:
from RecExConfig.InputFilePeeker import inputFileSummary
try:
if inputFileSummary['evt_type'][0] == "IS_DATA":
from GoodRunsLists.GoodRunsListsConf import *
ToolSvc += GoodRunsListSelectorTool()
GoodRunsListSelectorTool.GoodRunsListVec = grllist
from GoodRunsListsUser.GoodRunsListsUserConf import *
seq = AthSequencer("AthFilterSeq")
seq += GRLTriggerSelectorAlg('GRLTriggerAlg1')
#seq.GRLTriggerAlg1.GoodRunsListArray = ['PHYS_StandardGRL_All_Good_25ns']
seq.GRLTriggerAlg1.GoodRunsListArray = [grllist[0].replace('.xml','')]
except:
print "GRL not available!"
from PyUtils.MetaReaderPeeker import metadata
try:
if metadata['eventTypes'][0] == 'IS_DATA':
from GoodRunsLists.GoodRunsListsConf import *
ToolSvc += GoodRunsListSelectorTool()
GoodRunsListSelectorTool.GoodRunsListVec = grllist
from GoodRunsListsUser.GoodRunsListsUserConf import *
seq = AthSequencer("AthFilterSeq")
seq += GRLTriggerSelectorAlg('GRLTriggerAlg1')
#seq.GRLTriggerAlg1.GoodRunsListArray = ['PHYS_StandardGRL_All_Good_25ns']
seq.GRLTriggerAlg1.GoodRunsListArray = [grllist[0].replace('.xml','')]
except:
print("GRL not available!")
##################################### Mon Tools ##########################################
......
......@@ -121,9 +121,9 @@ topSequence = AlgSequence()
##################################### GRL Tools ##########################################
# Good Run List (GRL)
from RecExConfig.InputFilePeeker import inputFileSummary
if inputFileSummary['evt_type'][0] == "IS_DATA":
print 'IS_DATA! doGRL'
from PyUtils.MetaReaderPeeker import metadata
if metadata['eventTypes'][0] == "IS_DATA":
print('IS_DATA! doGRL')
from GoodRunsLists.GoodRunsListsConf import *
ToolSvc += GoodRunsListSelectorTool()
GoodRunsListSelectorTool.GoodRunsListVec = grllist
......
from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
from AthenaServices.Configurables import ThinningSvc, createThinningSvc
from RecExConfig.InputFilePeeker import inputFileSummary
inputObjects = inputFileSummary['eventdata_items']
from PyUtils.MetaReaderPeeker import convert_itemList
inputObjects = convert_itemList(layout=None)
def __addInput( stream, skip=[] ):
for element in inputObjects:
type_key = "%s#%s" % element
......
......@@ -48,9 +48,9 @@ if HLTMonFlags.doMaM == True:
# if HLTMonFlags.MCK is -1 (the default) we try to determine the MCK automatically, as long as this is not MC
isNotSIM = True
from RecExConfig.InputFilePeeker import inputFileSummary
if inputFileSummary.__contains__('evt_type'):
if 'IS_SIMULATION' in inputFileSummary['evt_type']:
from PyUtils.MetaReaderPeeker import metadata
if 'eventTypes' in metadata:
if 'IS_SIMULATION' in metadata['eventTypes']:
log.info("Will not try to get MCK automatically as we are running on MC")
isNotSIM = False
......@@ -90,14 +90,9 @@ if HLTMonFlags.doMaM == True:
else:
# try to get the MCK from COOL
if inputFileSummary.__contains__('bs_metadata') or inputFileSummary.__contains__('run_number'):
# get the run number
if inputFileSummary.__contains__('bs_metadata'):
run_number = inputFileSummary['bs_metadata']['run_number']
else:
run_number = int(inputFileSummary['run_number'][0])
pointintime = (int(run_number)<<32)
if 'runNumbers' in metadata:
run_number = metadata['runNumbers'][0]
pointintime = (int(run_number) << 32)
# try to connect to the COOL database
from PyCool import cool
......
......@@ -98,8 +98,8 @@ cfgRecExPers=CfgKeyStore("recexpers")
if globalflags.InputFormat.is_pool():
logRecExCommon_topOptions.info("Pool file : storing in objKeyStore the list of input object directly from file")
try:
from RecExConfig.InputFilePeeker import inputFileSummary
objKeyStore.addManyTypesInputFile(inputFileSummary['eventdata_itemsList'])
from PyUtils.MetaReaderPeeker import convert_itemList
objKeyStore.addManyTypesInputFile(convert_itemList(layout='#join'))
except:
logRecExCommon_topOptions.error("no input file defined in flags. If using RTT please use tag <athenaCommonFlags/>. Now continuing at own riske")
......
......@@ -149,7 +149,7 @@ muonCnvFlags.TgcCablingMode.set_Value_and_Lock( "12-fold" )
from TrigT1RPCRecRoiSvc.TrigT1RPCRecRoiConfig import RPCRecRoiConfig
from TrigT1TGCRecRoiSvc.TrigT1TGCRecRoiConfig import TGCRecRoiConfig
from RecExConfig.InputFilePeeker import inputFileSummary as ifs
from PyUtils.MetaReaderPeeker import metadata
from TrigT1CTMonitoring.TrigT1CTMonitoringConfig import *
#below to read from cool
......@@ -184,8 +184,8 @@ if testLabFile:
LVL1ConfigSvc.DBBGSKey=11
elif RunSimOnData:
run = ifs['run_number'][0]
lb= ifs['lumi_block'][0]
run = metadata['runNumbers'][0]
lb = metadata['lumiBlockNumbers'][0]
keys = _getKeys(run,lb)
from TriggerJobOpts.TriggerFlags import TriggerFlags as tf
tf.triggerConfig="DATARECO:DB:TRIGGERDB:%i,%i,%i" % keys
......@@ -212,8 +212,8 @@ elif RunSimOnData:
topSequence += CTPSimulationOnData("CTPSimulation")
elif checkDQ:
run = ifs['run_number'][0]
lb= ifs['lumi_block'][0]
run = metadata['runNumbers'][0]
lb = metadata['lumiBlockNumbers'][0]
keys = _getKeys(run,lb)
from TriggerJobOpts.TriggerFlags import TriggerFlags as tf
tf.triggerConfig="DATARECO:DB:TRIGGERDB:%i,%i,%i" % keys
......
......@@ -179,17 +179,18 @@ if not isOnline:
cfg = TriggerConfigGetter()
## add pre algorithms for rerunning CTP simulation
if not 'IS_SIMULATION' in inputFileSummary['evt_type']:
from PyUtils.MetaReaderPeeker import metadata
if 'IS_SIMULATION' not in metadata['eventTypes']:
#svcMgr.DSConfigSvc.readLVL1Thr=True
#svcMgr.DSConfigSvc.readLVL1BG=True
from TrigT1Muctpi.TrigT1MuctpiConfig import L1Muctpi_on_Data
topSequence += L1Muctpi_on_Data()
from TrigT1CTMonitoring.TrigT1CTMonitoringConf import TrigT1CTMonitoring__DeriveSimulationInputs as DeriveSimulationInputs
topSequence += DeriveSimulationInputs(do_MuCTPI_input=True,
do_L1Calo_sim=False)
from TrigT1CTP.TrigT1CTPConfig import CTPSimulationOnData
topSequence += CTPSimulationOnData("CTPSimulation")
......@@ -216,11 +217,11 @@ if not isOnline:
theApp.Dlls += [ "TrigT1CTMonitoring" ]
# check if global muons are on
from PyUtils.MetaReaderPeeker import metadata
# check if global muons are on
if not rec.doMuon:
if not 'IS_SIMULATION' in inputFileSummary['evt_type']:
if 'IS_SIMULATION' not in metadata['eventTypes']:
CTBSMonTool = BSMon( ProcessCTPData = True,
ProcessRoIBResult = False,
InclusiveTriggerThresholds = False,
......@@ -228,8 +229,7 @@ if not isOnline:
ProcessMuctpiDataRIO = False,
CompareRerun = True,
FillStateCoolFolderName=UsedFillStateCoolFolderName)
if 'IS_SIMULATION' in inputFileSummary['evt_type']:
else:
CTBSMonTool = BSMon( ProcessCTPData = True,
ProcessRoIBResult = False,
InclusiveTriggerThresholds = False,
......@@ -238,16 +238,14 @@ if not isOnline:
RunOnESD = True,
CompareRerun = False,
FillStateCoolFolderName=UsedFillStateCoolFolderName)
if rec.doMuon:
if not 'IS_SIMULATION' in inputFileSummary['evt_type']:
else:
if 'IS_SIMULATION' not in metadata['eventTypes']:
CTBSMonTool = BSMon( ProcessCTPData = True,
ProcessRoIBResult = True,
ProcessMuctpiData = True,
ProcessMuctpiDataRIO = True,
CompareRerun = True)
if 'IS_SIMULATION' in inputFileSummary['evt_type']:
else:
CTBSMonTool = BSMon( ProcessCTPData = True,
ProcessRoIBResult = True,
ProcessMuctpiData = True,
......@@ -261,8 +259,8 @@ if not isOnline:
processByteStream = True
from RecExConfig.InputFilePeeker import inputFileSummary
if not 'IS_SIMULATION' in inputFileSummary['evt_type']:
if 'IS_SIMULATION' not in metadata['eventTypes']:
from IOVDbSvc.CondDB import conddb
conddb.addFolder('TRIGGER', '/TRIGGER/LUMI/LBLB')
#conddb.addFolder('TRIGGER', "/TRIGGER/LVL1/BunchGroupContent") # already added by some other alg
......
......@@ -354,9 +354,10 @@ useNoiseCuts2012: use 2012 values of noise cuts (only available for matched filt
else:
pedestalProvider = ToolSvc.L1DynamicPedestalProviderRoot
else:
if not 'inputFileSummary' in dir():
if not 'MetaReaderPeeker' in dir():
try:
from RecExConfig.InputFilePeeker import inputFileSummary
from PyUtils.MetaReaderPeekerFull import metadata
except ImportError:
log.warning('configureTriggerTowerMaker could not retrieve input file summary. Will not configure dynamic pedestal correction from text.')
return
......@@ -366,7 +367,7 @@ useNoiseCuts2012: use 2012 values of noise cuts (only available for matched filt
pedestalProvider = LVL1__L1DynamicPedestalProviderTxt('L1DynamicPedestalProviderTxt',
InputFileEM=inputFileTxtEM,
InputFileHAD=inputFileTxtHAD)
pedestalProvider.BeamIntensityPattern=inputFileSummary['metadata']['/Digitization/Parameters']['BeamIntensityPattern']
pedestalProvider.BeamIntensityPattern = metadata['/Digitization/Parameters']['BeamIntensityPattern']
ToolSvc += pedestalProvider
else:
pedestalProvider = ToolSvc.L1DynamicPedestalProviderTxt
......
......@@ -29,12 +29,9 @@ addInputRename ( 'xAOD::TriggerTowerContainer', 'xAODTriggerTowers_rerun', 'xAOD
_bunchSpacing = None
_doPC = True # do pedestal correction?
_alg = {25 : Run2TriggerTowerMaker25ns, 50 : Run2TriggerTowerMaker50ns}
if not 'inputFileSummary' in dir():
try:
from RecExConfig.InputFilePeeker import inputFileSummary
except ImportError:
pass
from PyUtils.MetaReaderPeeker import metadata
from AthenaCommon.GlobalFlags import globalflags
if globalflags.isOverlay() is True:
_doPC = False
......@@ -49,17 +46,16 @@ if globalflags.isOverlay() is True:
DoOverlay = True )
else:
try:
if not 'inputFileSummary' in dir():
if not 'metadata' in dir():
raise RuntimeError('Input file summary not available.')
# try:
# digiParam = metadata['/Digitization/Parameters']
# except KeyError:
# raise RuntimeError('Collection /Digitization/Parameters not found in file {}.'.format(metadata['file_name']))
try:
digiParam = inputFileSummary['metadata']['/Digitization/Parameters']
except KeyError:
raise RuntimeError('Collection /Digitization/Parameters not found in file metadata.')
if 'intraTrainBunchSpacing' not in digiParam or not digiParam['intraTrainBunchSpacing']:
if 'intraTrainBunchSpacing' not in metadata or not metadata['intraTrainBunchSpacing']:
raise RuntimeError('No key "intraTrainBunchSpacing" in /Digitization/Parameters.')
_bunchSpacing = digiParam['intraTrainBunchSpacing']
_bunchSpacing = int(metadata['intraTrainBunchSpacing'])
except RuntimeError, re:
log.warning('Could not determine bunch-spacing from input file: %s' % re)
log.warning('Configuring for 25ns w/o pedestal correction - a wrong configuration might yield non sensible results!')
......
......@@ -56,7 +56,8 @@ if job.TriggerTowerMaker.BaselineCorrection:
pedestalProvider = LVL1__L1DynamicPedestalProviderTxt('L1DynamicPedestalProviderTxt',
InputFileEM='DynamicPedestalCorrectionEM.txt',
InputFileHAD='DynamicPedestalCorrectionHAD.txt')
pedestalProvider.BeamIntensityPattern=inputFileSummary['metadata']['/Digitization/Parameters']['BeamIntensityPattern']
from PyUtils.MetaReaderPeeker import metadata
pedestalProvider.BeamIntensityPattern = metadata['BeamIntensityPattern']
ToolSvc += pedestalProvider
ToolSvc.L1TriggerTowerTool.L1DynamicPedestalProvider=pedestalProvider
......
......@@ -56,7 +56,8 @@ if job.TriggerTowerMaker.BaselineCorrection:
pedestalProvider = LVL1__L1DynamicPedestalProviderTxt('L1DynamicPedestalProviderTxt',
InputFileEM='DynamicPedestalCorrectionEM.txt',
InputFileHAD='DynamicPedestalCorrectionHAD.txt')
pedestalProvider.BeamIntensityPattern=inputFileSummary['metadata']['/Digitization/Parameters']['BeamIntensityPattern']
from PyUtils.MetaReaderPeeker import metadata
pedestalProvider.BeamIntensityPattern = metadata['BeamIntensityPattern']
ToolSvc += pedestalProvider
ToolSvc.L1TriggerTowerTool.L1DynamicPedestalProvider=pedestalProvider
......
......@@ -58,7 +58,8 @@ if job.TriggerTowerMaker.BaselineCorrection:
pedestalProvider = LVL1__L1DynamicPedestalProviderTxt('L1DynamicPedestalProviderTxt',
InputFileEM='DynamicPedestalCorrectionEM.txt',
InputFileHAD='DynamicPedestalCorrectionHAD.txt')
pedestalProvider.BeamIntensityPattern=inputFileSummary['metadata']['/Digitization/Parameters']['BeamIntensityPattern']
from PyUtils.MetaReaderPeeker import metadata
pedestalProvider.BeamIntensityPattern = metadata['BeamIntensityPattern']
ToolSvc += pedestalProvider
else:
pedestalProvider = ToolSvc.L1DynamicPedestalProviderTxt
......
......@@ -55,7 +55,8 @@ if job.TriggerTowerMaker.BaselineCorrection:
pedestalProvider = LVL1__L1DynamicPedestalProviderTxt('L1DynamicPedestalProviderTxt',
InputFileEM='DynamicPedestalCorrectionEM.txt',
InputFileHAD='DynamicPedestalCorrectionHAD.txt')
pedestalProvider.BeamIntensityPattern=inputFileSummary['metadata']['/Digitization/Parameters']['BeamIntensityPattern']
from PyUtils.MetaReaderPeeker import metadata
pedestalProvider.BeamIntensityPattern = metadata['BeamIntensityPattern']
ToolSvc += pedestalProvider
ToolSvc.L1TriggerTowerTool.L1DynamicPedestalProvider=pedestalProvider
......
......@@ -6,9 +6,9 @@ mlog = logging.getLogger( 'TriggerConfigCheckHLTpsk' ) ## get the logger
runNumbers=[]
from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
if len(athenaCommonFlags.BSRDOInput()) > 0 :
from RecExConfig.InputFilePeeker import inputFileSummary
if inputFileSummary.has_key('run_number'): # online monitoring does not provide a run_number in the inputFileSummary (hence the rest of this program will be skipped)
runNumbers=inputFileSummary['run_number']
from PyUtils.MetaReaderPeeker import metadata
if 'runNumbers' in metadata: # online monitoring does not provide a run_number in the file metadata (hence the rest of this program will be skipped)
runNumbers = metadata['runNumbers']
if len(runNumbers)>0:
......
......@@ -8,15 +8,14 @@ from TriggerJobOpts.TriggerFlags import TriggerFlags
log = logging.getLogger( "TriggerConfigCheckMetadata.py" )
if len(athenaCommonFlags.PoolESDInput())>0 or len(athenaCommonFlags.PoolAODInput())>0 :
from RecExConfig.InputFilePeeker import inputFileSummary
from PyUtils.MetaReaderPeekerFull import metadata
if not 'DQMonFlags' in dir():
print "DataQualityMon_RecExCommon_Flags_jobOptions.py: DQMonFlags not yet imported - I import them now"
from AthenaMonitoring.DQMonFlags import DQMonFlags
if inputFileSummary.has_key('metadata'):
hasLVL1 = inputFileSummary['metadata'].has_key('/TRIGGER/LVL1/Lvl1ConfigKey')
hasHLT = inputFileSummary['metadata'].has_key('/TRIGGER/HLT/HltConfigKeys')
if len(metadata) > 0:
hasLVL1 = True if '/TRIGGER/LVL1/Lvl1ConfigKey' in metadata else False
hasHLT = True if '/TRIGGER/HLT/HltConfigKeys' in metadata else False
if globalflags.DataSource()=='data':
if hasLVL1 and not hasHLT:
......@@ -76,6 +75,6 @@ if len(athenaCommonFlags.PoolESDInput())>0 or len(athenaCommonFlags.PoolAODInput
rec.doTrigger.set_Value_and_Lock(False)
else:
log.warning("Either inputFileSummary does not have key 'metadata' or something strange is happening.")
log.warning("Either file(s) does not have key 'metadata' or something strange is happening.")
else:
log.warning("Wrong flags setting for pool input, try calling TriggerConfigGetter with 'ReadPool' or 'WritePool' as argument.")
......@@ -20,9 +20,6 @@ def EDMDecodingVersion():
# change version only if not rerunning the trigger
TriggerFlags.EDMDecodingVersion = 2
# run the AutoConfiguration
from RecExConfig.InputFilePeeker import inputFileSummary # noqa: F401
if globalflags.InputFormat.is_bytestream():
# BYTESTREAM: decide Run1/Run2 based on Run number
from RecExConfig.AutoConfiguration import GetRunNumber
......@@ -176,15 +173,17 @@ class ByteStreamUnpackGetter(Configured):
#
# Configure DataScouting
#
from RecExConfig.InputFilePeeker import inputFileSummary
if inputFileSummary['bs_metadata']['Stream'].startswith('calibration_DataScouting_') or TriggerFlags.doAlwaysUnpackDSResult():
for stag in inputFileSummary['stream_tags']:
if (stag['stream_type'] == 'calibration') and (stag['stream_name'].startswith('DataScouting_')):
ds_tag = stag['stream_name'][0:15]
ServiceMgr.ByteStreamAddressProviderSvc.TypeNames += [ "HLT::HLTResult/"+ds_tag ]
extr.DSResultKeys += [ ds_tag ]
else:
from PyUtils.MetaReaderPeeker import metadata
stream_local = metadata['stream']
if stream_local.startswith('calibration_DataScouting_') or TriggerFlags.doAlwaysUnpackDSResult():
if 'calibration' in stream_local and 'DataScouting_' in stream_local:
ds_tag = stream_local[12:27]
ServiceMgr.ByteStreamAddressProviderSvc.TypeNames += [ "HLT::HLTResult/"+ds_tag ]
extr.DSResultKeys += [ ds_tag ]
else:
#if data doesn't have HLT info set HLTResult keys as empty strings to avoid warnings
# but the extr alg must run
extr.L2ResultKey=""
......@@ -278,16 +277,16 @@ class HLTTriggerResultGetter(Configured):
log = logging.getLogger("HLTTriggerResultGetter.py")
if rec.doESD():
from RecExConfig.InputFilePeeker import inputFileSummary
if 'bs_metadata' in inputFileSummary and 'Stream' in inputFileSummary['bs_metadata']:
stream=inputFileSummary['bs_metadata']['Stream']
log.debug("the stream found in 'bs_metadata' is "+stream)
from PyUtils.MetaReaderPeeker import metadata
if 'stream' in metadata:
stream = metadata['stream']
log.debug("the stream found in 'metadata' is "+stream)
if "express" in stream:
from TrigEDMConfig.TriggerEDM import getTypeAndKey,EDMDetails
type,key=getTypeAndKey("TrigOperationalInfo#HLT_EXPRESS_OPI_HLT")
if 'collection'in EDMDetails[type]:
colltype = EDMDetails[type]['collection']
log.info("Adding HLT_EXPRESS_OPI_HLT to ESD for stream "+stream)
log.info("Adding HLT_EXPRESS_OPI_HLT to ESD for stream "+stream)
from RecExConfig.ObjKeyStore import objKeyStore
objKeyStore.addStreamESD(colltype, key)
return True
......@@ -441,11 +440,11 @@ class HLTTriggerResultGetter(Configured):
svcMgr += ThinningSvc(name='ESDThinningSvc', Streams=['StreamESD']) # the default is configured for AODs
_addSlimming('StreamESD', svcMgr.ESDThinningSvc, _TriggerESDList )
log.info("configured navigation slimming for ESD output")
objKeyStore.addManyTypesStreamESD( _TriggerESDList )
objKeyStore.addManyTypesStreamESD( _TriggerESDList )
objKeyStore.addManyTypesStreamAOD( _TriggerAODList )
return True
......
......@@ -39,11 +39,8 @@ def LVL1MonitoringTools():
def keyInInputFile(sgKey):
"""check, if the given StoreGate key is in the current input file
"""
from RecExConfig.InputFilePeeker import inputFileSummary
return sgKey in inputFileSummary['eventdata_itemsDic']
from PyUtils.MetaReaderPeeker import convert_itemList
return sgKey in convert_itemList(layout='dict')
class Lvl1SimulationGetter (Configured):
......
......@@ -40,12 +40,14 @@ class TriggerConfigGetter(Configured):
def checkFileMetaData(self):
log = logging.getLogger( "TriggerConfigGetter.py" )
from RecExConfig.InputFilePeeker import inputFileSummary
from PyUtils.MetaReaderPeekerFull import metadata
self.hasLBwiseHLTPrescalesAndL1ItemDef = True
if rec.readESD() or rec.readAOD() or "ReadPool" in self._environment:
self.hasLBwiseHLTPrescalesAndL1ItemDef = '/TRIGGER/HLT/Prescales' in inputFileSummary['metadata'] # they were all added at the same time (Repro with 15.6.3.2 Prod)
self.hasLBwiseHLTPrescalesAndL1ItemDef = '/TRIGGER/HLT/Prescales' in metadata # they were all added at the same time (Repro with 15.6.3.2 Prod)
# protection against early runs
if 'run_number' in inputFileSummary and self._environment=="" and globalflags.DataSource()=='data' and rec.readRDO() and any([run<134230 for run in inputFileSummary['run_number']]):
if 'runNumbers' in metadata and self._environment == "" and globalflags.DataSource() == 'data' and rec.readRDO() and any([run < 134230 for run in metadata['runNumbers']]):
self.hasLBwiseHLTPrescalesAndL1ItemDef = False
if self.hasLBwiseHLTPrescalesAndL1ItemDef:
log.info("Using LB-wise HLT prescales")
......@@ -53,9 +55,7 @@ class TriggerConfigGetter(Configured):
log.info("Using run-wise HLT prescales")
def checkInput(self):
self.checkFileMetaData()
log = logging.getLogger( "TriggerConfigGetter.py" )
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment