Module calibrations_mod

module calibrations_mod

        ! Uses
    use precision_mod
    use det_geom_mod
    use namelist_mod
    use strs_mod
    use track_resolution_mod

        ! Types
    public type bfldkey
    public type corrections_type
    public type T0_type
    public type adc_calib_type

        ! Variables
    real (kind=r4), public :: BField
    type (bfldkey), public, TARGET :: bfld
    real, public :: TriggerTime
    real, public :: TriggerTimeDC
    real, public :: TriggerTimePC
    real, public :: TriggerTimeSC
    real, public :: TriggerTimeTC
    integer, public, dimension (2) :: TriggerGateEnd
    real (kind=r4), public, dimension (MAX_PLANES_T*MAX_WIRES_T) :: TCtmkpar
    real (kind=r4), public, dimension (9,MAX_PLANES_T*MAX_WIRES_T) :: TCtcor
    type (corrections_type), public, DIMENSION(MAX_PLANES_D) :: dcplane_corr
    type (corrections_type), public, DIMENSION(MAX_PLANES_P) :: pcplane_corr
    type (corrections_type), public, dimension (MAX_PLANES_D,MAX_WIRES_D) :: dcwire_corr
    type (corrections_type), public, dimension (MAX_PLANES_P,MAX_WIRES_P) :: pcwire_corr
    type (T0_type), public, DIMENSION(MAX_PLANES_D,MAX_WIRES_D), TARGET :: dc_t0 = t0_type (0.0, 0.0, 0.0)
    type (T0_type), public, DIMENSION(MAX_PLANES_P,MAX_WIRES_P), TARGET :: pc_t0 = t0_type (0.0, 0.0, 0.0)
    type (T0_type), public, DIMENSION(MAX_SCINTS), TARGET :: sc_t0 = t0_type (0.0, 0.0, 0.0)
    type (T0_type), public, DIMENSION(MAX_PLANES_T,MAX_WIRES_T), TARGET :: tc_t0 = t0_type (0.0, 0.0, 0.0)
    real (kind=r4), public, PARAMETER :: pcadc_conversion = 0.2
    type (adc_calib_type), public, DIMENSION(MAX_PLANES_P,MAX_WIRES_P) :: PC_adc_calib
    type (adc_calib_type), public, DIMENSION(MAX_SCINTS,1) :: SC_adc_calib
    real (kind=r4), public, DIMENSION(MAX_PLANES_D,MAX_WIRES_D) :: Eff
    integer (kind=i4), public, PARAMETER :: DCDriftBinMax = 30
    real (kind=r4), public, PARAMETER :: DCDriftBinSize = 100.E-04
    real (kind=r4), public, dimension (DCDriftBinMax) :: DCsigma2
    integer, public, PARAMETER :: NXY_TC_IND = 651
    integer, public, PARAMETER :: NZ_TC_IND = 11
    real (kind=r4), public, DIMENSION(NXY_TC_IND,NZ_TC_IND) :: tc_table
    real (kind=r4), public, DIMENSION(NXY_TC_IND) :: tec_dttim
    real (kind=r4), public, DIMENSION(NXY_TC_IND) :: tec_dtpos
    real (kind=r4), public :: grid_step_TC
    integer (kind=i4), public :: istrversion
    logical, public :: UseDataDerivedSTR
    real (kind=r4), public, dimension (5,48) :: tc_para

        ! Subroutines and functions
    public subroutine CalibRead ()
    private subroutine CalibBfldSet ()
    private subroutine CalibPlaneCorrUV ()
    private subroutine CalibPCPlaneCorrUV ()
    private subroutine CalibPlaneCorrZ ()
    private subroutine CalibPlaneCorrRot ()
    private subroutine CalibWireCorrUV ()
    private subroutine CalibWireCorrZ ()
    private subroutine CalibWireCorrRot ()
    private subroutine CalibSTR ()
    private subroutine CalibT0 ()
    private subroutine CalibADC ()
    private subroutine CalibEff ()
    private subroutine CalibRes ()
    private subroutine CalibTCStr ()
    private subroutine CalibTCTWK ()
    private subroutine TCSTRCorrection ()
    private subroutine CalibResolution ()

