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  February 2015

HPS-SVN February 2015

Subject:

r2078 - in /java/trunk/evio/src/main/java/org/hps/evio: AbstractSvtEvioReader.java LCSimEngRunEventBuilder.java SvtEvioReader.java SvtEvioUtils.java TestRunSvtEvioReader.java

From:

[log in to unmask]

Reply-To:

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

Date:

Mon, 9 Feb 2015 04:29:17 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (787 lines)

Author: [log in to unmask]
Date: Sun Feb  8 20:29:11 2015
New Revision: 2078

Log:
Update AbstractSvtEvioReader to handle engineering run SVT EVIO data.  Create the engineering run SvtEvioReader. Update TestRunSvtEvioReader to implement all abstract methods added to AbstractSvtEvioReader. Add the SVT reader to the event builder.

Added:
    java/trunk/evio/src/main/java/org/hps/evio/SvtEvioReader.java   (with props)
Modified:
    java/trunk/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java
    java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java
    java/trunk/evio/src/main/java/org/hps/evio/SvtEvioUtils.java
    java/trunk/evio/src/main/java/org/hps/evio/TestRunSvtEvioReader.java

Modified: java/trunk/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java
 =============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java	(original)
+++ java/trunk/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java	Sun Feb  8 20:29:11 2015
@@ -5,16 +5,19 @@
 import java.util.List;
 import java.util.Map;
 
+import org.jlab.coda.jevio.DataType;
 import org.jlab.coda.jevio.EvioEvent;
+import org.jlab.coda.jevio.IEvioFilter;
+import org.jlab.coda.jevio.IEvioStructure;
 import org.jlab.coda.jevio.StructureFinder;
 import org.jlab.coda.jevio.BaseStructure;
-
+import org.jlab.coda.jevio.StructureType;
 import org.lcsim.detector.tracker.silicon.HpsSiSensor;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.RawTrackerHit;
+import org.lcsim.event.base.BaseRawTrackerHit;
 import org.lcsim.geometry.Subdetector;
 import org.lcsim.lcio.LCIOUtil;
-
 import org.hps.util.Pair;
 
 /**
@@ -46,19 +49,27 @@
 	private static final String READOUT_NAME = "TrackerHits";
 
 	/**
-	 *	Get the maximum data bank tag in the event.
-	 *
-	 * @return Maximum data bank tag
-	 */
-	abstract protected int getMaxDataBankTag();
-
-	/**
-	 *	Get the SVT bank tag
-	 *
-	 *	@return SVT bank tag 
-	 */
-	abstract protected int getSvtBankTag();
-
+	 *	Get the minimum SVT ROC bank tag in the event.
+	 *
+	 *	@return Minimum SVT ROC bank tag
+	 */
+	abstract protected int getMinRocBankTag(); 
+	
+	/**
+	 *	Get the maximum SVT ROC bank tag in the event.
+	 *
+	 *	@return Maximum SVT ROC bank tag
+	 */
+	abstract protected int getMaxRocBankTag(); 
+	
+
+	/**
+	 *	Get the SVT ROC bank number of the bank encapsulating the SVT samples.
+	 * 
+	 *	@return SVT ROC bank number 
+	 */
+	abstract protected int getRocBankNumber(); 
+	
 	/**
 	 *	Get the number of 32 bit integers composing the data block header
 	 *
@@ -91,14 +102,15 @@
 	 */
 	abstract protected HpsSiSensor getSensor(int[] data);
 
