#
# this is tcl that Sebastian Carron used for CDM ntuple jobs,
# which was adapted by Stephan Levy (Dec. 16, 2004)
#
module list
path enable AllPath
path list

module input GenInputManager
talk GenInputManager
  report set 1
#set run number 
run_number set 151435
exit

###!!! Seems to be some problem with Isajet at the moment
# mod enable Isajet
# set env(CDFPVLI) $env(GENERATORMODS_DIR)/examples/isajet/top175.val

# talk Isajet
# #  call_qq set t
# #  report set 1
# exit
# mod enable QQModule 
# talk QQModule
# exit

module enable FAKE_EVENT
talk FAKE_EVENT
    use PT
    use ETA
    use PHI
# SET PARAMETER_NAME MEAN SIGMA PMIN PMAX POWER MODE(1=gauss,2=flat)
    generate PT     0. 0.   10.   10.  0.  2
    generate ETA    0. 0.  -2.5   2.5  0.  2
# Vertical tracks in Phi
#    generate PHI    0. 0.   234.9127  246.3718   0.  2
###    generate CDFCODE 207
    generate CDFCODE 13
    generate NPARTICLES 10
# Generate mu- 207, mu+ 208 psi 1002
   show
exit

talk GeometryManager
# Use the defaults but substitute the detailed for the simple detector
# The following set up is to be added to the default GeometryManager set 
up.
  DetectorMenu
     enableAll set f
     enableCot set t
     enableSvx set t
#     enableTof set t
#     enablePassive set t
                                # central part of the beampipe
     enableBeampipeC set true   
     show
  exit
# Silicon Passive Geometry
  SiliconGeometryMenu
     BuildPassive set true
     AlignmentSource set "ofotl_prd_read 100035 1 GOOD"
  exit
# TOF geometry model
#   TofGeometryMenu
#                                 # options: Nominal, Naive
#     GeometryModel set Survey   
#   exit
#   MuonGeometryMenu
#    CMXGeometry set f
#     IMUGeometry set f
#   exit
exit

talk SimInitManager
  DetectorMenu
     declareCot set t
     declareSvx set t 
#      declareMuon set t
#      declareCalor set t
#      declareTof  set t
#     declarePassive set t 
  exit
exit


talk SimulationControlMod
  DebugMenu
    showActiveVolumes set t
    DebugLevel set 0 
  exit
  DetectorMenu
     simulateSvx set t
     simulateCot set t
#      simulateMuon set t
#      simulateTof set t
#      simulateCalor set t
#     simulatePassive set t 
  exit
  dumpFactory
  add CdfHalfLadder SvxDigitizer SvxGroup
  add CotSuperLayer CotDigitizer CotGroup
#   add CMUExtrusion MuonDigiCMU MuonCMUdata
#   add CMPPart      MuonDigiCMP MuonCMPdata
#   add CMXChamber   MuonDigiCMX MuonCMXdata
#   add CSXCounter   MuonDigiCSX MuonCSXdata
#   add Tof3Pack TofDigi3Pack TofGroup
#   add TofBar TofDigiBar   TofGroup
#   add CalorDetectorElement CalorDigiGeneric CalorGroup 
#    add BFCoil CalorDigiBFCoil CalorGroup
#    add NoBFCoil CalorDigiNoBFCoil CalorGroup
#   add BMUGas  ImuDigiBMUGas    ImuGroup
#   add BSUPaddle  ImuDigiBSUPaddle ImuGroup
#   add TSUPaddle  ImuDigiTSUPaddle ImuGroup
  show add
  ConfigMenus
    CotGroup_CotSuperLayer
      CreateCOTM set t
      CreateMCOT set f
      DriftModel set Garfield
      show
    exit
    SvxGroup_CdfHalfLadder
      pick_svx_cdm set PARAMETERIZED
#----turn OFF all effects-------
       svx_cdm_delta_rays set ON
       svx_cdm_noise set ON
       svx_cdm_magnetic_field set ON
###      svx_cdm_crosstalk_list set 1 0.135
# set values on different layers
#   (skip 2nd parameter)               L0 L0  L1   L1    L2   L2     L3   
L3    L4   L4   L5   L5  L6 L6 L7 L7
      svx_cdm_crosstalk_list set 2  0. 0. 0. 0.43 0.2 0.47 0.19   0.49 