end module calibrations_mod

Description of Types

bfldkey

public type bfldkey
    integer :: jfield
    real (kind=r4) :: field_max
    real (kind=r4) :: b_theta
    real (kind=r4) :: b_phi
    real (kind=r4), dimension (3) :: detect_pos
end type bfldkey

corrections_type

public type corrections_type
    real (kind=r4) :: UVshift
    real (kind=r4) :: rotation
    real (kind=r4) :: Zshift
end type corrections_type

T0_type

public type T0_type
    real (kind=r4) :: time
    real (kind=r4) :: sigma
    real (kind=r4) :: frac
end type T0_type

adc_calib_type

public type adc_calib_type
    real (kind=r4) :: e_conversion
    real (kind=r4) :: pedestal
    real (kind=r4) :: ped_sigma
end type adc_calib_type

Description of Variables

BField

real (kind=r4), public :: BField
 Bfield Variables
Integer(i4), PUBLIC::    BSwitch
 BField will be filled with the field at the origin, while the bfld
 structure has all of the initial settings from bfld set file or BFLD
 bank for MC (BJ)

bfld

type (bfldkey), public, TARGET :: bfld

TriggerTime

real, public :: TriggerTime
 global time offset, in ns. Reset for overall trigger timing changes

TriggerTimeDC

real, public :: TriggerTimeDC

TriggerTimePC

real, public :: TriggerTimePC

TriggerTimeSC

real, public :: TriggerTimeSC

TriggerTimeTC

real, public :: TriggerTimeTC

TriggerGateEnd

integer, public, dimension (2) :: TriggerGateEnd

TCtmkpar

real (kind=r4), public, dimension (MAX_PLANES_T*MAX_WIRES_T) :: TCtmkpar

TCtcor

real (kind=r4), public, dimension (9,MAX_PLANES_T*MAX_WIRES_T) :: TCtcor

dcplane_corr

type (corrections_type), public, DIMENSION(MAX_PLANES_D) :: dcplane_corr

pcplane_corr

type (corrections_type), public, DIMENSION(MAX_PLANES_P) :: pcplane_corr

dcwire_corr

type (corrections_type), public, dimension (MAX_PLANES_D,MAX_WIRES_D) :: dcwire_corr

pcwire_corr

type (corrections_type), public, dimension (MAX_PLANES_P,MAX_WIRES_P) :: pcwire_corr

dc_t0

type (T0_type), public, DIMENSION(MAX_PLANES_D,MAX_WIRES_D), TARGET :: dc_t0 = t0_type (0.0, 0.0, 0.0)
T0 calibration constants

pc_t0

type (T0_type), public, DIMENSION(MAX_PLANES_P,MAX_WIRES_P), TARGET :: pc_t0 = t0_type (0.0, 0.0, 0.0)

sc_t0

type (T0_type), public, DIMENSION(MAX_SCINTS), TARGET :: sc_t0 = t0_type (0.0, 0.0, 0.0)

tc_t0

type (T0_type), public, DIMENSION(MAX_PLANES_T,MAX_WIRES_T), TARGET :: tc_t0 = t0_type (0.0, 0.0, 0.0)

pcadc_conversion

real (kind=r4), public, PARAMETER :: pcadc_conversion = 0.2
ADC calibration constants

PC_adc_calib

type (adc_calib_type), public, DIMENSION(MAX_PLANES_P,MAX_WIRES_P) :: PC_adc_calib

SC_adc_calib

type (adc_calib_type), public, DIMENSION(MAX_SCINTS,1) :: SC_adc_calib

Eff

real (kind=r4), public, DIMENSION(MAX_PLANES_D,MAX_WIRES_D) :: Eff
DC efficiencies

DCDriftBinMax

integer (kind=i4), public, PARAMETER :: DCDriftBinMax = 30

DCDriftBinSize

