#####################
# Simulations
# - Generate datasets
# - Run Geant4
# - Run Juggler
#####################

sim_emcal_barrel_pions:
  image: eicweb.phy.anl.gov:4567/eic/juggler/juggler:$JUGGLER_TAG
  stage: simulate
  tags:
    - silicon
  artifacts:
    expire_in: 20 weeks
    paths:
      - results/
      - sim_output/
  script:
    - bash calorimeters/run_emcal_barrel_pions.sh
  allow_failure: true

sim_emcal_barrel_electrons:
  image: eicweb.phy.anl.gov:4567/eic/juggler/juggler:$JUGGLER_TAG
  stage: simulate
  tags:
    - silicon
  artifacts:
    expire_in: 20 weeks
    paths:
      - results/
      - sim_output/
  script:
    - bash calorimeters/run_emcal_barrel_electrons.sh
  allow_failure: true

crystal_emcal_simulation:
  stage: simulate
  needs: 
    - ["get_data"]
  tags:
    - silicon
  script:
    - cp NPDet/src/detectors/calorimeters/compact/elements.xml ./.
    - cp NPDet/src/detectors/calorimeters/compact/materials.xml ./.
    - bash calorimeters/run_simulation_crystal.sh

crystal_pion_simulation:
  stage: simulate
  needs:
    - ["get_data"]
  tags:
    - silicon
  script:
    - cd topside  && ls -l
    - npsim --runType batch --numberOfEvents 100 --compactFile topside.xml --inputFiles  ../data/emcal_electrons.hepmc  --outputFile  ../sim_output/output_emcal_electrons.root

    #zdc_simulation:
    #stage: simulate
    #needs: 
    #- ["get_data"]
    #tags:
    #- silicon
    #script:
    #- cp NPDet/src/detectors/calorimeters/compact/elements.xml ./.
    #- cp NPDet/src/detectors/calorimeters/compact/materials.xml ./.
    #- bash calorimeters/run_simulation_zdc.sh

###################
# Benchmarks
###################

ben_emcal_barrel_pions:
  stage: benchmarks
  tags:
    - silicon
  artifacts:
    expire_in: 20 weeks
    paths:
      - results/
  needs:
    - ["sim_emcal_barrel_pions"]
  script:
    - ls -lrth sim_output
    - root -b -q calorimeters/scripts/emcal_barrel_pions_analysis.cxx+
  allow_failure: true

ben_emcal_barrel_electrons:
  stage: benchmarks
  tags:
    - silicon
  artifacts:
    expire_in: 20 weeks
    paths:
      - results/
  needs:
    - ["sim_emcal_barrel_electrons"]
  script:
    - ls -lrth sim_output
    - root -b -q calorimeters/scripts/emcal_barrel_electrons_analysis.cxx+
  allow_failure: true

crystal_benchmark:
  stage: benchmarks
  tags:
    - silicon
  needs:
    - ["crystal_emcal_simulation"]
  script:
    - ls -lrth sim_output
    - root -b -q calorimeters/simple_checking_crystal.cxx+
  allow_failure: true

    #cal_test_3_zdc_neutrons_reader:
    #stage: benchmarks
    #tags:
    #- sodium
    #script:
    #- root -b -q calorimeters/zdc_neutrons_reader.cxx
      #artifact:
      #  paths: 
      #    - results/
      #allow_failure: true

    #zdc_benchmark:
    #stage: benchmarks
    #tags:
    #- silicon
    #needs: 
    #- ["zdc_simulation"]
    #dependencies:
    #- zdc_simulation
    #script:
    #- ls -lrth sim_output
    #- root -b -q calorimeters/simple_checking.cxx+
    #allow_failure: true

    #zdc_benchmark_info_histogram:
    #stage: benchmarks
    #needs: 
    #- ["zdc_simulation"]
    #tags:
    #- silicon
    #dependencies:
    #- zdc_simulation
    #script:
    #- cp NPDet/src/detectors/calorimeters/compact/elements.xml calorimeters/
    #- cp NPDet/src/detectors/calorimeters/compact/materials.xml calorimeters/
    #- root -b -q calorimeters/simple_info_plot_histograms.cxx+
    #allow_failure: true