Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c2007e3
separate functionality
baltzell Sep 4, 2026
2c569d3
fix method name
baltzell Sep 4, 2026
e2ff578
add accessor
baltzell Sep 4, 2026
e566858
add serial class
baltzell Sep 4, 2026
2988f8a
separate "serial" functionality for reusability
baltzell Sep 4, 2026
d8b8802
relocate serial/postprocessing utilities to clas-detector
baltzell Sep 4, 2026
6522196
default to zero for easier event counting
baltzell Sep 4, 2026
b1f3a22
add support for io-services
baltzell Sep 4, 2026
c21f1f6
add ReconMutil
baltzell Sep 4, 2026
ea4cc85
add recon-mutil
baltzell Sep 4, 2026
152295a
fix
baltzell Sep 4, 2026
dad364d
only printout if interval is positive
baltzell Sep 4, 2026
60ce0df
update ci for recon-mutil
baltzell Sep 4, 2026
919f999
bugfix
baltzell Sep 4, 2026
d8eb345
quiet tarball extraction
baltzell Sep 4, 2026
12472a2
prep pp
baltzell Sep 5, 2026
1a852a7
add another queue, to prime for postprocessing
baltzell Sep 5, 2026
b6b715d
cleanup
baltzell Sep 5, 2026
2afd58d
cleanup
baltzell Sep 5, 2026
0fe93f8
Merge branch 'development' into recon-mutil
baltzell Sep 8, 2026
67cce53
null yaml bugfix
baltzell Sep 9, 2026
870d275
remove throwers and catchers
baltzell Sep 10, 2026
6574f29
add postproc to serial
baltzell Sep 10, 2026
252abb0
replace duplicate serial.read w/ read+process
baltzell Sep 10, 2026
d0c451f
remove post-processing from Clas12Writer
baltzell Sep 10, 2026
e17fcd6
convert to HelicitySequence, oopts
baltzell Sep 10, 2026
7d62e4d
prime the serial buffer
baltzell Sep 10, 2026
a9e1a2a
set read queue limit at 100k events, 2 GB
baltzell Sep 10, 2026
5d4b587
cleanup
baltzell Sep 11, 2026
e7100b4
add pausing
baltzell Sep 11, 2026
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
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,12 @@ jobs:
tar xzf clara.tar.gz
tar xzf coatjava.tar.gz
- run: ls
- name: run test
run: ./bin/run-clara -y ./etc/services/rgd-clarode.yml -t 4 -n 500 -c ./clara -o ./tmp ./clas_018779.evio.00001
- name: run clara
run: ./coatjava/bin/run-clara -y ./etc/services/rgd-clarode.yml -t 4 -n 100 -c ./clara -o ./tmp ./clas_018779.evio.00001
- name: run mutil
run: ./coatjava/bin/recon-mutil -y ./etc/services/rgd-clarode.yml -t 4 -n 30 -o rec.hipo ./clas_018779.evio.00001
- name: ls tmp
run: ls -lhtr tmp
- name: rename
run: mv -v tmp/rec_clas_018779.evio.00001.hipo rec.hipo
run: ls -lhtr . tmp
- uses: actions/upload-artifact@v7
with:
name: test_clara_result
Expand Down
8 changes: 8 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ clara:
- run-clara -v -c $CLARA_HOME -t 4 -y ./etc/services/rgd-clarode.yml -n 30 -o out $EVIOFILE
- mv out/rec_$EVIOFILE.hipo claroded.hipo

recon-mutil:
stage: test
needs: [build,download]
dependencies: [build,download]
script:
- tar -xzf coatjava.tar.gz
- recon-mutil -t 4 -y ./etc/services/rgd-clarode.yml -n 30 -o rec_$EVIOFILE.hipo $EVIOFILE

profile:
extends: .clon
allow_failure: true
Expand Down
12 changes: 12 additions & 0 deletions bin/recon-mutil
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

. `dirname $0`/../libexec/env.sh

