Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration of L1 REPACK #1

Open
rekovic opened this issue Mar 24, 2016 · 6 comments
Open

Configuration of L1 REPACK #1

rekovic opened this issue Mar 24, 2016 · 6 comments

Comments

@rekovic
Copy link
Owner

rekovic commented Mar 24, 2016

cat Configuration/StandardSequences/python/SimL1EmulatorRepack_Full_cff.py

import FWCore.ParameterSet.Config as cms
from Configuration.StandardSequences.Eras import eras

## L1REPACK FULL:  Re-Emulate all of L1 and repack into RAW


if not (eras.stage2L1Trigger.isChosen()):
    print "L1T WARN:  L1REPACK ALL only supports Stage 2 eras for now."
    print "L1T WARN:  Use a legacy version of L1REPACK for now."
else:
    print "L1T INFO:  L1REPACK ALL will unpack all L1T inputs, re-emulated (Stage-2), and pack uGT, uGMT, and Calo Stage-2 output."

    # First, Unpack all inputs to L1:
    import EventFilter.DTTFRawToDigi.dttfunpacker_cfi
    unpackDttf = EventFilter.DTTFRawToDigi.dttfunpacker_cfi.dttfunpacker.clone(
        DTTF_FED_Source = cms.InputTag( 'rawDataCollector', processName=cms.InputTag.skipCurrentProcess()))    

    import EventFilter.CSCRawToDigi.cscUnpacker_cfi
    unpackCSC = EventFilter.CSCRawToDigi.cscUnpacker_cfi.muonCSCDigis.clone(
        InputObjects = cms.InputTag( 'rawDataCollector', processName=cms.InputTag.skipCurrentProcess()))

    import EventFilter.DTRawToDigi.dtunpacker_cfi
    unpackDT = EventFilter.DTRawToDigi.dtunpacker_cfi.muonDTDigis.clone(
        inputLabel = cms.InputTag( 'rawDataCollector', processName=cms.InputTag.skipCurrentProcess()))

    import EventFilter.RPCRawToDigi.rpcUnpacker_cfi
    unpackRPC = EventFilter.RPCRawToDigi.rpcUnpacker_cfi.rpcunpacker.clone(
        InputLabel = cms.InputTag( 'rawDataCollector', processName=cms.InputTag.skipCurrentProcess()))

    import EventFilter.EcalRawToDigi.EcalUnpackerData_cfi
    unpackEcal = EventFilter.EcalRawToDigi.EcalUnpackerData_cfi.ecalEBunpacker.clone(
        InputLabel = cms.InputTag( 'rawDataCollector', processName=cms.InputTag.skipCurrentProcess()))

    import EventFilter.HcalRawToDigi.HcalRawToDigi_cfi
    unpackHcal = EventFilter.HcalRawToDigi.HcalRawToDigi_cfi.hcalDigis.clone(
        InputLabel = cms.InputTag( 'rawDataCollector', processName=cms.InputTag.skipCurrentProcess()))

    # Second, Re-Emulate the entire L1T

    # Legacy trigger primitive emulations still running in 2016 trigger:
    # NOTE:  2016 HCAL HF TPs require a new emulation, which is not yet available...    
    from SimCalorimetry.HcalTrigPrimProducers.hcaltpdigi_cff import *
    simHcalTriggerPrimitiveDigis.inputLabel = cms.VInputTag(
        cms.InputTag('unpackHcal'),
        cms.InputTag('unpackHcal')
    )
    # not sure when/if this is needed...
    # HcalTPGCoderULUT.LUTGenerationMode = cms.bool(True)

    from L1Trigger.Configuration.SimL1Emulator_cff import *
    simDtTriggerPrimitiveDigis.digiTag = 'unpackDT'
    simCscTriggerPrimitiveDigis.CSCComparatorDigiProducer = cms.InputTag( 'unpackCSC', 'MuonCSCComparatorDigi' )
    simCscTriggerPrimitiveDigis.CSCWireDigiProducer       = cms.InputTag( 'unpackCSC', 'MuonCSCWireDigi' )
    simTwinMuxDigis.RPC_Source         = cms.InputTag('unpackRPC')
    simOmtfDigis.srcRPC                = cms.InputTag('unpackRPC')
    simCaloStage2Layer1Digis.ecalToken = cms.InputTag('unpackEcal:EcalTriggerPrimitives')
    simCaloStage2Layer1Digis.hcalToken = cms.InputTag('simHcalTriggerPrimitiveDigis')
    # Picking up simulation a bit further downstream for now:
    simTwinMuxDigis.DTDigi_Source = cms.InputTag("unpackDttf")
    simTwinMuxDigis.DTThetaDigi_Source = cms.InputTag("unpackDttf")
    simBmtfDigis.DTDigi_Source       = cms.InputTag("simTwinMuxDigis")
    simBmtfDigis.DTDigi_Theta_Source = cms.InputTag("unpackDttf")

    # Finally, pack the new L1T output back into RAW

    from EventFilter.L1TRawToDigi.caloStage2Raw_cfi import caloStage2Raw as packCaloStage2
    from EventFilter.L1TRawToDigi.gmtStage2Raw_cfi import gmtStage2Raw as packGmtStage2
    from EventFilter.L1TRawToDigi.gtStage2Raw_cfi import gtStage2Raw as packGtStage2

    # combine the new L1 RAW with existing RAW for other FEDs
    import EventFilter.RawDataCollector.rawDataCollectorByLabel_cfi
    rawDataCollector = EventFilter.RawDataCollector.rawDataCollectorByLabel_cfi.rawDataCollector.clone(
        verbose = cms.untracked.int32(0),
        RawCollectionList = cms.VInputTag(
            cms.InputTag('packCaloStage2'),
            cms.InputTag('packGmtStage2'),
            cms.InputTag('packGtStage2'),
            cms.InputTag('rawDataCollector', processName=cms.InputTag.skipCurrentProcess()),
            )
        )



    SimL1Emulator = cms.Sequence(unpackEcal+unpackHcal+unpackCSC+unpackDT+unpackRPC+unpackDttf
                                 +simHcalTriggerPrimitiveDigis+SimL1EmulatorCore+packCaloStage2
                                 +packGmtStage2+packGtStage2+rawDataCollector)
