Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
c1c6670
relax permissions and use decoder pool and new convenience method
baltzell Aug 27, 2026
76ab360
add multi-threaded recon-util
baltzell Aug 27, 2026
c047bcd
break it up
baltzell Aug 27, 2026
fa7f432
fininsh
baltzell Aug 27, 2026
11298f1
optimize
baltzell Aug 27, 2026
efc2394
cleanup
baltzell Aug 27, 2026
8c4e160
cleanup
baltzell Aug 27, 2026
71a0520
enlarge read queue
baltzell Aug 28, 2026
d8c8487
cleanup
baltzell Aug 28, 2026
124a0ee
cleanup
baltzell Aug 28, 2026
06c9b0b
try this
baltzell Aug 28, 2026
90d0c54
and the other one ...
baltzell Aug 28, 2026
448cdac
switch to recon-mutil in github ci test
baltzell Aug 30, 2026
4835468
fix
baltzell Aug 31, 2026
04d51ce
cleanup
baltzell Aug 31, 2026
4b54db4
switch to frames
baltzell Aug 31, 2026
28164eb
try this
baltzell Aug 31, 2026
b5e865a
try this
baltzell Aug 31, 2026
bc8f9e0
try this
baltzell Aug 31, 2026
0846c70
protect
baltzell Aug 31, 2026
bb64864
cleanup
baltzell Aug 31, 2026
5a52ade
release memory
baltzell Aug 31, 2026
535ce92
cleanup
baltzell Aug 31, 2026
ac9d837
fix
baltzell Aug 31, 2026
fff88ea
fix
baltzell Aug 31, 2026
dd4d5bf
switch scaling test to recon-mutil
baltzell Aug 31, 2026
056cdc5
no need for negatives for #events and #skip
baltzell Aug 31, 2026
e39db29
cleanup
baltzell Aug 31, 2026
2405005
cleanup
baltzell Aug 31, 2026
c176743
debug
baltzell Aug 31, 2026
a08374e
fixup
baltzell Aug 31, 2026
505db5f
fix
baltzell Aug 31, 2026
65b61d5
try this
baltzell Aug 31, 2026
f93f532
try this
baltzell Aug 31, 2026
48cc2de
fix
baltzell Aug 31, 2026
4474d7c
fix
baltzell Aug 31, 2026
86e98a0
fix
baltzell Aug 31, 2026
24a3342
fix
baltzell Aug 31, 2026
59075e8
cleanup
baltzell Aug 31, 2026
b5c130b
fix
baltzell Aug 31, 2026
63704cc
fix
baltzell Aug 31, 2026
3692d65
fix
baltzell Sep 1, 2026
001ae7a
normalize
baltzell Sep 1, 2026
a8977a5
start splitting
baltzell Sep 1, 2026
f899dd3
cleanup
baltzell Sep 1, 2026
cc305d1
reset
baltzell Sep 1, 2026
700dbcc
build clara from source
baltzell Sep 1, 2026
c6dca3d
fix path
baltzell Sep 1, 2026
6e2022f
fix
baltzell Sep 1, 2026
43390ab
cleanup
baltzell Sep 1, 2026
92adfb7
add getter for number of calls
baltzell Sep 1, 2026
4b3f0f0
add rethreading
baltzell Sep 1, 2026
2fbb0bf
cleanup
baltzell Sep 1, 2026
275ff78
reuse events during rethreading
baltzell Sep 1, 2026
fc96f68
cleanup, more accessibility
baltzell Sep 2, 2026
32fc55e
playing
baltzell Sep 2, 2026
e6cc9c3
start
baltzell Sep 2, 2026
57c42ac
more
baltzell Sep 2, 2026
6933b44
cleanup
baltzell Sep 2, 2026
0aac1c6
privatize
baltzell Sep 2, 2026
83ed13e
cleanup
baltzell Sep 2, 2026
a7bf60d
cleanup
baltzell Sep 2, 2026
ba4dc60
disable reusing events for now
baltzell Sep 2, 2026
0edb60e
honcho
baltzell Sep 2, 2026
b995143
cleanup
baltzell Sep 2, 2026
2c095f7
add missing finish
baltzell Sep 2, 2026
a107e37
let it get io-services too
baltzell Sep 3, 2026
644dcfb
import HipoToHipoWriter's schema stuff
baltzell Sep 3, 2026
badf270
fix
baltzell Sep 3, 2026
cb9b057
prepare
baltzell Sep 3, 2026
5074a71
cleanup
baltzell Sep 3, 2026
dee13dc
cleanup
baltzell Sep 3, 2026
f401478
move services to resource
baltzell Sep 3, 2026
e58ea9e
cleanup
baltzell Sep 3, 2026
eb55173
reorg
baltzell Sep 3, 2026
a587782
propagate name change
baltzell Sep 3, 2026
507f346
cleanup
baltzell Sep 4, 2026
6dc9605
go back
baltzell Sep 4, 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
9 changes: 2 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,15 @@ jobs:
clas_018779.evio.00001
- name: untar build
run: |
tar xzvf clara.tar.gz
tar xzvf 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: ls tmp
run: ls -lhtr tmp
- name: rename
run: mv -v tmp/rec_clas_018779.evio.00001.hipo rec.hipo
run: ./coatjava/bin/recon-mutil -t 4 -n 500 -y etc/services/rgd-clarode.yml -o rec_clas_018779.evio.00001.hipo -i clas_018779.evio.00001
- uses: actions/upload-artifact@v7
with:
name: test_clara_result
retention-days: 1
path: rec.hipo
path: rec_clas_018779.evio.00001.hipo

