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

Commit

Permalink
moved zone definition to DaqScalers class and some simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
raffaelladevita authored and baltzell committed Mar 18, 2023
1 parent 8e3d555 commit ef1cb54
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -631,7 +629,7 @@ public List<Bank> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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());
}

/**
Expand Down Expand Up @@ -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));
}

/**
Expand Down Expand Up @@ -266,8 +267,8 @@ public static List<Bank> createBanks(SchemaFactory schema,Bank rawScalerBank,Ind
* @param uet event time
* @return [RUN::scaler,HEL::scaler] banks
*/
public static List<Bank> 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<Bank> 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));
}

}
Expand Down

0 comments on commit ef1cb54

Please sign in to comment.