LArPhysOFCAlg.DecoderTool = theLArPhysAutoCorrDecoderTool
    else:
        LArPhysOFCAlg.DecoderTool = theLArAutoCorrDecoderTool

    if len(ofcdef.PhysAutoCorr) == 2:  #Second OFC flavor defined
        LArPhysOFCAlg.ComputeOFCV2 = True
        LArPhysOFCAlg.UseDeltaV2 = ofcdef.useDelta[1]
        LArPhysOFCAlg.KeyOFCV2 = ofcdef.KeyOFC[1]
        if ofcdef.PhysAutoCorr[1]:
            LArPhysOFCAlg.DecoderToolV2 = theLArPhysAutoCorrDecoderTool
        else:
            LArPhysOFCAlg.DecoderToolV2 = theLArAutoCorrDecoderTool

    if ofcdef.Nsamples == 4:
        LArPhysOFCAlg.ReadDSPConfig = ofcdef.ReadDSPConfig
        LArPhysOFCAlg.DSPConfigFolder = ofcdef.DSPConfigFolder
        conddb.addFolder("LAR_ONL", "/LAR/Configuration/DSPConfiguration")
        #conddb.addFolder("","<db>sqlite://;schema=/afs/cern.ch/atlas/maxidisk/d20/Automation/AtlasProduction-20.1.0.2/run/dspconfig_std.db;dbname=CONDBR2</db>/LAR/Configuration/DSPConfiguration")
        #conddb.addFolder("","<db>sqlite://;schema=/afs/cern.ch/atlas/maxidisk/d20/Automation/AtlasProduction-20.1.0.2/run/dspconfig_run1.db;dbname=CONDBR2</db>/LAR/Configuration/DSPConfiguration")

    LArPhysOFCAlg.OutputLevel = WARNING

    topSequence += LArPhysOFCAlg

    LArOFPhasePick = LArOFPhasePicker(ofcdef.Algoname + "Picker")
    LArOFPhasePick.KeyPhase = ""
    LArOFPhasePick.KeyOFC = ofcdef.KeyOFC[0]
    LArOFPhasePick.KeyOFC_new = ofcdef.KeyOFC[0] + "_picked"
    LArOFPhasePick.KeyShape = ofcdef.KeyShape
    LArOFPhasePick.KeyShape_new = ofcdef.KeyShape + "_picked"
    #LArOFPhasePick.OutputLevel=VERBOSE
LArPhysOFCAlg.Ndelay = Ndelays
LArPhysOFCAlg.Nsample = Nsamples
LArPhysOFCAlg.FillShape = FillShape
LArPhysOFCAlg.TimeShift = TimeShift
LArPhysOFCAlg.TimeShiftByIndex = TimeShiftByIndex
LArPhysOFCAlg.AddTimeOffset = -1.0 * TimeShiftGuardRegion
LArPhysOFCAlg.LArPhysWaveBinKey = ShiftKey

LArPhysOFCAlg.UseDelta = 0  #Only for high-mu OFCs
LArPhysOFCAlg.KeyOFC = OFCKey
LArPhysOFCAlg.KeyShape = ShapeKey
LArPhysOFCAlg.DecoderTool = theLArAutoCorrDecoderTool
LArPhysOFCAlg.isSC = SuperCells
if Nsamples == 4:
    LArPhysOFCAlg.ReadDSPConfig = ReadDSPConfig
    LArPhysOFCAlg.DSPConfigFolder = DSPConfigFolder

topSequence += LArPhysOFCAlg

LArPhysOFCAlg2 = LArOFCAlg("LArPhysOFCAlg2")

LArPhysOFCAlg2.ReadCaliWave = False
LArPhysOFCAlg2.KeyList = [InputKey]
LArPhysOFCAlg2.Normalize = Normalize
LArPhysOFCAlg2.Verify = True
LArPhysOFCAlg2.GroupingType = GroupingType

LArPhysOFCAlg2.Nphase = Nphases2
LArPhysOFCAlg2.Dphase = Dphases2
LArPhysOFCAlg2.Ndelay = Ndelays2
LArPhysOFCAlg2.Nsample = Nsamples2