test_coatjava:
needs: [ build ]
Expand Down
2 changes: 1 addition & 1 deletion bin/postprocess2
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export MALLOC_ARENA_MAX=1

java ${JAVA_OPTS-} -Xmx768m -Xms768m -XX:+UseSerialGC \
-cp ${COATJAVA_CLASSPATH:-''} \
org.jlab.analysis.postprocess.Processor \
org.jlab.detector.serial.PostProcessor \
$*
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[@]}
6 changes: 0 additions & 6 deletions common-tools/clara-io/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@
<version>14.2.0-SNAPSHOT</version>
</dependency>

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

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-utils</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@
import java.io.File;
import java.nio.file.Path;
import java.util.List;
import java.util.TreeMap;
import java.util.TreeSet;
import org.jlab.analysis.postprocess.Processor;
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.detector.serial.SerialHoncho;
import org.jlab.jnp.hipo4.data.Bank;
import org.jlab.jnp.hipo4.data.Event;
import org.jlab.jnp.hipo4.data.SchemaFactory;
Expand All @@ -33,34 +28,22 @@
*/
public class Clas12Writer extends HipoToHipoWriter {

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

Bank[] tag1banks;
SerialHoncho serial;
Bank runConfig;
Bank helicityAdc;
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"));
serial = new SerialHoncho(fullSchema);
runConfig = new Bank(fullSchema.getSchema("RUN::config"));
helicityAdc = new Bank(fullSchema.getSchema("HEL::adc"));
helicities = new TreeSet<>();
scalers = new DaqScalersSequence(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,29 +61,17 @@ 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);
if (!t.isEmpty()) writer.addEvent(t, 1);
Event tagged = serial.read(((Event)event));
if (!tagged.isEmpty()) writer.addEvent(tagged, 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);
serial.clear();
}