-	/**
-	 * 	Make a {@link RawTrackerHit} from a set of samples.
-	 * 
-	 *	@param data - sample block of data
-	 * 	@return A raw hit
-	 */
-	abstract protected RawTrackerHit makeHit(int[] data);
-
+
+	/**
+	 *	Check whether a data bank is valid i.e. contains SVT samples only.
+	 * 
+	 * 	@param dataBank - An EVIO bank containing integer data
+	 * 	@return true if the bank is valid, false otherwise
+	 */
+	abstract protected boolean isValidDataBank(BaseStructure dataBank); 	
+	
 	/**
 	 *	Process an EVIO event and extract all information relevant to the SVT.
 	 *	
@@ -107,8 +119,7 @@
 	 *	@return true if the EVIO was processed successfully, false otherwise 
 	 */
 	public boolean processEvent(EvioEvent event, EventHeader lcsimEvent) {
-		this.makeHits(event, lcsimEvent);
-		return true;
+		return this.makeHits(event, lcsimEvent);
 	}
 
 	/**
@@ -122,6 +133,8 @@
 	 */
 	public boolean makeHits(EvioEvent event, EventHeader lcsimEvent) {
 
+		this.setDebug(true);
+		
 		// Setup the DAQ map if it's not setup
 		if (!this.isDaqMapSetup)
 			this.setupDaqMap(lcsimEvent.getDetector().getSubdetector(
@@ -130,66 +143,145 @@
 		// Clear the list of raw tracker hits
 		rawHits.clear();
 
-		// Get the SVT data banks encapsulated by the physics event. There
-		// should only be a single SVT bank that contains all physics data.
-		// FIXME: Change the tag name so it's clear that we are referring to
-		// the data bank
-		List<BaseStructure> svtBanks = StructureFinder.getMatchingStructures(
-				event, this.getSvtBankTag());
-
-		// If there wasn't any SVT banks found, return false
-		if (svtBanks.isEmpty())
-			return false;
-
-		// Check that the SVT bank contains data banks. If not, throw an
-		// exception
-		if (svtBanks.get(0).getChildCount() == 0) {
-			throw new RuntimeException("[ " + this.getClass().getSimpleName()
-					+ " ]: SVT bank doesn't contain any data banks.");
+		// Retrieve the ROC banks encapsulated by the physics bank.  The ROC
+		// bank range is set in the subclass.
+		List<BaseStructure> rocBanks = new ArrayList<BaseStructure>();
+		for (int rocBankTag = this.getMinRocBankTag(); 
+				rocBankTag <= this.getMaxRocBankTag(); rocBankTag++) { 
+			
+			this.printDebug("Retrieving ROC bank: " + rocBankTag);
+			if (this.getRocBankNumber() == -1) { 
+				rocBanks.addAll(this.getMatchingBanks(event, rocBankTag));
+			} else { 
+				rocBanks.addAll(StructureFinder.getMatchingBanks(event, rocBankTag, this.getRocBankNumber()));
+			}
 		}
-
-		// Loop over the SVT data banks
-		for (BaseStructure dataBank : svtBanks.get(0).getChildrenList()) {
-
-			// Get the bank tag and check whether it's within the allowable
-			// ranges. If not, throw an exception
-			int dataBankTag = dataBank.getHeader().getTag();
-			if (dataBankTag < MIN_DATA_BANK_TAG
-					|| dataBankTag > this.getMaxDataBankTag()) {
-				throw new RuntimeException("[ "
-						+ this.getClass().getSimpleName()
-						+ " ]: Unexpected data bank tag:  " + dataBankTag);
-			}
-
-			// Get the int data encapsulated by the data bank
-			int[] data = dataBank.getIntData();
-
-			// Check that a complete set of samples exist
-			int sampleCount = data.length - this.getDataHeaderLength()
-					- this.getDataTailLength();
-			//System.out.println("[ " + this.getClass().getSimpleName()
-			//		+ " ]: Sample count: " + sampleCount);
-			if (sampleCount % 4 != 0) {
-				throw new RuntimeException("[ "
-						+ this.getClass().getSimpleName()
-						+ " ]: Size of samples array is not divisible by 4");
-			}
-
-			// Loop through all of the samples and make hits
-			for (int samplesN = 0; samplesN < sampleCount; samplesN += 4) {
-
-				int[] samples = new int[4];
-				System.arraycopy(data, this.getDataHeaderLength() + samplesN, samples, 0, samples.length);
-				rawHits.add(this.makeHit(samples));
+		this.printDebug("Total ROC banks found: " + rocBanks.size());
+		
+		// Return false if ROC banks weren't found
+		if (rocBanks.isEmpty()) return false;  
+	
+		// Loop over the SVT ROC banks and process all samples
+		for (BaseStructure rocBank : rocBanks) { 
+			
+			this.printDebug("ROC bank: " + rocBank.toString());
+			
+			this.printDebug("Processing ROC bank " + rocBank.getHeader().getTag());
+			
+			// If the ROC bank doesn't contain any data, raise an exception
+			if (rocBank.getChildCount() == 0) { 
+				throw new RuntimeException("[ " + this.getClass().getSimpleName() 
+						+ " ]: SVT bank doesn't contain any data banks.");
+			}
+			
+			// Get the data banks containing the SVT samples.  
+			List<BaseStructure> dataBanks = rocBank.getChildren(); 
+			this.printDebug("Total data banks found: " + dataBanks.size());
+			
+			// Loop over all of the data banks contained by the ROC banks and 
+			// processed them
+			for (BaseStructure dataBank : dataBanks) { 
+		
+				this.printDebug("Processing data bank: " + dataBank.toString());
+			
+				// Check that the bank is valid
+				if (!this.isValidDataBank(dataBank)) continue;
+				
+				// Get the int data encapsulated by the data bank
+				int[] data = dataBank.getIntData();
+				this.printDebug("Total number of integers contained by the data bank: " + data.length);
+		
+				// Check that a complete set of samples exist
+				int sampleCount = data.length - this.getDataHeaderLength()
+						- this.getDataTailLength();
+				this.printDebug("Total number of  samples: " + sampleCount);
+				if (sampleCount % 4 != 0) {
+					throw new RuntimeException("[ "
+							+ this.getClass().getSimpleName()
+							+ " ]: Size of samples array is not divisible by 4");
+				}
+
+				// Loop through all of the samples and make hits
+				for (int samplesN = 0; samplesN < sampleCount; samplesN += 4) {
+
+					int[] samples = new int[4];
+					System.arraycopy(data, this.getDataHeaderLength() + samplesN, samples, 0, samples.length);
+					rawHits.add(this.makeHit(samples));
+				}
 			}
 		}
+		
+		this.printDebug("Total number of RawTrackerHits created: " + rawHits.size());
 
 		// Turn on 64-bit cell ID.
 		int flag = LCIOUtil.bitSet(0, 31, true);
 		// Add the collection of raw hits to the LCSim event
-		lcsimEvent.put(SVT_HIT_COLLECTION_NAME, rawHits, RawTrackerHit.class,
-				flag, READOUT_NAME);
+		lcsimEvent.put(SVT_HIT_COLLECTION_NAME, rawHits, RawTrackerHit.class, flag, READOUT_NAME);
 
 		return true;
 	}
+
+	/**
+	 * 	Make a {@link RawTrackerHit} from a set of samples.
+	 * 
+	 *	@param data : sample block of data
+	 * 	@return A raw hit
+	 */
+	protected abstract RawTrackerHit makeHit(int[] data); 
+	
+	/**
+	 * 	Make a {@link RawTrackerHit} from a set of samples.
+	 * 
+	 *	@param data : Sample block of data
+	 *	@param channel : Channel number associated with these samples
+	 * 	@return A raw hit
+	 */
+	protected RawTrackerHit makeHit(int[] data, int channel) { 
+
+		// Get the sensor associated with this sample
+		HpsSiSensor sensor = this.getSensor(data);
+		//this.printDebug(sensor.toString());
+		
+		// Use the channel number to create the cell ID
+		long cellID = sensor.makeChannelID(channel);
+		
+		// Set the hit time.  For now this will be zero
+		int hitTime = 0;
+	
+		// Create and return a RawTrackerHit
+		return new BaseRawTrackerHit(hitTime, cellID, SvtEvioUtils.getSamples(data), null, sensor);
+	}
+	
+
+	/**
+	 *	Print a debug message
+	 * 
+	 * 	@param message : Debug message to print
+	 */
+	void printDebug(String message) { 
+		if (debug) System.out.println("[ " + this.getClass().getSimpleName() + " ]: " + message);
+	}
+	
+	/**
+	 *	Retrieve all the banks in an event that match the given tag in their
+	 *	header and are not data banks. 
+	 *
+	 * 	@param structure : The event/bank being queried
+	 * 	@param tag : The tag to match
+	 * 	@return A collection of all bank structures that pass the filter 
+	 * 			provided by the event
+	 */
+	// TODO: Move this to an EVIO utils class
+	private List<BaseStructure> getMatchingBanks(BaseStructure structure, final int tag) { 
+		IEvioFilter filter = new IEvioFilter() { 
+			public boolean accept(StructureType type, IEvioStructure struc) { 
+				return (type == StructureType.BANK) 
+						&& (tag == struc.getHeader().getTag())
+						&& (struc.getHeader().getDataType() == DataType.ALSOBANK);
+			}
+		};
+		return StructureFinder.getMatchingStructures(structure, filter);
+	}
+
+
 }

Modified: java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java
 =============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java	(original)
+++ java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java	Sun Feb  8 20:29:11 2015
@@ -5,14 +5,17 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.jlab.coda.jevio.BaseStructure;
+import org.jlab.coda.jevio.EvioEvent;
+
+import org.lcsim.event.EventHeader;
+
 import org.hps.readout.ecal.triggerbank.AbstractIntData;
 import org.hps.readout.ecal.triggerbank.SSPData;
 import org.hps.readout.ecal.triggerbank.TIData;
 import org.hps.readout.ecal.triggerbank.TriggerConfig;
 import org.hps.record.evio.EvioEventUtilities;
-import org.jlab.coda.jevio.BaseStructure;
-import org.jlab.coda.jevio.EvioEvent;
-import org.lcsim.event.EventHeader;
+
 
 /**
  * Build LCSim events from EVIO data.
@@ -25,13 +28,13 @@
     public LCSimEngRunEventBuilder() {
         ecalReader.setTopBankTag(0x25);
         ecalReader.setBotBankTag(0x27);
+        svtReader = new SvtEvioReader(); 
         sspCrateBankTag = 0x2E; //A.C. modification after Sergey's confirmation
         sspBankTag = 0xe10c;
         intBanks = new ArrayList<IntBankDefinition>();
         intBanks.add(new IntBankDefinition(SSPData.class, new int[]{sspCrateBankTag, sspBankTag}));
         intBanks.add(new IntBankDefinition(TIData.class, new int[]{sspCrateBankTag, 0xe10a}));
         // ecalReader = new ECalEvioReader(0x25, 0x27);
-        // svtReader = new SVTEvioReader();
     }
 
     @Override

Added: java/trunk/evio/src/main/java/org/hps/evio/SvtEvioReader.java
 =============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/SvtEvioReader.java	(added)
+++ java/trunk/evio/src/main/java/org/hps/evio/SvtEvioReader.java	Sun Feb  8 20:29:11 2015
@@ -0,0 +1,147 @@
+package org.hps.evio;
+
+import java.util.List;
+
+import org.jlab.coda.jevio.BaseStructure;
+import org.lcsim.detector.tracker.silicon.HpsSiSensor;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.geometry.Subdetector;
+import org.hps.util.Pair;
+
+/**
+ *	SVT EVIO reader used to convert SVT bank integer data to LCIO objects.
+ * 
+ * 	@author Omar Moreno <[log in to unmask]>
+ * 	@data February 03, 2015
+ *
+ */
+public final class SvtEvioReader extends AbstractSvtEvioReader {
+
+	//-----------------//
+	//--- Constants ---//
+	//-----------------//
+	private static final int DATA_HEADER_LENGTH = 1;
+	private static final int DATA_TAIL_LENGTH = 1; 
+	private static final int MIN_ROC_BANK_TAG = 11;
+	private static final int MAX_ROC_BANK_TAG = 17;
+	private static final int ROC_BANK_NUMBER = 0; 
+	
+	/**
+	 *	Get the minimum SVT ROC bank tag in the event.
+	 *
+	 *	@return Minimum SVT ROC bank tag
+	 */
+	@Override
+	protected int getMinRocBankTag() { 
+		return MIN_ROC_BANK_TAG; 
+	}
+
+	/**
+	 *	Get the maximum SVT ROC bank tag in the event.
+	 *
+	 *	@return Maximum SVT ROC bank tag
+	 */
+	@Override 
+	protected int getMaxRocBankTag() { 
+		return MAX_ROC_BANK_TAG; 
+	}
+	
+	/**
+	 *	Get the SVT ROC bank number of the bank encapsulating the SVT samples.
+	 * 
+	 *	@return SVT ROC bank number 
+	 */
+	@Override
+	protected int getRocBankNumber() { 
+		return ROC_BANK_NUMBER; 
+	}
+
+	/**
+	 *	Get the number of 32 bit integers composing the data block header
+	 *
+	 *	@return The header length
+	 */
+	@Override
+	protected int getDataHeaderLength() {
+		return DATA_HEADER_LENGTH;
+	}
+
+	/**
+	 *	Get the number of 32 bit integers composing the data block tail (the 
+	 *	data inserted after all sample blocks in a data block)
+	 * 
+	 *	@return The tail length 
+	 */
+	@Override
+	protected int getDataTailLength() {
+		return DATA_TAIL_LENGTH;
+	}
+
+	/**
+	 *	A method to setup a mapping between a DAQ pair (FEB/FEB Hybrid) and the 
+	 *	corresponding sensor.
+	 *
+	 *	@param subdetector : The tracker {@link Subdetector} object
+	 */
+	// TODO: This can probably be done when the conditions are loaded.
+	@Override
+	protected void setupDaqMap(Subdetector subdetector) {
+	
+		List<HpsSiSensor> sensors 
+			= subdetector.getDetectorElement().findDescendants(HpsSiSensor.class);
+		for (HpsSiSensor sensor : sensors) { 
+			Pair<Integer, Integer> daqPair 
+				= new Pair<Integer, Integer>(sensor.getFebID(), sensor.getFebHybridID());
+			daqPairToSensor.put(daqPair, sensor);
+		}
+		this.isDaqMapSetup = true; 
+	}
+
+	/**
+	 *	Get the sensor associated with a set of samples.  The sample block of
+	 *	data is used to extract the FEB ID and FEB Hybrid ID corresponding to 
+	 *	the samples. 
+	 *
+	 *	@param data : sample block of data
+	 *	@return The sensor associated with a set of sample 
+	 */
+	@Override
+	protected HpsSiSensor getSensor(int[] data) {
+		
+		this.printDebug("FEB ID: " + SvtEvioUtils.getFebID(data) 
+				+ " Hybrid ID: " + SvtEvioUtils.getFebHybridID(data));
+		
+		Pair<Integer, Integer> daqPair 
+			= new Pair<Integer, Integer>(SvtEvioUtils.getFebID(data), 
+										 SvtEvioUtils.getFebHybridID(data));
+		
+		return daqPairToSensor.get(daqPair);
+	}
+	
+	/**
+	 *	Check whether a data bank is valid i.e. contains SVT samples only.  For
+	 *	the engineering run, a valid data bank has a tag of 1.
+	 * 
+	 * 	@param dataBank - An EVIO bank containing integer data
+	 * 	@return true if the bank is valid, false otherwise
+	 * 
+	 */
+	@Override
+	protected boolean isValidDataBank(BaseStructure dataBank) { 
+		if (dataBank.getHeader().getTag() != 1) return false; 
+		return true; 
+	}
+
+	/**
+	 * 	Make a {@link RawTrackerHit} from a set of samples.
+	 * 
+	 *	@param data : sample block of data
+	 * 	@return A raw hit
+	 */
+	@Override
+	protected RawTrackerHit makeHit(int[] data) {
+		//this.printDebug("Channel: " + SvtEvioUtils.getChannelNumber(data));
+		return makeHit(data, SvtEvioUtils.getChannelNumber(data));
+	}
+
+}

Modified: java/trunk/evio/src/main/java/org/hps/evio/SvtEvioUtils.java
 =============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/SvtEvioUtils.java	(original)
+++ java/trunk/evio/src/main/java/org/hps/evio/SvtEvioUtils.java	Sun Feb  8 20:29:11 2015
@@ -13,16 +13,23 @@
 	//-----------------//
 	
 	private static final int TOTAL_SAMPLES = 6;
+    public static final int  SAMPLE_MASK = 0xFFFF;
 	
-	// --- Test Run ---//
+	//--- Test Run ---//
 	private static final int TEST_RUN_SAMPLE_HEADER_INDEX = 0; 
     public static final int  FPGA_MASK = 0xFFFF;
     public static final int  HYBRID_MASK = 0x3;
     public static final int  TEST_RUN_CHANNEL_MASK = 0x7F;
-    public static final int  SAMPLE_MASK = 0x3FFF;
 
+    //--- Engineering Run ---//
+    private static final int ENG_RUN_SAMPLE_HEADER_INDEX = 3; 
+    private static final int FEB_MASK = 0xFF;
+    private static final int FEB_HYBRID_MASK = 0x3;
+    private static final int ENG_RUN_CHANNEL_MASK = 0x7F; 
+    
     /**
-     * 	Extract and return the FPGA ID associated with the samples
+     * 	Extract and return the FPGA ID associated with the samples.
+     * 	Note: This method should only be used when looking at test run data.
      * 
 	 *	@param data - sample block of data
      * 	@return An FPGA ID in the range 0-7
@@ -32,9 +39,10 @@
 	}
 
     /**
-     * 	Extract and return the hybrid number associated with the samples 
+     * 	Extract and return the hybrid ID associated with the samples 
+     * 	Note: This method should only be used when looking at test run data.
      * 
-	 * 	@param data - sample block of data
+	 * 	@param data : sample block of data
      * 	@return A hybrid number in the range 0-2
      */
     public static int getHybridID(int[] data) {
@@ -43,19 +51,52 @@
 	
     /**
      *	Extract and return the channel number associated with the samples
+     * 	Note: This method should only be used when looking at test run data.
      * 
-	 * 	@param data - sample block of data
+	 * 	@param data : sample block of data
+     * 	@return A channel number in the range 0-127
+     */
+    public static int getTestRunChannelNumber(int[] data) {
+        return (data[TEST_RUN_SAMPLE_HEADER_INDEX] >>> 16) & TEST_RUN_CHANNEL_MASK;
+    }
+    
+    /**
+     *	Extract and return the front end board (FEB) ID associated with the
+     *	samples
+     *	
+	 * 	@param data : sample block of data
+	 * 	@return A FEB ID in the range 0-10
+     */
+    public static int getFebID(int[] data) { 
+    	return (data[ENG_RUN_SAMPLE_HEADER_INDEX] >> 8) & FEB_MASK; 
+    }
+    
+    /**
+     * 	Extract and return the front end board (FEB) hybrid ID associated with 
+     * 	the samples
+	 *
+	 * 	@param data : sample block of data
+	 * 	@return A FEB hybrid ID in the range 0-3
+     */
+    public static int getFebHybridID(int[] data) { 
+    	return (data[ENG_RUN_SAMPLE_HEADER_INDEX] >> 26) & FEB_HYBRID_MASK; 
+    }
+
+    /**
+     *	Extract and return the channel number associated with the samples
+     * 
+	 * 	@param data : sample block of data
      * 	@return A channel number in the range 0-127
      */
     public static int getChannelNumber(int[] data) {
-        return (data[TEST_RUN_SAMPLE_HEADER_INDEX] >>> 16) & TEST_RUN_CHANNEL_MASK;
+        return (data[ENG_RUN_SAMPLE_HEADER_INDEX] >>> 16) & ENG_RUN_CHANNEL_MASK;
     }
-	
+    
     /**
      * 	Extract and return the nth SVT sample.
      * 
-     * 	@param sampleN - The sample number of interest. Valid values are 0 to 5
-	 * 	@param data - sample block of data
+     * 	@param sampleN : The sample number of interest. Valid values are 0 to 5
+	 * 	@param data : sample block of data
      * 	@throws RuntimeException if the sample number is out of range
      * 	@return ADC value of the nth sample
      * 
@@ -83,7 +124,7 @@
     /**
      *	Extract and return all SVT samples as an array 
      * 
-	 * 	@param data - sample block of data
+	 * 	@param data : sample block of data
      * 	@return An array containing all SVT Shaper signal samples
      */
     public static short[] getSamples(int[] data) {
@@ -94,4 +135,9 @@
         }
         return samples;
     }
+
+    /**
+     *	Private constructor to prevent the class from being instantiated.
+     */
+    private SvtEvioUtils(){}; 
 }

Modified: java/trunk/evio/src/main/java/org/hps/evio/TestRunSvtEvioReader.java
 =============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/TestRunSvtEvioReader.java	(original)
+++ java/trunk/evio/src/main/java/org/hps/evio/TestRunSvtEvioReader.java	Sun Feb  8 20:29:11 2015
@@ -2,12 +2,12 @@
 
 import java.util.List;
 
+import org.jlab.coda.jevio.BaseStructure;
 import org.lcsim.detector.tracker.silicon.HpsSiSensor;
 import org.lcsim.detector.tracker.silicon.HpsTestRunSiSensor;
 import org.lcsim.event.RawTrackerHit;
 import org.lcsim.event.base.BaseRawTrackerHit;
 import org.lcsim.geometry.Subdetector;
-
 import org.hps.util.Pair;
 
 import static org.hps.evio.EventConstants.TEST_RUN_SVT_BANK_TAG;
@@ -29,6 +29,8 @@
 	private static final int DATA_HEADER_LENGTH = 7;
 	private static final int DATA_TAIL_LENGTH = 1; 
 	private static final int MAX_FPGA_ID = 6;
+	private static final int ROC_BANK_TAG = 3;
+	private static final int ROC_BANK_NUMBER = -1; 
 	
 	/** 
 	 * Default Constructor
@@ -36,25 +38,33 @@
 	public TestRunSvtEvioReader() { }; 
 	
 	/**
-	 *	Get the maximum data bank tag in the event.  For the test run, this
-	 *	corresponds to the maximum FPGA ID of 6.  The data contained an 
-	 *	additional FPGA bank with tag = 7, but this wasn't used.
+	 *	Get the minimum SVT ROC bank tag in the event.
 	 *
-	 *	@return Maximum FPGA ID
+	 *	@return Minimum SVT ROC bank tag
 	 */
 	@Override
-	protected int getMaxDataBankTag() {
-		return MAX_FPGA_ID;
+	protected int getMinRocBankTag() { 
+		return ROC_BANK_TAG; 
+	}
+
+	/**
+	 *	Get the maximum SVT ROC bank tag in the event.
+	 *
+	 *	@return Maximum SVT ROC bank tag
+	 */
+	@Override 
+	protected int getMaxRocBankTag() { 
+		return ROC_BANK_TAG; 
 	}
 	
 	/**
-	 *	Get the SVT bank tag.  For the test run, the bank tag was set to 0x3.
-	 *
-	 *	@return The SVT bank tag.
+	 *	Get the SVT ROC bank number of the bank encapsulating the SVT samples.
+	 * 
+	 *	@return SVT ROC bank number 
 	 */
 	@Override
-	protected int getSvtBankTag() { 
-		return TEST_RUN_SVT_BANK_TAG; 
+	protected int getRocBankNumber() { 
+		return ROC_BANK_NUMBER; 
 	}
 	
 	/**
@@ -83,7 +93,7 @@
 	 *	A method to setup a mapping between a DAQ pair (FPGA/Hybrid) and the 
 	 *	corresponding sensor.
 	 *
-	 *	@param subdetector - The tracker {@link Subdetector} object
+	 *	@param subdetector : The tracker {@link Subdetector} object
 	 */
 	// TODO: This can probably be done when the conditions are loaded.
 	@Override
@@ -104,40 +114,46 @@
 	 *	data is used to extract the FPGA ID and Hybrid ID corresponding to 
 	 *	the samples. 
 	 *
-	 *	@param data - sample block of data
+	 *	@param data : sample block of data
 	 *	@return The sensor associated with a set of sample 
 	 */
 	@Override
 	protected HpsSiSensor getSensor(int[] data) {
-		//System.out.println("[ " + this.getClass().getSimpleName() + " ]: FPGA ID: " + SvtEvioUtils.getFpgaID(data));
-		//System.out.println("[ " + this.getClass().getSimpleName() + " ]: Hybrid ID: " + SvtEvioUtils.getHybridID(data));
 		
-        Pair<Integer, Integer> daqPair 
+		/*this.printDebug("FEB ID: " + SvtEvioUtils.getFpgaID(data) 
+				+ " Hybrid ID: " + SvtEvioUtils.getHybridID(data));*/
+
+		Pair<Integer, Integer> daqPair 
         	= new Pair<Integer, Integer>(SvtEvioUtils.getFpgaID(data),
         								 SvtEvioUtils.getHybridID(data));
 		return daqPairToSensor.get(daqPair);
 	}
 
-
+	/**
+	 *	Check whether a data bank is valid i.e. contains SVT samples only.  For
+	 *	the test run, a valid data bank has a tag in the range 0-6.
+	 * 
+	 * 	@param dataBank - An EVIO bank containing integer data
+	 * 	@return true if the bank is valid, false otherwise
+	 * 
+	 */
+	@Override
+	protected boolean isValidDataBank(BaseStructure dataBank) { 
+		if (dataBank.getHeader().getTag() < 0 
+				|| dataBank.getHeader().getTag() >= MAX_FPGA_ID) return false; 
+		return true; 
+	}
+	
+	
 	/**
 	 * 	Make a {@link RawTrackerHit} from a set of samples.
 	 * 
-	 *	@param data - sample block of data
+	 *	@param data : sample block of data
 	 * 	@return A raw hit
 	 */
 	@Override
 	protected RawTrackerHit makeHit(int[] data) {
-		
-		HpsSiSensor sensor = this.getSensor(data); 
-		int channel = SvtEvioUtils.getChannelNumber(data);
-		//System.out.println("[ " + this.getClass().getSimpleName() + " ]: Channel ID: " + SvtEvioUtils.getChannelNumber(data));
-		long cellID = sensor.makeChannelID(channel);
-		int hitTime = 0;
-		//short[] samples = SvtEvioUtils.getSamples(data);
-		//for(int sampleN = 0; sampleN < 6; sampleN++) { 
-		//	System.out.println("[ " + this.getClass().getSimpleName() + " ]: Sample " + sampleN + ": " + samples[sampleN]);
-		//}
-		
-		return new BaseRawTrackerHit(hitTime, cellID, SvtEvioUtils.getSamples(data), null, sensor);
+		//this.printDebug("Channel: " + SvtEvioUtils.getTestRunChannelNumber(data));
+		return makeHit(data, SvtEvioUtils.getTestRunChannelNumber(data));
 	}
 }

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