diff --git a/bin/rebuild-scalers b/bin/rebuild-scalers
new file mode 100755
index 0000000000..18e769610c
--- /dev/null
+++ b/bin/rebuild-scalers
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+source `dirname $0`/env.sh
+
+MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX
+
+java -Xmx768m -Xms768m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.analysis.postprocess.RebuildScalers $*
diff --git a/common-tools/clas-analysis/pom.xml b/common-tools/clas-analysis/pom.xml
index 96b5060d95..a312bb7d98 100644
--- a/common-tools/clas-analysis/pom.xml
+++ b/common-tools/clas-analysis/pom.xml
@@ -3,14 +3,14 @@
4.0.0
org.jlab.clas
clas-analysis
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
jar
org.jlab.clas
clas12rec
../../parent/pom.xml
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
@@ -30,31 +30,31 @@
org.jlab.clas
clas-utils
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
org.jlab.clas
clas-physics
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
org.jlab.clas
clas-io
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
org.jlab.clas
clas-geometry
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
org.jlab.clas
clas-detector
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
diff --git a/common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess/RebuildScalers.java b/common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess/RebuildScalers.java
new file mode 100644
index 0000000000..b4e4133439
--- /dev/null
+++ b/common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess/RebuildScalers.java
@@ -0,0 +1,103 @@
+package org.jlab.analysis.postprocess;
+
+import java.sql.Time;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import org.jlab.detector.calib.utils.ConstantsManager;
+import org.jlab.detector.calib.utils.RCDBConstants;
+import org.jlab.detector.decode.DaqScalers;
+import org.jlab.jnp.hipo4.data.Bank;
+import org.jlab.jnp.hipo4.data.Event;
+import org.jlab.jnp.hipo4.io.HipoReader;
+import org.jlab.jnp.hipo4.io.HipoWriterSorted;
+import org.jlab.utils.groups.IndexedTable;
+import org.jlab.utils.options.OptionParser;
+import org.jlab.utils.system.ClasUtilsFile;
+
+/**
+ * Rebuild RUN::scaler from RAW::scaler
+ *
+ * @author baltzell
+ */
+public class RebuildScalers {
+
+ static final String CCDB_FCUP_TABLE="/runcontrol/fcup";
+
+ public static void main(String[] args) {
+
+ OptionParser parser = new OptionParser("rebuildscaler");
+ parser.addRequired("-o","output.hipo");
+ parser.parse(args);
+ List inputList = parser.getInputList();
+ if(inputList.isEmpty()==true){
+ parser.printUsage();
+ System.err.println("\n >>>> error : no input file is specified....\n");
+ System.exit(1);
+ }
+
+ HipoWriterSorted writer = new HipoWriterSorted();
+ writer.getSchemaFactory().initFromDirectory(ClasUtilsFile.getResourceDir("COATJAVA", "etc/bankdefs/hipo4"));
+ writer.setCompressionType(1);
+ writer.open(parser.getOption("-o").stringValue());
+
+ Event event = new Event();
+ Bank rawScalerBank = new Bank(writer.getSchemaFactory().getSchema("RAW::scaler"));
+ Bank runScalerBank = new Bank(writer.getSchemaFactory().getSchema("RUN::scaler"));
+ Bank runConfigBank = new Bank(writer.getSchemaFactory().getSchema("RUN::config"));
+
+ ConstantsManager conman = new ConstantsManager();
+ conman.init(Arrays.asList(new String[]{CCDB_FCUP_TABLE}));
+
+ for (String filename : inputList) {
+
+ HipoReader reader = new HipoReader();
+ reader.open(filename);
+
+ RCDBConstants rcdb = null;
+ IndexedTable ccdb = null;
+
+ while (reader.hasNext()) {
+
+ // read the event and necessary banks:
+ reader.nextEvent(event);
+ event.read(runConfigBank);
+ event.read(runScalerBank);
+ event.read(rawScalerBank);
+
+ // this is the bank we're here to rebuild:
+ event.remove(runScalerBank.getSchema());
+
+ // get CCDB/RCDB constants:
+ if (runConfigBank.getInt("run",0) >= 100) {
+ ccdb = conman.getConstants(runConfigBank.getInt("run",0),CCDB_FCUP_TABLE);
+ rcdb = conman.getRcdbConstants(runConfigBank.getInt("run",0));
+ }
+
+ // now rebuild the RUN::scaler bank:
+ if (rcdb!=null && ccdb !=null && rawScalerBank.getRows()>0) {
+
+ // Run duration in seconds. Nasty but works, until RCDB (uses java.sql.Time)
+ // is changed to support full date and not just HH:MM:SS. Meanwhile just
+ // requires that runs last less than 24 hours.
+ Date uet = new Date(runConfigBank.getInt("unixtime",0)*1000L);
+ Time rst = rcdb.getTime("run_start_time");
+ final double s1 = rst.getSeconds()+60*rst.getMinutes()+60*60*rst.getHours();
+ final double s2 = uet.getSeconds()+60*uet.getMinutes()+60*60*uet.getHours();
+ final double seconds = s24.0.0
org.jlab.clas
clas-detector
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
jar
org.jlab.clas
clas12rec
../../parent/pom.xml
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
@@ -30,7 +30,7 @@
org.jlab.clas
clas-utils
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
@@ -42,13 +42,13 @@
org.jlab.clas
clas-io
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
org.jlab.clas
clas-geometry
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalers.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalers.java
index 8102364c9d..6656cf9c47 100644
--- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalers.java
+++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalers.java
@@ -85,7 +85,7 @@ public static DaqScalers create(Bank rawScalerBank,IndexedTable fcupTable,double
if (dsc2.getClock() > 0) {
- float live = dsc2.getGatedSlm() / dsc2.getSlm();
+ float live = (float)dsc2.getGatedSlm() / dsc2.getSlm();
float q = (float)(dsc2.getFcup() - fcup_offset * seconds );
float qg = (float)(dsc2.getGatedFcup() - fcup_offset * seconds * live);
q *= fcup_atten / fcup_slope;
diff --git a/common-tools/clas-eventmerger/pom.xml b/common-tools/clas-eventmerger/pom.xml
index f48732911b..7f09d929c7 100644
--- a/common-tools/clas-eventmerger/pom.xml
+++ b/common-tools/clas-eventmerger/pom.xml
@@ -2,14 +2,14 @@
4.0.0
clas-eventmerger
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
jar
org.jlab.clas
clas12rec
../../parent/pom.xml
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
@@ -29,19 +29,19 @@
org.jlab.clas
clas-utils
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
org.jlab.clas
clas-io
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
org.jlab.clas
clas-geometry
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
diff --git a/common-tools/clas-geometry/pom.xml b/common-tools/clas-geometry/pom.xml
index 908157764b..0368135514 100644
--- a/common-tools/clas-geometry/pom.xml
+++ b/common-tools/clas-geometry/pom.xml
@@ -3,14 +3,14 @@
4.0.0
org.jlab.clas
clas-geometry
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
jar
org.jlab.clas
clas12rec
../../parent/pom.xml
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
diff --git a/common-tools/clas-io/pom.xml b/common-tools/clas-io/pom.xml
index 2195813842..d6f85b5d7c 100644
--- a/common-tools/clas-io/pom.xml
+++ b/common-tools/clas-io/pom.xml
@@ -3,14 +3,14 @@
4.0.0
org.jlab.clas
clas-io
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
jar
org.jlab.clas
clas12rec
../../parent/pom.xml
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
@@ -75,7 +75,7 @@
org.jlab.clas
clas-utils
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
diff --git a/common-tools/clas-jcsg/pom.xml b/common-tools/clas-jcsg/pom.xml
index cdcf3927af..5d92405f17 100644
--- a/common-tools/clas-jcsg/pom.xml
+++ b/common-tools/clas-jcsg/pom.xml
@@ -3,14 +3,14 @@
4.0.0
org.jlab.clas
clas-jcsg
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
jar
org.jlab.clas
clas12rec
../../parent/pom.xml
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
@@ -40,12 +40,12 @@
org.jlab.clas
clas-geometry
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
org.jlab.clas
clas-detector
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
java3d
diff --git a/common-tools/clas-math/pom.xml b/common-tools/clas-math/pom.xml
index 85931a22f2..04827bc90d 100644
--- a/common-tools/clas-math/pom.xml
+++ b/common-tools/clas-math/pom.xml
@@ -3,14 +3,14 @@
4.0.0
org.jlab.clas
clas-math
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
jar
org.jlab.clas
clas12rec
../../parent/pom.xml
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
diff --git a/common-tools/clas-physics/pom.xml b/common-tools/clas-physics/pom.xml
index cae0f269b8..444d97c9f5 100644
--- a/common-tools/clas-physics/pom.xml
+++ b/common-tools/clas-physics/pom.xml
@@ -4,7 +4,7 @@
org.jlab.clas
clas-physics
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
jar
@@ -23,7 +23,7 @@
org.jlab.clas
clas12rec
../../parent/pom.xml
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
diff --git a/common-tools/clas-reco/pom.xml b/common-tools/clas-reco/pom.xml
index 54a85fc890..35f7270827 100644
--- a/common-tools/clas-reco/pom.xml
+++ b/common-tools/clas-reco/pom.xml
@@ -3,14 +3,14 @@
4.0.0
org.jlab.clas
clas-reco
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
jar
org.jlab.clas
clas12rec
../../parent/pom.xml
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT
@@ -67,7 +67,7 @@
org.jlab.clas
clas-math
- 6.5.3-SNAPSHOT
+ 6.5.6-SNAPSHOT