Beispiel #1
0
def LArOFCCondAlgCfg(flags, name='LArOFCCondAlg', **kwargs):

    mlog = logging.getLogger('LArOFCCondAlgCfg')
    mlog.info(" entering LArOFCCondAlgCfg")

    kwargs.setdefault('isMC', True)
    kwargs.setdefault('firstSample', flags.LAr.ROD.FirstSample)
    kwargs.setdefault('useHighestGainAutoCorr',
                      flags.LAr.ROD.UseHighestGainAutoCorr)

    if flags.LAr.ROD.DoOFCPileupOptimization:
        if flags.LAr.ROD.NumberOfCollisions:
            kwargs.setdefault('Nminbias', flags.LAr.ROD.NumberOfCollisions)
            mlog.info("Setup LArOFCCOndAlg Nminbias %f ",
                      flags.LAr.ROD.NumberOfCollisions)
        else:
            kwargs.setdefault('Nminbias', flags.Beam.NumberOfCollisions)
            mlog.info("Setup LArOFCCOndAlg Nminbias %f ",
                      flags.Beam.NumberOfCollisions)
    else:
        kwargs.setdefault('Nminbias', 0.)
        mlog.info(" no pileup optimization")

    #The LArPileUpTool needs: Calbling, Shape, Noise, Pedestal and the (total) AutoCorr
    acc = LArOnOffIdMappingCfg(flags)
    requiredConditons = ["Shape", "Noise", "Pedestal"]
    acc.merge(LArElecCalibDbCfg(flags, requiredConditons))
    acc.merge(LArAutoCorrTotalCondAlgCfg(flags))
    LArOFCCondAlg = CompFactory.LArOFCCondAlg
    acc.addCondAlgo(LArOFCCondAlg(name, **kwargs))
    return acc
Beispiel #2
0
def LArRawChannelBuilderAlgCfg(configFlags, **kwargs):

    acc = LArADC2MeVCondAlgCfg(configFlags)

    kwargs.setdefault("name", "LArRawChannelBuilder")
    kwargs.setdefault("firstSample", configFlags.LAr.ROD.FirstSample)
    if configFlags.Input.isMC:
        # need OFC configuration, which includes appropriate ElecCalibDb
        acc.merge(LArOFCCondAlgCfg(configFlags))
        kwargs.setdefault("LArRawChannelKey", "LArRawChannels")
        kwargs.setdefault("ShapeKey", "LArShapeSym")
        if configFlags.Digitization.PileUpPremixing:
            kwargs.setdefault(
                "LArDigitKey",
                configFlags.Overlay.BkgPrefix() + "LArDigitContainer_MC")
        else:
            kwargs.setdefault("LArDigitKey", "LArDigitContainer_MC")
    else:
        acc.merge(LArElecCalibDbCfg(configFlags, ("OFC", "Shape", "Pedestal")))
        if configFlags.Overlay.DataOverlay:
            kwargs.setdefault("LArDigitKey", "LArDigitContainer_MC")
            kwargs.setdefault("LArRawChannelKey", "LArRawChannels")
        else:
            kwargs.setdefault("LArRawChannelKey", "LArRawChannels_FromDigits")

    acc.addEventAlgo(LArRawChannelBuilderAlg(**kwargs))

    return acc
Beispiel #3
0
def LArAutoCorrNoiseCondAlgCfg(flags,
                               name="LArAutoCorrNoiseCondAlg",
                               **kwargs):
    """Return ComponentAccumulator with configured LArAutoCorrNoiseCondAlg"""

    LArAutoCorrNoiseCondAlg = CompFactory.LArAutoCorrNoiseCondAlg
    # The LArAutoCorrNoiseCondAlgCfg needs the cabling, the sym-object and the AutoCorr
    acc = LArOnOffIdMappingCfg(flags)
    acc.merge(LArMCSymCondAlgCfg(flags))
    acc.merge(LArElecCalibDbCfg(flags, [
        "AutoCorr",
    ]))
    kwargs.setdefault("nSampl", flags.LAr.ROD.nSamples)
    acc.addCondAlgo(LArAutoCorrNoiseCondAlg(name, **kwargs))
    return acc