/**
Expand All @@ -120,35 +91,14 @@ private int getRunNumber() {
return 0;
}

/**
* 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);
Processor p = new Processor(List.of(filename), fullSchema, helicity, scalers);
helicity.addStream(serial.getHelicities());
PostProcessor p = new PostProcessor(List.of(filename), fullSchema, helicity, serial.getScalers());
HipoReader r = new HipoReader();
r.open(filename);
Event e = new Event();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.jlab.detector.scalers.DaqScalers;
import org.jlab.detector.helicity.HelicitySequenceManager;
import org.jlab.detector.scalers.DaqScalersSequence;
import org.jlab.detector.serial.SerialUtil;
import org.jlab.jnp.hipo4.data.Bank;
import org.jlab.jnp.hipo4.data.Event;
import org.jlab.jnp.hipo4.io.HipoReader;
Expand Down Expand Up @@ -122,7 +123,7 @@ else if (seq != null) {
runScalerBank = ds.createRunBank(writer.getSchemaFactory());
helScalerBank = ds.createHelicityBank(writer.getSchemaFactory());

Util.assignScalerHelicity(event, helScalerBank, helSeq);
SerialUtil.assignScalerHelicity(event, helScalerBank, helSeq);

// put modified HEL/RUN::scaler back in the event:
event.write(runScalerBank);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jlab.analysis.postprocess;

import org.jlab.detector.serial.PostProcessor;
import java.util.TreeMap;
import java.util.logging.Logger;
import org.jlab.clas.reco.ReconstructionEngine;
Expand All @@ -13,6 +14,7 @@
import org.jlab.detector.scalers.DaqScalersSequence;
import org.jlab.detector.helicity.HelicityBit;
import org.jlab.detector.helicity.HelicitySequenceDelayed;
import org.jlab.detector.serial.SerialUtil;
import org.jlab.jnp.hipo4.data.SchemaFactory;
import org.jlab.utils.groups.IndexedTable;
import org.jlab.utils.options.OptionParser;
Expand Down Expand Up @@ -81,7 +83,7 @@ public static void main(String[] args) {
LOGGER.info("\n>>> Initializing helicity configuration from CCDB ...\n");
ConstantsManager conman = new ConstantsManager();
conman.init("/runcontrol/hwp","/runcontrol/helicity");
final int run = Util.getRunNumber(parser.getInputList().get(0));
final int run = SerialUtil.getRunNumber(parser.getInputList().get(0));
IndexedTable helTable = conman.getConstants(run, "/runcontrol/helicity");

// Initialize the scaler sequence from tag-1 events:
Expand All @@ -102,7 +104,7 @@ public static void main(String[] args) {
}

// Initialize the unix-event map:
TreeMap<Integer,Integer> eventUnix = Processor.getEventUnixMap(schema, parser.getInputList());
TreeMap<Integer,Integer> eventUnix = PostProcessor.getEventUnixMap(schema, parser.getInputList());

// Loop over the input HIPO files:
LOGGER.info("\n>>> Starting post-processing ...\n");
Expand Down Expand Up @@ -138,7 +140,7 @@ public static void main(String[] args) {
if (doHelicityDelay) {
recEventBank.putByte("helicity",0,hb.value());
recEventBank.putByte("helicityRaw",0,hbraw.value());
Util.assignScalerHelicity(runConfigBank.getLong("timestamp",0), helScalerBank, helSeq);
SerialUtil.assignScalerHelicity(runConfigBank.getLong("timestamp",0), helScalerBank, helSeq);
}

// Write beam charge to REC::Event:
Expand Down Expand Up @@ -169,7 +171,7 @@ public static void main(String[] args) {
writer.addEvent(event, event.getEventTag());

// Copy config banks to new, tag-1 events:
Util.createTag1Events(writer, event, configEvent, configBanks);
SerialUtil.createTag1Events(writer, event, configEvent, configBanks);
}

reader.close();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
package org.jlab.analysis.postprocess;
package org.jlab.detector.serial;

import java.util.List;
import java.util.TreeMap;

import org.jlab.io.base.DataBank;
import org.jlab.io.base.DataEvent;
import org.jlab.io.hipo.HipoDataBank;
import org.jlab.jnp.hipo4.data.Bank;
import org.jlab.jnp.hipo4.data.Event;
import org.jlab.jnp.hipo4.data.SchemaFactory;
import org.jlab.jnp.hipo4.io.HipoReader;
import org.jlab.io.base.DataBank;
import org.jlab.io.base.DataEvent;
import org.jlab.io.hipo.HipoDataBank;
import org.jlab.jnp.hipo4.io.HipoWriterSorted;

import org.jlab.detector.calib.utils.ConstantsManager;
import org.jlab.detector.scalers.DaqScalers;
import org.jlab.detector.scalers.DaqScalersSequence;
import org.jlab.detector.helicity.HelicityBit;
import org.jlab.detector.helicity.HelicitySequenceDelayed;
import org.jlab.jnp.hipo4.io.HipoWriterSorted;
import org.jlab.detector.calib.utils.ConstantsManager;
import org.jlab.utils.options.OptionParser;
import org.jlab.utils.system.ClasUtilsFile;

/**
*
* @author baltzell
*/
public class Processor {
public class PostProcessor {

public static final String CCDB_TABLES[] = {"/runcontrol/fcup","/runcontrol/slm",
"/runcontrol/helicity","/daq/config/scalers/dsc1","/runcontrol/hwp"};
Expand All @@ -37,7 +37,7 @@ public class Processor {
private HelicitySequenceDelayed helicitySequence = null;
private TreeMap<Integer,Integer> eventUnix = null;

public Processor(List<String> files, boolean restream, boolean rebuild) {
public PostProcessor(List<String> files, boolean restream, boolean rebuild) {
HipoReader r = new HipoReader();
r.open(files.get(0));
schemaFactory = r.getSchemaFactory();
Expand All @@ -46,13 +46,13 @@ public Processor(List<String> files, boolean restream, boolean rebuild) {
recEvent = new Bank(schemaFactory.getSchema("REC::Event"));
conman = new ConstantsManager();
conman.init(CCDB_TABLES);
helicitySequence = Util.getHelicity(files, schemaFactory, restream, conman);
helicitySequence = SerialUtil.getHelicity(files, schemaFactory, restream, conman);
if (rebuild) chargeSequence = DaqScalersSequence.rebuildSequence(1, conman, files);
else chargeSequence = DaqScalersSequence.readSequence(files);
eventUnix = getEventUnixMap(schemaFactory, files);
}

public Processor(List<String> files, SchemaFactory schema, HelicitySequenceDelayed h, DaqScalersSequence s) {
public PostProcessor(List<String> files, SchemaFactory schema, HelicitySequenceDelayed h, DaqScalersSequence s) {
schemaFactory = schema;
helicitySequence = h;
chargeSequence = s;
Expand Down Expand Up @@ -102,7 +102,7 @@ private void processEventHelicity(DataEvent event, DataBank runcfg, DataBank rec
DataBank helScaler = event.getBank("HEL::scaler");
if (helScaler.rows()>0) {
event.removeBank("HEL::scaler");
Util.assignScalerHelicity(runcfg.getLong("timestamp",0), ((HipoDataBank)helScaler).getBank(), helicitySequence);
SerialUtil.assignScalerHelicity(runcfg.getLong("timestamp",0), ((HipoDataBank)helScaler).getBank(), helicitySequence);
event.appendBank(helScaler);
}
}
Expand All @@ -122,7 +122,7 @@ private void processEventHelicity(Event event, Bank runcfg, Bank recevt) {
event.read(helScaler);
if (helScaler.getRows()>0) {
event.remove(schemaFactory.getSchema("HEL::scaler"));
Util.assignScalerHelicity(runcfg.getLong("timestamp",0), helScaler, helicitySequence);
SerialUtil.assignScalerHelicity(runcfg.getLong("timestamp",0), helScaler, helicitySequence);
event.write(helScaler);
}
}
Expand Down Expand Up @@ -247,7 +247,7 @@ public static void main(String args[]) {
boolean restream = !o.getOption("-f").isDefault();
boolean rebuild = !o.getOption("-c").isDefault();

Processor post = new Processor(o.getInputList(), restream, rebuild);
PostProcessor post = new PostProcessor(o.getInputList(), restream, rebuild);

HipoWriterSorted writer = null;

Expand All @@ -274,4 +274,20 @@ public static void main(String args[]) {
if (writer != null) writer.close();
}

public void postprocess(int run, String input, SerialHoncho serial, HipoWriterSorted writer, List<Bank> banks) {
int d = serial.getConstantsManager().getConstants(run, "/runcontrol/helicity").getIntValue("delay",0,0,0);
HelicitySequenceDelayed helicity = new HelicitySequenceDelayed(d);
helicity.addStream(serial.getHelicities());
PostProcessor p = new PostProcessor(List.of(input), serial.getSchemaFactory(), helicity, serial.getScalers());
HipoReader r = new HipoReader();
r.open(input);
Event e = new Event();
while (r.hasNext()) {
r.nextEvent(e);
p.processEvent(e);
int tag = e.getEventTag();
if (tag==1 || banks.isEmpty()) writer.addEvent(e,tag);
else writer.addEvent(e.reduceEvent(banks),tag);
}
}
}
Loading
Loading