# These are the records that transform tick counts to time in nanoseconds, # by using the sampling frequency of the ADCs. # Giving the frequency in Hz, calculate the time in ns between each sample record (calc, "$(P):SAMP_TIME") { field(DESC, "Time between samples in ns") field(INPA, "$(P):ClkFreq CP") field(CALC, "1000000000/(2 * A)") } # Calculate the time correspondent to the number of samples of the pre-edge #m of the weight function record (calc, "$(P):PED_WIDTH_RBV") { field(DESC, "Duration of pre-edge in ns") field(INPA, "$(P):SAMP_TIME CP") field(INPB, "$(P):NumSamp0RBV") field(CALC, "A * B") } # Calculate the time correspondent to the number of samples of between edges # of the weight function. It must be at least the same size of the # pre-edge time because the time counts from the beginning of the pre-edge. record (calc, "$(P):GATE_START_RBV") { field(DESC, "Duration between edges in ns") field(INPA, "$(P):SAMP_TIME CP") field(INPB, "$(P):TrigDelay1RBV") field(CALC, "B*2 * A") } # Calculate the time correspondent to the number of samples of the pos-edge # of the weight function record (calc, "$(P):GATE_WIDTH_RBV") { field(DESC, "Duration of pos-edge in ns") field(INPA, "$(P):SAMP_TIME CP") field(INPB, "$(P):NumSamp1RBV") field(CALC, "A * B") } # Desired time of the weight function pre-edge record (ao, "$(P):PED_WIDTH") { field(DESC, "Duration of pre-edge in ns") field(DRVH, "724") field(HOPR, "724") info(autosaveFields, "VAL") } # Calculate the number of samples of the pre-edge of the weight function # giving the correspondent time and writes it to the firmware. Only even # numbers are allowed in the FPGA register (that is why we use ((~0)-1)& record (calcout, "$(P):NumSamp0_CLC") { field(DESC, "Number samples of pre-edge") field(INPA, "$(P):PED_WIDTH CP") field(INPB, "$(P):ClkFreq CP") field(CALC, "((~0)-1)&FLOOR((2*A*B)/1000000000)") field(OUT, "$(P):NumSamp0 PP") field(DOPT, "Use CALC") } # Desired time of the weight function between edges record (ao, "$(P):GATE_START") { field(DESC, "Duration of between edge in ns") field(DRVH, "1448") field(HOPR, "1448") info(autosaveFields, "VAL") } # Time between edges is doubled related to the edges. Also, timing zero for # this time is exactly timing zero for the pre-edge. So, we must not allow # that the between edges time keeps greater than the pre-edge. record (calc, "$(P):TIME_MIDC") { field(DESC, "Duration of between edge in ns") field(INPA, "$(P):PED_WIDTH CP") field(INPB, "$(P):GATE_START CP") field(CALC, "AABS(A-B)*0.35?A:C") field(INPA, "$(P):FAST_RAW_WF_MAX CP") field(INPB, "$(P):FAST_RAW_WF_MIN CP") field(OUT, "$(P):WF_MAX.C") field(DOPT, "Use CALC") field(NELM, "1024") } # Change the bottom of the visual weight function only if it is greater than 35% # of the last calculated bottom value. record (acalcout, "$(P):WF_MIN") { field(DESC, "Smooth function for the bottom") field(CALC, "ABS(B-C)>ABS(A-B)*0.35?B:C") field(INPA, "$(P):FAST_RAW_WF_MAX CP") field(INPB, "$(P):FAST_RAW_WF_MIN CP") field(OUT, "$(P):WF_MIN.C") field(DOPT, "Use CALC") field(NELM, "1024") } # Line before the edge (corresponding to +1 of the Weight Function) record (acalcout, "$(P):SCL_VWF_PRE") { field(DESC, "Equivalent to +1 in Weight") # Fills the array with the maximum of the raw waveform until the edge. # All other elements remain zero. field(CALC, "ARR(E){0,A-1}") field(NELM, "1024") # Number of samples pre-edge field(INPA, "$(P):NumSamp0 CP") field(INPE, "$(P):WF_MAX CP") # Raw waveform 16 bits. field(INAA, "$(P):FAST_WF_RAW_U16.VALA CP") } # Line after the edge (corresponding to -1 of the Weight Function) record (acalcout, "$(P):SCL_VWF_POS") { field(DESC, "Equivalent to -1 in Weight") # Fills the array with the minimum of the raw waveform after the edge. # All other elements remain zero. field(CALC, "ARR(D){B*2,B*2+C-1}") field(NELM, "1024") # Number of samples pre-edge field(INPA, "$(P):NumSamp0 CP") # Number of samples of the edge field(INPB, "$(P):TrigDelay1 CP") # Number of samples pos-edge field(INPC, "$(P):NumSamp1 CP") field(INPD, "$(P):WF_MIN CP") # Raw waveform 16 bits. field(INAA, "$(P):FAST_WF_RAW_U16.VALA CP") } # Line of the edge (corresponding to 0 of the Weight Function) record (acalcout, "$(P):SCL_VWF_MID") { field(DESC, "Equivalent to 0 in Weight") # Fills the array with the average of the maximum and minimum raw waveform # and places it between the pre and the pos-edge curves. # All other elements remain zero. field(CALC, "ARR((D+E)/2){A,B*2-1}") field(NELM, "1024") # Number of samples pre-edge field(INPA, "$(P):NumSamp0 CP") # Number of samples of the edge field(INPB, "$(P):TrigDelay1 CP") field(INPD, "$(P):WF_MAX CP") field(INPE, "$(P):WF_MIN CP") # Raw waveform 16 bits. field(INAA, "$(P):FAST_WF_RAW_U16.VALA CP") } # Last part of the weight function, after the pos-edge. record (acalcout, "$(P):SCL_VWF_FINAL") { field(DESC, "Final portion, after pos-edge") # Obtain the same value as used for the edge, placing it at the end of the # curve. field(CALC, "ARR((D+E)/2){B*2+C,-1}") field(NELM, "1024") # Number of samples pre-edge field(INPA, "$(P):NumSamp0 CP") # Number of samples of the edge field(INPB, "$(P):TrigDelay1 CP") # Number of samples pos-edge field(INPC, "$(P):NumSamp1 CP") field(INPD, "$(P):WF_MAX CP") field(INPE, "$(P):WF_MIN CP") # Raw waveform 16 bits. field(INAA, "$(P):FAST_WF_RAW_U16.VALA CP") } # This is the weight function multiplied by the raw min and max. The only # purpose is to fit the curve on the same chart as the raw data using the # same scale in the y-axis. record (acalcout, "$(P):SCL_VWF") { field(DESC, "Weight scaled for best plot") field(CALC, "AA+BB+CC+DD") field(NELM, "1024") field(INAA, "$(P):SCL_VWF_PRE.AVAL CP") field(INBB, "$(P):SCL_VWF_POS.AVAL CP") field(INCC, "$(P):SCL_VWF_MID.AVAL CP") field(INDD, "$(P):SCL_VWF_FINAL.AVAL CP") } # Calculated waveforms when multiplying raw for weight record (acalcout, "$(P):S_P_WF_CLC") { field(DESC, "Raw times weight") field(INAA, "$(P):FAST_WF_RAW_U16.VALA CP") field(INBB, "$(P):SCL_WF_CLC.AVAL CP") field(NELM, "1024") field(CALC, "AA * BB") } # Transform an acalcout AVAL info into an waveform VAL, just to maintain # compatibility with previous systems. record (waveform, "$(P):S_P_WF") { field(DESC, "Raw times weight") field(INP, "$(P):S_P_WF_CLC.AVAL CP") field(NELM, "1024") field(FTVL, "SHORT") }