hps-java/src/main/java/org/lcsim/hps/recon/tracking/apv25
diff -N HPSDataProcessingModule.java
--- HPSDataProcessingModule.java 5 Jan 2012 17:47:00 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,177 +0,0 @@
-package org.lcsim.hps.recon.tracking.apv25;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import org.lcsim.event.EventHeader;
-import org.lcsim.util.Driver;
-
-/**
- *
- * @author Omar Moreno <[log in to unmask]>
- * @version $Id: HPSDataProcessingModule.java,v 1.1 2012/01/05 17:47:00 omoreno Exp $
- */
-public class HPSDataProcessingModule extends Driver {
-
-
- SortedMap<Integer, Map<Integer, double[]>> samples;
- Map<Integer, List<Double>> blocks;
-
- Integer sampleNumber = 1;
- int numberOfSamples = 6;
-
- /**
- * Constructor
- */
- public HPSDataProcessingModule()
- {
- // ... //
- blocks = new HashMap<Integer, List<Double>>();
- samples = new TreeMap<Integer, Map<Integer, double[]>>();
- }
-
- /**
- *
- */
- public void addSample( Map<Integer, double[]> sample )
- {
- samples.put(sampleNumber, sample);
-
- //--->
- System.out.println(this.getClass().getName() + ": Sample # " + sampleNumber + " added!");
- //--->
-
- sampleNumber++;
-
- }
-
- /**
- *
- */
-
-
- /**
- *
- */
- public void createBlocks()
- {
-
- // First iterate through all samples
- Iterator sampleIterator = samples.keySet().iterator();
- while(sampleIterator.hasNext()){
-
- // Get a single sample of the APV25 output
- Map<Integer, double[]> sample
- = samples.get((Integer) sampleIterator.next());
-
- //--->
- System.out.println(this.getClass().getName() + ": Sample size:" + sample.size());
- //--->
-
- // Loop through the avp25 digital sample
- for(Map.Entry<Integer, double[]> entries : sample.entrySet()){
-
- // Get the chip number minus 1
- Integer chipN = entries.getKey();
-
- //--->
-// System.out.println(this.getClass().getName() + ": Chip Number: " + chipN);
- //--->
-
- double[] digitalData = entries.getValue();
-
- // Strip the digital sample of all header information
- digitalData = Arrays.copyOfRange(digitalData, 12, digitalData.length-1);
-
- //--->
-// System.out.println(this.getClass().getName() + ": Data Size: " + digitalData.length);
- //--->
-
- // Loop through all channels and add to blocks
- for(int index = 1; index <= digitalData.length; index++){
-
- int channelN = index+(chipN-1)*128;
-
- //--->
-// System.out.println(this.getClass().getName() + ": Channel Number: " + channelN );
- //--->
-
- // Check if map blocks has the channel
- if(!blocks.containsKey(channelN))
- blocks.put(channelN, new ArrayList<Double>(6));
-
- List<Double> signal = blocks.get(channelN);
-
- signal.add(digitalData[index-1]);
-
- blocks.put(channelN, signal);
- }
- }
- }
-
- //--->
-// System.out.println(this.getClass().getName() + ": Number of blocks: " + blocks.size());
- //--->
-
- //--->
-// for(Map.Entry<Integer, List<Double>> entries : blocks.entrySet()){
-// System.out.println(this.getClass().getName() + entries.getValue().toString());
-// }
- //--->
-
- // CLear all samples
- samples.clear();
-
- // Reset the sample number
- sampleNumber = 1;
-
- }
-
- /**
- *
- */
- public void findHits()
- {
- int nHits = 0;
-
- // Loop through all blocks
- for(Map.Entry<Integer, List<Double>> entries : blocks.entrySet()){
-
- if(entries.getValue().get(3) >= 1640 ){
- ++nHits;
- System.out.println("Found a hit! There are now a total of " + nHits);
- }
-
- }
- }
-
- /**
- *
- */
- @Override
- public void process(EventHeader event)
- {
- super.process(event);
-
- // If 6 samples have been collected, block the samples together
- // by channel
- if(samples.size() == 6 ){
-
- //
- createBlocks();
-
- // Once blocks are created, find which blocks have a hit above
- // threshold
- findHits();
-
- // Once cuts have been applied, clear the blocks
- blocks.clear();
-
- }
- }
-}
hps-java/src/main/java/org/lcsim/hps/recon/tracking/apv25
diff -N HPSRTM.java
--- HPSRTM.java 5 Jan 2012 17:47:00 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,171 +0,0 @@
-
-package org.lcsim.hps.recon.tracking.apv25;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- * @author Omar Moreno <[log in to unmask]>
- * @version $Id: HPSRTM.java,v 1.1 2012/01/05 17:47:00 omoreno Exp $
- */
-public class HPSRTM {
-
- private Map<Integer, double[]> analogData;
- private Map<Integer, double[]> digitalData;
-
- private static double INPUT_STAGE_GAIN = 2;
- private static double RESISTOR_VALUE = 100; // Ohms
-
- double adcHighRef = 1000; // mVolts
- double adcLowRef = -1000; // mVolts
- double adcResolution = 0; //bits
- double adcVoltageResolution = 0; // Volts
- int voltageIntervals;
-
-
- /**
- * Constructor
- */
- public HPSRTM(int bits)
- {
- // To do: In order to increase speed, HashMap should be initialized
- // to a specified capacity
- digitalData = new HashMap<Integer, double[]>();
-
- adcResolution = bits;
- voltageIntervals = (int) Math.pow(2, bits);
- System.out.println(voltageIntervals);
-
- adcVoltageResolution
- = (adcHighRef - adcLowRef)/voltageIntervals; // mV
-
- System.out.println(adcVoltageResolution);
-
- }
-
- //--- Methods ---//
- //---------------//
-
-
- /**
- *
- * @param data
- */
- public Map<Integer, double[]> digitize( Map<Integer, double[]> data )
- {
- analogData = data;
-
- // Amplify the incoming analog signal
- amplifySignal();
-
- // Loop over all apv25 analog signals and digitize them
- for(Map.Entry<Integer, double[]> entry : analogData.entrySet()){
-
- // Aquire the amplified signal
- double[] digitalSignal = entry.getValue();
-
- // Digitize the apv25 output
- for(int index = 0; index < digitalSignal.length; index++){
-
- digitalSignal[index]
- = Math.floor((digitalSignal[index]
- - adcLowRef)/adcVoltageResolution);
- }
-
- digitalData.put(entry.getKey(), digitalSignal);
-
-// System.out.println( "chip #: " + entry.getKey());
-// System.out.print("[ ");
-// for(double element : digitalSignal ){
-//
-// System.out.print(element + ",");
-// }
-// System.out.print(" ]");
-// System.out.println("");
- }
-
- //--->
- System.out.println(this.getClass().getName() + ": APV25 output has been digitized");
- //--->
-
- return digitalData;
- }
-
- /**
- *
- */
- public void amplifySignal()
- {
-
- //--->
- System.out.println(this.getClass().getName() + ": AmplyingSignal");
- //--->
-
- // Loop over all apv25 analog data
- for(Map.Entry<Integer, double[]> entry : analogData.entrySet() )
- {
- // Obtain the apv25 output
- double[] apv25Output = entry.getValue();
-
- for(int index = 0; index < apv25Output.length; index++ ){
-
- // Convert input current to voltage
- apv25Output[index] *= RESISTOR_VALUE;
-
- // Amplify the input signal
- apv25Output[index] *= INPUT_STAGE_GAIN;
- }
-
- // Store the amplified APV25 output
- analogData.put(entry.getKey(), apv25Output);
-
- // Loop over the array
-// System.out.println( "chip #: " + entry.getKey());
-// System.out.print("[ ");
-// for(double element : signal ){
-//
-// System.out.print(element + ",");
-// }
-// System.out.print(" ]");
-// System.out.println("");
-
- }
- }
-
- /**
- *
- */
- public void setResolution( int bits )
- {
- adcResolution = bits;
-
- // adcVoltageResolution
-// = Math.floor((adcHighRef - adcLowRef)/adcResolution)*1000;
-
- }
-
- /**
- *
- */
- public void printData()
- {
-
- double[] data = digitalData.get("1");
- System.out.println(data.length);
- //double[] data = digitalData.get("1");
-
- // System.out.println("[ " + digitalData.size());
-
-
-// for(double element : data )
-// {
-// System.out.println(element + ",");
-// }
-
- System.out.println(" ]");
- }
-
-
-
-}
hps-java/src/main/java/org/lcsim/hps/recon/tracking/apv25
diff -N HPSSVTHitDriver.java
--- HPSSVTHitDriver.java 5 Jan 2012 17:47:00 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,194 +0,0 @@
-
-package org.lcsim.hps.recon.tracking.apv25;
-
-
-//--- Java ---//
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-//--- org.lcsim ---//
-import org.lcsim.detector.IDetectorElement;
-import org.lcsim.detector.IReadout;
-import org.lcsim.detector.tracker.silicon.SiSensor;
-import org.lcsim.detector.tracker.silicon.SiTrackerModule;
-import org.lcsim.event.EventHeader;
-import org.lcsim.event.RawTrackerHit;
-import org.lcsim.event.SimTrackerHit;
-import org.lcsim.geometry.Detector;
-import org.lcsim.recon.tracking.digitization.sisim.CDFSiSensorSim;
-import org.lcsim.recon.tracking.digitization.sisim.SiDigitizer;
-import org.lcsim.util.Driver;
-
-
-//--- hps-java ---//
-import org.lcsim.hps.util.ClockSingleton;
-import org.lcsim.recon.tracking.digitization.sisim.config.SimTrackerHitReadoutDriver;
-
-/**
- *
- * @author Omar Moreno <[log in to unmask]>
- * @version $Id: HPSSVTHitDriver.java,v 1.1 2012/01/05 17:47:00 omoreno Exp $
- */
-public class HPSSVTHitDriver extends Driver {
-
-
- //
- CDFSiSensorSim siSimulation;
- HPSAPV25 apv25;
- HPSSiSensorReadout siReadout;
- HPSDataProcessingModule dpm;
-
- //
- List<String> processPaths = new ArrayList<String>();
- List<IDetectorElement> processDetectorElements
- = new ArrayList<IDetectorElement>();
- List<String> readouts = new ArrayList<String>();
- List<Integer> triggerTimeStamp = new ArrayList<Integer>();
-
- //
- Set<SiSensor> processSensors = new HashSet<SiSensor>();
- Set<SiTrackerModule> processModules = new HashSet<SiTrackerModule>();
-
- // Event number
- int eventNumber;
-
- /**
- * Constructor
- */
- public HPSSVTHitDriver()
- {
- //--- Sensor Simulation ---//
- //-------------------------//
- siSimulation = new CDFSiSensorSim();
-
- //--- APV25 Simulation ---//
- //------------------------//
- apv25 = new HPSAPV25( );
- // Set the APV25 Shaping time [ns]
- apv25.setShapingTime(35);
- // Set the APV25 operating mode
- apv25.setAPV25Mode("multi-peak");
- // Set the APV25 analog pipeline sampling time
- apv25.setSamplingTime(24);
-
- //--- HPS Data Processing Module ---//
- //----------------------------------//
- dpm = new HPSDataProcessingModule();
- add(dpm);
-
- //--- HPS Silicon Sensor Readout ---//
- //-------------------//
- siReadout = new HPSSiSensorReadout(siSimulation, apv25, dpm);
-
- //Specify the readouts to process
- readouts.add("TrackerHits");
- // Specify the detectors to process
- processPaths.add("Tracker");
- }
-
- /**
- * Initialize whenever we have a new detector
- *
- * @param detector :
- */
- @Override
- public void detectorChanged(Detector detector)
- {
- super.detectorChanged(detector);
-
- // Proces detectors specified by path, otherwise process the entire
- // detector
- IDetectorElement detectorElement = detector.getDetectorElement();
- for(String detectorElementPath : processPaths ){
- processDetectorElements.add(
- detectorElement.findDetectorElement(detectorElementPath));
- }
-
- if(processDetectorElements.isEmpty())
- processDetectorElements.add(detectorElement);
-
- for(IDetectorElement dElement : processDetectorElements ){
- processSensors.addAll(dElement.findDescendants(SiSensor.class));
- processModules.addAll(
- dElement.findDescendants(SiTrackerModule.class));
- }
- }
-
- /**
- *
- */
- @Override
- public void startOfData()
- {
- // Set up readouts if they haven't been set
- if(!readouts.isEmpty()){
- super.add(new SimTrackerHitReadoutDriver(readouts));
- }
-
- super.startOfData();
- readouts.clear();
-
- eventNumber = 1;
- }
-
-
- /**
- *
- */
- @Override
- public void process(EventHeader event)
- {
- super.process(event);
-
- // Output event number
-// if( eventNumber%100 == 0){
-// System.out.println("Now processing event " + eventNumber);
-// }
-
- // This should be moved to clock singleton ...
- // If a sampling cycle has passed, increment the pointer positions of
- // all existing analog pipelines
- if(ClockSingleton.getTime()%24 == 0 && eventNumber != 1){
- apv25.incrementAllPointerPositions(
- HPSSiSensorReadout.analogPipelineMap );
- apv25.stepAPV25Clock();
- }
-
- // Increment the event number
- ++eventNumber;
-
- // Loop over all sensors
- for( SiSensor sensor : processSensors ){
-
- // Readout the sensor
- siReadout.readoutSensor(sensor);
- }
-
- // If a trigger is recieved readout the APV25 and digitize all hits
- if(HPSAPV25.triggerBit){
- for(int sample = 0; sample < 6; sample++){
- if(!triggerTimeStamp.contains(apv25.apv25ClockCycle + sample)){
- triggerTimeStamp.add(apv25.apv25ClockCycle + sample);
- //--->
- System.out.println(triggerTimeStamp.toString());
- //--->
- }
- }
- HPSAPV25.triggerBit = false;
- }
-
-
-
- if(!triggerTimeStamp.isEmpty()){
- if(triggerTimeStamp.contains(apv25.apv25ClockCycle)){
- siReadout.readoutAPV25();
- triggerTimeStamp.remove((Integer) apv25.apv25ClockCycle);
- //--->
- System.out.println(triggerTimeStamp.toString());
- //--->
- }
- }
- }
-}