###############################################################
#
#  This file resides in:  SVTMon/test/SVTMon.tcl
#  This is an example script to run SVTMon
#  Note! you might have to change the input file.
#
#  Last Update: CDF offline software 4.2.0
###############################################################

set useRCP false

module input DHInput
module talk DHInput
  setInput noorder

#  include dataset bphysr run=124830
#  selectEvents set run=124830
#  selectEvents exclude run=124830 event=42617
#  setInput launch

#  include file /cdf/data21/s2/G_03349.0004/giovanni/bello/Data/aa01f17a.0001phys
#  include file /cdf/data21/s2/G_03349.0004/giagu/Prod/r128350/128350-br01f55e.0001phys.Dst-TTRK.prod
#  include file /cdf/data08/look/bphysr/br020b76.0001phys
#  include file /cdf/data08/look/bphysr/br020c4a.0001phys
  include file /cdf/data08/look/bphysr/br020d75.0001phys
  show
exit
 

module talk PuffModule
  PuffOnly set CdfTrackColl
exit
 

module talk svtsim
#  dataFileDir set $env(PROJECT_DIR)/svtsim/svtdata/
  dataFileDir set /cdf/data03/s7/off_val/svt_config/
  mapSet set default
#  hwSet set default
  debugPrint set t
  obspPrint set f
  inputDataPrint set f
  data_flag set t
  show
exit
 
 

module talk CalibrationManager
    add DiracConfigDB      OTL  cdf_reader/reader@cdfofprd
    add PhysicsTableDB     OTL  cdf_reader/reader@cdfofprd
    add DownloadsDB        OTL  cdf_reader/reader@cdfofprd
    add TriggerFilesViewDB OTL  cdf_reader/reader@cdfofprd
    add CalDigiToGeV       OTL  cdf_reader/reader@cdfofprd
    add CalDigiToGeV2      OTL  cdf_reader/reader@cdfofprd
    add XftConfigDB        OTL  cdf_reader/reader@cdfofprd
    DataDB    set database_oracle_online
    Database  set database_oracle_online
exit
 

module talk ErrorLoggerManager
  #errfile set TrigMonError.log
  limit    set 100
  severity set INFO
exit
 

module talk ConsumerErrorModule
  writeCentralLogFile set f
exit
 

module talk SVTMon

#### SVTMon is based on a BaseMonitor2 class,
#### therefore, in order to run it offline, all the Consumer-like features need to be switched off

  verbose             set f
  startServer         set f
  useRestartMechanism set f
  saveMemoryMapFile   set f
  saveROOTFile        set f
  saveSummaryFile     set f
  updateFreq          set 10
  jobName             set SVTMon

  SVTDMonitor
    SVTDMonitor set t

#### Set the SVT configuration files, "current .*" files point
#### to the latest configuration used by the SVT
#### If you need to run on OLD data,  look for the "AVAILABLE DATA SETS"
#### in http://www-cdf.fnal.gov/upgrades/daq_trig/trigger/svt/SVT_config.html
#### and download your own copy
#### (...soon all this will be managed via DB !!!)

#### 12 .patt files (one per SVT wedge) which contain the list of valid patterns (roads)
#    w0patt_File set "/cdf/data03/s7/off_val/svt_conf/current.0patt"
#    w1patt_File set "/cdf/data03/s7/off_val/svt_conf/current.1patt"
#    w2patt_File set "/cdf/data03/s7/off_val/svt_conf/current.2patt"
#    w3patt_File set "/cdf/data03/s7/off_val/svt_conf/current.3patt"
#    w4patt_File set "/cdf/data03/s7/off_val/svt_conf/current.4patt"
#    w5patt_File set "/cdf/data03/s7/off_val/svt_conf/current.5patt"
#    w6patt_File set "/cdf/data03/s7/off_val/svt_conf/current.6patt"
#    w7patt_File set "/cdf/data03/s7/off_val/svt_conf/current.7patt"
#    w8patt_File set "/cdf/data03/s7/off_val/svt_conf/current.8patt"
#    w9patt_File set "/cdf/data03/s7/off_val/svt_conf/current.9patt"
#    w10patt_File set "/cdf/data03/s7/off_val/svt_conf/current.10patt"
#    w11patt_File set "/cdf/data03/s7/off_val/svt_conf/current.11patt"
 

#### .ss file describe the super-strips geometry (how many per layer, their width)
#    ss_File set "/cdf/data03/s7/off_val/svt_conf/current.ss"

####  .gcon file contains the constants used to fit tracks within the road,
####  as done by the SVT Track Fitter boards)
#    gcon_File set "/cdf/data03/s7/off_val/svt_conf/current.gcon"

####  .am file describes the AM board assignement
####  (it is very unlikely that it changes)
#    am_File set "/cdf/data03/s7/off_val/svt_conf/current.am"

#####   Monitor_mode:   0= SVTD bank contains Real data,
#####                   1= SVTD bank contains svtsim data,
#####                   2= two SVTD banks are present:
#####                      one with Real and one with svtsim data
    Monitor_Mode set 2

#####  SVDDstatus: set it "old" to read SVTDD banks written before October2001 shutdown
    SVDDstatus set "new"

#####  Write ntuple: STVntuple_<runnumber>.hbook
    Create_Ntuple set t
##### turns on/off filling of control histograms
    Histo_Mode set t
    checkFreq   set 1
#####  set Chi2 cut: used only to fill histograms
    Chi2cut set 25
#####  turns ON/OFF DEBUG printouts
    Debug_Mode set t
#####  Write file SVTD_dump.txt      (friendly dump of SVTD bank)
    DumpSVT set f
#####  Write file SVTD_RAWdump.txt   (HEX dump of SVTD bank)
    DumpRAW set f
#####  Write file SVTD_XTRPdump.txt  (frienly dump of XTRP words)
    DumpXTRP set f
#####  Write file SVTD_XTRDdump.txt  (frienly dump of XTRD bank)
    DumpXFLD set f
#####  Write file SVTD_XFLDdump.txt  (frienly dump of XFLD bank)
    DumpXTRD set f
  exit
show
exit

##### you need to enable svtmon module
##### in order to produce simulated SVTD bank for each event
#module disable svtsim
module enable svtsim
#module disable CalibrationManager
module enable CalibrationManager

module disable PuffModule
path enable AllPath
path list

#ev begin
ev begin -n