Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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[@]}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
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.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 +32,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 +65,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);
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);
serial.clear();
}

/**
Expand All @@ -120,35 +95,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);
PostProcessor p = new PostProcessor(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 @@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package org.jlab.detector.serial;

import java.util.TreeMap;
import java.util.TreeSet;
import org.jlab.detector.calib.utils.ConstantsManager;
import org.jlab.detector.decode.CLASDecoder;
import org.jlab.detector.helicity.HelicitySequence;
import org.jlab.detector.helicity.HelicityState;
import org.jlab.detector.scalers.DaqScalersSequence;
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.HipoWriterSorted;

/**
*
* @author baltzell
*/
public class SerialHoncho {

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

SchemaFactory schema;
Bank[] tag1banks;
Bank runConfig;
Bank helicityAdc;
ConstantsManager conman;
TreeMap<Integer,Integer> eventUnix;
TreeSet<HelicityState> helicities;
DaqScalersSequence scalers;

public SerialHoncho(SchemaFactory schema) {
this.schema = schema;
conman = new ConstantsManager();
conman.init("/runcontrol/hwp","/runcontrol/helicity");
runConfig = new Bank(schema.getSchema("RUN::config"));
helicityAdc = new Bank(schema.getSchema("HEL::adc"));
helicities = new TreeSet<>();
scalers = new DaqScalersSequence(schema);
eventUnix = new TreeMap<>();
tag1banks = new Bank[TAG1BANKS.length];
for (int i=0; i<tag1banks.length; ++i)
tag1banks[i] = new Bank(schema.getSchema(TAG1BANKS[i]));
}

public synchronized Event read(Event event) {
scalers.add(event);
event.read(runConfig);
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));
return CLASDecoder.createTaggedEvent(event, runConfig, tag1banks);
}

public void finish(HipoWriterSorted writer) {
writer.addEvent(getUnixEvent(runConfig),1);
HelicitySequence.writeFlips(schema, writer, helicities);
}

public void clear() {
while (helicities.size() > 100) helicities.pollFirst();
scalers.clear(100);
}

Event getUnixEvent(Bank config) {
Bank unix = new Bank(schema.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;
}

public DaqScalersSequence getScalers() {
return scalers;
}

public TreeSet<HelicityState> getHelicities() {
return helicities;
}

public ConstantsManager getConstantsManager() {
return conman;
}

public SchemaFactory getSchemaFactory() {
return schema;
}
}
Loading
Loading