#include "services_dune.fcl"

BEGIN_PROLOG
# -JReichenbacher (01/11/2017)
#  v2.01/JS: use only generator and not also arGen
#  v2.1-02142017/JR: moved photon paddles by (0.5+0.476+0.001) cm in x
#  v2.2-02222017/JR: cut out LAr volume inside APA around PDs (-0.477,...,0.477) cm in x
#  v2.3-03212017/JR: include neutrons emitted from concrete of membrane cryostat structure (temporarily placed at aluminum field cage positions in sim.)
#  v2.4-05122017/JS: Removed the LAr cut out. Added in the 210po generation near the PDs. Disabled FC (Until Neutrons can be pushed to LArData.)
#  v2.5-05252017/JS: Added in 85Kr as a background in LAr using the WARP collaboration rates. https://arxiv.org/pdf/astro-ph/0603131.pdf
#  v2.6-05302017/JS: Added neutronGen back in, using the Concrete_DUNE1 spectrum (by JR). New spectrum will be in dune_pardata.
#  v2.7-06062017/JS: Added material specific generation for LAr contaminants.
#  v2.8-06092017/JS: Reconfigured this to be an include for a typical job. This file will now host generators for the various radiologicals, but will not run a simulation itself.
#  v3.0-19072021/Pierre Lasorak: Copy and past dune_radiological_model.fcl, and addapt to decay0

// Drop the 1x2x6 where necessary (everything "should work")

#The Generator names provided that should be called from other files are:
#dune10kt_39Ar_in_LAr                  #Ar39 in LAr
#dune10kt_85kr_in_LAr                  #Kr85 in LAr
#dune10kt_42Ar_in_LAr                  #Ar42 in LAr
#dune10kt_42Kfrom42Ar_in_LAr           #K42 in LAr (from Ar42)
#dune10kt_222Rn_chain_222RnOnly_in_LAr #Rn222 in LAr
#dune10kt_222Rn_chain_218PoOnly_in_LAr #Po218 in LAr (with x distribution) from Rn222
#dune10kt_222Rn_chain_214PbOnly_in_LAr #Pb214 in LAr (with x distribution) from Rn222
#dune10kt_222Rn_chain_214BiOnly_in_LAr #Bi214 in LAr (with x distribution) from Rn222
#dune10kt_222Rn_chain_210PbOnly_in_LAr #Pb210 in LAr (with x distribution) from Rn222

#dune10kt_1x2x6_40K_in_CPA             #K40 in CPA
#dune10kt_1x2x6_238U_chain_in_CPA      #U238 cahin in CPA
#dune10kt_1x2x6_42Kfrom42Ar_in_CPA     #K42 in CPA (from LAr's Ar42)
#dune10kt_222Rn_chain_218PoOnly_in_CPA #Po218 in CPA from LAr's Rn222
#dune10kt_222Rn_chain_214PbOnly_in_CPA #Pb214 in CPA from LAr's Rn222
#dune10kt_222Rn_chain_214BiOnly_in_CPA #Bi214 in CPA from LAr's Rn222
#dune10kt_222Rn_chain_210PbOnly_in_CPA #Pb210 in CPA from LAr's Rn222
#dune10kt_222Rn_chain_from210Bi_in_CPA #Bi210 in CPA from LAr's Rn222

#dune10kt_1x2x6_60Co_in_APA            #Co60 from APA frame
#dune10kt_1x2x6_238U_chain_in_APA      #U238 cahin in APA

#dune10kt_1x2x6_neutron_from_rock      #Neutrons from concrete/rocks (from dune_radiological_model.fcl).

#dune10kt_222Rn_chain_in_PDS           #Rn222 chain in PDS


dune10kt_1x2x6_weird_beta_example_in_LAr: # a dummy example
{
   # module_type: "Decay0Gen"
   module_type: "SpectrumVolumeGen"
   isotope:     "11"
   material:    "LAr"
   spectrum_p_min: 0
   spectrum_p_max: 0.01
   spectrum: [0,0,1,1,1,1,4,4,1,1,0,0]
   ## OR
   # spectrum_p_min: 0
   # spectrum_p_max: 0.01
   # nbins:100
   # function: "[0]*x+[1]*x*x+[2]"
   # parameters: [100,0,0]
   ## OR
   # spectrum: [0,1,4,4,1.5]
   # bins: [0.,0.02,0.04,0.08,0.15,0.3]
   ## OR
   # bins: [0.,0.02,0.04,0.08,0.15,0.3]
   # function: "[0]*x+[1]*x*x+[2]"
   # parameters: [100,0,0]
   BqPercc: 0.00141 # activity -- Becquerels per cc. 0.00141 assumes 1.01 Bq/kg (typical for 39Ar) and a density of 1.396 g/cc for LAr
   volume_rand: "volCryostat"
}

