From bb765b740084a376b704eb1d7878676d357a11dc Mon Sep 17 00:00:00 2001 From: Felix Touchte Codjo Date: Sun, 30 Mar 2025 08:43:46 -0400 Subject: [PATCH 1/3] Use pulse time and hide MVTFitter --- .../detector/decode/DetectorEventDecoder.java | 2 +- .../org/jlab/detector/pulse/ModeAHDC.java | 53 ++++--------------- 2 files changed, 12 insertions(+), 43 deletions(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java index d99b4544c7..da36a07577 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java @@ -168,7 +168,7 @@ public void fitPulses(List detectorData){ //custom MM fitter if( ( (table.equals("BMT"))&&(data.getDescriptor().getType().getName().equals("BMT")) ) || ( (table.equals("FMT"))&&(data.getDescriptor().getType().getName().equals("FMT")) ) - || ( (table.equals("AHDC"))&&(data.getDescriptor().getType().getName().equals("AHDC")) ) + //|| ( (table.equals("AHDC"))&&(data.getDescriptor().getType().getName().equals("AHDC")) ) || ( (table.equals("FTTRK"))&&(data.getDescriptor().getType().getName().equals("FTTRK")) ) ){ IndexedTable daq = fitterManager.getConstants(runNumber, table); short adcOffset = (short) daq.getDoubleValue("adc_offset", 0, 0, 0); diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java index d35b7731cb..f628908ab7 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java @@ -12,7 +12,7 @@ /** * A new extraction method dedicated to the AHDC signal waveform * - * Some blocks of code are inspired by MVTFitter.java + * Some blocks of code are inspired by MVTFitter.java and Bonus12 (`createBonusBank()`) * * @author ftouchte */ @@ -25,15 +25,15 @@ public class ModeAHDC extends HipoExtractor { * * @param pars CCDB row * @param id link to row in source bank + * @param timestamp ... + * @param time time (exprimed in bin) of the first channel of the AHDC pulse (after or not zero suppress; if ZS=0, time == 0) * @param samples ADC samples */ @Override - public List extract(NamedEntry pars, int id, long par1, long par2, short... samples){ + public List extract(NamedEntry pars, int id, long timestamp, long time, short... samples){ // Settings parameters (they can be initialised by a CCDB) float samplingTime = 44; - int sparseSample = 0; - short adcOffset = 0; - long timeStamp = 0; + short adcOffset = 0; ///< pedestal of the pulse float fineTimeStampResolution = 0; float amplitudeFractionCFA = 0.5f; @@ -42,11 +42,9 @@ public List extract(NamedEntry pars, int id, long par1, long par2, short. // Calculation intermediaries int binMax = 0; //Bin of the max ADC over the pulse - int binOffset = 0; //Offset due to sparse sample float adcMax = 0; //Max value of ADC over the pulse (fitted) float timeMax =0; //Time of the max ADC over the pulse (fitted) float integral = 0; //Sum of ADCs over the pulse (not fitted) - long timestamp = 0; short[] samplesCorr; //Waveform after offset (pedestal) correction int binNumber = 0; //Number of bins in one waveform @@ -58,7 +56,7 @@ public List extract(NamedEntry pars, int id, long par1, long par2, short. /// ///////////////////////// // Begin waveform correction /// //////////////////////// - //waveformCorrection(samples,adcOffset,samplingTime,sparseSample, binMax, adcMax, integral, samplesCorr[], binOffset, timeMax); + //waveformCorrection(samples,adcOffset,samplingTime, binMax, adcMax, integral, samplesCorr[], time, timeMax); /** * This method subtracts the pedestal (noise) from samples and stores it in : samplesCorr * It also computes a first value for : adcMax, binMax, timeMax and integral @@ -66,9 +64,8 @@ public List extract(NamedEntry pars, int id, long par1, long par2, short. * @param samples ADC samples * @param adcOffset pedestal or noise level * @param samplingTime time between two adc bins - * @param sparseSample used to define binOffset */ - //private void waveformCorrection(short[] samples, short adcOffset, float samplingTime, int sparseSample, int binMax, int adcMax, int integral, short samplesCorr[], int binOffset, int timeMax){ + //private void waveformCorrection(short[] samples, short adcOffset, float samplingTime, int binMax, int adcMax, int integral, short samplesCorr[], int time, int timeMax){ binNumber = samples.length; binMax = 0; if (binNumber >= 5) { @@ -102,8 +99,7 @@ public List extract(NamedEntry pars, int id, long par1, long par2, short. } binMax = (binMax + binMax2)/2; } - binOffset = sparseSample*binMax; - timeMax = (binMax + binOffset)*samplingTime; + timeMax = (binMax + time)*samplingTime; //} /// ///////////////////////// @@ -151,7 +147,7 @@ public List extract(NamedEntry pars, int id, long par1, long par2, short. if (binRise + 1 <= binNumber-1) slopeRise = samplesCorr[binRise+1] - samplesCorr[binRise]; float fittedBinRise = (slopeRise == 0) ? binRise : binRise + (threshold - samplesCorr[binRise])/slopeRise; - leadingEdgeTime = (fittedBinRise + binOffset)*samplingTime; // binOffset is determined in wavefromCorrection() // must be the same for all time ? // or must be defined using fittedBinRise*sparseSample + leadingEdgeTime = (fittedBinRise + time)*samplingTime; // trailingEdgeTime int binFall = binMax; @@ -168,7 +164,7 @@ public List extract(NamedEntry pars, int id, long par1, long par2, short. if (binFall - 1 >= 0) slopeFall = samplesCorr[binFall] - samplesCorr[binFall-1]; float fittedBinFall = (slopeFall == 0) ? binFall : binFall-1 + (threshold - samplesCorr[binFall-1])/slopeFall; - trailingEdgeTime = (fittedBinFall + binOffset)*samplingTime; + trailingEdgeTime = (fittedBinFall + time)*samplingTime; // timeOverThreshold timeOverThreshold = trailingEdgeTime - leadingEdgeTime; @@ -213,29 +209,10 @@ public List extract(NamedEntry pars, int id, long par1, long par2, short. if (binZero + 1 <= binNumber) slopeCFD = signal[binZero+1] - signal[binZero]; float fittedBinZero = (slopeCFD == 0) ? binZero : binZero + (0 - signal[binZero])/slopeCFD; - constantFractionTime = (fittedBinZero + binOffset)*samplingTime; + constantFractionTime = (fittedBinZero + time)*samplingTime; //} - /// ///////////////////////// - // Begin fineTimeStampCorrection - /// //////////////////////// - //fineTimeStampCorrection(timeStamp,fineTimeStampResolution); - /** - * From MVTFitter.java - * Make fine timestamp correction (using dream (=electronic chip) clock) - * @param timeStamp timing informations (used to make fine corrections) - * @param fineTimeStampResolution precision of dream clock (usually 8) - */ - //private void fineTimeStampCorrection (long timeStamp, float fineTimeStampResolution) { - //this.timestamp = timeStamp; - String binaryTimeStamp = Long.toBinaryString(timeStamp); //get 64 bit timestamp in binary format - if (binaryTimeStamp.length()>=3){ - byte fineTimeStamp = Byte.parseByte(binaryTimeStamp.substring(binaryTimeStamp.length()-3,binaryTimeStamp.length()),2); //fineTimeStamp : keep and convert last 3 bits of binary timestamp - timeMax += (float) ((fineTimeStamp+0.5) * fineTimeStampResolution); //fineTimeStampCorrection - // Question : I wonder if I have to do the same thing of all time quantities that the extract() methods compute. - } - //} // output Pulse pulse = new Pulse(); pulse.id = id; @@ -248,19 +225,11 @@ public List extract(NamedEntry pars, int id, long par1, long par2, short. pulse.timeOverThreshold = timeOverThreshold; pulse.constantFractionTime = constantFractionTime; //pulse.binMax = binMax; - //pulse.binOffset = binOffset; pulse.pedestal = adcOffset; List output = new ArrayList<>(); output.add(pulse); return output; } - /** - * Fit the max of the pulse using parabolic fit, this method updates the timeMax and adcMax values - * @param samplingTime time between 2 ADC bins - */ - private void fitParabolic(float samplingTime) { - - } @Override public void update(int n, IndexedTable it, DataEvent event, String wfBankName, String adcBankName) { From 4e9b81764da8718f1d11744e12cb3d749ed0d36d Mon Sep 17 00:00:00 2001 From: Felix Touchte Codjo Date: Sun, 30 Mar 2025 08:47:36 -0400 Subject: [PATCH 2/3] Change samplingTime --- .../src/main/java/org/jlab/detector/pulse/ModeAHDC.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java index f628908ab7..bd6ba45fde 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java @@ -32,7 +32,7 @@ public class ModeAHDC extends HipoExtractor { @Override public List extract(NamedEntry pars, int id, long timestamp, long time, short... samples){ // Settings parameters (they can be initialised by a CCDB) - float samplingTime = 44; + float samplingTime = 50.0; short adcOffset = 0; ///< pedestal of the pulse float fineTimeStampResolution = 0; From b1c6ffdb11fbde35598b5f96eafe4af2cf23cb8b Mon Sep 17 00:00:00 2001 From: Felix Touchte Codjo Date: Sun, 30 Mar 2025 12:24:41 -0400 Subject: [PATCH 3/3] Fix issue --- .../src/main/java/org/jlab/detector/pulse/ModeAHDC.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java index bd6ba45fde..80395d2b58 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java @@ -32,7 +32,7 @@ public class ModeAHDC extends HipoExtractor { @Override public List extract(NamedEntry pars, int id, long timestamp, long time, short... samples){ // Settings parameters (they can be initialised by a CCDB) - float samplingTime = 50.0; + float samplingTime = 50.0f; short adcOffset = 0; ///< pedestal of the pulse float fineTimeStampResolution = 0;