Skip to content

Commit dff4696

Browse files
authored
Move serial/postprocessor utilities to clas-detector package (#1414)
* add serial class * separate "serial" functionality for reusability * relocate serial/postprocessing utilities to clas-detector
1 parent 9a1c25e commit dff4696

7 files changed

Lines changed: 22 additions & 25 deletions

File tree

bin/postprocess2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export MALLOC_ARENA_MAX=1
66

77
java ${JAVA_OPTS-} -Xmx768m -Xms768m -XX:+UseSerialGC \
88
-cp ${COATJAVA_CLASSPATH:-''} \
9-
org.jlab.analysis.postprocess.Processor \
9+
org.jlab.detector.serial.PostProcessor \
1010
$*

common-tools/clara-io/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@
4848
<version>14.2.0-SNAPSHOT</version>
4949
</dependency>
5050

51-
<dependency>
52-
<groupId>org.jlab.clas</groupId>
53-
<artifactId>clas-analysis</artifactId>
54-
<version>14.2.0-SNAPSHOT</version>
55-
</dependency>
56-
5751
<dependency>
5852
<groupId>org.jlab.clas</groupId>
5953
<artifactId>clas-utils</artifactId>

common-tools/clara-io/src/main/java/org/jlab/io/clara/Clas12Writer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
import java.util.List;
66
import java.util.TreeMap;
77
import java.util.TreeSet;
8-
import org.jlab.analysis.postprocess.Processor;
98
import org.jlab.clara.std.services.EventWriterException;
109
import org.jlab.detector.calib.utils.ConstantsManager;
1110
import org.jlab.detector.decode.CLASDecoder4;
1211
import org.jlab.detector.helicity.HelicitySequence;
1312
import org.jlab.detector.helicity.HelicitySequenceDelayed;
1413
import org.jlab.detector.helicity.HelicityState;
1514
import org.jlab.detector.scalers.DaqScalersSequence;
15+
import org.jlab.detector.serial.PostProcessor;
1616
import org.jlab.jnp.hipo4.data.Bank;
1717
import org.jlab.jnp.hipo4.data.Event;
1818
import org.jlab.jnp.hipo4.data.SchemaFactory;
@@ -148,7 +148,7 @@ private void postprocess() {
148148
int d = conman.getConstants(getRunNumber(), "/runcontrol/helicity").getIntValue("delay",0,0,0);
149149
HelicitySequenceDelayed helicity = new HelicitySequenceDelayed(d);
150150
helicity.addStream(helicities);
151-
Processor p = new Processor(List.of(filename), fullSchema, helicity, scalers);
151+
PostProcessor p = new PostProcessor(List.of(filename), fullSchema, helicity, scalers);
152152
HipoReader r = new HipoReader();
153153
r.open(filename);
154154
Event e = new Event();

common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess/RebuildScalers.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.jlab.detector.scalers.DaqScalers;
1010
import org.jlab.detector.helicity.HelicitySequenceManager;
1111
import org.jlab.detector.scalers.DaqScalersSequence;
12+
import org.jlab.detector.serial.SerialUtil;
1213
import org.jlab.jnp.hipo4.data.Bank;
1314
import org.jlab.jnp.hipo4.data.Event;
1415
import org.jlab.jnp.hipo4.io.HipoReader;
@@ -122,7 +123,7 @@ else if (seq != null) {
122123
runScalerBank = ds.createRunBank(writer.getSchemaFactory());
123124
helScalerBank = ds.createHelicityBank(writer.getSchemaFactory());
124125

125-
Util.assignScalerHelicity(event, helScalerBank, helSeq);
126+
SerialUtil.assignScalerHelicity(event, helScalerBank, helSeq);
126127

127128
// put modified HEL/RUN::scaler back in the event:
128129
event.write(runScalerBank);

common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess/Tag1ToEvent.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.jlab.analysis.postprocess;
22

3+
import org.jlab.detector.serial.PostProcessor;
34
import java.util.TreeMap;
45
import java.util.logging.Logger;
56
import org.jlab.clas.reco.ReconstructionEngine;
@@ -13,6 +14,7 @@
1314
import org.jlab.detector.scalers.DaqScalersSequence;
1415
import org.jlab.detector.helicity.HelicityBit;
1516
import org.jlab.detector.helicity.HelicitySequenceDelayed;
17+
import org.jlab.detector.serial.SerialUtil;
1618
import org.jlab.jnp.hipo4.data.SchemaFactory;
1719
import org.jlab.utils.groups.IndexedTable;
1820
import org.jlab.utils.options.OptionParser;
@@ -81,7 +83,7 @@ public static void main(String[] args) {
8183
LOGGER.info("\n>>> Initializing helicity configuration from CCDB ...\n");
8284
ConstantsManager conman = new ConstantsManager();
8385
conman.init("/runcontrol/hwp","/runcontrol/helicity");
84-
final int run = Util.getRunNumber(parser.getInputList().get(0));
86+
final int run = SerialUtil.getRunNumber(parser.getInputList().get(0));
8587
IndexedTable helTable = conman.getConstants(run, "/runcontrol/helicity");
8688

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

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

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

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

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

175177
reader.close();

common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess/Processor.java renamed to common-tools/clas-detector/src/main/java/org/jlab/detector/serial/PostProcessor.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.jlab.analysis.postprocess;
1+
package org.jlab.detector.serial;
22

33
import java.util.List;
44
import java.util.TreeMap;
@@ -24,7 +24,7 @@
2424
*
2525
* @author baltzell
2626
*/
27-
public class Processor {
27+
public class PostProcessor {
2828

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

40-
public Processor(List<String> files, boolean restream, boolean rebuild) {
40+
public PostProcessor(List<String> files, boolean restream, boolean rebuild) {
4141
HipoReader r = new HipoReader();
4242
r.open(files.get(0));
4343
schemaFactory = r.getSchemaFactory();
@@ -46,13 +46,13 @@ public Processor(List<String> files, boolean restream, boolean rebuild) {
4646
recEvent = new Bank(schemaFactory.getSchema("REC::Event"));
4747
conman = new ConstantsManager();
4848
conman.init(CCDB_TABLES);
49-
helicitySequence = Util.getHelicity(files, schemaFactory, restream, conman);
49+
helicitySequence = SerialUtil.getHelicity(files, schemaFactory, restream, conman);
5050
if (rebuild) chargeSequence = DaqScalersSequence.rebuildSequence(1, conman, files);
5151
else chargeSequence = DaqScalersSequence.readSequence(files);
5252
eventUnix = getEventUnixMap(schemaFactory, files);
5353
}
5454

55-
public Processor(List<String> files, SchemaFactory schema, HelicitySequenceDelayed h, DaqScalersSequence s) {
55+
public PostProcessor(List<String> files, SchemaFactory schema, HelicitySequenceDelayed h, DaqScalersSequence s) {
5656
schemaFactory = schema;
5757
helicitySequence = h;
5858
chargeSequence = s;
@@ -102,7 +102,7 @@ private void processEventHelicity(DataEvent event, DataBank runcfg, DataBank rec
102102
DataBank helScaler = event.getBank("HEL::scaler");
103103
if (helScaler.rows()>0) {
104104
event.removeBank("HEL::scaler");
105-
Util.assignScalerHelicity(runcfg.getLong("timestamp",0), ((HipoDataBank)helScaler).getBank(), helicitySequence);
105+
SerialUtil.assignScalerHelicity(runcfg.getLong("timestamp",0), ((HipoDataBank)helScaler).getBank(), helicitySequence);
106106
event.appendBank(helScaler);
107107
}
108108
}
@@ -122,7 +122,7 @@ private void processEventHelicity(Event event, Bank runcfg, Bank recevt) {
122122
event.read(helScaler);
123123
if (helScaler.getRows()>0) {
124124
event.remove(schemaFactory.getSchema("HEL::scaler"));
125-
Util.assignScalerHelicity(runcfg.getLong("timestamp",0), helScaler, helicitySequence);
125+
SerialUtil.assignScalerHelicity(runcfg.getLong("timestamp",0), helScaler, helicitySequence);
126126
event.write(helScaler);
127127
}
128128
}
@@ -247,7 +247,7 @@ public static void main(String args[]) {
247247
boolean restream = !o.getOption("-f").isDefault();
248248
boolean rebuild = !o.getOption("-c").isDefault();
249249

250-
Processor post = new Processor(o.getInputList(), restream, rebuild);
250+
PostProcessor post = new PostProcessor(o.getInputList(), restream, rebuild);
251251

252252
HipoWriterSorted writer = null;
253253

common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess/Util.java renamed to common-tools/clas-detector/src/main/java/org/jlab/detector/serial/SerialUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.jlab.analysis.postprocess;
1+
package org.jlab.detector.serial;
22

33
import java.sql.Time;
44
import java.util.Arrays;
@@ -26,9 +26,9 @@
2626
* Static utility methods for postprocessing.
2727
* @author baltzell
2828
*/
29-
class Util {
29+
public class SerialUtil {
3030

31-
static final Logger logger = Logger.getLogger(Util.class.getName());
31+
static final Logger logger = Logger.getLogger(SerialUtil.class.getName());
3232

3333
/**
3434
* Assign the delay-corrected helicity to the HEL::scaler bank's rows

0 commit comments

Comments
 (0)