LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  October 2014

HPS-SVN October 2014

Subject:

r1259 - in /java/branches/hps_java_trunk_HPSJAVA-255/conditions/src: main/java/org/hps/conditions/svt/SvtDaqMapping.java main/java/org/hps/conditions/svt/TestRunSvtDaqMapping.java test/java/org/hps/conditions/svt/TestRunSvtDaqMappingTest.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Wed, 22 Oct 2014 07:12:01 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (226 lines)

Author: omoreno
Date: Wed Oct 22 00:11:54 2014
New Revision: 1259

Log:
Work in progress on a DAQ mapping class for the test run.

Added:
    java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtDaqMapping.java   (with props)
    java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtDaqMappingTest.java   (with props)
Modified:
    java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/SvtDaqMapping.java

Modified: java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/SvtDaqMapping.java
 =============================================================================
--- java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/SvtDaqMapping.java	(original)
+++ java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/SvtDaqMapping.java	Wed Oct 22 00:11:54 2014
@@ -12,7 +12,7 @@
  * @author Jeremy McCormick <[log in to unmask]>
  * @author Omar Moreno <[log in to unmask]>
  */
-public final class SvtDaqMapping extends AbstractConditionsObject {
+public class SvtDaqMapping extends AbstractConditionsObject {
 
     public static class SvtDaqMappingCollection extends ConditionsObjectCollection<SvtDaqMapping> {
 

Added: java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtDaqMapping.java
 =============================================================================
--- java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtDaqMapping.java	(added)
+++ java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtDaqMapping.java	Wed Oct 22 00:11:54 2014
@@ -0,0 +1,121 @@
+package org.hps.conditions.svt;
+
+import org.lcsim.detector.tracker.silicon.HpsSiSensor;
+import org.lcsim.detector.tracker.silicon.HpsTestRunSiSensor;
+import org.hps.util.Pair;
+
+/**
+ * This class encapsulates the Test run SVT DAQ map.
+ * 
+ * @author Omar Moreno <[log in to unmask]>
+ */
+public class TestRunSvtDaqMapping extends SvtDaqMapping {
+
+	public static class SvtDaqMappingCollection extends SvtDaqMapping.SvtDaqMappingCollection {
+	
+		/**
+		 * Get a test run DAQ pair (FPGA and Hybrid ID) for the given 
+		 * {@linkplain HpsTestRunSiSensor}
+		 * 
+		 * @param  sensor A sensor of type {@link HpsTestRunSiSensor}
+		 * @return The DAQ pair associated with the sensor 
+		 */
+		@Override
+		Pair<Integer, Integer> getDaqPair(HpsSiSensor sensor){
+			
+			String svtHalf = sensor.isTopLayer() ? TOP_HALF : BOTTOM_HALF; 
+			for(SvtDaqMapping daqMapping : this.getObjects()){
+				
+				if(svtHalf.equals(daqMapping.getSvtHalf())
+						&& daqMapping.getLayerNumber() == sensor.getLayerNumber()){
+					
+					return new Pair<Integer, Integer>(((TestRunSvtDaqMapping) daqMapping).getFpgaID(), 
+													  ((TestRunSvtDaqMapping) daqMapping).getHybridID());
+				}
+			}
+			return null;
+		}
+		
+        /**
+         * Get the orientation of a sensor using the FPGA and Hybrid ID.
+         * If the FPGA and Hybrid ID combination is not found, return null.
+         * 
+         * @param daqPair (Pair<FPGA ID, Hybrid ID>) for a given sensor
+         * @return If a daqPair is found, return an "A" if the sensor 
+         * 		   orientation is Axial, an "S" if the orientation is Stereo or
+         * 		   null if the daqPair doesn't exist.
+         */
+		@Override
+        public String getOrientation(Pair<Integer, Integer> daqPair){
+        	
+        	for(SvtDaqMapping daqMapping : this.getObjects()){
+        		
+        		if(daqPair.getFirstElement() == ((TestRunSvtDaqMapping) daqMapping).getFpgaID()
+        				&& daqPair.getSecondElement() == ((TestRunSvtDaqMapping) daqMapping).getHybridID()){
+        			return daqMapping.getOrientation(); 
+        		}
+        	}
+        	return null;
+        }
+		
+		
+        /**
+         * Convert {@link TestRunSvtDaqMapping} to a string.
+         * @return This object converted to a string.
+         */
+        public String toString() {
+        	StringBuffer buffer = new StringBuffer(); 
+        	buffer.append("FPGA ID: ");
+            buffer.append(" ");
+            buffer.append("Hybrid ID: ");
+            buffer.append(" ");
+            buffer.append("SVT half: ");
+            buffer.append(" ");
+            buffer.append("Layer");
+            buffer.append(" ");
+            buffer.append("Orientation: ");
+            buffer.append(" ");
+            buffer.append('\n');
+            buffer.append("----------------------");
+            buffer.append('\n');
+            for (SvtDaqMapping daqMapping : getObjects()){
+            	TestRunSvtDaqMapping testRunDaqMapping = (TestRunSvtDaqMapping) daqMapping; 
+            	buffer.append(testRunDaqMapping.getFpgaID());
+                buffer.append("    ");
+            	buffer.append(testRunDaqMapping.getHybridID());
+                buffer.append("    ");
+                buffer.append(testRunDaqMapping.getSvtHalf());
+                buffer.append("    ");
+                buffer.append(String.format("%-2d", testRunDaqMapping.getLayerNumber()));
+                buffer.append("    ");
+                buffer.append(testRunDaqMapping.getOrientation());
+                buffer.append("    ");
+                buffer.append('\n');
+            }
+        	return buffer.toString();
+        }
+	}
+	
+	public int getFpgaID(){
+		return getFieldValue("fpga");
+	}
+	
+	public int getHybridID(){
+		return getFieldValue("hybrid");
+	}
+
+	// TODO: Instead of throwing an exception, these classes should be pulled out to
+	//		 a subclass.
+    public int getFebID() { 
+    	throw new UnsupportedOperationException("The test run DAQ map doesn't use FEB ID's.");
+    }
+    
+    public int getFebHybridID() { 
+    	throw new UnsupportedOperationException("The test run DAQ map doesn't use FEB Hybrid ID's.");
+    }
+    
+    public String getSide(){
+    	throw new UnsupportedOperationException("The test run DAQ map doesn't use a side.");
+    }
+	
+}

Added: java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtDaqMappingTest.java
 =============================================================================
--- java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtDaqMappingTest.java	(added)
+++ java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtDaqMappingTest.java	Wed Oct 22 00:11:54 2014
@@ -0,0 +1,66 @@
+package org.hps.conditions.svt;
+
+import junit.framework.TestCase;
+
+import org.hps.conditions.DatabaseConditionsManager;
+import org.hps.conditions.TableMetaData;
+import org.hps.conditions.config.TestRunReadOnlyConfiguration;
+import org.hps.conditions.svt.TestRunSvtDaqMapping.SvtDaqMappingCollection;
+
+/**
+ * This test checks if the test run SVT DAQ map was loaded with reasonable 
+ * values and is being read correctly from the conditions database.
+ * 
+ * @author Omar Moreno <[log in to unmask]>
+ */
+public class TestRunSvtDaqMappingTest extends TestCase {
+
+	TableMetaData metaData = null;
+	DatabaseConditionsManager conditionsManager = null;
+	
+	//--- Constants ---//
+	//-----------------//
+	
+	// Total number of SVT sensors
+	public static final int TOTAL_NUMBER_OF_SENSORS = 20;
+	// Min and max values of front end boad (FEB) hybrid ID's
+	public static final int MIN_HYBRID_ID = 0; 
+	public static final int MAX_HYBRID_ID = 2; 
+	
+	
+	
+	public void setUp(){
+        new TestRunReadOnlyConfiguration().setup().load("HPS-TestRun-v5", 0);
+        conditionsManager = DatabaseConditionsManager.getInstance();
+	}
+	
+	public void test(){
+		
+		metaData = conditionsManager.findTableMetaData(SvtDaqMappingCollection.class);
+		SvtDaqMappingCollection daqMappingCollection 
+			= conditionsManager.getConditionsData(SvtDaqMappingCollection.class, metaData.getTableName());
+
+	
+		int totalSensors = 0; 
+		int fpgaID;
+		int hybridID; 
+		this.printDebug("");
+		for(SvtDaqMapping daqMapping : daqMappingCollection){
+			
+			this.printDebug("Sensor: \n" + ((TestRunSvtDaqMapping) daqMapping).toString());
+			
+			// Check that the Hybrid ID is within the allowable limits
+			hybridID = ((TestRunSvtDaqMapping) daqMapping).getHybridID();
+			assertTrue("Hybrid ID is out of range!.", hybridID >= MIN_HYBRID_ID && hybridID <= MAX_HYBRID_ID);
+			
+			totalSensors++;
+		}
+		
+		this.printDebug("Total number of sensors found: " + totalSensors);
+		assertTrue(totalSensors == TOTAL_NUMBER_OF_SENSORS);
+	}
+
+	private void printDebug(String debugMessage){
+		System.out.println("[ " + this.getClass().getSimpleName() + " ]: " + debugMessage);
+	}
+}

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use