Exemplo n.º 1
0
def customiseEcalLocalReconstruction(process):

    hasHLTEcalPreshowerSeq = any(seq in process.__dict__ for seq in [
        'HLTDoFullUnpackingEgammaEcalMFSequence',
        'HLTDoFullUnpackingEgammaEcalSequence'
    ])
    if not (hasHLTEcalPreshowerSeq
            or 'HLTDoFullUnpackingEgammaEcalWithoutPreshowerSequence'
            in process.__dict__):
        return process

    # FIXME replace the Sequences with empty ones to avoid expanding them during the (re)definition of Modules and EDAliases

    process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerSequence = cms.Sequence(
    )
    if hasHLTEcalPreshowerSeq:
        process.HLTDoFullUnpackingEgammaEcalMFSequence = cms.Sequence()
        process.HLTDoFullUnpackingEgammaEcalSequence = cms.Sequence()

    # Event Setup

    process.load(
        "EventFilter.EcalRawToDigi.ecalElectronicsMappingGPUESProducer_cfi")
    process.load(
        "RecoLocalCalo.EcalRecProducers.ecalGainRatiosGPUESProducer_cfi")
    process.load(
        "RecoLocalCalo.EcalRecProducers.ecalPedestalsGPUESProducer_cfi")
    process.load(
        "RecoLocalCalo.EcalRecProducers.ecalPulseCovariancesGPUESProducer_cfi")
    process.load(
        "RecoLocalCalo.EcalRecProducers.ecalPulseShapesGPUESProducer_cfi")
    process.load(
        "RecoLocalCalo.EcalRecProducers.ecalSamplesCorrelationGPUESProducer_cfi"
    )
    process.load(
        "RecoLocalCalo.EcalRecProducers.ecalTimeBiasCorrectionsGPUESProducer_cfi"
    )
    process.load(
        "RecoLocalCalo.EcalRecProducers.ecalTimeCalibConstantsGPUESProducer_cfi"
    )
    process.load(
        "RecoLocalCalo.EcalRecProducers.ecalMultifitParametersGPUESProducer_cfi"
    )

    process.load(
        "RecoLocalCalo.EcalRecProducers.ecalRechitADCToGeVConstantGPUESProducer_cfi"
    )
    process.load(
        "RecoLocalCalo.EcalRecProducers.ecalRechitChannelStatusGPUESProducer_cfi"
    )
    process.load(
        "RecoLocalCalo.EcalRecProducers.ecalIntercalibConstantsGPUESProducer_cfi"
    )
    process.load(
        "RecoLocalCalo.EcalRecProducers.ecalLaserAPDPNRatiosGPUESProducer_cfi")
    process.load(
        "RecoLocalCalo.EcalRecProducers.ecalLaserAPDPNRatiosRefGPUESProducer_cfi"
    )
    process.load(
        "RecoLocalCalo.EcalRecProducers.ecalLaserAlphasGPUESProducer_cfi")
    process.load(
        "RecoLocalCalo.EcalRecProducers.ecalLinearCorrectionsGPUESProducer_cfi"
    )
    process.load(
        "RecoLocalCalo.EcalRecProducers.ecalRecHitParametersGPUESProducer_cfi")

    # Modules and EDAliases

    # ECAL unpacker running on gpu
    from EventFilter.EcalRawToDigi.ecalRawToDigiGPU_cfi import ecalRawToDigiGPU as _ecalRawToDigiGPU
    process.hltEcalDigisGPU = _ecalRawToDigiGPU.clone()

    # SwitchProducer wrapping the legacy ECAL unpacker or the ECAL digi converter from SoA format on gpu to legacy format on cpu
    process.hltEcalDigisLegacy = process.hltEcalDigis.clone()
    from EventFilter.EcalRawToDigi.ecalCPUDigisProducer_cfi import ecalCPUDigisProducer as _ecalCPUDigisProducer

    process.hltEcalDigis = SwitchProducerCUDA(
        # legacy producer
        cpu=cms.EDAlias(hltEcalDigisLegacy=cms.VPSet(
            cms.PSet(type=cms.string("EBDigiCollection")),
            cms.PSet(type=cms.string("EEDigiCollection")),
            cms.PSet(type=cms.string("EBDetIdedmEDCollection")),
            cms.PSet(type=cms.string("EEDetIdedmEDCollection")),
            cms.PSet(type=cms.string("EBSrFlagsSorted")),
            cms.PSet(type=cms.string("EESrFlagsSorted")),
            cms.PSet(type=cms.string("EcalElectronicsIdedmEDCollection"),
                     fromProductInstance=cms.string(
                         "EcalIntegrityBlockSizeErrors")),
            cms.PSet(type=cms.string("EcalElectronicsIdedmEDCollection"),
                     fromProductInstance=cms.string(
                         "EcalIntegrityTTIdErrors")),
            cms.PSet(type=cms.string("EcalElectronicsIdedmEDCollection"),
                     fromProductInstance=cms.string(
                         "EcalIntegrityZSXtalIdErrors")),
            cms.PSet(type=cms.string("EcalPnDiodeDigisSorted")),
            cms.PSet(type=cms.string("EcalPseudoStripInputDigisSorted"),
                     fromProductInstance=cms.string("EcalPseudoStripInputs")),
            cms.PSet(type=cms.string("EcalTriggerPrimitiveDigisSorted"),
                     fromProductInstance=cms.string("EcalTriggerPrimitives")),
        )),
        # convert ECAL digis from SoA format on gpu to legacy format on cpu
        cuda=_ecalCPUDigisProducer.clone(
            digisInLabelEB=("hltEcalDigisGPU", "ebDigis"),
            digisInLabelEE=("hltEcalDigisGPU", "eeDigis"),
            produceDummyIntegrityCollections=cms.bool(True)))

    # ECAL multifit running on gpu
    from RecoLocalCalo.EcalRecProducers.ecalUncalibRecHitProducerGPU_cfi import ecalUncalibRecHitProducerGPU as _ecalUncalibRecHitProducerGPU
    process.hltEcalUncalibRecHitGPU = _ecalUncalibRecHitProducerGPU.clone(
        digisLabelEB=("hltEcalDigisGPU", "ebDigis"),
        digisLabelEE=("hltEcalDigisGPU", "eeDigis"),
        shouldRunTimingComputation=False)

    # copy the ECAL uncalibrated rechits from gpu to cpu in SoA format
    from RecoLocalCalo.EcalRecProducers.ecalCPUUncalibRecHitProducer_cfi import ecalCPUUncalibRecHitProducer as _ecalCPUUncalibRecHitProducer
    process.hltEcalUncalibRecHitSoA = _ecalCPUUncalibRecHitProducer.clone(
        recHitsInLabelEB=("hltEcalUncalibRecHitGPU", "EcalUncalibRecHitsEB"),
        recHitsInLabelEE=("hltEcalUncalibRecHitGPU", "EcalUncalibRecHitsEE"),
    )

    # SwitchProducer wrapping the legacy ECAL uncalibrated rechits producer or a converter from SoA to legacy format
    from RecoLocalCalo.EcalRecProducers.ecalUncalibRecHitConvertGPU2CPUFormat_cfi import ecalUncalibRecHitConvertGPU2CPUFormat as _ecalUncalibRecHitConvertGPU2CPUFormat
    process.hltEcalUncalibRecHit = SwitchProducerCUDA(
        # legacy producer
        cpu=process.hltEcalUncalibRecHit,
        # convert the ECAL uncalibrated rechits from SoA to legacy format
        cuda=_ecalUncalibRecHitConvertGPU2CPUFormat.clone(
            recHitsLabelGPUEB=("hltEcalUncalibRecHitSoA",
                               "EcalUncalibRecHitsEB"),
            recHitsLabelGPUEE=("hltEcalUncalibRecHitSoA",
                               "EcalUncalibRecHitsEE"),
        ))

    # Reconstructing the ECAL calibrated rechits on gpu works, but is extremely slow.
    # Disable it for the time being, until the performance has been addressed.
    """
    from RecoLocalCalo.EcalRecProducers.ecalRecHitGPU_cfi import ecalRecHitGPU as _ecalRecHitGPU
    process.hltEcalRecHitGPU = _ecalRecHitGPU.clone(
        uncalibrecHitsInLabelEB = ("hltEcalUncalibRecHitGPU","EcalUncalibRecHitsEB"),
        uncalibrecHitsInLabelEE = ("hltEcalUncalibRecHitGPU","EcalUncalibRecHitsEE"),
    )

    from RecoLocalCalo.EcalRecProducers.ecalCPURecHitProducer_cfi import ecalCPURecHitProducer as _ecalCPURecHitProducer
    process.hltEcalRecHitSoA = _ecalCPURecHitProducer.clone(
        recHitsInLabelEB = ("hltEcalRecHitGPU", "EcalRecHitsEB"),
        recHitsInLabelEE = ("hltEcalRecHitGPU", "EcalRecHitsEE"),
    )

    # SwitchProducer wrapping the legacy ECAL calibrated rechits producer or a converter from SoA to legacy format
    from RecoLocalCalo.EcalRecProducers.ecalRecHitConvertGPU2CPUFormat_cfi import ecalRecHitConvertGPU2CPUFormat as _ecalRecHitConvertGPU2CPUFormat
    process.hltEcalRecHit = SwitchProducerCUDA(
        # legacy producer
        cpu = process.hltEcalRecHit,
        # convert the ECAL calibrated rechits from SoA to legacy format
        cuda = _ecalRecHitConvertGPU2CPUFormat.clone(
            recHitsLabelGPUEB = ("hltEcalRecHitSoA", "EcalRecHitsEB"),
            recHitsLabelGPUEE = ("hltEcalRecHitSoA", "EcalRecHitsEE"),
        )
    )
    """

    # SwitchProducer wrapping the legacy ECAL rechits producer
    # the gpu unpacker does not produce the TPs used for the recovery, so the SwitchProducer alias does not provide them:
    #   - the cpu uncalibrated rechit producer may mark them for recovery, read the TPs explicitly from the legacy unpacker
    #   - the gpu uncalibrated rechit producer does not flag them for recovery, so the TPs are not necessary
    process.hltEcalRecHit = SwitchProducerCUDA(
        cpu=process.hltEcalRecHit.clone(
            triggerPrimitiveDigiCollection=('hltEcalDigisLegacy',
                                            'EcalTriggerPrimitives')),
        cuda=process.hltEcalRecHit.clone(
            triggerPrimitiveDigiCollection='unused'))

    # Tasks and Sequences

    process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerTask = cms.Task(
        process.hltEcalDigisGPU,  # unpack ECAL digis on gpu
        process.
        hltEcalDigisLegacy,  # legacy producer, referenced in the SwitchProducer
        process.hltEcalDigis,  # SwitchProducer
        process.
        hltEcalUncalibRecHitGPU,  # run ECAL local reconstruction and multifit on gpu
        process.
        hltEcalUncalibRecHitSoA,  # needed by hltEcalPhiSymFilter - copy to host
        process.
        hltEcalUncalibRecHit,  # needed by hltEcalPhiSymFilter - convert to legacy format
        # process.hltEcalRecHitGPU,                           # make ECAL calibrated rechits on gpu
        # process.hltEcalRecHitSoA,                           # copy to host
        process.hltEcalDetIdToBeRecovered,  # legacy producer
        process.hltEcalRecHit)  # legacy producer

    process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerSequence = cms.Sequence(
        process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerTask)

    if hasHLTEcalPreshowerSeq:
        process.HLTPreshowerTask = cms.Task(
            process.
            hltEcalPreshowerDigis,  # unpack ECAL preshower digis on the host
            process.hltEcalPreshowerRecHit
        )  # build ECAL preshower rechits on the host

        process.HLTPreshowerSequence = cms.Sequence(process.HLTPreshowerTask)

        process.HLTDoFullUnpackingEgammaEcalTask = cms.Task(
            process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerTask,
            process.HLTPreshowerTask)

        process.HLTDoFullUnpackingEgammaEcalSequence = cms.Sequence(
            process.HLTDoFullUnpackingEgammaEcalTask)

        process.HLTDoFullUnpackingEgammaEcalMFSequence = cms.Sequence(
            process.HLTDoFullUnpackingEgammaEcalTask)

    # done
    return process