0.51  0.41 0.24  0.46 0.50 0.49 0.50 0.49 0.50
#     svx_cdm_crosstalk_list set 2  0. 0. 0. 0.0 0.0 0.0 0.0   0.0 0.0  
0.0 0.0  0.0 0.0 0.0 0.0 0.0 0.0
      debug set 0  
#--------------------------------                         
      ZigZagL7 set t
      CreatePropagatedSi set t
      svx_validation set ON
      CreateSIXD set t
# G e t   n o i s e   f r o m   D B
#     useNoiseDB set t
      show
    exit
  exit
exit


#mod disable HepRootManager
mod enable HepRootManager 
mod talk HepRootManager
  histfile set letsgetaworkingversion.root
exit

#CT_Simulation needed for better matching!
mod enable CT_Simulation

mod enable CT_TrackingModule
module talk CT_TrackingModule
  OutputMenu
    WriteTRCK set t
  exit
  PatternRecognitionMenu
#   FindAxialSegments  set t
#   FindStereoSegments set t
#   LinkAxialSegments  set t
#   LinkStereoSegments set t
#   FindVertices       set t
#   LinkStereoHits     set t
#   Fit3dTracks        set t
  exit
exit

mod enable PVFinder
mod talk PVFinder
  SAS3DPVFinder set t
exit

mod enable SiClusteringModule
talk SiClusteringModule
   DebugMenu
       PrintNClusters set t
   exit
#------if Bfield OFF------------------
   CorrectClusterCentroids set TRUE     
#------if Bfield ON-------------------
# CorrectClusterCentroids set TRUE
  CentroidCorrectionModel set PARAMETERIZED     
#CentroidCorrectionModel set DATA     
#-------------------------------------
   StripCorrectorMenu
      FlagBad set t
      RemoveBad set f 
      UseL00PedFit set f
  exit
  UseNNDataUnpacker set f
exit

mod enable SiPatternRecModule
mod talk SiPatternRecModule
# Ken Bloom's tracking followed by Weiming's stereo tracking
#  PerformOutsideInTracking set t
#   PerformOIZTracking set t 
# Kal tracking for use with simulated data or when the full detector works
#   PerformKalOISvxStandaloneTracking set f
#   PerformKalSvxStandaloneTracking set t
# New Kal 3 loop tracking
#   Do3LoopOIInKal               set t
   PassAllCandidates            set t
   MinimumPt                    set 0.0
   missingMultLayers set 1 0 0 0 0 0 0 0
#testing the zigzagbonding
   zigzagbonding set false
show
exit

mod enable TestSiBanks
talk TestSiBanks
   printSiHitSet set f
exit

mod enable CdfTrackTest
mod talk CdfTrackTest
  PrintSummary set t
  PrintSet set f 
  CreateViews set f
  PrintViews set f
  PassProcessName set t
  ProcessName set ""
exit

mod enable SiHitAnalyzerModule
mod talk SiHitAnalyzerModule
  FillTrackInfo set t
  FillHitInfo set t
  FillStripInfo set t
  FillIntersectionInfo set t
  FillGeantIntersectionInfo set t
  FillObspTrackInfo set t
  FillObspIntersectionInfo set t
# Process names are needed to get defTracks ussualy ""(your own job) or 
"PROD"
  PassProcessName set t
  ProcessName set ""
exit

#talk DHOutput
#  output create main_stream phys_4.9.0.root
#  output path main_stream AllPath
#  output keepList main_stream \
\#                    LRIH_StorableBank EVCL_StorableBank 
HEPG_StorableBank \
 \#                   TL2D_StorableBank OBSP_StorableBank 
OBSV_StorableBank \
  \#                  COTD_StorableBank CMPD_StorableBank 
CMUD_StorableBank \
   \#                 CSPD_StorableBank CMXD_StorableBank 
IMUE_StorableBank \
    \#                SIXD_StorableBank MSVX_StorableBank 
ISLD_StorableBank \
     \#               MISL_StorableBank MCOT_StorableBank 
TOFD_StorableBank \
      \#              COTQ COTM_StorableObject \
       \#             PESD_StorableBank CESD_StorableBank 
CPRD_StorableBank \
        \#            CEMD_StorableBank PEMD_StorableBank 
CHAD_StorableBank \
         \#           WHAD_StorableBank PHAD_StorableBank 
PPRD_StorableBank \
          \#          MuonXHitColl MuonTHitColl MuonXZHitColl \
           \#         TOFD_StorableBank TofPulse TofPulseColl TofMatch 
TofMatchColli \
            \#        PropagatedSiParticleColl
#exit                                                           

ev begin -nev 600
show timer
exit