Skip to content

Commit ca0e2a4

Browse files
committed
finish
1 parent 1e18cdb commit ca0e2a4

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;
@@ -41,6 +43,8 @@ public class EngineProcessor {
4143
private SchemaFactory banksToKeep = null;
4244
private final List<String> schemaExempt = Arrays.asList("RUN::config","DC::tdc");
4345

46+
private CLASDecoder decoder = new CLASDecoder();
47+
4448
public EngineProcessor(){}
4549

4650
private ReconstructionEngine findEngine(String clazz) {
@@ -296,7 +300,7 @@ public void processEvent(DataEvent event, HipoDataSync writer) {
296300
removeBanks(event);
297301
writer.writeEvent(event);
298302
}
299-
303+
300304
public void processFile(HipoDataSource reader, HipoDataSync writer, int skipEvents, int maxEvents) {
301305
if (updateDictionary==true) updateDictionary(reader, writer);
302306
ProgressPrintout progress = new ProgressPrintout();
@@ -313,7 +317,6 @@ public void processFile(HipoDataSource reader, HipoDataSync writer, int skipEven
313317
}
314318

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

333340
/**}
334341
* process entire file through engine chain.
335-
* @param file input file name to process
342+
* @param input input file name to process
336343
* @param output output filename
337344
* @param nskip number of events to skip
338345
* @param nevents number of events to process
339346
*/
340-
public void processFile(String file, String output, int nskip, int nevents) {
341-
if (file.endsWith(".hipo") || file.endsWith(".h5") || file.endsWith(".h4")) {
347+
public void processFile(String input, String output, int nskip, int nevents) {
348+
HipoDataSync writer = new HipoDataSync();
349+
writer.setCompressionType(2);
350+
if (input.endsWith(".hipo") || input.endsWith(".h5") || input.endsWith(".h4")) {
342351
HipoDataSource reader = new HipoDataSource();
343-
reader.open(file);
344-
HipoDataSync writer = new HipoDataSync();
345-
writer.setCompressionType(2);
352+
reader.open(input);
346353
writer.open(output);
347354
processFile(reader, writer, nskip, nevents);
348355
} else {
349-
LOGGER.info(() -> "No HIPO file extension found, assuming this is an EVIO file: "+file);
356+
LOGGER.info(() -> "No HIPO file extension found, assuming this is an EVIO file: "+input);
350357
EvioSource reader = new EvioSource();
351-
reader.open(file);
352-
HipoDataSync writer = new HipoDataSync();
353-
writer.setCompressionType(2);
358+
reader.open(input);
354359
writer.open(output);
355360
processFile(reader, writer, nskip, nevents);
356361
}

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)