Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:27

0001 from __future__ import print_function
0002 # customization fragments to be used with cmsDriver and hltGetConfiguration
0003 #
0004 # V.M. Ghete 2010-06-09 initial version
0005 
0006 import FWCore.ParameterSet.Config as cms
0007 
0008 def customiseUnprescaleAlgoTriggers(process):
0009 
0010     # temporary solution FIXME
0011 
0012     process.load("L1TriggerConfig.L1GtConfigProducers.L1GtPrescaleFactorsAlgoTrigConfig_cff")
0013     process.es_prefer_l1GtPrescaleFactorsAlgoTrig = cms.ESPrefer(
0014         "L1GtPrescaleFactorsAlgoTrigTrivialProducer", "l1GtPrescaleFactorsAlgoTrig")
0015 
0016 
0017     return (process)
0018 
0019 ##############################################################################
0020 
0021 def customiseUnprescaleTechTriggers(process):
0022 
0023     # temporary solution FIXME
0024 
0025     process.load("L1TriggerConfig.L1GtConfigProducers.L1GtPrescaleFactorsTechTrigConfig_cff")
0026     process.es_prefer_l1GtPrescaleFactorsTechTrig = cms.ESPrefer(
0027         "L1GtPrescaleFactorsTechTrigTrivialProducer", "l1GtPrescaleFactorsTechTrig")
0028 
0029     return (process)
0030 
0031 ##############################################################################
0032 
0033 def customiseResetMasksAlgoTriggers(process):
0034 
0035     process.load("L1TriggerConfig.L1GtConfigProducers.L1GtTriggerMaskAlgoTrigConfig_cff")
0036     process.es_prefer_l1GtTriggerMaskAlgoTrig = cms.ESPrefer(
0037         "L1GtTriggerMaskAlgoTrigTrivialProducer", "l1GtTriggerMaskAlgoTrig")
0038 
0039     return (process)
0040 
0041 ##############################################################################
0042 
0043 def customiseResetMasksTechTriggers(process):
0044 
0045     process.load("L1TriggerConfig.L1GtConfigProducers.L1GtTriggerMaskTechTrigConfig_cff")
0046     process.es_prefer_l1GtTriggerMaskTechTrig = cms.ESPrefer(
0047         "L1GtTriggerMaskTechTrigTrivialProducer", "l1GtTriggerMaskTechTrig")
0048 
0049     return (process)
0050 
0051 ##############################################################################
0052 
0053 def customiseResetVetoMasksAlgoTriggers(process):
0054 
0055     process.load("L1TriggerConfig.L1GtConfigProducers.L1GtTriggerMaskVetoAlgoTrigConfig_cff")
0056     process.es_prefer_l1GtTriggerMaskVetoAlgoTrig = cms.ESPrefer(
0057         "L1GtTriggerMaskVetoAlgoTrigTrivialProducer", "l1GtTriggerMaskVetoAlgoTrig")
0058 
0059     return (process)
0060 
0061 ##############################################################################
0062 
0063 def customiseResetVetoMasksTechTriggers(process):
0064 
0065     process.load("L1TriggerConfig.L1GtConfigProducers.L1GtTriggerMaskVetoTechTrigConfig_cff")
0066     process.es_prefer_l1GtTriggerMaskVetoTechTrig = cms.ESPrefer(
0067         "L1GtTriggerMaskVetoTechTrigTrivialProducer", "l1GtTriggerMaskVetoTechTrig")
0068 
0069     return (process)
0070 
0071 ##############################################################################
0072 
0073 def customiseResetPrescalesAndMasks(process):
0074     process = customiseUnprescaleAlgoTriggers( process )
0075     process = customiseUnprescaleTechTriggers( process )
0076     process = customiseResetMasksAlgoTriggers( process )
0077     process = customiseResetMasksTechTriggers( process )
0078     process = customiseResetVetoMasksAlgoTriggers( process )
0079     process = customiseResetVetoMasksTechTriggers( process )
0080 
0081     return (process)
0082 
0083 ##############################################################################
0084 
0085 def customiseL1Menu(process):
0086 
0087     # replace the L1 menu from the global tag with one of the following alternatives
0088 
0089     ####### user choices
0090 
0091     #l1MenuSource='globalTag'
0092     #l1MenuSource='sqlFile'
0093     l1MenuSource='xmlFile'
0094 
0095 
0096     if l1MenuSource == 'sqlFile' :
0097         # the menu will be read from the SQL file instead of the global tag
0098         useSqlFile = '/afs/cern.ch/user/g/ghete/public/L1Menu/L1Menu_Collisions2015_25ns_v2/sqlFile/L1Menu_Collisions2015_25ns_v2_mc.db'
0099         menuDbTag = 'L1GtTriggerMenu_L1Menu_Collisions2015_25ns_v2_mc'
0100     elif l1MenuSource == 'xmlFile' :
0101         # the menu will be read from an XML file instead of the global tag - must copy the file in luminosityDirectory
0102         luminosityDirectory = "startup"
0103         useXmlFile = 'L1Menu_Collisions2015_25ns_v2_L1T_Scales_20141121_Imp0_0x1030.xml'
0104     else :
0105         # use the default L1 trigger menu from the global tag
0106         pass
0107 
0108     ####### end of user choices - do not change the following
0109 
0110     if l1MenuSource == 'xmlFile' :
0111         process.load('L1TriggerConfig.L1GtConfigProducers.l1GtTriggerMenuXml_cfi')
0112         process.l1GtTriggerMenuXml.TriggerMenuLuminosity = luminosityDirectory
0113         process.l1GtTriggerMenuXml.DefXmlFile = useXmlFile
0114 
0115         process.load('L1TriggerConfig.L1GtConfigProducers.L1GtTriggerMenuConfig_cff')
0116         process.es_prefer_l1GtParameters = cms.ESPrefer('L1GtTriggerMenuXmlProducer','l1GtTriggerMenuXml')
0117 
0118     elif l1MenuSource == 'sqlFile' :
0119         if useSqlFile != '' :
0120             from CondCore.DBCommon.CondDBSetup_cfi import CondDBSetup
0121             process.l1conddb = cms.ESSource("PoolDBESSource",
0122                                     CondDBSetup,
0123                                     connect = cms.string('sqlite_file:' + useSqlFile),
0124                                     toGet = cms.VPSet(cms.PSet(
0125                                                 record = cms.string('L1GtTriggerMenuRcd'),
0126                                                 tag = cms.string(menuDbTag))),
0127                                                 BlobStreamerName = cms.untracked.string('TBufferBlobStreamingService')
0128                                             )
0129             process.es_prefer_l1conddb = cms.ESPrefer("PoolDBESSource", "l1conddb")
0130 
0131         else :
0132             print('   Error: no SQL file is given; please provide a valid SQL file for option sqlFile')
0133 
0134     return process
0135 
0136 ##############################################################################
0137 
0138 def customiseOutputCommands(process):
0139 
0140     # customization of output commands, on top of the output commands selected
0141     # in cmsDriver command
0142 
0143     # examples
0144 
0145     # drop all products, keep only the products from L1EmulRaw process and the FEDRawDataCollection_
0146     #process.output.outputCommands.append('drop *_*_*_*')
0147     #process.output.outputCommands.append('keep *_*_*_L1EmulRaw')
0148     #process.output.outputCommands.append('keep FEDRawDataCollection_*_*_*')
0149 
0150 
0151     return process
0152 
0153 
0154 ##############################################################################
0155 
0156 def customiseL1EmulatorFromRaw(process):
0157     # customization fragment to run L1 emulator starting from a RAW file
0158 
0159     # run trigger primitive generation on unpacked digis
0160     process.load('L1Trigger.Configuration.CaloTriggerPrimitives_cff')
0161 
0162     process.CaloTPG_SimL1Emulator = cms.Sequence(
0163         process.CaloTriggerPrimitives +
0164         process.SimL1Emulator )
0165 
0166     for path in process._Process__paths.values():
0167         path.replace(process.SimL1Emulator, process.CaloTPG_SimL1Emulator)
0168 
0169     # set the new input tags after RawToDigi
0170     process.simEcalTriggerPrimitiveDigis.Label = 'ecalDigis'
0171     process.simHcalTriggerPrimitiveDigis.inputLabel = cms.VInputTag(
0172         cms.InputTag('hcalDigis'),
0173         cms.InputTag('hcalDigis')
0174     )
0175 
0176     process.simDtTriggerPrimitiveDigis.digiTag = 'muonDTDigis'
0177     process.simCscTriggerPrimitiveDigis.CSCComparatorDigiProducer = cms.InputTag( 'muonCSCDigis', 'MuonCSCComparatorDigi' )
0178     process.simCscTriggerPrimitiveDigis.CSCWireDigiProducer       = cms.InputTag( 'muonCSCDigis', 'MuonCSCWireDigi' )
0179     process.simRpcTriggerDigis.label         = 'muonRPCDigis'
0180     process.simRpcTechTrigDigis.RPCDigiLabel = 'muonRPCDigis'
0181 
0182     return process
0183 
0184 ##############################################################################
0185 
0186 def customiseL1GtEmulatorFromRaw(process):
0187     # customization fragment to run L1 GT emulator starting from a RAW file, with input from unpacked GCT and GMT products
0188     # assuming that "RawToDigi_cff" (or "RawToDigi_data_cff") and "SimL1Emulator_cff" have already been loaded
0189 
0190     # producers for technical triggers:
0191     # they must be re-run as their output is not available from RAW2DIGI
0192 
0193     # BSC Technical Trigger
0194     # Note: will normally not work, it requires SimHits (not available from RAW2DIGI)
0195     # works only on some MC samples where the SimHits are saved together with the FEDRaw
0196     import L1TriggerOffline.L1Analyzer.bscTrigger_cfi
0197     process.simBscDigis = L1TriggerOffline.L1Analyzer.bscTrigger_cfi.bscTrigger.clone()
0198 
0199     # RPC Technical Trigger
0200     import L1Trigger.RPCTechnicalTrigger.rpcTechnicalTrigger_cfi
0201     process.simRpcTechTrigDigis = L1Trigger.RPCTechnicalTrigger.rpcTechnicalTrigger_cfi.rpcTechnicalTrigger.clone()
0202 
0203     process.simRpcTriggerDigis.label = 'muonRPCDigis'
0204     process.simRpcTechTrigDigis.RPCDigiLabel = 'muonRPCDigis'
0205 
0206     # HCAL Technical Trigger
0207     import SimCalorimetry.HcalTrigPrimProducers.hcalTTPRecord_cfi
0208     process.simHcalTechTrigDigis = SimCalorimetry.HcalTrigPrimProducers.hcalTTPRecord_cfi.simHcalTTPRecord.clone()
0209 
0210 
0211     # Global Trigger emulator
0212 
0213     # do not run calo emulators - instead, use unpacked GCT digis for GT input
0214     process.simGtDigis.GctInputTag = 'gctDigis'
0215 
0216     # do not run muon emulators - instead, use unpacked GMT digis for GT input
0217     # (GMT digis produced by same module as the GT digis, as GT and GMT have common unpacker)
0218     process.simGtDigis.GmtInputTag = 'gtDigis'
0219 
0220     # technical triggers
0221     process.simGtDigis.TechnicalTriggersInputTags = cms.VInputTag(
0222         cms.InputTag( 'simBscDigis' ),
0223         cms.InputTag( 'simRpcTechTrigDigis' ),
0224         cms.InputTag( 'simHcalTechTrigDigis' )
0225         )
0226 
0227     process.SimL1TechnicalTriggers = cms.Sequence(
0228         process.simBscDigis +
0229         process.simRpcTechTrigDigis +
0230         process.simHcalTechTrigDigis
0231         )
0232 
0233     # run producers for technical triggers, L1 GT emulator only
0234     SimL1Emulator = cms.Sequence(
0235         process.SimL1TechnicalTriggers +
0236         process.simGtDigis )
0237 
0238     # replace the SimL1Emulator in all paths and sequences
0239     for iterable in process.sequences.values():
0240         iterable.replace( process.SimL1Emulator, SimL1Emulator)
0241     for iterable in process.paths.values():
0242         iterable.replace( process.SimL1Emulator, SimL1Emulator)
0243     for iterable in process.endpaths.values():
0244         iterable.replace( process.SimL1Emulator, SimL1Emulator)
0245     process.SimL1Emulator = SimL1Emulator
0246 
0247     return process
0248 
0249 ##############################################################################
0250 
0251 def customiseL1CaloAndGtEmulatorsFromRaw(process):
0252     # customization fragment to run calorimeter emulators (TPGs and L1 calorimeter emulators)
0253     # and GT emulator starting from a RAW file assuming that "RawToDigi_cff" and "SimL1Emulator_cff"
0254     # have already been loaded
0255 
0256     # run Calo TPGs on unpacked digis
0257     process.load('L1Trigger.Configuration.CaloTriggerPrimitives_cff')
0258     process.simEcalTriggerPrimitiveDigis.Label = 'ecalDigis'
0259     process.simHcalTriggerPrimitiveDigis.inputLabel = cms.VInputTag(
0260         cms.InputTag('hcalDigis'),
0261         cms.InputTag('hcalDigis')
0262     )
0263 
0264     # do not run muon emulators - instead, use unpacked GMT digis for GT input
0265     # (GMT digis produced by same module as the GT digis, as GT and GMT have common unpacker)
0266     process.simRpcTechTrigDigis.RPCDigiLabel = 'muonRPCDigis'
0267     process.simGtDigis.GmtInputTag = 'gtDigis'
0268 
0269     # run Calo TPGs, L1 GCT, technical triggers, L1 GT
0270     SimL1Emulator = cms.Sequence(
0271         process.CaloTriggerPrimitives +
0272         process.simRctDigis +
0273         process.simGctDigis +
0274         process.SimL1TechnicalTriggers +
0275         process.simGtDigis )
0276 
0277     # replace the SimL1Emulator in all paths and sequences
0278     for iterable in process.sequences.values():
0279         iterable.replace( process.SimL1Emulator, SimL1Emulator)
0280     for iterable in process.paths.values():
0281         iterable.replace( process.SimL1Emulator, SimL1Emulator)
0282     for iterable in process.endpaths.values():
0283         iterable.replace( process.SimL1Emulator, SimL1Emulator)
0284     process.SimL1Emulator = SimL1Emulator
0285 
0286     return process
0287 
0288 ##############################################################################
0289 
0290 def customiseL1TriggerReport(process):
0291 
0292     process.load("L1Trigger.GlobalTriggerAnalyzer.l1GtTrigReport_cfi")
0293 
0294     # boolean flag to select the input record
0295     # if true, it will use L1GlobalTriggerRecord
0296     #process.l1GtTrigReport.UseL1GlobalTriggerRecord = True
0297 
0298     # input tag for GT record:
0299     #   GT emulator:    gtDigis (DAQ record)
0300     #   GT unpacker:    gtDigis (DAQ record)
0301     #   GT lite record: l1GtRecord
0302     process.l1GtTrigReport.L1GtRecordInputTag = "gtDigis"
0303 
0304     process.l1GtTrigReport.PrintVerbosity = 10
0305     process.l1GtTrigReport.PrintOutput = 0
0306 
0307 
0308 
0309     #
0310     return (process)
0311 
0312 ##############################################################################