////////////////////////////////////////////////////////////////////
///
/// \brief   User control of calibration processors
///
/// \author Gabriel D. Orebi Gann <orebi@hep.upenn.edu>
///
///
/// REVISION HISTORY:\n
///
/// 15 Feb 2013: Freija Descamps (fbdescamps@lbl.gov)
///              Add PCACal details
///
/// 18 May 2015: Javier Caravaca (jcaravaca@berkeley.edu)
///              Add eca_occupancy, eca_rate and eca_logverbosity
///
/// 6 April 2017: Javier Caravaca (jcaravaca@berkeley.edu)
///               Allow different rate and pattern calibrations for
///               pedestal and time slopes
///
/// 22 Aug 2017: Ed Callaghan (ejc3@berkeley.edu)
///              Add default blacklist of triggers excluded from
///              noise calculation
///
/// \details   This file is for user control of the calibrations
///           (equivalent to the TCAL bank in SNO).
///           This is used to control application of:
///           - ECA constants (pedestals and time slopes)
///           - PCA constants
///           etc
///           to uncalibrated data/MC events.
///           Pedestals are subtracted from the Q measure
///           in ADC counts, and times in ADC counts are converted
///           to ns.  The results are stored in PMTCal.
///           NB there is also an option to just store PMTTruth info.
///           This is controlled by the flag `cal_type'.
///
///           To control generation of the ECA constants, see
///           ECA_generation.ratdb and ECAProc.cc,hh.
///
///           To control generation of the PCA constants, see
///           PCA_generation.ratdb and PCAProc.cc,hh.
///
////////////////////////////////////////////////////////////////////
{
type: "PMTCAL",
version: 1,
run_range: [0, 0],
pass: 0,
comment: "",
timestamp: "",

// Flag to specify ECA calibrations:
//   0: Do nothing
// + 1: Do pedestals (offset for Q, smearing for Q and T)
// +10: Do time slope (convert ADC -> ns)
eca_type: 11, // Default to everything (11) (= ped + 10*tslope)
eca_logverbosity: 0,   // Set to 1 to catch the 'dontdie' warnings

// Flag to specify PCA calibrations:
//   0: Do nothing
// + 1: Do time walk (time correction)
// +10: Do gain fit calculation: not implemented
pca_type: 1, // Default to PCA time calibration


// ECA validation tolerance levels (value set to -9999):
// 1: Each Q/T for pathological channels
// 2: Each Q/T that fails cell validation
// 3: Each Q/T that fails cell validation + T if QHS fails
// 4: Each Q/T that fails cell validation + all Q/T if channel fails
eca_validation: 0,     // 0: generates ECA status word (PMTCal->SetECAstat())
                       // 1-4 set tolerance level


// PCA validation tolerance levels (value set to -9999):
// 1: WARN level
// 2: TEST level
// 3: WARN + TEST level
pca_validation: 0,     // 0: generates PCA status word (PMTCal->SetPCAstat())
                       // 1-3 set tolerance level


// ADC-check tolerance
eca_adc: 0,       // 0,1,2,3: do nothing, flag caldac/frati/both-flagged channels

// Pattern for ECA calibration
// 1. Double-beta running
// 2. Solar running
// 3. Diagnostic (similar to SNO: crate-by-crate)
// 4. Bonus diagnostic (ahem, couldn't resist)
// 5. Channel by channel (i-th channel on all cards and crates; i runs from 0-31)
// 6. SNO patterns (half-crate-by-half-crate)
eca_pdst_pattern: 5,
eca_tslp_pattern: 5,

// Rate for ECA calibration
eca_pdst_rate: 10,
eca_tslp_rate: 200,

// Time offset of calibrated data
time_offset: 500.0,

// ECA checks cut values
test_qhsmax: 4000,
test_qhlmax: 4000,
test_qlxmax: 4000,
test_qhsmin: -200,
test_qhlmin: -200,
test_qlxmin: -200,
test_qlxvsqhs: 10,

// Masks used to define good PMT-calibrated hits, cells or channels
ECA_hitmask: 0xB0000CE,   //hit-level (applied to PMT->fStatus, first 32 bits)
PCA_hitmask: 0x3C,        //hit-level (applied to PMT->fStatus, last 32 bits)
PDST_cellmask: 0x200700E, //cell-level (applied to ECA_PDST[pdst_status])
TSLP_cellmask: 0x4000001, //cell-level (applied to ECA_TSLP[tslp_status])
TW_chmask: 0x8000020E,    //channel-level (applied to PCA_TW[PCATW_status])

// Triggers excluded from noise rate calculation
noise_blacklist: "N100Low,N100Med,N100High,N20,N20LB,Prescale,Pedestal,MissTrig"

}