Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
fix CND component number in ADC nd TDC banks and added filter option …
Browse files Browse the repository at this point in the history
…to hipo-utils
  • Loading branch information
raffaelladevita committed Jul 22, 2017
1 parent b514cb2 commit 2602d38
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -48,7 +50,7 @@ public static void writeHipoEvents(String name, List<String> inputFiles){
}


public static void writeHipo(String outputName, int compression, String keep, List<String> files){
public static void writeHipo(String outputName, int compression, String keep, String filter, List<String> files){
HipoWriter writer = new HipoWriter();
writer.open(outputName);
int nFiles = files.size();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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<String> 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");
Expand Down

0 comments on commit 2602d38

Please sign in to comment.