dune10kt_85Kr_in_LAr:{
   module_type: "Decay0Gen"
   isotope: "Kr85"
   volume_rand: "volCryostat"
   material: "LAr"
   BqPercc: 0.00016# Rate tied to LAr using rates established by the WARP collaboration. https://arxiv.org/pdf/astro-ph/0603131.pdf
}

dune10kt_39Ar_in_LAr:{
   module_type: "Decay0Gen"
   isotope: "Ar39"
   volume_rand: "volCryostat"
   material: "LAr"
   BqPercc: 0.141 # activity -- Becquerels per cc. 0.00141 assumes 1.01 Bq/kg (typical for 39Ar) and a density of 1.396 g/cc for LAr
	#Doping by a factor of 100 to make training on signal easier.
}

dune10kt_42Ar_in_LAr:{
   module_type: "Decay0Gen"
   isotope: "Ar42"
   volume_rand: "volCryostat"
   material: "LAr"
   BqPercc: 0.0000001283768 // No clue where this number comes from (see dune_radiological_model.fcl)
}

dune10kt_42Kfrom42Ar_in_LAr:{
   module_type: "Decay0Gen"
   isotope: "K42"
   volume_rand: "volCryostat"
   material:    "LAr"
   BqPercc: 0.00000002567536 // = 0.0000001283768*.2  as only 20% of the 42K stays in the Argon...
}

dune10kt_1x2x6_42Kfrom42Ar_in_CPA:{ // if somebody change the geom of the cathode, the activity will need to change (hence I didn't drop the 1x2x6 spec here)
   module_type: "Decay0Gen"
   isotope: "K42"
   volume_gen: ".*Cathode.*" // The rest of the 42K go to the cathode
   // This number was adjusted such that:
   // The rate of decays of dune10kt_42Kfrom42Ar_in_LAr + dune10kt_1x2x6_42Kfrom42Ar_in_CPA = dune10kt_42Kfrom42Ar_in_LAr
   // However, the decays in LAr happen over _ALL_ the LAr, but the CPA only convers 78% of the volumes in the 1x2x6,
   // so we have to multiply bt 78% the result of the previous line.
   BqPercc: 0.0029 //!\\ beware this number need to change if the geometry of the cathode changes.
}

dune10kt_1x2x6_40K_in_CPA:{ // again beware of geometry change here
   module_type: "Decay0Gen"
   isotope: "K40"
   volume_gen:".*Cathode.*"
   material: ".*"
   BqPercc: 0.0091
   # Should be 4.9 Bq/kg (measured for 40K) times a density of 1.85 g/cc for 3 mm thick G10 -JReichenbacher (01/11/2017)
   # For Decay0 3mm factor is not needed, since full cathode volume is retrieved from the MC geometry - TBezerra (18/02/2022)
}

dune10kt_1x2x6_238U_chain_in_CPA:{ // again beware of geometry change here
   module_type: "Decay0Gen"
   volume_gen:".*Cathode.*"
   material: ".*"
   decay_chain:{ # ALL THESE ARE ASSUMED TO BE @ EQUILIBRIUM!!
      isotope_0:"U238"
      isotope_1:"Th234"
      isotope_2:"Pa234m"
      isotope_3:"U234"
      isotope_4:"Th230"
      isotope_5:"Ra226"
      isotope_6:"Rn222"
      isotope_7:"Po218"
      isotope_8:"Pb214"
      isotope_9:"Bi214"
      isotope_10:"Pb210"
      isotope_11:"Bi210"
      isotope_12:"Po210"
   }
   BqPercc: 1.13e-4
   # Should be 6.105e-2 Bq/kg times a density of 1.85 g/cc for 3 mm thick G10 -JReichenbacher (01/11/2017)
   # For Decay0 3mm factor is not needed, since full cathode volume is retrieved from the MC geometry - TBezerra (18/02/2022)
}

