Skip to content

Commit 24091a2

Browse files
authored
use schema directory in dst-maker (#1094)
* cleanup * upgrade dst-maker
1 parent 6ab288d commit 24091a2

File tree

3 files changed

+66
-31
lines changed

3 files changed

+66
-31
lines changed

bin/dst-maker

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,10 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

3-
usage="\nUsage: dst-maker -o outputfile inputfile [inputfile [...]]\n"
3+
. `dirname $0`/../libexec/env.sh
44

5-
if [ "$#" -lt 3 ]; then
6-
echo -e $usage
7-
exit
8-
elif [ "$1" != "-o" ]; then
9-
echo -e $usage
10-
exit
11-
elif [ -e $2 ]; then
12-
echo -e $usage
13-
echo File already exists: $2
14-
exit
15-
else
16-
for x in ${@:3}
17-
do
18-
if ! [ -e $x ]; then
19-
echo -e $usage
20-
echo File does not exist: $x
21-
exit
22-
fi
23-
done
24-
fi
25-
26-
hipo-utils \
27-
-filter \
28-
-b 'RUN::*,RAW::epics,RAW::scaler,HEL::flip,HEL::online,REC::*,RECFT::*,MC::*' \
29-
-merge \
30-
-o $2 \
31-
${@:3}
5+
export MALLOC_ARENA_MAX=1
326

7+
java ${JAVA_OPTS-} -Xmx1280m -Xms768m -XX:+UseSerialGC \
8+
-cp ${COATJAVA_CLASSPATH:-''} \
9+
org.jlab.io.utils.DstMaker \
10+
$*
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.jlab.io.utils;
2+
3+
import java.io.File;
4+
import java.nio.file.Files;
5+
import org.jlab.io.base.DataEvent;
6+
import org.jlab.io.hipo.HipoDataSource;
7+
import org.jlab.io.hipo.HipoDataSync;
8+
import org.jlab.jnp.hipo4.data.SchemaFactory;
9+
import org.jlab.utils.options.OptionParser;
10+
import org.jlab.utils.system.ClasUtilsFile;
11+
12+
public class DstMaker {
13+
14+
public static void main(String args[]) {
15+
16+
OptionParser opt = new OptionParser("dst-maker");
17+
opt.addOption("-s","dst","schema path, or stock schema name (default=dst)");
18+
opt.addRequired("-o","output file");
19+
opt.setRequiresInputList(true);
20+
opt.parse(args);
21+
22+
HipoDataSync w = new HipoDataSync();
23+
w.setCompressionType(2);
24+
25+
SchemaFactory schema = new SchemaFactory();
26+
String stock = ClasUtilsFile.getResourceDir("CLAS12DIR","etc/bankdefs/hipo4/singles");
27+
String user = opt.getOption("-s").stringValue();
28+
if (Files.isDirectory((new File(stock+"/"+user)).toPath())) {
29+
System.out.println("Assuming -s is a stock schema: "+user);
30+
schema.initFromDirectory(stock+"/"+user);
31+
}
32+
else if (Files.isDirectory((new File(user)).toPath())) {
33+
System.out.println("Assuming -s is a schema path: "+user);
34+
schema.initFromDirectory(user);
35+
}
36+
else {
37+
System.err.println("Unable to initialize schema from -s "+user);
38+
System.exit(2);
39+
}
40+
w.open(opt.getOption("-o").stringValue());
41+
42+
for (String input : opt.getInputList()) {
43+
HipoDataSource r = new HipoDataSource();
44+
r.open(input);
45+
while (r.hasEvent()) {
46+
DataEvent e = r.getNextEvent();
47+
for (String name : e.getBankList()) {
48+
if (!schema.hasSchema(name)) {
49+
e.removeBank(name);
50+
}
51+
}
52+
w.writeEvent(e);
53+
}
54+
r.close();
55+
}
56+
w.close();
57+
}
58+
}

common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ public void processFile(HipoDataSource reader, HipoDataSync writer, int skipEven
312312
progress.updateStatus();
313313
}
314314
progress.showStatus();
315-
writer.close();
316315
}
317316

318317
public void processFile(EvioSource reader, HipoDataSync writer, int skipEvents, int maxEvents) {
@@ -335,7 +334,6 @@ public void processFile(EvioSource reader, HipoDataSync writer, int skipEvents,
335334
progress.updateStatus();
336335
}
337336
progress.showStatus();
338-
writer.close();
339337
}
340338

341339
/**}
@@ -360,6 +358,7 @@ public void processFile(String input, String output, int nskip, int nevents) {
360358
writer.open(output);
361359
processFile(reader, writer, nskip, nevents);
362360
}
361+
writer.close();
363362
}
364363

365364
/**

0 commit comments

Comments
 (0)