split_cli $@

export MALLOC_ARENA_MAX=1

java ${JAVA_OPTS-} -Xms10240m -XX:+UseParallelGC ${jvm_options[@]} \
-cp ${COATJAVA_CLASSPATH:-''} \
org.jlab.clas.reco.ReconMutil \
${class_options[@]}
8 changes: 1 addition & 7 deletions common-tools/clara-io/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@
<artifactId>jnp-hipo4</artifactId>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-io</artifactId>
<version>14.2.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-detector</artifactId>
Expand All @@ -50,7 +44,7 @@

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-utils</artifactId>
<artifactId>clas-io</artifactId>
<version>14.2.0-SNAPSHOT</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
package org.jlab.io.clara;

import java.io.File;
import java.nio.file.Path;
import java.util.List;
import java.util.TreeMap;
import java.util.TreeSet;
import org.jlab.clara.std.services.EventWriterException;
import org.jlab.detector.calib.utils.ConstantsManager;
import org.jlab.detector.decode.CLASDecoder4;
import org.jlab.detector.helicity.HelicitySequence;
import org.jlab.detector.helicity.HelicitySequenceDelayed;
import org.jlab.detector.helicity.HelicityState;
import org.jlab.detector.scalers.DaqScalersSequence;
import org.jlab.detector.serial.PostProcessor;
import org.jlab.jnp.hipo4.data.Bank;
import org.jlab.detector.serial.SerialHoncho;
import org.jlab.jnp.hipo4.data.Event;
import org.jlab.jnp.hipo4.data.SchemaFactory;
import org.jlab.jnp.hipo4.io.HipoReader;
import org.jlab.jnp.hipo4.io.HipoWriterSorted;
import org.jlab.jnp.utils.file.FileUtils;
import org.json.JSONObject;
Expand All @@ -26,41 +15,24 @@
* 1. Copies certain banks on-the-fly to new tag-1 events
* 2. Caches helicity states, scaler readouts, and unix time
* 3. Writes HEL::flip, RUN/HEL::scaler, and RUN::unix to new tag-1 events
* 4. Runs post-processing, writing tag-1 information to all events
* 5. Adds .hipo to the output filename, if necessary
*
* @author baltzell
*/
public class Clas12Writer extends HipoToHipoWriter {

static final String[] TAG1BANKS = {"RUN::scaler","HEL::scaler","RAW::scaler","RAW::epics","HEL::flip","COAT::config"};

Bank[] tag1banks;
Bank runConfig;
Bank helicityAdc;
SerialHoncho serial;
ConstantsManager conman;
TreeMap<Integer,Integer> eventUnix;
TreeSet<HelicityState> helicities;
DaqScalersSequence scalers;
SchemaFactory fullSchema;
boolean postprocess;

private void init(JSONObject opts) {
fullSchema = new SchemaFactory();
fullSchema.initFromDirectory(FileUtils.getEnvironmentPath("CLAS12DIR","etc/bankdefs/hipo4"));
runConfig = new Bank(fullSchema.getSchema("RUN::config"));
helicityAdc = new Bank(fullSchema.getSchema("HEL::adc"));
helicities = new TreeSet<>();
scalers = new DaqScalersSequence(fullSchema);
serial = new SerialHoncho(fullSchema);
conman = new ConstantsManager();
eventUnix = new TreeMap<>();
conman.init("/runcontrol/hwp","/runcontrol/helicity");
postprocess = opts.optBoolean("postprocess", false);
if (opts.has("variation")) conman.setVariation(opts.getString("variation"));
if (opts.has("timestamp")) conman.setTimeStamp(opts.getString("timestamp"));
tag1banks = new Bank[TAG1BANKS.length];
for (int i=0; i<tag1banks.length; ++i)
tag1banks[i] = new Bank(fullSchema.getSchema(TAG1BANKS[i]));
}

@Override
Expand All @@ -78,89 +50,15 @@ protected HipoWriterSorted createWriter(Path file, JSONObject opts) throws Event

@Override
protected void writeEvent(Object event) throws EventWriterException {
scalers.add((Event)event);
((Event)event).read(runConfig);
((Event)event).read(helicityAdc);
if (runConfig.getRows() > 0) {
int unix = runConfig.getInt("unixtime",0);
int evno = runConfig.getInt("event",0);
if (unix > 0 && evno > 0) eventUnix.put(evno, unix);
}
helicities.add(HelicityState.createFromFadcBank(helicityAdc, runConfig, conman));
Event t = CLASDecoder4.createTaggedEvent((Event)event, runConfig, tag1banks);
Event t = serial.read((Event)event);
if (!t.isEmpty()) writer.addEvent(t, 1);
super.writeEvent(event);
}

@Override
protected void closeWriter() {
HelicitySequence.writeFlips(fullSchema, writer, helicities);
writer.addEvent(getUnixEvent(runConfig),1);
serial.finish(writer);
super.closeWriter();
if (postprocess) postprocess();
// keep the latest helicity/scaler reading for the next file:
while (helicities.size() > 60) helicities.pollFirst();
scalers.clear(10);
}

/**
* Get the first valid run number from a RUN::config bank.
* @return run
*/
private int getRunNumber() {
Event e = new Event();
HipoReader r = new HipoReader();
r.open(filename);
while (r.hasNext()) {
r.nextEvent(e);
e.read(runConfig);
if (runConfig.getRows()>0 && runConfig.getInt("run",0)>0)
return runConfig.getInt("run",0);
}
return 0;
serial.clear();
}

/**
* Get a new event with a RUN::unix bank containing event-timestamp mapping,
* and the latest RUN::config bank.
* @param config
* @return
*/
private Event getUnixEvent(Bank config) {
Bank unix = new Bank(fullSchema.getSchema("RUN::unix"));
unix.setRows(eventUnix.size());
int row = 0;
for (int evno : eventUnix.keySet()) {
unix.putInt("event", row, evno);
unix.putInt("unixtime",row, eventUnix.get(evno));
row++;
}
Event e = new Event();
e.write(config);
e.write(unix);
return e;
}

/**
* Copy helicity/charge tag-1 information to all events.
*/
private void postprocess() {
int d = conman.getConstants(getRunNumber(), "/runcontrol/helicity").getIntValue("delay",0,0,0);
HelicitySequenceDelayed helicity = new HelicitySequenceDelayed(d);
helicity.addStream(helicities);
PostProcessor p = new PostProcessor(List.of(filename), fullSchema, helicity, scalers);
HipoReader r = new HipoReader();
r.open(filename);
Event e = new Event();
writer.open("pp_"+filename);
while (r.hasNext()) {
r.nextEvent(e);
p.processEvent(e);
HipoToHipoWriter.writeEvent(writer, e, schemaBankList);
}
writer.close();
new File(filename).delete();
new File("pp_"+filename).renameTo(new File(filename));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public CLASDecoderPool(int size, String variation, String timestamp) {
}
}

public CLASDecoder take() throws InterruptedException {
public CLASDecoder take() {
return pool.poll();
}

public void put(CLASDecoder decoder) throws InterruptedException {
public void put(CLASDecoder decoder) {
pool.offer(decoder);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,22 @@ public void processEvent(Event event) {
}
}

public void processFile(String input, String output) {
Event event = new Event();
HipoReader r = new HipoReader();
r.open(input);
HipoWriterSorted w = new HipoWriterSorted();
w.getSchemaFactory().initFromDirectory(ClasUtilsFile.getResourceDir("CLAS12DIR", "etc/bankdefs/hipo4"));
w.setCompressionType(2);
w.open(output);
while (r.hasNext()) {
r.nextEvent(event);
processEvent(event);
if (w != null) w.addEvent(event);
}
r.close();
}

/**
* The "postprocess" program.
* @param args
Expand Down
Loading
Loading