Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-04-17 02:42:20

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