Skip to content

Commit f5d4f2f

Browse files
committed
finish the old new postprocessor
1 parent ad08ce0 commit f5d4f2f

1 file changed

Lines changed: 48 additions & 1 deletion

File tree

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

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

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
import org.jlab.detector.scalers.DaqScalersSequence;
2424
import org.jlab.detector.helicity.HelicityBit;
2525
import org.jlab.detector.helicity.HelicitySequenceDelayed;
26+
import org.jlab.jnp.hipo4.io.HipoWriterSorted;
27+
import org.jlab.utils.options.OptionParser;
28+
import org.jlab.utils.system.ClasUtilsFile;
2629

2730
/**
2831
*
@@ -56,6 +59,10 @@ public Processor(String dir, String glob, boolean restream, boolean rebuild) {
5659
configure(findPreloadFiles(dir,glob), restream, rebuild);
5760
}
5861

62+
public Processor(List<String> files, boolean restream, boolean rebuild) {
63+
configure(files, restream, rebuild);
64+
}
65+
5966
public Processor(SchemaFactory schema, HelicitySequenceDelayed h, DaqScalersSequence s) {
6067
conman = new ConstantsManager();
6168
conman.init(CCDB_TABLES);
@@ -295,8 +302,48 @@ private static void replace(Map<String,String> files) {
295302
}
296303
}
297304

305+
/**
306+
* The "postprocess" program.
307+
* @param args
308+
*/
298309
public static void main(String args[]) {
299-
Processor p = new Processor(System.getenv("HOME")+"/tmp","r*.hipo",false,false);
310+
311+
OptionParser o = new OptionParser("postprocess");
312+
o.addOption("-f","0","reflip: rebuild the HEL::flip bank");
313+
o.addOption("-c","0","recharge: rebuild the RUN/HEL::scaler banks");
314+
o.addOption("-o",null,"merged output file path");
315+
o.setRequiresInputList(true);
316+
o.parse(args);
317+
318+
boolean restream = !o.getOption("-f").isDefault();
319+
boolean rebuild = !o.getOption("-c").isDefault();
320+
321+
Processor post = new Processor(o.getInputList(), restream, rebuild);
322+
323+
HipoWriterSorted writer = null;
324+
325+
if (!o.getOption("-o").isDefault()) {
326+
writer = new HipoWriterSorted();
327+
SchemaFactory schema = writer.getSchemaFactory();
328+
schema.initFromDirectory(ClasUtilsFile.getResourceDir("CLAS12DIR", "etc/bankdefs/hipo4"));
329+
writer.setCompressionType(2);
330+
writer.open(o.getOption("-o").stringValue());
331+
}
332+
333+
for (String f : o.getInputList()) {
334+
HipoReader reader = new HipoReader();
335+
reader.setTags(0);
336+
reader.open(f);
337+
Event event = new Event();
338+
while (reader.hasNext()) {
339+
reader.nextEvent(event);
340+
post.processEvent(event);
341+
if (writer != null) writer.addEvent(event);
342+
}
343+
reader.close();
344+
}
345+
346+
if (writer != null) writer.close();
300347
}
301348

302349
}

0 commit comments

Comments
 (0)