"""
##############################################################################
#                                                                            #
#  Configuration for ST Aging CCE scan analysis for TT                       #
#                                                                            #
#  @package ST/STAging                                                       #
#  @author Ch. Elsasser                                                      #
#  @date   15/06/2013                                                        #
#                                                                            #
##############################################################################
"""

from GaudiKernel.ProcessJobOptions import importOptions

from Configurables import GaudiSequencer
from TrackSys.Configuration import *
from Configurables import ( TrackSys, RecSysConf )
from Configurables import TrackContainerCopy
from Configurables import Velo__VeloTrackMonitor
from Configurables import EventClockSvc
from Configurables import Vetra
from Configurables import VetraRecoConf
from Configurables import ST__STDumpADCs
 


generalOutputLevel = 3

Vetra().MainSequence = [ 'ProcessPhase/Reco', GaudiSequencer('MoniTTSeq'), GaudiSequencer('MoniSTSeq')]


TrackSys().ExcludedLayers = ["TTaU"]
TrackSys().TrackPatRecAlgorithms = TrackSys().DefaultPatRecAlgorithms
VetraRecoConf().Sequence = RecSysConf().DefaultTrackingSubdets # = ["Decoding", "VELO","TT","IT","OT","Tr","Vertex"]

from Configurables import CondDB, CondDBAccessSvc, CondDBTimeSwitchSvc
connection="sqlite_file:$STSQLDDDBROOT/db/STCOND.db/COND"
CondDB().addLayer( CondDBAccessSvc("COND", ConnectionString = connection) )


importOptions('$HOME/cmtuser/Vetra_v13r2/ST/STVetraAnalysis/options/TTEmulator.py')

from Configurables import STNZSResolution, STADCTrackMonitor

#ODINChecker = STODINCheck()
#ODINChecker.OutputLevel = generalOutputLevel
#ODINChecker.ODINData = "DAQ/ODIN";

#GaudiSequencer('ODINPreChecker').Members = [ODINChecker]

ttRes = STNZSResolution("TTResolution")
ttRes.OutputLevel = 4
ttRes.DetType = "TT"
ttRes.UseNZSdata = True
ttRes.InputData =  "/Event/Raw/TT/LCMSADCs";

TrackMonitor = STADCTrackMonitor()
TrackMonitor.OutputLevel = generalOutputLevel
TrackMonitor.DetType = "TT"
TrackMonitor.RawDataCent = "/Event/Raw/TT/LCMSADCs";
TrackMonitor.ODINData = "DAQ/ODIN";
TrackMonitor.Layer   = "TTaU"
TrackMonitor.MaxNeighbours = 3



GaudiSequencer('MoniTTSeq').Members = [ GaudiSequencer('EmuTTSeq'), GaudiSequencer('EmuTTSeqPrev'), GaudiSequencer('EmuTTSeqNext'),TrackMonitor]
GaudiSequencer('MoniTTSeq').IgnoreFilterPassed = True#ReturnOK = True

histoname = "Histo.root"
tuplename = "Tuple.root"

Vetra().EvtMax =         -1
Vetra().OutputLevel =    INFO
Vetra().HistogramFile =  histoname
Vetra().TupleFile =      tuplename
vetra = Vetra()

def doMyChanges():
    from Configurables import VetraInit, FilterByBankType
    bankFilter = FilterByBankType()
    bankFilter.BankNames = [ "TTFull", "ITFull" ]
    from Configurables import LoKi__ODINFilter
    odinFilter = LoKi__ODINFilter('BBODINFilter', Code = " LHCb.ODIN.BeamCrossing == ODIN_BXTYP ")
    GaudiSequencer( 'Init' ).Members = [   VetraInit(), odinFilter, bankFilter   ]
appendPostConfigAction(doMyChanges)
