From 2602d38d434a77d6c55053c8ba80c3bd7048fe18 Mon Sep 17 00:00:00 2001 From: raffaelladevita Date: Sat, 22 Jul 2017 18:48:50 -0400 Subject: [PATCH] fix CND component number in ADC nd TDC banks and added filter option to hipo-utils --- .../java/org/jlab/io/hipo/EvioHipoEvent.java | 8 ++++---- .../org/jlab/clas/reco/io/HipoFileUtils.java | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/hipo/EvioHipoEvent.java b/common-tools/clas-io/src/main/java/org/jlab/io/hipo/EvioHipoEvent.java index 8c7a2ca603..76735f7ef0 100644 --- a/common-tools/clas-io/src/main/java/org/jlab/io/hipo/EvioHipoEvent.java +++ b/common-tools/clas-io/src/main/java/org/jlab/io/hipo/EvioHipoEvent.java @@ -289,25 +289,25 @@ public void fillHipoEventCND(HipoDataEvent hipoEvent, EvioDataEvent evioEvent){ hipoADC.setByte("sector", index, (byte) evioBank.getInt("sector",i)); hipoADC.setByte("layer", index, (byte) evioBank.getInt("layer",i)); - hipoADC.setShort("component", index, (short) evioBank.getInt("paddle",i)); + hipoADC.setShort("component", index, (short) evioBank.getInt("component",i)); hipoADC.setByte("order", index,(byte) 0); hipoADC.setInt("ADC", index, evioBank.getInt("ADCL", i)); hipoADC.setByte("sector", index+1, (byte) evioBank.getInt("sector",i)); hipoADC.setByte("layer", index+1, (byte) evioBank.getInt("layer",i)); - hipoADC.setShort("component", index+1, (short) evioBank.getInt("paddle",i)); + hipoADC.setShort("component", index+1, (short) evioBank.getInt("component",i)); hipoADC.setByte("order", index+1,(byte) 1); hipoADC.setInt("ADC", index+1, evioBank.getInt("ADCR", i)); hipoTDC.setByte("sector", index, (byte) evioBank.getInt("sector",i)); hipoTDC.setByte("layer", index, (byte) evioBank.getInt("layer",i)); - hipoTDC.setShort("component", index, (short) evioBank.getInt("paddle",i)); + hipoTDC.setShort("component", index, (short) evioBank.getInt("component",i)); hipoTDC.setByte("order", index,(byte) 2); hipoTDC.setInt("TDC", index, evioBank.getInt("TDCL", i)); hipoTDC.setByte("sector", index+1, (byte) evioBank.getInt("sector",i)); hipoTDC.setByte("layer", index+1, (byte) evioBank.getInt("layer",i)); - hipoTDC.setShort("component", index+1, (short) evioBank.getInt("paddle",i)); + hipoTDC.setShort("component", index+1, (short) evioBank.getInt("component",i)); hipoTDC.setByte("order", index+1,(byte) 3); hipoTDC.setInt("TDC", index+1, evioBank.getInt("TDCR", i)); diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/io/HipoFileUtils.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/io/HipoFileUtils.java index e4d17e035a..e77249f485 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/io/HipoFileUtils.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/io/HipoFileUtils.java @@ -15,12 +15,14 @@ import org.jlab.groot.data.H1F; import org.jlab.groot.ui.TCanvas; import org.jlab.hipo.data.HipoEvent; +import org.jlab.hipo.data.HipoGroup; import org.jlab.hipo.data.HipoNode; import org.jlab.hipo.data.HipoNodeBuilder; import org.jlab.hipo.io.HipoReader; import org.jlab.hipo.io.HipoWriter; import org.jlab.hipo.schema.Schema; import org.jlab.hipo.schema.SchemaFactory; +import org.jlab.io.base.DataEvent; import org.jlab.io.evio.EvioDataBank; import org.jlab.io.evio.EvioDataEvent; import org.jlab.io.evio.EvioFactory; @@ -48,7 +50,7 @@ public static void writeHipoEvents(String name, List inputFiles){ } - public static void writeHipo(String outputName, int compression, String keep, List files){ + public static void writeHipo(String outputName, int compression, String keep, String filter, List files){ HipoWriter writer = new HipoWriter(); writer.open(outputName); int nFiles = files.size(); @@ -85,10 +87,17 @@ public static void writeHipo(String outputName, int compression, String keep, Li int nEvents = reader.getEventCount(); for(int nev = 0; nev < nEvents; nev++){ HipoEvent event = reader.readHipoEvent(nev); + boolean flag = false; + for(HipoGroup group : event.getGroups()) { +// System.out.println(group.getSchema().getName()); + if(group.getSchema().getName().contains(filter)==true || filter.compareTo("ANY")==0) flag = true; + } + if(flag){ HipoEvent outEvent = writerFactory.getFilteredEvent(event); //outEvent.show(); writer.writeEvent(outEvent); progress.updateStatus(); + } } } writer.close(); @@ -254,16 +263,18 @@ public static void main(String[] args){ OptionParser parser = new OptionParser(); parser.addRequired("-o"); parser.addOption("-keep", "ALL", "Selection of banks to keep in the output"); + parser.addOption("-filter", "ANY", "Write only events with the selected bank"); parser.addOption("-c", "2","Compression algorithm (0-none, 1-gzip, 2-lz4)"); parser.parse(args); String outputFile = parser.getOption("-o").stringValue(); List inputFileList = parser.getInputList(); - int compression = parser.getOption("-c").intValue(); - String keepBanks = parser.getOption("-keep").stringValue(); + int compression = parser.getOption("-c").intValue(); + String keepBanks = parser.getOption("-keep").stringValue(); + String filterEvents = parser.getOption("-filter").stringValue(); - HipoFileUtils.writeHipo(outputFile, compression, keepBanks, inputFileList); + HipoFileUtils.writeHipo(outputFile, compression, keepBanks, filterEvents, inputFileList); /* if(parser.getCommand().getCommand().compareTo("-lund")==0){ String output = parser.getCommand().getAsString("-o");