Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The waveform proposal #352

Closed
wants to merge 10 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup, add a mode-7
baltzell committed Oct 24, 2024

Verified

This commit was signed with the committer’s verified signature.
Keith-CY Chen Yu
commit 05b21086e169072676f58468e086c26e9ccc180c
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
import org.jlab.detector.helicity.HelicityBit;
import org.jlab.detector.helicity.HelicitySequence;
import org.jlab.detector.helicity.HelicityState;
import org.jlab.detector.pulse.ExampleExtractor;
import org.jlab.detector.pulse.Mode3;

import org.jlab.logging.DefaultLogger;

@@ -48,7 +48,7 @@ public class CLASDecoder4 {
private boolean isRunNumberFixed = false;
private int decoderDebugMode = 0;
private SchemaFactory schemaFactory = new SchemaFactory();
private ExampleExtractor mode3 = new ExampleExtractor();
private Mode3 mode3 = new Mode3();

public CLASDecoder4(boolean development){
codaDecoder = new CodaEventDecoder();
Original file line number Diff line number Diff line change
@@ -4,7 +4,12 @@
import java.util.List;
import org.jlab.utils.groups.NamedEntry;

public class ExampleExtractor extends HipoExtractor {
/**
* Similar to FADC250 Mode-3 pulse extraction.
*
* @author baltzell
*/
public class Mode3 extends HipoExtractor {

// Fixed extraction parameters:
final double ped = 2000;
@@ -32,19 +37,25 @@ public List<Pulse> extract(NamedEntry pars, int id, short... samples) {
*/

// Perform the extraction:
for (int i=0; i<samples.length; ++i) {
if (samples[i] > ped+tet) {
for (int i=0; i<samples.length-1; ++i) {
// Check for threshold crossing:
if (samples[i] > ped+tet && samples[i+1] > samples[i]) {
int n = 0;
float integral = 0;
// Integrate the pulse:
for (int j=i-nsb; j<=i+nsa; ++j) {
if (j<0) continue;
if (j>=samples.length) break;
integral += samples[j];
n++;
}
integral -= n * ped;
Pulse p = new Pulse(integral, i, 0x0, id);
p.pedestal = (float)(ped);
// Add the new pulse to the list:
if (pulses == null) pulses = new ArrayList<>();
pulses.add(new Pulse(integral, i, 0x0, id));
pulses.add(p);
// Add a holdoff time before next possible pulse:
i += nsa;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.jlab.detector.pulse;

import java.util.List;
import org.jlab.utils.groups.NamedEntry;

/**
* Similar to a Mode-7 FADC250 pulse extraction
* @author baltzell
*/
public class Mode7 extends Mode3 {

/**
* @param t0 threshold-crossing sample index
* @param ped pedestal (for calculating pulse half-height)
* @param samples
* @return pulse time
*/
private static float calculateTime(int t0, float ped, short... samples) {
for (int j=t0+1; j<samples.length; ++j) {
if (samples[j] < samples[j-1]) {
float slope = (samples[j-1]-ped) / (j-t0);
float offset = samples[j-1] - (j-1)*slope;
return (samples[j-1]/2 - offset) / slope;
}
}
// Fall back to Mode-3 time:
return t0;
}

@Override
public List<Pulse> extract(NamedEntry pars, int id, short... samples) {
List<Pulse> pulses = super.extract(pars, id, samples);
for (Pulse p : pulses)
p.time = calculateTime((int)p.time, p.pedestal, samples);
return pulses;
}

}
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ public class Pulse {
public long timestamp;
public float integral;
public float time;
public float pedestal;
public long flags;
public int id;

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.jlab.clas.service;

import org.jlab.clas.reco.ReconstructionEngine;
import org.jlab.detector.pulse.ExampleExtractor;
import org.jlab.detector.pulse.Mode3;
import org.jlab.io.base.DataEvent;

public class PulseExtractorEngine extends ReconstructionEngine {

ExampleExtractor basic = new ExampleExtractor();
Mode3 basic = new Mode3();

public PulseExtractorEngine() {
super("PULSE", "baltzell", "0.0");