@rekovic
Copy link
Owner Author

rekovic commented Mar 24, 2016

cat L1Trigger/Configuration/python/SimL1Emulator_cff.py

import FWCore.ParameterSet.Config as cms

# Defines the L1 Emulator sequence for simulation use-case subsystem emulators
# run on the results of previous (in the hardware chain) subsystem emulator:
#  
#     SimL1Emulator = cms.Sequence(...)
#
# properly configured for the current Era (e.g. Run1, 2015, or 2016).  Also
# configures event setup producers appropriate to the current Era, to handle
# conditions which are not yet available in the GT.
#
# Author List
# Jim Brooke, 24 April 2008
# Vasile Mihai Ghete, 2009
# Jim Brooke, Michael Mulhearn, 2015

# Notes on Inputs:

# ECAL TPG emulator and HCAL TPG run in the simulation sequence in order to be able 
# to use unsuppressed digis produced by ECAL and HCAL simulation, respectively
# in Configuration/StandardSequences/python/Digi_cff.py
# SimCalorimetry.Configuration.SimCalorimetry_cff
# which calls
# SimCalorimetry.Configuration.ecalDigiSequence_cff
# SimCalorimetry.Configuration.hcalDigiSequence_cff

#
# At the moment, there is no emulator available for upgrade HF Trigger Primitives,
# so these missing (required!) inputs are presently ignored by downstream modules.
#

from L1Trigger.Configuration.SimL1TechnicalTriggers_cff import *

from L1Trigger.L1TCalorimeter.simDigis_cff import *
from L1Trigger.L1TMuon.simDigis_cff import *
from L1Trigger.L1TGlobal.simDigis_cff import *

