Skip to content

Commit c251ca3

Browse files
author
Whitney Armstrong
committed
Better names for constant fraction variables
- #378 (comment)
1 parent 639cb66 commit c251ca3

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public List<Pulse> extract(NamedEntry pars, int id, short... samples){
4949
short[] samplesCorr; //Waveform after offset (pedestal) correction
5050
int binNumber = 0; //Number of bins in one waveform
5151

52-
float timeRiseCFA = 0; // moment when the signal reaches a Constant Fraction of its Amplitude uphill (fitted)
53-
float timeFallCFA = 0; // moment when the signal reaches a Constant Fraction of its Amplitude downhill (fitted)
54-
float timeOverThresholdCFA = 0; // is equal to (timeFallCFA - timeRiseCFA)
55-
float timeCFD =0 ; // time extracted using the Constant Fraction Discriminator (CFD) algorithm (fitted)
52+
float leadingEdgeTime = 0; // moment when the signal reaches a Constant Fraction of its Amplitude uphill (fitted)
53+
float trailingEdgeTime = 0; // moment when the signal reaches a Constant Fraction of its Amplitude downhill (fitted)
54+
float timeOverThreshold = 0; // is equal to (timeFallCFA - timeRiseCFA)
55+
float constantFractionTime ; // time extracted using the Constant Fraction Discriminator (CFD) algorithm (fitted)
5656
/// /////////////////////////
5757
// Begin waveform correction
5858
/// ////////////////////////
@@ -129,25 +129,26 @@ public List<Pulse> extract(NamedEntry pars, int id, short... samples){
129129
//computeTimeAtConstantFractionAmplitude(samplingTime,amplitudeFractionCFA);
130130
/**
131131
* This method determines the moment when the signal reaches a Constant Fraction of its Amplitude (i.e fraction*adcMax)
132-
* It fills the attributs : timeRiseCFA, timeFallCFA, timeOverThresholdCFA
132+
* It fills the attributs : leadingEdgeTime trailingEdgeTime, timeOverThreshold
133+
*
133134
* @param samplingTime time between 2 ADC bins
134135
* @param amplitudeFraction amplitude fraction between 0 and 1
135136
*/
136137
//private void computeTimeAtConstantFractionAmplitude(float samplingTime, float amplitudeFractionCFA){
137138
float threshold = amplitudeFractionCFA*adcMax;
138-
// timeRiseCFA
139+
// leadingEdgeTime
139140
int binRise = 0;
140141
for (int bin = 0; bin < binMax; bin++){
141142
if (samplesCorr[bin] < threshold)
142143
binRise = bin; // last pass below threshold and before adcMax
143-
} // at this stage : binRise < timeRiseCFA/samplingTime <= binRise + 1 // timeRiseCFA is determined by assuming a linear fit between binRise and binRise + 1
144+
} // at this stage : binRise < leadingEdgeTime/samplingTime <= binRise + 1 // leadingEdgeTime is determined by assuming a linear fit between binRise and binRise + 1
144145
float slopeRise = 0;
145146
if (binRise + 1 <= binNumber-1)
146147
slopeRise = samplesCorr[binRise+1] - samplesCorr[binRise];
147148
float fittedBinRise = (slopeRise == 0) ? binRise : binRise + (threshold - samplesCorr[binRise])/slopeRise;
148-
timeRiseCFA = (fittedBinRise + binOffset)*samplingTime; // binOffset is determined in wavefromCorrection() // must be the same for all time ? // or must be defined using fittedBinRise*sparseSample
149+
leadingEdgeTime = (fittedBinRise + binOffset)*samplingTime; // binOffset is determined in wavefromCorrection() // must be the same for all time ? // or must be defined using fittedBinRise*sparseSample
149150

150-
// timeFallCFA
151+
// trailingEdgeTime
151152
int binFall = binMax;
152153
for (int bin = binMax; bin < binNumber; bin++){
153154
if (samplesCorr[bin] > threshold){
@@ -157,23 +158,23 @@ public List<Pulse> extract(NamedEntry pars, int id, short... samples){
157158
binFall = bin;
158159
break; // first pass below the threshold
159160
}
160-
} // at this stage : binFall - 1 <= timeRiseCFA/samplingTime < binFall // timeFallCFA is determined by assuming a linear fit between binFall - 1 and binFall
161+
} // at this stage : binFall - 1 <= timeRiseCFA/samplingTime < binFall // trailingEdgeTime is determined by assuming a linear fit between binFall - 1 and binFall
161162
float slopeFall = 0;
162163
if (binFall - 1 >= 0)
163164
slopeFall = samplesCorr[binFall] - samplesCorr[binFall-1];
164165
float fittedBinFall = (slopeFall == 0) ? binFall : binFall-1 + (threshold - samplesCorr[binFall-1])/slopeFall;
165-
timeFallCFA = (fittedBinFall + binOffset)*samplingTime;
166+
trailingEdgeTime = (fittedBinFall + binOffset)*samplingTime;
166167

167168
// timeOverThreshold
168-
timeOverThresholdCFA = timeFallCFA - timeRiseCFA;
169+
timeOverThreshold = trailingEdgeTime - leadingEdgeTime;
169170
//}
170171
/// /////////////////////////
171172
// Begin computeTimeUsingConstantFractionDiscriminator
172173
/// ////////////////////////
173174
//computeTimeUsingConstantFractionDiscriminator(samplingTime,fractionCFD,binDelayCFD);
174175
/**
175176
* This methods extracts a time using the Constant Fraction Discriminator (CFD) algorithm
176-
* It fills the attribut : timeCFD
177+
* It fills the attribut : constantFractionTime
177178
* @param samplingTime time between 2 ADC bins
178179
* @param fractionCFD CFD fraction parameter between 0 and 1
179180
* @param binDelayCFD CFD delay parameter
@@ -202,12 +203,12 @@ public List<Pulse> extract(NamedEntry pars, int id, short... samples){
202203
for (int bin = binHumpInf; bin <= binHumpSup; bin++){
203204
if (signal[bin] < 0)
204205
binZero = bin; // last pass below zero
205-
} // at this stage : binZero < timeCFD/samplingTime <= binZero + 1 // timeCFD is determined by assuming a linear fit between binZero and binZero + 1
206+
} // at this stage : binZero < constantFractionTime/samplingTime <= binZero + 1 // constantFractionTime is determined by assuming a linear fit between binZero and binZero + 1
206207
float slopeCFD = 0;
207208
if (binZero + 1 <= binNumber)
208209
slopeCFD = signal[binZero+1] - signal[binZero];
209210
float fittedBinZero = (slopeCFD == 0) ? binZero : binZero + (0 - signal[binZero])/slopeCFD;
210-
timeCFD = (fittedBinZero + binOffset)*samplingTime;
211+
constantFractionTime = (fittedBinZero + binOffset)*samplingTime;
211212

212213
//}
213214

@@ -236,10 +237,10 @@ public List<Pulse> extract(NamedEntry pars, int id, short... samples){
236237
pulse.time = timeMax;
237238
pulse.timestamp = timestamp;
238239
pulse.integral = integral;
239-
pulse.timeRiseCFA = timeRiseCFA;
240-
pulse.timeFallCFA = timeFallCFA;
241-
pulse.timeOverThresholdCFA = timeOverThresholdCFA;
242-
pulse.timeCFD = timeCFD;
240+
pulse.leadingEdgeTime = leadingEdgeTime ;
241+
pulse.trailingEdgeTime = trailingEdgeTime;
242+
pulse.timeOverThreshold = timeOverThreshold;
243+
pulse.constantFractionTime = constantFractionTime;
243244
//pulse.binMax = binMax;
244245
//pulse.binOffset = binOffset;
245246
pulse.pedestal = adcOffset;

common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Pulse.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public class Pulse {
1616
public int id;
1717

1818
public float adcMax;
19-
public float timeRiseCFA;
20-
public float timeFallCFA;
21-
public float timeOverThresholdCFA;
22-
public float timeCFD;
19+
public float leadingEdgeTime ;
20+
public float trailingEdgeTime;
21+
public float timeOverThreshold;
22+
public float constantFractionTime;
2323

2424
/**
2525
* Units are the same as the raw units of the samples.

0 commit comments

Comments
 (0)