Exemplo n.º 2
0
# ECAL conditions used by the unpacker running on GPU
from EventFilter.EcalRawToDigi.ecalElectronicsMappingGPUESProducer_cfi import ecalElectronicsMappingGPUESProducer

# ECAL unpacker running on GPU
from EventFilter.EcalRawToDigi.ecalRawToDigiGPU_cfi import ecalRawToDigiGPU as _ecalRawToDigiGPU
ecalDigisGPU = _ecalRawToDigiGPU.clone()

# disable the ECAL unpacker collections that are not available in the GPU unpacker
gpu.toModify(ecalDigis.cpu, headerUnpacking=False, memUnpacking=False)

# extend the SwitchProducer to add a case to copy the ECAL digis from GPU to CPU and covert them from SoA to legacy format
from EventFilter.EcalRawToDigi.ecalCPUDigisProducer_cfi import ecalCPUDigisProducer as _ecalCPUDigisProducer
gpu.toModify(
    ecalDigis,
    # copy the ECAL digis from GPU to CPU and covert them from SoA to legacy format
    cuda=_ecalCPUDigisProducer.clone(digisInLabelEB=('ecalDigisGPU',
                                                     'ebDigis'),
                                     digisInLabelEE=('ecalDigisGPU',
                                                     'eeDigis'),
                                     produceDummyIntegrityCollections=True))

gpu.toReplaceWith(
    ecalDigisTask,
    cms.Task(
        # ECAL conditions used by the unpacker running on GPU
        ecalElectronicsMappingGPUESProducer,
        # run the ECAL unpacker on GPU
        ecalDigisGPU,
        # run the ECAL unpacker on CPU, or copy the ECAL digis from GPU to CPU and covert them from SoA to legacy format
        ecalDigis))