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

Synching ALERT fork with main branch #378

Open
wants to merge 90 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
87011e4
Changed the data bank to process the hits in AHDCEngine:
efuchey Feb 16, 2024
3863e74
Merge branch 'JeffersonLab:development' into development
efuchey Feb 22, 2024
10559cd
reversed the change in AHDCEngine.
efuchey Feb 29, 2024
8ac4238
Merge branch 'development' of github.com:efuchey/coatjava into develo…
efuchey Mar 1, 2024
e9377c4
Merge branch 'development' of github.com:efuchey/coatjava into develo…
efuchey Mar 18, 2024
81b637e
Merge branch 'JeffersonLab:development' into development
efuchey Apr 12, 2024
4046143
Merge branch 'JeffersonLab:development' into development
efuchey Apr 22, 2024
08cd675
Reverted (again???) the hit type to be read in AHDC reconstruction fr…
efuchey Apr 22, 2024
10f0972
changed AHDC bank back to ADC only
mpaolone Apr 23, 2024
acde32e
Merge branch 'JeffersonLab:development' into development
efuchey May 14, 2024
9440e21
remove redundant checks
baltzell May 22, 2024
c95e068
remove unused objects
baltzell May 22, 2024
11d6954
cleanup
baltzell May 22, 2024
3420bb9
leave internal indexing at zero, output at 1
baltzell May 22, 2024
d6fd779
cleanup
baltzell May 22, 2024
46e33d0
remove redundant checks
baltzell May 22, 2024
268c239
leave internal indexing from zero, output from 1
baltzell May 22, 2024
4a9647f
simplicy logic
baltzell May 22, 2024
481795d
use s/l/c/o indexing starting from 1
baltzell May 23, 2024
04571a1
Merge pull request #1 from JeffersonLab/iss272-alert-indexing
mpaolone Jun 3, 2024
082ae77
merge post Nathan's indexing update
mpaolone Jun 4, 2024
f137c4f
Merge branch 'JeffersonLab:development' into development
efuchey Jun 14, 2024
7c6593a
Merge branch 'JeffersonLab:development' into development
efuchey Jun 17, 2024
f10c09e
Merge pull request #1 from mpaolone/development
efuchey Jun 18, 2024
2e86a66
fixed a merge error that slipped through the cracks.
efuchey Jun 18, 2024
7514d48
Merge branch 'JeffersonLab:development' into development
efuchey Jul 1, 2024
5ae48d4
Merge pull request #2 from efuchey/development
mpaolone Jul 2, 2024
85dbe45
Modified the reference layer index for the "OtherCluster" in the
efuchey Jul 9, 2024
e14c464
Modified the hardcoded lookup superlayer/layer indices to fill the pe…
efuchey Jul 9, 2024
4b3603b
Merge pull request #4 from efuchey/development
mpaolone Jul 9, 2024
06b8f90
Declared upfront the hardcoded variables for cluster z calculation in…
efuchey Jul 17, 2024
dad3cdd
Merge branch 'JeffersonLab:development' into development
efuchey Aug 19, 2024
230b1b1
Added printouts to debug kalman filter.
efuchey Sep 16, 2024
c8eeecf
Merge branch 'JeffersonLab:development' into development
efuchey Sep 16, 2024
5e4020e
Merge branch 'development' of github.com:efuchey/coatjava into develo…
efuchey Sep 16, 2024
66afda9
Merge pull request #2 from mpaolone/development
efuchey Sep 17, 2024
62544e7
Merge branch 'development' of github.com:efuchey/coatjava into develo…
efuchey Sep 17, 2024
abbb742
Revert "Merge branch 'development' of github.com:efuchey/coatjava int…
efuchey Sep 17, 2024
c9f73b0
Reapply "Merge branch 'development' of github.com:efuchey/coatjava in…
efuchey Sep 17, 2024
8a5ba10
Adjusted the AHDC gas parameters in alert KalmanFilter.java
efuchey Sep 17, 2024
e0559c1
Merge branch 'JeffersonLab:development' into development
efuchey Sep 18, 2024
fa4bd27
Merge branch 'JeffersonLab:development' into development
efuchey Oct 7, 2024
09cad74
Completed commit 3420bb9 by modifying output index of atof paddle sta…
efuchey Oct 7, 2024
fa23226
Merge branch 'development' of github.com:efuchey/coatjava into develo…
efuchey Oct 7, 2024
906f0b4
Merge pull request #5 from efuchey/development
mpaolone Oct 8, 2024
a8e69c4
Added comments about units quantities.
efuchey Oct 8, 2024
3c1234c
Merge branch 'JeffersonLab:development' into development
efuchey Oct 8, 2024
e3486e4
Merge pull request #3 from mpaolone/development
efuchey Oct 8, 2024
130ad45
Merge branch 'development' of github.com:efuchey/coatjava into develo…
efuchey Oct 8, 2024
d32a3b7
Merge branch 'JeffersonLab:development' into development
efuchey Oct 10, 2024
2b39ea9
export BMT waveform
baltzell Oct 21, 2024
fb5a235
cleanup
baltzell Oct 21, 2024
f8226e5
Fixed the calculation of the hit wire position in Hit/Hit.java and Ka…
efuchey Oct 21, 2024
ebea531
add NamedEntry
baltzell Oct 21, 2024
71d5584
Apparently, changing the wire indexing was not desirable, at least fo…
efuchey Oct 21, 2024
b2eff24
refactor
baltzell Oct 21, 2024
c4359cb
add bank link
baltzell Oct 21, 2024
27a4c21
refactor
baltzell Oct 21, 2024
d1e0e95
preserve index
baltzell Oct 24, 2024
89d0175
tested, cleaned up
baltzell Oct 24, 2024
05b2108
cleanup, add a mode-7
baltzell Oct 24, 2024
39a126e
docs, examples
baltzell Oct 24, 2024
4687e8c
Verified and updated the calculations of the wire ends positions.
efuchey Oct 28, 2024
be8c645
Merge branch 'JeffersonLab:development' into development
mpaolone Oct 28, 2024
bcb34f1
Merge pull request #6 from JeffersonLab/baltzell-wf
mpaolone Oct 28, 2024
2b4f081
Fixed B field direction in Kalman filter (anywhere else that it's wro…
efuchey Oct 28, 2024
2d513b9
Implementation of a new mode of extraction
Nov 6, 2024
65395cb
Update time calculations in ModeAHDC.java
Nov 8, 2024
544216d
Merge pull request #1 from ftouchte/test/extractor
ftouchte Nov 8, 2024
5f6d07c
Reduce indentation
Nov 18, 2024
cd0ba16
Merge pull request #21 from ftouchte/development
mpaolone Nov 25, 2024
4dd148f
* Fixed the magnetic field direction and the calculation of the wire …
efuchey Dec 2, 2024
9c7d06d
Merge branch 'development' of github.com:efuchey/coatjava into develo…
efuchey Dec 2, 2024
4143a25
Added additional functions called "getMeasurementNoise_simple", "getV…
efuchey Dec 3, 2024
7fe0c41
Merge pull request #4 from mpaolone/development
efuchey Dec 3, 2024
f379279
Merge branch 'development' of github.com:efuchey/coatjava into develo…
efuchey Dec 3, 2024
5dd9fe4
Duplicated the measurement matrices functions: one in cylindrical sys…
efuchey Dec 9, 2024
0723c15
For pull request only: commented out the line in AHDCEngine that gath…
efuchey Dec 9, 2024
506e888
Merge pull request #22 from efuchey/development
mpaolone Dec 9, 2024
9abc31a
Merge branch 'development' into development
baltzell Dec 10, 2024
3867efe
fix bad merge conflict
baltzell Dec 10, 2024
a25a4d1
Merge pull request #23 from baltzell/development
mpaolone Dec 12, 2024
5636a1a
changed ModeAHDC to be dumber and threadsafe, changed PreClusterFinde…
mpaolone Dec 12, 2024
d6adcd8
AHDC::wf must be defined
baltzell Dec 13, 2024
0bd4108
actually use the new ahdc pulse extractor
baltzell Dec 13, 2024
48eaa66
Merge pull request #24 from baltzell/development
mpaolone Dec 16, 2024
3521313
Add AI for ALERT trackfinding
Dec 16, 2024
bd001db
Revert "leave internal indexing at zero, output at 1"
baltzell Dec 16, 2024
e2acd07
Merge pull request #26 from baltzell/development
mpaolone Dec 18, 2024
88b1dd8
Merge pull request #25 from mathieuouillon/AI_for_ALERT
mpaolone Dec 18, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ public void setOrder(int order){
}
}

