Skip to content

Commit 87e7080

Browse files
ftouchteFelix Touchte Codjo
andauthored
Recover more data from AHDC pulse analysis (#446)
* 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]>
1 parent 271a38c commit 87e7080

File tree

3 files changed

+67
-12
lines changed

3 files changed

+67
-12
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,39 +91,39 @@ protected void update(int n, IndexedTable it, Bank wfBank, Bank adcBank) {
9191
}
9292
}
9393

94-
private static void copyIndices(Bank src, Bank dest, int isrc, int idest) {
94+
protected static void copyIndices(Bank src, Bank dest, int isrc, int idest) {
9595
dest.putByte("sector", idest, src.getByte("sector",isrc));
9696
dest.putByte("layer", idest, src.getByte("layer",isrc));
9797
dest.putShort("component", idest, src.getShort("component",isrc));
9898
dest.putByte("order", idest, src.getByte("order",isrc));
9999
dest.putShort("windex", idest, (short)isrc);
100100
}
101101

102-
private static void copyIndices(DataBank src, DataBank dest, int isrc, int idest) {
102+
protected static void copyIndices(DataBank src, DataBank dest, int isrc, int idest) {
103103
dest.setByte("sector", idest, src.getByte("sector",isrc));
104104
dest.setByte("layer", idest, src.getByte("layer",isrc));
105105
dest.setShort("component", idest, src.getShort("component",isrc));
106106
dest.setByte("order", idest, src.getByte("order",isrc));
107107
dest.setShort("windex", idest, (short)isrc);
108108
}
109109

110-
private static int[] getIndices(Bank bank, int row) {
110+
protected static int[] getIndices(Bank bank, int row) {
111111
return new int[] {
112112
bank.getShort("sector", row),
113113
bank.getShort("layer", row),
114114
bank.getShort("component", row),
115115
bank.getShort("order", row)};
116116
}
117117

118-
private static int[] getIndices(DataBank bank, int row) {
118+
protected static int[] getIndices(DataBank bank, int row) {
119119
return new int[] {
120120
bank.getShort("sector", row),
121121
bank.getShort("layer", row),
122122
bank.getShort("component", row),
123123
bank.getShort("order", row)};
124124
}
125125

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

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

160-
}
160+
}

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

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
import java.util.List;
44
import java.util.ArrayList;
5+
import org.jlab.io.base.DataBank;
6+
import org.jlab.io.base.DataEvent;
7+
import org.jlab.jnp.hipo4.data.Bank;
8+
import org.jlab.jnp.hipo4.data.Event;
9+
import org.jlab.jnp.hipo4.data.SchemaFactory;
10+
import org.jlab.utils.groups.IndexedTable;
511

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

37-
float amplitudeFractionCFA = 0;
38-
int binDelayCFD = 0;
39-
float fractionCFD = 0;
43+
float amplitudeFractionCFA = 0.5f;
44+
int binDelayCFD = 5;
45+
float fractionCFD = 0.3f;
4046

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

257263
}
264+
265+
@Override
266+
public void update(int n, IndexedTable it, DataEvent event, String wfBankName, String adcBankName) {
267+
DataBank wf = event.getBank(wfBankName);
268+
if (wf.rows() > 0) {
269+
event.removeBank(adcBankName);
270+
List<Pulse> pulses = getPulses(n, it, wf);
271+
if (pulses != null && !pulses.isEmpty()) {
272+
DataBank adc = event.createBank(adcBankName, pulses.size());
273+
for (int i=0; i<pulses.size(); ++i) {
274+
copyIndices(wf, adc, i, i);
275+
adc.setInt("ADC", i, (int)pulses.get(i).adcMax);
276+
adc.setFloat("time", i, pulses.get(i).time);
277+
adc.setFloat("leadingEdgeTime", i, pulses.get(i).leadingEdgeTime);
278+
adc.setFloat("timeOverThreshold", i, pulses.get(i).timeOverThreshold);
279+
adc.setFloat("constantFractionTime", i, pulses.get(i).constantFractionTime);
280+
adc.setInt("integral", i, (int)pulses.get(i).integral);
281+
adc.setShort("ped", i, (short)pulses.get(i).pedestal);
282+
}
283+
event.appendBank(adc);
284+
}
285+
}
286+
}
287+
288+
@Override
289+
protected void update(int n, IndexedTable it, Bank wfBank, Bank adcBank) {
290+
if (wfBank.getRows() > 0) {
291+
List<Pulse> pulses = getPulses(n, it, wfBank);
292+
adcBank.reset();
293+
adcBank.setRows(pulses!=null ? pulses.size() : 0);
294+
if (pulses!=null && !pulses.isEmpty()) {
295+
for (int i=0; i<pulses.size(); ++i) {
296+
copyIndices(wfBank, adcBank, pulses.get(i).id, i);
297+
adcBank.putInt("ADC", i, (int)pulses.get(i).adcMax);
298+
adcBank.putFloat("time", i, pulses.get(i).time);
299+
adcBank.putFloat("leadingEdgeTime", i, pulses.get(i).leadingEdgeTime);
300+
adcBank.putFloat("timeOverThreshold", i, pulses.get(i).timeOverThreshold);
301+
adcBank.putFloat("constantFractionTime", i, pulses.get(i).constantFractionTime);
302+
adcBank.putInt("integral", i, (int)pulses.get(i).integral);
303+
adcBank.putShort("ped", i, (short)pulses.get(i).pedestal);
304+
}
305+
}
306+
}
307+
}
308+
258309
}

etc/bankdefs/hipo4/data.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@
153153
{ "name":"ADC" , "type":"I", "info":"ADC maximum"},
154154
{ "name":"time" , "type":"F", "info":"time from pulse fit"},
155155
{ "name":"ped" , "type":"S", "info":"pedestal from pulse analysis"},
156-
{ "name":"windex" , "type":"S", "info":"row index in waveform bank"}
156+
{ "name":"windex" , "type":"S", "info":"row index in waveform bank"},
157+
{ "name":"integral" , "type":"I", "info":"sum of ADC"},
158+
{ "name":"leadingEdgeTime" , "type":"F", "info":"time at constant fraction amplitude"},
159+
{ "name":"timeOverThreshold" , "type":"F", "info":"time over threshold at constant fraction amplitude"},
160+
{ "name":"constantFractionTime" , "type":"F", "info":"time from constant fraction discriminator"}
157161
]
158162
},
159163
{

0 commit comments

Comments
 (0)