# define a core which can be extented in customizations:
SimL1EmulatorCore = cms.Sequence(
    SimL1TCalorimeter +
    SimL1TMuon +
    SimL1TechnicalTriggers +
    SimL1TGlobal
    )

SimL1Emulator = cms.Sequence( SimL1EmulatorCore )

#
# Next we load ES producers for any conditions that are not yet in GT,
# using the Era configuration.
#
from L1Trigger.L1TCalorimeter.hackConditions_cff import *
from L1Trigger.L1TMuon.hackConditions_cff import *
from L1Trigger.L1TGlobal.hackConditions_cff import *

@rekovic
Copy link
Owner Author

rekovic commented Mar 24, 2016

cat L1Trigger/L1TCalorimeter/python/simDigis_cff.py

import FWCore.ParameterSet.Config as cms
from Configuration.StandardSequences.Eras import eras

#
# Stage-2 Trigger
#
if eras.stage2L1Trigger.isChosen():
    from SimCalorimetry.HcalTrigPrimProducers.hcaltpdigi_cff import *
    print "L1TCalorimeter Sequence configured for Stage-2 (2016) trigger. "
    # select one of the following two options:
    # - layer1 from L1Trigger/L1TCalorimeter package
    from L1Trigger.L1TCalorimeter.simCaloStage2Layer1Digis_cfi import simCaloStage2Layer1Digis
    # - layer1 from L1Trigger/L1TCaloLayer1 package
    #from L1Trigger.L1TCaloLayer1.simCaloStage2Layer1Digis_cfi import simCaloStage2Layer1Digis
    from L1Trigger.L1TCalorimeter.simCaloStage2Digis_cfi import simCaloStage2Digis
    SimL1TCalorimeter = cms.Sequence( simCaloStage2Layer1Digis + simCaloStage2Digis )

@rekovic
Copy link
Owner Author

rekovic commented Mar 24, 2016

cat L1Trigger/L1TMuon/python/simDigis_cff.py

import FWCore.ParameterSet.Config as cms
from Configuration.StandardSequences.Eras import eras

#
# Legacy L1 Muon modules still running in 2016 trigger:
#

#  - DT TP emulator
from L1Trigger.DTTrigger.dtTriggerPrimitiveDigis_cfi import *
import L1Trigger.DTTrigger.dtTriggerPrimitiveDigis_cfi
simDtTriggerPrimitiveDigis = L1Trigger.DTTrigger.dtTriggerPrimitiveDigis_cfi.dtTriggerPrimitiveDigis.clone()

simDtTriggerPrimitiveDigis.digiTag = 'simMuonDTDigis'
#simDtTriggerPrimitiveDigis.debug = cms.untracked.bool(True)

# - CSC TP emulator
from L1Trigger.CSCCommonTrigger.CSCCommonTrigger_cfi import *
import L1Trigger.CSCTriggerPrimitives.cscTriggerPrimitiveDigis_cfi
simCscTriggerPrimitiveDigis = L1Trigger.CSCTriggerPrimitives.cscTriggerPrimitiveDigis_cfi.cscTriggerPrimitiveDigis.clone()
simCscTriggerPrimitiveDigis.CSCComparatorDigiProducer = cms.InputTag( 'simMuonCSCDigis', 'MuonCSCComparatorDigi' )
simCscTriggerPrimitiveDigis.CSCWireDigiProducer       = cms.InputTag( 'simMuonCSCDigis', 'MuonCSCWireDigi' )

SimL1TMuonCommon = cms.Sequence(simDtTriggerPrimitiveDigis + simCscTriggerPrimitiveDigis)

#
# Stage-2 Trigger
#
if eras.stage2L1Trigger.isChosen():
    print "L1TMuon Sequence configured for Stage-2 (2016) trigger. "
    from L1Trigger.L1TMuonBarrel.simTwinMuxDigis_cfi import *
    from L1Trigger.L1TMuonBarrel.simBmtfDigis_cfi import *
    from L1Trigger.L1TMuonEndCap.simEmtfDigis_cfi import *
    from L1Trigger.L1TMuonOverlap.simOmtfDigis_cfi import *
    from L1Trigger.L1TMuon.simGmtCaloSumDigis_cfi import *
    from L1Trigger.L1TMuon.simMuonQualityAdjusterDigis_cfi import *
    from L1Trigger.L1TMuon.simGmtStage2Digis_cfi import *