dune10kt_1x2x6_60Co_in_APA:{ // similar story as in the cathode
   module_type: "Decay0Gen"
   volume_gen:".*APA.*"
   material: "STEEL_STAINLESS_Fe7Cr2Ni"
   isotope: "Co60"
   BqPercc: 3.61e-4 # 45.5 mBq/kg = 45.5e-6 Bq/g (MPIK 2008 high measurement) and a density of 7.9300 g/cm3 (from gdml)
}

dune10kt_1x2x6_238U_chain_in_APA:{ // similar story as in the cathode
   module_type: "Decay0Gen"
   volume_gen:".*APA.*"
   material: "STEEL_STAINLESS_Fe7Cr2Ni"
   decay_chain:{ # ALL THESE ARE ASSUMED TO BE @ EQUILIBRIUM!!
      isotope_0:"U238"
      isotope_1:"Th234"
      isotope_2:"Pa234m"
      isotope_3:"U234"
      isotope_4:"Th230"
      isotope_5:"Ra226"
      isotope_6:"Rn222"
      isotope_7:"Po218"
      isotope_8:"Pb214"
      isotope_9:"Bi214"
      isotope_10:"Pb210"
      isotope_11:"Bi210"
      isotope_12:"Po210"
   }
   BqPercc: 9.5e-2 # 12 Bq/kg, and then very similar story as before dune10kt_1x2x6_60Co_in_APA
}

dune10kt_222Rn_chain_in_LAr:{ #only use this if x-profile not needed
   module_type:"Decay0Gen"
   BqPercc: 0.000001395
   volume_rand: "volCryostat"
   material: "LAr"
   decay_chain:{ # ALL THESE ARE ASSUMED TO BE @ EQUILIBRIUM!!
      isotope_0:"Rn222"
      isotope_1:"Po218"
      isotope_2:"Pb214"
      isotope_3:"Bi214"
      isotope_4:"Pb210"
      isotope_5:"Bi210"
      isotope_6:"Po210"
   }
}

dune10kt_222Rn_chain_in_PDS:{
   module_type:"Decay0Gen"
   # Arapucas have the following size: 2.3 x 11.8 x 209.2, this makes a total AREA of 5,953.72 cm^2
   # 0.2 Bq/m^2 is the requirement
   # total activity is then: 0.11907 Bq / Arapuca
   # this translate to 0.11907/(2.3x11.8x209.2) = 0.000021 Bq/cm^3
   BqPercc: 0.000021
   volume_gen: ".*Arapuca.*"
   decay_chain:{ # ALL THESE ARE ASSUMED TO BE @ EQUILIBRIUM!!
      isotope_0:"Rn222"
      isotope_1:"Po218"
      isotope_2:"Pb214"
      isotope_3:"Bi214"
      isotope_4:"Pb210"
      isotope_5:"Bi210"
      isotope_6:"Po210"
   }
}



dune10kt_222Rn_chain_222RnOnly_in_LAr:{
   module_type:"Decay0Gen"
   BqPercc: 0.000001395
   volume_rand: "volCryostat"
   material: "LAr"
   isotope:"Rn222"
}


dune10kt_222Rn_chain_218PoOnly_in_LAr:{
   @table::dune10kt_222Rn_chain_222RnOnly_in_LAr
   isotope:"Po218"
   BqPercc: 0.000001203885 # Rn222 rate minus the 13.7% on the cathode
   distrib_x: "936.088+2.81714*TMath::Abs(x)-0.00403933*x*x-1.24485e-06*TMath::Power(TMath::Abs(x),3)"
}
dune10kt_222Rn_chain_218PoOnly_in_CPA:{
   @table::dune10kt_222Rn_chain_218PoOnly_in_LAr
   volume_gen: ".*Cathode.*"
   material: @erase
   BqPercc:0.00528
   distrib_x: @erase
}


dune10kt_222Rn_chain_214PbOnly_in_LAr:{
   @table::dune10kt_222Rn_chain_222RnOnly_in_LAr
   isotope:"Pb214"
   BqPercc: 0.000000827235 # Rn222 rate minus the 40.7% on the cathode
   distrib_x: "590.016+1.83392*TMath::Abs(x)+0.00012101*x*x-5.42539e-06*TMath::Power(TMath::Abs(x),3)"
}
dune10kt_222Rn_chain_214PbOnly_in_CPA:{
   @table::dune10kt_222Rn_chain_214PbOnly_in_LAr
   volume_gen: ".*Cathode.*"
   material: @erase
   BqPercc:0.015678
   distrib_x: @erase
}