Beispiel #4
0
def LArADC2MeVCondAlgCfg(configFlags):
    from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
    from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDbCfg
    from LArGeoAlgsNV.LArGMConfig import LArGMCfg

    result = ComponentAccumulator()
    result.merge(LArOnOffIdMappingCfg(configFlags))
    result.merge(LArGMCfg(configFlags))  #Needed for identifier helpers

    theADC2MeVCondAlg = CompFactory.LArADC2MeVCondAlg(
        LArADC2MeVKey='LArADC2MeV')

    isMC = configFlags.Input.isMC

    if isMC:
        requiredConditions = [
            "Ramp", "DAC2uA", "uA2MeV", "MphysOverMcal", "HVScaleCorr"
        ]
        theADC2MeVCondAlg.LAruA2MeVKey = "LAruA2MeVSym"
        theADC2MeVCondAlg.LArDAC2uAKey = "LArDAC2uASym"
        theADC2MeVCondAlg.LArRampKey = "LArRampSym"
        theADC2MeVCondAlg.LArMphysOverMcalKey = "LArMphysOverMcalSym"
        theADC2MeVCondAlg.LArHVScaleCorrKey = "LArHVScaleCorr"
        theADC2MeVCondAlg.UseFEBGainTresholds = False
    else:  # not MC:
        requiredConditions = [
            "Ramp", "DAC2uA", "uA2MeV", "MphysOverMcal", "HVScaleCorr"
        ]
        from LArRecUtils.LArFebConfigCondAlgConfig import LArFebConfigCondAlgCfg
        if 'COMP200' in configFlags.IOVDb.DatabaseInstance:  # Run1 case
            theADC2MeVCondAlg.LAruA2MeVKey = "LAruA2MeVSym"
            theADC2MeVCondAlg.LArDAC2uAKey = "LArDAC2uASym"
        result.merge(LArFebConfigCondAlgCfg(configFlags))

    result.merge(LArElecCalibDbCfg(configFlags, requiredConditions))
    result.addCondAlgo(theADC2MeVCondAlg, primary=True)
    return result
Beispiel #5
0
def LArAutoCorrTotalCondAlgCfg(flags,
                               name='LArAutoCorrTotalCondAlg',
                               **kwargs):
    mlog = logging.getLogger('LArAutoCorrTotalCondAlgCfg')
    mlog.info(" entering LArAutoCorrTotalCondAlgCfg")
    from AthenaCommon.SystemOfUnits import ns

    kwargs.setdefault('Nsamples', flags.LAr.ROD.nSamples)
    kwargs.setdefault('firstSample', flags.LAr.ROD.FirstSample)
    mlog.info("Nsamples %d", flags.LAr.ROD.nSamples)
    mlog.info("firstSample %d", flags.LAr.ROD.FirstSample)
    deltaBunch = int(flags.Beam.BunchSpacing / (25. * ns) + 0.5)
    mlog.info("DeltaBunch %d ", deltaBunch)
    kwargs.setdefault('deltaBunch', deltaBunch)

    if flags.LAr.ROD.DoOFCPileupOptimization:
        if flags.LAr.ROD.NumberOfCollisions:
            kwargs.setdefault("Nminbias", flags.LAr.ROD.NumberOfCollisions)
            mlog.info(" NMminBias %f", flags.LAr.ROD.NumberOfCollisions)
        else:
            kwargs.setdefault("Nminbias", flags.Beam.NumberOfCollisions)
            mlog.info(" NMminBias %f", flags.Beam.NumberOfCollisions)
    else:
        kwargs.setdefault('Nminbias', 0.)
        mlog.info(" no pileup noise in LArAutoCorrTotal ")

    #The LArAutoCorrTotalAlg needs cabling and
    #Shape, AutoCorr, Noise, Pedestal, fSampl and MinBias
    acc = LArOnOffIdMappingCfg(flags)
    requiredConditons = [
        "Shape", "AutoCorr", "Noise", "Pedestal", "fSampl", "MinBias"
    ]
    acc.merge(LArElecCalibDbCfg(flags, requiredConditons))
    LArAutoCorrTotalCondAlg = CompFactory.LArAutoCorrTotalCondAlg
    acc.addCondAlgo(LArAutoCorrTotalCondAlg(name, **kwargs))
    return acc
