#include "services_refactored_pdune.fcl"
#include "LArG4_dune.fcl"
#include "IonAndScint_dune.fcl"
#include "PDFastSim_dune.fcl"
#include "ls4gan.fcl"

process_name: G4

services:
{
  TFileService: { fileName: "g4_protoDUNE_hist.root" }
  TimeTracker:       {}
  MemoryTracker:     {} # default is one
  RandomNumberGenerator: {} #ART native random number generator
  message:      @local::standard_info

  @table::protodune_larg4_services
  @table::protodune_refactored_simulation_services

  NuRandomService:       @local::dune_prod_seedservice
}


sim_sp_sio_1d: {
    @table::@local::sim_sp_sio
    wcls_main: {
        @table::@local::sim_sp_sio.wcls_main
        params: {
            @table::@local::sim_sp_sio.wcls_main.params
            fields: "dune-garfield-1d565-wires0.json.bz2"
            outname: "frames1d.npz"
        }
    }
}

sim_sp_sio_2d: {
    @table::@local::sim_sp_sio
    wcls_main: {
        @table::@local::sim_sp_sio.wcls_main
        params: {
            @table::@local::sim_sp_sio.wcls_main.params
            fields: "dune-garfield-1d565.json.bz2"
            outname: "frames2d.npz"
        }
    }
}

source:
{
  module_type: RootInput
  maxEvents:  30000
  fileNames: ["gen_protoDUNE.root"]
}

physics:
{

  producers:
  {

    #retain largeant name for compatibility
    largeant:     @local::protodune_larg4
    IonAndScint:  @local::protodune_ionandscint
    PDFastSim:    @local::protodune_pdfastsim_pvs
    sim_sp_sio_1d:@local::sim_sp_sio_1d
    sim_sp_sio_2d:@local::sim_sp_sio_2d
    rns: {module_type: "RandomNumberSaver"}
  }

  analyzers:
  {

  }

  #simulate:      [  rns, largeant, IonAndScint, PDFastSim ]
  simulate:      [  rns, largeant, IonAndScint, depodump ]
  stream1:       [ out1 ]

  trigger_paths: [  simulate ] 
  end_paths:     [  stream1  ]  
}

outputs:
{
  out1:
  {
    module_type: RootOutput
    fileName:    "%ifb_g4.root"
    dataTier:    "simulated"
    outputCommands: [ "drop *" ]
    #outputCommands: [ "keep *"
    #, "drop *_*_*_SinglesGen"
    #, "drop *_TriggerResults_*_G4"
    #, "drop *_rns_*_G4"
    #, "drop *_largeant_*_G4"
    #, "drop *_IonAndScint_priorSCE_G4"
    #]
    #outputCommands: [ "keep *" ]
    #outputCommands: [ "keep *", "drop sim::SimEnergyDeposits_largeant_*_G4"]
    #fastCloning: false #will fail if the split level is not the same as for the gen stage, so turn it off
    compressionLevel: 1 #zlib argument (0-9) 
    #basketSize: 8192 #[Byte] buffer size at 8k
    #splitLevel: 0 #reduces number of buffers
    #treeMaxVirtualSize: 1 #[Byte] limits number of buffers/branch to 1 (default is 10)
  }
}
