Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* 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
*
* 6. Outputs a parallel file of select trigger bits with a raw schema
* @author baltzell
*/
public class Clas12Writer extends HipoToHipoWriter {
Expand All @@ -44,6 +44,8 @@ public class Clas12Writer extends HipoToHipoWriter {
DaqScalersSequence scalers;
SchemaFactory fullSchema;
boolean postprocess;
HipoWriterSorted rawWriter;
long rawTriggerMask;

private void init(JSONObject opts) {
fullSchema = new SchemaFactory();
Expand All @@ -56,6 +58,7 @@ private void init(JSONObject opts) {
eventUnix = new TreeMap<>();
conman.init("/runcontrol/hwp","/runcontrol/helicity");
postprocess = opts.optBoolean("postprocess", false);
rawTriggerMask = opts.optLong("rawTriggerMask", -1);
if (opts.has("variation")) conman.setVariation(opts.getString("variation"));
if (opts.has("timestamp")) conman.setTimeStamp(opts.getString("timestamp"));
tag1banks = new Bank[TAG1BANKS.length];
Expand All @@ -70,6 +73,11 @@ protected HipoWriterSorted createWriter(Path file, JSONObject opts) throws Event
HipoWriterSorted w = new HipoWriterSorted();
super.configure(w, opts);
w.open(file.toString().endsWith(".hipo") ? file.toString() : file.toString()+".hipo");
if (rawTriggerMask > 0) {
rawWriter = new HipoWriterSorted();
rawWriter.getSchemaFactory().copy(fullSchema);
rawWriter.open("raw_"+file.toString().substring(file.toString().indexOf("_")));
}
return w;
} catch (Exception e) {
throw new EventWriterException(e);
Expand All @@ -90,6 +98,14 @@ protected void writeEvent(Object event) throws EventWriterException {
Event t = CLASDecoder4.createTaggedEvent((Event)event, runConfig, tag1banks);
if (!t.isEmpty()) writer.addEvent(t, 1);
super.writeEvent(event);
if (rawTriggerMask > 0) {
if (runConfig.getRows() > 0) {
if ((runConfig.getLong("trigger",0) & rawTriggerMask) != 0) {
rawWriter.addEvent((Event)event);
}
}
if (!t.isEmpty()) rawWriter.addEvent(t, 1);
}
}

@Override
Expand All @@ -101,6 +117,7 @@ protected void closeWriter() {
// keep the latest helicity/scaler reading for the next file:
while (helicities.size() > 60) helicities.pollFirst();
scalers.clear(10);
if (rawTriggerMask > 0) rawWriter.close();
}

/**
Expand Down
Loading