CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/L1Trigger/Configuration/python/L1Trigger_custom.py

Go to the documentation of this file.
00001 # customization fragments to be used with cmsDriver and hltGetConfiguration
00002 #
00003 # V.M. Ghete 2010-06-09 initial version
00004 
00005 import FWCore.ParameterSet.Config as cms
00006 
00007 def customiseUnprescaleAlgoTriggers(process):
00008 
00009     # temporary solution FIXME
00010 
00011     process.load("L1TriggerConfig.L1GtConfigProducers.L1GtPrescaleFactorsAlgoTrigConfig_cff")
00012     process.es_prefer_l1GtPrescaleFactorsAlgoTrig = cms.ESPrefer(
00013         "L1GtPrescaleFactorsAlgoTrigTrivialProducer", "l1GtPrescaleFactorsAlgoTrig")
00014 
00015 
00016     return (process)
00017 
00018 ##############################################################################
00019 
00020 def customiseUnprescaleTechTriggers(process):
00021 
00022     # temporary solution FIXME
00023 
00024     process.load("L1TriggerConfig.L1GtConfigProducers.L1GtPrescaleFactorsTechTrigConfig_cff")
00025     process.es_prefer_l1GtPrescaleFactorsTechTrig = cms.ESPrefer(
00026         "L1GtPrescaleFactorsTechTrigTrivialProducer", "l1GtPrescaleFactorsTechTrig")
00027 
00028     return (process)
00029 
00030 ##############################################################################
00031 
00032 def customiseResetMasksAlgoTriggers(process):
00033 
00034     process.load("L1TriggerConfig.L1GtConfigProducers.L1GtTriggerMaskAlgoTrigConfig_cff")
00035     process.es_prefer_l1GtTriggerMaskAlgoTrig = cms.ESPrefer(
00036         "L1GtTriggerMaskAlgoTrigTrivialProducer", "l1GtTriggerMaskAlgoTrig")
00037 
00038     return (process)
00039 
00040 ##############################################################################
00041 
00042 def customiseResetMasksTechTriggers(process):
00043 
00044     process.load("L1TriggerConfig.L1GtConfigProducers.L1GtTriggerMaskTechTrigConfig_cff")
00045     process.es_prefer_l1GtTriggerMaskTechTrig = cms.ESPrefer(
00046         "L1GtTriggerMaskTechTrigTrivialProducer", "l1GtTriggerMaskTechTrig")
00047 
00048     return (process)
00049 
00050 ##############################################################################
00051 
00052 def customiseResetVetoMasksAlgoTriggers(process):
00053 
00054     process.load("L1TriggerConfig.L1GtConfigProducers.L1GtTriggerMaskVetoAlgoTrigConfig_cff")
00055     process.es_prefer_l1GtTriggerMaskVetoAlgoTrig = cms.ESPrefer(
00056         "L1GtTriggerMaskVetoAlgoTrigTrivialProducer", "l1GtTriggerMaskVetoAlgoTrig")
00057 
00058     return (process)
00059 
00060 ##############################################################################
00061 
00062 def customiseResetVetoMasksTechTriggers(process):
00063 
00064     process.load("L1TriggerConfig.L1GtConfigProducers.L1GtTriggerMaskVetoTechTrigConfig_cff")
00065     process.es_prefer_l1GtTriggerMaskVetoTechTrig = cms.ESPrefer(
00066         "L1GtTriggerMaskVetoTechTrigTrivialProducer", "l1GtTriggerMaskVetoTechTrig")
00067 
00068     return (process)
00069 
00070 ##############################################################################
00071 
00072 def customiseResetPrescalesAndMasks(process):
00073     process = customiseUnprescaleAlgoTriggers( process )
00074     process = customiseUnprescaleTechTriggers( process )
00075     process = customiseResetMasksAlgoTriggers( process )
00076     process = customiseResetMasksTechTriggers( process )
00077     process = customiseResetVetoMasksAlgoTriggers( process )
00078     process = customiseResetVetoMasksTechTriggers( process )
00079 
00080     return (process)
00081 
00082 ##############################################################################
00083 
00084 def customiseL1Menu(process):
00085 
00086     # replace the L1 menu from the global tag with one of the following alternatives
00087 
00088     ####### user choices
00089 
00090     #l1MenuSource='globalTag'
00091     #l1MenuSource='sqlFile'
00092     l1MenuSource='xmlFile'
00093 
00094 
00095     if l1MenuSource == 'sqlFile' :
00096         # the menu will be read from the SQL file instead of the global tag
00097         useSqlFile = '/afs/cern.ch/user/g/ghete/public/L1Menu/L1Menu_CollisionsHeavyIons2013_v0/sqlFile/L1Menu_CollisionsHeavyIons2013_v0_mc.db'
00098         menuDbTag = 'L1GtTriggerMenu_L1Menu_CollisionsHeavyIons2013_v0_mc'
00099     elif l1MenuSource == 'xmlFile' :
00100         # the menu will be read from an XML file instead of the global tag - must copy the file in luminosityDirectory
00101         luminosityDirectory = "startup"
00102         useXmlFile = 'L1Menu_CollisionsHeavyIons2013_v0_L1T_Scales_20101224_Imp0_0x102c.xml'
00103 
00104     else :
00105         print '   Using default L1 trigger menu from Global Tag '
00106 
00107     ####### end of user choices - do not change the following
00108 
00109     if l1MenuSource == 'xmlFile' :
00110         print '   Retrieve L1 trigger menu only from XML file '
00111         print '       ', useXmlFile
00112         print '       '
00113 
00114         process.load('L1TriggerConfig.L1GtConfigProducers.l1GtTriggerMenuXml_cfi')
00115         process.l1GtTriggerMenuXml.TriggerMenuLuminosity = luminosityDirectory
00116         process.l1GtTriggerMenuXml.DefXmlFile = useXmlFile
00117 
00118         process.load('L1TriggerConfig.L1GtConfigProducers.L1GtTriggerMenuConfig_cff')
00119         process.es_prefer_l1GtParameters = cms.ESPrefer('L1GtTriggerMenuXmlProducer','l1GtTriggerMenuXml')
00120 
00121 
00122 
00123     elif l1MenuSource == 'sqlFile' :
00124         if useSqlFile != '' :
00125             print '   Retrieve L1 trigger menu only from SQLlite file '
00126             print '       ', useSqlFile
00127             print '       '
00128 
00129             from CondCore.DBCommon.CondDBSetup_cfi import CondDBSetup
00130             process.l1conddb = cms.ESSource("PoolDBESSource",
00131                                     CondDBSetup,
00132                                     connect = cms.string('sqlite_file:' + useSqlFile),
00133                                     toGet = cms.VPSet(cms.PSet(
00134                                                 record = cms.string('L1GtTriggerMenuRcd'),
00135                                                 tag = cms.string(menuDbTag))),
00136                                                 BlobStreamerName = cms.untracked.string('TBufferBlobStreamingService')
00137                                             )
00138             process.es_prefer_l1conddb = cms.ESPrefer("PoolDBESSource", "l1conddb")
00139 
00140         else :
00141             print '   Error: no SQL file is given; please provide a valid SQL file for option sqlFile'
00142 
00143     else :
00144         print ''
00145 
00146 
00147     return process
00148 
00149 ##############################################################################
00150 
00151 def customiseOutputCommands(process):
00152 
00153     # customization of output commands, on top of the output commands selected
00154     # in cmsDriver command
00155 
00156     # examples
00157 
00158     # drop all products, keep only the products from L1EmulRaw process and the FEDRawDataCollection_
00159     #process.output.outputCommands.append('drop *_*_*_*')
00160     #process.output.outputCommands.append('keep *_*_*_L1EmulRaw')
00161     #process.output.outputCommands.append('keep FEDRawDataCollection_*_*_*')
00162 
00163 
00164     return process
00165 
00166 
00167 ##############################################################################
00168 
00169 def customiseL1EmulatorFromRaw(process):
00170     # customization fragment to run L1 emulator starting from a RAW file
00171 
00172     # run trigger primitive generation on unpacked digis
00173     process.load('L1Trigger.Configuration.CaloTriggerPrimitives_cff')
00174 
00175     process.CaloTPG_SimL1Emulator = cms.Sequence(
00176         process.CaloTriggerPrimitives + 
00177         process.SimL1Emulator )
00178 
00179     for path in process._Process__paths.itervalues():
00180         path.replace(process.SimL1Emulator, process.CaloTPG_SimL1Emulator)
00181 
00182     # set the new input tags after RawToDigi
00183     process.simEcalTriggerPrimitiveDigis.Label = 'ecalDigis'
00184     process.simHcalTriggerPrimitiveDigis.inputLabel = cms.VInputTag(
00185         cms.InputTag('hcalDigis'),
00186         cms.InputTag('hcalDigis')
00187     )
00188 
00189     process.simDtTriggerPrimitiveDigis.digiTag = 'muonDTDigis'
00190     process.simCscTriggerPrimitiveDigis.CSCComparatorDigiProducer = cms.InputTag( 'muonCSCDigis', 'MuonCSCComparatorDigi' )
00191     process.simCscTriggerPrimitiveDigis.CSCWireDigiProducer       = cms.InputTag( 'muonCSCDigis', 'MuonCSCWireDigi' )
00192     process.simRpcTriggerDigis.label         = 'muonRPCDigis'
00193     process.simRpcTechTrigDigis.RPCDigiLabel = 'muonRPCDigis'
00194 
00195     return process
00196 
00197 ##############################################################################
00198 
00199 def customiseL1GtEmulatorFromRaw(process):
00200     # customization fragment to run L1 GT emulator starting from a RAW file, with input from unpacked GCT and GMT products
00201     # assuming that "RawToDigi_cff" (or "RawToDigi_data_cff") and "SimL1Emulator_cff" have already been loaded
00202 
00203     # producers for technical triggers:
00204     # they must be re-run as their output is not available from RAW2DIGI
00205 
00206     # BSC Technical Trigger
00207     # Note: will normally not work, it requires SimHits (not available from RAW2DIGI)
00208     # works only on some MC samples where the SimHits are saved together with the FEDRaw
00209     import L1TriggerOffline.L1Analyzer.bscTrigger_cfi
00210     process.simBscDigis = L1TriggerOffline.L1Analyzer.bscTrigger_cfi.bscTrigger.clone()
00211 
00212     # RPC Technical Trigger
00213     import L1Trigger.RPCTechnicalTrigger.rpcTechnicalTrigger_cfi
00214     process.simRpcTechTrigDigis = L1Trigger.RPCTechnicalTrigger.rpcTechnicalTrigger_cfi.rpcTechnicalTrigger.clone()
00215     
00216     process.simRpcTriggerDigis.label = 'muonRPCDigis'
00217     process.simRpcTechTrigDigis.RPCDigiLabel = 'muonRPCDigis'
00218 
00219     # HCAL Technical Trigger
00220     import SimCalorimetry.HcalTrigPrimProducers.hcalTTPRecord_cfi
00221     process.simHcalTechTrigDigis = SimCalorimetry.HcalTrigPrimProducers.hcalTTPRecord_cfi.simHcalTTPRecord.clone()
00222      
00223 
00224     # Global Trigger emulator
00225     
00226     # do not run calo emulators - instead, use unpacked GCT digis for GT input
00227     process.simGtDigis.GctInputTag = 'gctDigis'
00228     
00229     # do not run muon emulators - instead, use unpacked GMT digis for GT input 
00230     # (GMT digis produced by same module as the GT digis, as GT and GMT have common unpacker)
00231     process.simGtDigis.GmtInputTag = 'gtDigis'                                                                                                                                                               
00232     
00233     # technical triggers
00234     process.simGtDigis.TechnicalTriggersInputTags = cms.VInputTag(
00235         cms.InputTag( 'simBscDigis' ), 
00236         cms.InputTag( 'simRpcTechTrigDigis' ),
00237         cms.InputTag( 'simHcalTechTrigDigis' )
00238         )
00239 
00240     process.SimL1TechnicalTriggers = cms.Sequence(
00241         process.simBscDigis +
00242         process.simRpcTechTrigDigis +
00243         process.simHcalTechTrigDigis
00244         )
00245 
00246     # run producers for technical triggers, L1 GT emulator only
00247     SimL1Emulator = cms.Sequence(
00248         process.SimL1TechnicalTriggers +
00249         process.simGtDigis )
00250 
00251     # replace the SimL1Emulator in all paths and sequences
00252     for iterable in process.sequences.itervalues():
00253         iterable.replace( process.SimL1Emulator, SimL1Emulator)
00254     for iterable in process.paths.itervalues():
00255         iterable.replace( process.SimL1Emulator, SimL1Emulator)
00256     for iterable in process.endpaths.itervalues():
00257         iterable.replace( process.SimL1Emulator, SimL1Emulator)
00258     process.SimL1Emulator = SimL1Emulator
00259 
00260     return process
00261 
00262 ##############################################################################
00263 
00264 def customiseL1CaloAndGtEmulatorsFromRaw(process):
00265     # customization fragment to run calorimeter emulators (TPGs and L1 calorimeter emulators) 
00266     # and GT emulator starting from a RAW file assuming that "RawToDigi_cff" and "SimL1Emulator_cff" 
00267     # have already been loaded
00268 
00269     # run Calo TPGs on unpacked digis
00270     process.load('L1Trigger.Configuration.CaloTriggerPrimitives_cff')
00271     process.simEcalTriggerPrimitiveDigis.Label = 'ecalDigis'
00272     process.simHcalTriggerPrimitiveDigis.inputLabel = cms.VInputTag(
00273         cms.InputTag('hcalDigis'), 
00274         cms.InputTag('hcalDigis')
00275     )
00276     
00277     # do not run muon emulators - instead, use unpacked GMT digis for GT input 
00278     # (GMT digis produced by same module as the GT digis, as GT and GMT have common unpacker)
00279     process.simRpcTechTrigDigis.RPCDigiLabel = 'muonRPCDigis'                                                                                                                                                                                           
00280     process.simGtDigis.GmtInputTag = 'gtDigis'                                                                                                                                                                                                          
00281 
00282     # run Calo TPGs, L1 GCT, technical triggers, L1 GT
00283     SimL1Emulator = cms.Sequence(
00284         process.CaloTriggerPrimitives +
00285         process.simRctDigis +
00286         process.simGctDigis +
00287         process.SimL1TechnicalTriggers +
00288         process.simGtDigis )
00289 
00290     # replace the SimL1Emulator in all paths and sequences
00291     for iterable in process.sequences.itervalues():
00292         iterable.replace( process.SimL1Emulator, SimL1Emulator)
00293     for iterable in process.paths.itervalues():
00294         iterable.replace( process.SimL1Emulator, SimL1Emulator)
00295     for iterable in process.endpaths.itervalues():
00296         iterable.replace( process.SimL1Emulator, SimL1Emulator)
00297     process.SimL1Emulator = SimL1Emulator
00298 
00299     return process
00300 
00301 ##############################################################################
00302 
00303 def customiseL1TriggerReport(process):
00304 
00305     process.load("L1Trigger.GlobalTriggerAnalyzer.l1GtTrigReport_cfi")
00306 
00307     # boolean flag to select the input record
00308     # if true, it will use L1GlobalTriggerRecord
00309     #process.l1GtTrigReport.UseL1GlobalTriggerRecord = True
00310 
00311     # input tag for GT record:
00312     #   GT emulator:    gtDigis (DAQ record)
00313     #   GT unpacker:    gtDigis (DAQ record)
00314     #   GT lite record: l1GtRecord
00315     process.l1GtTrigReport.L1GtRecordInputTag = "gtDigis"
00316 
00317     process.l1GtTrigReport.PrintVerbosity = 10
00318     process.l1GtTrigReport.PrintOutput = 0
00319 
00320 
00321 
00322     #
00323     return (process)
00324 
00325 ##############################################################################