////////////////////////////////////////////////////////////////////
///
/// \brief   DAQ settings
///
///
/// REVISION HISTORY:\n
///     24 Feb 2010 : Gabriel Orebi Gann - Changed noise_rate from a number of
///                   hits per event to an actual mean rate (per PMT), in Hz
///                     - Included a flag for the noise model
///                     - Included a flag for the channel efficiency correction
///     05 Mar 2010 : Gabriel Orebi Gann - Include per-PMT noise rate array here,
///                                       (instead of the now obsolete DAQTHRESH.ratdb)
///                     - Included a flag for whether to use DQXX info to skip offline tubes
///                     Default value: 0, meaning NO, so as not to change people's simulations
///                     - Included a flag for whether to use SNO or SNO+ definitions
///                     to determine tube status (this allows for SNO+ to use a different
///                     definition from SNO, but still lets us do comparisons to SNOMAN MC).
///                     Default value: 0, meaning SNO+ definitions (which as of today are the
///                     same as SNO, but this provides the option for that to change in future).
///     12 Mar 2010 : Gabriel Orebi Gann - Remove noise control
///     03 Nov 2010 : Gabriel Orebi Gann - Add MTCA retrigger status
///     02 Apr 2015 : Gabriel Orebi Gann - Removed run-level settings to DAQ_RUN_LEVEL
///                     Remove "fprompt" specification (not used, and belongs with classifiers)
///     10 July 2015: Freija Descamps - Migrated HHP channel-specific PMT charge distributions
///                                     from PMTCALIB to here.
///     10 Mar 2017: T. Kaptanoglu - Change N20 width to 40ns from 25ns
///     29 Nov 2017: T. Kaptanoglu - Move variable that is used to decide whether to
///                                  digitize waveforms from run level to here. Also
///                                  add a rough empirical offset to center CAEN waveforms.
///     4 Jan 2018: T. Kaptanoglu -  Add option for perfect trigger efficiency
///
/// \details   This file includes settings for the DAQ and trigger simulation
///            that are expected NOT to change on a run-by-run basis, e.g.
///            parameters that change less often (pulse rise time),
///            or are user-defined inputs.
///            Run-level settings have been moved to DAQ_RUN_LEVEL.ratdb
///
////////////////////////////////////////////////////////////////////
/* Control for Data Acquisition Simulation*/
{
type: "DAQ",
version: 1,
run_range: [0, 0],
pass: 0,
comment: "",
timestamp: "",

//Front End specifications
sampling_time: 410.0, //full gate for grouping hits in a single integration
shortint_time: 60.0, //short integration time in ns (`SAMPLE')
longint_time: 390.0, //long integration time in ns (`RESET')
lowgain_factor: 16.0, //low gain charge is attenuated by 1/this amount
pulse_type:0, //0=square pulses, 1=realistic pulses
             //must change pulse_width definition below depending on selection
pulse_width: 15.0, //PMT pulse width in ns for square pulses
//pulse_width: 0.22, //PMT pulse width in log(ns) for real pulses
pulse_offset: 0.0, //PMT pulse offset in mV
pulse_mean: 2.727, //PMT pulse mean in log(ns) (for lognormal shape only)
step_time: 0.1, //stepping time for PMT waveforms
pulse_min: 0.001, //minimum pulse height to consider (in ADC counts!)
noise_amplitude: 0.61, //amplitude of high frequency noise in adc counts
gate_delay: 10.0, //time before discriminator fires that sampling gate opens

//
//Trigger specifications
//

trig_step_time: 0.25, //stepping time for trigger waveforms
triggerfecdelay: 110.0,  //delay of trigger signals from front end electronics
fulltriggerword: 0, // set to 1 to store full trigger word in mcev (ignores mtcd latching)

//MTC/D `digital' information


lockout: 420.0, //trigger lockout time in ns

prescale_delay: 30.0, // Internal delay for initiation of prescale pulse
prescale_width: 20.0, // Width of prescale raw trig (ns)
pulse_gtmin: 1600.0, // Minimum Pulse GT period in NS (note units!)
pulse_gt_default: 100.0, // If minimum PGT is violated, default to this (in ms, note units!)
pulsegtwidth: 20.0, // Width of pulse GT rawTrig pulse (ns)
trig_latch: 10.0, //latching time for trigger bits
extasync_time: 140.0, //Time ext-asy trigger will arrive relative to the MC event start

//MTC/A information
//Note NHIT thresholds are all floats

rawtrigwidth: 20.0, // raw trigger pulse width

//Trigger `primitive' information -- specifies pulse and waveform shapes

n100_width: 89.4, //width of 100 ns square `nhit' pulses
n20_width: 46.0, //width of 40 ns square `nhit' pulses
esum_width: 15.0, //half-width of esum pulses
nhit_dropout:1.25, //mean number of dropout channels
//////trig_amp_jitter:0.07, //fractional amplitude jitter in NHIT trigger pulse
esum_mvperpe:0.75, //mV per pe conversion for ESUM pulseheights
esum_adcperpe:30.0, //adc counts per pe (eventually should come from PCA)
baseline_drift: 0.8, //RMS of NHIT trigger baseline drift (in NHIT)
nhit_noise: 0.30, //RMS of NHIT trigger noise (in NHIT)
esum_noise: 0.13, //RMS of ESUM trigger noise (in mV)
trig_jitter:0.07, //fractional RMS of jitter in NHIT trigger pulse amplitude

lo_gain: 1.0    // The amount of gain on a low threshold MTCA+ channel
med_gain: 0.27, // The amount of gain on a medium threhsold MTCA+ channel
hi_gain: 0.1,   // The amount of gain on a high threshold MTC+ channel


// CAEN Digitiser Information
digTrigSum: 0,     // flag to control digitisation: off by default
latency: 32,       // latency from the FPGA (samples). Empirical and rough.
gtCaenDelay: 2.0,  // Delay of GT from MTCD to CAEN  / ns
trigSumDelay: 2.0, // Delay of TrigSums from MTCA+ to CAEN / ns
nBits: 12,          // Number of bits per sample (shouldn't change)
scaleCAEN: [38.0:8], // Scaling applied to each trigSum for CAEN.

// TUBii Simulation Settings
attenuationValues:[-0.2:8], // TUBii's attenuation for a given channel
unityGainValues: [-1.0:8], // TUBii's "unity" gain for a given channel
baselineShift: [0.0:8], //TUBii's baseline shift for a given channel


//Event Builder specifications
gtriggerdelay: 110.0,    //delay of global trigger back to front end electronics
fecddelay: 50.0,         //delay of raw trigger back to fecd channels
fecdchannel: 23,         //channel on fecd used for raw trigger out from MTCD
triggergate:  400.0, //width of trigger gate to collect hits

// Uncalibration (of PMT hit T, Q) specifications
uncal_type: 11, // Default to everything (11) (0: leave empty; 9: copy PMTTruth)
// Flag to specify ECA calibrations:
eca_type: 11, // Default to everything (11) (= ped + 10*tslope)
pca_type: 11, // ?? TBC
// ECA rate and occupancy
eca_pdst_pattern: 5, //Channel by channel
eca_pdst_rate: 10, //Hz
eca_tslp_pattern: 5, //Channel by channel
eca_tslp_rate: 200, //Hz

//Channel Efficiency correction
chaneff_flag: 0,   // 0 = no correction; 1 = use average chanEff across tubes; 2 = tube-by-tube

// DQXX information flags
dqxx_info: 1,  // Use DQXX info to skip offline tubes in the simulation? (0: no, 1: yes)
dqxx_expt: 0,  // Which expt definitions to use in determining tube status (0: sno+, 1: sno)
use_const_channel_thresh: 0,  // Use a single channel threshold across all channels (instead of calc from DQXX)
const_channel_thresh: 9,       // Channel threshold to use for all channels if flag above (constChanThresh) is set

// HHP setting
// Enable channel-specific PMT charge distributions
// 1 = Use the HHP values in the "QHS_hhp" array from PMTCALIB table
// 0 = Use the average "mean_hhp" for all channels
use_qhs_hhp: 1,

// Perfect trigger efficiency
perfect_trigger: 0, // off by default
// Realistic trigger efficiency, to use this
// need to pass a run-number
realistic_trigger: 0, // off by default
// store all the MCHits
store_all_hits: false, // set to true to store all hits in the MCHits

// Deal with long-lived particles
// These cut-off times are specific for the DAQ
jump_time: 10000.0, // amount of time between hits to override stepping algorithm
apply_cutoff: 0, // apply the cut-off time. Set this to one if you expect long lived particles in your simulation.
cutoff_time: 10000000.0, // default 10ms

}