Skip to content

Commit 0fbdf3d

Browse files
committed
finish
1 parent c1659d8 commit 0fbdf3d

File tree

2 files changed

+18
-50
lines changed

2 files changed

+18
-50
lines changed

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
import java.util.Arrays;
2020
import org.jlab.coda.jevio.EvioException;
2121
import org.jlab.detector.decode.CLASDecoder;
22+
import org.jlab.io.base.DataBank;
2223
import org.jlab.io.evio.EvioDataEvent;
2324
import org.jlab.io.evio.EvioSource;
25+
import org.jlab.io.hipo.HipoDataEvent;
2426
import org.jlab.jnp.hipo4.data.Event;
2527
import org.jlab.jnp.hipo4.data.SchemaFactory;
2628
import org.json.JSONObject;
@@ -42,6 +44,8 @@ public class EngineProcessor {
4244
private SchemaFactory banksToKeep = null;
4345
private final List<String> schemaExempt = Arrays.asList("RUN::config","DC::tdc");
4446

47+
private CLASDecoder decoder = new CLASDecoder();
48+
4549
public EngineProcessor(){}
4650

4751
private ReconstructionEngine findEngine(String clazz) {
@@ -297,7 +301,7 @@ public void processEvent(DataEvent event, HipoDataSync writer) {
297301
removeBanks(event);
298302
writer.writeEvent(event);
299303
}
300-
304+
301305
public void processFile(HipoDataSource reader, HipoDataSync writer, int skipEvents, int maxEvents) {
302306
if (updateDictionary==true) updateDictionary(reader, writer);
303307
ProgressPrintout progress = new ProgressPrintout();
@@ -314,7 +318,6 @@ public void processFile(HipoDataSource reader, HipoDataSync writer, int skipEven
314318
}
315319

316320
public void processFile(EvioSource reader, HipoDataSync writer, int skipEvents, int maxEvents) {
317-
CLASDecoder decoder = new CLASDecoder();
318321
ProgressPrintout progress = new ProgressPrintout();
319322
int eventsRead = 0;
320323
while (reader.hasEvent()) {
@@ -323,35 +326,37 @@ public void processFile(EvioSource reader, HipoDataSync writer, int skipEvents,
323326
ByteBuffer bb = reader.getEventBuffer(eventsRead, true);
324327
EvioDataEvent evio = new EvioDataEvent(bb.array(), ByteOrder.LITTLE_ENDIAN);
325328
Event hipo = decoder.getDecodedEvent(evio, -1, eventsRead, null, null);
326-
//processEvent(hipo, writer);
329+
HipoDataEvent hipo2 = new HipoDataEvent(hipo, decoder.getSchemaFactory());
330+
if (skipEvents <= 0 || eventsRead > skipEvents) processEvent(hipo2, writer);
331+
if (maxEvents > 0 && eventsRead > maxEvents+skipEvents) break;
327332
} catch (EvioException ex) {
328333
System.getLogger(EngineProcessor.class.getName()).log(System.Logger.Level.ERROR, (String) null, ex);
329334
}
330335
progress.updateStatus();
331336
}
337+
progress.showStatus();
338+
writer.close();
332339
}
333340

334341
/**}
335342
* process entire file through engine chain.
336-
* @param file input file name to process
343+
* @param input input file name to process
337344
* @param output output filename
338345
* @param nskip number of events to skip
339346
* @param nevents number of events to process
340347
*/
341-
public void processFile(String file, String output, int nskip, int nevents) {
342-
if (file.endsWith(".hipo") || file.endsWith(".h5") || file.endsWith(".h4")) {
348+
public void processFile(String input, String output, int nskip, int nevents) {
349+
HipoDataSync writer = new HipoDataSync();
350+
writer.setCompressionType(2);
351+
if (input.endsWith(".hipo") || input.endsWith(".h5") || input.endsWith(".h4")) {
343352
HipoDataSource reader = new HipoDataSource();
344-
reader.open(file);
345-
HipoDataSync writer = new HipoDataSync();
346-
writer.setCompressionType(2);
353+
reader.open(input);
347354
writer.open(output);
348355
processFile(reader, writer, nskip, nevents);
349356
} else {
350-
LOGGER.info(() -> "No HIPO file extension found, assuming this is an EVIO file: "+file);
357+
LOGGER.info(() -> "No HIPO file extension found, assuming this is an EVIO file: "+input);
351358
EvioSource reader = new EvioSource();
352-
reader.open(file);
353-
HipoDataSync writer = new HipoDataSync();
354-
writer.setCompressionType(2);
359+
reader.open(input);
355360
writer.open(output);
356361
processFile(reader, writer, nskip, nevents);
357362
}

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

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,6 @@ public EngineData execute(EngineData input) {
434434
try {
435435
this.processDataEvent(dataevent);
436436
ByteBuffer bbo = dataevent.getEventBuffer();
437-
//byte[] buffero = bbo.array();
438437
output.setData(mt, bbo);
439438
} catch (Exception e) {
440439
String msg = String.format("Error processing input event%n%n%s", ClaraUtil.reportException(e));
@@ -446,42 +445,6 @@ public EngineData execute(EngineData input) {
446445
}
447446

448447
return input;
449-
/*
450-
if (!mt.equalsIgnoreCase()) {
451-
String msg = String.format("Wrong input type: %s", mt);
452-
output.setStatus(EngineStatus.ERROR);
453-
output.setDescription(msg);
454-
return output;
455-
}*/
456-
/*
457-
EvioDataEvent dataevent = null;
458-
459-
try {
460-
ByteBuffer bb = (ByteBuffer) input.getData();
461-
byte[] buffer = bb.array();
462-
ByteOrder endianness = bb.order();
463-
dataevent = new EvioDataEvent(buffer, endianness, EvioFactory.getDictionary());
464-
} catch (Exception e) {
465-
String msg = String.format("Error reading input event%n%n%s", ClaraUtil.reportException(e));
466-
output.setStatus(EngineStatus.ERROR);
467-
output.setDescription(msg);
468-
return output;
469-
}
470-
471-
try {
472-
this.processDataEvent(dataevent);
473-
ByteBuffer bbo = dataevent.getEventBuffer();
474-
//byte[] buffero = bbo.array();
475-
output.setData(mt, bbo);
476-
} catch (Exception e) {
477-
String msg = String.format("Error processing input event%n%n%s", ClaraUtil.reportException(e));
478-
output.setStatus(EngineStatus.ERROR);
479-
output.setDescription(msg);
480-
return output;
481-
}
482-
483-
return output;
484-
*/
485448
}
486449

487450
@Override

0 commit comments

Comments
 (0)