dune10kt_222Rn_chain_214BiOnly_in_LAr:{
   @table::dune10kt_222Rn_chain_222RnOnly_in_LAr
   isotope:"Bi214"
   BqPercc:0.00000045756 # Rn222 rate minus the 67.2% on the cathode
   distrib_x: "263.835+1.32691*TMath::Abs(x)-0.000128904*x*x-1.64996e-06*TMath::Power(TMath::Abs(x),3)"
}
dune10kt_222Rn_chain_214BiOnly_in_CPA:{
   @table::dune10kt_222Rn_chain_214BiOnly_in_LAr
   volume_gen: ".*Cathode.*" // The rest of the 42K go to the cathode
   material: @erase
   BqPercc:0.025886
   distrib_x: @erase
}


dune10kt_222Rn_chain_210PbOnly_in_LAr:{
   @table::dune10kt_222Rn_chain_222RnOnly_in_LAr
   isotope:"Pb210"
   BqPercc:0.00000045756 # Rn222 rate minus the 67.2% on the cathode
   distrib_x:"259.482+1.58444*TMath::Abs(x)-0.00214077*x*x+1.95097e-06*TMath::Power(TMath::Abs(x),3)"
}
dune10kt_222Rn_chain_210PbOnly_in_CPA:{
   @table::dune10kt_222Rn_chain_210PbOnly_in_LAr
   volume_gen: ".*Cathode.*" // The rest of the 42K go to the cathode
   material: @erase
   BqPercc:0.025886
   distrib_x: @erase
}


dune10kt_222Rn_chain_from210Bi_in_CPA:{
   @table::dune10kt_222Rn_chain_210PbOnly_in_CPA
   BqPercc:0.0385
   isotope: @erase
   decay_chain:{ # ALL THESE ARE ASSUMED TO BE @ EQUILIBRIUM!!
      isotope_0:"Bi210"
      isotope_1:"Po210"
   }
}


// This is copied straight from dune_radiological_model.fcl
// This is MASSIVELY dependant on the geometry
dune10kt_1x2x6_neutron_from_rock: // Center region is added to simulate neutrons comming in from the rock at the outermost APAs (on the edge of the cryostat) per J. Reichenbacher's request. This should more accurately represent the worst case scenario in the FD.
{
   module_type:           "RadioGen"
   Nuclide:               ["Concrete_DUNE10MeV", "Concrete_DUNE10MeV", "Concrete_DUNE10MeV", "Concrete_DUNE10MeV", "Concrete_DUNE10MeV" ]
   Material:              [".*",".*",".*",".*", ".*"]
   BqPercc:               [ 0.0000076, 0.0000076, 0.0000076, 0.0000076, 0.0000076 ] # activity -- Becquerels per cc. 0.0000076 assumes 10 neutrons/y/g per 10 ppm U-238 in concrete and a density of 2.40 g/cc for 10 cm mean depth in concrete -JReichenbacher (03/21/2017)
   T0:                    [ -2246000.,-2246000.,-2246000.,-2246000.,-2246000 ] # ending time in ns
   T1:                    [  2246000., 2246000., 2246000., 2246000., 2246000 ] # ending time in ns
   
   X0:                    [    0. ,    0. ,    0.,    0.,   -0.5 ] # in cm in world coordinates, bottom corner of box
   X1:                    [  350. ,  350. ,  350.,  350.,    0.5 ] # in cm in world coordinates, top corner of box
   Y0:                    [ -600. , -600. , -601.,  600., -600.  ] # in cm in world coordinates, bottom corner of box
   Y1:                    [  600. ,  600. , -600.,  601.,  600.  ] # in cm in world coordinates, top corner of box
   Z0:                    [   -0.5, 1394.5,    0.,    0.,    0.  ] # in cm in world coordinates, bottom corner of box
   Z1:                    [    0.5, 1395.5, 1395., 1395., 1395.  ] # in cm in world coordinates, top corner of box
}

END_PROLOG