public int[] getCSC() {
baltzell marked this conversation as resolved.
Show resolved Hide resolved
return new int[]{hw_CRATE,hw_SLOT,hw_CHANNEL};
}

public int[] getSLCO() {
return new int[]{dt_SECTOR,dt_LAYER,dt_COMPONENT,dt_ORDER};
}

public DetectorType getType(){ return this.detectorType;}

public final void setType(DetectorType type){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +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.ModeAHDC;

import org.jlab.logging.DefaultLogger;

Expand Down Expand Up @@ -46,7 +47,8 @@ public class CLASDecoder4 {
private HipoDataEvent hipoEvent = null;
private boolean isRunNumberFixed = false;
private int decoderDebugMode = 0;
private SchemaFactory schemaFactory = new SchemaFactory();
private SchemaFactory schemaFactory = new SchemaFactory();
private ModeAHDC ahdcExtractor = new ModeAHDC();

public CLASDecoder4(boolean development){
codaDecoder = new CodaEventDecoder();
Expand Down Expand Up @@ -245,6 +247,26 @@ public List<DetectorDataDgtz> getEntriesSCALER(DetectorType type,
return scaler;
}

public void extractPulses(Event event) {
ahdcExtractor.update(6, null, event, schemaFactory, "AHDC::wf", "AHDC::adc");
}

public Bank getDataBankWF(String name, DetectorType type) {
List<DetectorDataDgtz> a = this.getEntriesADC(type);
Bank b = new Bank(schemaFactory.getSchema(name), a.size());
for (int i=0; i<a.size(); ++i) {
b.putByte("sector", i, (byte) a.get(i).getDescriptor().getSector());
b.putByte("layer", i, (byte) a.get(i).getDescriptor().getLayer());
b.putShort("component", i, (short) a.get(i).getDescriptor().getComponent());
b.putByte("order", i, (byte) a.get(i).getDescriptor().getOrder());
b.putLong("timestamp", i, a.get(i).getADCData(0).getTimeStamp());
DetectorDataDgtz.ADCData xxx = a.get(i).getADCData(0);
for (int j=0; j<xxx.getPulseSize(); ++j)
b.putShort(String.format("s%d",j+1), i, xxx.getPulseValue(j));
}
return b;
}

public Bank getDataBankADC(String name, DetectorType type){

List<DetectorDataDgtz> adcDGTZ = this.getEntriesADC(type);
Expand Down Expand Up @@ -420,20 +442,20 @@ public Event getDataEvent(){

Event event = new Event();

String[] wfBankNames = new String[]{"AHDC::wf"};
DetectorType[] wfBankTypes = new DetectorType[]{DetectorType.AHDC};
String[] adcBankNames = new String[]{"FTOF::adc","ECAL::adc","FTCAL::adc",
"FTHODO::adc", "FTTRK::adc",
"HTCC::adc","BST::adc","CTOF::adc",
"CND::adc","LTCC::adc","BMT::adc",
"FMT::adc","HEL::adc","RF::adc",
"BAND::adc","RASTER::adc",
"AHDC::adc"};
"BAND::adc","RASTER::adc"};
DetectorType[] adcBankTypes = new DetectorType[]{DetectorType.FTOF,DetectorType.ECAL,DetectorType.FTCAL,
DetectorType.FTHODO,DetectorType.FTTRK,
DetectorType.HTCC,DetectorType.BST,DetectorType.CTOF,
DetectorType.CND,DetectorType.LTCC,DetectorType.BMT,
DetectorType.FMT,DetectorType.HEL,DetectorType.RF,
DetectorType.BAND, DetectorType.RASTER,
DetectorType.AHDC};
DetectorType.BAND, DetectorType.RASTER};

String[] tdcBankNames = new String[]{"FTOF::tdc","ECAL::tdc","DC::tdc",
"HTCC::tdc","LTCC::tdc","CTOF::tdc",
Expand All @@ -453,6 +475,13 @@ public Event getDataEvent(){
}
}

for(int i = 0; i < wfBankTypes.length; i++){
Bank wfBank = getDataBankWF(wfBankNames[i],wfBankTypes[i]);
if(wfBank!=null && wfBank.getRows()>0){
event.write(wfBank);
}
}

for(int i = 0; i < tdcBankTypes.length; i++){
Bank tdcBank = getDataBankTDC(tdcBankNames[i],tdcBankTypes[i]);
if(tdcBank!=null){
Expand Down Expand Up @@ -825,7 +854,9 @@ public static void main(String[] args){
decodedEvent.read(rawScaler);
decodedEvent.read(rawRunConf);
decodedEvent.read(helicityAdc);


decoder.extractPulses(decodedEvent);

helicityReadings.add(HelicityState.createFromFadcBank(helicityAdc, rawRunConf,
decoder.detectorDecoder.scalerManager));

Expand Down Expand Up @@ -867,4 +898,5 @@ public static void main(String[] args){

writer.close();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@

package org.jlab.detector.pulse;

import java.util.ArrayList;
import java.util.List;
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;

/**
* For now, a place to store standard boilerplate for waveform/pulse HIPO
* manipulations. No bounds checking regarding number of samples.
*
* Here an IndexedTable object from CCDB is used to pass initialization parameters
* to the extractor. If that object is null, the @{link org.jlab.detector.pulse.IExtractor.extract}
* method should know what to do, e.g., hardcoded, channel-independent parameters.
*
* FIXME: Passing the #samples around is obviously bad, and there's probably a
* few non-horrible ways that can be addressed without changing bank format.
*
* @author baltzell
*/
public abstract class HipoExtractor implements IExtractor {

/**
* @param n number of samples in readout
* @param it CCDB table containing extraction initialization parameters
* @param event the event to modify
* @param schema bank schema factory
* @param wfBankName name of the input waveform bank
* @param adcBankName name of the output ADC bank
*/
public void update(int n, IndexedTable it, Event event, SchemaFactory schema, String wfBankName, String adcBankName) {
Bank wf = new Bank(schema.getSchema(wfBankName));
event.read(wf);
if (wf.getRows() > 0) {
Bank adc = new Bank(schema.getSchema(adcBankName));
update(n, it, wf, adc);
event.remove(schema.getSchema(adcBankName));
if (adc.getRows() > 0) event.write(adc);
}
}

/**
* This could be overriden, e.g., for non-standard ADC banks.
* @param n number of samples in readout
* @param it CCDB table containing extraction initialization parameters
* @param event the event to modify
* @param wfBankName name of the input waveform bank
* @param adcBankName name of the output ADC bank
*/
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).integral);
adc.setFloat("time", i, pulses.get(i).time);
}
event.appendBank(adc);
}
}
}

/**
* This could be overriden, e.g., for non-standard ADC banks.
* @param n number of samples in readout
* @param it CCDB table containing extraction initialization parameters
* @param wfBank input waveform bank
* @param adcBank output ADC bank
*/
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).integral);
adcBank.putFloat("time", i, pulses.get(i).time);
}
}
}
}