#
#
    SimL1TMuon = cms.Sequence(SimL1TMuonCommon + simTwinMuxDigis + simBmtfDigis + simEmtfDigis + simOmtfDigis + simGmtCaloSumDigis + simMuonQualityAdjusterDigis + simGmtStage2Digis)

@rekovic
Copy link
Owner Author

rekovic commented Mar 24, 2016

cat L1Trigger/L1TGlobal/python/simDigis_cff.py

#
# WARNING: This file is in the L1T configuration critical path.
#
# All changes must be explicitly discussed with the L1T offline coordinator.
#
import FWCore.ParameterSet.Config as cms
from Configuration.StandardSequences.Eras import eras

#
# Stage-2 Trigger
#
if eras.stage2L1Trigger.isChosen():
#
# -  Global Trigger emulator
#
    print "L1TGlobal Sequence configured for Stage-2 (2016) trigger. "
    from L1Trigger.L1TGlobal.simGtStage2Digis_cfi import *
    SimL1TGlobal = cms.Sequence(simGtStage2Digis)

cat L1Trigger/L1TGlobal/python/simGtStage2Digis_cfi.py

#
# WARNING: This file is in the L1T configuration critical path.
#
# All changes must be explicitly discussed with the L1T offline coordinator.
#
import FWCore.ParameterSet.Config as cms

# cfi uGT emulator

simGtStage2Digis = cms.EDProducer("L1TGlobalProducer",
    MuonInputTag = cms.InputTag("simGmtStage2Digis"),
    ExtInputTag = cms.InputTag("none"),
    EGammaInputTag = cms.InputTag("simCaloStage2Digis"),
    TauInputTag = cms.InputTag("simCaloStage2Digis"),
    JetInputTag = cms.InputTag("simCaloStage2Digis"),
    EtSumInputTag = cms.InputTag("simCaloStage2Digis"),
    AlgorithmTriggersUnmasked = cms.bool(False),    
    AlgorithmTriggersUnprescaled = cms.bool(False),
)

@rekovic
Copy link
Owner Author

rekovic commented Mar 24, 2016

PACKERS of caloStage2, gmtStage2, gtStage2

cat EventFilter/L1TRawToDigi/python/caloStage2Raw_cfi.py

import FWCore.ParameterSet.Config as cms

caloStage2Raw = cms.EDProducer(
    "L1TDigiToRaw",
    Setup = cms.string("stage2::CaloSetup"),
    TowerInputLabel = cms.InputTag("simCaloStage2Layer1Digis"),
    InputLabel = cms.InputTag("simCaloStage2Digis"),
    FedId = cms.int32(1366),
    FWId = cms.uint32(1),
    lenSlinkHeader = cms.untracked.int32(8),
    lenSlinkTrailer = cms.untracked.int32(8)
)

cat EventFilter/L1TRawToDigi/python/gmtStage2Raw_cfi.py

import FWCore.ParameterSet.Config as cms

gmtStage2Raw = cms.EDProducer(
    "L1TDigiToRaw",
    Setup = cms.string("stage2::GMTSetup"),
    InputLabel = cms.InputTag("simGmtStage2Digis"),
    BMTFInputLabel = cms.InputTag("simBmtfDigis", "BMTF"),
    OMTFInputLabel = cms.InputTag("simOmtfDigis", "OMTF"),
    EMTFInputLabel = cms.InputTag("simEmtfDigis", "EMTF"),
    FedId = cms.int32(1402),
    FWId = cms.uint32(1),
    lenSlinkHeader = cms.untracked.int32(8),
    lenSlinkTrailer = cms.untracked.int32(8)
)

cat EventFilter/L1TRawToDigi/python/gtStage2Raw_cfi.py

import FWCore.ParameterSet.Config as cms

