# ----------------------------------------------------------------------------------------------------------------------
# Paths to parameter files, required by different algorithms

parFiles:
  readout:
    sts:
      readout: StsReadout.yaml
      channelMask: StsChannelMaskSet.yaml
      walkMap: StsWalkMap.yaml
    much:
      readout: MuchReadout.yaml
    trd:
      readout: TrdReadoutSetup.yaml
      channelMask: ""
    tof:
      readout: TofReadout.yaml
      channelMask: ""
    bmon:
      readout: BmonReadout.yaml
      channelMask: ""
    trd2d:
      readout: Trd2dReadoutSetup.yaml
      fee: Trd2dUnCalibFee.yaml
  recoParameters: reco.par.bin

# ----------------------------------------------------------------------------------------------------------------------
# Local reconstruction in STS
sts:
  digiSortMode: BlockSort
  clusterSortMode: BlockSort
  unpackMode: CPU
  findClustersMultiKernels: 1
  timeCutDigiAbs: -1
  timeCutDigiSig: 3
  timeCutClusterAbs: -1
  timeCutClusterSig: 4
  doChargeCorrelation: yes
  chargeCorrelationDelta: 2500

  memory:
    allocationMode: Auto
    maxNDigisPerTS: 30000000
    maxNDigisPerModule: 3000000
    clustersPerDigi: 1.0
    hitsPerCluster: 3.5


# ----------------------------------------------------------------------------------------------------------------------
# Tracking parameters
ca:
  # Parameters defining the CA tracking algorithm execution logic
  core:
    # Common parameters for the entire core
    common:
      # Sequence of station names to be IGNORED by tracking
      # A station name contains the official detector subsystem abbreviation (MVD, STS, MUCH, TRD, TOF), 
      # which is followed by the local geometry index of station (the index, which is used in the detector
      # interface classes). If there is no index provided, the whole detector subsystem is skept.
      # Examples:  
      # 1) Turn the first and the second STS in the geometry and the full TRD detector off
      #     inactive_stations: [STS:0', 'STS:1', 'TRD']
      # 2) Turn first TOF station in the geometry off
      #     inactive_stations: [TOF:0]
      # 3) Turn the full TOF off
      #     inactive_stations: [TOF]
      inactive_stations: ['MUCH', 'TRD', 'TOF']

      # Random seed
      random_seed: 1

    # Track finder parameters 
    track_finder:
      # Iteration sequence
      # The iterations themselves are defined in the ca/possible_iterations branch.
      iteration_sequence: ['FastPrim', 'AllPrim', 'AllPrimJump', 'AllSec']
      
      # Flag to suppress ghost tracks (true/false)
      is_ghost_suppression: true

      # Max number of doublets per singlet
      max_doublets_per_singlet: 150

      # Max number of triplets per doublet
      max_triplets_per_doublet: 15
    
    # Developement flags
    dev:
      ignore_hit_search_areas:      false
      use_of_original_field:        false
      match_doublets_via_mc:        false
      match_triplets_via_mc:        false
      extend_tracks_via_mc:         false
      suppress_overlap_hits_via_mc: false
      par_search_w_used:            false

  # Full set of default iterations. Each iteration is assigned to a target track group and has recommended set of 
  # parameters. Later, the iterations from this list can be accessed from user configuration file
  possible_iterations:
      # A default iteration of CA tracking, is used to initialized all the parameter fields
      # of other iterations, if the corresponding field is missing
      # TODO: provide with documentation
    - name: "Default"
      track_chi2_cut:           10.
      triplet_chi2_cut:         23.4450
      triplet_final_chi2_cut:   23.4450
      doublet_chi2_cut:         7.56327
      pick_gather:              4.0
      triplet_link_chi2:        25.
      max_qp:                   2.   # 1 / 0.5 [GeV/c]^-1
      max_slope_pv:             1.1
      max_slope:                2.748
      max_dz:                   0.1
      target_pos_sigma_x:       0.
      target_pos_sigma_y:       0.
      min_n_hits:               4
      min_n_hits_station_0:     4
      first_station_index:      0
      is_extend_tracks:         true
      is_primary:               false
      is_electron:              false
      max_station_gap:          0
      is_track_from_triplets:   false
      is_polynomial_triplets:   true
    
    - name: "FastPrim"
      base_iteration:           "Default"
      min_n_hits_station_0:     3
      pick_gather:              3.0
      max_qp:                   2.  # 1 / 0.5
      max_dz:                   0.
      target_pos_sigma_x:       1.
      target_pos_sigma_y:       1.
      is_primary:               true
    
    - name: "AllPrim"
      base_iteration:           "Default"
      min_n_hits_station_0:     3
      max_qp:                   20.  # 1 / 0.05
      target_pos_sigma_x:       1.
      target_pos_sigma_y:       1.
      is_primary:               true
    
    - name: "FastPrim2"
      base_iteration:           "Default"
      triplet_chi2_cut:         21.1075
      triplet_final_chi2_cut:   21.1075
      pick_gather:              3.0
      max_qp:                   2.  # 1 / 0.5
      max_dz:                   0.
      target_pos_sigma_x:       5.
      target_pos_sigma_y:       5.
      is_primary:               true
    
    - name: "AllSec"
      base_iteration:           "Default"
      triplet_chi2_cut:         18.7560
      triplet_final_chi2_cut:   18.7560
      max_qp:                   10.  # 1 / 0.1
      target_pos_sigma_x:       10.
      target_pos_sigma_y:       10.
      max_slope_pv:             1.5
      is_primary:               false

    - name: "FastPrimJump"
      base_iteration:           "Default"
      triplet_chi2_cut:         21.1075
      triplet_final_chi2_cut:   21.1075
      pick_gather:              3.0
      max_qp:                   2.  # 1 / 0.5
      max_dz:                   0.
      target_pos_sigma_x:       5.
      target_pos_sigma_y:       5.
      is_primary:               true
      max_station_gap:          1

    - name: "AllPrimJump"
      base_iteration:           "Default"
      triplet_chi2_cut:         18.7560
      triplet_final_chi2_cut:   18.7560
      max_qp:                   10.  # 1 / 0.1
      target_pos_sigma_x:       5.
      target_pos_sigma_y:       5.
      is_primary:               true
      max_station_gap:          1

    - name: "AllSecJump"
      base_iteration:           "Default"
      triplet_chi2_cut:         21.1075
      triplet_final_chi2_cut:   21.1075
      max_qp:                   10.  # 1 / 0.1
      max_slope_pv:             1.5
      target_pos_sigma_x:       10.
      target_pos_sigma_y:       10.
      is_primary:               false

    - name: "AllPrimElectron"
      base_iteration:           "Default"
      min_n_hits_station_0:     3
      max_qp:                   20.  # 1 / 0.05
      target_pos_sigma_x:       1.
      target_pos_sigma_y:       1.
      is_primary:               true
      is_electron:              true

    - name: "AllSecElectron"
      base_iteration:           "Default"
      triplet_chi2_cut:         18.7560
      triplet_final_chi2_cut:   18.7560
      max_qp:                   20.  # 1 / 0.05
      max_slope_pv:             1.5
      target_pos_sigma_x:       10.
      target_pos_sigma_y:       10.
      is_primary:               false
      is_electron:              true