private 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("id", idest, (short)isrc);
}

private 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("id", idest, (short)isrc);
}

private 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) {
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) {
List<Pulse> pulses = null;
short[] samples = new short[n];
for (int i=0; i<wfBank.rows(); ++i) {
for (int j=0; j<n; ++j)
samples[j] = wfBank.getShort(String.format("s%d",j+1), i);
List<Pulse> p = it==null ? extract(null, i, samples) :
extract(it.getNamedEntry(getIndices(wfBank,i)), i, samples);
if (p!=null && !p.isEmpty()) {
if (pulses == null) pulses = new ArrayList<>();
pulses.addAll(p);
}
}
return pulses;
}

private 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) {
for (int j=0; j<n; ++j)
samples[j] = wfBank.getShort(String.format("s%d",j+1), i);
// FIXME: Can speed this up (but looks like not for DataBank?):
//samples[j] = wfBank.getShort(String.format(5+j,j+1), i);
List p = it==null ? extract(null, i, samples) :
extract(it.getNamedEntry(getIndices(wfBank,i)), i, samples);
if (p!=null && !p.isEmpty()) {
if (pulses == null) pulses = new ArrayList<>();
pulses.addAll(p);
}
}
return pulses;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.jlab.detector.pulse;

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

public interface IExtractor <T> {

public List<T> extract(NamedEntry pars, int id, short... samples);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.jlab.detector.pulse;

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

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

// Fixed extraction parameters:
final double ped = 2000;
final double tet = 2000;
final int nsa = 30;
final int nsb = 5;

/**
* @param pars CCDB row
* @param id link to row in source bank
* @param samples ADC samples
* @return extracted pulses
*/
@Override
public List<Pulse> extract(NamedEntry pars, int id, short... samples) {

List<Pulse> pulses = null;

/*
// Retrive extraction parameters from a CCDB table:
double ped = pars.getValue("ped").doubleValue();
double tet = pars.getValue("tet").doubleValue();
int nsa = pars.getValue("nsa").intValue();
int nsb = pars.getValue("nsb").intValue();
*/

// Perform the extraction:
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(p);
// Add a holdoff time before next possible pulse:
i += nsa;
}
}
return pulses;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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;
}

}
Loading