From ef1cb546f5f00a634e4b90b2fa582e34662fc816 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Fri, 9 Dec 2022 22:22:11 +0100 Subject: [PATCH] moved zone definition to DaqScalers class and some simplification --- .../analysis/postprocess/RebuildScalers.java | 5 +---- .../jlab/detector/decode/CLASDecoder4.java | 4 +--- .../org/jlab/detector/scalers/DaqScalers.java | 19 ++++++++++--------- 3 files changed, 12 insertions(+), 16 deletions(-) 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 index 4126ee2922..7bac7172fd 100644 --- 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 @@ -1,7 +1,6 @@ package org.jlab.analysis.postprocess; import java.sql.Time; -import java.time.ZoneId; import java.util.Arrays; import java.util.List; import org.jlab.detector.calib.utils.ConstantsManager; @@ -28,8 +27,6 @@ public class RebuildScalers { static final String CCDB_SLM_TABLE="/runcontrol/slm"; static final String CCDB_HEL_TABLE="/runcontrol/helicity"; - static final ZoneId zoneId = ZoneId.of( "America/New_York" ); - public static void main(String[] args) { DefaultLogger.debug(); @@ -101,7 +98,7 @@ public static void main(String[] args) { Time rst = rcdb.getTime("run_start_time"); long uet = runConfigBank.getInt("unixtime",0); - DaqScalers ds = DaqScalers.create(rawScalerBank, ccdb_fcup, ccdb_slm, ccdb_hel, zoneId, rst, uet); + DaqScalers ds = DaqScalers.create(rawScalerBank, ccdb_fcup, ccdb_slm, ccdb_hel, rst, uet); runScalerBank = ds.createRunBank(writer.getSchemaFactory()); helScalerBank = ds.createHelicityBank(writer.getSchemaFactory()); diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java index 809fa9a6ba..fad9a5224a 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java @@ -5,7 +5,6 @@ import java.util.List; import java.sql.Time; -import java.time.ZoneId; import java.util.LinkedHashMap; import java.util.Map; import org.jlab.detector.base.DetectorDescriptor; @@ -47,7 +46,6 @@ public class CLASDecoder4 { private boolean isRunNumberFixed = false; private int decoderDebugMode = 0; private SchemaFactory schemaFactory = new SchemaFactory(); - private ZoneId timeZone = ZoneId.of( "America/New_York" ); public CLASDecoder4(boolean development){ codaDecoder = new CodaEventDecoder(); @@ -631,7 +629,7 @@ public List createReconScalerBanks(Event event){ // abort if no RCDB access (e.g. offsite) return ret; } - ret.addAll(DaqScalers.createBanks(schemaFactory,rawScalerBank,fcupTable,slmTable,helTable,timeZone,rst,uet)); + ret.addAll(DaqScalers.createBanks(schemaFactory,rawScalerBank,fcupTable,slmTable,helTable,rst,uet)); return ret; } diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/DaqScalers.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/DaqScalers.java index 9ecd392ca1..6c6b27d042 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/DaqScalers.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/DaqScalers.java @@ -53,6 +53,8 @@ public class DaqScalers { public void setTimestamp(long timestamp) { this.timestamp=timestamp; } public long getTimestamp(){ return this.timestamp; } + private static final ZoneId zoneId = ZoneId.of( "America/New_York" ); + /** * Get seconds between two dates assuming the differ by not more than 24 hours. * @@ -80,17 +82,16 @@ public static double getSeconds(Date rst,Date uet) { * Get seconds between two times specified as a local time and a unix time * assuming they differ by less than 24 h * - * @param zone run start time zone * @param rst run start local local time * @param uet unix event time * @return */ - public static double getSeconds(ZoneId zone, Time rst,long uet) { + public static double getSeconds(Time rst,long uet) { // seconds since 00:00:00, on their given day: - ZonedDateTime et = ZonedDateTime.ofInstant(Instant.ofEpochSecond(uet), zone); - ZonedDateTime st = ZonedDateTime.of(et.toLocalDate(), rst.toLocalTime(), zone); + ZonedDateTime et = ZonedDateTime.ofInstant(Instant.ofEpochSecond(uet), zoneId); + ZonedDateTime st = ZonedDateTime.of(et.toLocalDate(), rst.toLocalTime(), zoneId); if(st.isAfter(et)) st.minusDays(1L); - return (double) (et.toInstant().getEpochSecond()-st.toInstant().getEpochSecond()); + return (double) (et.toEpochSecond()-st.toEpochSecond()); } /** @@ -149,8 +150,8 @@ public static DaqScalers create(Bank rawScalerBank,IndexedTable fcupTable,Indexe * @param uet unix event time * @return */ - public static DaqScalers create(Bank rawScalerBank,IndexedTable fcupTable,IndexedTable slmTable,IndexedTable helTable,ZoneId zone,Time rst,long uet) { - return DaqScalers.create(rawScalerBank,fcupTable,slmTable,helTable,DaqScalers.getSeconds(zone, rst, uet)); + public static DaqScalers create(Bank rawScalerBank,IndexedTable fcupTable,IndexedTable slmTable,IndexedTable helTable,Time rst,long uet) { + return DaqScalers.create(rawScalerBank,fcupTable,slmTable,helTable,DaqScalers.getSeconds(rst, uet)); } /** @@ -266,8 +267,8 @@ public static List createBanks(SchemaFactory schema,Bank rawScalerBank,Ind * @param uet event time * @return [RUN::scaler,HEL::scaler] banks */ - public static List createBanks(SchemaFactory schema,Bank rawScalerBank,IndexedTable fcupTable,IndexedTable slmTable,IndexedTable helTable,ZoneId zone,Time rst,long uet) { - return DaqScalers.createBanks(schema,rawScalerBank,fcupTable,slmTable,helTable,DaqScalers.getSeconds(zone,rst,uet)); + public static List createBanks(SchemaFactory schema,Bank rawScalerBank,IndexedTable fcupTable,IndexedTable slmTable,IndexedTable helTable,Time rst,long uet) { + return DaqScalers.createBanks(schema,rawScalerBank,fcupTable,slmTable,helTable,DaqScalers.getSeconds(rst,uet)); } }