# ----------------------------------------------------------------------------------------------------------------------
# Event trigger
trigger:
  detector: TOF
  window: 100
  threshold: 8
  deadtime: 30


# ----------------------------------------------------------------------------------------------------------------------
# Event builder
eventbuilder:
  BMON:  [-65, 65]
  STS:   [-80, 75]
  MUCH:  [-50, 500]
  TRD :  [-100, 300]
  TRd2D: [-150, 200]
  TOF:   [-10, 70]
  RICH:  [-120, 120]
  FSD:   [-50, 150]


# ----------------------------------------------------------------------------------------------------------------------
# Event selector
selector:
  minDigis:
    BMON: 1
    TOF: 8
    STS: 2
    TRD2D: 1
  minLayers:
    STS: 0
    TOF: 0


# ----------------------------------------------------------------------------------------------------------------------
# V0-trigger
v0trigger:
  track_start_z_min: -10
  track_start_z_max: 50
  track_end_z_min: -50
  track_impact_x_min: -1
  track_impact_x_max: 1
  track_impact_y_min: -1
  track_impact_y_max: 1
  pair_deltaT_max: 20
  pair_dist_max: 0.5
  pair_z_min: 4
  pair_z_max: 50

# ----------------------------------------------------------------------------------------------------------------------
# V0-finder
v0finder:
  reconstruct_pdg: 3122     # Lambda -> pi- p
  bmon_address: 0x00002806  # Address of reference BMON diamond
  t0_offset: 0.12           # Time offset for T0 [ns]
  qa_uncertainty: 0.1       # Assigned relative uncertainty for the q/p estimation
  primary_pdg: 321          # Assigned PDG code for primary tracks

  cuts:  # Different cuts
    kfp:  # KFParticleFinder specific cuts
      min_decay_length: 5.  # Minimal decay length of particles [cm]
      min_decay_ldl: 1.     # Minimal value of decay length to decay length error ratio
      max_chi2_ndf_prim: 0. # Maximal chi2/NDF for primary particles
      max_chi2_ndf_geo: 50. # Maximal chi2/NDF for V0 candidates
    particles:  # Defined particle
      - pdg: -211  # Pion
        min_dca: 1.5        # [cm]
        min_velocity: 25.   # [cm/ns]
        max_velocity: 29.5  # [cm/ns]
      - pdg: 2212  # Proton
        min_dca: 0.5       # [cm]
        min_velocity: 15.  # [cm/ns]
        max_velocity: 28.  # [cm/ns]
...