Beispiel #6
0
def LArPileUpToolCfg(flags, name="LArPileUpTool", **kwargs):
    """Return ComponentAccumulator with configured LArPileUpTool"""
    acc = LArGMCfg(flags)

    #The LArPileupTool needs: Noise, fSampl, Pedestal,Shape ADC2MeV
    # AutoCorrNoise, the list of bad FEBs and the cabling
    acc.merge(LArADC2MeVCondAlgCfg(flags))
    acc.merge(LArBadFebCfg(flags))
    if flags.Overlay.DataOverlay:
        kwargs.setdefault("ShapeKey", "LArShape")
    if not flags.Digitization.DoCaloNoise:
        requiredConditons = ["fSampl", "Pedestal", "Shape"]
    else:
        requiredConditons = ["Noise", "fSampl", "Pedestal", "Shape"]
    acc.merge(LArElecCalibDbCfg(flags, requiredConditons))

    if not flags.Detector.OverlayLAr:
        acc.merge(LArAutoCorrNoiseCondAlgCfg(flags))
    if "MaskingTool" not in kwargs:
        maskerTool = acc.popToolsAndMerge(
            LArBadChannelMaskerCfg(flags, ["deadReadout", "deadPhys"],
                                   ToolName="LArRCBMasker"))
        kwargs["MaskingTool"] = maskerTool
    # defaults
    kwargs.setdefault("NoiseOnOff", flags.Digitization.DoCaloNoise)
    kwargs.setdefault("DoDigiTruthReconstruction",
                      flags.Digitization.DoDigiTruth)
    if flags.Digitization.DoXingByXingPileUp:
        kwargs.setdefault("FirstXing", -751)
        kwargs.setdefault("LastXing", 101)
    if (not flags.Digitization.HighGainFCal) and (
            not flags.Detector.OverlayLAr):
        kwargs.setdefault("HighGainThreshFCAL", 0)
    if (not flags.Digitization.HighGainEMECIW) and (
            not flags.Detector.OverlayLAr):
        kwargs.setdefault("HighGainThreshEMECIW", 0)
    kwargs.setdefault("RndmEvtOverlay", flags.Detector.OverlayLAr)
    if flags.Digitization.PileUpPremixing:
        kwargs.setdefault("DigitContainer",
                          flags.Overlay.BkgPrefix + "LArDigitContainer_MC")
    else:
        kwargs.setdefault(
            "DigitContainer",
            "LArDigitContainer_MC")  # FIXME - should not be hard-coded
    # if doing MC+MC overlay
    if flags.Input.isMC and flags.Detector.OverlayLAr:
        kwargs.setdefault("isMcOverlay", True)
    kwargs.setdefault("Nsamples", flags.LAr.ROD.nSamples)
    kwargs.setdefault("firstSample", flags.LAr.ROD.FirstSample)
    # cosmics digitization
    if flags.Beam.Type == "cosmics":
        kwargs.setdefault("UseTriggerTime", True)
        CosmicTriggerTimeTool = CompFactory.CosmicTriggerTimeTool
        kwargs.setdefault("TriggerTimeToolName", CosmicTriggerTimeTool())
    # pileup configuration "algorithm" way
    if not flags.Digitization.DoXingByXingPileUp:
        if flags.Digitization.Pileup or flags.Detector.OverlayLAr:
            kwargs.setdefault("PileUp", True)
    kwargs.setdefault("useLArFloat", useLArFloat(flags))
    if useLArFloat(flags):
        maps = [
            "LArHitContainer#LArHitEMB->LArHitFloatContainer#LArHitEMB",
            "LArHitContainer#LArHitEMEC->LArHitFloatContainer#LArHitEMEC",
            "LArHitContainer#LArHitHEC->LArHitFloatContainer#LArHitHEC",
            "LArHitContainer#LArHitFCAL->LArHitFloatContainer#LArHitFCAL"
        ]
        AddressRemappingSvc, ProxyProviderSvc = CompFactory.getComps(
            "AddressRemappingSvc",
            "ProxyProviderSvc",
        )
        acc.addService(
            AddressRemappingSvc(TypeKeyOverwriteMaps=maps,
                                ProxyDict="ActiveStoreSvc"))
        acc.addService(ProxyProviderSvc(ProviderNames=["AddressRemappingSvc"]))
        kwargs.setdefault("LArHitContainers", [])
    else:
        kwargs.setdefault("LArHitFloatContainers", [])
    if flags.Detector.OverlayLAr:
        kwargs.setdefault("OnlyUseContainerName", False)
        if flags.Overlay.DataOverlay:
            kwargs.setdefault("InputDigitContainer",
                              flags.Overlay.BkgPrefix + "FREE")
        else:
            kwargs.setdefault("InputDigitContainer",
                              flags.Overlay.BkgPrefix + "LArDigitContainer_MC")
    LArPileUpTool = CompFactory.LArPileUpTool
    acc.setPrivateTools(LArPileUpTool(name, **kwargs))
    return acc
