Skip to content

Commit

Permalink
Recover more data from AHDC pulse analysis (#446)
Browse files Browse the repository at this point in the history
* 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

---------

Co-authored-by: Felix Touchte Codjo <[email protected]>
  • Loading branch information
ftouchte and Felix Touchte Codjo authored Feb 13, 2025
1 parent 271a38c commit 87e7080
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,39 +91,39 @@ protected void update(int n, IndexedTable it, Bank wfBank, Bank adcBank) {
}
}

private static void copyIndices(Bank src, Bank dest, int isrc, int idest) {
protected static void copyIndices(Bank src, Bank dest, int isrc, int idest) {
dest.putByte("sector", idest, src.getByte("sector",isrc));
dest.putByte("layer", idest, src.getByte("layer",isrc));
dest.putShort("component", idest, src.getShort("component",isrc));
dest.putByte("order", idest, src.getByte("order",isrc));
dest.putShort("windex", idest, (short)isrc);
}

private static void copyIndices(DataBank src, DataBank dest, int isrc, int idest) {
protected static void copyIndices(DataBank src, DataBank dest, int isrc, int idest) {
dest.setByte("sector", idest, src.getByte("sector",isrc));
dest.setByte("layer", idest, src.getByte("layer",isrc));
dest.setShort("component", idest, src.getShort("component",isrc));
dest.setByte("order", idest, src.getByte("order",isrc));
dest.setShort("windex", idest, (short)isrc);
}

private static int[] getIndices(Bank bank, int row) {
protected static int[] getIndices(Bank bank, int row) {
return new int[] {
bank.getShort("sector", row),
bank.getShort("layer", row),
bank.getShort("component", row),
bank.getShort("order", row)};
}

private static int[] getIndices(DataBank bank, int row) {
protected static int[] getIndices(DataBank bank, int row) {
return new int[] {
bank.getShort("sector", row),
bank.getShort("layer", row),
bank.getShort("component", row),
bank.getShort("order", row)};
}

private List<Pulse> getPulses(int n, IndexedTable it, DataBank wfBank) {
protected List<Pulse> getPulses(int n, IndexedTable it, DataBank wfBank) {
List<Pulse> pulses = null;
short[] samples = new short[n];
for (int i=0; i<wfBank.rows(); ++i) {
Expand All @@ -139,7 +139,7 @@ private List<Pulse> getPulses(int n, IndexedTable it, DataBank wfBank) {
return pulses;
}

private List<Pulse> getPulses(int n, IndexedTable it, Bank wfBank) {
protected List<Pulse> getPulses(int n, IndexedTable it, Bank wfBank) {
List<Pulse> pulses = null;
short[] samples = new short[n];
for (int i=0; i<wfBank.getRows(); ++i) {
Expand All @@ -157,4 +157,4 @@ private List<Pulse> getPulses(int n, IndexedTable it, Bank wfBank) {
return pulses;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

import java.util.List;
import java.util.ArrayList;
import org.jlab.io.base.DataBank;
import org.jlab.io.base.DataEvent;
import org.jlab.jnp.hipo4.data.Bank;
import org.jlab.jnp.hipo4.data.Event;
import org.jlab.jnp.hipo4.data.SchemaFactory;
import org.jlab.utils.groups.IndexedTable;

import net.jcip.annotations.GuardedBy;
import org.jlab.utils.groups.NamedEntry;
Expand All @@ -28,15 +34,15 @@ public class ModeAHDC extends HipoExtractor {
@Override
public List<Pulse> extract(NamedEntry pars, int id, short... samples){
// Settings parameters (they can be initialised by a CCDB)
float samplingTime = 0;
float samplingTime = 44;
int sparseSample = 0;
short adcOffset = 0;
long timeStamp = 0;
float fineTimeStampResolution = 0;

float amplitudeFractionCFA = 0;
int binDelayCFD = 0;
float fractionCFD = 0;
float amplitudeFractionCFA = 0.5f;
int binDelayCFD = 5;
float fractionCFD = 0.3f;

// Calculation intermediaries
int binMax = 0; //Bin of the max ADC over the pulse
Expand Down Expand Up @@ -255,4 +261,49 @@ public List<Pulse> extract(NamedEntry pars, int id, short... samples){
private void fitParabolic(float samplingTime) {

}

@Override
public void update(int n, IndexedTable it, DataEvent event, String wfBankName, String adcBankName) {
DataBank wf = event.getBank(wfBankName);
if (wf.rows() > 0) {
event.removeBank(adcBankName);
List<Pulse> pulses = getPulses(n, it, wf);
if (pulses != null && !pulses.isEmpty()) {
DataBank adc = event.createBank(adcBankName, pulses.size());
for (int i=0; i<pulses.size(); ++i) {
copyIndices(wf, adc, i, i);
adc.setInt("ADC", i, (int)pulses.get(i).adcMax);
adc.setFloat("time", i, pulses.get(i).time);
adc.setFloat("leadingEdgeTime", i, pulses.get(i).leadingEdgeTime);
adc.setFloat("timeOverThreshold", i, pulses.get(i).timeOverThreshold);
adc.setFloat("constantFractionTime", i, pulses.get(i).constantFractionTime);
adc.setInt("integral", i, (int)pulses.get(i).integral);
adc.setShort("ped", i, (short)pulses.get(i).pedestal);
}
event.appendBank(adc);
}
}
}

@Override
protected void update(int n, IndexedTable it, Bank wfBank, Bank adcBank) {
if (wfBank.getRows() > 0) {
List<Pulse> pulses = getPulses(n, it, wfBank);
adcBank.reset();
adcBank.setRows(pulses!=null ? pulses.size() : 0);
if (pulses!=null && !pulses.isEmpty()) {
for (int i=0; i<pulses.size(); ++i) {
copyIndices(wfBank, adcBank, pulses.get(i).id, i);
adcBank.putInt("ADC", i, (int)pulses.get(i).adcMax);
adcBank.putFloat("time", i, pulses.get(i).time);
adcBank.putFloat("leadingEdgeTime", i, pulses.get(i).leadingEdgeTime);
adcBank.putFloat("timeOverThreshold", i, pulses.get(i).timeOverThreshold);
adcBank.putFloat("constantFractionTime", i, pulses.get(i).constantFractionTime);
adcBank.putInt("integral", i, (int)pulses.get(i).integral);
adcBank.putShort("ped", i, (short)pulses.get(i).pedestal);
}
}
}
}

}
6 changes: 5 additions & 1 deletion etc/bankdefs/hipo4/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@
{ "name":"ADC" , "type":"I", "info":"ADC maximum"},
{ "name":"time" , "type":"F", "info":"time from pulse fit"},
{ "name":"ped" , "type":"S", "info":"pedestal from pulse analysis"},
{ "name":"windex" , "type":"S", "info":"row index in waveform bank"}
{ "name":"windex" , "type":"S", "info":"row index in waveform bank"},
{ "name":"integral" , "type":"I", "info":"sum of ADC"},
{ "name":"leadingEdgeTime" , "type":"F", "info":"time at constant fraction amplitude"},
{ "name":"timeOverThreshold" , "type":"F", "info":"time over threshold at constant fraction amplitude"},
{ "name":"constantFractionTime" , "type":"F", "info":"time from constant fraction discriminator"}
]
},
{
Expand Down

0 comments on commit 87e7080

Please sign in to comment.