if IOVEndLB <= 0:
    svcMgr.EventSelector.FirstEvent = 1
else:
    svcMgr.EventSelector.FirstEvent = 0
    svcMgr.EventSelector.FirstLB = IOVEndLB

## get a handle to the default top-level algorithm sequence
from AthenaCommon.AlgSequence import AlgSequence
topSequence = AlgSequence()

## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc
from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr, ToolSvc)

conddb.addFolder("", folderStr + tagStr + dbStr)
#conddb.addFolder("LAR_OFL","/LAR/BadChannelsOfl/MissingFEBs")

svcMgr.IOVDbSvc.GlobalTag = "CONDBR2-ES1PA-2014-01"

from LArBadChannelTool.LArBadChannelToolConf import LArBadChanTool
theLArBadChannelTool = LArBadChanTool()
theLArBadChannelTool.CoolFolder = folderStr
theLArBadChannelTool.CoolMissingFEBsFolder = ""
ToolSvc += theLArBadChannelTool

from LArBadChannelTool.LArBadChannelToolConf import LArBadChannel2Ascii
theLArBadChannels2Ascii = LArBadChannel2Ascii()
theLArBadChannels2Ascii.FileName = OutputFile
theLArBadChannels2Ascii.WithMissing = False
theLArBadChannels2Ascii.ExecutiveSummaryFile = ""
topSequence += theLArBadChannels2Ascii
from LArBadChannelTool.LArBadChannelToolConf import LArBadChanTool
theLArBadChannelTool = LArBadChanTool()
theLArBadChannelTool.ReadFromASCII = True

theLArBadChannelTool.EMECAfile = InputFile
theLArBadChannelTool.HECAfile = InputFile
theLArBadChannelTool.FCALAfile = InputFile

theLArBadChannelTool.EMECCfile = InputFile
theLArBadChannelTool.HECCfile = InputFile
theLArBadChannelTool.FCALCfile = InputFile

theLArBadChannelTool.EMBAfile = InputFile
theLArBadChannelTool.EMBCfile = InputFile

theLArBadChannelTool.CoolFolder = ""
theLArBadChannelTool.CoolMissingFEBsFolder = ""

theLArBadChannelTool.OutputLevel = DEBUG
ToolSvc += theLArBadChannelTool

OutputList = ["CondAttrListCollection#" + Folder]
Tag = join(split(Folder, '/'), '') + TagPostfix
OutputTagList = [Tag]

from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg
theOutputConditionsAlg = OutputConditionsAlg("OutputConditionsAlg",
                                             "dummy.pool.root", OutputList,
                                             OutputTagList, True)

theOutputConditionsAlg.Run1 = IOVBeginRun