Beispiel #7
0
def LArHVScaleCfg(configFlags):
    result = ComponentAccumulator()

    from IOVDbSvc.IOVDbSvcConfig import addFolders
    #result.merge(IOVDbSvcCfg(configFlags))

    if configFlags.Input.isMC:
        result.merge(
            addFolders(configFlags, [
                "/LAR/Identifier/HVLineToElectrodeMap<tag>LARHVLineToElectrodeMap-001</tag>"
            ],
                       "LAR_OFL",
                       className="AthenaAttributeList"))

        LArHVIdMappingAlg = CompFactory.LArHVIdMappingAlg
        hvmapalg = LArHVIdMappingAlg(
            ReadKey="/LAR/Identifier/HVLineToElectrodeMap",
            WriteKey="LArHVIdMap")
        result.addCondAlgo(hvmapalg)

    elif not configFlags.Common.isOnline:
        result.merge(
            addFolders(configFlags, ["/LAR/DCS/HV/BARREl/I16"],
                       "DCS_OFL",
                       className="CondAttrListCollection"))
        result.merge(
            addFolders(configFlags, ["/LAR/DCS/HV/BARREL/I8"],
                       "DCS_OFL",
                       className="CondAttrListCollection"))

        result.merge(
            addFolders(configFlags,
                       ["/LAR/IdentifierOfl/HVLineToElectrodeMap"],
                       "LAR_OFL",
                       className="AthenaAttributeList"))
        result.merge(
            addFolders(configFlags, ["/LAR/HVPathologiesOfl/Pathologies"],
                       "LAR_OFL",
                       className="AthenaAttributeList"))

        from LArBadChannelTool.LArBadChannelConfig import LArBadChannelCfg, LArBadFebCfg
        result.merge(LArBadChannelCfg(configFlags))
        result.merge(LArBadFebCfg(configFlags))

        LArHVIdMappingAlg = CompFactory.LArHVIdMappingAlg
        hvmapalg = LArHVIdMappingAlg(
            ReadKey="/LAR/IdentifierOfl/HVLineToElectrodeMap",
            WriteKey="LArHVIdMap")
        result.addCondAlgo(hvmapalg)

        LArHVPathologyDbCondAlg = CompFactory.LArHVPathologyDbCondAlg
        hvpath = LArHVPathologyDbCondAlg(
            PathologyFolder="/LAR/HVPathologiesOfl/Pathologies",
            HVMappingKey="LArHVIdMap",
            HVPAthologyKey="LArHVPathology")
        result.addCondAlgo(hvpath)

        LArHVCondAlg = CompFactory.LArHVCondAlg
        hvcond = LArHVCondAlg("LArHVPathologyAlg",
                              HVPathologies="LArHVPathology",
                              OutputHVData="LArHVData")
        result.addCondAlgo(hvcond)

        from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDbCfg
        result.merge(LArElecCalibDbCfg(configFlags, [
            "HVScaleCorr",
        ]))

        LArHVScaleCorrCondAlg = CompFactory.LArHVScaleCorrCondAlg
        hvscalecorrkey = "LArHVScaleCorrRecomputed"
        if configFlags.Input.isMC:
            hvscalecorrkey = "LArHVScaleCorr"

        hvscale = LArHVScaleCorrCondAlg(keyHVdata="LArHVData",
                                        keyOutputCorr=hvscalecorrkey)
        hvscale.UndoOnlineHVCorr = True
        result.addCondAlgo(hvscale)

    return result