1 added + 4 modified, total 5 files
hps-java/src/main/java/org/lcsim/hps/recon/tracking
diff -u -r1.8 -r1.9
--- SvtUtils.java 12 Sep 2012 22:34:53 -0000 1.8
+++ SvtUtils.java 18 Sep 2012 19:56:58 -0000 1.9
@@ -1,14 +1,14 @@
package org.lcsim.hps.recon.tracking;
//--- java ---//
-import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
-import java.util.Properties;
import java.util.Set;
//--- org.lcsim ---//
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.conditions.ConditionsSet;
import org.lcsim.detector.IDetectorElement;
import org.lcsim.detector.identifier.IIdentifier;
import org.lcsim.detector.identifier.IIdentifierHelper;
@@ -22,7 +22,7 @@
/**
*
* @author Omar Moreno
- * @version $Id: SvtUtils.java,v 1.8 2012/09/12 22:34:53 meeg Exp $
+ * @version $Id: SvtUtils.java,v 1.9 2012/09/18 19:56:58 meeg Exp $
*/
public class SvtUtils {
@@ -51,6 +51,7 @@
private boolean isSetup = false;
boolean debug = false;
String subdetectorName = "Tracker";
+ ConditionsManager mgr = ConditionsManager.defaultInstance();
private SvtUtils() {
}
@@ -189,19 +190,13 @@
}
// Get the SVT DAQ Maps
- Properties topSvtDaqMap = new Properties();
- Properties bottomSvtDaqMap = new Properties();
- try {
- topSvtDaqMap.load(SvtUtils.class.getResourceAsStream("/org/lcsim/hps/calib/testrun/daqmap/SVTDAQMapTop.properties"));
- bottomSvtDaqMap.load(SvtUtils.class.getResourceAsStream("/org/lcsim/hps/calib/testrun/daqmap/SVTDAQMapBottom.properties"));
- } catch (IOException e) {
- throw new RuntimeException("couldn't get baseline list file", e);
- }
+ ConditionsSet topSvtDaqMap = mgr.getConditions("daqmap/SVTDAQMapTop");
+ ConditionsSet bottomSvtDaqMap = mgr.getConditions("daqmap/SVTDAQMapBottom");
String[] daqPair;
// Loop over the top layers and fill the DAQ map
for (Object topLayer : topSvtDaqMap.keySet()) {
- daqPair = topSvtDaqMap.getProperty(topLayer.toString()).split(" ");
+ daqPair = topSvtDaqMap.getString(topLayer.toString()).split(" ");
if (debug) {
System.out.println("Layer: " + topLayer.toString() + " FPGA: " + daqPair[1] + " Hybrid: " + daqPair[0]);
}
@@ -210,7 +205,7 @@
// Loop over the bottom layers and fill the DAQ Map
for (Object bottomLayer : bottomSvtDaqMap.keySet()) {
- daqPair = bottomSvtDaqMap.getProperty(bottomLayer.toString()).split(" ");
+ daqPair = bottomSvtDaqMap.getString(bottomLayer.toString()).split(" ");
if (debug) {
System.out.println("Layer: " + bottomLayer.toString() + " FPGA: " + daqPair[1] + " Hybrid: " + daqPair[0]);
}
hps-java/src/main/java/org/lcsim/hps/recon/tracking
diff -u -r1.18 -r1.19
--- HPSSVTCalibrationConstants.java 12 Sep 2012 22:34:53 -0000 1.18
+++ HPSSVTCalibrationConstants.java 18 Sep 2012 19:56:58 -0000 1.19
@@ -2,10 +2,10 @@
import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
import java.io.Reader;
import java.util.*;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.conditions.ConditionsSet;
import org.lcsim.detector.identifier.IIdentifier;
import org.lcsim.detector.identifier.IIdentifierHelper;
import org.lcsim.detector.tracker.silicon.SiSensor;
@@ -15,7 +15,7 @@
/**
*
* @author Mathew Graham <[log in to unmask]>
- * $Id: HPSSVTCalibrationConstants.java,v 1.18 2012/09/12 22:34:53 meeg Exp $
+ * $Id: HPSSVTCalibrationConstants.java,v 1.19 2012/09/18 19:56:58 meeg Exp $
*/
public class HPSSVTCalibrationConstants {
@@ -49,16 +49,12 @@
public static void loadCalibrationConstants(Date date) {
//write something here to read in constants from calibration file
+ ConditionsManager conditions = ConditionsManager.defaultInstance();
String filePath = null;
if (date != null) {
- Properties calibSet = new Properties();
- try {
- calibSet.load(HPSSVTCalibrationConstants.class.getResourceAsStream("/org/lcsim/hps/calib/testrun/calibSVT/base.properties"));
- } catch (IOException e) {
- throw new RuntimeException("couldn't get baseline list file", e);
- }
+ ConditionsSet calibSet = conditions.getConditions("calibSVT/base");
filePath = HPSCalibrationListener.getCalibForDate(calibSet, date);
}
@@ -66,16 +62,16 @@
filePath = "calibSVT/default.base";
}
- Reader baselineReader = new InputStreamReader(HPSSVTCalibrationConstants.class.getResourceAsStream("/org/lcsim/hps/calib/testrun/" + filePath));
- loadBaseline(baselineReader);
+ try {
+ Reader baselineReader = conditions.getRawConditions(filePath).getReader();
+ loadBaseline(baselineReader);
+ } catch (IOException e) {
+ throw new RuntimeException("couldn't get baseline file", e);
+ }
+
if (date != null) {
- Properties calibSet = new Properties();
- try {
- calibSet.load(HPSSVTCalibrationConstants.class.getResourceAsStream("/org/lcsim/hps/calib/testrun/calibSVT/tp.properties"));
- } catch (IOException e) {
- throw new RuntimeException("couldn't get Tp list file", e);
- }
+ ConditionsSet calibSet = conditions.getConditions("calibSVT/tp");
filePath = HPSCalibrationListener.getCalibForDate(calibSet, date);
}
@@ -83,8 +79,13 @@
filePath = "calibSVT/default.tp";
}
- Reader tpReader = new InputStreamReader(HPSSVTCalibrationConstants.class.getResourceAsStream("/org/lcsim/hps/calib/testrun/" + filePath));
- loadTp(tpReader);
+ try {
+ Reader tpReader = conditions.getRawConditions(filePath).getReader();
+ loadTp(tpReader);
+ } catch (IOException e) {
+ throw new RuntimeException("couldn't get Tp file", e);
+ }
+
}
private static void loadBaseline(Reader baselineReader) {
@@ -203,23 +204,30 @@
badChannelMap.clear();
System.out.println("Loading the SVT bad channels for run " + runNumber);
+ ConditionsManager conditions = ConditionsManager.defaultInstance();
+ BufferedReader reader;
+
// First load the bad channels found during QA (not run dependent)
String filePath = "daqmap/svt_qa.badchannels";
- Reader reader = new InputStreamReader(HPSSVTCalibrationConstants.class.getResourceAsStream("/org/lcsim/hps/calib/testrun/" + filePath));
- loadBadChannels(reader);
+ try {
+ reader = new BufferedReader(conditions.getRawConditions(filePath).getReader());
+ loadBadChannels(reader);
+ } catch (IOException exception) {
+ throw new RuntimeException("Unable to load bad channels for list " + filePath, exception);
+ }
// Load the bad channels for the specified run number
if (runNumber < 0) {
return;
}
filePath = "daqmap/svt" + runNumber + ".badchannels";
- InputStream stream = HPSSVTCalibrationConstants.class.getResourceAsStream("/org/lcsim/hps/calib/testrun/" + filePath);
- if (stream != null) {
- reader = new InputStreamReader(stream);
- } else {
+ try {
+ reader = new BufferedReader(conditions.getRawConditions(filePath).getReader());
+ loadBadChannels(reader);
+ } catch (IOException exception) {
+ // If the file isn't found, continue on with just the QA bad channels
System.out.println("File " + filePath + " was not found! Continuing with only QA bad channels");
}
- loadBadChannels(reader);
}
/**
@@ -262,12 +270,13 @@
System.out.println("Loading SVT gains ...");
+ ConditionsManager conditions = ConditionsManager.defaultInstance();
BufferedReader gainReader;
String filePath = "calibSVT/svt_default.gain";
String line = null;
try {
- gainReader = new BufferedReader(new InputStreamReader(HPSSVTCalibrationConstants.class.getResourceAsStream("/org/lcsim/hps/calib/testrun/" + filePath)));
+ gainReader = new BufferedReader(conditions.getRawConditions(filePath).getReader());
while ((line = gainReader.readLine()) != null) {
// If the line is a comment, skip it
if (line.indexOf("#") != -1) {
hps-java/src/main/java/org/lcsim/hps/recon/tracking
diff -u -r1.3 -r1.4
--- FieldMap.java 12 Sep 2012 22:34:53 -0000 1.3
+++ FieldMap.java 18 Sep 2012 19:56:58 -0000 1.4
@@ -2,9 +2,10 @@
import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStreamReader;
import java.io.Reader;
import java.util.*;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.conditions.ConditionsSet;
import org.lcsim.hps.monitoring.HPSCalibrationListener;
import org.lcsim.hps.util.Pair;
@@ -55,16 +56,12 @@
public static void loadFieldMap(Date date) {
//write something here to read in constants from calibration file
+ ConditionsManager conditions = ConditionsManager.defaultInstance();
String filePath = null;
if (date != null) {
- Properties calibSet = new Properties();
- try {
- calibSet.load(FieldMap.class.getResourceAsStream("/org/lcsim/hps/calib/testrun/FieldMap/bfieldmap"));
- } catch (IOException e) {
- throw new RuntimeException("couldn't get baseline list file", e);
- }
+ ConditionsSet calibSet = conditions.getConditions("FieldMap/bfieldmap");
filePath = HPSCalibrationListener.getCalibForDate(calibSet, date);
}
@@ -73,7 +70,7 @@
}
try {
- Reader baselineReader = new InputStreamReader(FieldMap.class.getResourceAsStream("/org/lcsim/hps/calib/testrun/" + filePath));
+ Reader baselineReader = conditions.getRawConditions(filePath).getReader();
loadBField(baselineReader);
} catch (IOException e) {
throw new RuntimeException("couldn't get baseline file", e);
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.18 -r1.19
--- HPSEcalConditions.java 12 Sep 2012 22:34:54 -0000 1.18
+++ HPSEcalConditions.java 18 Sep 2012 19:56:58 -0000 1.19
@@ -3,11 +3,11 @@
import java.io.BufferedReader;
import org.lcsim.geometry.compact.Subdetector;
import java.io.IOException;
-import java.io.InputStreamReader;
import java.io.Reader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;
+import org.lcsim.conditions.ConditionsManager;
import org.lcsim.detector.identifier.ExpandedIdentifier;
import org.lcsim.detector.identifier.IExpandedIdentifier;
import org.lcsim.detector.identifier.IIdentifierHelper;
@@ -17,7 +17,7 @@
/**
*
* @author meeg
- * @version $Id: HPSEcalConditions.java,v 1.18 2012/09/12 22:34:54 meeg Exp $
+ * @version $Id: HPSEcalConditions.java,v 1.19 2012/09/18 19:56:58 meeg Exp $
*/
public class HPSEcalConditions extends Driver {
@@ -90,10 +90,15 @@
}
public static void loadPedestals() {
- Reader pedestalsReader = new InputStreamReader(HPSEcalConditions.class.getResourceAsStream("/org/lcsim/hps/calib/testrun/calibECal/default01.ped"));
- loadPedestals(pedestalsReader, 1);
- pedestalsReader = new InputStreamReader(HPSEcalConditions.class.getResourceAsStream("/org/lcsim/hps/calib/testrun/calibECal/default02.ped"));
- loadPedestals(pedestalsReader, 2);
+ ConditionsManager conditions = ConditionsManager.defaultInstance();
+ try {
+ Reader pedestalsReader = conditions.getRawConditions("calibECal/default01.ped").getReader();
+ loadPedestals(pedestalsReader, 1);
+ pedestalsReader = conditions.getRawConditions("calibECal/default02.ped").getReader();
+ loadPedestals(pedestalsReader, 2);
+ } catch (IOException e) {
+ throw new RuntimeException("couldn't get pedestals file", e);
+ }
pedestalsLoaded = true;
}
@@ -137,7 +142,13 @@
IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields());
expId.setValue(helper.getFieldIndex("system"), ecal.getSystemID());
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(HPSEcalConditions.class.getResourceAsStream("/org/lcsim/hps/calib/testrun/daqmap/ecal.badchannels")));
+ ConditionsManager conditions = ConditionsManager.defaultInstance();
+ BufferedReader bufferedReader;
+ try {
+ bufferedReader = new BufferedReader(conditions.getRawConditions("daqmap/ecal.badchannels").getReader());
+ } catch (IOException e) {
+ throw new RuntimeException("couldn't get ECal bad channels from conditions manager", e);
+ }
String line;
while (true) {
try {
@@ -174,7 +185,13 @@
}
public static void loadGains() {
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(HPSEcalConditions.class.getResourceAsStream("/org/lcsim/hps/calib/testrun/calibECal/default.gain")));
+ BufferedReader bufferedReader;
+ ConditionsManager conditions = ConditionsManager.defaultInstance();
+ try {
+ bufferedReader = new BufferedReader(conditions.getRawConditions("calibECal/default.gain").getReader());
+ } catch (IOException e) {
+ throw new RuntimeException("couldn't get gain file", e);
+ }
String line;
while (true) {
@@ -218,8 +235,13 @@
IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields());
expId.setValue(helper.getFieldIndex("system"), ecal.getSystemID());
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(HPSEcalConditions.class.getResourceAsStream("/org/lcsim/hps/calib/testrun/daqmap/ecal.txt")));
-
+ ConditionsManager conditions = ConditionsManager.defaultInstance();
+ BufferedReader bufferedReader;
+ try {
+ bufferedReader = new BufferedReader(conditions.getRawConditions("daqmap/ecal.txt").getReader());
+ } catch (IOException e) {
+ throw new RuntimeException("couldn't get DAQ map from conditions manager", e);
+ }
String line;
while (true) {
try {
hps-java/src/main/java/org/lcsim/hps/conditions
diff -N TestRunConditionsReader.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TestRunConditionsReader.java 18 Sep 2012 19:56:58 -0000 1.1
@@ -0,0 +1,41 @@
+package org.lcsim.hps.conditions;
+
+import java.io.IOException;
+import java.io.InputStream;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.conditions.ConditionsReader;
+
+/**
+ *
+ * @author Sho Uemura <[log in to unmask]>
+ * @version $Id: TestRunConditionsReader.java,v 1.1 2012/09/18 19:56:58 meeg Exp $
+ */
+public class TestRunConditionsReader extends ConditionsReader {
+
+ private String detectorName = null;
+
+ public TestRunConditionsReader(ConditionsReader reader) {
+ }
+
+ @Override
+ public InputStream open(String name, String type) throws IOException {
+ InputStream in = getClass().getResourceAsStream("/org/lcsim/hps/calib/testrun/" + name + "." + type);
+ if (in == null) {
+ in = getClass().getResourceAsStream("/" + detectorName + "/" + name + "." + type);
+ if (in == null) {
+ throw new IOException("Conditions " + name + " for " + detectorName + " with type " + type + " were not found");
+ }
+ }
+ return in;
+ }
+
+ @Override
+ public void close() throws IOException {
+ }
+
+ @Override
+ protected boolean update(ConditionsManager manager, String detectorName, int run) throws IOException {
+ this.detectorName = detectorName;
+ return false;
+ }
+}
CVSspam 0.2.12