Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-27 06:46:21

0001 #! /usr/bin/env python3
0002 
0003 import sys
0004 import subprocess
0005 import FWCore.ParameterSet.Config as cms
0006 
0007 config = sys.argv[1]
0008 
0009 def extractBlock(config, blocks, target):
0010   #print 'configuration: %s' % config
0011   #print 'blocks:        %s' % ', '.join(blocks)
0012   #print 'target:        %s' % target
0013   #print
0014   commands = ','.join( block + '::outputCommands' for block in blocks )
0015   proc = subprocess.Popen(
0016     "hltConfigFromDB --configName %s --noedsources --nopaths --noes --nopsets --noservices --cff --blocks %s --format python | sed -e'/^streams/,/^)/d' -e'/^datasets/,/^)/d' > %s" % (config, commands, target),
0017     shell  = True,
0018     stdin  = None,
0019     stdout = None,
0020     stderr = None,
0021   )
0022   proc.wait()
0023 
0024 def extractBlocks(config):
0025   outputA        = [ 'hltOutputA', 'hltOutputPhysicsCommissioning' ]
0026   outputALCA     = [ 'hltOutputALCAPHISYM', 'hltOutputALCAP0', 'hltOutputALCAPPS', 'hltOutputALCALumiPixelsCountsExpress', 'hltOutputALCALumiPixelsCountsPrompt', 'hltOutputRPCMON' ]
0027   outputMON      = [ 'hltOutputA', 'hltOutputPhysicsCommissioning', 'hltOutputDQM', 'hltOutputDQMGPUvsCPU', 'hltOutputHLTMonitor', 'hltOutputReleaseValidation' ]
0028   outputScouting = [ 'hltOutputScoutingPF' ]
0029   extractBlock(config, outputA,         'hltOutputA_cff.py')
0030   extractBlock(config, outputALCA,      'hltOutputALCA_cff.py')
0031   extractBlock(config, outputMON,       'hltOutputMON_cff.py')
0032   extractBlock(config, outputScouting,  'hltScouting_cff.py')
0033 
0034 def makePSet(statements):
0035   statements = sorted(statements)
0036   block = cms.PSet(
0037     outputCommands = cms.untracked.vstring( 'drop *_hlt*_*_*', )
0038   )
0039   block.outputCommands.extend( statements )
0040   return block
0041 
0042 def makePSetNoDrop(statements):
0043   statements = sorted(statements)
0044   block = cms.PSet(
0045     outputCommands = cms.untracked.vstring()
0046   )
0047   block.outputCommands.extend( statements )
0048   return block
0049 
0050 def buildPSet(blocks):
0051   statements = set()
0052   for block in blocks:
0053     statements.update( statement for statement in block if statement.find('drop') != 0 )
0054   return makePSet(statements)
0055 
0056 def buildPSetNoDrop(blocks):
0057   statements = set()
0058   for block in blocks:
0059     statements.update( statement for statement in block if statement.find('drop') != 0 )
0060   return makePSetNoDrop(statements)
0061 
0062 def buildPSetWithoutRAWs(blocks):
0063   statements = set()
0064   for block in blocks:
0065     statements.update( statement for statement in block if statement.find('drop') != 0 and statement.find('keep FEDRawDataCollection') != 0)
0066   return makePSet(statements)
0067 
0068 
0069 # customisation of AOD event content, requested by David Dagenhart
0070 def dropL1GlobalTriggerObjectMapRecord(block):
0071   """drop the old L1GlobalTriggerObjectMapRecord data format from the block (meant for the AOD data tier)"""
0072   try:
0073     # look for the hltL1GtObjectMap keep statement
0074     position = block.outputCommands.index('keep *_hltL1GtObjectMap_*_*')
0075   except ValueError:
0076     pass
0077   else:
0078     # add just after it a drop statement for the old data format
0079     block.outputCommands.insert(position  + 1, 'drop L1GlobalTriggerObjectMapRecord_hltL1GtObjectMap_*_*')
0080 
0081 
0082 # extract the HLT layer event content
0083 extractBlocks( config )
0084 import hltOutputA_cff
0085 import hltOutputALCA_cff
0086 import hltOutputMON_cff
0087 import hltScouting_cff
0088 
0089 # hltDebugOutput
0090 
0091 if not hasattr(hltOutputMON_cff,'block_hltOutputA'):
0092   hltOutputMON_cff.block_hltOutputA = hltOutputMON_cff.block_hltOutputPhysicsCommissioning
0093 if not hasattr(hltOutputMON_cff,'block_hltOutputDQM'):
0094   hltOutputMON_cff.block_hltOutputDQM = cms.PSet(outputCommands = cms.untracked.vstring( 'drop *' ))
0095 if not hasattr(hltOutputMON_cff,'block_hltOutputDQMGPUvsCPU'):
0096   hltOutputMON_cff.block_hltOutputDQMGPUvsCPU = cms.PSet(outputCommands = cms.untracked.vstring( 'drop *' ))
0097 if not hasattr(hltOutputMON_cff,'block_hltOutputHLTMonitor'):
0098   hltOutputMON_cff.block_hltOutputHLTMonitor = cms.PSet(outputCommands = cms.untracked.vstring( 'drop *_hlt*_*_*' ))
0099 if not hasattr(hltOutputMON_cff,'block_hltOutputReleaseValidation'):
0100   hltOutputMON_cff.block_hltOutputReleaseValidation = cms.PSet(outputCommands = cms.untracked.vstring( 'drop *' ))
0101 
0102 hltDebugOutputBlocks = (
0103   # the DQM, DQMGPUvsCPU and HLTMON streams have the HLT debug outputs used online
0104   hltOutputMON_cff.block_hltOutputA.outputCommands,
0105   hltOutputMON_cff.block_hltOutputDQM.outputCommands,
0106   hltOutputMON_cff.block_hltOutputDQMGPUvsCPU.outputCommands,
0107   hltOutputMON_cff.block_hltOutputHLTMonitor.outputCommands,
0108   hltOutputMON_cff.block_hltOutputReleaseValidation.outputCommands,
0109 )
0110 hltDebugOutputContent = buildPSet(hltDebugOutputBlocks)
0111 
0112 
0113 # hltDebugWithAlCaOutput
0114 if not hasattr(hltOutputALCA_cff,'block_hltOutputALCAPHISYM'):
0115   hltOutputALCA_cff.block_hltOutputALCAPHISYM = cms.PSet(outputCommands = cms.untracked.vstring( 'drop *' ))
0116 if not hasattr(hltOutputALCA_cff,'block_hltOutputALCAP0'):
0117   hltOutputALCA_cff.block_hltOutputALCAP0 = cms.PSet(outputCommands = cms.untracked.vstring( 'drop *' ))
0118 if not hasattr(hltOutputALCA_cff,'block_hltOutputALCAPPS'):
0119   hltOutputALCA_cff.block_hltOutputALCAPPS = cms.PSet(outputCommands = cms.untracked.vstring( 'drop *' ))
0120 if not hasattr(hltOutputALCA_cff,'block_hltOutputALCALumiPixelsCountsExpress'):
0121   hltOutputALCA_cff.block_hltOutputALCALumiPixelsCountsExpress = cms.PSet(outputCommands = cms.untracked.vstring( 'drop *' ))
0122 if not hasattr(hltOutputALCA_cff,'block_hltOutputALCALumiPixelsCountsPrompt'):
0123   hltOutputALCA_cff.block_hltOutputALCALumiPixelsCountsPrompt = cms.PSet(outputCommands = cms.untracked.vstring( 'drop *' ))
0124 if not hasattr(hltOutputALCA_cff,'block_hltOutputRPCMON'):
0125   hltOutputALCA_cff.block_hltOutputRPCMON = cms.PSet(outputCommands = cms.untracked.vstring( 'drop *' ))
0126 hltDebugWithAlCaOutputBlocks = (
0127   # the DQM, DQMGPUvsCPU and HLTMON streams have the HLT debug outputs used online
0128   hltOutputMON_cff.block_hltOutputA.outputCommands,
0129   hltOutputMON_cff.block_hltOutputDQM.outputCommands,
0130   hltOutputMON_cff.block_hltOutputDQMGPUvsCPU.outputCommands,
0131   hltOutputMON_cff.block_hltOutputHLTMonitor.outputCommands,
0132   hltOutputMON_cff.block_hltOutputReleaseValidation.outputCommands,
0133   # the ALCA streams have the AlCa outputs
0134   hltOutputALCA_cff.block_hltOutputALCAPHISYM.outputCommands,
0135   hltOutputALCA_cff.block_hltOutputALCAP0.outputCommands,
0136   hltOutputALCA_cff.block_hltOutputALCAPPS.outputCommands,
0137   hltOutputALCA_cff.block_hltOutputALCALumiPixelsCountsExpress.outputCommands,
0138   hltOutputALCA_cff.block_hltOutputALCALumiPixelsCountsPrompt.outputCommands,
0139   hltOutputALCA_cff.block_hltOutputRPCMON.outputCommands,
0140 )
0141 hltDebugWithAlCaOutputContent = buildPSet(hltDebugWithAlCaOutputBlocks)
0142 
0143 # hltScoutingOutput
0144 
0145 if not hasattr(hltScouting_cff,'block_hltOutputScoutingPF'):
0146   hltScouting_cff.block_hltOutputScoutingPF = cms.PSet(outputCommands = cms.untracked.vstring( 'drop *' ))
0147 
0148 hltScoutingOutputBlocks = (
0149   # the Scouting streams have the Scouting outputs
0150   hltScouting_cff.block_hltOutputScoutingPF.outputCommands,
0151 )
0152 hltScoutingOutputContent = buildPSetNoDrop(hltScoutingOutputBlocks)
0153 
0154 
0155 # hltDefaultOutput
0156 if not hasattr(hltOutputA_cff,'block_hltOutputA'):
0157   hltOutputA_cff.block_hltOutputA = hltOutputA_cff.block_hltOutputPhysicsCommissioning
0158 hltDefaultOutputBlocks = (
0159   # the A stream has the HLT default output, with FEDs - strip out the FEDRawDataCollection keep statements for hltDefaultOutput
0160   hltOutputA_cff.block_hltOutputA.outputCommands,
0161 )
0162 hltDefaultOutputContent         = buildPSetWithoutRAWs(hltDefaultOutputBlocks)
0163 hltDefaultOutputWithFEDsContent = buildPSet(hltDefaultOutputBlocks)
0164 
0165 
0166 # define the CMSSW default event content configurations
0167 
0168 # RAW event content
0169 HLTriggerRAW = cms.PSet(
0170     outputCommands = cms.vstring()
0171 )
0172 HLTriggerRAW.outputCommands.extend(hltDefaultOutputWithFEDsContent.outputCommands)
0173 HLTriggerRAW.outputCommands.extend(hltScoutingOutputContent.outputCommands)
0174 
0175 # RECO event content
0176 HLTriggerRECO = cms.PSet(
0177     outputCommands = cms.vstring()
0178 )
0179 HLTriggerRECO.outputCommands.extend(hltDefaultOutputContent.outputCommands)
0180 HLTriggerRECO.outputCommands.extend(hltScoutingOutputContent.outputCommands)
0181 
0182 # AOD event content
0183 HLTriggerAOD = cms.PSet(
0184     outputCommands = cms.vstring()
0185 )
0186 HLTriggerAOD.outputCommands.extend(hltDefaultOutputContent.outputCommands)
0187 HLTriggerAOD.outputCommands.extend(hltScoutingOutputContent.outputCommands)
0188 dropL1GlobalTriggerObjectMapRecord(HLTriggerAOD)
0189 
0190 # HLTDEBUG RAW event content
0191 HLTDebugRAW = cms.PSet(
0192     outputCommands = cms.vstring()
0193 )
0194 HLTDebugRAW.outputCommands.extend(hltDebugWithAlCaOutputContent.outputCommands)
0195 HLTDebugRAW.outputCommands.extend(hltScoutingOutputContent.outputCommands)
0196 
0197 # HLTDEBUG FEVT event content
0198 HLTDebugFEVT = cms.PSet(
0199     outputCommands = cms.vstring()
0200 )
0201 HLTDebugFEVT.outputCommands.extend(hltDebugWithAlCaOutputContent.outputCommands)
0202 HLTDebugFEVT.outputCommands.extend(hltScoutingOutputContent.outputCommands)
0203 
0204 # Scouting event content
0205 HLTScouting = cms.PSet(
0206     outputCommands = cms.vstring()
0207 )
0208 HLTScouting.outputCommands.extend(hltScoutingOutputContent.outputCommands)
0209 
0210 # dump the expanded event content configurations to a python configuration fragment
0211 dump = open('HLTrigger_EventContent_cff.py', 'w')
0212 dump.write('''import FWCore.ParameterSet.Config as cms
0213 
0214 # EventContent for HLT related products.
0215 
0216 # This file exports the following EventContent blocks:
0217 #   HLTriggerRAW  HLTriggerRECO  HLTriggerAOD (without DEBUG products)
0218 #   HLTDebugRAW   HLTDebugFEVT                (with    DEBUG products)
0219 #   HLTScouting                               (with Scouting products)
0220 #
0221 # as these are used in Configuration/EventContent
0222 #
0223 ''')
0224 dump.write('HLTriggerRAW  = cms.PSet(\n    outputCommands = cms.vstring( *(\n%s\n    ) )\n)\n\n'  % ',\n'.join( '        \'%s\'' % keep for keep in HLTriggerRAW.outputCommands))
0225 dump.write('HLTriggerRECO = cms.PSet(\n    outputCommands = cms.vstring( *(\n%s\n    ) )\n)\n\n'  % ',\n'.join( '        \'%s\'' % keep for keep in HLTriggerRECO.outputCommands))
0226 dump.write('HLTriggerAOD  = cms.PSet(\n    outputCommands = cms.vstring( *(\n%s\n    ) )\n)\n\n'  % ',\n'.join( '        \'%s\'' % keep for keep in HLTriggerAOD.outputCommands))
0227 dump.write('HLTDebugRAW   = cms.PSet(\n    outputCommands = cms.vstring( *(\n%s\n    ) )\n)\n\n'  % ',\n'.join( '        \'%s\'' % keep for keep in HLTDebugRAW.outputCommands))
0228 dump.write('HLTDebugFEVT  = cms.PSet(\n    outputCommands = cms.vstring( *(\n%s\n    ) )\n)\n\n'  % ',\n'.join( '        \'%s\'' % keep for keep in HLTDebugFEVT.outputCommands))
0229 dump.write('HLTScouting   = cms.PSet(\n    outputCommands = cms.vstring( *(\n%s\n    ) )\n)\n\n'  % ',\n'.join( '        \'%s\'' % keep for keep in HLTScouting.outputCommands))
0230 dump.close()