gtStage2Raw = cms.EDProducer(
    "L1TDigiToRaw",
    Setup = cms.string("stage2::GTSetup"),
#    TowerInputLabel = cms.InputTag("simCaloStage2Digis"),
    InputLabel = cms.InputTag("simGtStage2Digis"),
    FedId = cms.int32(1404),
    FWId = cms.uint32(1),
    lenSlinkHeader = cms.untracked.int32(8),
    lenSlinkTrailer = cms.untracked.int32(8)
)

@rekovic
Copy link
Owner Author

rekovic commented Mar 24, 2016

An example how to run from RAW (i.e. GEN-SIM-DIGI-RAW-HLTDEBUG)

cmsDriver.py test_mc_RAW2DIGI -s RAW2DIGI --era=Run2_2016 -n 200 --mc --no_exec --no_output 
--conditions=80X_mcRun2_asymptotic_v6 
--customise=L1Trigger/Configuration/customiseReEmul.L1TReEmulFromRAW  
--customise=L1Trigger/Configuration/customiseUtils.L1TTurnOffUnpackStage2GtGmtAndCalo 
--filein=/store/relval/CMSSW_7_6_3_patch2/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PUpmx25ns_76X_mcRun2_asymptotic_v12-v1/10000/0EC8A075-BFDF-E511-B513-0CC47A4C8F08.root --geometry=Extended2016,Extended2016Reco

code snipet from L1Trigger/Configuration/customiseReEmul.py

def L1TReEmulFromRAW(process):
    process.load('L1Trigger.Configuration.SimL1Emulator_cff')
    process.load('L1Trigger.Configuration.CaloTriggerPrimitives_cff')
    process.simEcalTriggerPrimitiveDigis.Label = 'ecalDigis'
    process.simHcalTriggerPrimitiveDigis.inputLabel = cms.VInputTag(
        cms.InputTag('hcalDigis'),
        cms.InputTag('hcalDigis')
    )
    process.L1TReEmul = cms.Sequence(process.simHcalTriggerPrimitiveDigis * process.SimL1Emulator)
    process.simDtTriggerPrimitiveDigis.digiTag = 'muonDTDigis'
    process.simCscTriggerPrimitiveDigis.CSCComparatorDigiProducer = cms.InputTag( 'muonCSCDigis', 'MuonCSCComparatorDigi')
    process.simCscTriggerPrimitiveDigis.CSCWireDigiProducer       = cms.InputTag( 'muonCSCDigis', 'MuonCSCWireDigi' )

    if eras.stage2L1Trigger.isChosen(): 
        process.simTwinMuxDigis.RPC_Source         = cms.InputTag('muonRPCDigis')
        # When available, this will switch to TwinMux input Digis:
        process.simTwinMuxDigis.DTDigi_Source      = cms.InputTag("dttfDigis")
        process.simTwinMuxDigis.DTThetaDigi_Source = cms.InputTag("dttfDigis")
        process.simOmtfDigis.srcRPC                = cms.InputTag('muonRPCDigis')
        process.simBmtfDigis.DTDigi_Source         = cms.InputTag("simTwinMuxDigis")
        process.simBmtfDigis.DTDigi_Theta_Source   = cms.InputTag("dttfDigis")
        process.simCaloStage2Layer1Digis.ecalToken = cms.InputTag("ecalDigis:EcalTriggerPrimitives")
        process.L1TReEmulPath = cms.Path(process.L1TReEmul)
        process.schedule.append(process.L1TReEmulPath)
        print "L1TReEmul sequence:  "
        print process.L1TReEmul
        print process.schedule
        return process

code snipet from L1Trigger/Configuration/customiseUtils.py

# Unpack Stage-2 GT and GMT
def L1TTurnOffUnpackStage2GtGmtAndCalo(process):
    cutlist=['gtStage2Digis','gmtStage2Digis','caloStage2Digis']
    for b in cutlist:
        process.L1TRawToDigi.remove(getattr(process,b))
    return process

@rekovic rekovic changed the title Test syntax Configuration of L1 REPACK Apr 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant