diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 9b62e169a1..ba7ff717a3 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -25,7 +25,7 @@ env:
java_distribution: zulu
javadoc_version: 24 # newer than `java_version` for better javadoc
groovy_version: 4.x
- CCDB_CONNECTION: 'sqlite:////cvmfs/oasis.opensciencegrid.org/jlab/hallb/clas12/sw/noarch/data/ccdb/ccdb_latest.sqlite'
+ #CCDB_CONNECTION: 'sqlite:////cvmfs/oasis.opensciencegrid.org/jlab/hallb/clas12/sw/noarch/data/ccdb/ccdb_latest.sqlite'
nthreads: 1
jobs:
diff --git a/CODEOWNERS b/CODEOWNERS
index 93391aaaeb..7a83b03630 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -2,58 +2,28 @@
# | Name | GitHub Handle |
# | ---- | ------------- |
# | Adam Hobart | ajhobart |
-# | Alessandra Filippi | afilippi67 |
# | Andrey Kim | drewkenjo |
-# | Blake Huck | huckb |
-# | Bruno Benkel | bleaktwig |
# | Christopher Dilks | c-dilks |
# | Cole Smith | forcar |
-# | Connor Pecar | cpecar |
# | David Heddle | heddle |
-# | Silvia Niccolai | silvianic |
-# | David Payette | dpayette |
+# | Eric Fuchey | efuchey |
# | Felix Touchte Codjo | ftouchte |
# | Florian Hauenstein | hauenst |
-# | Francesco Bossu | fbossu |
-# | Francois-Xavier Girod | fxgirod |
# | Gagik Gavalian | gavalian |
-# | Giovanni Angelini | gangel85 |
-# | Guillaume Christiaens | Guillaum-C |
-# | Joseph Newton | josnewton |
-# | L Smith | forcar |
-# | Latif Kabir | latifkabir |
# | Marco Contalbrigo | mcontalb |
# | Mathieu Ouillon | mathieuouillon |
-# | Maurik Holtrop | mholtrop |
-# | Maxime Defurne | mdefurne |
-# | Michael Hoffer | miho |
+# | Michael Paolone | mpaolone |
+# | Mohammad Hattawy | Hattawy |
# | Nathan Baltzell | baltzell |
-# | Nathan Harrison | naharrison |
-# | Nick Markov | markovnick |
-# | Noemie Pilleux-LOCAL | N-Plx |
+# | Noemie Pilleux | N-Plx |
# | Pierre Chatagnon | PChatagnon |
# | Rafayel Paremuzyan | rafopar |
# | Raffaella De Vita | raffaelladevita |
+# | Silvia Niccolai | silvianic |
# | Sylvester Joosten | sly2j |
# | Tongtong Cao | tongtongcao |
-# | Vardan Gyurjyan | gurjyan |
# | Veronique Ziegler | zieglerv |
# | Whitney Armstrong | whit2333 |
-# | ajhobart | ajhobart |
-# | colesmith | forcar |
-# | cqplatt | cqplatt |
-# | dcpayette | dcpayette |
-# | efuchey | efuchey |
-# | hattawy | Hattawy |
-# | huckb | huckb |
-# | jwgibbs | jwgibbs |
-# | mariangela-bondi | mariangela-bondi |
-# | marmstr4 | marmstr4 |
-# | mcontalb | mcontalb |
-# | mpaolone | mpaolone |
-# | rtysonCLAS12 | rtysonCLAS12 |
-# | tongtongcao | tongtongcao |
-# | veronique | zieglerv |
##################################################################################
# primary (default) maintainers
@@ -69,56 +39,54 @@ external-dependencies/ @baltzell @raffaelladevita @c-dilks
libexec/ @baltzell @raffaelladevita @c-dilks
# common-tools
-common-tools/clara-io/ @baltzell @raffaelladevita
-common-tools/clas-analysis/ @raffaelladevita @baltzell @naharrison @zieglerv @marmstr4
-common-tools/clas-decay-tools/ @baltzell @raffaelladevita @zieglerv
-common-tools/clas-detector/ @baltzell @raffaelladevita @zieglerv
-common-tools/clas-geometry/ @baltzell @raffaelladevita @zieglerv @mathieuouillon
-common-tools/clas-io/ @raffaelladevita @baltzell @gavalian @naharrison @zieglerv @forcar @drewkenjo @huckb
-common-tools/clas-jcsg/ @drewkenjo @naharrison @raffaelladevita @baltzell @zieglerv @gangel85 @mcontalb @cqplatt @mariangela-bondi @gavalian @cpecar
-common-tools/clas-logging/ @baltzell @raffaelladevita
-common-tools/clas-math/ @raffaelladevita @baltzell @zieglerv @tongtongcao
-common-tools/clas-physics/ @raffaelladevita @baltzell @naharrison @zieglerv @drewkenjo @gavalian @fxgirod
-common-tools/clas-reco/ @raffaelladevita @baltzell @naharrison @zieglerv @josnewton @mcontalb @gavalian @afilippi67 @N-Plx @drewkenjo @rafopar @gurjyan @dcpayette @hauenst
-common-tools/clas-tracking/ @zieglerv @baltzell @raffaelladevita @tongtongcao
-common-tools/clas-utils/ @raffaelladevita @baltzell @naharrison @zieglerv @gavalian
-common-tools/swim-tools/ @raffaelladevita @baltzell @zieglerv @heddle @tongtongcao @gurjyan
+common-tools/clara-io/ @baltzell
+common-tools/clas-analysis/ @raffaelladevita @baltzell @zieglerv
+common-tools/clas-decay-tools/ @zieglerv
+common-tools/clas-detector/ @baltzell @raffaelladevita
+common-tools/clas-geometry/ @baltzell @raffaelladevita @zieglerv
+common-tools/clas-io/ @raffaelladevita @baltzell @gavalian @drewkenjo
+common-tools/clas-jcsg/ @drewkenjo @raffaelladevita @baltzell
+common-tools/clas-logging/ @baltzell
+common-tools/clas-math/ @zieglerv
+common-tools/clas-physics/ @raffaelladevita @baltzell @zieglerv @gavalian
+common-tools/clas-reco/ @raffaelladevita @baltzell
+common-tools/clas-tracking/ @zieglerv @raffaelladevita @tongtongcao
+common-tools/clas-utils/ @raffaelladevita @baltzell @zieglerv @gavalian
+common-tools/swim-tools/ @zieglerv @heddle @tongtongcao
# coat-libs
common-tools/coat-libs/ @raffaelladevita @baltzell @c-dilks
# common-tools / cnuphys
-common-tools/cnuphys/ @heddle @naharrison @raffaelladevita @baltzell @zieglerv @tongtongcao
+common-tools/cnuphys/ @heddle
# reconstruction
-reconstruction/alert/ @baltzell @raffaelladevita @mathieuouillon @mpaolone @efuchey @whit2333 @ftouchte
-reconstruction/band/ @raffaelladevita @baltzell @zieglerv @hauenst
+reconstruction/alert/ @baltzell @mathieuouillon @mpaolone @efuchey @whit2333 @ftouchte @N-Plx
+reconstruction/band/ @hauenst
reconstruction/bg/ @baltzell @raffaelladevita
-reconstruction/cnd/ @raffaelladevita @baltzell @naharrison @zieglerv @PChatagnon @ajhobart @silvianic
-reconstruction/cvt/ @zieglerv @raffaelladevita @baltzell @naharrison @drewkenjo @fbossu @N-Plx @Guillaum-C
-reconstruction/dc/ @naharrison @raffaelladevita @baltzell @zieglerv @drewkenjo @tongtongcao @gurjyan @mcontalb @hauenst @latifkabir @gavalian @bleaktwig @N-Plx @marmstr4
-reconstruction/eb/ @baltzell @naharrison @raffaelladevita @sly2j @zieglerv @josnewton
-reconstruction/ec/ @naharrison @raffaelladevita @baltzell @zieglerv @forcar @gavalian @rafopar
-reconstruction/ec/src/ @forcar @naharrison @raffaelladevita @baltzell @gavalian @rafopar
-reconstruction/fmt/ @baltzell @raffaelladevita
-reconstruction/ft/ @naharrison @raffaelladevita @baltzell @zieglerv @afilippi67
-reconstruction/htcc/ @raffaelladevita @baltzell @naharrison @zieglerv @markovnick
-reconstruction/ltcc/ @naharrison @raffaelladevita @baltzell @zieglerv @sly2j
-reconstruction/mc/ @baltzell @raffaelladevita @rafopar @zieglerv
-reconstruction/mltn/ @baltzell @raffaelladevita @gavalian
+reconstruction/cnd/ @PChatagnon @ajhobart @silvianic
+reconstruction/cvt/ @zieglerv @raffaelladevita
+reconstruction/dc/ @zieglerv @tongtongcao @hauenst
+reconstruction/eb/ @baltzell @raffaelladevita
+reconstruction/ec/ @forcar @gavalian
+reconstruction/fmt/ @zieglerv @raffaelladevita
+reconstruction/ft/ @raffaelladevita
+reconstruction/htcc/ @raffaelladevita @baltzell @zieglerv
+reconstruction/ltcc/ @raffaelladevita @baltzell @zieglerv @sly2j
+reconstruction/mc/ @baltzell @rafopar
+reconstruction/mltn/ @gavalian
reconstruction/postproc/ @baltzell
-reconstruction/raster/ @baltzell @raffaelladevita @N-Plx
-reconstruction/rich/ @drewkenjo @raffaelladevita @baltzell @naharrison @zieglerv @mcontalb
-reconstruction/rtpc/ @dcpayette @raffaelladevita @baltzell @mathieuouillon @zieglerv @Hattawy @dpayette
+reconstruction/raster/ @raffaelladevita @N-Plx
+reconstruction/rich/ @drewkenjo @mcontalb
+reconstruction/rtpc/ @mathieuouillon @Hattawy
reconstruction/swaps/ @baltzell @raffaelladevita
-reconstruction/tof/ @naharrison @zieglerv @raffaelladevita @baltzell @drewkenjo @gavalian
-reconstruction/urwell/ @baltzell @raffaelladevita @tongtongcao
-reconstruction/vtx/ @baltzell @raffaelladevita @zieglerv
+reconstruction/tof/ @zieglerv @raffaelladevita
+reconstruction/urwell/ @raffaelladevita @tongtongcao
+reconstruction/vtx/ @zieglerv
# etc
etc/bankdefs/ @baltzell @raffaelladevita @c-dilks
-etc/benchmarks/ @naharrison
-etc/data/ @drewkenjo @baltzell
+etc/data/ @baltzell
etc/ejml/ @raffaelladevita @gavalian
etc/logging/ @baltzell
etc/nnet/ @gavalian
diff --git a/common-tools/clara-io/pom.xml b/common-tools/clara-io/pom.xml
index 4774770499..645974e344 100644
--- a/common-tools/clara-io/pom.xml
+++ b/common-tools/clara-io/pom.xml
@@ -4,13 +4,13 @@
org.jlab.clas
clara-io
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
jar
org.jlab.clas
common-tools
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
@@ -44,25 +44,25 @@
org.jlab.clas
clas-io
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-detector
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-analysis
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-utils
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
diff --git a/common-tools/clas-analysis/pom.xml b/common-tools/clas-analysis/pom.xml
index b654fe090b..073b24d8b5 100644
--- a/common-tools/clas-analysis/pom.xml
+++ b/common-tools/clas-analysis/pom.xml
@@ -4,13 +4,13 @@
org.jlab.clas
clas-analysis
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
jar
org.jlab.clas
common-tools
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
@@ -38,55 +38,55 @@
org.jlab.clas
clas-utils
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-physics
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-io
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-geometry
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-jcsg
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-detector
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-reco
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-logging
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
swim-tools
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
diff --git a/common-tools/clas-decay-tools/pom.xml b/common-tools/clas-decay-tools/pom.xml
index 9538b4ccde..75581d0ae6 100644
--- a/common-tools/clas-decay-tools/pom.xml
+++ b/common-tools/clas-decay-tools/pom.xml
@@ -4,13 +4,13 @@
org.jlab.clas
clas-decay-tools
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
jar
org.jlab.clas
common-tools
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
@@ -21,59 +21,59 @@
org.jlab.clas
swim-tools
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
jar
cnuphys
swimmer
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
cnuphys
magfield
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas12.detector
clas12detector-vtx
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
jar
org.jlab.clas
clas-reco
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-logging
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-utils
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-detector
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-io
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-physics
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-geometry
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
diff --git a/common-tools/clas-detector/pom.xml b/common-tools/clas-detector/pom.xml
index 144f633617..c1af360145 100644
--- a/common-tools/clas-detector/pom.xml
+++ b/common-tools/clas-detector/pom.xml
@@ -4,20 +4,20 @@
org.jlab.clas
clas-detector
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
jar
org.jlab.clas
common-tools
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-utils
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
@@ -43,19 +43,19 @@
org.jlab.clas
clas-io
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-geometry
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-logging
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/examples/DaqPulsePlotter.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/examples/DaqPulsePlotter.java
index 82bf909454..95ab32cda5 100644
--- a/common-tools/clas-detector/src/main/java/org/jlab/detector/examples/DaqPulsePlotter.java
+++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/examples/DaqPulsePlotter.java
@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.detector.examples;
import java.awt.BorderLayout;
@@ -15,17 +10,13 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
import javax.swing.JFrame;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import org.jlab.detector.base.DetectorCollection;
import org.jlab.detector.base.DetectorType;
import org.jlab.detector.decode.CodaEventDecoder;
import org.jlab.detector.decode.DetectorDataDgtz;
-import org.jlab.detector.decode.DetectorDecoderView;
import org.jlab.detector.decode.DetectorEventDecoder;
import org.jlab.detector.view.DetectorListener;
import org.jlab.detector.view.DetectorPane2D;
@@ -33,8 +24,6 @@
import org.jlab.detector.view.DetectorView2D;
import org.jlab.groot.data.H1F;
import org.jlab.groot.data.IDataSet;
-import org.jlab.groot.graphics.EmbeddedCanvas;
-import org.jlab.groot.graphics.EmbeddedCanvasTabbed;
import org.jlab.io.base.DataEvent;
import org.jlab.io.evio.EvioDataEvent;
import org.jlab.io.task.DataSourceProcessorPane;
@@ -45,61 +34,30 @@
* @author gavalian
*/
public class DaqPulsePlotter implements IDataEventListener,DetectorListener,ActionListener {
- Map > detectorMap =
- new HashMap >();
- JPanel pane = null;
-
+ Map > detectorMap = new HashMap< >();
+ JPanel pane = null;
CodaEventDecoder decoder = new CodaEventDecoder();
DetectorEventDecoder detectorDecoder = new DetectorEventDecoder();
- DataSourceProcessorPane processorPane = null;
-
- //EmbeddedCanvasTabbed canvasTab = new EmbeddedCanvasTabbed(true);
- //EmbeddedCanvasGroup canvasTab = new EmbeddedCanvasGroup();
-
- JComboBox comboDetector = null;
- JComboBox comboSector = null;
- JComboBox comboLayer = null;
- JComboBox comboBunch = null;
-
+ DataSourceProcessorPane processorPane = null;
+
public String[] detectorNames = new String[]{"EC","FTOF","CTOF", "HTCC","LTCC"};
public String[] detectorSectors = new String[] {"1","2","3","4","5","6"};
public String[] detectorLayers = new String[] {"1","2","3","4","5","6","7","8","9","10"};
public String[] detectorBunch = new String[] {"1","2","3","4","5","6","7","8","9","10"};
- int nDetectorsPerBunch = 12;
-
-
- DetectorPane2D detectorView = null;
- DetectorDecoderView detectorDecoderView = null;
+ DetectorPane2D detectorView = null;
public DaqPulsePlotter(){
pane = new JPanel();
pane.setLayout(new BorderLayout());
- //canvasTab.addCanvas("DAQ");
processorPane = new DataSourceProcessorPane();
processorPane.setDelay(2);
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout());
- comboDetector = new JComboBox(this.detectorNames);
- comboSector = new JComboBox(this.detectorSectors);
- comboLayer = new JComboBox(this.detectorLayers);
- comboBunch = new JComboBox(this.detectorBunch);
-
-
- //buttonPane.add(comboDetector);
- //buttonPane.add(comboSector);
- //buttonPane.add(comboLayer);
- //buttonPane.add(new JLabel("Page Number"));
- //buttonPane.add(comboBunch);
-
- //JButton drawButton = new JButton("Draw");
- //drawButton.addActionListener(this);
- //buttonPane.add(drawButton);
-
pane.add(buttonPane,BorderLayout.PAGE_START);
JSplitPane splitPane = new JSplitPane();
@@ -108,15 +66,12 @@ public DaqPulsePlotter(){
detectorView.getView().addDetectorListener(this);
this.updateDetectorView();
splitPane.setLeftComponent(detectorView);
- // splitPane.setRightComponent(canvasTab);
pane.add(splitPane,BorderLayout.CENTER);
- //pane.add(canvasTab,BorderLayout.CENTER);
pane.add(processorPane,BorderLayout.PAGE_END);
this.processorPane.addEventListener(this);
}
-
-
+
public void updateDetectorView(){
for(int sector = 1 ; sector < 7; sector++){
@@ -224,24 +179,16 @@ public void drawSectorLayer(DetectorType type, int sector, int layer){
System.out.println(" plotting type = " + type);
DetectorCollection collection = this.detectorMap.get(type.getDetectorId());
Set components = collection.getComponents(sector, layer);
- //EmbeddedCanvas c = this.canvasTab.getCanvas();
- //c.clear();
- //c.divide(3, 4);
int counter = 0;
- int counterCanvas = 0;
System.out.println("COLLECTION HAS " + collection.getList().size()
+ " COMPONENTS = " + components.size());
- int bunch = Integer.parseInt(this.comboBunch.getSelectedItem().toString());
- List datasetList = new ArrayList();
+ List datasetList = new ArrayList<>();
for(Integer key : components){
- //c.cd(counterCanvas);
H1F h = collection.get(sector,layer,key);
datasetList.add(h);
- //c.draw(h);
}
counter++;
- //this.canvasTab.setData(datasetList);
}
}
diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/examples/DataContainers.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/examples/DataContainers.java
deleted file mode 100644
index e79d036eb3..0000000000
--- a/common-tools/clas-detector/src/main/java/org/jlab/detector/examples/DataContainers.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.detector.examples;
-
-import org.jlab.groot.data.H2F;
-import org.jlab.utils.groups.IndexedList;
-
-/**
- *
- * @author gavalian
- */
-public class DataContainers {
- public static void main(String[] args){
- IndexedList h2TOF = new IndexedList(3);
-
- for(int sector = 1; sector < 6; sector++){
- for(int paddle = 1; paddle < 23; paddle++){
- h2TOF.add(new H2F(), sector,1,paddle);
- }
- }
-
-
- boolean flag = h2TOF.hasItem(2,1,13);
- H2F h2P = h2TOF.getItem(2,1,13);
- }
-}
diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java
index 9a3707cafd..75058451a6 100644
--- a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java
+++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java
@@ -42,6 +42,8 @@ public class ModeAHDC extends HipoExtractor {
private final int flateness = 200;
//ADC offset to be considered as the default baseline
private final float defaultBaseline = 300;
+ // dream clock for fine timestamp correction
+ private final float dream_clock = 8.0f;
//Waveform and corresponding pulse
//This is the CURRENT pulse, it is initialized
@@ -318,6 +320,22 @@ public int computeTimeUsingConstantFractionDiscriminator(){
return 0;
}
+
+ /**
+ * Apply fine timestamp correction
+ *
+ * adapted from decode/MVTFitter.java
+ *
+ * @param timestamp for fine time correction
+ * @param fineTimeStampResolution correspond to the dream clock (usually equals to 8; but to be checked!)
+ */
+
+ private void fineTimeStampCorrection(long timestamp, float fineTimeStampResolution) {
+ long fineTimeStamp = timestamp & 0x00000007; // keep and convert last 3 bits of binary timestamp
+ this.pulse.leadingEdgeTime += (double) ((fineTimeStamp+0.5) * fineTimeStampResolution); //fineTimeStampCorrection, only on the leadingEdgeTime for the moment (we don't use timeMax or constantFractionTime in the reconstruction yet)
+ }
+
+
/**
* This method extracts relevant information from the waveform
@@ -355,6 +373,9 @@ public List extract(NamedEntry pars, int id, long timestamp, long time_ZS
//Get the CFD time
this.computeTimeUsingConstantFractionDiscriminator();
+
+ // Fine timestamp correction on leadingEdgeTime
+ this.fineTimeStampCorrection(timestamp, dream_clock);
output.add(this.pulse);
return output;
@@ -399,7 +420,7 @@ protected void update(int n, IndexedTable it, Bank wfBank, Bank adcBank) {
adcBank.putFloat("timeOverThreshold", i, pulses.get(i).timeOverThreshold);
adcBank.putFloat("constantFractionTime", i, pulses.get(i).constantFractionTime);
adcBank.putInt("integral", i, (int)pulses.get(i).integral);
- adcBank.putFloat("ped", i, (short)pulses.get(i).pedestal);
+ adcBank.putFloat("ped", i, pulses.get(i).pedestal);
adcBank.putShort("wfType", i, pulses.get(i).wftype);
}
}
diff --git a/common-tools/clas-geometry/pom.xml b/common-tools/clas-geometry/pom.xml
index 4efca63ceb..289799fc8c 100644
--- a/common-tools/clas-geometry/pom.xml
+++ b/common-tools/clas-geometry/pom.xml
@@ -4,13 +4,13 @@
org.jlab.clas
clas-geometry
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
jar
org.jlab.clas
common-tools
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
diff --git a/common-tools/clas-io/pom.xml b/common-tools/clas-io/pom.xml
index c954342015..b2406e8019 100644
--- a/common-tools/clas-io/pom.xml
+++ b/common-tools/clas-io/pom.xml
@@ -4,13 +4,13 @@
org.jlab.clas
clas-io
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
jar
org.jlab.clas
common-tools
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
@@ -50,13 +50,13 @@
org.jlab.clas
clas-utils
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
org.jlab.clas
clas-logging
- 13.0.3-SNAPSHOT
+ 13.1.0-SNAPSHOT
compile
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/base/BasicDataBank.java b/common-tools/clas-io/src/main/java/org/jlab/io/base/BasicDataBank.java
index 0c7efe9cab..2e7d961897 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/base/BasicDataBank.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/base/BasicDataBank.java
@@ -1,12 +1,6 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
package org.jlab.io.base;
-import java.util.HashMap;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -19,26 +13,22 @@
* @author gavalian
*/
public class BasicDataBank implements DataBank {
+
/**
* Defining the containers to hold bank data.
*/
- private Boolean isUniLength = true;
- private Map shortContainer = new LinkedHashMap();
- private Map intContainer = new LinkedHashMap();
- private Map floatContainer = new LinkedHashMap();
- private Map doubleContainer = new LinkedHashMap();
- private Map byteContainer = new LinkedHashMap();
- private Map longContainer = new LinkedHashMap();
+ private Map shortContainer = new LinkedHashMap<>();
+ private Map intContainer = new LinkedHashMap<>();
+ private Map floatContainer = new LinkedHashMap<>();
+ private Map doubleContainer = new LinkedHashMap<>();
+ private Map byteContainer = new LinkedHashMap<>();
+ private Map longContainer = new LinkedHashMap<>();
private DataDescriptor bankDescriptor;
public BasicDataBank(DataDescriptor desc){
bankDescriptor = desc;
}
-
- public BasicDataBank(){
- //bankDescriptor = desc;
- }
-
+
private void printWarningColumnExists(String routine,String column_name){
System.err.println("[BasicDataBank::"+ routine + ": " +
this.getDescriptor().getName() +
@@ -60,12 +50,14 @@ private void printOutOfBoundsWarning(String routine, String column_name, int ind
}
+ @Override
public String[] getColumnList() {
return null;
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
+ @Override
public DataDescriptor getDescriptor() {
return bankDescriptor;
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
@@ -76,6 +68,7 @@ public DataDescriptor getDescriptor() {
* @return double array
*/
+ @Override
public double[] getDouble(String path) {
if(doubleContainer.containsKey(path)==true){
return doubleContainer.get(path);
@@ -89,6 +82,7 @@ public double[] getDouble(String path) {
* @param arr array of doubles to add to the container.
*/
+ @Override
public void setDouble(String path, double[] arr) {
if(doubleContainer.containsKey(path)==true){
this.printWarningColumnExists("setDouble", path);
@@ -104,6 +98,7 @@ public void setDouble(String path, double[] arr) {
* @param value new value to set
*/
+ @Override
public void setDouble(String path, int row, double value) {
if(doubleContainer.containsKey(path)==false){
this.printWarningColumnDoesNotExist("setDouble", path);
@@ -123,6 +118,7 @@ public void setDouble(String path, int row, double value) {
* @param arr
*/
+ @Override
public void appendDouble(String path, double[] arr) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@@ -132,6 +128,7 @@ public void appendDouble(String path, double[] arr) {
* @return array of floats
*/
+ @Override
public float[] getFloat(String path) {
if(floatContainer.containsKey(path)==true){
return floatContainer.get(path);
@@ -145,6 +142,7 @@ public float[] getFloat(String path) {
* @param arr
*/
+ @Override
public void setFloat(String path, float[] arr) {
if(floatContainer.containsKey(path)==true){
this.printWarningColumnExists("setDouble", path);
@@ -160,6 +158,7 @@ public void setFloat(String path, float[] arr) {
* @param value
*/
+ @Override
public void setFloat(String path, int row, float value) {
if(floatContainer.containsKey(path)==false){
this.printWarningColumnDoesNotExist("setDouble", path);
@@ -179,11 +178,13 @@ public void setFloat(String path, int row, float value) {
* @param arr
*/
+ @Override
public void appendFloat(String path, float[] arr) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
+ @Override
public int[] getInt(String path) {
if(intContainer.containsKey(path)==true){
return intContainer.get(path);
@@ -192,6 +193,7 @@ public int[] getInt(String path) {
}
+ @Override
public void setInt(String path, int[] arr) {
if(intContainer.containsKey(path)==true){
this.printWarningColumnExists("setInt", path);
@@ -201,6 +203,7 @@ public void setInt(String path, int[] arr) {
}
+ @Override
public void setInt(String path, int row, int value) {
if(intContainer.containsKey(path)==false){
this.printWarningColumnDoesNotExist("setInt", path);
@@ -220,11 +223,13 @@ public void setInt(String path, int row, int value) {
* @param arr
*/
+ @Override
public void appendInt(String path, int[] arr) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
+ @Override
public short[] getShort(String path) {
if(shortContainer.containsKey(path)==true){
return shortContainer.get(path);
@@ -233,6 +238,7 @@ public short[] getShort(String path) {
}
+ @Override
public void setShort(String path, short[] arr) {
if(shortContainer.containsKey(path)==true){
this.printWarningColumnExists("setShort", path);
@@ -242,6 +248,7 @@ public void setShort(String path, short[] arr) {
}
+ @Override
public void setShort(String path, int row, short value) {
if(shortContainer.containsKey(path)==false){
this.printWarningColumnDoesNotExist("setShort", path);
@@ -257,11 +264,13 @@ public void setShort(String path, int row, short value) {
}
+ @Override
public void appendShort(String path, short[] arr) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
+ @Override
public byte[] getByte(String path) {
if(byteContainer.containsKey(path)==true){
return byteContainer.get(path);
@@ -270,6 +279,7 @@ public byte[] getByte(String path) {
}
+ @Override
public void setByte(String path, byte[] arr) {
if(byteContainer.containsKey(path)==true){
this.printWarningColumnExists("setByte", path);
@@ -279,6 +289,7 @@ public void setByte(String path, byte[] arr) {
}
+ @Override
public void setByte(String path, int row, byte value) {
if(byteContainer.containsKey(path)==false){
this.printWarningColumnDoesNotExist("setByte", path);
@@ -294,11 +305,13 @@ public void setByte(String path, int row, byte value) {
}
+ @Override
public void appendByte(String path, byte[] arr) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
+ @Override
public long[] getLong(String path) {
if(longContainer.containsKey(path)==true){
return longContainer.get(path);
@@ -306,6 +319,7 @@ public long[] getLong(String path) {
return new long[0];
}
+ @Override
public void setLong(String path, long[] arr) {
if(longContainer.containsKey(path)==true){
this.printWarningColumnExists("setLong", path);
@@ -314,6 +328,7 @@ public void setLong(String path, long[] arr) {
}
}
+ @Override
public void setLong(String path, int row, long value) {
if(longContainer.containsKey(path)==false){
this.printWarningColumnDoesNotExist("setLong", path);
@@ -328,10 +343,12 @@ public void setLong(String path, int row, long value) {
}
}
+ @Override
public void appendLong(String path, long[] arr) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
+ @Override
public int columns() {
int ic = 0;
ic += shortContainer.size();
@@ -342,8 +359,8 @@ public int columns() {
ic += longContainer.size();
return ic;
}
-
+ @Override
public int rows() {
int nrows = 0;
for(Map.Entry item : floatContainer.entrySet()){
@@ -363,8 +380,8 @@ public int rows() {
}
return nrows;
}
-
+ @Override
public void show() {
int size = this.columns();
String bankname = "undefined";
@@ -422,7 +439,7 @@ public void show() {
}
}
-
+ @Override
public void reset() {
shortContainer.clear();
byteContainer.clear();
@@ -431,13 +448,13 @@ public void reset() {
doubleContainer.clear();
longContainer.clear();
}
-
+ @Override
public void allocate(int rows) {
System.err.println("[BasicDataBank]---> allocate is not implemented..");
}
-
+ @Override
public double getDouble(String path, int index) {
if(doubleContainer.containsKey(path)==true){
if(doubleContainer.get(path).length<=index){
@@ -452,8 +469,8 @@ public double getDouble(String path, int index) {
}
return 0.0;
}
-
+ @Override
public float getFloat(String path, int index) {
if(floatContainer.containsKey(path)==true){
if(floatContainer.get(path).length<=index){
@@ -469,7 +486,7 @@ public float getFloat(String path, int index) {
return (float) 0.0;
}
-
+ @Override
public int getInt(String path, int index) {
if(intContainer.containsKey(path)==true){
if(intContainer.get(path).length<=index){
@@ -484,8 +501,8 @@ public int getInt(String path, int index) {
}
return 0;
}
-
+ @Override
public long getLong(String path, int index) {
if(longContainer.containsKey(path)==true){
if(longContainer.get(path).length<=index){
@@ -501,6 +518,7 @@ public long getLong(String path, int index) {
return 0;
}
+ @Override
public short getShort(String path, int index) {
if(shortContainer.containsKey(path)==true){
if(shortContainer.get(path).length<=index){
@@ -515,8 +533,8 @@ public short getShort(String path, int index) {
}
return 0;
}
-
+ @Override
public byte getByte(String path, int index) {
if(byteContainer.containsKey(path)==true){
if(byteContainer.get(path).length<=index){
@@ -532,13 +550,12 @@ public byte getByte(String path, int index) {
return 0;
}
+ @Override
public TableModel getTableModel(String mask) {
String[] tokens = mask.split(":");
- Set entryMask = new HashSet();
- for(String item : tokens){
- entryMask.add(item);
- }
+ Set entryMask = new HashSet<>();
+ entryMask.addAll(Arrays.asList(tokens));
String[] columns = this.bankDescriptor.getEntryList();
int nrows = this.rows();
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/base/BasicDataDescriptor.java b/common-tools/clas-io/src/main/java/org/jlab/io/base/BasicDataDescriptor.java
deleted file mode 100644
index 07f47d1cef..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/base/BasicDataDescriptor.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package org.jlab.io.base;
-
-import java.util.HashMap;
-
-/**
- *
- * @author gavalian
- */
-public class BasicDataDescriptor implements DataDescriptor {
- private HashMap descProperties = new HashMap();
- private String descName = "UNDEF";
- private String jsonObjectString = "";
-
- public BasicDataDescriptor(String name) {
- descName = name;
- }
-
- public void init(String s) {
- // JSonObject model = new Json.createObjectBuilder();
- }
-
- public String[] getEntryList() {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public String getName() {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public String getXML() {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public int getProperty(String property_name, String entry_name) {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public int getProperty(String property_name) {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public void setPropertyString(String name, String value) {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public String getPropertyString(String property_name) {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public void show() {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public boolean hasEntry(String entry) {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public boolean hasEntries(String... entries) {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/base/DataDescriptor.java b/common-tools/clas-io/src/main/java/org/jlab/io/base/DataDescriptor.java
index 9ac975cc91..1bddf813e9 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/base/DataDescriptor.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/base/DataDescriptor.java
@@ -5,15 +5,15 @@
* It consists of a list of Entries by name and integer ID.
*/
public interface DataDescriptor {
- void init(String s);
- String[] getEntryList();
- String getName();
- String getXML();
- boolean hasEntry(String entry);
- boolean hasEntries(String... entries);
- int getProperty(String property_name, String entry_name);
- int getProperty(String property_name);
- void setPropertyString(String name, String value);
- String getPropertyString(String property_name);
- void show();
+ void init(String s);
+ String[] getEntryList();
+ String getName();
+ String getXML();
+ boolean hasEntry(String entry);
+ boolean hasEntries(String... entries);
+ int getProperty(String property_name, String entry_name);
+ int getProperty(String property_name);
+ void setPropertyString(String name, String value);
+ String getPropertyString(String property_name);
+ void show();
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/base/DataDictionary.java b/common-tools/clas-io/src/main/java/org/jlab/io/base/DataDictionary.java
index 2716e82b8a..2fb2206681 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/base/DataDictionary.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/base/DataDictionary.java
@@ -1,9 +1,9 @@
package org.jlab.io.base;
public interface DataDictionary {
- void init(String format);
- String getXML();
- String[] getDescriptorList();
- DataDescriptor getDescriptor(String desc_name);
- DataBank createBank(String name, int rows);
+ void init(String format);
+ String getXML();
+ String[] getDescriptorList();
+ DataDescriptor getDescriptor(String desc_name);
+ DataBank createBank(String name, int rows);
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/base/DataEntryType.java b/common-tools/clas-io/src/main/java/org/jlab/io/base/DataEntryType.java
index 79545a4bbc..dac66ea0cb 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/base/DataEntryType.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/base/DataEntryType.java
@@ -1,9 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
package org.jlab.io.base;
/**
@@ -19,9 +13,6 @@ public enum DataEntryType {
LONG (4,8,"int64"),
FLOAT (5,4,"float32"),
DOUBLE (6,8,"float64");
- //CHAR8 (7,1,"CHAR8"),
- //INT32 (8,4,"INT32");
-
private final int typeId;
private final int typeSize;
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/base/DataEventStore.java b/common-tools/clas-io/src/main/java/org/jlab/io/base/DataEventStore.java
deleted file mode 100644
index 05e72ddcab..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/base/DataEventStore.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.base;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- *
- * @author gavalian
- */
-public class DataEventStore {
- private TreeMap store = new TreeMap();
-
-
-
- public DataEventStore(){
-
- }
-
- public DataEventStore(DataEvent event){
- this.init(event);
- }
-
- public final void init(DataEvent event){
- String[] banks = event.getBankList();
- store.clear();
- for(String bank : banks){
- DataBank db = event.getBank(bank);
- if(db!=null){
- store.put(bank, db);
- } else {
- System.err.println("[DataEventStore::init] ----> error : reading bank "
- + " [" + bank + "] failed....");
- }
- }
- }
-
- public DataBank getBank(String name){
- return this.store.get(name);
- }
-
- public boolean hasBank(String name){
- return this.store.containsKey(name);
- }
-
- public void show(){
- for(Map.Entry bank : this.store.entrySet()){
- System.out.println(String.format("| %-24s | %6d | %6d |", bank.getKey(),
- bank.getValue().rows(),bank.getValue().rows()));
- }
- }
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/base/DataEventType.java b/common-tools/clas-io/src/main/java/org/jlab/io/base/DataEventType.java
index d08de5afdb..f23ae0619e 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/base/DataEventType.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/base/DataEventType.java
@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.io.base;
/**
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/base/DataFactory.java b/common-tools/clas-io/src/main/java/org/jlab/io/base/DataFactory.java
deleted file mode 100644
index d966d6368a..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/base/DataFactory.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.jlab.io.base;
-
-import java.io.File;
-
-public class DataFactory {
- public DataSource createDataSource(File file) {
- return null;
-
- }
-
- public DataSource createEvioDataSource(File file) {
- return null;
-
- }
- /*
- public DataSource createEvioDataSource(JioSerial ioserial) {
- return null;
-
- }
-
- public DataDictionary createEvioDictionary(String dirpath) {
-
- }*/
-
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/base/DataSourceType.java b/common-tools/clas-io/src/main/java/org/jlab/io/base/DataSourceType.java
index c823a52761..03e3259a9c 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/base/DataSourceType.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/base/DataSourceType.java
@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.io.base;
/**
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/base/DataSync.java b/common-tools/clas-io/src/main/java/org/jlab/io/base/DataSync.java
index 98b5044322..8f4c688b0b 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/base/DataSync.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/base/DataSync.java
@@ -1,9 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
package org.jlab.io.base;
/**
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataBank.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataBank.java
index b2fd9e1a04..5aab89d33e 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataBank.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataBank.java
@@ -1,11 +1,9 @@
package org.jlab.io.evio;
-
import org.jlab.io.base.BasicDataBank;
import org.jlab.io.base.DataDescriptor;
import org.jlab.io.base.DataEntryType;
-
public class EvioDataBank extends BasicDataBank {
public EvioDataBank(DataDescriptor desc){
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataBucket.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataBucket.java
deleted file mode 100644
index 220d97a597..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataBucket.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package org.jlab.io.evio;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.zip.GZIPOutputStream;
-import org.jlab.coda.jevio.DataType;
-import org.jlab.coda.jevio.EventBuilder;
-import org.jlab.coda.jevio.EventWriter;
-import org.jlab.coda.jevio.EvioEvent;
-import org.jlab.coda.jevio.EvioException;
-import org.jlab.coda.jevio.EvioReader;
-
-/**
- *
- * @author gavalian
- */
-public class EvioDataBucket {
-
- private EventWriter writer = null;
- private EvioReader reader = null;
-
- private ByteBuffer eventBuffer = null;
- private int MAX_BUFFER_SIZE = 10*1024*1024;
-
- public EvioDataBucket(){
-
- }
-
- public EvioDataBucket(byte[] array, ByteOrder order){
-
- this.eventBuffer = ByteBuffer.wrap(array);
- this.eventBuffer.order(order);
-
- try {
-
- reader = new EvioReader(this.eventBuffer);
-
- System.out.println("number of events = " + reader.getEventCount()
- + " buffer length = " + array.length);
- int counter = 0;
-
- EvioEvent event = reader.parseNextEvent();
- if(event==null) System.out.println(" event is null " );
- for(int loop = 0; loop < array.length; loop++){
- System.out.print(String.format(" %6X ", array[loop]));
- if(loop%10==0) System.out.println();
- }
- while(event!=null){
- event = reader.parseNextEvent();
- counter++;
- }
- System.out.println("event count = " + counter);
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataBucket.class.getName()).log(Level.SEVERE, null, ex);
- } catch (IOException ex) {
- Logger.getLogger(EvioDataBucket.class.getName()).log(Level.SEVERE, null, ex);
- }
-
- }
-
- public void openWriter(String filename){
- this.eventBuffer = ByteBuffer.allocate(this.MAX_BUFFER_SIZE);
- this.eventBuffer.order(ByteOrder.LITTLE_ENDIAN);
- try {
- writer = new EventWriter(this.eventBuffer, null);
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataBucket.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
-
- public void writeEvent(EvioEvent ev){
- try {
- this.writer.writeEvent(ev);
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataBucket.class.getName()).log(Level.SEVERE, null, ex);
- } catch (IOException ex) {
- Logger.getLogger(EvioDataBucket.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- public void writeEvent(ByteBuffer buffer){
- try {
- writer.writeEvent(buffer);
- System.out.println("WRITING EVENT BUFFER of LENGTH " + buffer.capacity());
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataBucket.class.getName()).log(Level.SEVERE, null, ex);
- } catch (IOException ex) {
- Logger.getLogger(EvioDataBucket.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
-
- public boolean hasSpace(EvioDataEvent event){
- return (event.getEventBuffer().capacity()+writer.getBytesWrittenToBuffer()>=this.MAX_BUFFER_SIZE);
- }
-
-
- public byte[] getEventArray(){
- long bytesWritten = this.writer.getBytesWrittenToBuffer();
- int alloc = (int) bytesWritten;
- byte[] array = new byte[alloc];
- this.eventBuffer.get(array,0,array.length);
- return array;
- }
-
- public byte[] getEventArrayGzip(){
- return EvioDataBucket.gzip(this.getEventArray());
- }
-
- public static byte[] gzip(byte[] ungzipped) {
- final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
- try {
- final GZIPOutputStream gzipOutputStream = new GZIPOutputStream(bytes);
- gzipOutputStream.write(ungzipped);
- gzipOutputStream.close();
- } catch (IOException e) {
- // LOG.error("Could not gzip " + Arrays.toString(ungzipped));
- System.out.println("[iG5DataCompressor] ERROR: Could not gzip the array....");
- }
- return bytes.toByteArray();
- }
-
- public void writeEvent(EvioDataEvent event){
- this.writeEvent(event.getEventBuffer());
- }
-
- public void show(){
- System.out.println("ALLOCATED SIZE = " + this.eventBuffer.capacity()
- + " LIMIT " + this.eventBuffer.limit() + " BYTES WRITTEN = " +
- writer.getBytesWrittenToBuffer());
- }
-
-
-
- public static void main(String[] args){
- EvioDataBucket bucket = new EvioDataBucket();
- bucket.openWriter("test.evio");
- bucket.show();
- for(int loop = 0; loop < 2; loop++){
- System.out.println("WRITING event # " + loop);
- EventBuilder eb = new EventBuilder(1, DataType.INT32, 1);
- EvioEvent ev = eb.getEvent();
- int[] dat = new int[24];
- try {
- ev.appendIntData(dat);
- bucket.writeEvent(ev);
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataBucket.class.getName()).log(Level.SEVERE, null, ex);
- }
- //EvioDataEvent event = EvioFactory.createEvioEvent();
- //bucket.writeEvent(event.getEventBuffer());
- }
-
- bucket.show();
-
- EvioDataBucket rb = new EvioDataBucket(bucket.getEventArray(), ByteOrder.LITTLE_ENDIAN);
- }
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataChain.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataChain.java
deleted file mode 100644
index db87c1c812..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataChain.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.evio;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.jlab.coda.jevio.EvioCompactReader;
-import org.jlab.coda.jevio.EvioException;
-import org.jlab.io.base.DataEvent;
-import org.jlab.io.base.DataEventList;
-import org.jlab.io.base.DataSource;
-import org.jlab.utils.FileUtils;
-
-/**
- *
- * @author gavalian
- */
-public class EvioDataChain {
-
- private ArrayList fileList = new ArrayList();
- private Integer currentFileNumber = 0;
- private Integer currentFileNumberOfEvents = 0;
- private Integer currentFilePosition = 0;
- private EvioCompactReader reader = null;
- private ByteBuffer eventBuffer = null;
- private Long printoutTimeLast = (long) 0;
- private Boolean printoutEnabled = true;
- private Integer readerCount = 0;
- private double timeIntervalPrintoutSec = 10.0;
-
- public EvioDataChain(){
- printoutTimeLast = System.currentTimeMillis();
- }
-
- public void addDir(String directory){
- this.addDir(directory, "evio");
- }
-
- public void addDir(String directory, String extension){
- ArrayList list = FileUtils.filesInFolder(new File(directory), extension);
- fileList.clear();
- for(String item : list){
- System.out.println("add : " + item);
- fileList.add(item);
- }
- }
-
- public void addFile(String filename){
- fileList.add(filename);
- }
-
- public void open() {
- System.err.println("** OPENNING STREAM WITH FILE # = " + this.fileList.size()
- + " **");
-
- try {
- reader = new EvioCompactReader(fileList.get(0));
- this.currentFileNumberOfEvents = reader.getEventCount();
- this.currentFilePosition = 1;
- this.currentFileNumber = 0;
- this.readerCount = 0;
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataChain.class.getName()).log(Level.SEVERE, null, ex);
- } catch (IOException ex) {
- Logger.getLogger(EvioDataChain.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
-
- public boolean hasEvent(){
- if(this.currentFileNumber==this.fileList.size()-1){
- if(this.currentFilePositionthis.timeIntervalPrintoutSec){
- this.printoutTimeLast = System.currentTimeMillis();
- System.out.println(String.format("evio reader : %8.1f events %12d ",
- elapsedTime,readerCount));
- }
-
- if(this.currentFilePosition entryNames = new ArrayList();
- private Map descriptorEntries = new LinkedHashMap();
- private HashMap descriptorProperties = new HashMap();
+ private ArrayList entryNames = new ArrayList<>();
+ private Map descriptorEntries = new LinkedHashMap<>();
+ private HashMap descriptorProperties = new HashMap<>();
public EvioDataDescriptor(String name, String parenttag, String containertag) {
this.descriptorName = name;
@@ -36,35 +30,23 @@ public EvioDataDescriptor(String format) {
this.init(format);
}
- public void init(String s) {
+ @Override
+ public final void init(String s) {
descriptorEntries.clear();
String[] tokens = s.split("/");
// System.out.println(" N - tokens = " + tokens.length);
String[] header = tokens[0].split(":");
this.descriptorName = header[0] + "::" + header[1];
- String section_name = header[1];
- this.descriptorContainerTag = Integer.parseInt(header[2]);
- this.descriptorContainerNum = Integer.parseInt(header[3]);
+ this.descriptorContainerTag = Integer.valueOf(header[2]);
+ this.descriptorContainerNum = Integer.valueOf(header[3]);
this.descriptorProperties.put("parent_tag", header[2]);
this.descriptorProperties.put("container_tag", header[3]);
- Integer sectionTag = Integer.parseInt(header[3]);
+ Integer sectionTag = Integer.valueOf(header[3]);
for (int loop = 1; loop < tokens.length; loop++) {
String[] entryParams = tokens[loop].split(":");
- this.addEntry(this.descriptorName, entryParams[0], sectionTag, Integer.parseInt(entryParams[1]), entryParams[2]);
+ this.addEntry(this.descriptorName, entryParams[0], sectionTag, Integer.valueOf(entryParams[1]), entryParams[2]);
}
- /*
- * descriptorName = tokens[0];
- *
- * descriptorContainerTag = Integer.parseInt(tokens[1]); descriptorContainerNum = Integer.parseInt(tokens[2]); ArrayList nnn = new
- * ArrayList(); for(int loop = 3 ; loop < tokens.length; loop+=4){ nnn.add(tokens[loop]); descriptorEntries.put(tokens[loop], new
- * EvioDataDescriptorEntry("generic",tokens[loop], Integer.parseInt(tokens[loop+1]), Integer.parseInt(tokens[loop+2]), tokens[loop+3] )); }
- */
- // entryNames = new String[nnn.size()];
- // for(int loop = 0; loop < nnn.size(); loop++){
- // entryNames[loop] = nnn.get(loop);
- // }
- // entryNames = (String[]) nnn.toArray();
}
public void addEntry(String section, String name, Integer tag, Integer num, String type) {
@@ -72,6 +54,7 @@ public void addEntry(String section, String name, Integer tag, Integer num, Stri
entryNames.add(name);
}
+ @Override
public String[] getEntryList() {
// return entryNames;
String[] entries = new String[descriptorEntries.size()];
@@ -81,10 +64,12 @@ public String[] getEntryList() {
return entries;
}
+ @Override
public String getName() {
return descriptorName;
}
+ @Override
public int getProperty(String property_name, String entry_name) {
int ret = -1;
if (descriptorEntries.containsKey(entry_name) == false) {
@@ -107,6 +92,7 @@ public int getProperty(String property_name, String entry_name) {
return ret;
}
+ @Override
public int getProperty(String property_name) {
if (property_name.equals("tag") == true) {
return descriptorContainerTag;
@@ -117,6 +103,7 @@ public int getProperty(String property_name) {
return 0;
}
+ @Override
public void show() {
System.out.println("\n\n>>> BANK name = " + this.getName() + " tag = " + this.getPropertyString("parent_tag"));
String[] entry_names = this.getEntryList();
@@ -132,12 +119,14 @@ public void show() {
table.show();
}
+ @Override
public String getXML() {
StringBuilder str = new StringBuilder();
return str.toString();
}
+ @Override
public void setPropertyString(String name, String value) {
if (descriptorProperties.containsKey(name) == true) {
descriptorProperties.remove(name);
@@ -145,6 +134,7 @@ public void setPropertyString(String name, String value) {
descriptorProperties.put(name, value);
}
+ @Override
public String getPropertyString(String property_name) {
if (descriptorProperties.containsKey(property_name) == true) {
return descriptorProperties.get(property_name);
@@ -160,8 +150,6 @@ public String toString() {
str.append(this.descriptorProperties.get("parent_tag"));
str.append(":");
str.append(this.descriptorProperties.get("container_tag"));
-
- // for(Map.Entry entry : this.descriptorEntries.entrySet()){
for (String item : this.getEntryList()) {
str.append("/");
str.append(this.descriptorEntries.get(item).name);
@@ -173,23 +161,26 @@ public String toString() {
return str.toString();
}
- public static void main(String[] args) {
- EvioDataDescriptor desc = new EvioDataDescriptor("DC::true", "120", "0");
- desc.init("DC:true:1200:1201/sector:1:float64/layer:2:int64/wire:3:int64");
- desc.show();
- System.out.println(desc);
- EvioDataDescriptor desc2 = new EvioDataDescriptor(desc.toString());
- desc2.show();
- }
-
+ @Override
public boolean hasEntry(String entry) {
return this.descriptorEntries.containsKey(entry);
}
+ @Override
public boolean hasEntries(String... entries) {
for (String item : entries)
if (this.hasEntry(item) == false)
return false;
return true;
}
+
+ public static void main(String[] args) {
+ EvioDataDescriptor desc = new EvioDataDescriptor("DC::true", "120", "0");
+ desc.init("DC:true:1200:1201/sector:1:float64/layer:2:int64/wire:3:int64");
+ desc.show();
+ System.out.println(desc);
+ EvioDataDescriptor desc2 = new EvioDataDescriptor(desc.toString());
+ desc2.show();
+ }
+
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataDescriptorEntry.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataDescriptorEntry.java
index dfb024d081..d69a764654 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataDescriptorEntry.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataDescriptorEntry.java
@@ -1,9 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
package org.jlab.io.evio;
import org.jlab.io.base.DataEntryType;
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataDictionary.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataDictionary.java
index de03331989..1129c8a18b 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataDictionary.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataDictionary.java
@@ -20,8 +20,8 @@
*/
public class EvioDataDictionary implements DataDictionary {
- Logger LOGGER = Logger.getLogger(EvioDataDictionary.class.getName());
- private HashMap descriptors = new HashMap();
+ static final Logger LOGGER = Logger.getLogger(EvioDataDictionary.class.getName());
+ private HashMap descriptors = new HashMap<>();
public EvioDataDictionary() {
@@ -35,26 +35,28 @@ public EvioDataDictionary(String directory) {
this.initWithDir(directory);
}
+ @Override
public void init(String format) {
}
+ @Override
public String getXML() {
return "some xml";
}
+ @Override
public String[] getDescriptorList() {
String[] names = new String[descriptors.keySet().size()];
- // ArrayList array = new ArrayList();
int icounter = 0;
for (String key : descriptors.keySet()) {
names[icounter] = key;
icounter++;
}
return names;
- // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
+ @Override
public DataDescriptor getDescriptor(String desc_name) {
if (descriptors.containsKey(desc_name) == true) {
return descriptors.get(desc_name);
@@ -81,10 +83,10 @@ public final void initWithEnv(String envname) {
}
public final void initWithDir(String dirname) {
- ArrayList ignorePrefixes = new ArrayList();
+ ArrayList ignorePrefixes = new ArrayList<>();
ignorePrefixes.add(".");
ignorePrefixes.add("_");
- LOGGER.log(Level.INFO,"[EvioDataDictionary]---> loading bankdefs from directory : " + dirname);
+ LOGGER.log(Level.INFO, "[EvioDataDictionary]---> loading bankdefs from directory : {0}", dirname);
File dict_dir = new File(dirname);
if (dict_dir.exists() == false) {
@@ -93,33 +95,24 @@ public final void initWithDir(String dirname) {
}
ArrayList xmlFileList = FileUtils.filesInFolder(dict_dir, "xml", ignorePrefixes);
- LOGGER.log(Level.INFO,"[EvioDataDictionary]------> number of XML files located : " + xmlFileList.size());
+ LOGGER.log(Level.INFO, "[EvioDataDictionary]------> number of XML files located : {0}", xmlFileList.size());
Integer counter = 0;
for (String file : xmlFileList) {
ArrayList descList = DictionaryLoader.getDescriptorsFromFile(file);
- // ArrayList descList = DictionaryLoader.descriptorParseXMLtoString(file);
for (EvioDataDescriptor desc : descList) {
descriptors.put(desc.getName(), desc);
- // System.out.println(" rev = " + counter + " desc = " + desc.getName());
- // ArrayList descList =
- // EvioDataDescriptor desc = new EvioDataDescriptor();
- // desc.init(format);
- // descriptors.put(desc.getName(), desc);
counter++;
}
}
- LOGGER.log(Level.INFO,"[EvioDataDictionary]--> total number of descriptors found : " + counter.toString());
+ LOGGER.log(Level.INFO, "[EvioDataDictionary]--> total number of descriptors found : {0}", counter.toString());
}
public void show() {
TablePrintout table = new TablePrintout("Bank:Columns:Tag:Number", "42:8:8:8");
for (Map.Entry entry : descriptors.entrySet()) {
- // System.out.println(" step 1 ");
String name = entry.getKey();
String[] info = new String[4];
- // System.out.println(" step 2 ");
info[0] = name;
- // System.out.println(" step 3 ");
Integer nentries = descriptors.get(name).getEntryList().length;
info[1] = nentries.toString();
Integer tag = descriptors.get(name).getProperty("tag");
@@ -155,16 +148,17 @@ public String getNameByTagNum(int tag, int num) {
}
}
if (desc.getValue().getProperty("tag", entryname) == tag && desc.getValue().getProperty("num", entryname) == num) {
- return new String(desc.getKey() + "." + entryname);
+ return desc.getKey() + "." + entryname;
}
}
}
return name;
}
+ @Override
public DataBank createBank(String name, int rows) {
if (descriptors.containsKey(name) == false) {
- LOGGER.log(Level.SEVERE,"[EvioDataDictionary]:: ERROR ---> no descriptor with name = " + name + " is found");
+ LOGGER.log(Level.SEVERE, "[EvioDataDictionary]:: ERROR ---> no descriptor with name = {0} is found", name);
}
EvioDataDescriptor desc = descriptors.get(name);
EvioDataBank bank = new EvioDataBank(desc);
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataEvent.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataEvent.java
index e1a5264b2b..7228a3a9e9 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataEvent.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataEvent.java
@@ -3,6 +3,7 @@
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -28,873 +29,724 @@
public class EvioDataEvent implements DataEvent {
- private HashMap eventProperties = new HashMap();
- private ByteBuffer evioBuffer;
- private EvioCompactStructureHandler structure = null;
- private EvioDataEventHandler eventHandler = null;
- private EvioDataDictionary dictionary = null;
- private List eventNodes = null;
- private DataEventType eventType = DataEventType.EVENT_ACCUMULATE;
-
- public EvioDataEvent(byte[] buffer, ByteOrder b_order) {
-
- evioBuffer = ByteBuffer.wrap(buffer);
- evioBuffer.order(b_order);
- eventHandler = new EvioDataEventHandler(evioBuffer);
- /*
- * try { structure = new EvioCompactStructureHandler(evioBuffer,DataType.BANK); eventNodes = structure.getChildNodes(); } catch (EvioException ex) {
- * Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex); }
- */
-
- }
-
- public EvioDataEvent(ByteBuffer buff) {
- evioBuffer = buff;
- eventHandler = new EvioDataEventHandler(evioBuffer);
- /*
- * try { structure = new EvioCompactStructureHandler(evioBuffer,DataType.BANK); eventNodes = structure.getChildNodes(); } catch (EvioException ex) {
- * Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex); }
- */
- }
-
- public EvioDataEvent(ByteBuffer buff, EvioDataDictionary dict) {
- evioBuffer = buff;
- dictionary = dict;
- eventHandler = new EvioDataEventHandler(evioBuffer);
- /*
- * try { structure = new EvioCompactStructureHandler(evioBuffer,DataType.BANK); eventNodes = structure.getChildNodes(); } catch (EvioException ex) {
- * Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex); }
- */
- }
-
- public ByteOrder getByteOrder() {
- return this.eventHandler.getStructure().getByteBuffer().order();
- }
-
- public EvioDataEvent(byte[] buffer, ByteOrder b_order, EvioDataDictionary dict) {
- evioBuffer = ByteBuffer.wrap(buffer);
- evioBuffer.order(b_order);
- this.eventHandler = new EvioDataEventHandler(buffer, b_order);
- /*
- * try { structure = new EvioCompactStructureHandler(evioBuffer,DataType.BANK); eventNodes = structure.getChildNodes(); } catch (EvioException ex) {
- * Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex); }
- */
- dictionary = dict;
- this.setProperty("banks", "*");
- this.setProperty("variables", "*");
- }
-
- public String[] getBankList() {
- try {
- // TODO Auto-generated method stub
- List nodes = this.eventHandler.getStructure().getNodes();
- ArrayList list = new ArrayList();
- String[] descList = dictionary.getDescriptorList();
- for (EvioNode item : nodes) {
- // System.out.println(" TAG-NUM = " + item.getTag() + " " + item.getNum()
- // + " " + item.getDataTypeObj());
- if (item.getDataTypeObj() == DataType.ALSOBANK && item.getNum() == 0) {
- for (String di : descList) {
- if (Integer.parseInt(dictionary.getDescriptor(di).getPropertyString("container_tag")) == item.getTag()) {
- list.add(di);
- }
- // list.add("[" + item.getTag() + ":" + item.getNum() + "]");
- }
- // ((EvioDataBank ) bank).addDoubleBuffer(tag, item.);
- }
- }
- String[] banks = new String[list.size()];
- for (int loop = 0; loop < list.size(); loop++)
- banks[loop] = list.get(loop);
- return banks;
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
- }
- return null;
- }
-
- public EvioCompactStructureHandler getStructureHandler() {
- // this.eventHandler.getStructure();
- return this.eventHandler.getStructure();
- }
-
- public EvioDataEventHandler getHandler() {
- return this.eventHandler;
- }
-
- public void initEvent(ByteBuffer buffer) {
- evioBuffer = buffer;
- }
-
- public String[] getColumnList(String bank_name) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public DataDictionary getDictionary() {
- return this.dictionary;
- }
-
- private int[] getTagNum(String path) {
- String[] split_path = path.split("[.]+");
- String bank = split_path[0];
- String col = split_path[1];
-
- DataDescriptor desc = this.dictionary.getDescriptor(bank);
- int tag = desc.getProperty("tag", col);
- int num = desc.getProperty("num", col);
- int[] ret = { tag, num };
- return ret;
- }
-
- public float[] getFloat(String path) {
- if (path.contains("/") == true) {
- String[] tokens = path.split("/");
- return this.getFloat(Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]));
- } else {
- int[] tagnum = this.getTagNum(path);
- return this.getFloat(tagnum[0], tagnum[1]);
- }
- // int[] tagnum = this.getTagNum(path);
- // return this.getFloat(tagnum[0],tagnum[1]);
- }
-
- public float[] getFloat(int tag, int num) {
- EvioNode node = this.getNodeFromTree(tag, num, DataType.FLOAT32);
- if (node != null) {
- try {
- ByteBuffer buffer = this.eventHandler.getStructure().getData(node);
- float[] nodedata = ByteDataTransformer.toFloatArray(buffer);
- return nodedata;
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- return null;
- }
-
- public void setFloat(String path, float[] arr) {
- // TODO Auto-generated method stub
-
- }
-
- public void appendFloat(String path, float[] arr) {
- // TODO Auto-generated method stub
-
- }
-
- public int[] getInt(String path) {
- if (path.contains("/") == true) {
- String[] tokens = path.split("/");
- return this.getInt(Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]));
- } else {
- int[] tagnum = this.getTagNum(path);
- return this.getInt(tagnum[0], tagnum[1]);
- }
- }
-
- public String[] getString(int tag, int num) {
- EvioNode node = this.getNodeFromTree(tag, num, DataType.CHARSTAR8);
- if (node != null) {
- try {
- ByteBuffer buffer = this.eventHandler.getStructure().getData(node);
- String[] nodedata = ByteDataTransformer.toStringArray(buffer);
- return nodedata;
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- return null;
- }
-
- public int[] getInt(int tag, int num) {
- EvioNode node = this.getNodeFromTree(tag, num, DataType.INT32);
- if (node != null) {
- try {
- ByteBuffer buffer = this.eventHandler.getStructure().getData(node);
- int[] nodedata = ByteDataTransformer.toIntArray(buffer);
- return nodedata;
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- return null;
- }
+ private HashMap eventProperties = new HashMap<>();
+ private ByteBuffer evioBuffer;
+ private EvioDataEventHandler eventHandler = null;
+ private EvioDataDictionary dictionary = null;
+ private DataEventType eventType = DataEventType.EVENT_ACCUMULATE;
+
+ public EvioDataEvent(byte[] buffer, ByteOrder b_order) {
+ evioBuffer = ByteBuffer.wrap(buffer);
+ evioBuffer.order(b_order);
+ eventHandler = new EvioDataEventHandler(evioBuffer);
+ }
+
+ public EvioDataEvent(ByteBuffer buff) {
+ evioBuffer = buff;
+ eventHandler = new EvioDataEventHandler(evioBuffer);
+ }
+
+ public EvioDataEvent(ByteBuffer buff, EvioDataDictionary dict) {
+ evioBuffer = buff;
+ dictionary = dict;
+ eventHandler = new EvioDataEventHandler(evioBuffer);
+ }
+
+ public ByteOrder getByteOrder() {
+ return this.eventHandler.getStructure().getByteBuffer().order();
+ }
+
+ public EvioDataEvent(byte[] buffer, ByteOrder b_order, EvioDataDictionary dict) {
+ evioBuffer = ByteBuffer.wrap(buffer);
+ evioBuffer.order(b_order);
+ this.eventHandler = new EvioDataEventHandler(buffer, b_order);
+ dictionary = dict;
+ this.setProperty("banks", "*");
+ this.setProperty("variables", "*");
+ }
+
+ @Override
+ public String[] getBankList() {
+ try {
+ List nodes = this.eventHandler.getStructure().getNodes();
+ ArrayList list = new ArrayList<>();
+ String[] descList = dictionary.getDescriptorList();
+ for (EvioNode item : nodes) {
+ if (item.getDataTypeObj() == DataType.ALSOBANK && item.getNum() == 0) {
+ for (String di : descList) {
+ if (Integer.parseInt(dictionary.getDescriptor(di).getPropertyString("container_tag")) == item.getTag()) {
+ list.add(di);
+ }
+ }
+ }
+ }
+ String[] banks = new String[list.size()];
+ for (int loop = 0; loop < list.size(); loop++)
+ banks[loop] = list.get(loop);
+ return banks;
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return null;
+ }
+
+ public EvioCompactStructureHandler getStructureHandler() {
+ return this.eventHandler.getStructure();
+ }
+
+ public EvioDataEventHandler getHandler() {
+ return this.eventHandler;
+ }
+
+ public void initEvent(ByteBuffer buffer) {
+ evioBuffer = buffer;
+ }
+
+ @Override
+ public String[] getColumnList(String bank_name) {
+ return null;
+ }
+
+ @Override
+ public DataDictionary getDictionary() {
+ return this.dictionary;
+ }
+
+ private int[] getTagNum(String path) {
+ String[] split_path = path.split("[.]+");
+ String bank = split_path[0];
+ String col = split_path[1];
+
+ DataDescriptor desc = this.dictionary.getDescriptor(bank);
+ int tag = desc.getProperty("tag", col);
+ int num = desc.getProperty("num", col);
+ int[] ret = { tag, num };
+ return ret;
+ }
+
+ @Override
+ public float[] getFloat(String path) {
+ if (path.contains("/") == true) {
+ String[] tokens = path.split("/");
+ return this.getFloat(Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]));
+ } else {
+ int[] tagnum = this.getTagNum(path);
+ return this.getFloat(tagnum[0], tagnum[1]);
+ }
+ }
+
+ public float[] getFloat(int tag, int num) {
+ EvioNode node = this.getNodeFromTree(tag, num, DataType.FLOAT32);
+ if (node != null) {
+ try {
+ ByteBuffer buffer = this.eventHandler.getStructure().getData(node);
+ float[] nodedata = ByteDataTransformer.toFloatArray(buffer);
+ return nodedata;
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void setFloat(String path, float[] arr) {
+ }
+
+ @Override
+ public void appendFloat(String path, float[] arr) {
+ }
+
+ @Override
+ public int[] getInt(String path) {
+ if (path.contains("/") == true) {
+ String[] tokens = path.split("/");
+ return this.getInt(Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]));
+ } else {
+ int[] tagnum = this.getTagNum(path);
+ return this.getInt(tagnum[0], tagnum[1]);
+ }
+ }
+
+ public String[] getString(int tag, int num) {
+ EvioNode node = this.getNodeFromTree(tag, num, DataType.CHARSTAR8);
+ if (node != null) {
+ try {
+ ByteBuffer buffer = this.eventHandler.getStructure().getData(node);
+ String[] nodedata = ByteDataTransformer.toStringArray(buffer);
+ return nodedata;
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ return null;
+ }
+
+ public int[] getInt(int tag, int num) {
+ EvioNode node = this.getNodeFromTree(tag, num, DataType.INT32);
+ if (node != null) {
+ try {
+ ByteBuffer buffer = this.eventHandler.getStructure().getData(node);
+ int[] nodedata = ByteDataTransformer.toIntArray(buffer);
+ return nodedata;
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ return null;
+ }
public long[] getLong(int tag, int num) {
- EvioNode node = this.getNodeFromTree(tag, num, DataType.LONG64);
- if (node != null) {
- try {
- ByteBuffer buffer = this.eventHandler.getStructure().getData(node);
- long[] nodedata = ByteDataTransformer.toLongArray(buffer);
- return nodedata;
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- return null;
- }
+ EvioNode node = this.getNodeFromTree(tag, num, DataType.LONG64);
+ if (node != null) {
+ try {
+ ByteBuffer buffer = this.eventHandler.getStructure().getData(node);
+ long[] nodedata = ByteDataTransformer.toLongArray(buffer);
+ return nodedata;
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ return null;
+ }
- public void setInt(String path, int[] arr) {
- // TODO Auto-generated method stub
-
- }
-
- public void appendInt(String path, int[] arr) {
- // TODO Auto-generated method stub
-
- }
-
- public short[] getShort(String path) {
- int[] tagnum = this.getTagNum(path);
- return this.getShort(tagnum[0], tagnum[1]);
- }
-
- public short[] getShort(int tag, int num) {
- return null;
- }
-
- public void setShort(String path, short[] arr) {
- // TODO Auto-generated method stub
-
- }
-
- public void appendShort(String path, short[] arr) {
- // TODO Auto-generated method stub
-
- }
-
- public byte[] getComposite(int tag, int num) {
- EvioNode node = this.getNodeFromTree(tag, num, DataType.COMPOSITE);
- if (node != null) {
- try {
- ByteBuffer buffer = this.eventHandler.getStructure().getData(node);
- byte[] nodedata = ByteDataTransformer.toByteArray(buffer);
- return nodedata;
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- return null;
- }
-
- public boolean hasBank(int tag, int num) {
- EvioNode node = this.getNodeFromTree(tag, num, DataType.COMPOSITE);
- if (node == null)
- return false;
- return true;
- }
-
- public boolean hasBank(String bank_name) {
-
- if (this.dictionary.getDescriptor(bank_name) == null) {
- System.err.println("[EvioDataEvent::hasBank] ( ERROR ) ---> " + " there is no descriptor with name " + bank_name);
- return false;
- }
- if (this.eventHandler == null) {
- System.out.println("SEVERE ERROR Event handler is NULL");
- return false;
- }
-
- EvioDataDescriptor desc = (EvioDataDescriptor) this.dictionary.getDescriptor(bank_name);
- if (desc == null) {
- return false;
- }
- int parenttag = Integer.parseInt(desc.getPropertyString("parent_tag"));
- int nodetag = Integer.parseInt(desc.getPropertyString("container_tag"));
- // System.out.println("Looking for bank " + bank_name + " TAGS = " +
- // parenttag + " / " + nodetag);
-
- EvioNode parentNode = this.eventHandler.getRootNode(parenttag, 0, DataType.ALSOBANK);
- // System.out.println("Looking for bank " + bank_name + " TAGS = " +
- // parenttag + " / " + nodetag + " " + parentNode);
- // System.out.println("looking for parent tag = " + parenttag);
- if (bank_name.compareTo("GenPart::header") == 0 && parentNode != null)
- return true;
- if (bank_name.compareTo("GenPart::true") == 0 && parentNode != null)
- return true;
- if (bank_name.compareTo("Lund::header") == 0 && parentNode != null)
- return true;
- if (bank_name.compareTo("Lund::true") == 0 && parentNode != null)
- return true;
- if (parentNode == null)
- return false;
- // System.out.println("ROOT NODE IS FOUND");
- EvioNode leafNode = this.eventHandler.getChildNode(parentNode, nodetag, 0, DataType.ALSOBANK);
- if (leafNode == null)
- return false;
- // System.out.println("CHILD NODE IS FOUND");
- // EvioNode banknode = this.getNodeFromTree(nodetag, 0, DataType.ALSOBANK);
- // if(banknode==null) return false;
- return true;
- }
-
- public DataBank getBank(String bank_name) {
- EvioDataDescriptor desc = (EvioDataDescriptor) this.dictionary.getDescriptor(bank_name);
- if (desc == null)
- return null;
-
- int parenttag = Integer.parseInt(desc.getPropertyString("parent_tag"));
- int nodetag = Integer.parseInt(desc.getPropertyString("container_tag"));
-
- EvioNode parentNode = this.eventHandler.getRootNode(parenttag, 0, DataType.ALSOBANK);
- if (parentNode == null)
- return null;
-
- EvioNode leafNode = this.eventHandler.getChildNode(parentNode, nodetag, 0, DataType.ALSOBANK);
- if (leafNode == null && bank_name.compareTo("GenPart::header") != 0 && bank_name.compareTo("GenPart::true") != 0
+ @Override
+ public void setInt(String path, int[] arr) {
+ }
+
+ @Override
+ public void appendInt(String path, int[] arr) {
+ }
+
+ @Override
+ public short[] getShort(String path) {
+ int[] tagnum = this.getTagNum(path);
+ return this.getShort(tagnum[0], tagnum[1]);
+ }
+
+ public short[] getShort(int tag, int num) {
+ return null;
+ }
+
+ @Override
+ public void setShort(String path, short[] arr) {
+ }
+
+ @Override
+ public void appendShort(String path, short[] arr) {
+ }
+
+ public byte[] getComposite(int tag, int num) {
+ EvioNode node = this.getNodeFromTree(tag, num, DataType.COMPOSITE);
+ if (node != null) {
+ try {
+ ByteBuffer buffer = this.eventHandler.getStructure().getData(node);
+ byte[] nodedata = ByteDataTransformer.toByteArray(buffer);
+ return nodedata;
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ return null;
+ }
+
+ public boolean hasBank(int tag, int num) {
+ EvioNode node = this.getNodeFromTree(tag, num, DataType.COMPOSITE);
+ return node != null;
+ }
+
+ @Override
+ public boolean hasBank(String bank_name) {
+
+ if (this.dictionary.getDescriptor(bank_name) == null) {
+ System.err.println("[EvioDataEvent::hasBank] ( ERROR ) ---> " + " there is no descriptor with name " + bank_name);
+ return false;
+ }
+ if (this.eventHandler == null) {
+ System.out.println("SEVERE ERROR Event handler is NULL");
+ return false;
+ }
+
+ EvioDataDescriptor desc = (EvioDataDescriptor) this.dictionary.getDescriptor(bank_name);
+ if (desc == null) {
+ return false;
+ }
+ int parenttag = Integer.parseInt(desc.getPropertyString("parent_tag"));
+ int nodetag = Integer.parseInt(desc.getPropertyString("container_tag"));
+
+ EvioNode parentNode = this.eventHandler.getRootNode(parenttag, 0, DataType.ALSOBANK);
+ if (bank_name.compareTo("GenPart::header") == 0 && parentNode != null)
+ return true;
+ if (bank_name.compareTo("GenPart::true") == 0 && parentNode != null)
+ return true;
+ if (bank_name.compareTo("Lund::header") == 0 && parentNode != null)
+ return true;
+ if (bank_name.compareTo("Lund::true") == 0 && parentNode != null)
+ return true;
+ if (parentNode == null)
+ return false;
+ EvioNode leafNode = this.eventHandler.getChildNode(parentNode, nodetag, 0, DataType.ALSOBANK);
+ return leafNode != null;
+ }
+
+ @Override
+ public DataBank getBank(String bank_name) {
+ EvioDataDescriptor desc = (EvioDataDescriptor) this.dictionary.getDescriptor(bank_name);
+ if (desc == null)
+ return null;
+
+ int parenttag = Integer.parseInt(desc.getPropertyString("parent_tag"));
+ int nodetag = Integer.parseInt(desc.getPropertyString("container_tag"));
+
+ EvioNode parentNode = this.eventHandler.getRootNode(parenttag, 0, DataType.ALSOBANK);
+ if (parentNode == null)
+ return null;
+
+ EvioNode leafNode = this.eventHandler.getChildNode(parentNode, nodetag, 0, DataType.ALSOBANK);
+ if (leafNode == null && bank_name.compareTo("GenPart::header") != 0 && bank_name.compareTo("GenPart::true") != 0
&& bank_name.compareTo("Lund::header") != 0 && bank_name.compareTo("Lund::true") != 0)
- return null;
+ return null;
- TreeMap dataTree = null;
- if (bank_name.compareTo("GenPart::header") == 0) {
- dataTree = this.eventHandler.getNodeData(parentNode);
+ TreeMap dataTree = null;
+ if (bank_name.compareTo("GenPart::header") == 0) {
+ dataTree = this.eventHandler.getNodeData(parentNode);
} else if (bank_name.compareTo("GenPart::true") == 0) {
- dataTree = this.eventHandler.getNodeData(parentNode);
- } else if (bank_name.compareTo("Lund::header") == 0) {
- dataTree = this.eventHandler.getNodeData(parentNode);
- } else if (bank_name.compareTo("Lund::true") == 0) {
- dataTree = this.eventHandler.getNodeData(parentNode);
- } else {
- dataTree = this.eventHandler.getNodeData(leafNode);
- }
-
- EvioDataBank bank = new EvioDataBank(desc);
- String[] entries = desc.getEntryList();
-
-// if(bank_name.compareTo("Lund::particles") == 0 || bank_name.compareTo("GenPart::true") == 0) {
-// System.out.println("beginning " + bank.rows()+" "+bank.columns());
-// bank.show();
-// }
- for (String item : entries) {
- // if(item.getValue()<20){
- int type = desc.getProperty("type", item);
- int num = desc.getProperty("num", item);
-// if(bank_name.compareTo("Lund::particles") == 0 || bank_name.compareTo("GenPart::true") == 0) {
-// System.out.println("entry = " + item);
-// System.out.println(type + " " + num);
-// }
-
- if (DataEntryType.getType(type) == DataEntryType.INTEGER) {
- bank.setInt(item, (int[]) dataTree.get(num));
- }
-
- if (DataEntryType.getType(type) == DataEntryType.DOUBLE) {
- bank.setDouble(item, (double[]) dataTree.get(num));
- }
-
- if (DataEntryType.getType(type) == DataEntryType.FLOAT) {
- bank.setFloat(item, (float[]) dataTree.get(num));
- // System.out.println("ADDING FLOAT VALUE : " + bank_name + " " + item);
- }
- if (DataEntryType.getType(type) == DataEntryType.SHORT) {
- bank.setShort(item, (short[]) dataTree.get(num));
- }
-
- if (DataEntryType.getType(type) == DataEntryType.BYTE) {
- bank.setByte(item, (byte[]) dataTree.get(num));
- // System.out.println("ADDING BYTE VALUE : " + bank_name + " " + item);
- }
- // } else {
-
- // }
- // System.out.println(item.getKey() + " " + item.getValue()
- // + " " + desc.types.get(item.getKey()));
-// if(bank_name.compareTo("Lund::particles") == 0 || bank_name.compareTo("GenPart::true") == 0) {
-// System.out.println(bank.rows()+" "+bank.columns());
-// bank.show();
-// }
- }
-// if(bank_name.compareTo("Lund::particles") == 0 || bank_name.compareTo("GenPart::true") == 0) {
-// System.out.println("end " + bank.rows()+" "+bank.columns());
-// bank.show();
-// }
- return bank;
- }
-
- public void getBank(String bank_name, DataBank bank) {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public void show() {
-
- // System.out.println("-----> event show");
- // dictionary.show();
- String[] bankList = this.getBankList();
- /*
- * ArrayList bList = new ArrayList(); bList.addAll(Arrays.asList(bankList));
- */
- TablePrintout table = new TablePrintout("bank:nrows:ncols", "48:12:12");
-
- if (bankList != null) {
- ArrayList bankNames = new ArrayList();
- for (String bank : bankList) {
- bankNames.add(bank);
- }
-
- Collections.sort(bankNames);
-
- for (String bank : bankNames) {
- String[] tokens = new String[3];
- tokens[0] = bank;
- DataBank dbank = null;
- try {
- dbank = this.getBank(bank);
- } catch (Exception e) {
- System.out.println(" ERROR : getbank failed for bank name " + bank);
- e.printStackTrace();
- }
- if (dbank == null) {
- System.err.println("[EvioDataEvent::show] ERROR : bank " + bank + " does not exist");
- continue;
- }
- Integer ncols = dbank.columns();
- Integer nrows = dbank.rows();
- tokens[1] = nrows.toString();
- tokens[2] = ncols.toString();
- table.addData(tokens);
- // System.out.println("BANK [] ---> " + bank);
- }
- }
- table.show();
- }
-
- public EvioNode getNodeFromTree(int parent_tag, int tag, int num, DataType type) {
- /*
- * try { List nodes = structure.getChildNodes(); } catch (EvioException ex) { Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE,
- * null, ex); }
- */
- return null;
- }
-
- /*
- * public EvioNode getChildNode(EvioNode node, int tag, int num, DataType type){
- *
- * }
- */
-
- public EvioNode getNodeFromTree(int tag, int num, DataType type) {
-
- try {
- List nodes = this.eventHandler.getStructure().getNodes();
-
- if (nodes == null) {
- System.out.println("EVENT NODES = NULL");
- return null;
- }
-
- for (EvioNode item : nodes) {
- if (item.getDataTypeObj() == type) {
- // System.out.println("parsin node " + item.getTag() + " looking for " + tag );
- }
- if (type == DataType.INT32) {
- if (item.getTag() == tag && item.getNum() == num
- && (item.getDataTypeObj() == DataType.INT32 || item.getDataTypeObj() == DataType.UINT32))
- return item;
- }
+ dataTree = this.eventHandler.getNodeData(parentNode);
+ } else if (bank_name.compareTo("Lund::header") == 0) {
+ dataTree = this.eventHandler.getNodeData(parentNode);
+ } else if (bank_name.compareTo("Lund::true") == 0) {
+ dataTree = this.eventHandler.getNodeData(parentNode);
+ } else {
+ dataTree = this.eventHandler.getNodeData(leafNode);
+ }
+
+ EvioDataBank bank = new EvioDataBank(desc);
+ String[] entries = desc.getEntryList();
+
+ for (String item : entries) {
+ int type = desc.getProperty("type", item);
+ int num = desc.getProperty("num", item);
+
+ if (DataEntryType.getType(type) == DataEntryType.INTEGER) {
+ bank.setInt(item, (int[]) dataTree.get(num));
+ }
+
+ if (DataEntryType.getType(type) == DataEntryType.DOUBLE) {
+ bank.setDouble(item, (double[]) dataTree.get(num));
+ }
+
+ if (DataEntryType.getType(type) == DataEntryType.FLOAT) {
+ bank.setFloat(item, (float[]) dataTree.get(num));
+ }
+ if (DataEntryType.getType(type) == DataEntryType.SHORT) {
+ bank.setShort(item, (short[]) dataTree.get(num));
+ }
+
+ if (DataEntryType.getType(type) == DataEntryType.BYTE) {
+ bank.setByte(item, (byte[]) dataTree.get(num));
+ }
+ }
+ return bank;
+ }
+
+ @Override
+ public void getBank(String bank_name, DataBank bank) {
+ throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void show() {
+
+ String[] bankList = this.getBankList();
+ TablePrintout table = new TablePrintout("bank:nrows:ncols", "48:12:12");
+
+ if (bankList != null) {
+ ArrayList bankNames = new ArrayList<>();
+ bankNames.addAll(Arrays.asList(bankList));
+
+ Collections.sort(bankNames);
+
+ for (String bank : bankNames) {
+ String[] tokens = new String[3];
+ tokens[0] = bank;
+ DataBank dbank = null;
+ try {
+ dbank = this.getBank(bank);
+ } catch (Exception e) {
+ System.out.println(" ERROR : getbank failed for bank name " + bank);
+ e.printStackTrace();
+ }
+ if (dbank == null) {
+ System.err.println("[EvioDataEvent::show] ERROR : bank " + bank + " does not exist");
+ continue;
+ }
+ Integer ncols = dbank.columns();
+ Integer nrows = dbank.rows();
+ tokens[1] = nrows.toString();
+ tokens[2] = ncols.toString();
+ table.addData(tokens);
+ }
+ }
+ table.show();
+ }
+
+ public EvioNode getNodeFromTree(int parent_tag, int tag, int num, DataType type) {
+ return null;
+ }
+
+ public EvioNode getNodeFromTree(int tag, int num, DataType type) {
+
+ try {
+ List nodes = this.eventHandler.getStructure().getNodes();
+
+ if (nodes == null) {
+ System.out.println("EVENT NODES = NULL");
+ return null;
+ }
+
+ for (EvioNode item : nodes) {
+ if (item.getDataTypeObj() == type) {
+ }
+ if (type == DataType.INT32) {
+ if (item.getTag() == tag && item.getNum() == num
+ && (item.getDataTypeObj() == DataType.INT32 || item.getDataTypeObj() == DataType.UINT32))
+ return item;
+ }
- if(type == DataType.LONG64){
- if (item.getTag() == tag && item.getNum() == num
- && (item.getDataTypeObj() == DataType.LONG64 || item.getDataTypeObj() == DataType.ULONG64))
- return item;
- }
- if (item.getTag() == tag && item.getNum() == num && item.getDataTypeObj() == type)
- return item;
- /*
- * if(item.getTag()==tag&&item.getNum()==num&& item.getDataTypeObj()==type) return item;
- */
- }
-
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
- }
- return null;
- }
-
- public double[] getDouble(int tag, int num) {
- EvioNode node = this.getNodeFromTree(tag, num, DataType.DOUBLE64);
- if (node != null) {
- try {
- ByteBuffer buffer = this.eventHandler.getStructure().getData(node);
- double[] nodedata = ByteDataTransformer.toDoubleArray(buffer);
- return nodedata;
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- // double[] ret = {0.0};
- return null;
- }
-
- public double[] getDouble(String path) {
- if (path.contains("/") == true) {
- String[] tokens = path.split("/");
- return this.getDouble(Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]));
- } else {
- int[] tagnum = this.getTagNum(path);
- return this.getDouble(tagnum[0], tagnum[1]);
- }
- }
-
- public void setDouble(String path, double[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public void appendDouble(String path, double[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public void appendGeneratedBank(DataBank bank) {
- // System.err.println("---------> 1");
- String parent_tag = bank.getDescriptor().getPropertyString("parent_tag");
- String container_tag = bank.getDescriptor().getPropertyString("container_tag");
- // System.err.println("---------> 2");
- EvioEvent baseBank = new EvioEvent(Integer.parseInt(parent_tag), DataType.ALSOBANK, 0);
- // System.err.println("---------> 3");
- EvioBank sectionBank = new EvioBank(Integer.parseInt(container_tag), DataType.ALSOBANK, 0);
- // System.err.println("---------> 4");
-
- EventBuilder builder = new EventBuilder(baseBank);
-
- ByteOrder byteOrder = this.eventHandler.getStructure().getByteBuffer().order();
-
- baseBank.setByteOrder(byteOrder);
- sectionBank.setByteOrder(byteOrder);
- // doubleBank.setByteOrder(byteOrder);
- // System.err.println("------------ adding bank ");
- // System.err.println("------------ adding bank " + bank.getDescriptor().getName());
- try {
- String[] entries = bank.getDescriptor().getEntryList();
- for (String entry : entries) {
- // System.out.println("----> adding entry " + entry);
- int e_tag = bank.getDescriptor().getProperty("tag", entry);
- int e_num = bank.getDescriptor().getProperty("num", entry);
- int e_typ = bank.getDescriptor().getProperty("type", entry);
- if (DataEntryType.getType(e_typ) == DataEntryType.INTEGER) {
- EvioBank dataBank = new EvioBank(e_tag, DataType.INT32, e_num);
- dataBank.setByteOrder(byteOrder);
- dataBank.appendIntData(bank.getInt(entry));
- builder.addChild(baseBank, dataBank);
- }
-
- if (DataEntryType.getType(e_typ) == DataEntryType.DOUBLE) {
- EvioBank dataBank = new EvioBank(e_tag, DataType.DOUBLE64, e_num);
- dataBank.setByteOrder(byteOrder);
- dataBank.appendDoubleData(bank.getDouble(entry));
- builder.addChild(baseBank, dataBank);
- }
-
- if (DataEntryType.getType(e_typ) == DataEntryType.FLOAT) {
- EvioBank dataBank = new EvioBank(e_tag, DataType.FLOAT32, e_num);
- dataBank.setByteOrder(byteOrder);
- dataBank.appendFloatData(bank.getFloat(entry));
- builder.addChild(baseBank, dataBank);
- }
-
- if (DataEntryType.getType(e_typ) == DataEntryType.SHORT) {
- EvioBank dataBank = new EvioBank(e_tag, DataType.SHORT16, e_num);
- dataBank.setByteOrder(byteOrder);
- dataBank.appendShortData(bank.getShort(entry));
- builder.addChild(baseBank, dataBank);
- }
-
- if (DataEntryType.getType(e_typ) == DataEntryType.BYTE) {
- EvioBank dataBank = new EvioBank(e_tag, DataType.CHAR8, e_num);
- dataBank.setByteOrder(byteOrder);
- dataBank.appendByteData(bank.getByte(entry));
- builder.addChild(baseBank, dataBank);
- }
- }
-
- // builder.addChild(baseBank, sectionBank);
-
- int byteSize = baseBank.getTotalBytes();
- ByteBuffer bb = ByteBuffer.allocate(byteSize);
- // System.out.println("-------> adding bank " + bank.getDescriptor().getName()
- // + " size = " + byteSize);
- bb.order(byteOrder);
- baseBank.write(bb);
- bb.flip();
- // System.out.println("-----> prior size = " + structure.getByteBuffer().limit());
- ByteBuffer newBuffer = this.eventHandler.getStructure().addStructure(bb);
- // System.out.println("---> new byte buffer has size " + newBuffer.limit()
- // + " changed from " + structure.getByteBuffer().limit());
- // structure.
- EvioCompactStructureHandler handler =
- new EvioCompactStructureHandler(this.eventHandler.getStructure().getByteBuffer(), DataType.BANK);
- this.eventHandler.setStructure(handler);
- /*
- * for (Map.Entry bank : integerContainer.entrySet()) { EvioBank dataBank = new EvioBank(tag, DataType.INT32, bank.getKey());
- * dataBank.setByteOrder(byteOrder); dataBank.appendIntData(bank.getValue()); builder.addChild(intBank, dataBank); }
- *
- * for (Entry bank : doubleBanks.entrySet()) { EvioBank dataBank = new EvioBank(tag, DataType.DOUBLE64, bank.getKey());
- * dataBank.setByteOrder(byteOrder); dataBank.appendDoubleData(bank.getValue()); builder.addChild(doubleBank, dataBank); }
- */
- } catch (EvioException e) {
- e.printStackTrace();
- }
- }
-
- public void appendBank(DataBank bank) {
- // System.err.println("---------> 1");
- String parent_tag = bank.getDescriptor().getPropertyString("parent_tag");
- String container_tag = bank.getDescriptor().getPropertyString("container_tag");
- // System.err.println("---------> 2");
- EvioEvent baseBank = new EvioEvent(Integer.parseInt(parent_tag), DataType.ALSOBANK, 0);
- // System.err.println("---------> 3");
- EvioBank sectionBank = new EvioBank(Integer.parseInt(container_tag), DataType.ALSOBANK, 0);
- // System.err.println("---------> 4");
-
- EventBuilder builder = new EventBuilder(baseBank);
-
- ByteOrder byteOrder = this.eventHandler.getStructure().getByteBuffer().order();
-
- baseBank.setByteOrder(byteOrder);
- sectionBank.setByteOrder(byteOrder);
- // doubleBank.setByteOrder(byteOrder);
- // System.err.println("------------ adding bank ");
- // System.err.println("------------ adding bank " + bank.getDescriptor().getName());
- try {
- String[] entries = bank.getDescriptor().getEntryList();
- for (String entry : entries) {
- // System.out.println("----> adding entry " + entry);
- int e_tag = bank.getDescriptor().getProperty("tag", entry);
- int e_num = bank.getDescriptor().getProperty("num", entry);
- int e_typ = bank.getDescriptor().getProperty("type", entry);
- if (DataEntryType.getType(e_typ) == DataEntryType.INTEGER) {
- EvioBank dataBank = new EvioBank(e_tag, DataType.INT32, e_num);
- dataBank.setByteOrder(byteOrder);
- dataBank.appendIntData(bank.getInt(entry));
- builder.addChild(sectionBank, dataBank);
- }
-
- if (DataEntryType.getType(e_typ) == DataEntryType.DOUBLE) {
- EvioBank dataBank = new EvioBank(e_tag, DataType.DOUBLE64, e_num);
- dataBank.setByteOrder(byteOrder);
- dataBank.appendDoubleData(bank.getDouble(entry));
- builder.addChild(sectionBank, dataBank);
- }
-
- if (DataEntryType.getType(e_typ) == DataEntryType.FLOAT) {
- EvioBank dataBank = new EvioBank(e_tag, DataType.FLOAT32, e_num);
- dataBank.setByteOrder(byteOrder);
- dataBank.appendFloatData(bank.getFloat(entry));
- builder.addChild(sectionBank, dataBank);
- }
-
- if (DataEntryType.getType(e_typ) == DataEntryType.SHORT) {
- EvioBank dataBank = new EvioBank(e_tag, DataType.SHORT16, e_num);
- dataBank.setByteOrder(byteOrder);
- dataBank.appendShortData(bank.getShort(entry));
- builder.addChild(sectionBank, dataBank);
- }
-
- if (DataEntryType.getType(e_typ) == DataEntryType.BYTE) {
- EvioBank dataBank = new EvioBank(e_tag, DataType.CHAR8, e_num);
- dataBank.setByteOrder(byteOrder);
- dataBank.appendByteData(bank.getByte(entry));
- builder.addChild(sectionBank, dataBank);
- }
- }
-
- builder.addChild(baseBank, sectionBank);
-
- int byteSize = baseBank.getTotalBytes();
- ByteBuffer bb = ByteBuffer.allocate(byteSize);
- // System.out.println("-------> adding bank " + bank.getDescriptor().getName()
- // + " size = " + byteSize);
- bb.order(byteOrder);
- baseBank.write(bb);
- bb.flip();
- // System.out.println("-----> prior size = " + structure.getByteBuffer().limit());
- ByteBuffer newBuffer = this.eventHandler.getStructure().addStructure(bb);
- // System.out.println("---> new byte buffer has size " + newBuffer.limit()
- // + " changed from " + structure.getByteBuffer().limit());
- // structure.
- EvioCompactStructureHandler handler =
- new EvioCompactStructureHandler(this.eventHandler.getStructure().getByteBuffer(), DataType.BANK);
- this.eventHandler.setStructure(handler);
- /*
- * for (Map.Entry bank : integerContainer.entrySet()) { EvioBank dataBank = new EvioBank(tag, DataType.INT32, bank.getKey());
- * dataBank.setByteOrder(byteOrder); dataBank.appendIntData(bank.getValue()); builder.addChild(intBank, dataBank); }
- *
- * for (Entry bank : doubleBanks.entrySet()) { EvioBank dataBank = new EvioBank(tag, DataType.DOUBLE64, bank.getKey());
- * dataBank.setByteOrder(byteOrder); dataBank.appendDoubleData(bank.getValue()); builder.addChild(doubleBank, dataBank); }
- */
- } catch (EvioException e) {
- e.printStackTrace();
- }
-
- }
-
- public ByteBuffer getEventBuffer() {
- return this.eventHandler.getStructure().getByteBuffer();
- }
-
- public void setProperty(String property, String value) {
- if (eventProperties.containsKey(property) == true) {
- eventProperties.remove(property);
- }
- eventProperties.put(property, value);
- }
-
- public String getProperty(String property) {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public byte[] getByte(int tag, int num) {
- EvioNode node = this.getNodeFromTree(tag, num, DataType.CHAR8);
- if (node != null) {
- try {
- ByteBuffer buffer = this.eventHandler.getStructure().getData(node);
- byte[] nodedata = ByteDataTransformer.toByteArray(buffer);
- return nodedata;
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- // byte[] ret = {0};
- return null;
- }
-
- public byte[] getByte(String path) {
- if (path.contains("/") == true) {
- String[] tokens = path.split("/");
- return this.getByte(Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]));
- } else {
- int[] tagnum = this.getTagNum(path);
- return this.getByte(tagnum[0], tagnum[1]);
- }
- // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public void setByte(String path, byte[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public void appendByte(String path, byte[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public void copyEvent(EvioDataEvent event) {
- byte[] eventBytes = event.getEventBuffer().array();
- this.eventHandler = new EvioDataEventHandler(eventBytes, event.getByteOrder());
- }
-
- public void appendBanks(DataBank... banklist) {
-
- String common_tag = banklist[0].getDescriptor().getPropertyString("parent_tag");
- Boolean check = true;
- for (int loop = 0; loop < banklist.length; loop++) {
- String btag = banklist[loop].getDescriptor().getPropertyString("parent_tag");
- if (btag.compareTo(common_tag) != 0)
- check = false;
- }
-
- // System.out.println("Bank consistency check = " + check);
-
- String parent_tag = common_tag;
-
- try {
-
- EvioEvent baseBank = new EvioEvent(Integer.parseInt(parent_tag), DataType.ALSOBANK, 0);
- ByteOrder byteOrder = this.eventHandler.getStructure().getByteBuffer().order();
- baseBank.setByteOrder(byteOrder);
- EventBuilder builder = new EventBuilder(baseBank);
-
- for (DataBank bank : banklist) {
- String container_tag = bank.getDescriptor().getPropertyString("container_tag");
- // System.err.println("---------> 2");
-
- // System.err.println("---------> 3");
- EvioBank sectionBank = new EvioBank(Integer.parseInt(container_tag), DataType.ALSOBANK, 0);
- // System.err.println("---------> 4");
-
- sectionBank.setByteOrder(byteOrder);
- // doubleBank.setByteOrder(byteOrder);
- // System.err.println("------------ adding bank ");
- // System.err.println("------------ adding bank " + bank.getDescriptor().getName());
-
- String[] entries = bank.getDescriptor().getEntryList();
- for (String entry : entries) {
- // System.out.println("----> adding entry " + entry);
- int e_tag = bank.getDescriptor().getProperty("tag", entry);
- int e_num = bank.getDescriptor().getProperty("num", entry);
- int e_typ = bank.getDescriptor().getProperty("type", entry);
- if (DataEntryType.getType(e_typ) == DataEntryType.INTEGER) {
- EvioBank dataBank = new EvioBank(e_tag, DataType.INT32, e_num);
- dataBank.setByteOrder(byteOrder);
- dataBank.appendIntData(bank.getInt(entry));
- builder.addChild(sectionBank, dataBank);
- }
-
- if (DataEntryType.getType(e_typ) == DataEntryType.DOUBLE) {
- EvioBank dataBank = new EvioBank(e_tag, DataType.DOUBLE64, e_num);
- dataBank.setByteOrder(byteOrder);
- dataBank.appendDoubleData(bank.getDouble(entry));
- builder.addChild(sectionBank, dataBank);
- }
-
- if (DataEntryType.getType(e_typ) == DataEntryType.FLOAT) {
- EvioBank dataBank = new EvioBank(e_tag, DataType.FLOAT32, e_num);
- dataBank.setByteOrder(byteOrder);
- dataBank.appendFloatData(bank.getFloat(entry));
- builder.addChild(sectionBank, dataBank);
- }
-
- if (DataEntryType.getType(e_typ) == DataEntryType.SHORT) {
- EvioBank dataBank = new EvioBank(e_tag, DataType.SHORT16, e_num);
- dataBank.setByteOrder(byteOrder);
- dataBank.appendShortData(bank.getShort(entry));
- builder.addChild(sectionBank, dataBank);
- }
-
- if (DataEntryType.getType(e_typ) == DataEntryType.BYTE) {
- EvioBank dataBank = new EvioBank(e_tag, DataType.CHAR8, e_num);
- dataBank.setByteOrder(byteOrder);
- dataBank.appendByteData(bank.getByte(entry));
- builder.addChild(sectionBank, dataBank);
- }
- }
-
- builder.addChild(baseBank, sectionBank);
- }
-
- int byteSize = baseBank.getTotalBytes();
- ByteBuffer bb = ByteBuffer.allocate(byteSize);
- // System.out.println("-------> adding bank " + bank.getDescriptor().getName()
- // + " size = " + byteSize);
- bb.order(byteOrder);
- baseBank.write(bb);
- bb.flip();
- // System.out.println("-----> prior size = " + structure.getByteBuffer().limit());
- ByteBuffer newBuffer = this.eventHandler.getStructure().addStructure(bb);
- // System.out.println("---> new byte buffer has size " + newBuffer.limit()
- // + " changed from " + structure.getByteBuffer().limit());
- // structure.
- EvioCompactStructureHandler handler =
- new EvioCompactStructureHandler(this.eventHandler.getStructure().getByteBuffer(), DataType.BANK);
- this.eventHandler.setStructure(handler);
- /*
- * for (Map.Entry bank : integerContainer.entrySet()) { EvioBank dataBank = new EvioBank(tag, DataType.INT32, bank.getKey());
- * dataBank.setByteOrder(byteOrder); dataBank.appendIntData(bank.getValue()); builder.addChild(intBank, dataBank); }
- *
- * for (Entry bank : doubleBanks.entrySet()) { EvioBank dataBank = new EvioBank(tag, DataType.DOUBLE64, bank.getKey());
- * dataBank.setByteOrder(byteOrder); dataBank.appendDoubleData(bank.getValue()); builder.addChild(doubleBank, dataBank); }
- */
- } catch (EvioException e) {
- e.printStackTrace();
- }
- }
-
- public void setType(DataEventType type) {
- this.eventType = type;
- }
-
- public DataEventType getType() {
- return this.eventType;
- }
+ if(type == DataType.LONG64){
+ if (item.getTag() == tag && item.getNum() == num
+ && (item.getDataTypeObj() == DataType.LONG64 || item.getDataTypeObj() == DataType.ULONG64))
+ return item;
+ }
+ if (item.getTag() == tag && item.getNum() == num && item.getDataTypeObj() == type)
+ return item;
+ }
+
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return null;
+ }
+
+ public double[] getDouble(int tag, int num) {
+ EvioNode node = this.getNodeFromTree(tag, num, DataType.DOUBLE64);
+ if (node != null) {
+ try {
+ ByteBuffer buffer = this.eventHandler.getStructure().getData(node);
+ double[] nodedata = ByteDataTransformer.toDoubleArray(buffer);
+ return nodedata;
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public double[] getDouble(String path) {
+ if (path.contains("/") == true) {
+ String[] tokens = path.split("/");
+ return this.getDouble(Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]));
+ } else {
+ int[] tagnum = this.getTagNum(path);
+ return this.getDouble(tagnum[0], tagnum[1]);
+ }
+ }
+
+ @Override
+ public void setDouble(String path, double[] arr) {
+ throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void appendDouble(String path, double[] arr) {
+ throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
+ }
+
+ public void appendGeneratedBank(DataBank bank) {
+ String parent_tag = bank.getDescriptor().getPropertyString("parent_tag");
+ String container_tag = bank.getDescriptor().getPropertyString("container_tag");
+ EvioEvent baseBank = new EvioEvent(Integer.parseInt(parent_tag), DataType.ALSOBANK, 0);
+ EvioBank sectionBank = new EvioBank(Integer.parseInt(container_tag), DataType.ALSOBANK, 0);
+
+ EventBuilder builder = new EventBuilder(baseBank);
+
+ ByteOrder byteOrder = this.eventHandler.getStructure().getByteBuffer().order();
+
+ baseBank.setByteOrder(byteOrder);
+ sectionBank.setByteOrder(byteOrder);
+ try {
+ String[] entries = bank.getDescriptor().getEntryList();
+ for (String entry : entries) {
+ int e_tag = bank.getDescriptor().getProperty("tag", entry);
+ int e_num = bank.getDescriptor().getProperty("num", entry);
+ int e_typ = bank.getDescriptor().getProperty("type", entry);
+ if (DataEntryType.getType(e_typ) == DataEntryType.INTEGER) {
+ EvioBank dataBank = new EvioBank(e_tag, DataType.INT32, e_num);
+ dataBank.setByteOrder(byteOrder);
+ dataBank.appendIntData(bank.getInt(entry));
+ builder.addChild(baseBank, dataBank);
+ }
+
+ if (DataEntryType.getType(e_typ) == DataEntryType.DOUBLE) {
+ EvioBank dataBank = new EvioBank(e_tag, DataType.DOUBLE64, e_num);
+ dataBank.setByteOrder(byteOrder);
+ dataBank.appendDoubleData(bank.getDouble(entry));
+ builder.addChild(baseBank, dataBank);
+ }
+
+ if (DataEntryType.getType(e_typ) == DataEntryType.FLOAT) {
+ EvioBank dataBank = new EvioBank(e_tag, DataType.FLOAT32, e_num);
+ dataBank.setByteOrder(byteOrder);
+ dataBank.appendFloatData(bank.getFloat(entry));
+ builder.addChild(baseBank, dataBank);
+ }
+
+ if (DataEntryType.getType(e_typ) == DataEntryType.SHORT) {
+ EvioBank dataBank = new EvioBank(e_tag, DataType.SHORT16, e_num);
+ dataBank.setByteOrder(byteOrder);
+ dataBank.appendShortData(bank.getShort(entry));
+ builder.addChild(baseBank, dataBank);
+ }
+
+ if (DataEntryType.getType(e_typ) == DataEntryType.BYTE) {
+ EvioBank dataBank = new EvioBank(e_tag, DataType.CHAR8, e_num);
+ dataBank.setByteOrder(byteOrder);
+ dataBank.appendByteData(bank.getByte(entry));
+ builder.addChild(baseBank, dataBank);
+ }
+ }
+
+ int byteSize = baseBank.getTotalBytes();
+ ByteBuffer bb = ByteBuffer.allocate(byteSize);
+ bb.order(byteOrder);
+ baseBank.write(bb);
+ bb.flip();
+ ByteBuffer newBuffer = this.eventHandler.getStructure().addStructure(bb);
+ EvioCompactStructureHandler handler =
+ new EvioCompactStructureHandler(this.eventHandler.getStructure().getByteBuffer(), DataType.BANK);
+ this.eventHandler.setStructure(handler);
+ } catch (EvioException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void appendBank(DataBank bank) {
+ String parent_tag = bank.getDescriptor().getPropertyString("parent_tag");
+ String container_tag = bank.getDescriptor().getPropertyString("container_tag");
+ EvioEvent baseBank = new EvioEvent(Integer.parseInt(parent_tag), DataType.ALSOBANK, 0);
+ EvioBank sectionBank = new EvioBank(Integer.parseInt(container_tag), DataType.ALSOBANK, 0);
+
+ EventBuilder builder = new EventBuilder(baseBank);
+
+ ByteOrder byteOrder = this.eventHandler.getStructure().getByteBuffer().order();
+
+ baseBank.setByteOrder(byteOrder);
+ sectionBank.setByteOrder(byteOrder);
+ try {
+ String[] entries = bank.getDescriptor().getEntryList();
+ for (String entry : entries) {
+ int e_tag = bank.getDescriptor().getProperty("tag", entry);
+ int e_num = bank.getDescriptor().getProperty("num", entry);
+ int e_typ = bank.getDescriptor().getProperty("type", entry);
+ if (DataEntryType.getType(e_typ) == DataEntryType.INTEGER) {
+ EvioBank dataBank = new EvioBank(e_tag, DataType.INT32, e_num);
+ dataBank.setByteOrder(byteOrder);
+ dataBank.appendIntData(bank.getInt(entry));
+ builder.addChild(sectionBank, dataBank);
+ }
+
+ if (DataEntryType.getType(e_typ) == DataEntryType.DOUBLE) {
+ EvioBank dataBank = new EvioBank(e_tag, DataType.DOUBLE64, e_num);
+ dataBank.setByteOrder(byteOrder);
+ dataBank.appendDoubleData(bank.getDouble(entry));
+ builder.addChild(sectionBank, dataBank);
+ }
+
+ if (DataEntryType.getType(e_typ) == DataEntryType.FLOAT) {
+ EvioBank dataBank = new EvioBank(e_tag, DataType.FLOAT32, e_num);
+ dataBank.setByteOrder(byteOrder);
+ dataBank.appendFloatData(bank.getFloat(entry));
+ builder.addChild(sectionBank, dataBank);
+ }
+
+ if (DataEntryType.getType(e_typ) == DataEntryType.SHORT) {
+ EvioBank dataBank = new EvioBank(e_tag, DataType.SHORT16, e_num);
+ dataBank.setByteOrder(byteOrder);
+ dataBank.appendShortData(bank.getShort(entry));
+ builder.addChild(sectionBank, dataBank);
+ }
+
+ if (DataEntryType.getType(e_typ) == DataEntryType.BYTE) {
+ EvioBank dataBank = new EvioBank(e_tag, DataType.CHAR8, e_num);
+ dataBank.setByteOrder(byteOrder);
+ dataBank.appendByteData(bank.getByte(entry));
+ builder.addChild(sectionBank, dataBank);
+ }
+ }
+
+ builder.addChild(baseBank, sectionBank);
+
+ int byteSize = baseBank.getTotalBytes();
+ ByteBuffer bb = ByteBuffer.allocate(byteSize);
+ bb.order(byteOrder);
+ baseBank.write(bb);
+ bb.flip();
+ ByteBuffer newBuffer = this.eventHandler.getStructure().addStructure(bb);
+ EvioCompactStructureHandler handler =
+ new EvioCompactStructureHandler(this.eventHandler.getStructure().getByteBuffer(), DataType.BANK);
+ this.eventHandler.setStructure(handler);
+ } catch (EvioException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public ByteBuffer getEventBuffer() {
+ return this.eventHandler.getStructure().getByteBuffer();
+ }
+
+ @Override
+ public final void setProperty(String property, String value) {
+ if (eventProperties.containsKey(property) == true) {
+ eventProperties.remove(property);
+ }
+ eventProperties.put(property, value);
+ }
+
+ @Override
+ public String getProperty(String property) {
+ throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
+ }
+
+ public byte[] getByte(int tag, int num) {
+ EvioNode node = this.getNodeFromTree(tag, num, DataType.CHAR8);
+ if (node != null) {
+ try {
+ ByteBuffer buffer = this.eventHandler.getStructure().getData(node);
+ byte[] nodedata = ByteDataTransformer.toByteArray(buffer);
+ return nodedata;
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public byte[] getByte(String path) {
+ if (path.contains("/") == true) {
+ String[] tokens = path.split("/");
+ return this.getByte(Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]));
+ } else {
+ int[] tagnum = this.getTagNum(path);
+ return this.getByte(tagnum[0], tagnum[1]);
+ }
+ }
+
+ @Override
+ public void setByte(String path, byte[] arr) {
+ throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void appendByte(String path, byte[] arr) {
+ throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
+ }
+
+ public void copyEvent(EvioDataEvent event) {
+ byte[] eventBytes = event.getEventBuffer().array();
+ this.eventHandler = new EvioDataEventHandler(eventBytes, event.getByteOrder());
+ }
+
+ @Override
+ public void appendBanks(DataBank... banklist) {
+
+ String parent_tag = banklist[0].getDescriptor().getPropertyString("parent_tag");
+
+ try {
+
+ EvioEvent baseBank = new EvioEvent(Integer.parseInt(parent_tag), DataType.ALSOBANK, 0);
+ ByteOrder byteOrder = this.eventHandler.getStructure().getByteBuffer().order();
+ baseBank.setByteOrder(byteOrder);
+ EventBuilder builder = new EventBuilder(baseBank);
+
+ for (DataBank bank : banklist) {
+ String container_tag = bank.getDescriptor().getPropertyString("container_tag");
+ EvioBank sectionBank = new EvioBank(Integer.parseInt(container_tag), DataType.ALSOBANK, 0);
+ sectionBank.setByteOrder(byteOrder);
+
+ String[] entries = bank.getDescriptor().getEntryList();
+ for (String entry : entries) {
+ int e_tag = bank.getDescriptor().getProperty("tag", entry);
+ int e_num = bank.getDescriptor().getProperty("num", entry);
+ int e_typ = bank.getDescriptor().getProperty("type", entry);
+ if (DataEntryType.getType(e_typ) == DataEntryType.INTEGER) {
+ EvioBank dataBank = new EvioBank(e_tag, DataType.INT32, e_num);
+ dataBank.setByteOrder(byteOrder);
+ dataBank.appendIntData(bank.getInt(entry));
+ builder.addChild(sectionBank, dataBank);
+ }
+
+ if (DataEntryType.getType(e_typ) == DataEntryType.DOUBLE) {
+ EvioBank dataBank = new EvioBank(e_tag, DataType.DOUBLE64, e_num);
+ dataBank.setByteOrder(byteOrder);
+ dataBank.appendDoubleData(bank.getDouble(entry));
+ builder.addChild(sectionBank, dataBank);
+ }
+
+ if (DataEntryType.getType(e_typ) == DataEntryType.FLOAT) {
+ EvioBank dataBank = new EvioBank(e_tag, DataType.FLOAT32, e_num);
+ dataBank.setByteOrder(byteOrder);
+ dataBank.appendFloatData(bank.getFloat(entry));
+ builder.addChild(sectionBank, dataBank);
+ }
+
+ if (DataEntryType.getType(e_typ) == DataEntryType.SHORT) {
+ EvioBank dataBank = new EvioBank(e_tag, DataType.SHORT16, e_num);
+ dataBank.setByteOrder(byteOrder);
+ dataBank.appendShortData(bank.getShort(entry));
+ builder.addChild(sectionBank, dataBank);
+ }
+
+ if (DataEntryType.getType(e_typ) == DataEntryType.BYTE) {
+ EvioBank dataBank = new EvioBank(e_tag, DataType.CHAR8, e_num);
+ dataBank.setByteOrder(byteOrder);
+ dataBank.appendByteData(bank.getByte(entry));
+ builder.addChild(sectionBank, dataBank);
+ }
+ }
+
+ builder.addChild(baseBank, sectionBank);
+ }
+
+ int byteSize = baseBank.getTotalBytes();
+ ByteBuffer bb = ByteBuffer.allocate(byteSize);
+ bb.order(byteOrder);
+ baseBank.write(bb);
+ bb.flip();
+ ByteBuffer newBuffer = this.eventHandler.getStructure().addStructure(bb);
+ EvioCompactStructureHandler handler =
+ new EvioCompactStructureHandler(this.eventHandler.getStructure().getByteBuffer(), DataType.BANK);
+ this.eventHandler.setStructure(handler);
+ } catch (EvioException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void setType(DataEventType type) {
+ this.eventType = type;
+ }
+
+ @Override
+ public DataEventType getType() {
+ return this.eventType;
+ }
+
+ @Override
public DataBank createBank(String bank_name, int rows) {
return this.dictionary.createBank(bank_name, rows);
}
@@ -912,12 +764,12 @@ public void removeBanks(String... bankNames) {
@Override
public long[] getLong(String path) {
if (path.contains("/") == true) {
- String[] tokens = path.split("/");
- return this.getLong(Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]));
- } else {
- int[] tagnum = this.getTagNum(path);
- return this.getLong(tagnum[0], tagnum[1]);
- }
+ String[] tokens = path.split("/");
+ return this.getLong(Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]));
+ } else {
+ int[] tagnum = this.getTagNum(path);
+ return this.getLong(tagnum[0], tagnum[1]);
+ }
}
@Override
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataEventHandler.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataEventHandler.java
index cae3f5c028..ef8e7c5953 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataEventHandler.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataEventHandler.java
@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.io.evio;
import java.nio.ByteBuffer;
@@ -40,13 +35,11 @@ public EvioDataEventHandler(byte[] buffer, ByteOrder b_order){
//} else {
try {
structure = new EvioCompactStructureHandler(evioBuffer,DataType.BANK);
- //eventNodes = structure.getChildNodes();
eventNodes = structure.getNodes();
} catch (EvioException ex) {
Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
}
//}
- //this.list();
}
public EvioDataEventHandler(ByteBuffer buff){
@@ -57,12 +50,10 @@ public EvioDataEventHandler(ByteBuffer buff){
} catch (EvioException ex) {
Logger.getLogger(EvioDataEvent.class.getName()).log(Level.SEVERE, null, ex);
}
- //this.list();
}
public EvioNode getRootNode(int tag, int num, DataType type){
for(EvioNode node : eventNodes){
- //System.out.println(" LOOKING for tag = " + tag + " num = " + num + " type = " + type);
if(node.getTag()==tag&&node.getNum()==num&&node.getDataTypeObj()==type){
return node;
}
@@ -166,7 +157,6 @@ public void list(){
try {
childnodes = this.structure.getNodes();
for(EvioNode node : childnodes){
- //for(EvioNode node : this.eventNodes){
System.out.println(String.format(" tag = %8d num = %8d type = %s",
node.getTag(),node.getNum(),node.getDataTypeObj()));
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataSync.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataSync.java
index cd7093b467..c12f2febbd 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataSync.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataSync.java
@@ -1,13 +1,6 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
package org.jlab.io.evio;
import java.io.File;
-import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.file.Path;
@@ -19,7 +12,6 @@
import org.jlab.coda.jevio.EventBuilder;
import org.jlab.coda.jevio.EventWriter;
import org.jlab.coda.jevio.EvioBank;
-//import org.jlab.coda.jevio.EvioCompactEventWriter;
import org.jlab.coda.jevio.EvioEvent;
import org.jlab.coda.jevio.EvioException;
import org.jlab.io.base.DataEvent;
@@ -29,195 +21,140 @@
*
* @author gavalian
*/
-public class EvioDataSync implements DataSync {
-
- private String evioOutputDirectory = null;
- private String evioOutputFile = null;
- private Integer evioCurrentFileNumber = 0;
- // private Long maximumBytesToWrite = (long) 1*1024*1024*1024;
- private Long maximumBytesToWrite = (long) 1932735283;
- private Long maximumRecordsToWrite = (long) 2000000;
- private Long currentBytesWritten = (long) 0;
- private Long currentRecordsWritten = (long) 0;
- private Boolean splitFiles = true;
- private ByteOrder writerByteOrder = ByteOrder.LITTLE_ENDIAN;
- private EventWriter evioWriter = null;
- private String[] CLASDetectors = new String[] { "EC", "PCAL", "FTOF1A", "FTOF1B", "FTOF2", "BST", "CND", "HTCC", "FTCAL", "CTOF" };
-
- public EvioDataSync() {
-
- }
-
- public EvioDataSync(String filename) {
- this.open(filename);
- }
-
- public void setSplit(boolean flag) {
- this.splitFiles = flag;
- }
-
- public void open(String filename) {
- // this.openFileForWriting(filename);
- this.initFileNames(filename);
- this.openFileForWriting();
- }
-
- public void initFileNames(String filename) {
- Path filepath = Paths.get(filename);
- this.evioOutputFile = filepath.getFileName().toString();
- if (filepath.getParent() == null) {
- this.evioOutputDirectory = "";
- } else {
- this.evioOutputDirectory = filepath.getParent().toString();
- }
- /*
- * int extensionIndex = this.evioOutputFile.lastIndexOf("."); if(extensionIndex>=0&&extensionIndex " + this.evioOutputDirectory);
- System.out.println("[EvioDataSync] ---> " + this.evioOutputFile);
-
- }
-
- private void openFileForWriting() {
- StringBuilder str = new StringBuilder();
- if (this.evioOutputDirectory.length() > 2) {
- str.append(this.evioOutputDirectory);
- str.append("/");
- }
- str.append(this.evioOutputFile);
- // str.append(".");
- // str.append(this.evioCurrentFileNumber);
- // str.append(".evio");
- String filename = str.toString();
- String dictionary = "\n" +
- // EvioDictionaryGenerator.createDAQDictionary(CLASDetectors)
- "\n";
- System.out.println(dictionary);
- this.currentBytesWritten = (long) 0;
- this.currentRecordsWritten = (long) 0;
- File file = new File(filename);
- try {
- evioWriter =
- new EventWriter(new File(filename), dictionary, true);
- // writerByteOrder, null, true);
- // new EventWriter(file, 1000000, 2,
- // ByteOrder.BIG_ENDIAN, null, null);
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataSync.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
-
- public void writeEvent(DataEvent event) {
-
- if (this.currentBytesWritten > this.maximumBytesToWrite || this.currentRecordsWritten > this.maximumRecordsToWrite) {
- this.evioWriter.close();
- this.evioCurrentFileNumber++;
- this.openFileForWriting();
- System.out.println("open file # " + this.evioCurrentFileNumber);
- }
-
- try {
- // System.err.println("[sync] ---> buffer size = " + event.getEventBuffer().limit());
- ByteBuffer original = event.getEventBuffer();
- Long bufferSize = (long) original.capacity();
- this.currentBytesWritten += bufferSize;
- this.currentRecordsWritten++;
- ByteBuffer clone = ByteBuffer.allocate(original.capacity());
- clone.order(original.order());
- original.rewind();
- clone.put(original);
- original.rewind();
- clone.flip();
- evioWriter.writeEvent(clone);
- // event.getEventBuffer().flip();
-
- } catch (Exception e){
- System.out.println("Something went wrong with writing");
- }
- }
-
- public void openWithDictionary(String filename, String dictionary) {
- File file = new File(filename);
- try {
- evioWriter =
- new EventWriter(new File(filename), null, true);
- // new EventWriter(file, 1000000, 2,
- // ByteOrder.BIG_ENDIAN, null, null);
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataSync.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
-
- public void close() {
-
- evioWriter.close();
- }
-
- public static void writeFileWithDictionary(String inputfile, String outputfile) {
- EvioSource reader = new EvioSource();
- reader.open(inputfile);
- EvioDataSync writer = new EvioDataSync();
- EvioDataDictionary dict = new EvioDataDictionary("CLAS12DIR", "lib/bankdefs/clas12new/");
- String dictString = dict.getXML();
-
- }
-
- public EvioDataEvent createEvent(EvioDataDictionary dict) {
-
- try {
- // EvioEvent baseBank = new EvioEvent(1, DataType.BANK, 0);
- EventBuilder builder = new EventBuilder(1, DataType.BANK, 0);
- EvioEvent event = builder.getEvent();
- EvioBank baseBank = new EvioBank(10, DataType.ALSOBANK, 0);
-
- builder.addChild(event, baseBank);
-
- ByteOrder byteOrder = writerByteOrder;
-
- int byteSize = event.getTotalBytes();
- // System.out.println("base bank size = " + byteSize);
- ByteBuffer bb = ByteBuffer.allocate(byteSize);
- bb.order(byteOrder);
- event.write(bb);
- bb.flip();
-
- return new EvioDataEvent(bb, dict);
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataSync.class.getName()).log(Level.SEVERE, null, ex);
- }
- return null;
- }
-
- public DataEvent createEvent() {
-
- try {
- // EvioEvent baseBank = new EvioEvent(1, DataType.BANK, 0);
- EventBuilder builder = new EventBuilder(1, DataType.BANK, 0);
- EvioEvent event = builder.getEvent();
- EvioBank baseBank = new EvioBank(10, DataType.ALSOBANK, 0);
-
- builder.addChild(event, baseBank);
-
- ByteOrder byteOrder = writerByteOrder;
-
- int byteSize = event.getTotalBytes();
- // System.out.println("base bank size = " + byteSize);
- ByteBuffer bb = ByteBuffer.allocate(byteSize);
- bb.order(byteOrder);
- event.write(bb);
- bb.flip();
-
- // return new EvioDataEvent(bb);
- return new EvioDataEvent(bb, EvioFactory.getDictionary());
- } catch (EvioException ex) {
- Logger.getLogger(EvioDataSync.class.getName()).log(Level.SEVERE, null, ex);
- }
- return null;
- }
-
- public static void main(String[] args) {
- String inputfile = args[0];
-
- }
+public final class EvioDataSync implements DataSync {
+
+ private String evioOutputDirectory = null;
+ private String evioOutputFile = null;
+ private Integer evioCurrentFileNumber = 0;
+ private Long maximumBytesToWrite = (long) 1932735283;
+ private Long maximumRecordsToWrite = (long) 2000000;
+ private Long currentBytesWritten = (long) 0;
+ private Long currentRecordsWritten = (long) 0;
+ private ByteOrder writerByteOrder = ByteOrder.LITTLE_ENDIAN;
+ private EventWriter evioWriter = null;
+
+ public EvioDataSync() {
+ }
+
+ public EvioDataSync(String filename) {
+ this.open(filename);
+ }
+
+ public void setSplit(boolean flag) {
+ }
+
+ @Override
+ public void open(String filename) {
+ this.initFileNames(filename);
+ this.openFileForWriting();
+ }
+
+ public void initFileNames(String filename) {
+ Path filepath = Paths.get(filename);
+ this.evioOutputFile = filepath.getFileName().toString();
+ if (filepath.getParent() == null) {
+ this.evioOutputDirectory = "";
+ } else {
+ this.evioOutputDirectory = filepath.getParent().toString();
+ }
+ System.out.println("[EvioDataSync] ---> " + this.evioOutputDirectory);
+ System.out.println("[EvioDataSync] ---> " + this.evioOutputFile);
+ }
+
+ private void openFileForWriting() {
+ StringBuilder str = new StringBuilder();
+ if (this.evioOutputDirectory.length() > 2) {
+ str.append(this.evioOutputDirectory);
+ str.append("/");
+ }
+ str.append(this.evioOutputFile);
+ String filename = str.toString();
+ String dictionary = "\n\n";
+ System.out.println(dictionary);
+ this.currentBytesWritten = (long) 0;
+ this.currentRecordsWritten = (long) 0;
+ try {
+ evioWriter = new EventWriter(new File(filename), dictionary, true);
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioDataSync.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ @Override
+ public void writeEvent(DataEvent event) {
+
+ if (this.currentBytesWritten > this.maximumBytesToWrite || this.currentRecordsWritten > this.maximumRecordsToWrite) {
+ this.evioWriter.close();
+ this.evioCurrentFileNumber++;
+ this.openFileForWriting();
+ System.out.println("open file # " + this.evioCurrentFileNumber);
+ }
+
+ try {
+ ByteBuffer original = event.getEventBuffer();
+ Long bufferSize = (long) original.capacity();
+ this.currentBytesWritten += bufferSize;
+ this.currentRecordsWritten++;
+ ByteBuffer clone = ByteBuffer.allocate(original.capacity());
+ clone.order(original.order());
+ original.rewind();
+ clone.put(original);
+ original.rewind();
+ clone.flip();
+ evioWriter.writeEvent(clone);
+ } catch (Exception e){
+ System.out.println("Something went wrong with writing");
+ }
+ }
+
+ public void openWithDictionary(String filename, String dictionary) {
+ try {
+ evioWriter = new EventWriter(new File(filename), null, true);
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioDataSync.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ @Override
+ public void close() {
+ evioWriter.close();
+ }
+
+ public EvioDataEvent createEvent(EvioDataDictionary dict) {
+ try {
+ EventBuilder builder = new EventBuilder(1, DataType.BANK, 0);
+ EvioEvent event = builder.getEvent();
+ EvioBank baseBank = new EvioBank(10, DataType.ALSOBANK, 0);
+ builder.addChild(event, baseBank);
+ ByteOrder byteOrder = writerByteOrder;
+ int byteSize = event.getTotalBytes();
+ ByteBuffer bb = ByteBuffer.allocate(byteSize);
+ bb.order(byteOrder);
+ event.write(bb);
+ bb.flip();
+ return new EvioDataEvent(bb, dict);
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioDataSync.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return null;
+ }
+
+ public DataEvent createEvent() {
+ try {
+ EventBuilder builder = new EventBuilder(1, DataType.BANK, 0);
+ EvioEvent event = builder.getEvent();
+ EvioBank baseBank = new EvioBank(10, DataType.ALSOBANK, 0);
+ builder.addChild(event, baseBank);
+ ByteOrder byteOrder = writerByteOrder;
+ int byteSize = event.getTotalBytes();
+ ByteBuffer bb = ByteBuffer.allocate(byteSize);
+ bb.order(byteOrder);
+ event.write(bb);
+ bb.flip();
+ return new EvioDataEvent(bb, EvioFactory.getDictionary());
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioDataSync.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return null;
+ }
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataWritter.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataWritter.java
deleted file mode 100644
index af5b52630c..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDataWritter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.evio;
-
-import org.jlab.io.base.DataEvent;
-import org.jlab.io.base.DataSync;
-
-/**
- *
- * @author gavalian
- */
-public class EvioDataWritter implements DataSync {
-
-
-
- public void open(String file) {
-
- }
-
- public void writeEvent(DataEvent event) {
-
- }
-
- public void close() {
-
- }
-
- public DataEvent createEvent() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDescriptor.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDescriptor.java
index 7fc744172c..0ee26a1d98 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDescriptor.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDescriptor.java
@@ -8,105 +8,114 @@
public class EvioDescriptor implements DataDescriptor {
- String[] entries;
- String name;
- int tag;
- HashMap nums;
- HashMap types;
-
- public EvioDescriptor(String name, int tag, String[] col_names, HashMap nums, HashMap types) {
- this.name = name;
- this.tag = tag;
- this.entries = col_names;
- this.nums = nums;
- this.types = types;
- }
-
- public String toString() {
- String ret = this.name + " tag: " + this.tag + "\n";
- for (String e : this.entries) {
- ret += " " + this.nums.get(e) + " " + e + " (" + this.types.get(e) + ")\n";
- }
- return ret;
- }
-
- public String[] getEntryList() {
- return this.entries;
- }
-
- public String getName() {
- return this.name;
- }
-
- public int getProperty(String property_name, String entry_name) {
- int ret = -1;
- if ("tag".equals(property_name)) {
- ret = tag;
- } else if (property_name == "num") {
- ret = this.nums.get(entry_name);
- } else if (property_name == "type") {
- ret = this.types.get(entry_name);
- }
- return ret;
- }
-
- public int getProperty(String property_name) {
- int ret = -1;
- if (property_name == "tag") {
- ret = tag;
- }
- return ret;
- }
-
- public void init(String s) {
- // do nothing for EVIO
- }
-
- public void show() {
- System.out.println("-----> DataBankDescriptor NAME = " + this.name);
- TablePrintout table = new TablePrintout("Column:Tag:Number:Type", "24:8:8:8");
- Integer banktag = tag;
- for (Map.Entry item : nums.entrySet()) {
- String[] tdata = new String[4];
- tdata[0] = item.getKey();
- tdata[1] = banktag.toString();
- tdata[2] = item.getValue().toString();
- tdata[3] = types.get(item.getKey()).toString();
- table.addData(tdata);
- /*
- * System.out.println(String.format("---------> %12s tag=%5d num=%5d type=%5d", item.getKey(),tag,item.getValue(),types.get(item.getKey())));
- */
- }
- table.show();
- }
-
- public int getType(String name) {
- if (this.types.containsKey(name) == true) {
- return this.types.get(name);
- }
- return -1;
- }
-
- public String getXML() {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public void setPropertyString(String name, String value) {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public String getPropertyString(String property_name) {
- throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
- }
-
- public boolean hasEntry(String entry) {
- return this.types.containsKey(entry);
- }
-
- public boolean hasEntries(String... entries) {
- for (String item : entries)
- if (this.hasEntry(item) == false)
- return false;
- return true;
- }
+ String[] entries;
+ String name;
+ int tag;
+ HashMap nums;
+ HashMap types;
+
+ public EvioDescriptor(String name, int tag, String[] col_names, HashMap nums, HashMap types) {
+ this.name = name;
+ this.tag = tag;
+ this.entries = col_names;
+ this.nums = nums;
+ this.types = types;
+ }
+
+ @Override
+ public String toString() {
+ String ret = this.name + " tag: " + this.tag + "\n";
+ for (String e : this.entries) {
+ ret += " " + this.nums.get(e) + " " + e + " (" + this.types.get(e) + ")\n";
+ }
+ return ret;
+ }
+
+ @Override
+ public String[] getEntryList() {
+ return this.entries;
+ }
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public int getProperty(String property_name, String entry_name) {
+ int ret = -1;
+ if (null != property_name) switch (property_name) {
+ case "tag" -> ret = tag;
+ case "num" -> ret = this.nums.get(entry_name);
+ case "type" -> ret = this.types.get(entry_name);
+ default -> {
+ }
+ }
+ return ret;
+ }
+
+ @Override
+ public int getProperty(String property_name) {
+ int ret = -1;
+ if ("tag".equals(property_name)) {
+ ret = tag;
+ }
+ return ret;
+ }
+
+ @Override
+ public void init(String s) {
+ // do nothing for EVIO
+ }
+
+ @Override
+ public void show() {
+ System.out.println("-----> DataBankDescriptor NAME = " + this.name);
+ TablePrintout table = new TablePrintout("Column:Tag:Number:Type", "24:8:8:8");
+ Integer banktag = tag;
+ for (Map.Entry item : nums.entrySet()) {
+ String[] tdata = new String[4];
+ tdata[0] = item.getKey();
+ tdata[1] = banktag.toString();
+ tdata[2] = item.getValue().toString();
+ tdata[3] = types.get(item.getKey()).toString();
+ table.addData(tdata);
+ }
+ table.show();
+ }
+
+ public int getType(String name) {
+ if (this.types.containsKey(name) == true) {
+ return this.types.get(name);
+ }
+ return -1;
+ }
+
+ @Override
+ public String getXML() {
+ throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void setPropertyString(String name, String value) {
+ throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public String getPropertyString(String property_name) {
+ throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public boolean hasEntry(String entry) {
+ return this.types.containsKey(entry);
+ }
+
+ @Override
+ public boolean hasEntries(String... entries) {
+ for (String item : entries)
+ if (this.hasEntry(item) == false)
+ return false;
+ return true;
+ }
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDictionary.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDictionary.java
index 5b536e27f5..01fb60b57b 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDictionary.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioDictionary.java
@@ -45,10 +45,7 @@ public EvioDictionary() {
try {
File dict_dir = new File(dict_path);
this.setDictionary(dict_dir);
- /*
- * } catch (NoSuchAlgorithmException | ParserConfigurationException | SAXException | IOException | TransformerException e) { // TODO Auto-generated catch
- * block e.printStackTrace(); }
- */ } catch (ParserConfigurationException ex) {
+ } catch (ParserConfigurationException ex) {
Logger.getLogger(EvioDictionary.class.getName()).log(Level.SEVERE, null, ex);
} catch (SAXException ex) {
Logger.getLogger(EvioDictionary.class.getName()).log(Level.SEVERE, null, ex);
@@ -68,10 +65,7 @@ public EvioDictionary() {
public EvioDictionary(File dict_dir) {
try {
this.setDictionary(dict_dir);
- /*
- * } catch (NoSuchAlgorithmException | ParserConfigurationException | SAXException | IOException | TransformerException e) { // TODO Auto-generated catch
- * block e.printStackTrace(); }
- */ } catch (ParserConfigurationException ex) {
+ } catch (ParserConfigurationException ex) {
Logger.getLogger(EvioDictionary.class.getName()).log(Level.SEVERE, null, ex);
} catch (SAXException ex) {
Logger.getLogger(EvioDictionary.class.getName()).log(Level.SEVERE, null, ex);
@@ -84,30 +78,31 @@ public EvioDictionary(File dict_dir) {
}
}
+ @Override
public void init(String xml_dict) {
/*
* try { this.setDictionary(xml_dict); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (ParserConfigurationException e) {
* e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }
- *
*/
}
+ @Override
public String getXML() {
return dict;
}
+ @Override
public String[] getDescriptorList() {
String[] names = new String[descriptors.keySet().size()];
- // ArrayList array = new ArrayList();
int icounter = 0;
for (String key : descriptors.keySet()) {
names[icounter] = key;
icounter++;
}
return names;
- // return (String[]) descriptors.keySet().toArray();
}
+ @Override
public DataDescriptor getDescriptor(String bank_name) {
return this.descriptors.get(bank_name);
}
@@ -133,22 +128,12 @@ private Document getDocument() throws ParserConfigurationException, SAXException
return doc;
}
- private void rebuildHashMaps_2p0() throws ParserConfigurationException, SAXException, IOException {
- Document doc = this.getDocument();
- if (doc == null) {
- return;
- }
- this.descriptors = new HashMap();
- NodeList evio_dict_nodelist = doc.getElementsByTagName("evio_dictionary");
-
- }
-
private void rebuildHashMaps() throws ParserConfigurationException, SAXException, IOException {
Document doc = this.getDocument();
if (doc == null) {
return;
}
- this.descriptors = new HashMap();
+ this.descriptors = new HashMap<>();
NodeList evio_dict_nodelist = doc.getElementsByTagName("evio_dictionary");
for (int i = 0; i < evio_dict_nodelist.getLength(); i++) {
Element evio_dict = (Element) evio_dict_nodelist.item(i);
@@ -160,28 +145,25 @@ private void rebuildHashMaps() throws ParserConfigurationException, SAXException
if (name != null) {
int tag = Integer.parseInt(bank_elem.getAttribute("tag"));
- ArrayList col_names = new ArrayList();
- HashMap nums = new HashMap();
- HashMap types = new HashMap();
+ ArrayList col_names = new ArrayList<>();
+ HashMap nums = new HashMap<>();
+ HashMap types = new HashMap<>();
NodeList col_node_list = bank_elem.getElementsByTagName("column");
for (int k = 0; k < col_node_list.getLength(); k++) {
Element col_elem = (Element) col_node_list.item(k);
String col_name = col_elem.getAttribute("name");
- Integer num = Integer.parseInt(col_elem.getAttribute("num"));
+ Integer num = Integer.valueOf(col_elem.getAttribute("num"));
String type_str = col_elem.getAttribute("type");
Integer type;
- if (type_str.equals("int32")) {
- type = 1;
- } else if (type_str.equals("float32")) {
- type = 2;
- } else if (type_str.equals("float64")) {
- type = 3;
- } else {
- type = 0;
- }
+ type = switch (type_str) {
+ case "int32" -> 1;
+ case "float32" -> 2;
+ case "float64" -> 3;
+ default -> 0;
+ };
col_names.add(col_name);
nums.put(col_name, num);
@@ -200,7 +182,7 @@ private void rebuildHashMaps() throws ParserConfigurationException, SAXException
}
public void setDictionary(File dict_dir) throws ParserConfigurationException, SAXException, IOException, NoSuchAlgorithmException, TransformerException {
- ArrayList ignorePrefixes = new ArrayList();
+ ArrayList ignorePrefixes = new ArrayList<>();
ignorePrefixes.add(".");
ignorePrefixes.add("_");
@@ -222,7 +204,7 @@ public void setDictionary(File dict_dir) throws ParserConfigurationException, SA
// }
}
} else {
- xmlFileList = new ArrayList();
+ xmlFileList = new ArrayList<>();
xmlFileList.add(dict_dir.getAbsolutePath());
}
@@ -309,6 +291,7 @@ public static void main(String[] args) {
System.out.println("DC.x_avg (" + tag + ", " + num + ", " + typ + ")");
}
+ @Override
public DataBank createBank(String name, int rows) {
throw new UnsupportedOperationException("Not supported yet."); // To change body of generated methods, choose Tools | Templates.
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioETSource.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioETSource.java
index 8a7efabb6b..85bead48d7 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioETSource.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioETSource.java
@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.io.evio;
import java.io.File;
@@ -20,7 +15,6 @@
import org.jlab.coda.et.EtSystem;
import org.jlab.coda.et.EtSystemOpenConfig;
import org.jlab.coda.et.enums.Mode;
-import org.jlab.coda.et.enums.Modify;
import org.jlab.coda.et.exception.EtBusyException;
import org.jlab.coda.et.exception.EtClosedException;
import org.jlab.coda.et.exception.EtDeadException;
@@ -38,7 +32,6 @@
import org.jlab.io.base.DataSourceType;
import org.jlab.utils.options.OptionParser;
-
/**
*
* @author gavalian
@@ -46,7 +39,6 @@
public class EvioETSource implements DataSource {
-
private Boolean connectionOK = false;
private String etRingHost = "localhost";
private Integer etRingPort = 11111;
@@ -58,7 +50,7 @@ public class EvioETSource implements DataSource {
private Integer MAX_NEVENTS = 20;
private int currentEventPosition = 0;
- List readerEvents = new ArrayList();
+ List readerEvents = new ArrayList<>();
public EvioETSource(){
this.etRingPort = EtConstants.serverPort;
@@ -127,30 +119,20 @@ public void open(String filename) {
if(this.remoteConnection==true){
config.setConnectRemotely(true);
}
- //config.setConnectRemotely(true);
- //System.out.println("-------------->>>>> CONNECTING REMOTELY");
-
- //System.out.println("-------------->>>>> CONNECTING LOCALY");
sys = new EtSystem(config);
sys.setDebug(EtConstants.debugInfo);
sys.open();
EtStationConfig statConfig = new EtStationConfig();
- //statConfig.setBlockMode(EtConstants.stationBlocking);
statConfig.setBlockMode(EtConstants.stationNonBlocking);
statConfig.setUserMode(EtConstants.stationUserMulti);
statConfig.setRestoreMode(EtConstants.stationRestoreOut);
- //EtStation station = sys.createStation(statConfig, "GRAND_CENTRAL");
EtStation station = sys.createStation(statConfig, this.etStation);
myAttachment = sys.attach(station);
- //this.loadEvents();
- //sys.detach(myAttachment);
- //System.out.println("[ET-RING] ----> opened a stream with events # = " + this.readerEvents.size());
-
} catch (EtException ex) {
this.connectionOK = false;
ex.printStackTrace();
@@ -198,30 +180,13 @@ public void loadEvents(){
ByteBuffer evioBuffer = ByteBuffer.allocate(events[nevent].getLength());
evioBuffer.put(data, 0, length);
evioBuffer.order(buffer.order());
- //EvioReader reader;
- //System.out.println("------> parsing event # " + nevent +
- // " width length = " + length);
try {
- //reader = new EvioReader(buffer);
EvioCompactReader reader = new EvioCompactReader(buffer);
- //EvioEvent event = reader.parseNextEvent();
- /*List nodes = event.getChildrenList();
- System.out.println("----> rawbytes size = " + event.getRawBytes().length);
- for(BaseStructure base : nodes){
- System.out.println("----> event # " + nevent + " " + base);
- }*/
ByteBuffer localBuffer = reader.getEventBuffer(1);
- /*
- EvioDataEvent dataEvent = new EvioDataEvent(
- event.getRawBytes(),reader.getByteOrder(),
- EvioFactory.getDictionary());
- */
- //System.out.println("---> compact event buffer size = " + localBuffer.capacity());
EvioDataEvent dataEvent = new EvioDataEvent(localBuffer,EvioFactory.getDictionary());
this.readerEvents.add(dataEvent);
} catch (EvioException ex) {
System.out.println("*** ERROR *** : problem reading event # " + nevent );
- //Logger.getLogger(EvioETSource.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
@@ -281,6 +246,7 @@ public void putEvents(){
}
+ @Override
public DataEvent getNextEvent() {
if(this.currentEventPosition1){
- ethost = args[0];
- file = args[1];
- } else {
- System.out.println("\n\n\nUsage : et-connect host etfile\n");
- System.exit(0);
- }
-
- if(args.length>2){
- String flag = args[2];
- if(flag.compareTo("true")==0){
- isRemote = true;
- }
- }
-
- EvioETSource reader = new EvioETSource(ethost);
- reader.setRemote(isRemote);
- reader.open(file);
- //for(int loop = 0 ; loop < 10 ; loop++){
- int counter = 0;
- EvioEventDecoder decoder = new EvioEventDecoder();
- while(reader.hasEvent()){
- counter++;
- System.out.println("Reading next event # " + counter);
- EvioDataEvent event = (EvioDataEvent) reader.getNextEvent();
- if(event!=null) {
- System.out.println("------> received an event");
- event.getHandler().list();
- List rawdata = decoder.getDataEntries(event);
- for(DetectorRawData data : rawdata){
- System.out.println(data);
- }
- }
- }*/
- //}
}
@Override
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioETSync.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioETSync.java
index 491cf10b95..e591a00b1f 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioETSync.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioETSync.java
@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.io.evio;
import java.io.IOException;
@@ -12,7 +7,6 @@
import org.jlab.coda.et.EtAttachment;
import org.jlab.coda.et.EtConstants;
import org.jlab.coda.et.EtEvent;
-import org.jlab.coda.et.EtEventImpl;
import org.jlab.coda.et.EtStation;
import org.jlab.coda.et.EtStationConfig;
import org.jlab.coda.et.EtSystem;
@@ -23,7 +17,6 @@
import org.jlab.coda.et.exception.EtDeadException;
import org.jlab.coda.et.exception.EtEmptyException;
import org.jlab.coda.et.exception.EtException;
-import org.jlab.coda.et.exception.EtExistsException;
import org.jlab.coda.et.exception.EtTimeoutException;
import org.jlab.coda.et.exception.EtTooManyException;
import org.jlab.coda.et.exception.EtWakeUpException;
@@ -36,20 +29,18 @@
*/
public class EvioETSync implements DataSync {
- private Boolean connectionOK = false;
private String etRingHost = "";
private Integer etRingPort = 11111;
private EtSystem sys = null;
private EtAttachment myAttachment = null;
-
public EvioETSync(String ip){
this.etRingHost = ip;
}
+ @Override
public void open(String filename) {
try {
- this.connectionOK = true;
String etFile = filename;
EtSystemOpenConfig config = new EtSystemOpenConfig( etFile,this.etRingHost,this.etRingPort);
@@ -62,94 +53,63 @@ public void open(String filename) {
statConfig.setRestoreMode(EtConstants.stationRestoreOut);
EtStation gsStation = sys.stationNameToObject("GRAND_CENTRAL");
-
- //EtStation station = sys.createStation(statConfig, "my_station");
- //EtStation etst = new EtStation();
- //EtStation station = sys.attach();
myAttachment = sys.attach(gsStation);
} catch (EtException ex) {
- this.connectionOK = false;
ex.printStackTrace();
} catch (IOException ex) {
- this.connectionOK = false;
Logger.getLogger(EvioETSource.class.getName()).log(Level.SEVERE, null, ex);
} catch (EtTooManyException ex) {
- this.connectionOK = false;
Logger.getLogger(EvioETSource.class.getName()).log(Level.SEVERE, null, ex);
} catch (EtDeadException ex) {
Logger.getLogger(EvioETSource.class.getName()).log(Level.SEVERE, null, ex);
} catch (EtClosedException ex) {
Logger.getLogger(EvioETSource.class.getName()).log(Level.SEVERE, null, ex);
}
-
}
+ @Override
public void writeEvent(DataEvent event) {
- EvioDataEvent evioEvent = (EvioDataEvent) event;
-
- //byte[] buffer = evioEvent.getHandler().getStructure().getByteBuffer().array();
- //EtEventImpl etEvent = new EtEventImpl(buffer.length);
- //etEvent.setData(buffer);
- //etEvent.setOwner(1);
- //EtEvent[] evs = new EtEvent[]{etEvent};
byte[] buffer = new byte[200];
int eventLength = buffer.length;
-
System.out.println("WRITING DATA WITH LENGTH " + buffer.length);
- try {
-
- EtEvent[] etevents = sys.newEvents(myAttachment, Mode.SLEEP, false,
- 0,1,buffer.length, 1);
-
- ByteBuffer byteBuffer = etevents[0].getDataBuffer();
- byteBuffer.put(buffer);
- byteBuffer.flip();
-
- etevents[0].setLength(eventLength);
-
- //System.out.println("# of events = " + etevents.length + " BUFFER SIZE = " + byteBuffer.capacity()
- //+ " LENGTH = " + etevents[0].getLength());
-
-
- sys.putEvents(myAttachment, etevents);
+ try {
+ EtEvent[] etevents = sys.newEvents(myAttachment, Mode.SLEEP, false,
+ 0,1,buffer.length, 1);
+ ByteBuffer byteBuffer = etevents[0].getDataBuffer();
+ byteBuffer.put(buffer);
+ byteBuffer.flip();
+ etevents[0].setLength(eventLength);
+ sys.putEvents(myAttachment, etevents);
- } catch (IOException ex) {
- Logger.getLogger(EvioETSync.class.getName()).log(Level.SEVERE, null, ex);
- } catch (EtException ex) {
- Logger.getLogger(EvioETSync.class.getName()).log(Level.SEVERE, null, ex);
- } catch (EtDeadException ex) {
- Logger.getLogger(EvioETSync.class.getName()).log(Level.SEVERE, null, ex);
- } catch (EtClosedException ex) {
- Logger.getLogger(EvioETSync.class.getName()).log(Level.SEVERE, null, ex);
- } catch (EtEmptyException ex) {
- Logger.getLogger(EvioETSync.class.getName()).log(Level.SEVERE, null, ex);
- } catch (EtBusyException ex) {
- Logger.getLogger(EvioETSync.class.getName()).log(Level.SEVERE, null, ex);
- } catch (EtTimeoutException ex) {
- Logger.getLogger(EvioETSync.class.getName()).log(Level.SEVERE, null, ex);
- } catch (EtWakeUpException ex) {
- Logger.getLogger(EvioETSync.class.getName()).log(Level.SEVERE, null, ex);
- }
+ } catch (IOException ex) {
+ Logger.getLogger(EvioETSync.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (EtException ex) {
+ Logger.getLogger(EvioETSync.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (EtDeadException ex) {
+ Logger.getLogger(EvioETSync.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (EtClosedException ex) {
+ Logger.getLogger(EvioETSync.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (EtEmptyException ex) {
+ Logger.getLogger(EvioETSync.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (EtBusyException ex) {
+ Logger.getLogger(EvioETSync.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (EtTimeoutException ex) {
+ Logger.getLogger(EvioETSync.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (EtWakeUpException ex) {
+ Logger.getLogger(EvioETSync.class.getName()).log(Level.SEVERE, null, ex);
+ }
}
+ @Override
public void close() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
-
public static void main(String[] args){
String ethost = "129.57.76.215";
String file = "/tmp/myEtRing";
String evioFile = "/Users/gavalian/Work/Software/Release-8.0/COATJAVA/etaPXSection_0_recon.evio";
- /*
- if(args.length>1){
- ethost = args[0];
- file = args[1];
- } else {
- System.out.println("\n\n\nUsage : et-connect host etfile\n");
- System.exit(0);
- }*/
EvioETSync writer = new EvioETSync(ethost);
writer.open(file);
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioEventList.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioEventList.java
deleted file mode 100644
index b96378a8b6..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioEventList.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.jlab.io.evio;
-
-import org.jlab.io.base.DataEvent;
-import org.jlab.io.base.DataEventList;
-
-public class EvioEventList implements DataEventList {
-
- public int getSize() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public DataEvent getEvent(int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioFactory.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioFactory.java
index ea20698997..e4d0d94264 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioFactory.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioFactory.java
@@ -1,20 +1,9 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
package org.jlab.io.evio;
-import java.io.File;
-import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-import java.security.NoSuchAlgorithmException;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.TransformerException;
import org.jlab.coda.jevio.DataType;
import org.jlab.coda.jevio.EventBuilder;
import org.jlab.coda.jevio.EvioBank;
@@ -23,7 +12,6 @@
import org.jlab.io.base.DataDescriptor;
import org.jlab.io.base.DataEntryType;
import org.jlab.utils.CLASResources;
-import org.xml.sax.SAXException;
/**
*
@@ -36,7 +24,6 @@ public class EvioFactory {
public static EvioDataDictionary readDefaultDictionary(){
EvioDataDictionary dict = new EvioDataDictionary();
- //return dict;
String clasDictionaryPath = CLASResources.getResourcePath("etc/bankdefs/clas12");
if(clasDictionaryPath!=null){
dict.initWithDir(clasDictionaryPath);
@@ -113,7 +100,6 @@ public static EvioDataBank createEvioBank(String name,int rows){
public static EvioDataEvent createEvioEvent(){
try {
- //EvioEvent baseBank = new EvioEvent(1, DataType.BANK, 0);
EventBuilder builder = new EventBuilder(1,DataType.BANK,0);
EvioEvent event = builder.getEvent();
EvioBank baseBank = new EvioBank(10, DataType.ALSOBANK, 0);
@@ -123,7 +109,6 @@ public static EvioDataEvent createEvioEvent(){
ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
int byteSize = event.getTotalBytes();
- //System.out.println("base bank size = " + byteSize);
ByteBuffer bb = ByteBuffer.allocate(byteSize);
bb.order(byteOrder);
event.write(bb);
@@ -137,7 +122,6 @@ public static EvioDataEvent createEvioEvent(){
}
public static EvioDataBank createEvioBank(String name,DataDescriptor desc,int rows){
- //EvioDataDescriptor desc = (EvioDataDescriptor) EvioFactory.getDictionary().getDescriptor(name);
EvioDataBank bank = new EvioDataBank(desc);
String[] entries = desc.getEntryList();
for(String entry : entries){
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioRingSource.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioRingSource.java
index 4f3822f3da..6b565ad098 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioRingSource.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioRingSource.java
@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.io.evio;
import java.io.File;
@@ -34,11 +29,10 @@
*/
public class EvioRingSource implements DataSource {
- private List eventStore = new ArrayList();
+ private List eventStore = new ArrayList<>();
private int eventStoreMaxCapacity = 500;
private xMsg xmsgServer = null;
-
private boolean createConnection(String host){
boolean result = true;
@@ -52,13 +46,11 @@ private boolean createConnection(String host){
}
} catch (xMsgException ex) {
- //Logger.getLogger(HipoRingSource.class.getName()).log(Level.SEVERE, null, ex);
System.out.println(" >>> connection to server " + host + " : failed");
this.xmsgServer.destroy();
this.xmsgServer = null;
result = false;
}
- //System.out.println("-----> connection estabilished...");
return result;
}
@@ -140,11 +132,7 @@ public DataEvent getNextEvent() {
return null;
}
EvioDataEvent event = this.eventStore.get(0);
- //System.out.println(" >>> success getting event : size = " + eventStore.size());
- //event.show();
this.eventStore.remove(0);
- //System.out.println(" >>> FILO cleanup : size = " + eventStore.size());
- //System.out.println("\n\n");
return event;
}
@@ -171,31 +159,24 @@ public int getCurrentIndex() {
@Override
public DataSourceType getType() {
return DataSourceType.STREAM;
- // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void waitForEvents() {
- // For the Ring source, waiting for the events
}
-
private class MyCallBack implements xMsgCallBack {
@Override
public void callback(xMsgMessage mm) {
-
byte[] data = mm.getData();
String type = mm.getMimeType();
-
System.out.println("\n\n >>>>>> received data : mime " + type);
System.out.println(" >>>>>> received data : size " + data.length);
if(eventStore.size()>>>>> adding event to the store : size = %d \n", eventStore.size());
} else {
- //System.out.printf(" >>>>>> event store is full : size = %d \n", eventStore.size());
}
}
}
@@ -212,7 +193,6 @@ public static void main(String[] args){
while(true){
if(reader.hasEvent()==true){
- //System.out.println("has event");
DataEvent event = reader.getNextEvent();
try {
event.show();
@@ -220,7 +200,6 @@ public static void main(String[] args){
System.out.println("something went wrong");
}
} else {
- //System.out.println("no event");
try {
Thread.sleep(20);
} catch (InterruptedException ex) {
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioSource.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioSource.java
index 9fe9038e09..abadc99fc9 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioSource.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioSource.java
@@ -14,14 +14,13 @@
import org.jlab.io.base.DataSource;
import org.jlab.io.base.DataSourceType;
-public class EvioSource implements DataSource {
+public final class EvioSource implements DataSource {
- Logger LOGGER = Logger.getLogger(EvioSource.class.getName());
- private ByteOrder storeByteOrder = ByteOrder.BIG_ENDIAN;
- private EvioCompactReader evioReader = null;
- private EvioDataEvent evioEvent = null;
- private int currentEvent;
- private int currentFileEntries;
+ static final Logger LOGGER = Logger.getLogger(EvioSource.class.getName());
+ private ByteOrder storeByteOrder = ByteOrder.BIG_ENDIAN;
+ private EvioCompactReader evioReader = null;
+ private int currentEvent;
+ private int currentFileEntries;
@Override
public void close() {
@@ -37,143 +36,138 @@ public ByteBuffer getEventBuffer(int eventNumber, boolean asdf) throws EvioExcep
return evioReader.getEventBuffer(eventNumber, asdf);
}
- public EvioSource() {}
-
- public EvioSource(String filename) {
- this.open(filename);
- }
-
- public void open(File file) {
- this.open(file.getAbsolutePath());
- }
-
- public void open(String filename) {
- try {
- evioReader = new EvioCompactReader(new File(filename));
- currentEvent = 1;
- currentFileEntries = evioReader.getEventCount();
- storeByteOrder = evioReader.getFileByteOrder();
- LOGGER.log(Level.INFO,"****** opened FILE [] ** NEVENTS = " + currentFileEntries + " *******");
- // TODO Auto-generated method stub
- } catch (EvioException ex) {
- Logger.getLogger(EvioSource.class.getName()).log(Level.SEVERE, null, ex);
- } catch (IOException ex) {
- Logger.getLogger(EvioSource.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
-
- public void open(ByteBuffer buff) {
- try {
- evioReader = new EvioCompactReader(buff);
- currentEvent = 1;
- currentFileEntries = evioReader.getEventCount()+1;
- storeByteOrder = evioReader.getFileByteOrder();
- // LOGGER.log(Level.INFO,"****** opened BUFFER [] ** NEVENTS = " + currentFileEntries + " *******");
- } catch (EvioException ex) {
- Logger.getLogger(EvioSource.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
-
- public int getSize() {
- // TODO Auto-generated method stub
- return currentFileEntries;
- }
-
- public DataEventList getEventList(int start, int stop) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public DataEventList getEventList(int nrecords) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void reset() {
- currentEvent = 1;
- }
-
- public int getCurrentIndex() {
- // TODO Auto-generated method stub
- return currentEvent;
- }
-
- public DataEvent getPreviousEvent() {
- if (currentEvent > currentFileEntries || currentEvent == 2)
- return null;
- try {
- currentEvent--;
- currentEvent--;
- ByteBuffer evioBuffer = evioReader.getEventBuffer(currentEvent, true);
- EvioDataEvent event = new EvioDataEvent(evioBuffer.array(), storeByteOrder);
- currentEvent++;
- return event;
- } catch (EvioException ex) {
- Logger.getLogger(EvioSource.class.getName()).log(Level.SEVERE, null, ex);
- }
- return null;
- }
-
- public DataEvent gotoEvent(int index) {
- if (index <= 1 || index > currentFileEntries)
- return null;
- try {
- ByteBuffer evioBuffer = evioReader.getEventBuffer(index, true);
- EvioDataEvent event = new EvioDataEvent(evioBuffer.array(), storeByteOrder);
- currentEvent = index + 1;
- return event;
- } catch (EvioException ex) {
- Logger.getLogger(EvioSource.class.getName()).log(Level.SEVERE, null, ex);
- }
- return null;
- }
-
- public EvioDataEventHandler getNextEventHandler() {
- if (currentEvent > currentFileEntries)
- return null;
- try {
- ByteBuffer evioBuffer = evioReader.getEventBuffer(currentEvent, true);
- EvioDataEventHandler event = new EvioDataEventHandler(evioBuffer.array(), storeByteOrder);
- currentEvent++;
- return event;
- } catch (EvioException ex) {
- Logger.getLogger(EvioSource.class.getName()).log(Level.SEVERE, null, ex);
- }
- return null;
- }
-
- public DataEvent getNextEvent() {
- if (currentEvent > currentFileEntries)
- return null;
- try {
- ByteBuffer evioBuffer = evioReader.getEventBuffer(currentEvent, true);
- EvioDataEvent event = new EvioDataEvent(evioBuffer.array(), storeByteOrder);
- currentEvent++;
- return event;
- } catch (EvioException ex) {
- Logger.getLogger(EvioSource.class.getName()).log(Level.SEVERE, null, ex);
- }
- return null;
- }
- /*
- * public Histogram1D scanTree(String path, int maxevents){ currentEvent = 1; int maxestimate = 5000; if(maxestimate>=maxevents){ maxestimate = maxevents-2; }
- *
- * DataRangeEstimator datae = new DataRangeEstimator(path,100,maxestimate);
- *
- * for(int loop = 0; loop < maxevents; loop++){ DataEvent event = this.getNextEvent(); double[] darray = event.getDouble(path); if(darray!=null){ for(int ndata =
- * 0; ndata < darray.length; ndata++){ datae.fill(darray[ndata]); //System.out.println("--> " + darray[ndata]); } } } //= new Histogram1D();
- * System.out.println("----> bins = " + datae.getHistogram().getAxis().getNbins()); return datae.getHistogram(); }
- */
-
- public boolean hasEvent() {
- if (currentEvent > currentFileEntries)
- return false;
- return true;
- }
-
- public static void main(String[] args) {
-
- }
+ public EvioSource() {}
+
+ public EvioSource(String filename) {
+ this.open(filename);
+ }
+
+ @Override
+ public void open(File file) {
+ this.open(file.getAbsolutePath());
+ }
+
+ @Override
+ public void open(String filename) {
+ try {
+ evioReader = new EvioCompactReader(new File(filename));
+ currentEvent = 1;
+ currentFileEntries = evioReader.getEventCount();
+ storeByteOrder = evioReader.getFileByteOrder();
+ LOGGER.log(Level.INFO, "****** opened FILE [] ** NEVENTS = {0} *******", currentFileEntries);
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioSource.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(EvioSource.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ @Override
+ public void open(ByteBuffer buff) {
+ try {
+ evioReader = new EvioCompactReader(buff);
+ currentEvent = 1;
+ currentFileEntries = evioReader.getEventCount()+1;
+ storeByteOrder = evioReader.getFileByteOrder();
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioSource.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ @Override
+ public int getSize() {
+ return currentFileEntries;
+ }
+
+ @Override
+ public DataEventList getEventList(int start, int stop) {
+ return null;
+ }
+
+ @Override
+ public DataEventList getEventList(int nrecords) {
+ return null;
+ }
+
+ @Override
+ public void reset() {
+ currentEvent = 1;
+ }
+
+ @Override
+ public int getCurrentIndex() {
+ return currentEvent;
+ }
+
+ @Override
+ public DataEvent getPreviousEvent() {
+ if (currentEvent > currentFileEntries || currentEvent == 2)
+ return null;
+ try {
+ currentEvent--;
+ currentEvent--;
+ ByteBuffer evioBuffer = evioReader.getEventBuffer(currentEvent, true);
+ EvioDataEvent event = new EvioDataEvent(evioBuffer.array(), storeByteOrder);
+ currentEvent++;
+ return event;
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioSource.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return null;
+ }
+
+ @Override
+ public DataEvent gotoEvent(int index) {
+ if (index <= 1 || index > currentFileEntries)
+ return null;
+ try {
+ ByteBuffer evioBuffer = evioReader.getEventBuffer(index, true);
+ EvioDataEvent event = new EvioDataEvent(evioBuffer.array(), storeByteOrder);
+ currentEvent = index + 1;
+ return event;
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioSource.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return null;
+ }
+
+ public EvioDataEventHandler getNextEventHandler() {
+ if (currentEvent > currentFileEntries)
+ return null;
+ try {
+ ByteBuffer evioBuffer = evioReader.getEventBuffer(currentEvent, true);
+ EvioDataEventHandler event = new EvioDataEventHandler(evioBuffer.array(), storeByteOrder);
+ currentEvent++;
+ return event;
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioSource.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return null;
+ }
+
+ @Override
+ public DataEvent getNextEvent() {
+ if (currentEvent > currentFileEntries)
+ return null;
+ try {
+ ByteBuffer evioBuffer = evioReader.getEventBuffer(currentEvent, true);
+ EvioDataEvent event = new EvioDataEvent(evioBuffer.array(), storeByteOrder);
+ currentEvent++;
+ return event;
+ } catch (EvioException ex) {
+ Logger.getLogger(EvioSource.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return null;
+ }
+
+ @Override
+ public boolean hasEvent() {
+ return currentEvent <= currentFileEntries;
+ }
+
+ public static void main(String[] args) {
+
+ }
@Override
public DataSourceType getType() {
@@ -182,7 +176,5 @@ public DataSourceType getType() {
@Override
public void waitForEvents() {
- // This method does nothing for source associated with
- // a file.
}
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioTreeBranch.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioTreeBranch.java
index 24963bbd24..ea70120378 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioTreeBranch.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioTreeBranch.java
@@ -1,9 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
package org.jlab.io.evio;
import java.util.ArrayList;
@@ -20,7 +14,6 @@ public class EvioTreeBranch {
private final ArrayList leafNodes = new ArrayList();
-
public EvioTreeBranch(int tag, int num){
branchTag = tag;
branchNumber = num;
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataBank.java b/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataBank.java
index 94caa903b0..b1bd77e0fc 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataBank.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataBank.java
@@ -30,6 +30,7 @@ public Bank getBank(){
return hipoGroup;
}
+ @Override
public String[] getColumnList() {
String[] columns = new String[descriptor.getSchema().getElements()];
for(int i = 0; i < columns.length; i++) columns[i] = descriptor.getSchema().getElementName(i);
@@ -41,6 +42,7 @@ public DataDescriptor getDescriptor() {
return this.descriptor;
}
+ @Override
public double[] getDouble(String path) {
int nrows = this.hipoGroup.getRows();
double[] result = new double[nrows];
@@ -53,18 +55,22 @@ public double getDouble(String path, int index) {
return this.hipoGroup.getDouble(path, index);
}
+ @Override
public void setDouble(String path, double[] arr) {
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public void setDouble(String path, int row, double value) {
hipoGroup.putDouble(path,row,value);
}
+ @Override
public void appendDouble(String path, double[] arr) {
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public float[] getFloat(String path) {
int nrows = this.hipoGroup.getRows();
float[] result = new float[nrows];
@@ -72,22 +78,27 @@ public float[] getFloat(String path) {
return result;
}
+ @Override
public float getFloat(String path, int index) {
return this.hipoGroup.getFloat(path, index);
}
+ @Override
public void setFloat(String path, float[] arr) {
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public void setFloat(String path, int row, float value) {
this.hipoGroup.putFloat(path, row, value);
}
+ @Override
public void appendFloat(String path, float[] arr) {
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public int[] getInt(String path) {
int nrows = this.hipoGroup.getRows();
int[] result = new int[nrows];
@@ -95,22 +106,27 @@ public int[] getInt(String path) {
return result;
}
+ @Override
public int getInt(String path, int index) {
return hipoGroup.getInt(path, index);
}
+ @Override
public void setInt(String path, int[] arr) {
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public void setInt(String path, int row, int value) {
hipoGroup.putInt(path, row, value);
}
+ @Override
public void appendInt(String path, int[] arr) {
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public short[] getShort(String path) {
int nrows = this.hipoGroup.getRows();
short[] result = new short[nrows];
@@ -118,22 +134,27 @@ public short[] getShort(String path) {
return result;
}
+ @Override
public short getShort(String path, int index) {
return hipoGroup.getShort(path, index);
}
+ @Override
public void setShort(String path, short[] arr) {
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public void setShort(String path, int row, short value) {
hipoGroup.putShort(path, row, value);
}
+ @Override
public void appendShort(String path, short[] arr) {
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public long[] getLong(String path) {
int nrows = this.hipoGroup.getRows();
long[] result = new long[nrows];
@@ -141,22 +162,27 @@ public long[] getLong(String path) {
return result;
}
+ @Override
public long getLong(String path, int index) {
return hipoGroup.getLong(path, index);
}
+ @Override
public void setLong(String path, long[] arr) {
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public void setLong(String path, int row, long value) {
hipoGroup.putLong(path, row, value);
}
+ @Override
public void appendLong(String path, long[] arr) {
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public byte[] getByte(String path) {
int nrows = this.hipoGroup.getRows();
byte[] result = new byte[nrows];
@@ -164,43 +190,53 @@ public byte[] getByte(String path) {
return result;
}
+ @Override
public byte getByte(String path, int index) {
return hipoGroup.getByte(path, index);
}
+ @Override
public void setByte(String path, byte[] arr) {
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public void setByte(String path, int row, byte value) {
hipoGroup.putByte(path, row, value);
}
+ @Override
public void appendByte(String path, byte[] arr) {
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public int columns() {
return hipoGroup.getSchema().getElements();
}
+ @Override
public int rows() {
return hipoGroup.getRows();
}
+ @Override
public void show() {
System.out.println(" SHOWING BANK");
this.hipoGroup.show();
}
+ @Override
public void reset() {
}
+ @Override
public void allocate(int rows) {
}
+ @Override
public TableModel getTableModel(String mask) {
return null;
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataDescriptor.java b/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataDescriptor.java
index 69190252c4..f8d504f6ab 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataDescriptor.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataDescriptor.java
@@ -1,16 +1,8 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.io.hipo;
-import java.util.List;
import org.jlab.io.base.DataDescriptor;
-import org.jlab.jnp.hipo.data.HipoNodeType;
import org.jlab.jnp.hipo4.data.Schema;
-
/**
*
* @author gavalian
@@ -20,18 +12,16 @@ public class HipoDataDescriptor implements DataDescriptor {
private Schema hipoSchema = null;
public HipoDataDescriptor(){
-
}
public HipoDataDescriptor(Schema schema){
- //this.init(schema);
hipoSchema = schema;
}
public final void init(Schema schema){
- // hipoSchema.copy(schema);
}
+ @Override
public void init(String s) {
hipoSchema = Schema.fromJsonString(s);
}
@@ -40,7 +30,6 @@ public void init(String s) {
public String[] getEntryList() {
int elements = hipoSchema.getElements();
String[] entries = new String[elements];
- int counter = 0;
for(int i = 0; i < elements; i++){
entries[i] = hipoSchema.getElementName(i);
}
@@ -55,7 +44,6 @@ public String getXML() {
@Override
public boolean hasEntry(String entry) {
return hipoSchema.hasEntry(entry);
- //return (this.hipoSchema.getEntry(entry)!=null);
}
@Override
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataDictionary.java b/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataDictionary.java
index 5bc60878fd..4915068682 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataDictionary.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataDictionary.java
@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.io.hipo;
import java.util.HashMap;
@@ -17,9 +12,6 @@
import org.jlab.jnp.hipo4.data.Schema;
import org.jlab.jnp.hipo4.data.SchemaFactory;
-
-
-
/**
*
* @author gavalian
@@ -37,11 +29,9 @@ public HipoDataDictionary(){
}
factory.initFromDirectory(envCLAS + "/" + "etc/bankdefs/hipo4");
List entries = factory.getSchemaList();
- //System.out.println(" schema size = " + entries.size());
for(Schema sch : entries){
HipoDataDescriptor desc = new HipoDataDescriptor(sch);
descriptors.put(desc.getName(), desc);
- //System.out.println("name = " + sch.getName() + " desc = " + desc.getName());
}
System.out.println(" >>>>> loading default dictionary : entries = " + descriptors.size());
}
@@ -55,8 +45,6 @@ public void init(String format) {
public String getXML() {
return "";
}
-
-
@Override
public String[] getDescriptorList() {
@@ -80,8 +68,6 @@ public DataBank createBank(String name, int rows) {
Schema schema = descriptors.get(name).getSchema();
Bank bank = new Bank(schema,rows);
HipoDataBank dataBank = new HipoDataBank(bank);
- //Map map = descriptors.get(name).getSchema().createNodeMap(rows);
- //HipoDataBank bank = new HipoDataBank(map,descriptors.get(name).getSchema());
return dataBank;
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataEvent.java b/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataEvent.java
index 5da4ed5265..3019d3222a 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataEvent.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataEvent.java
@@ -1,16 +1,9 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.io.hipo;
import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Map;
import org.jlab.io.base.DataBank;
import org.jlab.io.base.DataDictionary;
import org.jlab.io.base.DataEvent;
@@ -49,8 +42,7 @@ public HipoDataEvent(Event event,SchemaFactory factory){
public Event getHipoEvent(){return this.hipoEvent;}
public void initDictionary(SchemaFactory factory){
- //this.hipoEvent.getSchemaFactory().copy(factory);
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
@Override
@@ -64,7 +56,6 @@ public String[] getBankList() {
existingBanks.add(schema.getName());
}
}
-
String[] list = new String[existingBanks.size()];
for(int i = 0; i < list.length; i++) list[i] = existingBanks.get(i);
return list;
@@ -73,7 +64,6 @@ public String[] getBankList() {
public String[] getColumnList(String bank_name) {
Schema schema = schemaFactory.getSchema(bank_name);
int ncolumns = schemaFactory.getSchema(bank_name).getElements();
- //List columnsList = schemaFactory.getSchema(bank_name).getElements();
String[] columns = new String[ncolumns];
for(int i = 0; i < columns.length; i++) columns[i] = schema.getElementName(i);
return columns;
@@ -89,13 +79,11 @@ public void addSchemaList(List schemaList){
@Override
public DataDictionary getDictionary() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ByteBuffer getEventBuffer() {
- //ByteBuffer buffer = ByteBuffer.wrap(this.hipoEvent.getEventBuffer()
- //buffer.order(ByteOrder.LITTLE_ENDIAN);
return hipoEvent.getEventBuffer();
}
@@ -123,145 +111,86 @@ public boolean hasBank(String name) {
@Override
public DataBank getBank(String bank_name) {
-
Schema schema = schemaFactory.getSchema(bank_name);
-
if(schema!=null){
Bank bank = new Bank(schema);
hipoEvent.read(bank);
HipoDataBank dataBank = new HipoDataBank(bank);
return dataBank;
}
- //HipoDataBank bank = new HipoDataBank();
return null;
}
public void getBank(String bank_name, DataBank bank) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public void setProperty(String property, String value) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public String getProperty(String property) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public double[] getDouble(String path) {
- /*HipoNode node = this.getHipoNodeByPath(path);
- if(node==null){
- System.out.println("\n>>>>> error : getting node failed : " + path);
- return new double[0];
- }
- return node.getDouble();*/
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public void setDouble(String path, double[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public void appendDouble(String path, double[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public float[] getFloat(String path) {
- /* HipoNode node = this.getHipoNodeByPath(path);
- if(node==null){
- System.out.println("\n>>>>> error : getting node failed : " + path);
- return new float[0];
- }
- return node.getFloat();*/
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public void setFloat(String path, float[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public void appendFloat(String path, float[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public int[] getInt(String path) {
- /*HipoNode node = this.getHipoNodeByPath(path);
- if(node==null){
- System.out.println("\n>>>>> error : getting node failed : " + path);
- return new int[0];
- }
- return node.getInt();*/
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public void setInt(String path, int[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public void appendInt(String path, int[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public short[] getShort(String path) {
- /*HipoNode node = this.getHipoNodeByPath(path);
- if(node==null){
- System.out.println("\n>>>>> error : getting node failed : " + path);
- return new short[0];
- }
- return node.getShort();*/
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public void setShort(String path, short[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public void appendShort(String path, short[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
- /* public HipoNode getHipoNodeByPath(String path){
- String[] bank_and_item = path.split("[.]+");
- if(bank_and_item.length<2){
- System.out.println("\n>>>>> error : syntax error in path name : " + path);
- return null;
- }
- Schema schema = this.hipoEvent.getSchemaFactory().getSchema(bank_and_item[0]);
- if(schema==null){
- System.out.println("\n>>>>> error : can not find schema with name : "
- + bank_and_item[0]);
- return null;
- }
-
- SchemaEntry entry = schema.getEntry(bank_and_item[1]);
- if(entry==null){
- System.out.println("\n>>>>> error : schema " + bank_and_item[0] +
- " dose not have an entry with name :"
- + bank_and_item[1]);
- return null;
- }
-
- HipoNode node = hipoEvent.getNode(schema.getGroup(), entry.getId());
- return node;
- }*/
-
public byte[] getByte(String path) {
-
- /*HipoNode node = this.getHipoNodeByPath(path);
- if(node==null){
- System.out.println("\n>>>>> error : getting node failed : " + path);
- return new byte[0];
- }
- return node.getByte();*/
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public void setByte(String path, byte[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public void appendByte(String path, byte[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
public void setType(DataEventType type) {
@@ -273,7 +202,6 @@ public DataEventType getType() {
}
public void show(){
- //this.hipoEvent.show();
this.hipoEvent.scan();
}
@@ -284,8 +212,6 @@ public void showBankByOrder(int order){
@Override
public DataBank createBank(String bank_name, int rows) {
- //System.out.println(" CREATING BANK = " + bank_name);
-
Schema schema = schemaFactory.getSchema(bank_name);
if(schema ==null) {
System.out.println(" SCHEMA FOR ["+bank_name + "] = NULL");
@@ -296,24 +222,8 @@ public DataBank createBank(String bank_name, int rows) {
System.out.println("\t ----> " + sc);
}
}
- //System.out.println("SCHEMA = " + schema.getName());
-
- Bank bank = new Bank(schema,rows);
-
- HipoDataBank dataBank = new HipoDataBank(bank);
- return dataBank;
- /*
- if(this.hipoEvent.getSchemaFactory().hasSchema(bank_name)==false){
- System.out.println(">>>>> error : descriptor not found : " + bank_name);
- System.out.println(">>>>> error : number of descriptors : " +
- hipoEvent.getSchemaFactory().getSchemaList().size());
- System.out.println();
- this.hipoEvent.getSchemaFactory().show();
- return null;
- }
- HipoGroup group = this.hipoEvent.getSchemaFactory().getSchema(bank_name).createGroup(rows);
- HipoDataBank bank = new HipoDataBank(group);
- return bank;*/
+ Bank bank = new Bank(schema,rows);
+ return new HipoDataBank(bank);
}
@Override
@@ -329,7 +239,6 @@ public void removeBanks(String... bankNames) {
for(String bank : bankNames){
removeBank(bank);
}
- //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
@@ -343,16 +252,16 @@ public long[] getLong(String path) {
long[] data = new long[size];
for(int i =0; i < data.length; i++) data[i] = node.getLong(i);
return data;*/
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setLong(String path, long[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void appendLong(String path, long[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataSync.java b/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataSync.java
index 412920ee69..c401daaaa0 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataSync.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataSync.java
@@ -3,26 +3,21 @@
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
-
import org.jlab.io.base.DataEvent;
import org.jlab.io.base.DataSync;
-
-
import org.jlab.io.base.DataBank;
import org.jlab.jnp.hipo4.data.Event;
import org.jlab.jnp.hipo4.data.Schema;
import org.jlab.jnp.hipo4.data.SchemaFactory;
-import org.jlab.jnp.hipo4.io.HipoWriter;
import org.jlab.jnp.hipo4.io.HipoWriterSorted;
-
/**
*
* @author gavalian
*/
public class HipoDataSync implements DataSync {
- public static Logger LOGGER = Logger.getLogger(HipoDataSync.class.getName());
+ public static final Logger LOGGER = Logger.getLogger(HipoDataSync.class.getName());
HipoWriterSorted writer = null;
@@ -31,9 +26,7 @@ public HipoDataSync(){
this.writer.setCompressionType(2);
String env = System.getenv("CLAS12DIR");
writer.getSchemaFactory().initFromDirectory(env + "/etc/bankdefs/hipo4");
- LOGGER.log(Level.INFO,"[HipoDataSync] ---> dictionary size = " + writer.getSchemaFactory().getSchemaList().size());
- //this.writer.getSchemaFactory().initFromDirectory("CLAS12DIR", "etc/bankdefs/hipo");
- //this.writer.getSchemaFactory().show();
+ LOGGER.log(Level.INFO, "[HipoDataSync] ---> dictionary size = {0}", writer.getSchemaFactory().getSchemaList().size());
}
public HipoDataSync(SchemaFactory factory){
@@ -47,13 +40,6 @@ public HipoDataSync(SchemaFactory factory){
@Override
public void open(String file) {
- /*
- EvioDataDictionary dict = EvioFactory.getDictionary();
- String[] descList = dict.getDescriptorList();
- for(String desc : descList){
- String descString = dict.getDescriptor(desc).toString();
- this.writer.addHeader(descString);
- }*/
this.writer.open(file);
}
@@ -67,7 +53,6 @@ public void addSchemaList(List schemaList){
@Override
public void writeEvent(DataEvent event) {
- //EvioDataEvent evioEvent = (EvioDataEvent) event;
if(event instanceof HipoDataEvent) {
HipoDataEvent hipoEvent = (HipoDataEvent) event;
@@ -76,6 +61,7 @@ public void writeEvent(DataEvent event) {
}
public HipoWriterSorted getWriter(){ return writer;}
+ @Override
public void close() {
this.writer.close();
}
@@ -116,79 +102,10 @@ public static void main(String[] args){
bank.setInt("TDCL", k, (int) (Math.random()*3000) );
bank.setInt("TDCR", k, (int) (Math.random()*3000) );
}
- //bank.show();
event.appendBanks(bank,bankDC);
writer.writeEvent(event);
}
writer.close();
- /*
- if(args.length<3){
- HipoDataSync.printUsage();
- System.exit(0);
- }
-
- if(args[0].startsWith("-")==false){
- System.out.println("\n\n--> please provide compression type");
- HipoDataSync.printUsage();
- System.exit(0);
- }
-
- int compressionType = -1;
-
- if(args[0].compareTo("-u")==0){
- compressionType = 0;
- }
-
- if(args[0].compareTo("-gzip")==0){
- compressionType = 1;
- }
-
- if(args[0].compareTo("-lz4")==0){
- compressionType = 2;
- }
-
- if(compressionType<0){
- HipoDataSync.printUsage();
- System.out.println("[error] ---> compression type string is invalid.");
- System.exit(0);
- }
-
- String outputFile = args[1];
- List inputFiles = new ArrayList();
-
- for(int i = 2; i < args.length; i++){
- inputFiles.add(args[i]);
- }
-
- File outFile = new File(outputFile);
-
- if(outFile.exists()==true){
- System.out.println("\n[error] ---> can not overwrite existing file.\n\n");
- System.exit(0);
- }
-
- HipoDataSync writer = new HipoDataSync();
- writer.setCompressionType(compressionType);
- writer.open(outputFile);
- for(String inFile : inputFiles){
- EvioSource reader = new EvioSource();
- reader.open(inFile);
- while(reader.hasEvent()){
- EvioDataEvent event = (EvioDataEvent) reader.getNextEvent();
-
- EvioDataBank bankFTOF = EvioHipoEvent.getBankFTOF(event);
- EvioDataEvent cevent = EvioFactory.createEvioEvent();
- cevent.appendBank(bankFTOF);
- if(event.hasBank("TimeBasedTrkg::TBTracks")==true){
- EvioDataBank bankTRK = (EvioDataBank) event.getBank("TimeBasedTrkg::TBTracks");
- cevent.appendBanks(bankTRK);
- }
-
- writer.writeEvent(cevent);
- //writer.writeEvent(event);
- }
- }
- writer.close();*/
}
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoRingSource.java b/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoRingSource.java
index a10b972047..2f5fa64d2a 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoRingSource.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoRingSource.java
@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.io.hipo;
import java.io.File;
@@ -35,44 +30,12 @@
*/
public class HipoRingSource implements DataSource {
- private List eventStore = new ArrayList();
+ private List eventStore = new ArrayList<>();
private int eventStoreMaxCapacity = 500;
private SchemaFactory dictionary = new SchemaFactory();
private xMsg xmsgServer = null;
-
-
public HipoRingSource(String host){
- /*
- super("DataSource",
- new xMsgProxyAddress(host, xMsgConstants.DEFAULT_PORT),
- new xMsgRegAddress(host, xMsgConstants.REGISTRAR_PORT),
- 2);
- final String domain = "clas12-domain";
- final String subject = "clas12-data";
- final String type = "data";
- final String description = "clas12 data distribution ring";
-
- xMsgTopic topic = xMsgTopic.build(domain, subject, type);
-
- try {
- // Register this subscriber
- register(xMsgRegInfo.subscriber(topic, description));
- } catch (xMsgException ex) {
- Logger.getLogger(HipoRingSource.class.getName()).log(Level.SEVERE, null, ex);
- }
-
- try {
- // Subscribe to default proxy
- subscribe(topic, new MyCallBack());
- } catch (xMsgException ex) {
- Logger.getLogger(HipoRingSource.class.getName()).log(Level.SEVERE, null, ex);
- }
- System.out.printf("Subscribed to = %s%n", topic);
-
- this.dictionary.initFromDirectory("CLAS12DIR", "etc/bankdefs/hipo");
- */
-
String envCLAS = System.getenv("CLAS12DIR");
dictionary.initFromDirectory(envCLAS + "/etc/bankdefs/hipo4");
}
@@ -121,7 +84,7 @@ public static HipoRingSource createSource(){
@Override
public boolean hasEvent() {
- return (eventStore.size()>0);
+ return !eventStore.isEmpty();
}
@Override
@@ -141,13 +104,11 @@ private boolean createConnection(String host){
}
} catch (xMsgException ex) {
- //Logger.getLogger(HipoRingSource.class.getName()).log(Level.SEVERE, null, ex);
System.out.println(" >>> connection to server " + host + " : failed");
this.xmsgServer.destroy();
this.xmsgServer = null;
result = false;
}
- //System.out.println("-----> connection estabilished...");
return result;
}
@@ -187,12 +148,11 @@ public void open(String filename) {
}
System.out.println(" >>> subscription to topic : success\n\n");
- //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void open(ByteBuffer buff) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
@Override
@@ -202,26 +162,21 @@ public int getSize() {
@Override
public DataEventList getEventList(int start, int stop) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public DataEventList getEventList(int nrecords) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public DataEvent getNextEvent() {
- //System.out.println(" >>> get next event : size = " + eventStore.size());
if(eventStore.isEmpty()){
return null;
}
HipoDataEvent event = this.eventStore.get(0);
- //System.out.println(" >>> success getting event : size = " + eventStore.size());
- //event.show();
this.eventStore.remove(0);
- //System.out.println(" >>> FILO cleanup : size = " + eventStore.size());
- //System.out.println("\n\n");
return event;
}
@@ -245,7 +200,7 @@ public int getCurrentIndex() {
return 0;
}
-
+ @Override
public void close() {
/*try {
this.getConnection().close();
@@ -257,7 +212,6 @@ public void close() {
@Override
public DataSourceType getType() {
return DataSourceType.STREAM;
- //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
@@ -269,15 +223,10 @@ private class MyCallBack implements xMsgCallBack {
@Override
public void callback(xMsgMessage mm) {
byte[] data = mm.getData();
- String type = mm.getMimeType();
- //System.out.println("\n\n >>>>>> received data : mime " + type);
- //System.out.println(" >>>>>> received data : size " + data.length);
if(eventStore.size()>>>>> adding event to the store : size = %d \n", eventStore.size());
} else {
- //System.out.printf(" >>>>>> event store is full : size = %d \n", eventStore.size());
}
}
}
@@ -294,7 +243,6 @@ public static void main(String[] args){
while(true){
if(reader.hasEvent()==true){
- //System.out.println("has event");
DataEvent event = reader.getNextEvent();
try {
event.show();
@@ -302,7 +250,6 @@ public static void main(String[] args){
System.out.println("something went wrong");
}
} else {
- //System.out.println("no event");
try {
Thread.sleep(20);
} catch (InterruptedException ex) {
@@ -310,32 +257,5 @@ public static void main(String[] args){
}
}
}
- //reader.open("localhost");
- /*
- OptionParser parser = new OptionParser();
- parser.addRequired("-s");
-
-
- HipoRingSource reader = HipoRingSource.createSource();
-
- while(reader.hasEvent()==true){
-
- HipoDataEvent event = (HipoDataEvent) reader.getNextEvent();
- //event.show();
-
- try {
- Thread.sleep(8000);
- } catch (InterruptedException ex) {
- Logger.getLogger(HipoRingSource.class.getName()).log(Level.SEVERE, null, ex);
- }
-
- }
- System.out.println("DONE");
- */
- /*
- String host = args[0];
- try (HipoRingSource subscriber = new HipoRingSource(host)) {
- xMsgUtil.keepAlive();
- } */
}
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataBank.java b/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataBank.java
deleted file mode 100644
index 7ad0492691..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataBank.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.hipo3;
-
-import java.util.List;
-import java.util.Map;
-import javax.swing.table.TableModel;
-
-import org.jlab.io.base.DataBank;
-import org.jlab.io.base.DataDescriptor;
-import org.jlab.jnp.hipo.data.HipoGroup;
-import org.jlab.jnp.hipo.data.HipoNode;
-import org.jlab.jnp.hipo.schema.Schema;
-
-/**
- *
- * @author gavalian
- */
-public class Hipo3DataBank implements DataBank {
-
- private Hipo3DataDescriptor descriptor = null;
- private HipoGroup hipoGroup = null;
-
- public Hipo3DataBank(Hipo3DataDescriptor desc, int size){
- Map nodes = desc.getSchema().createNodeMap(size);
- this.descriptor = desc;
- hipoGroup = new HipoGroup(nodes,this.descriptor.getSchema());
- }
-
- public Hipo3DataBank(Map nodes, Schema desc){
- descriptor = new Hipo3DataDescriptor();
- descriptor.init(desc);
- hipoGroup = new HipoGroup(nodes,this.descriptor.getSchema());
- }
-
- public Hipo3DataBank(HipoGroup group){
- this.hipoGroup = group;
- descriptor = new Hipo3DataDescriptor();
- descriptor.init(this.hipoGroup.getSchema());
- }
-
- public HipoGroup getGroup(){
- return this.hipoGroup;
- }
-
- public String[] getColumnList() {
- List columnsList = this.hipoGroup.getSchema().schemaEntryList();
- String[] columns = new String[columnsList.size()];
- for(int i = 0; i < columns.length; i++) columns[i] = columnsList.get(i);
- return columns;
- }
-
- public DataDescriptor getDescriptor() {
- return this.descriptor;
- }
-
- public double[] getDouble(String path) {
- return this.hipoGroup.getNode(path).getDouble();
- }
-
- public double getDouble(String path, int index) {
- return this.hipoGroup.getNode(path).getDouble(index);
- }
-
- public void setDouble(String path, double[] arr) {
- //this.getNode(path).setDouble(index, value);
- }
-
- public void setDouble(String path, int row, double value) {
- this.hipoGroup.getNode(path).setDouble(row, value);
- }
-
- public void appendDouble(String path, double[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public float[] getFloat(String path) {
- return this.hipoGroup.getNode(path).getFloat();
- }
-
- public float getFloat(String path, int index) {
- return this.hipoGroup.getNode(path).getFloat(index);
- }
-
- public void setFloat(String path, float[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public void setFloat(String path, int row, float value) {
- this.hipoGroup.getNode(path).setFloat(row, value);
- }
-
- public void appendFloat(String path, float[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public int[] getInt(String path) {
- return this.getGroup().getNode(path).getInt();
- }
-
- public int getInt(String path, int index) {
- return this.hipoGroup.getNode(path).getInt(index);
- }
-
- public void setInt(String path, int[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public void setInt(String path, int row, int value) {
- this.hipoGroup.getNode(path).setInt(row, value);
- }
-
- public void appendInt(String path, int[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public short[] getShort(String path) {
- return this.hipoGroup.getNode(path).getShort();
- }
-
- public short getShort(String path, int index) {
- return this.hipoGroup.getNode(path).getShort(index);
- }
-
- public void setShort(String path, short[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public void setShort(String path, int row, short value) {
- this.hipoGroup.getNode(path).setShort(row, value);
- }
-
- public void appendShort(String path, short[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public long[] getLong(String path) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public long getLong(String path, int index) {
- return this.hipoGroup.getNode(path).getLong(index);
- }
-
- public void setLong(String path, long[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public void setLong(String path, int row, long value) {
- this.hipoGroup.getNode(path).setLong(row, value);
- }
-
- public void appendLong(String path, long[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public byte[] getByte(String path) {
- return this.hipoGroup.getNode(path).getByte();
- }
-
- public byte getByte(String path, int index) {
- return this.hipoGroup.getNode(path).getByte(index);
- }
-
- public void setByte(String path, byte[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public void setByte(String path, int row, byte value) {
- this.hipoGroup.getNode(path).setByte(row, value);
- }
-
- public void appendByte(String path, byte[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public int columns() {
- return this.hipoGroup.getSchema().getEntries();
- }
-
- public int rows() {
- return this.hipoGroup.getMaxSize();
- }
-
- public void show() {
- System.out.println(" SHOWING BANK");
- this.hipoGroup.show();
- }
-
- public void reset() {
-
- }
-
- public void allocate(int rows) {
-
- }
-
- public TableModel getTableModel(String mask) {
- return null;
- }
-
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataDescriptor.java b/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataDescriptor.java
deleted file mode 100644
index bf640195dc..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataDescriptor.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.hipo3;
-
-import java.util.List;
-import org.jlab.io.base.DataDescriptor;
-import org.jlab.jnp.hipo.data.HipoNodeType;
-import org.jlab.jnp.hipo.schema.Schema;
-import org.jlab.jnp.hipo.schema.Schema.SchemaEntry;
-
-/**
- *
- * @author gavalian
- */
-public class Hipo3DataDescriptor implements DataDescriptor {
-
- private final Schema hipoSchema = new Schema();
-
- public Hipo3DataDescriptor(){
-
- }
-
- public Hipo3DataDescriptor(Schema schema){
- this.init(schema);
- }
-
- public final void init(Schema schema){
- hipoSchema.copy(schema);
- }
-
- public void init(String s) {
- this.hipoSchema.setFromText(s);
- }
-
- @Override
- public String[] getEntryList() {
- List entryList = hipoSchema.schemaEntryList();
- String[] entries = new String[entryList.size()];
- int counter = 0;
- for(int i = 0; i < entryList.size(); i++){
- entries[i] = entryList.get(i);
- }
- return entries;
- }
-
- public String getXML() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public boolean hasEntry(String entry) {
- return (this.hipoSchema.getEntry(entry)!=null);
- }
-
- public boolean hasEntries(String... entries) {
- for(String entry : entries){
- if(hasEntry(entry)==false) return false;
- }
- return true;
- }
-
- public int getProperty(String property_name, String entry_name) {
- if(property_name.compareTo("type")==0){
- SchemaEntry entry = this.hipoSchema.getEntry(entry_name);
- if(entry!=null){
- if(entry.getType()==HipoNodeType.BYTE) return 1;
- if(entry.getType()==HipoNodeType.SHORT) return 2;
- if(entry.getType()==HipoNodeType.INT) return 3;
- if(entry.getType()==HipoNodeType.FLOAT) return 5;
- if(entry.getType()==HipoNodeType.DOUBLE) return 6;
- return 0;
- }
- }
- return 0;
- }
-
- public int getProperty(String property_name) {
- return 1;
- }
-
- public void setPropertyString(String name, String value) {
-
- }
-
- public String getPropertyString(String property_name) {
- return "undefined";
- }
-
- public void show() {
- System.out.println(this.hipoSchema.toString());
- }
-
- public String getName() {
- return this.hipoSchema.getName();
- }
-
- public Schema getSchema(){ return this.hipoSchema;}
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataDictionary.java b/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataDictionary.java
deleted file mode 100644
index eda645009e..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataDictionary.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.hipo3;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jlab.io.base.DataBank;
-import org.jlab.io.base.DataDescriptor;
-import org.jlab.io.base.DataDictionary;
-import org.jlab.jnp.hipo.data.HipoNode;
-import org.jlab.jnp.hipo.schema.Schema;
-import org.jlab.jnp.hipo.schema.SchemaFactory;
-
-
-/**
- *
- * @author gavalian
- */
-public class Hipo3DataDictionary implements DataDictionary {
-
- private final Map descriptors = new HashMap();
-
- public Hipo3DataDictionary(){
-
- SchemaFactory factory = new SchemaFactory();
- factory.initFromDirectory("CLAS12DIR", "etc/bankdefs/hipo");
- List entries = factory.getSchemaList();
- //System.out.println(" schema size = " + entries.size());
- for(Schema sch : entries){
- Hipo3DataDescriptor desc = new Hipo3DataDescriptor(sch);
- descriptors.put(desc.getName(), desc);
- //System.out.println("name = " + sch.getName() + " desc = " + desc.getName());
- }
- System.out.println(" >>>>> loading default dictionary : entries = " + descriptors.size());
- }
-
- @Override
- public void init(String format) {
- System.out.println("---- INITIALIZATION NOT IMPLEMENTED ----");
- }
-
- @Override
- public String getXML() {
- return "";
- }
-
-
-
- @Override
- public String[] getDescriptorList() {
- Set list = this.descriptors.keySet();
- int counter = 0;
- String[] tokens = new String[list.size()];
- for(String item : list){
- tokens[counter] = item;
- counter++;
- }
- return tokens;
- }
-
- @Override
- public DataDescriptor getDescriptor(String desc_name) {
- return descriptors.get(desc_name);
- }
-
- @Override
- public DataBank createBank(String name, int rows) {
- Map map = descriptors.get(name).getSchema().createNodeMap(rows);
- Hipo3DataBank bank = new Hipo3DataBank(map,descriptors.get(name).getSchema());
- return bank;
- }
-
- public static void main(String[] args){
- System.setProperty("CLAS12DIR", "/Users/gavalian/Work/Software/Release-9.0/COATJAVA/coatjava");
- Hipo3DataDictionary dict = new Hipo3DataDictionary();
-
- String[] list = dict.getDescriptorList();
- for(String item : list){
- System.out.println("---> " + item);
- Hipo3DataDescriptor desc = (Hipo3DataDescriptor) dict.getDescriptor(item);
- String[] entries = desc.getEntryList();
- for(int i = 0; i < entries.length; i++){
- System.out.println("\t\t---> " + entries[i]);
- }
- }
- }
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataEvent.java b/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataEvent.java
deleted file mode 100644
index b1a05fd261..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataEvent.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.hipo3;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import org.jlab.io.base.DataBank;
-import org.jlab.io.base.DataDictionary;
-import org.jlab.io.base.DataEvent;
-import org.jlab.io.base.DataEventType;
-import org.jlab.jnp.hipo.data.HipoEvent;
-import org.jlab.jnp.hipo.data.HipoGroup;
-import org.jlab.jnp.hipo.data.HipoNode;
-import org.jlab.jnp.hipo.schema.Schema;
-import org.jlab.jnp.hipo.schema.Schema.SchemaEntry;
-import org.jlab.jnp.hipo.schema.SchemaFactory;
-
-/**
- *
- * @author gavalian
- */
-public class Hipo3DataEvent implements DataEvent {
-
- private HipoEvent hipoEvent = null;
- private DataEventType eventType = DataEventType.EVENT_ACCUMULATE;
-
- public Hipo3DataEvent(byte[] array, SchemaFactory factory){
- hipoEvent = new HipoEvent(array,factory);
- }
-
- public Hipo3DataEvent(HipoEvent event){
- this.hipoEvent = event;
- }
-
- public HipoEvent getHipoEvent(){return this.hipoEvent;}
-
- public void initDictionary(SchemaFactory factory){
- this.hipoEvent.getSchemaFactory().copy(factory);
- }
-
- @Override
- public String[] getBankList() {
- List schemaList = hipoEvent.getSchemaFactory().getSchemaList();
- List existingBanks = new ArrayList();
- for(Schema schema : schemaList){
- int group = schema.getGroup();
- if(hipoEvent.hasGroup(group)==true){
- existingBanks.add(schema.getName());
- }
- }
-
- String[] list = new String[existingBanks.size()];
- for(int i = 0; i < list.length; i++) list[i] = existingBanks.get(i);
- return list;
- }
-
- public String[] getColumnList(String bank_name) {
- List columnsList = this.hipoEvent.getSchemaFactory().getSchema(bank_name).schemaEntryList();
- String[] columns = new String[columnsList.size()];
- for(int i = 0; i < columns.length; i++) columns[i] = columnsList.get(i);
- return columns;
- }
-
- public DataDictionary getDictionary() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public ByteBuffer getEventBuffer() {
- ByteBuffer buffer = ByteBuffer.wrap(this.hipoEvent.getDataBuffer());
- buffer.order(ByteOrder.LITTLE_ENDIAN);
- return buffer;
- }
-
- public void appendBank(DataBank bank) {
- if(bank==null) return;
- if(bank instanceof Hipo3DataBank){
- HipoGroup group = ((Hipo3DataBank) bank).getGroup();
- hipoEvent.writeGroup(group);
- }
- }
-
- public void appendBanks(DataBank... bank) {
- for(DataBank item : bank){
- this.appendBank(item);
- }
- }
-
- @Override
- public boolean hasBank(String name) {
- return (this.hipoEvent.hasGroup(name));
- }
-
- @Override
- public DataBank getBank(String bank_name) {
- if(this.hipoEvent.getSchemaFactory().hasSchema(bank_name)==true){
- //Schema schema = this.hipoEvent.getSchemaFactory().getSchema(bank_name);
- //Map map = this.hipoEvent.getGroup(schema.getGroup());
- HipoGroup group = hipoEvent.getGroup(bank_name);
- Hipo3DataBank bank = new Hipo3DataBank(group.getNodesMap(),group.getSchema());
- return bank;
- }
- //HipoDataBank bank = new HipoDataBank();
- return null;
- }
-
- public void getBank(String bank_name, DataBank bank) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public void setProperty(String property, String value) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public String getProperty(String property) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public double[] getDouble(String path) {
- HipoNode node = this.getHipoNodeByPath(path);
- if(node==null){
- System.out.println("\n>>>>> error : getting node failed : " + path);
- return new double[0];
- }
- return node.getDouble();
- //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public void setDouble(String path, double[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public void appendDouble(String path, double[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public float[] getFloat(String path) {
- HipoNode node = this.getHipoNodeByPath(path);
- if(node==null){
- System.out.println("\n>>>>> error : getting node failed : " + path);
- return new float[0];
- }
- return node.getFloat();
- //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public void setFloat(String path, float[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public void appendFloat(String path, float[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public int[] getInt(String path) {
- HipoNode node = this.getHipoNodeByPath(path);
- if(node==null){
- System.out.println("\n>>>>> error : getting node failed : " + path);
- return new int[0];
- }
- return node.getInt();
- }
-
- public void setInt(String path, int[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public void appendInt(String path, int[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public short[] getShort(String path) {
- HipoNode node = this.getHipoNodeByPath(path);
- if(node==null){
- System.out.println("\n>>>>> error : getting node failed : " + path);
- return new short[0];
- }
- return node.getShort();
- }
-
- public void setShort(String path, short[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public void appendShort(String path, short[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public HipoNode getHipoNodeByPath(String path){
- String[] bank_and_item = path.split("[.]+");
- if(bank_and_item.length<2){
- System.out.println("\n>>>>> error : syntax error in path name : " + path);
- return null;
- }
- Schema schema = this.hipoEvent.getSchemaFactory().getSchema(bank_and_item[0]);
- if(schema==null){
- System.out.println("\n>>>>> error : can not find schema with name : "
- + bank_and_item[0]);
- return null;
- }
-
- SchemaEntry entry = schema.getEntry(bank_and_item[1]);
- if(entry==null){
- System.out.println("\n>>>>> error : schema " + bank_and_item[0] +
- " dose not have an entry with name :"
- + bank_and_item[1]);
- return null;
- }
-
- HipoNode node = hipoEvent.getNode(schema.getGroup(), entry.getId());
- return node;
- }
-
- public byte[] getByte(String path) {
- HipoNode node = this.getHipoNodeByPath(path);
- if(node==null){
- System.out.println("\n>>>>> error : getting node failed : " + path);
- return new byte[0];
- }
- return node.getByte();
- }
-
- public void setByte(String path, byte[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public void appendByte(String path, byte[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public void setType(DataEventType type) {
- this.eventType = type;
- }
-
- public DataEventType getType() {
- return this.eventType;
- }
-
- public void show(){
- this.hipoEvent.show();
- }
-
- public void showBankByOrder(int order){
- this.hipoEvent.showGroupByOrder(order);
- }
-
- @Override
- public DataBank createBank(String bank_name, int rows) {
- if(this.hipoEvent.getSchemaFactory().hasSchema(bank_name)==false){
- System.out.println(">>>>> error : descriptor not found : " + bank_name);
- System.out.println(">>>>> error : number of descriptors : " +
- hipoEvent.getSchemaFactory().getSchemaList().size());
- System.out.println();
- this.hipoEvent.getSchemaFactory().show();
- return null;
- }
- HipoGroup group = this.hipoEvent.getSchemaFactory().getSchema(bank_name).createGroup(rows);
- Hipo3DataBank bank = new Hipo3DataBank(group);
- return bank;
- }
-
- @Override
- public void removeBank(String bankName) {
- this.hipoEvent.removeGroup(bankName);
- }
-
- @Override
- public void removeBanks(String... bankNames) {
-
- //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public long[] getLong(String path) {
- HipoNode node = this.getHipoNodeByPath(path);
- if(node==null){
- System.out.println("\n>>>>> error : getting node failed : " + path);
- return new long[0];
- }
- int size = node.getDataSize();
- long[] data = new long[size];
- for(int i =0; i < data.length; i++) data[i] = node.getLong(i);
- return data;
- }
-
- @Override
- public void setLong(String path, long[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void appendLong(String path, long[] arr) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataSource.java b/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataSource.java
deleted file mode 100644
index 732c9aac95..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataSource.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.hipo3;
-
-import java.io.File;
-import java.nio.ByteBuffer;
-import org.jlab.io.base.DataEvent;
-import org.jlab.io.base.DataEventList;
-import org.jlab.io.base.DataEventType;
-import org.jlab.io.base.DataSource;
-import org.jlab.io.evio.EvioDataDictionary;
-import org.jlab.io.base.DataSourceType;
-import org.jlab.jnp.hipo.data.HipoEvent;
-import org.jlab.jnp.hipo.io.HipoReader;
-import org.jlab.jnp.hipo.schema.SchemaFactory;
-
-/**
- *
- * @author gavalian
- */
-public class Hipo3DataSource implements DataSource {
-
- HipoReader reader = null;
- EvioDataDictionary dictionary = new EvioDataDictionary();
- int numberOfRecords = 0;
- int currentEventNumber = 0;
- int minEventNumber = 0;
- int numberOfEvent = 0;
-
- public Hipo3DataSource(){
- this.reader = new HipoReader();
- }
-
- @Override
- public boolean hasEvent() {
- return reader.hasNext();
- }
-
- @Override
- public void open(File file) {
- this.open(file.getAbsolutePath());
- }
- /**
- * Creates a Writer class with Dictionary from the Reader.
- * This method should be used when filtering the input file
- * to ensure consistency of dictionaries and banks in the output.
- * @return HipoDataSync object for writing an output.
- */
- public Hipo3DataSync createWriter(){
- SchemaFactory factory = reader.getSchemaFactory();
- Hipo3DataSync writer = new Hipo3DataSync(factory);
- return writer;
- }
-
- @Override
- public void open(String filename) {
- this.reader.open(filename);
- System.out.println("[DataSourceDump] --> opened file with events # " + this.reader.getEventCount());
- //this.reader.getSchemaFactory().show();
- /*
- HipoRecord header = this.reader.getHeaderRecord();
- int ncount = header.getEventCount();
- System.out.println("[HipoDataSource] ---> dictionary record opened. # entries = " + ncount);
- for(int ev = 0; ev < ncount; ev++){
- byte[] descBytes = header.getEvent(ev);
- String descString = new String(descBytes);
- //System.out.println("init dictionary : " + descString);
- EvioDataDescriptor descriptor = new EvioDataDescriptor(descString);
- this.dictionary.addDescriptor(descriptor);
- }*/
- //this.dictionary.show();
- /*this.minEventNumber = 0;
- this.currentEventNumber = 0;
- this.numberOfEvent = this.reader.getEventCount();*/
- }
-
- public void open(ByteBuffer buff) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- public void close() {
-
- }
-
- @Override
- public int getSize() {
- return reader.getEventCount();
- }
-
- @Override
- public DataEventList getEventList(int start, int stop) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public DataEventList getEventList(int nrecords) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public DataEvent getNextEvent() {
- HipoEvent hipoEvent = reader.readNextEvent();
- /*hipoEvent.getDataBuffer();
- System.out.println(" GET NEXT HIPO EVENT : DICTIONARY SIZE = " +
- hipoEvent.getSchemaFactory().getSchemaList().size() + " EVENT LENGTH = "
- + hipoEvent.getDataBuffer().length);
- hipoEvent.showNodes();*/
- Hipo3DataEvent evioEvent = new Hipo3DataEvent(hipoEvent.getDataBuffer(),hipoEvent.getSchemaFactory());
- if(reader.hasNext()==true){
- evioEvent.setType(DataEventType.EVENT_ACCUMULATE);
- } else {
- evioEvent.setType(DataEventType.EVENT_STOP);
- }
- return evioEvent;
- }
-
- @Override
- public DataEvent getPreviousEvent() {
- HipoEvent hipoEvent = reader.readPreviousEvent();
- hipoEvent.getDataBuffer();
- Hipo3DataEvent evioEvent = new Hipo3DataEvent(hipoEvent.getDataBuffer(),hipoEvent.getSchemaFactory());
- return evioEvent;
-
- }
-
- @Override
- public DataEvent gotoEvent(int index) {
- HipoEvent hipoEvent = reader.readEvent(index);
- hipoEvent.getDataBuffer();
- Hipo3DataEvent evioEvent = new Hipo3DataEvent(hipoEvent.getDataBuffer(),hipoEvent.getSchemaFactory());
- return evioEvent;
- }
-
- @Override
- public void reset() {
- this.currentEventNumber = 0;
- }
-
- @Override
- public int getCurrentIndex() {
- return this.currentEventNumber;
- }
-
- public static void main(String[] args){
- Hipo3DataSource reader = new Hipo3DataSource();
- reader.open("test_hipoio.hipo");
- int counter = 0;
- while(reader.hasEvent()==true){
- DataEvent event = reader.getNextEvent();
- System.out.println("EVENT # " + counter);
- event.show();
- counter++;
- }
- }
-
- @Override
- public DataSourceType getType() {
- return DataSourceType.FILE;
- //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void waitForEvents() {
-
- }
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataSync.java b/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataSync.java
deleted file mode 100644
index afa2d9b5cb..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3DataSync.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.hipo3;
-
-import org.jlab.io.base.DataEvent;
-import org.jlab.io.base.DataSync;
-
-
-import org.jlab.io.base.DataBank;
-import org.jlab.io.evio.EvioDataBank;
-import org.jlab.jnp.hipo.data.HipoEvent;
-import org.jlab.jnp.hipo.io.HipoWriter;
-import org.jlab.jnp.hipo.schema.SchemaFactory;
-
-/**
- *
- * @author gavalian
- */
-public class Hipo3DataSync implements DataSync {
-
- HipoWriter writer = null;
-
- public Hipo3DataSync(){
- this.writer = new HipoWriter();
- this.writer.setCompressionType(2);
- writer.appendSchemaFactoryFromDirectory("CLAS12DIR", "etc/bankdefs/hipo");
- System.out.println("[HipoDataSync] ---> dictionary size = " + writer.getSchemaFactory().getSchemaList().size());
- //this.writer.getSchemaFactory().initFromDirectory("CLAS12DIR", "etc/bankdefs/hipo");
- //this.writer.getSchemaFactory().show();
- }
-
- public Hipo3DataSync(SchemaFactory factory){
- this.writer = new HipoWriter();
- this.writer.setCompressionType(2);
- writer.appendSchemaFactory(factory);
- }
-
- @Override
- public void open(String file) {
- /*
- EvioDataDictionary dict = EvioFactory.getDictionary();
- String[] descList = dict.getDescriptorList();
- for(String desc : descList){
- String descString = dict.getDescriptor(desc).toString();
- this.writer.addHeader(descString);
- }*/
- this.writer.open(file);
- }
-
- @Override
- public void writeEvent(DataEvent event) {
- //EvioDataEvent evioEvent = (EvioDataEvent) event;
- if(event instanceof Hipo3DataEvent) {
- Hipo3DataEvent hipoEvent = (Hipo3DataEvent) event;
- this.writer.writeEvent(hipoEvent.getHipoEvent());
- }
- }
-
- public void close() {
- this.writer.close();
- }
-
- public void setCompressionType(int type){
- this.writer.setCompressionType(type);
- }
-
- public DataEvent createEvent() {
- HipoEvent event = this.writer.createEvent();
- return new Hipo3DataEvent(event);
- }
-
- public static void printUsage(){
- System.out.println("\tUsage: convert -[option] output.hipo input.evio [input2.evio] [input3.evio]");
- System.out.println("\n\t Options :");
- System.out.println("\t\t -u : uncompressed");
- System.out.println("\t\t -gzip : gzip compression");
- System.out.println("\t\t -lz4 : lz4 compression");
- System.out.println("\n");
- }
-
- public static void main(String[] args){
-
- Hipo3DataSync writer = new Hipo3DataSync();
- writer.open("test_hipoio.hipo");
- for(int i = 0; i < 20; i++){
- DataEvent event = writer.createEvent();
- DataBank bank = event.createBank("FTOF::dgtz", 12);
- DataBank bankDC = event.createBank("DC::dgtz", 7);
- for(int k = 0; k < 5; k++){
- bank.setByte("sector", k, (byte) (1+k));
- bank.setByte("layer", k, (byte) (2+k));
- bank.setShort("component", k, (short) (2+k*5));
- bank.setInt("ADCL", k, (int) (Math.random()*3000) );
- bank.setInt("ADCR", k, (int) (Math.random()*3000) );
- bank.setInt("TDCL", k, (int) (Math.random()*3000) );
- bank.setInt("TDCR", k, (int) (Math.random()*3000) );
- }
- //bank.show();
- event.appendBanks(bank,bankDC);
- writer.writeEvent(event);
- }
- writer.close();
- /*
- if(args.length<3){
- HipoDataSync.printUsage();
- System.exit(0);
- }
-
- if(args[0].startsWith("-")==false){
- System.out.println("\n\n--> please provide compression type");
- HipoDataSync.printUsage();
- System.exit(0);
- }
-
- int compressionType = -1;
-
- if(args[0].compareTo("-u")==0){
- compressionType = 0;
- }
-
- if(args[0].compareTo("-gzip")==0){
- compressionType = 1;
- }
-
- if(args[0].compareTo("-lz4")==0){
- compressionType = 2;
- }
-
- if(compressionType<0){
- HipoDataSync.printUsage();
- System.out.println("[error] ---> compression type string is invalid.");
- System.exit(0);
- }
-
- String outputFile = args[1];
- List inputFiles = new ArrayList();
-
- for(int i = 2; i < args.length; i++){
- inputFiles.add(args[i]);
- }
-
- File outFile = new File(outputFile);
-
- if(outFile.exists()==true){
- System.out.println("\n[error] ---> can not overwrite existing file.\n\n");
- System.exit(0);
- }
-
- HipoDataSync writer = new HipoDataSync();
- writer.setCompressionType(compressionType);
- writer.open(outputFile);
- for(String inFile : inputFiles){
- EvioSource reader = new EvioSource();
- reader.open(inFile);
- while(reader.hasEvent()){
- EvioDataEvent event = (EvioDataEvent) reader.getNextEvent();
-
- EvioDataBank bankFTOF = EvioHipoEvent.getBankFTOF(event);
- EvioDataEvent cevent = EvioFactory.createEvioEvent();
- cevent.appendBank(bankFTOF);
- if(event.hasBank("TimeBasedTrkg::TBTracks")==true){
- EvioDataBank bankTRK = (EvioDataBank) event.getBank("TimeBasedTrkg::TBTracks");
- cevent.appendBanks(bankTRK);
- }
-
- writer.writeEvent(cevent);
- //writer.writeEvent(event);
- }
- }
- writer.close();*/
- }
-
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3RingSource.java b/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3RingSource.java
deleted file mode 100644
index bccc050d1e..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/hipo3/Hipo3RingSource.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.hipo3;
-
-import java.io.File;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.swing.JOptionPane;
-import org.jlab.coda.xmsg.core.xMsg;
-import org.jlab.coda.xmsg.core.xMsgCallBack;
-import org.jlab.coda.xmsg.core.xMsgConstants;
-import org.jlab.coda.xmsg.core.xMsgMessage;
-import org.jlab.coda.xmsg.core.xMsgTopic;
-import org.jlab.coda.xmsg.data.xMsgRegInfo;
-import org.jlab.coda.xmsg.excp.xMsgException;
-import org.jlab.coda.xmsg.net.xMsgProxyAddress;
-import org.jlab.coda.xmsg.net.xMsgRegAddress;
-import org.jlab.io.base.DataEvent;
-import org.jlab.io.base.DataEventList;
-import org.jlab.io.base.DataSource;
-import org.jlab.io.base.DataSourceType;
-import org.jlab.jnp.hipo.schema.SchemaFactory;
-import org.jlab.utils.options.OptionParser;
-
-/**
- *
- * @author gavalian
- */
-public class Hipo3RingSource implements DataSource {
-
- private List eventStore = new ArrayList();
- private int eventStoreMaxCapacity = 500;
- private SchemaFactory dictionary = new SchemaFactory();
- private xMsg xmsgServer = null;
-
-
-
- public Hipo3RingSource(String host){
- /*
- super("DataSource",
- new xMsgProxyAddress(host, xMsgConstants.DEFAULT_PORT),
- new xMsgRegAddress(host, xMsgConstants.REGISTRAR_PORT),
- 2);
- final String domain = "clas12-domain";
- final String subject = "clas12-data";
- final String type = "data";
- final String description = "clas12 data distribution ring";
-
- xMsgTopic topic = xMsgTopic.build(domain, subject, type);
-
- try {
- // Register this subscriber
- register(xMsgRegInfo.subscriber(topic, description));
- } catch (xMsgException ex) {
- Logger.getLogger(HipoRingSource.class.getName()).log(Level.SEVERE, null, ex);
- }
-
- try {
- // Subscribe to default proxy
- subscribe(topic, new MyCallBack());
- } catch (xMsgException ex) {
- Logger.getLogger(HipoRingSource.class.getName()).log(Level.SEVERE, null, ex);
- }
- System.out.printf("Subscribed to = %s%n", topic);
-
- this.dictionary.initFromDirectory("CLAS12DIR", "etc/bankdefs/hipo");
- */
- dictionary.initFromDirectory("CLAS12DIR", "etc/bankdefs/hipo");
- }
-
- public Hipo3RingSource(){
- dictionary.initFromDirectory("CLAS12DIR", "etc/bankdefs/hipo");
- }
-
- public static Hipo3RingSource createSourceDaq(){
- String daqHosts = "129.57.167.107:129.57.167.109:129.57.167.226:129.57.167.227:129.57.167.41:129.57.167.60:129.57.68.135";
- Hipo3RingSource reader = new Hipo3RingSource();
- reader.open(daqHosts);
- return reader;
- }
-
- public static Hipo3RingSource createSource(){
- String s = (String)JOptionPane.showInputDialog(
- null,
- "Complete the sentence:\n"
- + "\"Green eggs and...\"",
- "Customized Dialog",
- JOptionPane.PLAIN_MESSAGE,
- null,
- null,
- "0.0.0.0");
- if(s!=null){
- System.out.println("----> connecting to host : " + s);
- Hipo3RingSource source = new Hipo3RingSource();
- source.open(s);
- System.out.println("\n\n");
- System.out.println(" |----> caching connection ---> ");
- for(int i = 0; i < 5; i++){
- try {
- Thread.sleep(1000);
- System.out.println(" |----> caching connection ---- " + source.getSize());
- } catch (InterruptedException ex) {
- Logger.getLogger(Hipo3RingSource.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- return source;
- }
-
- return null;
- }
-
- @Override
- public boolean hasEvent() {
- return (eventStore.size()>0);
- }
-
- @Override
- public void open(File file) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- private boolean createConnection(String host){
- boolean result = true;
- this.xmsgServer = new xMsg("DataSource",
- new xMsgProxyAddress(host, xMsgConstants.DEFAULT_PORT),
- new xMsgRegAddress(host, xMsgConstants.REGISTRAR_PORT),
- 2);
- try {
- if(this.xmsgServer.getConnection()!=null){
- System.out.println(" >>> connection to server " + host + " : success");
- }
-
- } catch (xMsgException ex) {
- //Logger.getLogger(HipoRingSource.class.getName()).log(Level.SEVERE, null, ex);
- System.out.println(" >>> connection to server " + host + " : failed");
- this.xmsgServer.destroy();
- this.xmsgServer = null;
- result = false;
- }
- //System.out.println("-----> connection estabilished...");
- return result;
- }
-
- @Override
- public void open(String filename) {
-
- String[] hostList = filename.split(":");
-
- for(String host : hostList){
- boolean result = this.createConnection(host);
- if(result==true) break;
- }
-
- if(this.xmsgServer==null){
- System.out.println("----> error finding server.");
- return;
- }
- System.out.println(" >>> subscribing to topic : data-hipo");
-
- final String subject = "clas12data";
- final String type = "data-hipo";
- final String description = "clas12 data distribution ring";
- final String domain = "clas12domain";
- xMsgTopic topic = xMsgTopic.build(domain, subject, type);
- try {
- // Register this subscriber
- this.xmsgServer.register(xMsgRegInfo.subscriber(topic, description));
- } catch (xMsgException ex) {
- Logger.getLogger(Hipo3RingSource.class.getName()).log(Level.SEVERE, null, ex);
- }
-
- try {
- // Subscribe to default proxy
- this.xmsgServer.subscribe(topic, new MyCallBack());
- } catch (xMsgException ex) {
- Logger.getLogger(Hipo3RingSource.class.getName()).log(Level.SEVERE, null, ex);
- }
- System.out.println(" >>> subscription to topic : success\n\n");
-
- //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void open(ByteBuffer buff) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public int getSize() {
- return this.eventStore.size();
- }
-
- @Override
- public DataEventList getEventList(int start, int stop) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public DataEventList getEventList(int nrecords) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public DataEvent getNextEvent() {
- //System.out.println(" >>> get next event : size = " + eventStore.size());
- if(eventStore.isEmpty()){
- return null;
- }
- Hipo3DataEvent event = this.eventStore.get(0);
- //System.out.println(" >>> success getting event : size = " + eventStore.size());
- //event.show();
- this.eventStore.remove(0);
- //System.out.println(" >>> FILO cleanup : size = " + eventStore.size());
- //System.out.println("\n\n");
- return event;
- }
-
- @Override
- public DataEvent getPreviousEvent() {
- return null;
- }
-
- @Override
- public DataEvent gotoEvent(int index) {
- return null;
- }
-
- @Override
- public void reset() {
- this.eventStore.clear();
- }
-
- @Override
- public int getCurrentIndex() {
- return 0;
- }
-
-
- public void close() {
- /*try {
- this.getConnection().close();
- } catch (xMsgException ex) {
- Logger.getLogger(HipoRingSource.class.getName()).log(Level.SEVERE, null, ex);
- }*/
- }
-
- @Override
- public DataSourceType getType() {
- return DataSourceType.STREAM;
- //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void waitForEvents() {
-
- }
- private class MyCallBack implements xMsgCallBack {
-
- @Override
- public void callback(xMsgMessage mm) {
- byte[] data = mm.getData();
- String type = mm.getMimeType();
- //System.out.println("\n\n >>>>>> received data : mime " + type);
- //System.out.println(" >>>>>> received data : size " + data.length);
- if(eventStore.size()>>>>> adding event to the store : size = %d \n", eventStore.size());
- } else {
- //System.out.printf(" >>>>>> event store is full : size = %d \n", eventStore.size());
- }
- }
- }
-
- public static void main(String[] args){
-
- OptionParser parser = new OptionParser();
- parser.addOption("-s", "localhost");
- parser.parse(args);
-
- Hipo3RingSource reader = new Hipo3RingSource();
- reader.open(parser.getOption("-s").stringValue());
- //reader.open("128.82.188.90:129.57.76.220:129.57.76.215:129.57.76.230");
-
- while(true){
- if(reader.hasEvent()==true){
- //System.out.println("has event");
- DataEvent event = reader.getNextEvent();
- try {
- event.show();
- } catch (Exception e) {
- System.out.println("something went wrong");
- }
- } else {
- //System.out.println("no event");
- try {
- Thread.sleep(20);
- } catch (InterruptedException ex) {
- Logger.getLogger(Hipo3RingSource.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
- //reader.open("localhost");
- /*
- OptionParser parser = new OptionParser();
- parser.addRequired("-s");
-
-
- HipoRingSource reader = HipoRingSource.createSource();
-
- while(reader.hasEvent()==true){
-
- HipoDataEvent event = (HipoDataEvent) reader.getNextEvent();
- //event.show();
-
- try {
- Thread.sleep(8000);
- } catch (InterruptedException ex) {
- Logger.getLogger(HipoRingSource.class.getName()).log(Level.SEVERE, null, ex);
- }
-
- }
- System.out.println("DONE");
- */
- /*
- String host = args[0];
- try (HipoRingSource subscriber = new HipoRingSource(host)) {
- xMsgUtil.keepAlive();
- } */
- }
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/ring/DataDistributionRing.java b/common-tools/clas-io/src/main/java/org/jlab/io/ring/DataDistributionRing.java
index 4939f4b6df..e208048713 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/ring/DataDistributionRing.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/ring/DataDistributionRing.java
@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.io.ring;
import java.util.logging.Level;
@@ -38,19 +33,10 @@ public DataDistributionRing(){
*/
public void initProxy(){
try {
-
String host = xMsgUtil.localhost();
xMsgProxyAddress address = new xMsgProxyAddress(host,xMsgConstants.DEFAULT_PORT);
System.out.println("\n >>>>> starting xmsg proxy : " + host + "/" + xMsgConstants.DEFAULT_PORT);
proxy = new xMsgProxy(xMsgContext.newContext(), address);
-
- /* Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- xMsgContext.destroyContext();
- proxy.shutdown();
- }
- });*/
proxy.start();
System.out.println("\n >>>>> starting xmsg proxy : success");
} catch (xMsgException ex) {
@@ -69,14 +55,6 @@ public void initRegistrar(){
try {
xMsgRegAddress address = new xMsgRegAddress("localhost", xMsgConstants.REGISTRAR_PORT);
xMsgRegistrar registrar = new xMsgRegistrar(xMsgContext.newContext(), address);
- /* Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- xMsgContext.destroyContext();
- registrar.shutdown();
- }
- });*/
-
registrar.start();
System.out.println("\n >>>>> starting xmsg registrar : success");
} catch (xMsgException ex) {
@@ -88,35 +66,14 @@ public void initRing(){
producer = new DataRingProducer();
producer.setDelay(3000);
producer.start();
- /*
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
-
- System.out.println("\n\n\n");
- System.out.println(" ********* Graceful exit initiated");
- producer.shutdown();
- xMsgContext.destroyContext();
- System.out.println(" ********* Destroying xMsg context : done");
- registrar.shutdown();
- System.out.println(" ********* Registrar shudown : done");
- proxy.shutdown();
- System.out.println(" ********* Proxy service shudown : done");
- System.out.println(" ********* Exiting Data Distribution\n\n");
- System.exit(0);
- }
- });*/
}
public void shutdown(){
System.out.println("\n\n\n");
System.out.println(" ********* Graceful exit initiated");
producer.shutdown();
-
System.out.println(" ********* Destroying xMsg context : done");
-
registrar.shutdown();
-
System.out.println(" ********* Registrar shudown : done");
proxy.shutdown();
System.out.println(" ********* Proxy service shudown : done");
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/ring/DataRingProducer.java b/common-tools/clas-io/src/main/java/org/jlab/io/ring/DataRingProducer.java
index 8689e7c98d..3641dc4d8e 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/ring/DataRingProducer.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/ring/DataRingProducer.java
@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.io.ring;
import java.util.logging.Level;
@@ -34,6 +29,7 @@ public class DataRingProducer extends xMsg {
public DataRingProducer(){
super("DataRingProducer");
}
+
/**
* sets the sleep timer after each event has been published.
* @param delay
@@ -45,28 +41,22 @@ public void setDelay(int delay){
public void updateList(){
}
+
/**
* Start publisher service. establishes connection
*/
public void start(){
try {
-
connection = getConnection();
-
final String domain = "clas12domain";
final String subject = "clas12data";
final String typeHipo = "data-hipo";
final String typeEvio = "data-evio";
-
final String description = "clas12 data distribution ring";
-
topicHipo = xMsgTopic.build(domain, subject, typeHipo);
topicEvio = xMsgTopic.build(domain, subject, typeEvio);
-
register(xMsgRegInfo.publisher(topicHipo, description));
- //register(xMsgRegInfo.publisher(topicEvio, description));
-
} catch (xMsgException ex) {
Logger.getLogger(DataRingProducer.class.getName()).log(Level.SEVERE, null, ex);
@@ -89,23 +79,17 @@ public void addEvioEvent(EvioDataEvent event){
System.out.println(" >>>>>> published message : size = " + b.length);
System.out.println(" >>>>>> delay " + publishDelay + " ms");
}
- //this.publishCounter++;
}
-
public void shutdown(){
-
this.unsubscribeAll();
this.connection.close();
this.destroy();
}
public void addEvent(HipoDataEvent event){
-
byte[] b = event.getEventBuffer().array();
-
xMsgMessage msg = new xMsgMessage(topicHipo,"data/hipo",b);
-
try {
this.publish(connection, msg);
} catch (xMsgException ex) {
@@ -119,7 +103,6 @@ public void addEvent(HipoDataEvent event){
this.publishCounter++;
}
-
public static void main(String[] args){
int delay = Integer.parseInt(args[0]);
String file = args[1];
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/stream/EvioInputStream.java b/common-tools/clas-io/src/main/java/org/jlab/io/stream/EvioInputStream.java
index 203325efaa..547bf76113 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/stream/EvioInputStream.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/stream/EvioInputStream.java
@@ -1,9 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
package org.jlab.io.stream;
import java.io.File;
@@ -35,19 +29,16 @@ public class EvioInputStream {
private ByteOrder storeByteOrder = ByteOrder.BIG_ENDIAN;
private EvioCompactReader evioReader = null;
- private int currentEvent;
private int currentFileEntries;
private EvioCompactStructureHandler cStructure = null;
public void open(String filename){
try {
evioReader = new EvioCompactReader(new File(filename));
- currentEvent = 1;
currentFileEntries = evioReader.getEventCount();
storeByteOrder = evioReader.getFileByteOrder();
System.out.println("****** opened FILE [] ** NEVENTS = " +
currentFileEntries + " *******");
- // TODO Auto-generated method stub
} catch (EvioException ex) {
Logger.getLogger(EvioSource.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
@@ -56,14 +47,14 @@ public void open(String filename){
}
public Map getKeys(){
- Map keymap = new HashMap();
+ Map keymap = new HashMap<>();
return keymap;
}
public int getEntries() { return this.currentFileEntries; }
public TreeMap getObjectFromNode(EvioNode root){
- TreeMap treemap = new TreeMap();
+ TreeMap treemap = new TreeMap<>();
List nodes = root.getAllNodes();
for(int loop = 0; loop < nodes.size(); loop++){
@@ -113,9 +104,8 @@ public TreeMap getObjectTree(int event){
}
public ArrayList< TreeMap > getObjectTree(){
- ArrayList< TreeMap > objectArray = new ArrayList< TreeMap >();
+ ArrayList< TreeMap > objectArray = new ArrayList< >();
for(int loop = 0; loop < currentFileEntries; loop++){
- //System.err.println("--- reading file ---");
try {
ByteBuffer evioBuffer = evioReader.getEventBuffer(loop+1, true);
EvioCompactStructureHandler structure = new EvioCompactStructureHandler(evioBuffer,DataType.BANK);
@@ -127,7 +117,7 @@ public ArrayList< TreeMap > getObjectTree(){
(node.getDataTypeObj()==DataType.ALSOBANK||
node.getDataTypeObj()==DataType.BANK)){
TreeMap objects = this.getObjectFromNode(node);
- if(objects.size()>0) objectArray.add(objects);
+ if(!objects.isEmpty()) objectArray.add(objects);
}
}
} catch (EvioException ex) {
@@ -141,7 +131,7 @@ public void close(){
this.evioReader.close();
}
public ArrayList getContainerTags(){
- ArrayList tags = new ArrayList();
+ ArrayList tags = new ArrayList<>();
for(int loop = 0; loop < currentFileEntries; loop++){
try {
ByteBuffer evioBuffer = evioReader.getEventBuffer(loop+1, true);
@@ -152,7 +142,6 @@ public ArrayList getContainerTags(){
item.getDataTypeObj()==DataType.BANK||
item.getDataTypeObj()==DataType.ALSOBANK)
tags.add(item.getTag());
- //return item;
}
} catch (EvioException ex) {
Logger.getLogger(EvioInputStream.class.getName()).log(Level.SEVERE, null, ex);
@@ -185,10 +174,6 @@ public EvioNode getNodeFromTree(int tag, int num, DataType type){
item.getDataTypeObj()==type)
return item;
}
- /*
- if(item.getTag()==tag&&item.getNum()==num&&
- item.getDataTypeObj()==type)
- return item;*/
}
} catch (EvioException ex) {
System.err.println("**** ERROR ***** : error getting node [" + tag
@@ -208,9 +193,9 @@ public byte[] getByte(int tag, int num){
Logger.getLogger(EvioInputStream.class.getName()).log(Level.SEVERE, null, ex);
}
}
- //byte[] ret = {0};
return null;
}
+
public double[] getDouble(int tag, int num){
EvioNode node = this.getNodeFromTree(tag,num,DataType.DOUBLE64);
if(node!=null){
@@ -222,7 +207,6 @@ public double[] getDouble(int tag, int num){
Logger.getLogger(EvioInputStream.class.getName()).log(Level.SEVERE, null, ex);
}
}
- //double[] ret = {0.0};
return null;
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/stream/EvioOutputStream.java b/common-tools/clas-io/src/main/java/org/jlab/io/stream/EvioOutputStream.java
index df6b3a4720..c06c1c7395 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/stream/EvioOutputStream.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/stream/EvioOutputStream.java
@@ -1,9 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
package org.jlab.io.stream;
import java.io.File;
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/stream/EvioStreamObject.java b/common-tools/clas-io/src/main/java/org/jlab/io/stream/EvioStreamObject.java
index 6261b203dd..94ea45803f 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/stream/EvioStreamObject.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/stream/EvioStreamObject.java
@@ -1,9 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
package org.jlab.io.stream;
import java.util.TreeMap;
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/task/DataSourceProcessorPane.java b/common-tools/clas-io/src/main/java/org/jlab/io/task/DataSourceProcessorPane.java
index 72e009032a..569d720f47 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/task/DataSourceProcessorPane.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/task/DataSourceProcessorPane.java
@@ -20,7 +20,6 @@
import org.jlab.io.base.DataSource;
import org.jlab.io.evio.EvioETSource;
import org.jlab.io.evio.EvioSource;
-import org.jlab.io.hipo3.Hipo3DataSource;
import org.jlab.io.hipo.HipoDataSource;
import org.jlab.io.hipo.HipoRingSource;
import org.jlab.io.ui.ConnectionDialog;
@@ -37,7 +36,6 @@ public class DataSourceProcessorPane extends JPanel implements ActionListener {
private DataSourceProcessor dataProcessor = new DataSourceProcessor();
private String dataFile = null;
- private int dataPaneStyle = DataSourceProcessorPane.TOOLBAR;
private JLabel statusLabel = null;
private java.util.Timer processTimer = null;
private JButton mediaPause = null;
@@ -47,7 +45,6 @@ public class DataSourceProcessorPane extends JPanel implements ActionListener {
private JButton mediaEject = null;
private JButton sourceFile = null;
private int eventDelay = 0;
- public boolean isHipo3Event = false;
private String defaultHost = null;
private String defaultIp = null;
@@ -302,32 +299,9 @@ public void actionPerformed(ActionEvent e) {
mediaPlay.setEnabled(true);
this.setDataFile(null);
}
-
- if(e.getActionCommand().compareTo("OpenFileHipo3")==0){
- this.stopProcessorTimer();
- isHipo3Event = true;
- JFileChooser fc = new JFileChooser();
- fc.setCurrentDirectory(null);
- int returnVal = fc.showOpenDialog(this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- String fileName = fc.getSelectedFile().getAbsolutePath();
- System.out.println("file -> " + fileName);
- Hipo3DataSource source = new Hipo3DataSource();
- source.open(fileName);
- //This is where a real application would open the file.
- this.dataProcessor.setSource(source);
- statusLabel.setText(dataProcessor.getStatusString());
- mediaNext.setEnabled(true);
- mediaPrev.setEnabled(true);
- mediaPlay.setEnabled(true);
- this.setDataFile(fileName);
- }
- }
-
if(e.getActionCommand().compareTo("OpenFileHipo4")==0){
this.stopProcessorTimer();
- isHipo3Event = false;
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(null);
int returnVal = fc.showOpenDialog(this);
@@ -389,6 +363,7 @@ public static void main(String[] args){
pane.addEventListener(new IDataEventListener(){
int ncount = 0;
+ @Override
public void dataEventAction(DataEvent event) {
ncount++;
if(event.getType() == DataEventType.EVENT_START){
@@ -400,10 +375,12 @@ public void dataEventAction(DataEvent event) {
}
}
+ @Override
public void timerUpdate() {
System.out.println("update is called");
}
+ @Override
public void resetEventListener() {
System.out.println("reset is called");
ncount = 0;
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/task/IDataEventListener.java b/common-tools/clas-io/src/main/java/org/jlab/io/task/IDataEventListener.java
index 8d9f62159c..c08b083132 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/task/IDataEventListener.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/task/IDataEventListener.java
@@ -1,9 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
package org.jlab.io.task;
import org.jlab.io.base.DataEvent;
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/ui/BankEntryMasks.java b/common-tools/clas-io/src/main/java/org/jlab/io/ui/BankEntryMasks.java
deleted file mode 100644
index 53dcc328e7..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/ui/BankEntryMasks.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.ui;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- * @author gavalian
- */
-public class BankEntryMasks {
-
- Map bankMasks = new HashMap();
-
- public BankEntryMasks(){
-
- }
-
- public String getMask(String bankName){
- return bankMasks.get(bankName);
- }
-
-
- public void setMask(String bankName, String mask){
- bankMasks.put(bankName, mask);
- }
-
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/ui/BasicDialog.java b/common-tools/clas-io/src/main/java/org/jlab/io/ui/BasicDialog.java
index 2f509f1b0d..83ef1d1e1e 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/ui/BasicDialog.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/ui/BasicDialog.java
@@ -1,11 +1,5 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.io.ui;
-
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/ui/ConnectionDialog.java b/common-tools/clas-io/src/main/java/org/jlab/io/ui/ConnectionDialog.java
index d1c3c08677..fed12d0953 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/ui/ConnectionDialog.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/ui/ConnectionDialog.java
@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.io.ui;
import java.awt.Component;
@@ -35,8 +30,6 @@ public class ConnectionDialog extends BasicDialog {
public static final int RING_TYPE_ET = 5;
public static final int RING_TYPE_HIPO = 6;
- private int connectionType = ConnectionDialog.RING_TYPE_ET;
-
private JRadioButton _directConnect;
private JRadioButton _connectToDAQ;
@@ -45,7 +38,7 @@ public class ConnectionDialog extends BasicDialog {
private static String defaultHost = "clondaq7";
private static String defaultIP = "129.57.167.20";
- Map connectionHosts = new LinkedHashMap();
+ Map connectionHosts = new LinkedHashMap<>();
private static String[] closeoutButtons = {"Connect", "Cancel"};
@@ -55,7 +48,6 @@ public class ConnectionDialog extends BasicDialog {
private JComboBox _comboHosts;
private JComboBox _comboEtFiles;
- private JComboBox _files;
private int _reason = DialogUtilities.CANCEL_RESPONSE;
@@ -64,7 +56,6 @@ public class ConnectionDialog extends BasicDialog {
*/
public ConnectionDialog() {
super("Connection.....", true, closeoutButtons);
- int nhosts = hostNames.length;
for(int i = 0; i < hostNames.length; i++){
this.connectionHosts.put(hostNames[i],hostIP[i]);
}
@@ -72,7 +63,6 @@ public ConnectionDialog() {
public ConnectionDialog(int type) {
super("Connection.....", true, closeoutButtons);
- int nhosts = hostNames.length;
for(int i = 0; i < hostNames.length; i++){
this.connectionHosts.put(hostNames[i],hostIP[i]);
}
@@ -80,7 +70,6 @@ public ConnectionDialog(int type) {
public ConnectionDialog(String defaultHost, String defaultIP) {
super("Connection.....", true, closeoutButtons);
- int nhosts = hostNames.length;
for(int i = 0; i < hostNames.length; i++){
this.connectionHosts.put(hostNames[i],hostIP[i]);
}
@@ -105,13 +94,13 @@ protected Component createCenterComponent() {
BoxLayout.Y_AXIS));
_ipField = new JTextField(25);
- _ipField.setText(this.defaultIP);
+ _ipField.setText(ConnectionDialog.defaultIP);
JPanel subpanel = new JPanel();
subpanel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 2));
JLabel labelip = new JLabel(" Address: ");
- _comboHosts = new JComboBox(this.hostNames);
+ _comboHosts = new JComboBox(ConnectionDialog.hostNames);
ItemListener itemListener = new ItemListener() {
@Override
@@ -122,7 +111,7 @@ public void itemStateChanged(ItemEvent e) {
}
}
};
- _comboHosts.setSelectedItem(this.defaultHost);
+ _comboHosts.setSelectedItem(ConnectionDialog.defaultHost);
_comboHosts.addItemListener(itemListener);
subpanel.add(labelip);
@@ -140,11 +129,8 @@ public void itemStateChanged(ItemEvent e) {
_fileName.setText("/et/clasprod");
subpanel2.add(label);
subpanel2.add(_fileName);
- //List etFiles = FileUtils.filesInFolder(null, reason);
try {
List etFiles = FileUtils.dirListStartsWith("/et", "");
- //List etFiles = FileUtils.dirListStartsWith("/tmp", "et_sys");
- //List etFiles = FileUtils.dirListStartsWith("/Users/gavalian/Work", "d");
for(String f : etFiles){
System.out.println(" -----> " + f);
}
@@ -208,8 +194,8 @@ public Integer getPort(){
String port_number = _portNumber.getText();
Integer port = 11111;
try {
- port = Integer.parseInt(port_number);
- } catch (Exception e) {
+ port = Integer.valueOf(port_number);
+ } catch (NumberFormatException e) {
System.out.println("ERROR : the string provided is not a number : " + port_number);
}
return port;
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/ui/ConnectionDialogHipo.java b/common-tools/clas-io/src/main/java/org/jlab/io/ui/ConnectionDialogHipo.java
index 353cf8dd95..91795ef7ed 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/ui/ConnectionDialogHipo.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/ui/ConnectionDialogHipo.java
@@ -7,7 +7,6 @@
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
-import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
@@ -25,23 +24,18 @@ public class ConnectionDialogHipo extends BasicDialog {
public static final int RING_TYPE_ET = 5;
public static final int RING_TYPE_HIPO = 6;
- private int connectionType = ConnectionDialog.RING_TYPE_ET;
-
private JRadioButton _directConnect;
private JRadioButton _connectToDAQ;
private static String[] hostNames = new String[]{"clondaq2","clondaq3","clondaq4","clondaq5","clondaq6","clondaq7"};
private static String[] hostIP = new String[]{"129.57.167.109","129.57.167.226","129.57.167.227","129.57.167.41","129.57.167.60","129.57.167.20"};
- Map connectionHosts = new LinkedHashMap();
+ Map connectionHosts = new LinkedHashMap<>();
private static String[] closeoutButtons = {"Connect", "Cancel"};
private JTextField _ipField;
private JTextField _fileName;
- private JComboBox _comboHosts;
- private JComboBox _comboEtFiles;
- private JComboBox _files;
private int _reason = DialogUtilities.CANCEL_RESPONSE;
@@ -50,7 +44,6 @@ public class ConnectionDialogHipo extends BasicDialog {
*/
public ConnectionDialogHipo() {
super("Connection.....", true, closeoutButtons);
- int nhosts = hostNames.length;
for(int i = 0; i < hostNames.length; i++){
this.connectionHosts.put(hostNames[i],hostIP[i]);
}
@@ -77,9 +70,7 @@ protected Component createCenterComponent() {
panel.add(Box.createVerticalStrut(6));
panel.add(_connectToDAQ);
- Border emptyBorder = BorderFactory
- .createEtchedBorder();//4, 4, 4, 4);
-
+ Border emptyBorder = BorderFactory.createEtchedBorder();
panel.setBorder(BorderFactory.createTitledBorder(emptyBorder, "Connect to Host"));
return panel;
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/ui/DataBankPanel.java b/common-tools/clas-io/src/main/java/org/jlab/io/ui/DataBankPanel.java
deleted file mode 100644
index 2f6671555e..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/ui/DataBankPanel.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.ui;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import org.jlab.io.base.DataBank;
-
-/**
- *
- * @author gavalian
- */
-public class DataBankPanel extends JPanel {
-
- private JScrollPane scrollPane = null;
- private JTable table = null;
-
- public DataBankPanel(){
- super();
- this.setPreferredSize(new Dimension(600,400));
- this.initComponents();
- }
-
- public DataBankPanel(DataBank bank){
- super();
- this.setPreferredSize(new Dimension(600,400));
- this.initComponents();
- this.setBank(bank);
- }
-
- public DataBankPanel(DataBank bank, BankEntryMasks masks){
- super();
- this.setPreferredSize(new Dimension(600,400));
- this.initComponents();
- this.setBank(bank,masks);
- }
-
- private void initComponents(){
- this.setLayout(new BorderLayout());
-
- String[] cnames = {"id","p"};
- String[][] cdata = {{"11","0.45"},{"2212","0.65"}};
- this.table = new JTable(cdata,cnames);
-
- //scrollPane.add(table);
- scrollPane = new JScrollPane(table);
- //scrollPane.setAutoscrolls(true);
- //this.table.setFillsViewportHeight(true);
- this.add(scrollPane,BorderLayout.CENTER);
- }
-
- public void setBank(DataBank bank){
- this.table.setModel(bank.getTableModel(""));
- }
-
- public void setBank(DataBank bank, BankEntryMasks masks){
- if(masks.getMask(bank.getDescriptor().getName())==null){
- this.table.setModel(bank.getTableModel(""));
- } else {
- this.table.setModel(bank.getTableModel(masks.getMask(bank.getDescriptor().getName())));
- }
- }
-
- public static void main(String[] args){
- JFrame frame = new JFrame();
- DataBankPanel panel = new DataBankPanel();
- frame.add(panel);
- frame.pack();
- frame.setVisible(true);
- }
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/ui/DialogUtilities.java b/common-tools/clas-io/src/main/java/org/jlab/io/ui/DialogUtilities.java
index a363a744dc..5b7df28c4f 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/ui/DialogUtilities.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/ui/DialogUtilities.java
@@ -118,9 +118,9 @@ public String padString(Component c, String inp, String tstr) {
int newgap;
if (inp == null) {
- str = new String("");
+ str = "";
} else {
- str = new String(inp);
+ str = inp;
}
FontMetrics fm = c.getFontMetrics(c.getFont());
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/utils/CompositeFormatReader.java b/common-tools/clas-io/src/main/java/org/jlab/io/utils/CompositeFormatReader.java
index 2b125a9b21..620119ccd0 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/utils/CompositeFormatReader.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/utils/CompositeFormatReader.java
@@ -1,9 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
package org.jlab.io.utils;
import java.io.IOException;
@@ -31,7 +25,6 @@ public class CompositeFormatReader {
public static void main4(String[] args){
EvioSource reader = new EvioSource();
reader.open("/Users/gavalian/Work/DataSpace/LTCC/ltcc0test_000195.evio");
- //while(reader.hasEvent()){
for(int loop = 0; loop < 10; loop++){
EvioDataEvent event = (EvioDataEvent) reader.getNextEvent();
EvioNode rawnode = event.getNodeFromTree(57601, 43, DataType.COMPOSITE);
@@ -55,7 +48,6 @@ public static void main4(String[] args){
}
}
-
public static void main2(){
try {
@@ -77,17 +69,16 @@ public static void main2(){
Logger.getLogger(CompositeFormatReader.class.getName()).log(Level.SEVERE, null, ex);
}
}
+
public static void main(String[] args){
CompositeFormatReader.main4(args);
}
+
public static void main3(String[] args){
try {
EvioCompactReader reader = new EvioCompactReader("/Users/gavalian/Work/DataSpace/LTCC/ltcc0test_000195.evio");
for(int loop = 0; loop < 10; loop++){
- //EvioNode node = reader.getEvent(loop);
- //List nodes = reader.searchEvent(loop+1, 57601, 7);
- //System.err.println("event " + loop + " " + nodes.size());
ByteBuffer buffer = reader.getEventBuffer(loop+1);
System.err.println("event " + loop + " " + buffer.limit() + " " + buffer.order());
EvioCompactStructureHandler structure = new EvioCompactStructureHandler(buffer,DataType.BANK);
@@ -123,11 +114,6 @@ public static void main3(String[] args){
);
CompositeData cdata = new CompositeData(bdata,ByteOrder.LITTLE_ENDIAN);
- List itemTypes = cdata.getTypes();
- //String format = cdata.
- //for(DataType type : itemTypes){
- // System.err.println(" Data type = " + type);
- //}
}
}
}
@@ -142,35 +128,4 @@ public static void main3(String[] args){
Logger.getLogger(CompositeFormatReader.class.getName()).log(Level.SEVERE, null, ex);
}
}
- /*
- public static void main(String[] args) {
- EvioSource reader = new EvioSource();
- reader.open("/Users/gavalian/Work/DataSpace/LTCC/ltcc0test_000168.evio");
- for(int loop = 0; loop < 10; loop++){
- EvioDataEvent event = (EvioDataEvent) reader.getNextEvent();
- System.err.println("Event " + loop + " Has bank = " + event.hasBank(57601, 7));
- EvioCompactStructureHandler structure = event.getStructureHandler();
- try {
- List nodes = structure.getNodes();
- /*
- if(event.hasBank(57601, 7)==true){
-
- EvioNode node = event.getNodeFromTree(57601, 7, DataType.COMPOSITE);
-
- if(node!=null){
- System.err.println("FOUND THE NODE");
- //ByteBuffer buffer = node.getStructureBuffer(false);
-
- try {
- CompositeData cdata = new CompositeData(buffer.array(),ByteOrder.LITTLE_ENDIAN);
- } catch (EvioException ex) {
- Logger.getLogger(CompositeFormatReader.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
- } catch (EvioException ex) {
- Logger.getLogger(CompositeFormatReader.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }*/
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/utils/DataSourceDump.java b/common-tools/clas-io/src/main/java/org/jlab/io/utils/DataSourceDump.java
deleted file mode 100644
index 2cb1273be4..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/utils/DataSourceDump.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.jlab.io.utils;
-
-import java.io.Console;
-import org.jlab.io.base.DataBank;
-import org.jlab.io.base.DataEvent;
-import org.jlab.io.base.DataSource;
-import org.jlab.io.evio.EvioSource;
-import org.jlab.io.hipo.HipoDataEvent;
-import org.jlab.io.hipo.HipoDataSource;
-import org.jlab.logging.DefaultLogger;
-
-/**
- *
- * @author gavalian
- */
-public class DataSourceDump {
-
- public static String waitForEnter() {
- String line = "";
- Console c = System.console();
- if (c != null) {
- // printf-like arguments
- //c.format(message, args);
- c.format("\nChoose (n=next,p=previous, q=quit), Type Bank Name or id : ");
- line = c.readLine();
- }
- return line;
- }
- public static void main(String[] args){
-
- DefaultLogger.debug();
-
- if(args.length==0){
- System.out.println("\n\n\t Usage : eviodump [filename]");
- System.exit(0);
- }
-
- String inputFile = args[0];
-
- DataSource reader = null;
-
- if(inputFile.contains("hipo")==true){
- reader = new HipoDataSource();
- } else {
- reader = new EvioSource();
- }
-
- reader.open(inputFile);
-
- String command = "";
- DataEvent event = null;
- int icounter = 0;
-
- event = reader.getNextEvent();
- System.out.println(" HAS EVENTS = " + reader.hasEvent());
- while(reader.hasEvent()==true){
-
-
- if(command.length()<1){
- System.out.println("\n");
- System.out.println("*********************** EVENT # " + icounter
- + " ***********************");
- event.show();
- }
-
- command = DataSourceDump.waitForEnter();
-
- if(command.compareTo("n")==0){
- event = reader.getNextEvent();
- icounter++;
- command = "";
- continue;
- }
-
- if(command.compareTo("p")==0){
- if(icounter>0){
- event = reader.getPreviousEvent();
- icounter--;
- }
- command = "";
- continue;
- }
-
- if(command.length()>=1){
- int order = -1;
- if(command.matches("-?\\d+(\\.\\d+)?")){
- try {
- order = Integer.parseInt(command);
- if(event instanceof HipoDataEvent){
- HipoDataEvent he = (HipoDataEvent) event;
- he.showBankByOrder(order);
- continue;
- }
- } catch(Exception e) {
- System.out.println(" [warning] --> unrecognized input [" + command + "]");
- }
- } else {
- if(event.hasBank(command)==true){
- DataBank bank = event.getBank(command);
- bank.show();
- } else {
- System.out.println("[DataDump] warning ---> bank not found : " + command);
- }
- }
- }
- if(command.compareTo("q")==0){
- reader.close();
- System.exit(0);
- }
- }
- }
-
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/utils/DetectorBank.java b/common-tools/clas-io/src/main/java/org/jlab/io/utils/DetectorBank.java
deleted file mode 100644
index 74f5fbbec8..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/utils/DetectorBank.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.utils;
-
-/**
- *
- * @author gavalian
- */
-public class DetectorBank {
- public float X = 0;
- public float Y = 0;
- public float Z = 0;
- public float dX = 0;
- public float dY = 0;
- public float dZ = 0;
- public float time = (float) 0.0;
- public float energy = (float) 0.0;
- public float path = (float) 0.0;
- public short pindex = (short) 0;
- public byte dindex = (byte) 0;
- public byte detector = (byte) 1;
- public byte sector = (byte) 1;
- public byte superlayer = (byte) 1;
- public short component = (short) 1;
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/utils/DictionaryLoader.java b/common-tools/clas-io/src/main/java/org/jlab/io/utils/DictionaryLoader.java
index e9153cea9d..83efa60988 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/utils/DictionaryLoader.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/utils/DictionaryLoader.java
@@ -1,9 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
package org.jlab.io.utils;
import java.io.IOException;
@@ -29,7 +23,7 @@ public class DictionaryLoader {
public static ArrayList getDescriptorsFromFile(String xmlfile){
- ArrayList list = new ArrayList();
+ ArrayList list = new ArrayList<>();
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
@@ -46,10 +40,7 @@ public static ArrayList getDescriptorsFromFile(String xmlfil
for(EvioDataDescriptor item : descList){
list.add(item);
}
- //String oneBank = DictionaryLoader.parseBankXMLtoString(evio_bank);
- //dictionary_list.add(oneBank);
}
-
}
return list;
} catch (ParserConfigurationException ex) {
@@ -59,14 +50,12 @@ public static ArrayList getDescriptorsFromFile(String xmlfil
} catch (IOException ex) {
Logger.getLogger(DictionaryLoader.class.getName()).log(Level.SEVERE, null, ex);
}
-
return null;
}
-
public static ArrayList descriptorParseXMLtoString(String xmlfile) {
- ArrayList dictionary_list = new ArrayList();
+ ArrayList dictionary_list = new ArrayList<>();
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = dbFactory.newDocumentBuilder();
@@ -77,12 +66,10 @@ public static ArrayList descriptorParseXMLtoString(String xmlfile) {
Element evio_nodes = (Element) evio_dict_nodelist.item(b);
NodeList evio_bank_nodes = evio_nodes.getElementsByTagName("bank");
for (int s = 0; s < evio_bank_nodes.getLength(); s++) {
-
Element evio_bank = (Element) evio_bank_nodes.item(s);
String oneBank = DictionaryLoader.parseBankXMLtoString(evio_bank);
dictionary_list.add(oneBank);
}
-
}
} catch (ParserConfigurationException ex) {
Logger.getLogger(DictionaryLoader.class.getName()).log(Level.SEVERE, null, ex);
@@ -91,9 +78,9 @@ public static ArrayList descriptorParseXMLtoString(String xmlfile) {
} catch (IOException ex) {
Logger.getLogger(DictionaryLoader.class.getName()).log(Level.SEVERE, null, ex);
}
-
return dictionary_list;
}
+
/**
* Parse an XML string into a descriptors.
* @param xmlstring
@@ -115,13 +102,14 @@ public static ArrayList parseXMLString(String xmlstring){
}
return null;
}
+
/**
*
* @param doc
* @return
*/
public static ArrayList parseDocumentXMLtoString(Document doc){
- ArrayList dictionary_list = new ArrayList();
+ ArrayList dictionary_list = new ArrayList<>();
NodeList evio_bank_nodes = doc.getElementsByTagName("bank");
for (int s = 0; s < evio_bank_nodes.getLength(); s++) {
Element evio_bank = (Element) evio_bank_nodes.item(s);
@@ -157,19 +145,14 @@ public static String parseBankXMLtoString(Element bankElement){
str.append(entry_num);
str.append(":");
str.append(entry_type);
-
- //System.err.println("Entry = " + entry_name + " "
- // + section_tag + " " + entry_num
- // + " " + entry_type);
}
}
System.err.println("--> " + str.toString());
- //dictionary_list.add(str.toString());
return str.toString();
}
public static ArrayList parseBankXMLtoDescriptorList(Element bankElement){
- ArrayList list = new ArrayList();
+ ArrayList list = new ArrayList<>();
String bank_name = bankElement.getAttribute("name");
String bank_tag = bankElement.getAttribute("tag");
@@ -178,8 +161,7 @@ public static ArrayList parseBankXMLtoDescriptorList(Element
for(int e = 0 ; e < evio_section.getLength(); e++){
StringBuilder str = new StringBuilder();
Element evio_entry = (Element) evio_section.item(e);
-
- Integer section_tag = Integer.parseInt(evio_entry.getAttribute("tag"));
+ Integer section_tag = Integer.valueOf(evio_entry.getAttribute("tag"));
String section_name = evio_entry.getAttribute("name");
str.append(bank_name);
str.append("::");
@@ -193,16 +175,10 @@ public static ArrayList parseBankXMLtoDescriptorList(Element
String entry_num = evio_col.getAttribute("num");
String entry_type = evio_col.getAttribute("type");
desc.addEntry(section_name, entry_name, section_tag,
- Integer.parseInt(entry_num), entry_type);
- //System.err.println("Entry = " + str.toString() + " " + entry_name + " "
- // + section_tag + " " + entry_num
- // + " " + entry_type);
+ Integer.valueOf(entry_num), entry_type);
}
list.add(desc);
}
- //System.err.println("--> " + str.toString());
- //dictionary_list.add(str.toString());
- //return str.toString();
return list;
}
}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/utils/Evio2HipoConverter.java b/common-tools/clas-io/src/main/java/org/jlab/io/utils/Evio2HipoConverter.java
deleted file mode 100644
index 34d6d220c7..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/utils/Evio2HipoConverter.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.utils;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import org.jlab.io.base.DataBank;
-import org.jlab.io.base.DataEvent;
-import org.jlab.io.evio.EvioDataBank;
-import org.jlab.io.evio.EvioDataEvent;
-import org.jlab.io.evio.EvioDataSync;
-import org.jlab.io.evio.EvioFactory;
-import org.jlab.io.evio.EvioSource;
-import org.jlab.io.hipo.HipoDataSync;
-
-/**
- *
- * @author gavalian
- */
-public class Evio2HipoConverter {
-
- public int COMPRESSION_TYPE = 0;
- private Map excludedBanks = new LinkedHashMap();
-
- public Evio2HipoConverter(){
- this.exclude("DC::true");
- this.exclude("FTOF1A::true");
- this.exclude("FTOF1B::true");
- this.exclude("FTOF2B::true");
- this.exclude("PCAL::true");
- this.exclude("EC::true");
- this.exclude("HTCC::true");
- this.exclude("BST::true");
- }
-
- public final void exclude(String name){
- this.excludedBanks.put(name, 1);
- }
- /**
- * returns list of banks from the dictionary that match the name.
- * @param name
- * @return
- */
- public List getBanksWithName(String name){
- String[] system = EvioFactory.getDictionary().getDescriptorList();
-
- List bankNames = new ArrayList();
- for(String item : system){
- if(item.startsWith(name)==true){
- bankNames.add(item);
- }
- }
- return bankNames;
- }
- /**
- * Returns bank names that match the name, and exist in the event
- * @param event
- * @param name
- * @return
- */
- public List getExistingBanksWithName(DataEvent event, String name){
- List banks = this.getBanksWithName(name);
- List banksExist = new ArrayList();
-
- for(String item : banks){
- if(event.hasBank(item)==true){
- if(this.excludedBanks.containsKey(item)==false){
- banksExist.add(item);
- }
- }
- }
- return banksExist;
- }
-
- public Map getExcluded(){
- return this.excludedBanks;
- }
-
- public DataBank[] getDataBanksWithName(DataEvent event, String name){
- List banksExist = this.getExistingBanksWithName(event, name);
- DataBank[] banks = new DataBank[banksExist.size()];
- int icounter = 0;
- for(int i = 0; i < banksExist.size(); i++){
- banks[i] = event.getBank(banksExist.get(i));
- }
- return banks;
- }
-
- public void convertEvio(String output, List input, List banks){
- EvioDataSync writer = new EvioDataSync();
- writer.open(output);
- //writer.setCompressionType(this.COMPRESSION_TYPE);
-
- for(int icount = 0; icount < input.size(); icount++){
- EvioSource reader = new EvioSource();
- reader.open(input.get(icount));
- System.out.println("[convertor] ---> openning file # " + icount
- + " : " + input.get(icount));
- while(reader.hasEvent()==true){
- DataEvent inEevent = reader.getNextEvent();
- DataEvent outEvent = EvioFactory.createEvioEvent();
- for(String entries : banks){
- DataBank[] dataBanks = this.getDataBanksWithName(inEevent, entries);
- if(dataBanks.length!=0){
- outEvent.appendBanks(dataBanks);
- }
- }
- writer.writeEvent(outEvent);
- }
- }
- }
-
- public void convertHipo(String output, List input, List banks){
- if(this.COMPRESSION_TYPE>2){
- this.convertEvio(output, input, banks);
- }
- HipoDataSync writer = new HipoDataSync();
- writer.open(output);
- writer.setCompressionType(this.COMPRESSION_TYPE);
-
- for(int icount = 0; icount < input.size(); icount++){
- EvioSource reader = new EvioSource();
- reader.open(input.get(icount));
- System.out.println("[convertor] ---> openning file # " + icount
- + " : " + input.get(icount));
- int counter = 0;
- while(reader.hasEvent()==true){
- DataEvent inEvent = reader.getNextEvent();
- DataEvent outEvent = EvioFactory.createEvioEvent();
- counter++;
- if(banks.isEmpty()){
- writer.writeEvent(inEvent);
- } else {
-
- for(String entries : banks){
- DataBank[] dataBanks = this.getDataBanksWithName(inEvent, entries);
- if(dataBanks.length!=0){
- outEvent.appendBanks(dataBanks);
- }
- }
-
- if(inEvent.hasBank("GenPart::true")==true){
- EvioDataBank bankGen = (EvioDataBank) inEvent.getBank("GenPart::true");
- //System.out.println("writing generated event " + counter);
- //bankGen.show();
- ((EvioDataEvent) outEvent).appendGeneratedBank(bankGen);
- //outEvent.appendBank(bankGen);
- }
- writer.writeEvent(outEvent);
- }
- }
- }
- writer.close();
- }
-
- public static void printUsage(){
- System.out.println("\tUsage: convert -[compression] -b [bank1:bank2] output.hipo input.evio [input2.evio] [input3.evio]");
- System.out.println("\n\t Options :");
- System.out.println("\t\t -u : uncompressed");
- System.out.println("\t\t -gzip : gzip compression");
- System.out.println("\t\t -lz4 : lz4 compression");
- System.out.println("\n");
- }
-
- public static void main(String[] args){
-
-
- if(args.length>0){
- if(args[0].compareTo("-list")==0){
- EvioFactory.getDictionary().show();
- }
- }
- /*
- if(args.length<5){
- HipoDataSync.printUsage();
- System.exit(0);
- }*/
-
- if(args[0].startsWith("-")==false){
- System.out.println("\n\n--> please provide compression type");
- HipoDataSync.printUsage();
- System.exit(0);
- }
-
- int compressionType = -1;
-
- if(args[0].compareTo("-u")==0){
- compressionType = 0;
- }
-
- if(args[0].compareTo("-gzip")==0){
- compressionType = 1;
- }
-
- if(args[0].compareTo("-lz4")==0){
- compressionType = 2;
- }
-
- if(args[0].compareTo("-evio")==0){
- compressionType = 3;
- }
-
- if(compressionType<0){
- HipoDataSync.printUsage();
- System.out.println("[error] ---> compression type string is invalid.");
- System.exit(0);
- }
-
- if(args[1].startsWith("-b")==false){
- System.out.println("\n\n--> please provide bank names in the output");
- HipoDataSync.printUsage();
- System.exit(0);
- }
-
- String bankNames = args[2];
- List bankList = new ArrayList();
-
- boolean writeTrueBanks = false;
-
- if(bankNames.compareTo("ALLTRUE")==0){
- System.out.println("[convertor] ---> outputing ALL banks with TRUE");
- writeTrueBanks = true;
- } else {
- if(bankNames.compareTo("ALL")==0){
- System.out.println("[convertor] ---> outputing ALL banks");
- } else {
- String[] tokens = bankNames.split(":");
- for(String token : tokens){
- bankList.add(token);
- }
- }
- }
-
- String outputFile = args[3];
-
- File outFile = new File(outputFile);
-
- if(outFile.exists()==true){
- System.out.println("\n[error] ---> can not overwrite existing file.\n\n");
- System.exit(0);
- }
-
- List inputFiles = new ArrayList();
-
- for(int i = 4; i < args.length; i++){
- inputFiles.add(args[i]);
- }
-
-
- Evio2HipoConverter converter = new Evio2HipoConverter();
- converter.COMPRESSION_TYPE = compressionType;
- if(writeTrueBanks==true){
- converter.getExcluded().clear();
- }
-
- converter.convertHipo(outputFile, inputFiles, bankList);
- //String bank = args[0];
- //converter.getBanksWithName(bank);
-
- }
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/utils/EvioCure.java b/common-tools/clas-io/src/main/java/org/jlab/io/utils/EvioCure.java
index ab89f8af8a..d62a828cb7 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/utils/EvioCure.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/utils/EvioCure.java
@@ -15,7 +15,7 @@
*/
public class EvioCure {
- private static Logger LOGGER = Logger.getLogger(EvioCure.class.getName());
+ private static final Logger LOGGER = Logger.getLogger(EvioCure.class.getName());
public static void main(String[] args) {
DefaultLogger.debug();
@@ -27,11 +27,9 @@ public static void main(String[] args) {
EventWriter evioWriter = null;
try {
EvioReader reader = new EvioReader(inputFile, false, false);
- LOGGER.log(Level.INFO, " READER OPENED " + reader.getEventCount());
- String dictionary = "\n";
- LOGGER.log(Level.INFO, " ENDIANNESS : " + reader.getByteOrder());
+ LOGGER.log(Level.INFO, " READER OPENED {0}", reader.getEventCount());
+ LOGGER.log(Level.INFO, " ENDIANNESS : {0}", reader.getByteOrder());
evioWriter = new EventWriter(outputFile, false, reader.getByteOrder());
- boolean isActive = true;
reader.rewind();
for (int i = 1; i < reader.getEventCount(); i++) {
ByteBuffer buffer = reader.getEventBuffer(i);
@@ -39,7 +37,7 @@ public static void main(String[] args) {
evioWriter.writeEvent(buffer);
icounter++;
}
- LOGGER.log(Level.INFO, " RECOVERED EVENT " + icounter);
+ LOGGER.log(Level.INFO, " RECOVERED EVENT {0}", icounter);
evioWriter.close();
} catch (EvioException ex) {
LOGGER.log(Level.WARNING, " RECOVERED EVENT (EVIO exception) " + icounter, ex);
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/utils/EvioDataConvertor.java b/common-tools/clas-io/src/main/java/org/jlab/io/utils/EvioDataConvertor.java
deleted file mode 100644
index 8cde59c629..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/utils/EvioDataConvertor.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.utils;
-
-/**
- *
- * @author gavalian
- */
-public class EvioDataConvertor {
- public static short getShortFromByte(byte data){
- short short_data = 0;
- return (short) ((short_data|data)&0x00FF);
- }
-
- public static int getIntFromShort(short data){
- int int_data = 0;
- return (int) ( (int_data|data)&0x0000FFFF);
- }
-
- public static void main(String[] args){
- byte data = -117;
- System.err.println(String.format("byte = %d short = %d , B=%X S=%X",
- data,EvioDataConvertor.getShortFromByte(data),data,
- EvioDataConvertor.getShortFromByte(data)));
-
- short sdata = -25678;
- System.err.println(String.format("short = %d int = %d , S=%X I=%X",
- sdata,EvioDataConvertor.getIntFromShort(sdata),sdata,
- EvioDataConvertor.getIntFromShort(sdata)));
- }
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/utils/EvioFileRecover.java b/common-tools/clas-io/src/main/java/org/jlab/io/utils/EvioFileRecover.java
index 5db0354d86..01a0ccb55e 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/io/utils/EvioFileRecover.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/io/utils/EvioFileRecover.java
@@ -1,26 +1,15 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.io.utils;
import java.io.File;
import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jlab.coda.jevio.DataType;
import org.jlab.coda.jevio.EventBuilder;
import org.jlab.coda.jevio.EventWriter;
-//import org.jlab.coda.jevio.EvioCompactEventWriter;
import org.jlab.coda.jevio.EvioEvent;
import org.jlab.coda.jevio.EvioException;
-import org.jlab.coda.jevio.EvioNode;
import org.jlab.coda.jevio.EvioReader;
-import org.jlab.io.evio.EvioFactory;
/**
*
@@ -36,11 +25,7 @@ public static void test(){
try {
EventWriter writer = new EventWriter(outputfile);
EventBuilder eventBuilder = new EventBuilder(1, DataType.BANK, 1);
- //byte[] byteData1 = new byte[499990];
-
EvioEvent ev = eventBuilder.getEvent();
-
- //ev.appendByteData(byteData1);
writer.writeEvent(ev);
writer.close();
} catch (EvioException ex) {
@@ -65,9 +50,8 @@ public static void recoverFile(String inputfile, String outputfile) {
return;
}
- EvioReader reader = null;
-
- EventWriter writer = null;
+ EvioReader reader;
+ EventWriter writer;
try {
@@ -94,10 +78,6 @@ public static void recoverFile(String inputfile, String outputfile) {
}
public static void main(String[] args){
- /*
- String inputfile = "/Users/gavalian/Work/Software/Release-8.0/COATJAVA/coatjava/../svt257er_000015.evio.0";
- String outputfile = "/Users/gavalian/Work/Software/Release-8.0/COATJAVA/coatjava/../svt257er_000015_recovered.evio";
- */
String inputfile = args[0];
String outputfile = args[1];
EvioFileRecover.recoverFile(inputfile, outputfile);
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/utils/EvioFileUtils.java b/common-tools/clas-io/src/main/java/org/jlab/io/utils/EvioFileUtils.java
deleted file mode 100644
index 6ef884e27c..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/utils/EvioFileUtils.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.utils;
-
-import java.util.ArrayList;
-
-/**
- *
- * @author gavalian
- */
-public class EvioFileUtils {
- public EvioFileUtils(){
-
- }
-
- public static void mergeFiles(String outputFile, ArrayList inputFiles){
-
- }
-
- public static void splitFile(String inputFile, String outputTemplate, int nevents){
-
- }
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/utils/HipoFileUtils.java b/common-tools/clas-io/src/main/java/org/jlab/io/utils/HipoFileUtils.java
deleted file mode 100644
index 7510ed4585..0000000000
--- a/common-tools/clas-io/src/main/java/org/jlab/io/utils/HipoFileUtils.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jlab.io.utils;
-
-import org.jlab.io.hipo.HipoDataSource;
-
-/**
- *
- * @author gavalian
- */
-public class HipoFileUtils {
-
- public static void hipoDump(String filename){
- HipoDataSource reader = new HipoDataSource();
- reader.open(filename);
-
- }
-
- public static void main(String[] args){
- String file = args[0];
- HipoFileUtils.hipoDump(file);
- }
-}
diff --git a/common-tools/clas-io/src/main/java/org/jlab/utils/EtProducer.java b/common-tools/clas-io/src/main/java/org/jlab/utils/EtProducer.java
index b17e700973..335b0c902a 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/utils/EtProducer.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/utils/EtProducer.java
@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package org.jlab.utils;
import java.io.IOException;
diff --git a/common-tools/clas-io/src/main/java/org/jlab/utils/FileUtils.java b/common-tools/clas-io/src/main/java/org/jlab/utils/FileUtils.java
index d1e865fada..fe76b951a0 100644
--- a/common-tools/clas-io/src/main/java/org/jlab/utils/FileUtils.java
+++ b/common-tools/clas-io/src/main/java/org/jlab/utils/FileUtils.java
@@ -8,7 +8,7 @@ public class FileUtils {
public static ArrayList filesInFolder(File folder, String ext)
{
- ArrayList file_list = new ArrayList();
+ ArrayList file_list = new ArrayList<>();
for (File f : folder.listFiles())
{
if (f.isDirectory())
@@ -30,7 +30,7 @@ public static ArrayList filesInFolder(File folder, String ext)
public static List dirListStartsWith(File folder, String starts)
{
- List file_list = new ArrayList();
+ List