"""
##############################################################################
#                                                                            #
#  Configuration for ST Cluster 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().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, STClusterTrackMonitor

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

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

TrackMonitor = STClusterTrackMonitor()
TrackMonitor.OutputLevel = 4
TrackMonitor.DetType = "TT"
TrackMonitor.ODINData = "DAQ/ODIN";




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

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

Vetra().EvtMax =         8000
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)
