#include "services_dune.fcl"
#include "backtrackerservice.fcl"
#include "particleinventoryservice.fcl"
#include "singles.fcl"
#include "largeantmodules.fcl"
#include "detsimmodules.fcl"
#include "opticaldetectormodules_dune.fcl"
#include "opticaldetectorservices_dune.fcl"
#include "photolibbuild_services_dune.fcl"
#include "photpropservices_dune.fcl"
#include "lightsource.fcl"


process_name: LibraryBuild





services:
{
  # Load the service that manages root files for histograms.
  TFileService: { fileName: "PhotonLibraryFile_dune35ton_v5_test.root" }
  TimeTracker:       {}
  RandomNumberGenerator: {} #ART native random number generator
                 @table::dune35t_photolibbuild_services 
  message:       @local::standard_info
  BackTrackerService:   @local::dunefd_backtrackerservice # defined in backtrackerservice.fcl
  ParticleInventoryService:   @local::dunefd_particleinventoryservice # defined in backtrackerservice.fcl
}


services.Geometry.GDML: "dune35t4apa_v5.gdml"
services.Geometry.ROOT: "dune35t4apa_v5.gdml"
services.Geometry.SortingParameters.DetectorVersion: "dune35t4apa_v5"


#Start each new event with an empty event.
source:
{
  module_type: EmptyEvent
  maxEvents:   100        # Number of events to create
  firstRun:    1           # Run number to use for this file
  firstEvent:  1           # number of first event in the file
}

# Define and configure some modules to do work on each event.
# First modules are defined; they are scheduled later.
# Modules are grouped by type.
physics:
{

 producers:
 {
   generator: @local::standard_lightsource	  
   largeant:  @local::standard_largeant	  
 }

 analyzers:
 {
   pmtresponse: @local::dune35t_simphotoncounter    # defined in opticaldetectormodules.fcl
 }

 #define the producer and filter modules for this path, order matters, 
 #filters reject all following items.  see lines starting physics.producers below
 simulate: [ generator, largeant ] 
 analyzeIt:  [ pmtresponse ]
 #define the output stream, there could be more than one if using filters 
 stream1:  [ ]

 #trigger_paths is a keyword and contains the paths that modify the art::event, 
 #ie filters and producers
 trigger_paths: [simulate] 

 #end_paths is a keyword and contains the paths that do not modify the art::Event, 
 #ie analyzers and output streams.  these all run simultaneously
 end_paths:     [analyzeIt, stream1]  
}

#block to define where the output goes.  if you defined a filter in the physics
#block and put it in the trigger_paths then you need to put a SelectEvents: {SelectEvents: [XXX]}
#entry in the output stream you want those to go to, where XXX is the label of the filter module(s)
outputs:
{
 out1:
 {
   module_type: RootOutput
   fileName:    "opticallibrary_dune35t.root" #default file name, can override from command line with -o or --output
 }
}




##### Parameter changes for the generator (lightsource) #####

# do not allow lightsource to write output into root file
physics.producers.generator.FillTree: false

##### Parameter changes for the pmt respnse analyzer (simphotoncounter) #####

physics.analyzers.pmtresponse.MakeAllPhotonsTree: false
physics.analyzers.pmtresponse.MakeDetectedPhotonsTree: false
physics.analyzers.pmtresponse.MakeOpDetsTree: false
physics.analyzers.pmtresponse.MakeOpDetEventsTree: false


# To disable wireplane absorption, uncomment this line
#services.LArG4Parameters.OpticalParamModels: ["TransparentPlaneAction"]



#services.PhotonVisibilityService.NX: 30
#services.PhotonVisibilityService.NY: 30
#services.PhotonVisibilityService.NZ: 30
#physics.producers.generator.FirstVoxel: 1000
#physics.producers.generator.LastVoxel: 1020
#physics.producers.generator.N: 500

#physics.analyzers.pmtresponse.Verbosity: 3

physics.producers.generator.N: 10000


# Number of voxels
services.PhotonVisibilityService.NX: 1
services.PhotonVisibilityService.NY: 20
services.PhotonVisibilityService.NZ: 5

services.PhotonVisibilityService.UseCryoBoundary: false

# IF UseCryoBoundary is set to false, so use the following parameters in cm
services.PhotonVisibilityService.XMin:  -8.
services.PhotonVisibilityService.XMax:  -6.
services.PhotonVisibilityService.YMin:  -100.
services.PhotonVisibilityService.YMax:  0
services.PhotonVisibilityService.ZMin:  60.
services.PhotonVisibilityService.ZMax:  90.
