Skip to content

Commit 6f19d0d

Browse files
committed
test: track usage of hard-coded scaler clock frequencies
The DSC2 and STRUCK scaler clock frequencies are stored in CCDB, but they are also hard-coded. This branch adds a magic number to each of the hard-coded assignments, and checks for that magic number when they're (likely) used. Printouts to `stderr` starting with `clockbug` are used to investigate.
1 parent d1eaa84 commit 6f19d0d

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/DaqScaler.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ public void add(DaqScaler other) {
7474
protected void calibrate(IndexedTable fcupTable,IndexedTable slmTable,double seconds,double liveSeconds) {
7575

7676
if (this.clock > 0) {
77+
78+
String prefix = String.format("clockbug [%s]", this.getClass().getSimpleName());
79+
if(Math.abs(this.clockFreq - ((1e6)+1)) < 0.1)
80+
System.err.println(String.format("%s: used hard-coded clockFreq from Dsc2Scaler(bank,table,table,seconds)", prefix));
81+
else if(Math.abs(this.clockFreq - ((1e6)+2)) < 0.1)
82+
System.err.println(String.format("%s: used hard-coded clockFreq from StruckScaler()", prefix));
83+
else if(Math.abs(this.clockFreq - ((1e6)+3)) < 0.1)
84+
System.err.println(String.format("%s: used hard-coded clockFreq from StruckScaler(table,table,table)", prefix));
85+
else
86+
System.err.println(String.format("%s: clockFreq OK (value=%f)", prefix, this.clockFreq));
87+
System.err.println(String.format("%s: %s", prefix, this.toString()));
88+
7789
final double fcup_slope = fcupTable.getDoubleValue("slope",0,0,0); // Hz/nA
7890
final double fcup_offset = fcupTable.getDoubleValue("offset",0,0,0); // Hz
7991
final double fcup_atten = fcupTable.getDoubleValue("atten",0,0,0); // attenuation
@@ -97,6 +109,7 @@ protected void calibrate(IndexedTable fcupTable,IndexedTable slmTable,double sec
97109
this.beamCharge = q * fcup_atten / fcup_slope;
98110
this.beamChargeGated = qg * fcup_atten / fcup_slope;
99111
}
112+
System.err.println(String.format("%s: beamCharge=%f beamChargeGated=%f", prefix, this.beamCharge, this.beamChargeGated));
100113
}
101114
}
102115

common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/Dsc2Scaler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public Dsc2Scaler() {}
3838
* @param seconds dwell time, provided in case the clock rolls over
3939
*/
4040
public Dsc2Scaler(Bank bank, IndexedTable fcupTable, IndexedTable slmTable, double seconds) {
41-
this.clockFreq=1e6;
41+
this.clockFreq=(1e6)+1;
4242
this.read(bank);
4343
this.calibrate(fcupTable,slmTable,seconds);
4444
}
@@ -110,4 +110,4 @@ public final void read(Bank bank) {
110110
}
111111
}
112112

113-
}
113+
}

common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/StruckScaler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public final Interval getStableInterval(Bank bank, IndexedTable helTable) {
164164
}
165165

166166
public StruckScaler() {
167-
this.clockFreq = 1e6;
167+
this.clockFreq = (1e6)+2;
168168
}
169169

170170
/**
@@ -178,7 +178,7 @@ public StruckScaler() {
178178
public StruckScaler(Bank bank,IndexedTable fcupTable, IndexedTable slmTable, IndexedTable helTable) {
179179

180180
// the STRUCK's clock is 1 MHz
181-
this.clockFreq = 1e6;
181+
this.clockFreq = (1e6)+3;
182182

183183
// Here we're going to assume the stable period is the same Struck
184184
// period throughout a single readout. Almost always correct ...
@@ -239,4 +239,4 @@ else if (Input.equals(Input.CLOCK, chan)) {
239239

240240
this.calibrate(fcupTable,slmTable);
241241
}
242-
}
242+
}

0 commit comments

Comments
 (0)