real (kind=r4), public, PARAMETER :: DCDriftBinSize = 100.E-04

DCsigma2

real (kind=r4), public, dimension (DCDriftBinMax) :: DCsigma2

NXY_TC_IND

integer, public, PARAMETER :: NXY_TC_IND = 651

NZ_TC_IND

integer, public, PARAMETER :: NZ_TC_IND = 11

tc_table

real (kind=r4), public, DIMENSION(NXY_TC_IND,NZ_TC_IND) :: tc_table

tec_dttim

real (kind=r4), public, DIMENSION(NXY_TC_IND) :: tec_dttim

tec_dtpos

real (kind=r4), public, DIMENSION(NXY_TC_IND) :: tec_dtpos

grid_step_TC

real (kind=r4), public :: grid_step_TC

istrversion

integer (kind=i4), public :: istrversion

UseDataDerivedSTR

logical, public :: UseDataDerivedSTR

tc_para

real (kind=r4), public, dimension (5,48) :: tc_para

Description of Subroutines and Functions

CalibRead

public subroutine CalibRead ()
    ! Calls: CalibADC, CalibBfldSet, CalibPCPlaneCorrUV, CalibPlaneCorrRot, CalibPlaneCorrUV, CalibPlaneCorrZ, CalibRes, CalibSTR, CalibT0, CalibTCStr, CalibTCTWK, TCSTRCorrection
end subroutine CalibRead

CalibBfldSet

private subroutine CalibBfldSet ()
    ! Calls: CDFGET, KERROR, Rite, kerror
end subroutine CalibBfldSet

CalibPlaneCorrUV

private subroutine CalibPlaneCorrUV ()
    ! Calls: CDFGET, Rite, kerror
end subroutine CalibPlaneCorrUV

CalibPCPlaneCorrUV

private subroutine CalibPCPlaneCorrUV ()
    ! Calls: CDFGET, Rite, kerror
end subroutine CalibPCPlaneCorrUV

CalibPlaneCorrZ

private subroutine CalibPlaneCorrZ ()
    ! Calls: CDFGET, Rite, kerror
end subroutine CalibPlaneCorrZ

CalibPlaneCorrRot

private subroutine CalibPlaneCorrRot ()
    ! Calls: CDFGET, Rite, kerror
end subroutine CalibPlaneCorrRot

CalibWireCorrUV

private subroutine CalibWireCorrUV ()
    ! Calls: CDFGET, Rite, kerror
end subroutine CalibWireCorrUV

CalibWireCorrZ

private subroutine CalibWireCorrZ ()
    ! Calls: CDFGET, Rite, kerror
end subroutine CalibWireCorrZ

CalibWireCorrRot

private subroutine CalibWireCorrRot ()
    ! Calls: CDFGET, Rite, kerror
end subroutine CalibWireCorrRot

CalibSTR

private subroutine CalibSTR ()
    ! Calls: CDFGET, Rite, exit, init_STRs, kerror
end subroutine CalibSTR

CalibT0

private subroutine CalibT0 ()
    ! Calls: CDFGET, Rite, kerror
end subroutine CalibT0

CalibADC

private subroutine CalibADC ()
    ! Calls: CDFGET, Rite, kerror
end subroutine CalibADC

CalibEff

private subroutine CalibEff ()
    ! Calls: CDFGET, Rite, kerror
end subroutine CalibEff

CalibRes

private subroutine CalibRes ()
    ! Calls: CDFGET, Rite, kerror
end subroutine CalibRes

CalibTCStr

private subroutine CalibTCStr ()
    ! Calls: CDFGET, Rite, kerror
end subroutine CalibTCStr

CalibTCTWK

private subroutine CalibTCTWK ()
    ! Calls: CDFGET, Rite, kerror
end subroutine CalibTCTWK

TCSTRCorrection

private subroutine TCSTRCorrection ()
    ! Calls: CDFGET, Rite, kerror
end subroutine TCSTRCorrection

CalibResolution

private subroutine CalibResolution ()
    ! Calls: read_resolution
end subroutine CalibResolution