Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-27 03:17:53

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                                                 BlobStreamerName = cms.untracked.string('TBufferBlobStreamingService')
0127                                             )
0128             process.es_prefer_l1conddb = cms.ESPrefer("PoolDBESSource", "l1conddb")
0129 
0130         else :
0131             print('   Error: no SQL file is given; please provide a valid SQL file for option sqlFile')
0132 
0133     return process
0134 
0135 ##############################################################################
0136 
0137 def customiseOutputCommands(process):
0138 
0139     # customization of output commands, on top of the output commands selected
0140     # in cmsDriver command
0141 
0142     # examples
0143 
0144     # drop all products, keep only the products from L1EmulRaw process and the FEDRawDataCollection_
0145     #process.output.outputCommands.append('drop *_*_*_*')
0146     #process.output.outputCommands.append('keep *_*_*_L1EmulRaw')
0147     #process.output.outputCommands.append('keep FEDRawDataCollection_*_*_*')
0148 
0149 
0150     return process
0151 
0152 
0153 ##############################################################################
0154 
0155 def customiseL1EmulatorFromRaw(process):
0156     # customization fragment to run L1 emulator starting from a RAW file
0157 
0158     # run trigger primitive generation on unpacked digis
0159     process.load('L1Trigger.Configuration.CaloTriggerPrimitives_cff')
0160 
0161     process.CaloTPG_SimL1Emulator = cms.Sequence(
0162         process.CaloTriggerPrimitives +
0163         process.SimL1Emulator )
0164 
0165     for path in process._Process__paths.values():
0166         path.replace(process.SimL1Emulator, process.CaloTPG_SimL1Emulator)
0167 
0168     # set the new input tags after RawToDigi
0169     process.simEcalTriggerPrimitiveDigis.Label = 'ecalDigis'
0170     process.simHcalTriggerPrimitiveDigis.inputLabel = cms.VInputTag(
0171         cms.InputTag('hcalDigis'),
0172         cms.InputTag('hcalDigis')
0173     )
0174 
0175     process.simDtTriggerPrimitiveDigis.digiTag = 'muonDTDigis'
0176     process.simCscTriggerPrimitiveDigis.CSCComparatorDigiProducer = cms.InputTag( 'muonCSCDigis', 'MuonCSCComparatorDigi' )
0177     process.simCscTriggerPrimitiveDigis.CSCWireDigiProducer       = cms.InputTag( 'muonCSCDigis', 'MuonCSCWireDigi' )
0178     process.simRpcTriggerDigis.label         = 'muonRPCDigis'
0179     process.simRpcTechTrigDigis.RPCDigiLabel = 'muonRPCDigis'
0180 
0181     return process
0182 
0183 ##############################################################################
0184 
0185 def customiseL1GtEmulatorFromRaw(process):
0186     # customization fragment to run L1 GT emulator starting from a RAW file, with input from unpacked GCT and GMT products
0187     # assuming that "RawToDigi_cff" (or "RawToDigi_data_cff") and "SimL1Emulator_cff" have already been loaded
0188 
0189     # producers for technical triggers:
0190     # they must be re-run as their output is not available from RAW2DIGI
0191 
0192     # BSC Technical Trigger
0193     # Note: will normally not work, it requires SimHits (not available from RAW2DIGI)
0194     # works only on some MC samples where the SimHits are saved together with the FEDRaw
0195     import L1TriggerOffline.L1Analyzer.bscTrigger_cfi
0196     process.simBscDigis = L1TriggerOffline.L1Analyzer.bscTrigger_cfi.bscTrigger.clone()
0197 
0198     # RPC Technical Trigger
0199     import L1Trigger.RPCTechnicalTrigger.rpcTechnicalTrigger_cfi
0200     process.simRpcTechTrigDigis = L1Trigger.RPCTechnicalTrigger.rpcTechnicalTrigger_cfi.rpcTechnicalTrigger.clone()
0201 
0202     process.simRpcTriggerDigis.label = 'muonRPCDigis'
0203     process.simRpcTechTrigDigis.RPCDigiLabel = 'muonRPCDigis'
0204 
0205     # HCAL Technical Trigger
0206     import SimCalorimetry.HcalTrigPrimProducers.hcalTTPRecord_cfi
0207     process.simHcalTechTrigDigis = SimCalorimetry.HcalTrigPrimProducers.hcalTTPRecord_cfi.simHcalTTPRecord.clone()
0208 
0209 
0210     # Global Trigger emulator
0211 
0212     # do not run calo emulators - instead, use unpacked GCT digis for GT input
0213     process.simGtDigis.GctInputTag = 'gctDigis'
0214 
0215     # do not run muon emulators - instead, use unpacked GMT digis for GT input
0216     # (GMT digis produced by same module as the GT digis, as GT and GMT have common unpacker)
0217     process.simGtDigis.GmtInputTag = 'gtDigis'
0218 
0219     # technical triggers
0220     process.simGtDigis.TechnicalTriggersInputTags = cms.VInputTag(
0221         cms.InputTag( 'simBscDigis' ),
0222         cms.InputTag( 'simRpcTechTrigDigis' ),
0223         cms.InputTag( 'simHcalTechTrigDigis' )
0224         )
0225 
0226     process.SimL1TechnicalTriggers = cms.Sequence(
0227         process.simBscDigis +
0228         process.simRpcTechTrigDigis +
0229         process.simHcalTechTrigDigis
0230         )
0231 
0232     # run producers for technical triggers, L1 GT emulator only
0233     SimL1Emulator = cms.Sequence(
0234         process.SimL1TechnicalTriggers +
0235         process.simGtDigis )
0236 
0237     # replace the SimL1Emulator in all paths and sequences
0238     for iterable in process.sequences.values():
0239         iterable.replace( process.SimL1Emulator, SimL1Emulator)
0240     for iterable in process.paths.values():
0241         iterable.replace( process.SimL1Emulator, SimL1Emulator)
0242     for iterable in process.endpaths.values():
0243         iterable.replace( process.SimL1Emulator, SimL1Emulator)
0244     process.SimL1Emulator = SimL1Emulator
0245 
0246     return process
0247 
0248 ##############################################################################
0249 
0250 def customiseL1CaloAndGtEmulatorsFromRaw(process):
0251     # customization fragment to run calorimeter emulators (TPGs and L1 calorimeter emulators)
0252     # and GT emulator starting from a RAW file assuming that "RawToDigi_cff" and "SimL1Emulator_cff"
0253     # have already been loaded
0254 
0255     # run Calo TPGs on unpacked digis
0256     process.load('L1Trigger.Configuration.CaloTriggerPrimitives_cff')
0257     process.simEcalTriggerPrimitiveDigis.Label = 'ecalDigis'
0258     process.simHcalTriggerPrimitiveDigis.inputLabel = cms.VInputTag(
0259         cms.InputTag('hcalDigis'),
0260         cms.InputTag('hcalDigis')
0261     )
0262 
0263     # do not run muon emulators - instead, use unpacked GMT digis for GT input
0264     # (GMT digis produced by same module as the GT digis, as GT and GMT have common unpacker)
0265     process.simRpcTechTrigDigis.RPCDigiLabel = 'muonRPCDigis'
0266     process.simGtDigis.GmtInputTag = 'gtDigis'
0267 
0268     # run Calo TPGs, L1 GCT, technical triggers, L1 GT
0269     SimL1Emulator = cms.Sequence(
0270         process.CaloTriggerPrimitives +
0271         process.simRctDigis +
0272         process.simGctDigis +
0273         process.SimL1TechnicalTriggers +
0274         process.simGtDigis )
0275 
0276     # replace the SimL1Emulator in all paths and sequences
0277     for iterable in process.sequences.values():
0278         iterable.replace( process.SimL1Emulator, SimL1Emulator)
0279     for iterable in process.paths.values():
0280         iterable.replace( process.SimL1Emulator, SimL1Emulator)
0281     for iterable in process.endpaths.values():
0282         iterable.replace( process.SimL1Emulator, SimL1Emulator)
0283     process.SimL1Emulator = SimL1Emulator
0284 
0285     return process
0286 
0287 ##############################################################################
0288 
0289 def customiseL1TriggerReport(process):
0290 
0291     process.load("L1Trigger.GlobalTriggerAnalyzer.l1GtTrigReport_cfi")
0292 
0293     # boolean flag to select the input record
0294     # if true, it will use L1GlobalTriggerRecord
0295     #process.l1GtTrigReport.UseL1GlobalTriggerRecord = True
0296 
0297     # input tag for GT record:
0298     #   GT emulator:    gtDigis (DAQ record)
0299     #   GT unpacker:    gtDigis (DAQ record)
0300     #   GT lite record: l1GtRecord
0301     process.l1GtTrigReport.L1GtRecordInputTag = "gtDigis"
0302 
0303     process.l1GtTrigReport.PrintVerbosity = 10
0304     process.l1GtTrigReport.PrintOutput = 0
0305 
0306 
0307 
0308     #
0309     return (process)
0310 
0311 ##############################################################################