Skip to content

Commit 22cb3e2

Browse files
ftouchteFelix Touchte CodjoFelix Touchte Codjo
authored
Fix AHDC pulse indexing and estimate the pedestal of the AHDC waveform using the first five samples (#480)
* Recover more data from AHDC pulse * caotjava for mon12/ahdc (fix merging conflicts) * Don't change HipoExtractor but Override ModeAHDC * Declare `protected` some methods of HipoExtractor * Estimate the pedestal using the first five samples * Fix AHDC pulse indexing --------- Co-authored-by: Felix Touchte Codjo <[email protected]> Co-authored-by: Felix Touchte Codjo <[email protected]>
1 parent 141e407 commit 22cb3e2

File tree

1 file changed

+6
-2
lines changed
  • common-tools/clas-detector/src/main/java/org/jlab/detector/pulse

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public List<Pulse> extract(NamedEntry pars, int id, short... samples){
5858
float leadingEdgeTime = 0; // moment when the signal reaches a Constant Fraction of its Amplitude uphill (fitted)
5959
float trailingEdgeTime = 0; // moment when the signal reaches a Constant Fraction of its Amplitude downhill (fitted)
6060
float timeOverThreshold = 0; // is equal to (timeFallCFA - timeRiseCFA)
61-
float constantFractionTime ; // time extracted using the Constant Fraction Discriminator (CFD) algorithm (fitted)
61+
float constantFractionTime = 0; // time extracted using the Constant Fraction Discriminator (CFD) algorithm (fitted)
6262
/// /////////////////////////
6363
// Begin waveform correction
6464
/// ////////////////////////
@@ -75,11 +75,14 @@ public List<Pulse> extract(NamedEntry pars, int id, short... samples){
7575
//private void waveformCorrection(short[] samples, short adcOffset, float samplingTime, int sparseSample, int binMax, int adcMax, int integral, short samplesCorr[], int binOffset, int timeMax){
7676
binNumber = samples.length;
7777
binMax = 0;
78+
if (binNumber >= 5) {
79+
adcOffset = (short) ((samples[0] + samples[1] + samples[2] + samples[3] + samples[4])/5); // try to estimate the baseline (pedestal) using the first five samples
80+
}
7881
adcMax = (short) (samples[0] - adcOffset);
7982
integral = 0;
8083
samplesCorr = new short[binNumber];
8184
for (int bin = 0; bin < binNumber; bin++){
82-
samplesCorr[bin] = (short) (samples[bin] - adcOffset);
85+
samplesCorr[bin] = (short) Math.max(samples[bin] - adcOffset, 0);
8386
if (adcMax < samplesCorr[bin]){
8487
adcMax = samplesCorr[bin];
8588
binMax = bin;
@@ -239,6 +242,7 @@ public List<Pulse> extract(NamedEntry pars, int id, short... samples){
239242
//}
240243
// output
241244
Pulse pulse = new Pulse();
245+
pulse.id = id;
242246
pulse.adcMax = adcMax;
243247
pulse.time = timeMax;
244248
pulse.timestamp = timestamp;

0 commit comments

Comments
 (0)