sandbox unused tracking classes
diff -N HPSRTM.java --- HPSRTM.java 12 Mar 2012 23:03:03 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,127 +0,0 @@
- -package org.lcsim.hps.recon.tracking; - -import java.util.HashMap; -import java.util.Map; - -/** - * - * @author Omar Moreno <[log in to unmask]> - * @version $Id: HPSRTM.java,v 1.2 2012/03/12 23:03:03 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); - - adcVoltageResolution - = (adcHighRef - adcLowRef)/voltageIntervals; // mV - - } - - //--- Methods ---// - //---------------// - - - /** - * - * @param data - */ - public Map<Integer, double[]> digitize( Map<Integer, double[]> data ) - { - digitalData = data; - - // Amplify the incoming analog signal - amplifySignal(); - - // Loop over all apv25 analog signals and digitize them - for(Map.Entry<Integer, double[]> entry : digitalData.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); - - } - - return digitalData; - } - - /** - * - */ - public void amplifySignal() - { - - // Loop over all apv25 analog data - for(Map.Entry<Integer, double[]> entry : digitalData.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 - digitalData.put(entry.getKey(), apv25Output); - - } - } - - /** - * - */ - public void setResolution( int bits ) - { - adcResolution = bits; - } - - /** - * - */ - public void printData() - { - - double[] data = digitalData.get("1"); - System.out.println(data.length); - System.out.println(" ]"); - } -}
diff -N MakeSensorsDriver.java --- MakeSensorsDriver.java 1 Jun 2011 17:05:31 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,18 +0,0 @@
-/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.lcsim.hps.recon.tracking; - -import org.lcsim.util.Driver; - -/** - * - * @author mgraham - */ -public class MakeSensorsDriver extends Driver { - - public MakeSensorsDriver() { - add(new SiTrackerFixedTargetSensorSetup("Tracker")); - } -}
diff -N TestRunDataProcessingModule.java --- TestRunDataProcessingModule.java 18 Dec 2012 23:42:56 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,138 +0,0 @@
-package org.lcsim.hps.recon.tracking; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.lcsim.detector.IReadout; -import org.lcsim.detector.tracker.silicon.ChargeCarrier; -import org.lcsim.detector.tracker.silicon.SiSensor; -import org.lcsim.event.EventHeader; -import org.lcsim.event.RawTrackerHit; -import org.lcsim.event.SimTrackerHit; -import org.lcsim.event.base.BaseRawTrackerHit; -import org.lcsim.geometry.Detector; -import org.lcsim.hps.recon.tracking.apv25.Apv25DigitalData; -import org.lcsim.util.Driver; - - -/** - * - * @author Omar Moreno <[log in to unmask]> - * @version $Id: TestRunDataProcessingModule.java,v 1.2 2012/12/18 23:42:56 omoreno Exp $ - */ -public class TestRunDataProcessingModule extends DataProcessingModule { - - int nSamplesAboveThreshold = 1; // Number of samples above noise threshold - int noiseThreshold = 3; // Units of RMS noise - - boolean enablePileUpCut = true; - boolean enableThresholdCut = true; - - /** - * Default Ctor - */ - public TestRunDataProcessingModule(){ - }; - - /** - * - */ - public void setNumberOfSamplesAboveThreshold(int nSamplesAboveThreshold){ - this.nSamplesAboveThreshold = nSamplesAboveThreshold; - } - - /** - * - */ - public void setNoiseThreshold(int noiseThreshold /* Noise RMS */){ - this.noiseThreshold = noiseThreshold; - } - - /** - * - */ - public void setEnablePileUpCut(boolean enablePileUpCut){ - this.enablePileUpCut = enablePileUpCut; - } - - /** - * - */ - public void setEnableThresholdCut(boolean enableThresholdCut){ - this.enableThresholdCut = enableThresholdCut; - } - - protected List<RawTrackerHit> findRawHits(){ - - List<RawTrackerHit> rawHits = new ArrayList<RawTrackerHit>(); - - // Loop through all blocked data - for(Map.Entry<SiSensor, SvtDataBlocks> sensor : sensorToDataBlocks.entrySet()){ - - SvtDataBlocks blocks = sensor.getValue(); - - for(int channel = 0; channel < 639; channel++){ - - if(HPSSVTCalibrationConstants.isBadChannel(sensor.getKey(), channel)) continue; - - short[] samples = blocks.getSamples(channel); - - if(enableThresholdCut && !this.samplesAboveThreshold(sensor.getKey(), channel, samples)) continue; - - if(enablePileUpCut && !this.pileUpCut(samples)) continue; - - // Create a RawTrackerHit - int sideNumber; - int time = 0; - if(sensor.getKey().hasElectrodesOnSide(ChargeCarrier.HOLE)){ - sideNumber = ChargeCarrier.HOLE.charge(); - } else { - sideNumber = ChargeCarrier.ELECTRON.charge(); - } - long cellID = sensor.getKey().makeStripId(channel, sideNumber).getValue(); - RawTrackerHit rawHit = new BaseRawTrackerHit(time, cellID, samples, new ArrayList<SimTrackerHit>(), sensor.getKey()); - rawHits.add(rawHit); - - // Add the raw hit to the sensor readout - IReadout readOut = sensor.getKey().getReadout(); - readOut.addHit(rawHit); - } - } - - System.out.println(this.getClass().getSimpleName() + ": Number of RawTrackerHits created: " + rawHits.size()); - return rawHits; - } - - /** - * - */ - private boolean samplesAboveThreshold(SiSensor sensor, int channel, short[] samples){ - // Number of samples above threshold - int nSamplesAboveThreshold = 0; - - // Get the pedestal and noise for this channel - double pedestal = HPSSVTCalibrationConstants.getPedestal(sensor, channel); - double noise = HPSSVTCalibrationConstants.getNoise(sensor, channel); - - // Calculate the threshold - int threshold = (int) (pedestal + noise*this.noiseThreshold); - - for(int index = 0; index < 6; index++){ - if(samples[index] >= threshold) nSamplesAboveThreshold++; - } - - // If the prerequisite number of samples are above threshold return true - if(nSamplesAboveThreshold >= this.nSamplesAboveThreshold ) return true; - return false; - } - - /** - * - */ - private boolean pileUpCut(short[] sample){ - if(sample[2] > sample[1] || sample[3] > sample[2]) return true; - return false; - } -}
diff -N RearTransitionModule.java --- RearTransitionModule.java 9 Nov 2012 01:40:52 -0000 1.6 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,140 +0,0 @@
-package org.lcsim.hps.recon.tracking; - -//--- java ---// -import java.util.ArrayList; -import java.util.List; - -//--- org.lcsim ---// -import org.lcsim.event.EventHeader; -import org.lcsim.util.Driver; - -//--- hps-java ---// -import org.lcsim.hps.recon.tracking.apv25.Apv25AnalogData; -import org.lcsim.hps.recon.tracking.apv25.Apv25DigitalData; -import org.lcsim.hps.util.RandomGaussian; - -//--- Constants ---// -import static org.lcsim.hps.recon.tracking.apv25.Apv25Constants.CHANNELS; -import static org.lcsim.hps.recon.tracking.apv25.Apv25Constants.MULTIPLEXER_GAIN; -import static org.lcsim.hps.recon.tracking.apv25.Apv25Constants.MIP; -import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TOTAL_STRIPS_PER_SENSOR; - -/** - * - * @author Omar Moreno <[log in to unmask]> - * @version $Id: RearTransitionModule.java,v 1.6 2012/11/09 01:40:52 omoreno Exp $ - */ -public class RearTransitionModule extends Driver { - - String apv25AnalogDataCollectionName = "APV25AnalogData"; - String apv25DigitalDataCollectionName = "AVP25DigitalData"; - - double adcVHighRef = 1000; // mVolts - double adcVLowRef = -1000; // mVolts - int adcResolution = 14; // bits - double adcVoltageResolution = 1; // mV - int quantizationLevels = 256; - - double resistorValue = 100; // Ohms - double inputStageGain = 1.5; - - boolean noiseless = false; - - /** - * Default Ctor - */ - public RearTransitionModule(){ - - // Find the number of quantization levels - int quantizationLevels = (int) Math.pow(2, adcResolution); - - // Find the ADC voltage resolution - adcVoltageResolution = (adcVHighRef - adcVLowRef)/quantizationLevels; // mV - } - - /** - * - */ - public void setResolution(int bits){ - adcResolution = bits; - - // Find the number of quantization levels - quantizationLevels = (int) Math.pow(2, adcResolution); - - - // Find the ADC voltage resolution - adcVoltageResolution = (adcVHighRef - adcVLowRef)/quantizationLevels; // mV - } - - /** - * - */ - public void setADCSpan(double adcVHighRef, double adcVLowRef){ - this.adcVHighRef = adcVHighRef; - this.adcVLowRef = adcVLowRef; - - // Find the ADC voltage resolution - adcVoltageResolution = (adcVHighRef - adcVLowRef)/quantizationLevels; // mV - } - - /** - * Turn readout noise on/off - */ - public void setNoiseless(boolean noiseless){ - this.noiseless = noiseless; - } - - /** - * - */ - @Override - protected void process(EventHeader event){ - super.process(event); - - // If the event does not contain any analog data that needs to be digitized, skip the event - if(!event.hasCollection(Apv25AnalogData.class, apv25AnalogDataCollectionName)) return; - - // Get the analog data from the event - List<Apv25AnalogData> analogData = event.get(Apv25AnalogData.class, apv25AnalogDataCollectionName); - - // Create a list hold the digital data - List<Apv25DigitalData> digitalData = new ArrayList<Apv25DigitalData>(); - - // Amplify the analog data - for(Apv25AnalogData analogDatum : analogData){ - - // Make a hard copy of the APV25 analog output to avoid modification of the original - double[] apv25Output = new double[140]; - System.arraycopy(analogDatum.getApv25AnalogOutput(), 0, apv25Output, 0, apv25Output.length); - - for(int index = 0; index < apv25Output.length; index++){ - - // For now, don't digitize the header - if(index < 12) continue; - - // Get the physical channel - int physicalChannel = TOTAL_STRIPS_PER_SENSOR - - (analogDatum.getApvNumber()*CHANNELS + (CHANNELS - 1) - (index - 12)); - - apv25Output[index] += 4; // mA - apv25Output[index] *= (MIP/MULTIPLEXER_GAIN); - - // Digitize the signal - apv25Output[index] *= HPSSVTCalibrationConstants.getGain(analogDatum.getSensor(), physicalChannel); - - // Add pedestal and noise - double pedestal = HPSSVTCalibrationConstants.getPedestal(analogDatum.getSensor(), physicalChannel); - double noise = HPSSVTCalibrationConstants.getNoise(analogDatum.getSensor(), physicalChannel); - if(!noiseless) - apv25Output[index] += RandomGaussian.getGaussian(pedestal, noise); - else - apv25Output[index] += pedestal; - } - - // Add the digital data to the list - digitalData.add(new Apv25DigitalData(analogDatum.getSensor(), analogDatum.getApvNumber(), apv25Output)); - } - - event.put(apv25DigitalDataCollectionName, digitalData, Apv25DigitalData.class, 0); - } -}
diff -N SiTrackerFixedTargetSensorSetup.java --- SiTrackerFixedTargetSensorSetup.java 1 Jun 2011 17:05:31 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,131 +0,0 @@
-package org.lcsim.hps.recon.tracking; - -import hep.physics.matrix.BasicMatrix; -import hep.physics.vec.BasicHep3Vector; -import hep.physics.vec.VecOp; - -import java.util.List; - -import org.lcsim.detector.IDetectorElement; -import org.lcsim.detector.IRotation3D; -import org.lcsim.detector.ITranslation3D; -import org.lcsim.detector.RotationPassiveXYZ; -import org.lcsim.detector.Transform3D; -import org.lcsim.detector.Translation3D; -import org.lcsim.detector.solids.Polygon3D; -import org.lcsim.detector.solids.Trd; -import org.lcsim.detector.tracker.silicon.ChargeCarrier; -import org.lcsim.detector.tracker.silicon.SiSensor; -import org.lcsim.detector.tracker.silicon.SiSensorElectrodes; -import org.lcsim.detector.tracker.silicon.SiStrips; -import org.lcsim.geometry.Detector; -import org.lcsim.geometry.compact.Subdetector; -import org.lcsim.geometry.subdetector.SiTrackerFixedTarget2; -import org.lcsim.util.Driver; - -public class SiTrackerFixedTargetSensorSetup extends Driver { - - String subdetectorName; - - public SiTrackerFixedTargetSensorSetup() { - } - - public SiTrackerFixedTargetSensorSetup(String subdetectorName) { - this.subdetectorName = subdetectorName; - } - - public void setSubdetectorName(String subdetectorName) { - this.subdetectorName = subdetectorName; - } - - public void detectorChanged(Detector detector) { - if (subdetectorName == null) { - throw new RuntimeException("The subdetectorName was not set."); - } - - Subdetector subdetector = detector.getSubdetector(subdetectorName); - if (subdetector instanceof SiTrackerFixedTarget2) { - setupSensorDetectorElements(subdetector); - } else { - throw new RuntimeException("The subdetector " + subdetectorName + " is not an instance of SiTrackerFixedTarget2."); - } - } - - private void setupSensorDetectorElements(Subdetector subdet) { - System.out.println(this.getClass().getCanonicalName() + " - Setting up sensors for " + subdet.getName() + " ..."); - - for (IDetectorElement endcap : subdet.getDetectorElement().getChildren()) { - for (IDetectorElement layer : endcap.getChildren()) { - //int nwedges = layer.getChildren().size(); - for (IDetectorElement wedge : layer.getChildren()) { - for (IDetectorElement module : wedge.getChildren()) { - List<SiSensor> sensors = module.findDescendants(SiSensor.class); - - if (sensors.size() == 0) { - throw new RuntimeException("No sensors found in module."); - } - - //int sensorId = 0; - for (SiSensor sensor : sensors) { - Trd sensor_solid = (Trd) sensor.getGeometry().getLogicalVolume().getSolid(); - - Polygon3D n_side = sensor_solid.getFacesNormalTo(new BasicHep3Vector(0, -1, 0)).get(0); - Polygon3D p_side = sensor_solid.getFacesNormalTo(new BasicHep3Vector(0, 1, 0)).get(0); - - // Bias the sensor -// sensor.setBiasSurface(ChargeCarrier.ELECTRON, p_side); -// sensor.setBiasSurface(ChargeCarrier.HOLE, n_side); - - sensor.setBiasSurface(ChargeCarrier.HOLE, p_side); - sensor.setBiasSurface(ChargeCarrier.ELECTRON, n_side); - -// double strip_angle = Math.atan2(sensor_solid.getXHalfLength2() - sensor_solid.getXHalfLength1(), sensor_solid.getZHalfLength() * 2); - double strip_angle = 0.00; - ITranslation3D electrodes_position = new Translation3D(VecOp.mult(-p_side.getDistance(), new BasicHep3Vector(0, 0, 1))); // translate to outside of polygon - //ITranslation3D electrodes_position = new Translation3D(VecOp.mult(n_side.getDistance(), new BasicHep3Vector(0, 0, 1))); // translate to outside of polygon - - IRotation3D electrodes_rotation = new RotationPassiveXYZ(-Math.PI / 2, 0, strip_angle); - Transform3D electrodes_transform = new Transform3D(electrodes_position, electrodes_rotation); - - // Free calculation of readout electrodes, sense electrodes determined thereon - SiStrips readout_electrodes = new SiStrips(ChargeCarrier.HOLE, 0.060, sensor, electrodes_transform); - SiStrips sense_electrodes = new SiStrips(ChargeCarrier.HOLE,0.030,(readout_electrodes.getNCells()*2-1),sensor,electrodes_transform); - -// SiStrips readout_electrodes = new SiStrips(ChargeCarrier.ELECTRON, 0.060, sensor, electrodes_transform); -// SiStrips sense_electrodes = new SiStrips(ChargeCarrier.ELECTRON, 0.030, (readout_electrodes.getNCells() * 2 - 1), sensor, electrodes_transform); - - // SiSensorElectrodes sense_electrodes = new SiStrips(ChargeCarrier.HOLE, 0.060, sensor, electrodes_transform); - -//pristine conditions -/* - readout_electrodes.setCapacitanceIntercept(0); - readout_electrodes.setCapacitanceSlope(0.12); - sense_electrodes.setCapacitanceIntercept(0); - sense_electrodes.setCapacitanceSlope(0.12); -*/ - - readout_electrodes.setCapacitanceIntercept(0); - readout_electrodes.setCapacitanceSlope(0.16); - sense_electrodes.setCapacitanceIntercept(0); - sense_electrodes.setCapacitanceSlope(0.16); - - sensor.setSenseElectrodes(sense_electrodes); - sensor.setReadoutElectrodes(readout_electrodes); -// - -// double[][] transfer_efficiencies = {{1.0}}; - double[][] transfer_efficiencies = {{0.986, 0.419}}; - sensor.setTransferEfficiencies(ChargeCarrier.HOLE, new BasicMatrix(transfer_efficiencies)); -// sensor.setTransferEfficiencies(ChargeCarrier.ELECTRON, new BasicMatrix(transfer_efficiencies)); - // here - - //++sensorId; - } - } - } - } - } - } -} - -
diff -N HPSDataProcessingModule.java --- HPSDataProcessingModule.java 24 May 2012 17:08:18 -0000 1.14 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,396 +0,0 @@
-package org.lcsim.hps.recon.tracking; - -//--- Java ---// -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -//--- org.lcsim ---// -import java.util.Set; -import org.lcsim.detector.IReadout; -import org.lcsim.detector.tracker.silicon.SiSensor; -import org.lcsim.event.EventHeader; -import org.lcsim.event.RawTrackerHit; -import org.lcsim.event.SimTrackerHit; -import org.lcsim.event.base.BaseRawTrackerHit; -import org.lcsim.geometry.Detector; -import org.lcsim.util.Driver; - -//--- Constants ---// -import static org.lcsim.hps.recon.tracking.HPSSVTConstants.SVT_TOTAL_FPGAS; -import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TOTAL_APV25_CHANNELS; -import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TOTAL_APV25_PER_HYBRID; -import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TOTAL_HYBRIDS_PER_FPGA; - -/** - * - * @author Omar Moreno <[log in to unmask]> - * @version $Id: HPSDataProcessingModule.java,v 1.14 2012/05/24 17:08:18 omoreno Exp $ - */ -public class HPSDataProcessingModule extends Driver { - - // A map relating a sensor to all sample blocks collected from that sensor - Map<SiSensor, Map<Integer, List<Double>>> sensorToSamplesMap; - - // Relate a channel to its six samples - Map<Integer, List<Double>> channelToBlock; - - // Relate a sensor Identifier to the actual sensor - Map<Long, SiSensor> sensorMap = new HashMap<Long, SiSensor>(); - - // Collection of all sensors - Set<SiSensor> sensorSet = new HashSet<SiSensor>(); - - // Collections of RawTrackerHits - List<RawTrackerHit> rawHits; // Cuts are applied - List<RawTrackerHit> rawHitsNoCuts; // No cuts are applied to samples - - // Collection of all SVT data - List<HPSSVTData> svtData; - List<HPSSVTData> svtFpgaData; - List<Double> samples; - - int numberOfSamples = 0; // Total number of APV25 samples - int nSamplesAboveThresh = 3; // Number of samples above noise threshold - int pedestal = 1638; // [ADC counts] For now, all channels have the same pedestal - int flags = 0; // - int noise = 18; // [ADC Counts] RMS noise - int noiseThreshold = 3; // Units of RMS noise - int physicalChannel; - - private boolean thresholdCut = false; // Apply threshold cut? - private boolean tailCut = false; // Apply tail cut? - private boolean noiseSuppression = false; // Apply noise suppression? - boolean debug = false; - - double[] apv25DataStream; - - String RawTrackerHitsCollectionName = "RawTrackerHits"; - String RawTrackerHitsNoCutsCollectionName = "RawTrackerHitsNoCuts"; - String svtCollectionName = "SVTData"; - - /** - * Default Constructor - */ - public HPSDataProcessingModule() { - channelToBlock = new HashMap<Integer, List<Double>>(); - sensorToSamplesMap = new HashMap<SiSensor, Map<Integer, List<Double>>>(); - rawHits = new ArrayList<RawTrackerHit>(); - rawHitsNoCuts = new ArrayList<RawTrackerHit>(); - svtData = new ArrayList<HPSSVTData>(); - svtFpgaData = new ArrayList<HPSSVTData>(); - } - - /** - * - */ - @Override - public void detectorChanged(Detector detector) { - - for (SiSensor sensor : SvtUtils.getInstance().getSensors()) { - // Map a sensor to its corresponding samples - sensorToSamplesMap.put(sensor, new HashMap<Integer, List<Double>>()); - } - } - - /** - * Set the SVT collection name - */ - public void setSvtCollectionName(String svtCollectionName) { - this.svtCollectionName = svtCollectionName; - } - - /** - * Set the number of samples above threshold a signal must have - */ - public void setSamplesAboveThresh(int nSamplesAboveThresh) { - this.nSamplesAboveThresh = nSamplesAboveThresh; - } - - /** - * Set the noise RMS [ADC Counts] - */ - public void setNoise(int noise) { - this.noise = noise; - } - - /** - * Set the noise threshold in units of RMS noise - */ - public void setNoiseThreshold(int noiseThreshold) { - this.noiseThreshold = noiseThreshold; - } - - /** - * Set the pedestal value for all channels - */ - public void setPedestal(int pedestal) { - this.pedestal = pedestal; - } - - /** - * Enable the threshold cut. The threshold cut requires a certain number - * of samples per hit to be above a noise threshold. - */ - public void enableThresholdCut() { - this.thresholdCut = true; - } - - /** - * Enable the tail cut. The tail cut requires sample 1 to be greater than - * sample 0 or sample 2 to be greater than sample 1. This eliminates - * hits that may arise due to shaper signal tails. - */ - public void enableTailCut() { - this.tailCut = true; - } - - /** - * Enable noise suppression cut. Requires samples 2 or 3 to be above a - * threshold noiseThreshold + noise. - */ - public void enableNoiseSuppressionCut() { - this.noiseSuppression = true; - } - - /** - * Buffer a sample that has been readout from a sensor. - * - * @param sensorToDigitalMap - * A map relating a sensor to the digital samples readout from the - * sensor - */ - public void addSample(Map<SiSensor, Map<Integer, double[]>> sensorToDigitalMap) { - - /* - * Integer: Chip Number - * double[]: APV25 Data Analog Data - */ - - int physicalChannel; - - // Loop through the list of all sensors - for (Map.Entry<SiSensor, Map<Integer, double[]>> sensor : sensorToDigitalMap.entrySet()) { - - // Loop through all APV25s - for (Map.Entry<Integer, double[]> chipData : sensor.getValue().entrySet()) { - - // Copy the sample to avoid concurrent modification - apv25DataStream = chipData.getValue(); - - // Strip the APV25 data stream of all header information - apv25DataStream = Arrays.copyOfRange(apv25DataStream, 12, apv25DataStream.length - 1); - - // Loop through all channels - for (int channel = 0; channel < apv25DataStream.length; channel++) { - - physicalChannel = channel + chipData.getKey() * 128; - - // Check if a block has been created for this channel. If not create it - if (!sensorToSamplesMap.get(sensor.getKey()).containsKey(physicalChannel)) { - sensorToSamplesMap.get(sensor.getKey()).put(physicalChannel, new ArrayList<Double>(6)); - } - sensorToSamplesMap.get(sensor.getKey()).get(physicalChannel).add(apv25DataStream[channel]); - } - } - } - numberOfSamples++; - } - - /** - * Finds hits that satisfied all required cuts and creates both - * RawTrackerHits and SVTData - */ - public void findHits() { - - int fpgaNumber, hybridNumber, apvNumber, rawChannel; - - // Clear the list of raw tracker hits - rawHits.clear(); - rawHitsNoCuts.clear(); - svtData.clear(); - - // Loop through all sensors and the corresponding blocks - for (Map.Entry<SiSensor, Map<Integer, List<Double>>> sensor : sensorToSamplesMap.entrySet()) { - - // Get the FPGA number - fpgaNumber = SvtUtils.getInstance().getFPGA(sensor.getKey()); - if(fpgaNumber > SVT_TOTAL_FPGAS || fpgaNumber < 0) - throw new RuntimeException("FPGA Number out of range!"); - if(debug) System.out.println(this.getClass().getSimpleName() + ": FPGA Number: " + fpgaNumber); - - // Clear the temporary list - svtFpgaData.clear(); - - for (Map.Entry<Integer, List<Double>> samples : sensor.getValue().entrySet()) { - short[] adc = new short[6]; - - // Convert ADC value to a short - for (int index = 0; index < adc.length; index++) - adc[index] = samples.getValue().get(index).shortValue(); - - // If a strip had any charge deposited on it, create a RawTrackerHit - if(!(samplesAboveThreshold(adc) >= 1)){ - samples.getValue().clear(); - continue; - } - - RawTrackerHit rawHit = makeRawTrackerHit(samples.getKey(), sensor.getKey(), adc); - rawHitsNoCuts.add(rawHit); - - // Check if a block has the appropriate number of blocks above threshold - if (thresholdCut && !(samplesAboveThreshold(adc) >= nSamplesAboveThresh)) { - samples.getValue().clear(); - continue; - } - - // Apply the tail cut - if (tailCut && !tailCut(adc)) { - samples.getValue().clear(); - continue; - } - - // Apply noise suppression cut - if (noiseSuppression && !noiseSuppressionCut(adc)) { - samples.getValue().clear(); - continue; - } - - // If all cuts are satisfied, add the hit to the list of hits to be saved - rawHits.add(rawHit); - - // Get the hybrid number - hybridNumber = SvtUtils.getInstance().getHybrid(sensor.getKey()); - if(hybridNumber > TOTAL_HYBRIDS_PER_FPGA || hybridNumber < 0) - throw new RuntimeException("Hybrid number is out of range!"); - //if(debug) System.out.println(this.getClass().getSimpleName() + ": Hybrid Number: " + hybridNumber); - - // Find the APV number. Note that strip numbering is from 639 to 0 - apvNumber = (TOTAL_APV25_PER_HYBRID - 1) - (int) Math.floor(samples.getKey()/128); - if(apvNumber > TOTAL_APV25_PER_HYBRID || apvNumber < 0) - throw new RuntimeException("APV25 Number out of range!"); - //if(debug) System.out.println(this.getClass().getSimpleName() + ": APV Number: " + apvNumber); - - // Find the raw channel number from the physical channel - rawChannel = samples.getKey() - (TOTAL_APV25_CHANNELS*TOTAL_APV25_PER_HYBRID - 1) - + apvNumber*TOTAL_APV25_CHANNELS + (TOTAL_APV25_CHANNELS - 1); - if(rawChannel > TOTAL_APV25_CHANNELS || rawChannel < 0) - throw new RuntimeException("APV25 Channel " + rawChannel + " out of range!"); - //if(debug) System.out.println(this.getClass().getSimpleName() + ": Raw Channel Number: " + rawChannel); - - // Create an svtData packet - HPSSVTData data = new HPSSVTData(hybridNumber, apvNumber, rawChannel, fpgaNumber, adc); - svtData.add(data); - svtFpgaData.add(data); - - samples.getValue().clear(); - } - - HPSSVTDataBuffer.addToBuffer(svtFpgaData, fpgaNumber); - } - if(debug) System.out.println(this.getClass().getName() + ": Total RawTrackerHits before cuts: " + rawHitsNoCuts.size()); - if(debug) System.out.println(this.getClass().getName() + ": Total RawTrackerHits: " + rawHits.size()); - if(debug) System.out.println(this.getClass().getName() + ": Total SVTData: " + svtData.size()); - } - - /** - * Creates a rawTrackerHit - * - * @param channelNumber - * Si Strip from which the hit originates from - * @param sensor - * Sensor from which the hit originates from - * @param adcValues - * Shaper signal samples - * @return RawTrackerHit - */ - private RawTrackerHit makeRawTrackerHit(Integer channelNumber, SiSensor sensor, short[] adcValues) { - IReadout ro = sensor.getReadout(); - - // No time yet - int time = 0; - long cell_id = sensor.makeStripId(channelNumber, 1).getValue(); - - RawTrackerHit rawHit = new BaseRawTrackerHit(time, cell_id, adcValues, new ArrayList<SimTrackerHit>(), sensor); - - ro.addHit(rawHit); - - return rawHit; - } - - /** - * Finds how many samples are above a given threshold - * - * @param adc - * Shaper signal samples - * @return Number of samples above threshold - */ - private int samplesAboveThreshold(short[] adc) { - // Number of samples above threshold - int nSamplesAboveThreshold = 0; - - for (int sample = 0; sample < adc.length; sample++) { - if (adc[sample] >= pedestal + noiseThreshold * noise) { - nSamplesAboveThreshold++; - } - } - return nSamplesAboveThreshold; - } - - /** - * Applies tail cut - * - * @param adc - * Shaper signal samples - * @return true if the cut is satisfied, false otherwise - */ - private boolean tailCut(short[] adc) { - if (adc[3] > adc[2] || adc[4] > adc[3]) { - return true; - } - return false; - } - - /** - * Applies noise suppression cut - * - * @param adc - * Shaper signal samples - * @return true if the cut is satisfied, false otherwise - */ - private boolean noiseSuppressionCut(short[] adc) { - if (adc[3] > pedestal + noiseThreshold * noise || adc[4] > pedestal + noiseThreshold * noise) { - return true; - } - return false; - } - - /** - * - */ - @Override - public void process(EventHeader event) { - super.process(event); - - // If six samples have been collected process the data - if (numberOfSamples == 6) { - - // Find hits - findHits(); - - // Add RawTrackerHits to the event - event.put(RawTrackerHitsCollectionName, rawHits, RawTrackerHit.class, flags); - - // Add SVTData to event - System.out.println("Adding SVTData Collection of size: " + svtData.size() + " to the Event"); - event.put(this.svtCollectionName, this.svtData, HPSSVTData.class, 0); - - - // - numberOfSamples = 0; - } - } -}
diff -N MultiTrackReco.java --- MultiTrackReco.java 26 Nov 2012 18:12:01 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,120 +0,0 @@
-/* - * TrackReconstructionDriver class - */ -package org.lcsim.hps.recon.tracking; - -import java.io.File; -import java.util.List; - -import org.lcsim.recon.tracking.seedtracker.SeedStrategy; -import org.lcsim.recon.tracking.seedtracker.SeedTracker; -import org.lcsim.recon.tracking.seedtracker.StrategyXMLUtils; -import org.lcsim.recon.tracking.seedtracker.diagnostic.SeedTrackerDiagnostics; -import org.lcsim.util.Driver; - -/** - * Driver to perform hit digitization and track reconstruction for the sATLAS detector - * - * @author M. Graham and R. Partridge - */ -public class MultiTrackReco extends Driver { - - public MultiTrackReco(String strategyPrefix, String detType, double bField, String sAxialfile, String sFinalfile, String sLongLived, List<int[]> stereoPairs, List<Integer> passLayers) { -// Digitization and hit making driver for planar sensors - - HPSTrackerHitDriver thd = new HPSTrackerHitDriver(); - add(thd); - - HelicalTrackHitDriver hitdriver = new HelicalTrackHitDriver(); - hitdriver.addCollection(((HPSTrackerHitDriver) thd).getStripHits1DName()); - hitdriver.setOutputCollectionName("AxialTrackHits"); - hitdriver.HitRelationName("AxialTrackHitRelations"); - hitdriver.MCRelationName("AxialTrackMCRelations"); - - - add(hitdriver); - // Tracking code - - // Two step fitting method below... - // 1) fit the track with axial strips only - // 2) pair the xy strips and make all possible space points - // 3) run the ReReconstructoin driver to remove the space points - // which don't have an axial track associated - // 4) run track finding with the remaining points - - - if (!sAxialfile.contentEquals("none")) { - List<SeedStrategy> slist = StrategyXMLUtils.getStrategyListFromFile(new File(strategyPrefix + sAxialfile)); - SeedTracker st = new SeedTracker(slist); - st.setInputCollectionName("AxialTrackHits"); - st.setTrkCollectionName("AxialTracks"); - st.setBField(bField); - st.setTimingPlots(true); -// st.setDiagnostics(new SeedTrackerDiagnostics()); - st.setSectorParams(false); - add(st); - - } - - HelicalTrackHitDriver hthdriver = new HelicalTrackHitDriver(); - hthdriver.addCollection(((HPSTrackerHitDriver) thd).getStripHits1DName()); - hthdriver.setOutputCollectionName("HelicalTrackHits"); - hthdriver.HitRelationName("HelicalTrackHitRelations"); - hthdriver.MCRelationName("HelicalTrackMCRelations"); - - - for (int[] pair : stereoPairs) - hthdriver.setStereoPair("Tracker", pair[0], pair[1]); - - if (detType.contains("Test")) { - System.out.println("Setting separation for a Test detector"); - hthdriver.setMaxSeperation(10.01); - hthdriver.setTolerance(0.01); - } else { - - hthdriver.setMaxSeperation(50.); - hthdriver.setTolerance(0.4); - } - add(hthdriver); - - - if (!sAxialfile.contentEquals("none")) { - ReReconstructionDriver rrd = new ReReconstructionDriver(); - for (Integer pass : passLayers) - rrd.setLayersToKeep(pass); - add(rrd); - } - - List<SeedStrategy> sFinallist = StrategyXMLUtils.getStrategyListFromFile(new File(strategyPrefix + sFinalfile)); - SeedTracker stFinal = null; - stFinal = new SeedTracker(sFinallist); - if (!sAxialfile.contentEquals("none")) { - stFinal.setInputCollectionName("MatchedHTHits"); - stFinal.setTrkCollectionName("MatchedTracks"); - - } else { - stFinal.setInputCollectionName("HelicalTrackHits"); - stFinal.setTrkCollectionName("MatchedTracks"); - } -// stFinal.setDiagnostics(new SeedTrackerDiagnostics()); - stFinal.setBField(bField); - stFinal.setSectorParams(false); - stFinal.setTimingPlots(true); - - add(stFinal); - - if (!sLongLived.contentEquals("none")) { - StripHitsOnTrack shot = new StripHitsOnTrack(); - add(shot); - - List<SeedStrategy> sLLlist = StrategyXMLUtils.getStrategyListFromFile(new File(strategyPrefix + sLongLived)); - - SeedTracker stLL = new SeedTracker(sLLlist); - stLL.setInputCollectionName("RemainingHits"); - stLL.setTrkCollectionName("LLTracks"); - stLL.setTimingPlots(true); - - add(stLL); - } - } -}
diff -N HPSSVTDataBuffer.java --- HPSSVTDataBuffer.java 16 Aug 2012 01:06:30 -0000 1.7 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,155 +0,0 @@
- -package org.lcsim.hps.recon.tracking; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -// Constants -import static org.lcsim.hps.recon.tracking.HPSSVTConstants.SVT_TOTAL_FPGAS; -import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TEMP_MASK; - -/** - * - * @author Omar Moreno <[log in to unmask]> - * @version $Id: HPSSVTDataBuffer.java,v 1.7 2012/08/16 01:06:30 meeg Exp $ - */ -public class HPSSVTDataBuffer { - - // Map the FPGA to the data emerging from it - private Map<Integer, List<Integer>> fpgaToData = new HashMap<Integer, List<Integer>>(); - - // Singleton - private static final HPSSVTDataBuffer instance = new HPSSVTDataBuffer(); - private static int eventNumber = 0; - - int[] header = new int[6]; - int temp = FpgaData.temperatureToInt(23.0); // C - - boolean debug = false; - - /** - * Default constructor; Set to private to prevent instantiation - */ - private HPSSVTDataBuffer(){ - // - for(int fpgaNumber = 0; fpgaNumber <= SVT_TOTAL_FPGAS; fpgaNumber++) - fpgaToData.put(fpgaNumber, new ArrayList<Integer>()); - } - - /** - * Add data to SVT buffer - * - * @param svtData : List of SVT data packets - * @param fpga : FPGA from which the data emerges from - */ - public static void addToBuffer(List<HPSSVTData> svtData, int fpga){ - // If the FPGA data block is empty, add header information and data, otherwise - // just add the data - instance.encapsulateSVTData(svtData, fpga); - } - - /** - * Readout data stored in the SVT buffer - * - * @param fpga : FPGA from which data is to be read from - * @return data : An FPGA data packet - * - */ - public static int[] readoutBuffer(int fpga){ - // Add the event number to the beginning - instance.addEventNumber(fpga); - - // Add the tail to the data - instance.addTail(fpga); - - // Copy the data in the map so that the buffer can be cleared - int[] data = new int[instance.fpgaToData.get(fpga).size()]; - int index = 0; - for(Integer datum : instance.fpgaToData.get(fpga)){ - data[index] = datum; - index++; - } - - // Clear the buffer - instance.fpgaToData.get(fpga).clear(); - - // Return the - return data; - } - - /** - * Encapsulate SVT data by FPGA - * - * @param svtData : List of SVT data packets - * @param fpga : FPGA from which the data emerges from - */ - private void encapsulateSVTData(List<HPSSVTData> svtData, int fpga){ - // Ignore FPGA 7 for now - if(fpga == 7) return; - - // If the FPGA data block is empty, add the header information and increment the event number - if(instance.fpgaToData.get(fpga).isEmpty()){ - - // Insert the temperature information. All temperatures are currently - // set to 23 C - header[0] = (header[0] &= ~TEMP_MASK) | (temp & TEMP_MASK); - header[0] = (header[0] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16); - - header[1] = (header[1] &= ~TEMP_MASK) | (temp & TEMP_MASK); - header[1] = (header[1] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16); - - header[2] = (header[2] &= ~TEMP_MASK) | (temp & TEMP_MASK); - header[2] = (header[2] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16); - - header[3] = (header[3] &= ~TEMP_MASK) | (temp & TEMP_MASK); - header[3] = (header[3] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16); - - header[4] = (header[4] &= ~TEMP_MASK) | (temp & TEMP_MASK); - header[4] = (header[4] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16); - - header[5] = (header[5] &= ~TEMP_MASK) | (temp & TEMP_MASK); - header[5] = (header[5] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16); - - for(int index = 0; index < header.length; index++) fpgaToData.get(fpga).add(header[index]); - - eventNumber++; - } - - // Add all samples emerging from this FPGA - if(!svtData.isEmpty()){ - for(HPSSVTData svtDatum : svtData){ - if(debug){ - System.out.println("FPGA: " + svtDatum.getFPGAAddress() + " Hybrid: " + svtDatum.getHybridNumber() + " APV: " - + svtDatum.getAPVNumber() + " Channel: " + svtDatum.getChannelNumber()); - } - for(int index = 0; index < svtDatum.getData().length; index++){ - fpgaToData.get(fpga).add(svtDatum.getData()[index]); - } - } - } - } - - /** - * Add a tail to the FPGA data packet. In real data, this may be - * non-zero which would indicate an error. - * - * @param fpga : FPGA from which the data emerges from - */ - private void addTail(int fpga){ - - // For now just make it zero - instance.fpgaToData.get(fpga).add(0); - } - - /** - * Add an SVT event number to the top of the FPGA data packet. - * - * @param fpga : FPGA from which the data emerges from - */ - private void addEventNumber(int fpga){ - - instance.fpgaToData.get(fpga).add(0, eventNumber); - } -}
diff -N DataProcessingModule.java --- DataProcessingModule.java 15 Sep 2012 01:21:02 -0000 1.6 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,117 +0,0 @@
-package org.lcsim.hps.recon.tracking; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.lcsim.detector.tracker.silicon.SiSensor; -import org.lcsim.event.EventHeader; -import org.lcsim.event.RawTrackerHit; -import org.lcsim.geometry.Detector; -import org.lcsim.hps.recon.tracking.apv25.Apv25DigitalData; -import org.lcsim.util.Driver; -/** - * - * @author Omar Moreno - * @version $Id: DataProcessingModule.java,v 1.6 2012/09/15 01:21:02 omoreno Exp $ - */ -public abstract class DataProcessingModule extends Driver{ - - Map<SiSensor, SvtDataBlocks> sensorToDataBlocks = new HashMap<SiSensor, SvtDataBlocks>(); - - // Collection Names - String apv25DigitalDataCollectionName = "AVP25DigitalData"; - String rawTrackerHitsCollectionName = "SVTRawTrackerHits"; - - int nSamples = 0; // Number of samples which have been processed - int totalSamples = 6; // Number of samples which are read out - - /** - * Set the number of shaper signal samples to be readout - */ - public void setNumberOfSamplesToReadOut(int totalSamples){ - this.totalSamples = totalSamples; - } - - protected abstract List<RawTrackerHit> findRawHits(); - - @Override - public void detectorChanged(Detector detector){ - for(SiSensor sensor : SvtUtils.getInstance().getSensors()){ - sensorToDataBlocks.put(sensor, new SvtDataBlocks()); - } - } - - @Override - public void process(EventHeader event){ - - // If the event does not contain any data to process, skip it - if(!event.hasCollection(Apv25DigitalData.class, apv25DigitalDataCollectionName)) return; - - // Get the digital data from the event - List<Apv25DigitalData> digitalData = event.get(Apv25DigitalData.class, apv25DigitalDataCollectionName); - - // Block the data together - for(Apv25DigitalData digitalDatum : digitalData){ - SiSensor sensor = digitalDatum.getSensor(); - int apvN = digitalDatum.getApv(); - - double[] apv25DigitalOutput = new double[128]; - System.arraycopy(digitalDatum.getSamples(), 0, apv25DigitalOutput, 0, apv25DigitalOutput.length); - - for(int channel = 0; channel < apv25DigitalOutput.length; channel++){ - - // Calculate the physical number - int physicalChannel = 639 - (apvN*128 + 127 - channel); - - sensorToDataBlocks.get(sensor).addSample(physicalChannel, nSamples, (short) apv25DigitalOutput[channel]); - } - } - nSamples++; - - // If the expected number of samples has been collected, process the data - if(nSamples == totalSamples){ - - // Add RawTrackerHits to the event - event.put(rawTrackerHitsCollectionName, this.findRawHits(), RawTrackerHit.class, 0); - nSamples = 0; - } - } - - protected class SvtDataBlocks { - - Map<Integer /* sample number */, short[]> channelToSamples = new HashMap<Integer, short[]>(); - - /** - * - */ - public SvtDataBlocks(){ - } - - public void addSample(Integer physicalChannel, int sampleN, short value){ - if(!channelToSamples.containsKey(physicalChannel)) channelToSamples.put(physicalChannel, new short[6]); - channelToSamples.get(physicalChannel)[sampleN] = value; - } - - /** - * - */ - public short[] getSamples(int physicalChannel){ - return channelToSamples.get(physicalChannel); - } - - /** - * - */ - public String printSamples(int physicalChannel){ - String sampleString = "[ "; - short[] samples = this.getSamples(physicalChannel); - for(int index = 0; index < samples.length -1; index++){ - sampleString += samples[index] + ", "; - } - sampleString += samples[samples.length - 1] + "]"; - return sampleString; - } - } - -}
diff -N OccupancyDriver.java --- OccupancyDriver.java 1 Jun 2011 17:05:31 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,305 +0,0 @@
-/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.lcsim.hps.recon.tracking; - -import java.io.IOException; -import hep.aida.IHistogramFactory; -import hep.aida.IProfile1D; -import hep.physics.vec.Hep3Vector; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -import java.util.Set; -import org.lcsim.detector.IDetectorElement; -import org.lcsim.detector.IReadout; -import org.lcsim.detector.identifier.IIdentifier; -import org.lcsim.detector.tracker.silicon.ChargeCarrier; -import org.lcsim.detector.tracker.silicon.SiSensor; -import org.lcsim.detector.tracker.silicon.SiSensorElectrodes; -import org.lcsim.detector.tracker.silicon.SiStrips; -import org.lcsim.detector.tracker.silicon.SiTrackerIdentifierHelper; -import org.lcsim.event.EventHeader; -import org.lcsim.event.MCParticle; -import org.lcsim.event.RawTrackerHit; -import org.lcsim.event.SimTrackerHit; -import org.lcsim.geometry.Detector; -import org.lcsim.recon.tracking.digitization.sisim.GenericReadoutChip; -import org.lcsim.recon.tracking.digitization.sisim.ReadoutChip; -import org.lcsim.util.Driver; -import org.lcsim.util.aida.AIDA; - -/** - * - * @author partridge - */ -public class OccupancyDriver extends Driver { - - private AIDA aida = AIDA.defaultInstance(); - private IHistogramFactory _hf; - List<String> _process_paths = new ArrayList<String>(); - List<IDetectorElement> _process_de = new ArrayList<IDetectorElement>(); - Set<SiSensor> _process_sensors = new HashSet<SiSensor>(); - public String outputPlots = "myOccupancyPlots.aida"; - Map<String, IProfile1D> occMap = new HashMap<String, IProfile1D>(); - int nevt = 0; - - public OccupancyDriver() { - - // Specify the detectors to process - _process_paths.add("Tracker"); - - // Define the efficiency histograms - _hf = aida.histogramFactory(); - } - - - public void process( - EventHeader event) { - String dir = "DigiOccupancy/"; - // Increment the event counter - nevt++; - -// System.out.println("B: " + event.getDetector().getFieldMap().getField(new BasicHep3Vector(0., 0., 0.))); - - ReadoutChip chip = new GenericReadoutChip(); - - int hittot = 0; - for (SiSensor sensor : _process_sensors) { - - SiSensorElectrodes electrodes = sensor.getReadoutElectrodes(ChargeCarrier.HOLE); -// SiSensorElectrodes electrodes = sensor.getReadoutElectrodes(ChargeCarrier.ELECTRON); -// if (sensor.hasPixels()) { -// System.out.println("Found some pixels"); -// electrodes = sensor.getReadoutElectrodes(ChargeCarrier.ELECTRON); - // } else { -// System.out.println("...got strips"); - // } - SiTrackerIdentifierHelper _sid_helper = (SiTrackerIdentifierHelper) sensor.getIdentifierHelper(); - - int nchan = electrodes.getNCells(); - - IReadout readout = sensor.getReadout(); - - List<RawTrackerHit> raw_hits = readout.getHits(RawTrackerHit.class); - - - - - String layer = sensor.getName().substring(8, 15); - - double nstrips = 1; //number of strips per step - double nstripsz = 1; //number of strips per step - int nbins = 1000; - double pitch=0.06; - double[] occVsY = new double[nbins]; - double[] occVsZ = new double[nbins]; - double miny = -nbins*pitch/2; - double maxy = nbins*pitch/2; - double minz = -nbins*pitch/2; - double maxz = nbins*pitch/2; - double step = (maxy - miny) / nbins; -// double nstrips=step/0.06; //number of strips per step - - double stepz = (maxz - minz) / nbins; -// double nstripsz=stepz/0.06; //number of strips per step - - - for (RawTrackerHit raw_hit : raw_hits) { - IIdentifier id = raw_hit.getIdentifier(); - Integer strip_id = _sid_helper.getElectrodeValue(id); - Hep3Vector local_pos = ((SiStrips) electrodes).getStripCenter(strip_id); - electrodes.getParentToLocal().inverse().transform(local_pos); - Hep3Vector global_pos = ((SiSensor) electrodes.getDetectorElement()).getGeometry().getLocalToGlobal().transformed(local_pos); - double ypos = global_pos.y(); - double zpos = global_pos.z(); - //System.out.println("ypos="+ypos+";zpos="+zpos); - if (ypos < maxy && ypos > miny) { -// System.out.println("Putting hit into occVsY"); - int bin = (int) ((ypos - miny) / step); - occVsY[bin]++; - } - if (zpos < maxz && zpos > minz) { -// System.out.println("Putting hit into occVsY"); - int bin = (int) ((zpos - minz) / stepz); - occVsZ[bin]++; - } - } - - String occvsyID = layer + " Occupancy vs y -- Near Beam"; - if (!occMap.containsKey(occvsyID)) - occMap.put(occvsyID, _hf.createProfile1D(occvsyID, nbins, miny, maxy)); - - String occvsyIDZ = layer + " Occupancy vs z -- Near Beam"; - if (!occMap.containsKey(occvsyIDZ)) - occMap.put(occvsyIDZ, _hf.createProfile1D(occvsyIDZ, nbins, minz, maxz)); - - for (int i = 0; i < nbins; i++) { - double binVal = step * i + miny + step / 2; - occMap.get(occvsyID).fill(binVal, occVsY[i] / nstrips); - - } - - for (int i = 0; i < nbins; i++) { - double binVal = stepz * i + minz + stepz / 2; - occMap.get(occvsyIDZ).fill(binVal, occVsZ[i] / nstripsz); - - } - - int nhits = raw_hits.size(); - hittot += nhits; - Set<SimTrackerHit> simhits = new HashSet<SimTrackerHit>(); - - /* - for (RawTrackerHit hit : raw_hits) { - double charge = chip.decodeCharge(hit); - aida.histogram1D("Hit charge", 100, 0., 100000.).fill(charge); - aida.cloud1D("Number of SimTrackerHits per raw hit").fill(hit.getSimTrackerHits().size()); - double energy = 0.; - for (SimTrackerHit shit : hit.getSimTrackerHits()) { - simhits.add(shit); - energy += 1000 * shit.getdEdx(); - } - aida.histogram1D("SimTrackerHit energy", 100, 0., 10.).fill(energy); - // aida.cloud2D("charge vs SimTrackerHit energy").fill(charge, energy); - } - */ - double occ = ((double) nhits) / ((double) nchan); -// double occ = ((double) nhits) / ((double) nchan); -// if (nhits > 0) { -// System.out.println("sensor " + sensor.getName() + " has nhits: " + nhits + " nchan: " + nchan + " occ: " + occ); -// } else { -// System.out.println("sensor " + sensor.getName() + " is empty "); -// } - - Hep3Vector pos = sensor.getGeometry().getPosition(); - - double x = pos.x(); - double y = pos.y(); - double z = pos.z(); - double r = Math.sqrt(x * x + y * y); - int xi = 2 * ((int) Math.round(x / 20)); - int zi = 2 * ((int) Math.round(Math.abs(z) / 20)); - aida.cloud1D("Sensor Occupancy").fill(occ); - -// if (!barrel) { -// continue; -// } -// String layer = sensor.getName().substring(8, 15); - aida.cloud1D(layer + " Occupancy").fill(occ); - if (y >= 0) - aida.cloud1D(layer + " Occupancy--positive y").fill(occ); - else - aida.cloud1D(layer + " Occupancy--negative y").fill(occ); - - - String identifier; - String identifier2; - String identifier3; - - //incredibly kludgy way to get the radii/z positions to display the way I want - - identifier = "Occupancy vs X"; - identifier2 = layer + " Occupancy vs y"; - identifier3 = layer + " Occupancy vs z"; - - //create the histograms if they are not already there... - if (!occMap.containsKey(identifier)) - occMap.put(identifier, _hf.createProfile1D(identifier, 120, 0., 120.)); - if (!occMap.containsKey(identifier2)) { - - occMap.put(identifier2, _hf.createProfile1D(identifier2, 24, -12., 12.)); - occMap.put(identifier3, _hf.createProfile1D(identifier3, 24, -12, 12.)); - - } - - - occMap.get(identifier).fill(x / 10, occ); - occMap.get(identifier2).fill(y / 10, occ); - occMap.get(identifier3).fill(z / 10, occ); - - } - -// System.out.println("Total number of hit channels: " + hittot); - /* - List<List<SimTrackerHit>> simall = - (List<List<SimTrackerHit>>) event.get(SimTrackerHit.class); - - for (List<SimTrackerHit> simcol : simall) { - for (SimTrackerHit hit : simcol) { - IDetectorElement de = hit.getDetectorElement(); - Hep3Vector pos = hit.getPositionVec(); - double x = pos.x(); - double y = pos.y(); - double z = pos.z(); - double r = Math.sqrt(x * x + y * y); - Hep3Vector p = hit.getMCParticle().getMomentum(); - double px = p.x(); - double py = p.y(); - double pz = p.z(); - double pr = Math.sqrt(px * px + py * py); - double eta = -Math.log(Math.tan(0.5 * Math.atan2(pr, pz))); - String detname = hit.getSubdetector().getName(); - int layer = hit.getLayer(); - aida.histogram1D("MC eta for Layer " + detname + layer, 50, -2.5, 2.5).fill(eta); - aida.histogram1D("SimTracker Hi z for Layer " + detname + layer, 50, -120., 120.).fill(z / 10); - // de. - } - } - - for (MCParticle mcp : event.getMCParticles()) { - if (mcp.getCharge() == 0) continue; - Hep3Vector p = mcp.getMomentum(); - double px = p.x(); - double py = p.y(); - double pz = p.z(); - double pr = Math.sqrt(px * px + py * py); - double eta = -Math.log(Math.tan(0.5 * Math.atan2(pr, pz))); - if (mcp.getGeneratorStatus() == mcp.FINAL_STATE) { - aida.histogram1D("MCP eta - final state",50,-2.5, 2.5).fill(eta); - } - if (mcp.getSimulatorStatus().isCreatedInSimulation()) { - aida.histogram1D("MCP eta - created in simulation",50, -2.5, 2.5).fill(eta); - } - } - */ - return; - } - - - public void endOfData() { - try { - aida.saveAs(outputPlots); - } catch (IOException ex) { -// Logger.getLogger(TrackAnalysisDriver.class.getName()).log(Level.SEVERE, null, ex); - } - } - - public void setOutputPlots(String output) { - this.outputPlots = output; - - } - - public void detectorChanged(Detector detector) { - System.out.println("In Occupancy Driver : " + detector.getName()); - super.detectorChanged(detector); - - // Process detectors specified by path, otherwise process entire detector - IDetectorElement detector_de = detector.getDetectorElement(); - System.out.println("In Occupancy Driver : detector_de = " + detector_de.getName()); - for (String de_path : _process_paths) - _process_de.add(detector_de.findDetectorElement(de_path)); - - if (_process_de.size() == 0) - _process_de.add(detector_de); - - for (IDetectorElement detector_element : _process_de) - _process_sensors.addAll(detector_element.findDescendants(SiSensor.class)); - - } -}
\ No newline at end of file
diff -N ReReconstructionDriver.java --- ReReconstructionDriver.java 29 Apr 2012 23:31:09 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,100 +0,0 @@
-/* - * TrackReconstructionDriver class - */ -package org.lcsim.hps.recon.tracking; - -import java.util.ArrayList; -import java.util.List; - -import org.lcsim.event.EventHeader; -import org.lcsim.event.LCRelation; -import org.lcsim.event.RawTrackerHit; -import org.lcsim.event.RelationalTable; -import org.lcsim.event.Track; -import org.lcsim.event.TrackerHit; -import org.lcsim.event.base.BaseRelationalTable; -import org.lcsim.fit.helicaltrack.HelicalTrackHit; -import org.lcsim.recon.tracking.seedtracker.SeedTrack; -import org.lcsim.util.Driver; -import org.lcsim.util.aida.AIDA; - -/** - * Driver to perform hit digitization and track reconstruction for the sATLAS detector - * - * @author M. Graham and R. Partridge - */ -public class ReReconstructionDriver extends Driver { - - private AIDA aida = AIDA.defaultInstance(); - List<Integer> passLayers = new ArrayList(); -// double pcut=5.2; - double pcut=0.95*2.2; - public ReReconstructionDriver() { - } - - - public void process( - EventHeader event) { - - List<Track> tracklist = event.get(Track.class, "AxialTracks"); - List<HelicalTrackHit> hthits = event.get(HelicalTrackHit.class, "HelicalTrackHits"); - List<HelicalTrackHit> axhits = event.get(HelicalTrackHit.class, "AxialTrackHits"); - List<LCRelation> mcrelations = event.get(LCRelation.class, "HelicalTrackMCRelations"); - List<LCRelation> hitrelations = new ArrayList<LCRelation>(); - List<LCRelation> matchedmcrelations = new ArrayList<LCRelation>(); - List<HelicalTrackHit> matchedhits = new ArrayList<HelicalTrackHit>(); - List<RawTrackerHit> axhitsontrack = new ArrayList<RawTrackerHit>(); - - RelationalTable hittomc = new BaseRelationalTable(RelationalTable.Mode.MANY_TO_MANY, RelationalTable.Weighting.UNWEIGHTED); - - for (LCRelation relation : mcrelations) - if (relation != null&&relation.getFrom()!=null&&relation.getTo()!=null) - hittomc.add(relation.getFrom(), relation.getTo()); - int totax = axhits.size(); - int totaxontrack = 0; - int tothth = hthits.size(); - int toththontrack = 0; - for (Track track : tracklist) { - double trMom=track.getPX(); - SeedTrack st = (SeedTrack) track; - List<TrackerHit> trackhits = st.getTrackerHits(); - for (TrackerHit th : trackhits) { - HelicalTrackHit hth = (HelicalTrackHit) th; - List<RawTrackerHit> rawhits = hth.getRawHits(); - totaxontrack += rawhits.size(); - if(trMom<pcut)axhitsontrack.addAll(rawhits); - } - } - for (HelicalTrackHit hit : hthits) { - List<RawTrackerHit> rawhits = hit.getRawHits(); - for (RawTrackerHit rh : rawhits) - if (axhitsontrack.contains(rh) || keepHit(rh))// see if there is an overlap of raw hits in the helical track hit... - if (!matchedhits.contains(hit)) { //only add if it's not already in the collection - for (LCRelation relation : mcrelations) { - if (relation.getFrom() == hit) - matchedmcrelations.add(relation); - if (relation.getTo() == hit) - matchedmcrelations.add(relation); - } - matchedhits.add(hit); - } - } - -// System.out.println("Total axial hits = " + totax + "; total associated axial hits = " + totaxontrack); -// System.out.println("Total HelicalTrackHits = " + tothth+ "; total associated HelicalTrackHits = " + matchedhits.size()); - - event.put("MatchedHTHits", matchedhits, HelicalTrackHit.class, 0); - //event.put("MatchedHTRelations", hitrelations, LCRelation.class, 0); - event.put("MatchedHTMCRelations", matchedmcrelations, LCRelation.class, 0); - } - - public void setLayersToKeep(Integer layer) { - passLayers.add(layer); - } - - private boolean keepHit(RawTrackerHit raw) { - for (Integer keep : passLayers) - if (raw.getLayerNumber() == keep) return true; - return false; - } -}
diff -N SiTrackerSpectrometerSensorSetup.java --- SiTrackerSpectrometerSensorSetup.java 16 Nov 2011 18:00:04 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,130 +0,0 @@
-package org.lcsim.hps.recon.tracking; - -import hep.physics.matrix.BasicMatrix; -import hep.physics.vec.BasicHep3Vector; -import hep.physics.vec.VecOp; - -import java.util.List; - -import org.lcsim.detector.IDetectorElement; -import org.lcsim.detector.IRotation3D; -import org.lcsim.detector.ITranslation3D; -import org.lcsim.detector.RotationPassiveXYZ; -import org.lcsim.detector.Transform3D; -import org.lcsim.detector.Translation3D; -import org.lcsim.detector.solids.Polygon3D; -import org.lcsim.detector.solids.Trd; -import org.lcsim.detector.tracker.silicon.ChargeCarrier; -import org.lcsim.detector.tracker.silicon.SiSensor; -import org.lcsim.detector.tracker.silicon.SiStrips; -import org.lcsim.geometry.Detector; -import org.lcsim.geometry.compact.Subdetector; -import org.lcsim.geometry.subdetector.SiTrackerSpectrometer; -import org.lcsim.util.Driver; - -public class SiTrackerSpectrometerSensorSetup extends Driver { - - String subdetectorName; - - public SiTrackerSpectrometerSensorSetup() { - } - - public SiTrackerSpectrometerSensorSetup(String subdetectorName) { - this.subdetectorName = subdetectorName; - } - - public void setSubdetectorName(String subdetectorName) { - this.subdetectorName = subdetectorName; - } - - public void detectorChanged(Detector detector) { - if (subdetectorName == null) { - throw new RuntimeException("The subdetectorName was not set."); - } - - Subdetector subdetector = detector.getSubdetector(subdetectorName); - if (subdetector instanceof SiTrackerSpectrometer) { - setupSensorDetectorElements(subdetector); - } else { - throw new RuntimeException("The subdetector " + subdetectorName + " is not an instance of SiTrackerSpectrometer."); - } - } - - private void setupSensorDetectorElements(Subdetector subdet) { - System.out.println(this.getClass().getCanonicalName() + " - Setting up sensors for " + subdet.getName() + " ..."); - int sensorId = 0; - - for (IDetectorElement endcap : subdet.getDetectorElement().getChildren()) { - for (IDetectorElement layer : endcap.getChildren()) { - //int nwedges = layer.getChildren().size(); - for (IDetectorElement wedge : layer.getChildren()) { - for (IDetectorElement module : wedge.getChildren()) { - List<SiSensor> sensors = module.findDescendants(SiSensor.class); - - if (sensors.size() == 0) { - throw new RuntimeException("No sensors found in module."); - } - - for (SiSensor sensor : sensors) { - Trd sensor_solid = (Trd) sensor.getGeometry().getLogicalVolume().getSolid(); - - Polygon3D n_side = sensor_solid.getFacesNormalTo(new BasicHep3Vector(0, -1, 0)).get(0); - Polygon3D p_side = sensor_solid.getFacesNormalTo(new BasicHep3Vector(0, 1, 0)).get(0); - - // Bias the sensor -// sensor.setBiasSurface(ChargeCarrier.ELECTRON, p_side); -// sensor.setBiasSurface(ChargeCarrier.HOLE, n_side); - - sensor.setBiasSurface(ChargeCarrier.HOLE, p_side); - sensor.setBiasSurface(ChargeCarrier.ELECTRON, n_side); - -// double strip_angle = Math.atan2(sensor_solid.getXHalfLength2() - sensor_solid.getXHalfLength1(), sensor_solid.getZHalfLength() * 2); - double strip_angle = 0.00; - ITranslation3D electrodes_position = new Translation3D(VecOp.mult(-p_side.getDistance(), new BasicHep3Vector(0, 0, 1))); // translate to outside of polygon - //ITranslation3D electrodes_position = new Translation3D(VecOp.mult(n_side.getDistance(), new BasicHep3Vector(0, 0, 1))); // translate to outside of polygon - - IRotation3D electrodes_rotation = new RotationPassiveXYZ(-Math.PI / 2, 0, strip_angle); - Transform3D electrodes_transform = new Transform3D(electrodes_position, electrodes_rotation); - - // Free calculation of readout electrodes, sense electrodes determined thereon - SiStrips readout_electrodes = new SiStrips(ChargeCarrier.HOLE, 0.060, sensor, electrodes_transform); - SiStrips sense_electrodes = new SiStrips(ChargeCarrier.HOLE,0.030,(readout_electrodes.getNCells()*2-1),sensor,electrodes_transform); - -// SiStrips readout_electrodes = new SiStrips(ChargeCarrier.ELECTRON, 0.060, sensor, electrodes_transform); -// SiStrips sense_electrodes = new SiStrips(ChargeCarrier.ELECTRON, 0.030, (readout_electrodes.getNCells() * 2 - 1), sensor, electrodes_transform); - - // SiSensorElectrodes sense_electrodes = new SiStrips(ChargeCarrier.HOLE, 0.060, sensor, electrodes_transform); - -//pristine conditions -/* - readout_electrodes.setCapacitanceIntercept(0); - readout_electrodes.setCapacitanceSlope(0.12); - sense_electrodes.setCapacitanceIntercept(0); - sense_electrodes.setCapacitanceSlope(0.12); -*/ - - readout_electrodes.setCapacitanceIntercept(0); - readout_electrodes.setCapacitanceSlope(0.16); - sense_electrodes.setCapacitanceIntercept(0); - sense_electrodes.setCapacitanceSlope(0.16); - - sensor.setSenseElectrodes(sense_electrodes); - sensor.setReadoutElectrodes(readout_electrodes); -// - -// double[][] transfer_efficiencies = {{1.0}}; - double[][] transfer_efficiencies = {{0.986, 0.419}}; - sensor.setTransferEfficiencies(ChargeCarrier.HOLE, new BasicMatrix(transfer_efficiencies)); -// sensor.setTransferEfficiencies(ChargeCarrier.ELECTRON, new BasicMatrix(transfer_efficiencies)); - // here - - sensor.setSensorID(++sensorId); - } - } - } - } - } - } -} - -
diff -N HPSSVTHitDriver.java --- HPSSVTHitDriver.java 12 Mar 2012 23:05:17 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,160 +0,0 @@
- -package org.lcsim.hps.recon.tracking; - - -//--- 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.tracker.silicon.SiSensor; -import org.lcsim.detector.tracker.silicon.SiTrackerModule; -import org.lcsim.event.EventHeader; -import org.lcsim.event.RawTrackerHit; -import org.lcsim.geometry.Detector; -import org.lcsim.recon.tracking.digitization.sisim.CDFSiSensorSim; -import org.lcsim.util.Driver; - - -//--- hps-java ---// -import org.lcsim.hps.util.ClockSingleton; -import org.lcsim.recon.tracking.digitization.sisim.config.SimTrackerHitReadoutDriver; -import org.lcsim.hps.recon.tracking.apv25.HPSSiSensorReadout; -import org.lcsim.hps.recon.tracking.apv25.HPSAPV25; -import org.lcsim.recon.tracking.digitization.sisim.NearestNeighborRMS; -import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHit; -import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitStrip1D; -import org.lcsim.recon.tracking.digitization.sisim.StripHitMaker; - -/** - * - * @author Omar Moreno <[log in to unmask]> - * @version $Id: HPSSVTHitDriver.java,v 1.3 2012/03/12 23:05:17 omoreno Exp $ - */ -public class HPSSVTHitDriver extends Driver { - - -// HPSStripHitMaker stripClusterer; - - // - 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() - { - - CDFSiSensorSim stripSimulation = new CDFSiSensorSim(); - -// HPSNearestNeighborRMS stripClustering = new HPSNearestNeighborRMS(); - -// stripClustering.setSeedThreshold(278*4); -// stripClustering.setNeighborThreshold(278*3); -// stripClustering.setClusterThreshold(4); -// -// stripClusterer = new HPSStripHitMaker(stripSimulation, stripClustering); -// -// stripClusterer.setMaxClusterSize(10); -// stripClusterer.setCentralStripAveragingThreshold(4); -// -// double multiplier = 1.0; -// stripClusterer.SetOneClusterErr(multiplier/Math.sqrt(12)); -// stripClusterer.SetTwoClusterErr(multiplier/5); -// stripClusterer.SetThreeClusterErr(multiplier/3); -// stripClusterer.SetFourClusterErr(multiplier/2); -// stripClusterer.SetFiveClusterErr(multiplier/1); - - } - - /** - * 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); - - List<RawTrackerHit> rawHits = (List<RawTrackerHit>) event.get("RawTrackerHits"); - List<SiTrackerHit> hitsStrip1D = new ArrayList<SiTrackerHit>(); - - if(rawHits.size() > 0) System.out.println("It worked!"); - -// for(SiSensor sensor: processSensors){ -// hitsStrip1D.addAll(stripClusterer.makeHits(sensor)); -// -// } - - - if(hitsStrip1D.size() > 0){ - System.out.println(this.getClass().getName() + ": The Number of Clusters Found: " + hitsStrip1D.size()); - } - - event.put("_SiTrackerHitStrip1D",hitsStrip1D, SiTrackerHitStrip1D.class, 0, toString()); - } - - public String getStripHits1DName(){ - return "_SiTrackerHitStrip1D"; - } -}
diff -N StripHitsOnTrack.java --- StripHitsOnTrack.java 1 Jun 2011 17:05:31 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,92 +0,0 @@
-/* - * TrackReconstructionDriver class - */ -package org.lcsim.hps.recon.tracking; - -import java.util.ArrayList; -import java.util.List; - -import org.lcsim.event.EventHeader; -import org.lcsim.event.LCRelation; -import org.lcsim.event.RelationalTable; -import org.lcsim.event.Track; -import org.lcsim.event.TrackerHit; -import org.lcsim.event.base.BaseRelationalTable; -import org.lcsim.fit.helicaltrack.HelicalTrackHit; -import org.lcsim.recon.tracking.seedtracker.SeedTrack; -import org.lcsim.util.Driver; -import org.lcsim.util.aida.AIDA; - -/** - * Driver to perform hit digitization and track reconstruction for the sATLAS detector - * - * @author M. Graham and R. Partridge - */ -public class StripHitsOnTrack extends Driver { - - private AIDA aida = AIDA.defaultInstance(); - List<Integer> passLayers = new ArrayList(); - - public StripHitsOnTrack() { - } - - - public void process( - EventHeader event) { - - List<Track> tracklist = event.get(Track.class, "MatchedTracks"); - List<HelicalTrackHit> hthits = event.get(HelicalTrackHit.class, "HelicalTrackHits"); - List<LCRelation> mcrelations = event.get(LCRelation.class, "HelicalTrackMCRelations"); - List<LCRelation> availablemcrelations = new ArrayList<LCRelation>(); - List<HelicalTrackHit> availablehits = new ArrayList<HelicalTrackHit>(); - List<HelicalTrackHit> hitsOnTracks = new ArrayList<HelicalTrackHit>(); - - RelationalTable hittomc = new BaseRelationalTable(RelationalTable.Mode.MANY_TO_MANY, RelationalTable.Weighting.UNWEIGHTED); - - - for (LCRelation relation : mcrelations) - if (relation != null&&relation.getFrom()!=null&&relation.getTo()!=null) - hittomc.add(relation.getFrom(), relation.getTo()); - - - int totaxontrack = 0; - int tothth = hthits.size(); - int toththontrack = 0; - for (Track track : tracklist) { - SeedTrack st = (SeedTrack) track; - List<TrackerHit> trackhits = st.getTrackerHits(); - for (TrackerHit th : trackhits) { - hitsOnTracks.add((HelicalTrackHit) th); - } - } - for (HelicalTrackHit hit : hthits) { - if (!(hitsOnTracks.contains(hit)) || keepHit(hit))// see if there is an overlap of raw hits in the helical track hit... - if (!availablehits.contains(hit)) { //only add if it's not already in the collection - for (LCRelation relation : mcrelations) { - if (relation.getFrom() == hit) - availablemcrelations.add(relation); - if (relation.getTo() == hit) - availablemcrelations.add(relation); - } - availablehits.add(hit); - } - } - -// System.out.println("Total axial hits = " + totax + "; total associated axial hits = " + totaxontrack); -// System.out.println("Total HelicalTrackHits = " + tothth+ "; total associated HelicalTrackHits = " + matchedhits.size()); - - event.put("RemainingHits", availablehits, HelicalTrackHit.class, 0); - //event.put("MatchedHTRelations", hitrelations, LCRelation.class, 0); - event.put("RemainingMCRelations", availablemcrelations, LCRelation.class, 0); - } - - public void setLayersToKeep(Integer layer) { - passLayers.add(layer); - } - - private boolean keepHit(HelicalTrackHit raw) { - for (Integer keep : passLayers) - if (raw.Layer() == keep) return true; - return false; - } -}
diff -N HPSRTM.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSRTM.java 15 Mar 2013 21:05:28 -0000 1.3 @@ -0,0 +1,127 @@
+ +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.3 2013/03/15 21:05:28 meeg 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); + + adcVoltageResolution + = (adcHighRef - adcLowRef)/voltageIntervals; // mV + + } + + //--- Methods ---// + //---------------// + + + /** + * + * @param data + */ + public Map<Integer, double[]> digitize( Map<Integer, double[]> data ) + { + digitalData = data; + + // Amplify the incoming analog signal + amplifySignal(); + + // Loop over all apv25 analog signals and digitize them + for(Map.Entry<Integer, double[]> entry : digitalData.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); + + } + + return digitalData; + } + + /** + * + */ + public void amplifySignal() + { + + // Loop over all apv25 analog data + for(Map.Entry<Integer, double[]> entry : digitalData.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 + digitalData.put(entry.getKey(), apv25Output); + + } + } + + /** + * + */ + public void setResolution( int bits ) + { + adcResolution = bits; + } + + /** + * + */ + public void printData() + { + + double[] data = digitalData.get("1"); + System.out.println(data.length); + System.out.println(" ]"); + } +}
diff -N HPSSVTDataBuffer.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSSVTDataBuffer.java 15 Mar 2013 21:05:28 -0000 1.1 @@ -0,0 +1,157 @@
+ +package org.lcsim.hps.recon.tracking.apv25; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +// Constants +import org.lcsim.hps.recon.tracking.FpgaData; +import org.lcsim.hps.recon.tracking.HPSSVTData; +import static org.lcsim.hps.recon.tracking.HPSSVTConstants.SVT_TOTAL_FPGAS; +import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TEMP_MASK; + +/** + * + * @author Omar Moreno <[log in to unmask]> + * @version $Id: HPSSVTDataBuffer.java,v 1.1 2013/03/15 21:05:28 meeg Exp $ + */ +public class HPSSVTDataBuffer { + + // Map the FPGA to the data emerging from it + private Map<Integer, List<Integer>> fpgaToData = new HashMap<Integer, List<Integer>>(); + + // Singleton + private static final HPSSVTDataBuffer instance = new HPSSVTDataBuffer(); + private static int eventNumber = 0; + + int[] header = new int[6]; + int temp = FpgaData.temperatureToInt(23.0); // C + + boolean debug = false; + + /** + * Default constructor; Set to private to prevent instantiation + */ + private HPSSVTDataBuffer(){ + // + for(int fpgaNumber = 0; fpgaNumber <= SVT_TOTAL_FPGAS; fpgaNumber++) + fpgaToData.put(fpgaNumber, new ArrayList<Integer>()); + } + + /** + * Add data to SVT buffer + * + * @param svtData : List of SVT data packets + * @param fpga : FPGA from which the data emerges from + */ + public static void addToBuffer(List<HPSSVTData> svtData, int fpga){ + // If the FPGA data block is empty, add header information and data, otherwise + // just add the data + instance.encapsulateSVTData(svtData, fpga); + } + + /** + * Readout data stored in the SVT buffer + * + * @param fpga : FPGA from which data is to be read from + * @return data : An FPGA data packet + * + */ + public static int[] readoutBuffer(int fpga){ + // Add the event number to the beginning + instance.addEventNumber(fpga); + + // Add the tail to the data + instance.addTail(fpga); + + // Copy the data in the map so that the buffer can be cleared + int[] data = new int[instance.fpgaToData.get(fpga).size()]; + int index = 0; + for(Integer datum : instance.fpgaToData.get(fpga)){ + data[index] = datum; + index++; + } + + // Clear the buffer + instance.fpgaToData.get(fpga).clear(); + + // Return the + return data; + } + + /** + * Encapsulate SVT data by FPGA + * + * @param svtData : List of SVT data packets + * @param fpga : FPGA from which the data emerges from + */ + private void encapsulateSVTData(List<HPSSVTData> svtData, int fpga){ + // Ignore FPGA 7 for now + if(fpga == 7) return; + + // If the FPGA data block is empty, add the header information and increment the event number + if(instance.fpgaToData.get(fpga).isEmpty()){ + + // Insert the temperature information. All temperatures are currently + // set to 23 C + header[0] = (header[0] &= ~TEMP_MASK) | (temp & TEMP_MASK); + header[0] = (header[0] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16); + + header[1] = (header[1] &= ~TEMP_MASK) | (temp & TEMP_MASK); + header[1] = (header[1] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16); + + header[2] = (header[2] &= ~TEMP_MASK) | (temp & TEMP_MASK); + header[2] = (header[2] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16); + + header[3] = (header[3] &= ~TEMP_MASK) | (temp & TEMP_MASK); + header[3] = (header[3] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16); + + header[4] = (header[4] &= ~TEMP_MASK) | (temp & TEMP_MASK); + header[4] = (header[4] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16); + + header[5] = (header[5] &= ~TEMP_MASK) | (temp & TEMP_MASK); + header[5] = (header[5] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16); + + for(int index = 0; index < header.length; index++) fpgaToData.get(fpga).add(header[index]); + + eventNumber++; + } + + // Add all samples emerging from this FPGA + if(!svtData.isEmpty()){ + for(HPSSVTData svtDatum : svtData){ + if(debug){ + System.out.println("FPGA: " + svtDatum.getFPGAAddress() + " Hybrid: " + svtDatum.getHybridNumber() + " APV: " + + svtDatum.getAPVNumber() + " Channel: " + svtDatum.getChannelNumber()); + } + for(int index = 0; index < svtDatum.getData().length; index++){ + fpgaToData.get(fpga).add(svtDatum.getData()[index]); + } + } + } + } + + /** + * Add a tail to the FPGA data packet. In real data, this may be + * non-zero which would indicate an error. + * + * @param fpga : FPGA from which the data emerges from + */ + private void addTail(int fpga){ + + // For now just make it zero + instance.fpgaToData.get(fpga).add(0); + } + + /** + * Add an SVT event number to the top of the FPGA data packet. + * + * @param fpga : FPGA from which the data emerges from + */ + private void addEventNumber(int fpga){ + + instance.fpgaToData.get(fpga).add(0, eventNumber); + } +}
diff -N HPSDataProcessingModule.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSDataProcessingModule.java 15 Mar 2013 21:05:28 -0000 1.3 @@ -0,0 +1,398 @@
+package org.lcsim.hps.recon.tracking.apv25; + +//--- Java ---// +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +//--- org.lcsim ---// +import java.util.Set; +import org.lcsim.detector.IReadout; +import org.lcsim.detector.tracker.silicon.SiSensor; +import org.lcsim.event.EventHeader; +import org.lcsim.event.RawTrackerHit; +import org.lcsim.event.SimTrackerHit; +import org.lcsim.event.base.BaseRawTrackerHit; +import org.lcsim.geometry.Detector; +import org.lcsim.hps.recon.tracking.HPSSVTData; +import org.lcsim.hps.recon.tracking.SvtUtils; +import org.lcsim.util.Driver; + +//--- Constants ---// +import static org.lcsim.hps.recon.tracking.HPSSVTConstants.SVT_TOTAL_FPGAS; +import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TOTAL_APV25_CHANNELS; +import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TOTAL_APV25_PER_HYBRID; +import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TOTAL_HYBRIDS_PER_FPGA; + +/** + * + * @author Omar Moreno <[log in to unmask]> + * @version $Id: HPSDataProcessingModule.java,v 1.3 2013/03/15 21:05:28 meeg Exp $ + */ +public class HPSDataProcessingModule extends Driver { + + // A map relating a sensor to all sample blocks collected from that sensor + Map<SiSensor, Map<Integer, List<Double>>> sensorToSamplesMap; + + // Relate a channel to its six samples + Map<Integer, List<Double>> channelToBlock; + + // Relate a sensor Identifier to the actual sensor + Map<Long, SiSensor> sensorMap = new HashMap<Long, SiSensor>(); + + // Collection of all sensors + Set<SiSensor> sensorSet = new HashSet<SiSensor>(); + + // Collections of RawTrackerHits + List<RawTrackerHit> rawHits; // Cuts are applied + List<RawTrackerHit> rawHitsNoCuts; // No cuts are applied to samples + + // Collection of all SVT data + List<HPSSVTData> svtData; + List<HPSSVTData> svtFpgaData; + List<Double> samples; + + int numberOfSamples = 0; // Total number of APV25 samples + int nSamplesAboveThresh = 3; // Number of samples above noise threshold + int pedestal = 1638; // [ADC counts] For now, all channels have the same pedestal + int flags = 0; // + int noise = 18; // [ADC Counts] RMS noise + int noiseThreshold = 3; // Units of RMS noise + int physicalChannel; + + private boolean thresholdCut = false; // Apply threshold cut? + private boolean tailCut = false; // Apply tail cut? + private boolean noiseSuppression = false; // Apply noise suppression? + boolean debug = false; + + double[] apv25DataStream; + + String RawTrackerHitsCollectionName = "RawTrackerHits"; + String RawTrackerHitsNoCutsCollectionName = "RawTrackerHitsNoCuts"; + String svtCollectionName = "SVTData"; + + /** + * Default Constructor + */ + public HPSDataProcessingModule() { + channelToBlock = new HashMap<Integer, List<Double>>(); + sensorToSamplesMap = new HashMap<SiSensor, Map<Integer, List<Double>>>(); + rawHits = new ArrayList<RawTrackerHit>(); + rawHitsNoCuts = new ArrayList<RawTrackerHit>(); + svtData = new ArrayList<HPSSVTData>(); + svtFpgaData = new ArrayList<HPSSVTData>(); + } + + /** + * + */ + @Override + public void detectorChanged(Detector detector) { + + for (SiSensor sensor : SvtUtils.getInstance().getSensors()) { + // Map a sensor to its corresponding samples + sensorToSamplesMap.put(sensor, new HashMap<Integer, List<Double>>()); + } + } + + /** + * Set the SVT collection name + */ + public void setSvtCollectionName(String svtCollectionName) { + this.svtCollectionName = svtCollectionName; + } + + /** + * Set the number of samples above threshold a signal must have + */ + public void setSamplesAboveThresh(int nSamplesAboveThresh) { + this.nSamplesAboveThresh = nSamplesAboveThresh; + } + + /** + * Set the noise RMS [ADC Counts] + */ + public void setNoise(int noise) { + this.noise = noise; + } + + /** + * Set the noise threshold in units of RMS noise + */ + public void setNoiseThreshold(int noiseThreshold) { + this.noiseThreshold = noiseThreshold; + } + + /** + * Set the pedestal value for all channels + */ + public void setPedestal(int pedestal) { + this.pedestal = pedestal; + } + + /** + * Enable the threshold cut. The threshold cut requires a certain number + * of samples per hit to be above a noise threshold. + */ + public void enableThresholdCut() { + this.thresholdCut = true; + } + + /** + * Enable the tail cut. The tail cut requires sample 1 to be greater than + * sample 0 or sample 2 to be greater than sample 1. This eliminates + * hits that may arise due to shaper signal tails. + */ + public void enableTailCut() { + this.tailCut = true; + } + + /** + * Enable noise suppression cut. Requires samples 2 or 3 to be above a + * threshold noiseThreshold + noise. + */ + public void enableNoiseSuppressionCut() { + this.noiseSuppression = true; + } + + /** + * Buffer a sample that has been readout from a sensor. + * + * @param sensorToDigitalMap + * A map relating a sensor to the digital samples readout from the + * sensor + */ + public void addSample(Map<SiSensor, Map<Integer, double[]>> sensorToDigitalMap) { + + /* + * Integer: Chip Number + * double[]: APV25 Data Analog Data + */ + + int physicalChannel; + + // Loop through the list of all sensors + for (Map.Entry<SiSensor, Map<Integer, double[]>> sensor : sensorToDigitalMap.entrySet()) { + + // Loop through all APV25s + for (Map.Entry<Integer, double[]> chipData : sensor.getValue().entrySet()) { + + // Copy the sample to avoid concurrent modification + apv25DataStream = chipData.getValue(); + + // Strip the APV25 data stream of all header information + apv25DataStream = Arrays.copyOfRange(apv25DataStream, 12, apv25DataStream.length - 1); + + // Loop through all channels + for (int channel = 0; channel < apv25DataStream.length; channel++) { + + physicalChannel = channel + chipData.getKey() * 128; + + // Check if a block has been created for this channel. If not create it + if (!sensorToSamplesMap.get(sensor.getKey()).containsKey(physicalChannel)) { + sensorToSamplesMap.get(sensor.getKey()).put(physicalChannel, new ArrayList<Double>(6)); + } + sensorToSamplesMap.get(sensor.getKey()).get(physicalChannel).add(apv25DataStream[channel]); + } + } + } + numberOfSamples++; + } + + /** + * Finds hits that satisfied all required cuts and creates both + * RawTrackerHits and SVTData + */ + public void findHits() { + + int fpgaNumber, hybridNumber, apvNumber, rawChannel; + + // Clear the list of raw tracker hits + rawHits.clear(); + rawHitsNoCuts.clear(); + svtData.clear(); + + // Loop through all sensors and the corresponding blocks + for (Map.Entry<SiSensor, Map<Integer, List<Double>>> sensor : sensorToSamplesMap.entrySet()) { + + // Get the FPGA number + fpgaNumber = SvtUtils.getInstance().getFPGA(sensor.getKey()); + if(fpgaNumber > SVT_TOTAL_FPGAS || fpgaNumber < 0) + throw new RuntimeException("FPGA Number out of range!"); + if(debug) System.out.println(this.getClass().getSimpleName() + ": FPGA Number: " + fpgaNumber); + + // Clear the temporary list + svtFpgaData.clear(); + + for (Map.Entry<Integer, List<Double>> samples : sensor.getValue().entrySet()) { + short[] adc = new short[6]; + + // Convert ADC value to a short + for (int index = 0; index < adc.length; index++) + adc[index] = samples.getValue().get(index).shortValue(); + + // If a strip had any charge deposited on it, create a RawTrackerHit + if(!(samplesAboveThreshold(adc) >= 1)){ + samples.getValue().clear(); + continue; + } + + RawTrackerHit rawHit = makeRawTrackerHit(samples.getKey(), sensor.getKey(), adc); + rawHitsNoCuts.add(rawHit); + + // Check if a block has the appropriate number of blocks above threshold + if (thresholdCut && !(samplesAboveThreshold(adc) >= nSamplesAboveThresh)) { + samples.getValue().clear(); + continue; + } + + // Apply the tail cut + if (tailCut && !tailCut(adc)) { + samples.getValue().clear(); + continue; + } + + // Apply noise suppression cut + if (noiseSuppression && !noiseSuppressionCut(adc)) { + samples.getValue().clear(); + continue; + } + + // If all cuts are satisfied, add the hit to the list of hits to be saved + rawHits.add(rawHit); + + // Get the hybrid number + hybridNumber = SvtUtils.getInstance().getHybrid(sensor.getKey()); + if(hybridNumber > TOTAL_HYBRIDS_PER_FPGA || hybridNumber < 0) + throw new RuntimeException("Hybrid number is out of range!"); + //if(debug) System.out.println(this.getClass().getSimpleName() + ": Hybrid Number: " + hybridNumber); + + // Find the APV number. Note that strip numbering is from 639 to 0 + apvNumber = (TOTAL_APV25_PER_HYBRID - 1) - (int) Math.floor(samples.getKey()/128); + if(apvNumber > TOTAL_APV25_PER_HYBRID || apvNumber < 0) + throw new RuntimeException("APV25 Number out of range!"); + //if(debug) System.out.println(this.getClass().getSimpleName() + ": APV Number: " + apvNumber); + + // Find the raw channel number from the physical channel + rawChannel = samples.getKey() - (TOTAL_APV25_CHANNELS*TOTAL_APV25_PER_HYBRID - 1) + + apvNumber*TOTAL_APV25_CHANNELS + (TOTAL_APV25_CHANNELS - 1); + if(rawChannel > TOTAL_APV25_CHANNELS || rawChannel < 0) + throw new RuntimeException("APV25 Channel " + rawChannel + " out of range!"); + //if(debug) System.out.println(this.getClass().getSimpleName() + ": Raw Channel Number: " + rawChannel); + + // Create an svtData packet + HPSSVTData data = new HPSSVTData(hybridNumber, apvNumber, rawChannel, fpgaNumber, adc); + svtData.add(data); + svtFpgaData.add(data); + + samples.getValue().clear(); + } + + HPSSVTDataBuffer.addToBuffer(svtFpgaData, fpgaNumber); + } + if(debug) System.out.println(this.getClass().getName() + ": Total RawTrackerHits before cuts: " + rawHitsNoCuts.size()); + if(debug) System.out.println(this.getClass().getName() + ": Total RawTrackerHits: " + rawHits.size()); + if(debug) System.out.println(this.getClass().getName() + ": Total SVTData: " + svtData.size()); + } + + /** + * Creates a rawTrackerHit + * + * @param channelNumber + * Si Strip from which the hit originates from + * @param sensor + * Sensor from which the hit originates from + * @param adcValues + * Shaper signal samples + * @return RawTrackerHit + */ + private RawTrackerHit makeRawTrackerHit(Integer channelNumber, SiSensor sensor, short[] adcValues) { + IReadout ro = sensor.getReadout(); + + // No time yet + int time = 0; + long cell_id = sensor.makeStripId(channelNumber, 1).getValue(); + + RawTrackerHit rawHit = new BaseRawTrackerHit(time, cell_id, adcValues, new ArrayList<SimTrackerHit>(), sensor); + + ro.addHit(rawHit); + + return rawHit; + } + + /** + * Finds how many samples are above a given threshold + * + * @param adc + * Shaper signal samples + * @return Number of samples above threshold + */ + private int samplesAboveThreshold(short[] adc) { + // Number of samples above threshold + int nSamplesAboveThreshold = 0; + + for (int sample = 0; sample < adc.length; sample++) { + if (adc[sample] >= pedestal + noiseThreshold * noise) { + nSamplesAboveThreshold++; + } + } + return nSamplesAboveThreshold; + } + + /** + * Applies tail cut + * + * @param adc + * Shaper signal samples + * @return true if the cut is satisfied, false otherwise + */ + private boolean tailCut(short[] adc) { + if (adc[3] > adc[2] || adc[4] > adc[3]) { + return true; + } + return false; + } + + /** + * Applies noise suppression cut + * + * @param adc + * Shaper signal samples + * @return true if the cut is satisfied, false otherwise + */ + private boolean noiseSuppressionCut(short[] adc) { + if (adc[3] > pedestal + noiseThreshold * noise || adc[4] > pedestal + noiseThreshold * noise) { + return true; + } + return false; + } + + /** + * + */ + @Override + public void process(EventHeader event) { + super.process(event); + + // If six samples have been collected process the data + if (numberOfSamples == 6) { + + // Find hits + findHits(); + + // Add RawTrackerHits to the event + event.put(RawTrackerHitsCollectionName, rawHits, RawTrackerHit.class, flags); + + // Add SVTData to event + System.out.println("Adding SVTData Collection of size: " + svtData.size() + " to the Event"); + event.put(this.svtCollectionName, this.svtData, HPSSVTData.class, 0); + + + // + numberOfSamples = 0; + } + } +}
diff -N RearTransitionModule.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ RearTransitionModule.java 15 Mar 2013 21:05:28 -0000 1.1 @@ -0,0 +1,141 @@
+package org.lcsim.hps.recon.tracking.apv25; + +//--- java ---// +import java.util.ArrayList; +import java.util.List; + +//--- org.lcsim ---// +import org.lcsim.event.EventHeader; +import org.lcsim.hps.recon.tracking.HPSSVTCalibrationConstants; +import org.lcsim.util.Driver; + +//--- hps-java ---// +import org.lcsim.hps.recon.tracking.apv25.Apv25AnalogData; +import org.lcsim.hps.recon.tracking.apv25.Apv25DigitalData; +import org.lcsim.hps.util.RandomGaussian; + +//--- Constants ---// +import static org.lcsim.hps.recon.tracking.apv25.Apv25Constants.CHANNELS; +import static org.lcsim.hps.recon.tracking.apv25.Apv25Constants.MULTIPLEXER_GAIN; +import static org.lcsim.hps.recon.tracking.apv25.Apv25Constants.MIP; +import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TOTAL_STRIPS_PER_SENSOR; + +/** + * + * @author Omar Moreno <[log in to unmask]> + * @version $Id: RearTransitionModule.java,v 1.1 2013/03/15 21:05:28 meeg Exp $ + */ +public class RearTransitionModule extends Driver { + + String apv25AnalogDataCollectionName = "APV25AnalogData"; + String apv25DigitalDataCollectionName = "AVP25DigitalData"; + + double adcVHighRef = 1000; // mVolts + double adcVLowRef = -1000; // mVolts + int adcResolution = 14; // bits + double adcVoltageResolution = 1; // mV + int quantizationLevels = 256; + + double resistorValue = 100; // Ohms + double inputStageGain = 1.5; + + boolean noiseless = false; + + /** + * Default Ctor + */ + public RearTransitionModule(){ + + // Find the number of quantization levels + int quantizationLevels = (int) Math.pow(2, adcResolution); + + // Find the ADC voltage resolution + adcVoltageResolution = (adcVHighRef - adcVLowRef)/quantizationLevels; // mV + } + + /** + * + */ + public void setResolution(int bits){ + adcResolution = bits; + + // Find the number of quantization levels + quantizationLevels = (int) Math.pow(2, adcResolution); + + + // Find the ADC voltage resolution + adcVoltageResolution = (adcVHighRef - adcVLowRef)/quantizationLevels; // mV + } + + /** + * + */ + public void setADCSpan(double adcVHighRef, double adcVLowRef){ + this.adcVHighRef = adcVHighRef; + this.adcVLowRef = adcVLowRef; + + // Find the ADC voltage resolution + adcVoltageResolution = (adcVHighRef - adcVLowRef)/quantizationLevels; // mV + } + + /** + * Turn readout noise on/off + */ + public void setNoiseless(boolean noiseless){ + this.noiseless = noiseless; + } + + /** + * + */ + @Override + protected void process(EventHeader event){ + super.process(event); + + // If the event does not contain any analog data that needs to be digitized, skip the event + if(!event.hasCollection(Apv25AnalogData.class, apv25AnalogDataCollectionName)) return; + + // Get the analog data from the event + List<Apv25AnalogData> analogData = event.get(Apv25AnalogData.class, apv25AnalogDataCollectionName); + + // Create a list hold the digital data + List<Apv25DigitalData> digitalData = new ArrayList<Apv25DigitalData>(); + + // Amplify the analog data + for(Apv25AnalogData analogDatum : analogData){ + + // Make a hard copy of the APV25 analog output to avoid modification of the original + double[] apv25Output = new double[140]; + System.arraycopy(analogDatum.getApv25AnalogOutput(), 0, apv25Output, 0, apv25Output.length); + + for(int index = 0; index < apv25Output.length; index++){ + + // For now, don't digitize the header + if(index < 12) continue; + + // Get the physical channel + int physicalChannel = TOTAL_STRIPS_PER_SENSOR + - (analogDatum.getApvNumber()*CHANNELS + (CHANNELS - 1) - (index - 12)); + + apv25Output[index] += 4; // mA + apv25Output[index] *= (MIP/MULTIPLEXER_GAIN); + + // Digitize the signal + apv25Output[index] *= HPSSVTCalibrationConstants.getGain(analogDatum.getSensor(), physicalChannel); + + // Add pedestal and noise + double pedestal = HPSSVTCalibrationConstants.getPedestal(analogDatum.getSensor(), physicalChannel); + double noise = HPSSVTCalibrationConstants.getNoise(analogDatum.getSensor(), physicalChannel); + if(!noiseless) + apv25Output[index] += RandomGaussian.getGaussian(pedestal, noise); + else + apv25Output[index] += pedestal; + } + + // Add the digital data to the list + digitalData.add(new Apv25DigitalData(analogDatum.getSensor(), analogDatum.getApvNumber(), apv25Output)); + } + + event.put(apv25DigitalDataCollectionName, digitalData, Apv25DigitalData.class, 0); + } +}
diff -N TestRunDataProcessingModule.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ TestRunDataProcessingModule.java 15 Mar 2013 21:05:28 -0000 1.1 @@ -0,0 +1,139 @@
+package org.lcsim.hps.recon.tracking.apv25; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.lcsim.detector.IReadout; +import org.lcsim.detector.tracker.silicon.ChargeCarrier; +import org.lcsim.detector.tracker.silicon.SiSensor; +import org.lcsim.event.EventHeader; +import org.lcsim.event.RawTrackerHit; +import org.lcsim.event.SimTrackerHit; +import org.lcsim.event.base.BaseRawTrackerHit; +import org.lcsim.geometry.Detector; +import org.lcsim.hps.recon.tracking.HPSSVTCalibrationConstants; +import org.lcsim.hps.recon.tracking.apv25.Apv25DigitalData; +import org.lcsim.util.Driver; + + +/** + * + * @author Omar Moreno <[log in to unmask]> + * @version $Id: TestRunDataProcessingModule.java,v 1.1 2013/03/15 21:05:28 meeg Exp $ + */ +public class TestRunDataProcessingModule extends DataProcessingModule { + + int nSamplesAboveThreshold = 1; // Number of samples above noise threshold + int noiseThreshold = 3; // Units of RMS noise + + boolean enablePileUpCut = true; + boolean enableThresholdCut = true; + + /** + * Default Ctor + */ + public TestRunDataProcessingModule(){ + }; + + /** + * + */ + public void setNumberOfSamplesAboveThreshold(int nSamplesAboveThreshold){ + this.nSamplesAboveThreshold = nSamplesAboveThreshold; + } + + /** + * + */ + public void setNoiseThreshold(int noiseThreshold /* Noise RMS */){ + this.noiseThreshold = noiseThreshold; + } + + /** + * + */ + public void setEnablePileUpCut(boolean enablePileUpCut){ + this.enablePileUpCut = enablePileUpCut; + } + + /** + * + */ + public void setEnableThresholdCut(boolean enableThresholdCut){ + this.enableThresholdCut = enableThresholdCut; + } + + protected List<RawTrackerHit> findRawHits(){ + + List<RawTrackerHit> rawHits = new ArrayList<RawTrackerHit>(); + + // Loop through all blocked data + for(Map.Entry<SiSensor, SvtDataBlocks> sensor : sensorToDataBlocks.entrySet()){ + + SvtDataBlocks blocks = sensor.getValue(); + + for(int channel = 0; channel < 639; channel++){ + + if(HPSSVTCalibrationConstants.isBadChannel(sensor.getKey(), channel)) continue; + + short[] samples = blocks.getSamples(channel); + + if(enableThresholdCut && !this.samplesAboveThreshold(sensor.getKey(), channel, samples)) continue; + + if(enablePileUpCut && !this.pileUpCut(samples)) continue; + + // Create a RawTrackerHit + int sideNumber; + int time = 0; + if(sensor.getKey().hasElectrodesOnSide(ChargeCarrier.HOLE)){ + sideNumber = ChargeCarrier.HOLE.charge(); + } else { + sideNumber = ChargeCarrier.ELECTRON.charge(); + } + long cellID = sensor.getKey().makeStripId(channel, sideNumber).getValue(); + RawTrackerHit rawHit = new BaseRawTrackerHit(time, cellID, samples, new ArrayList<SimTrackerHit>(), sensor.getKey()); + rawHits.add(rawHit); + + // Add the raw hit to the sensor readout + IReadout readOut = sensor.getKey().getReadout(); + readOut.addHit(rawHit); + } + } + + System.out.println(this.getClass().getSimpleName() + ": Number of RawTrackerHits created: " + rawHits.size()); + return rawHits; + } + + /** + * + */ + private boolean samplesAboveThreshold(SiSensor sensor, int channel, short[] samples){ + // Number of samples above threshold + int nSamplesAboveThreshold = 0; + + // Get the pedestal and noise for this channel + double pedestal = HPSSVTCalibrationConstants.getPedestal(sensor, channel); + double noise = HPSSVTCalibrationConstants.getNoise(sensor, channel); + + // Calculate the threshold + int threshold = (int) (pedestal + noise*this.noiseThreshold); + + for(int index = 0; index < 6; index++){ + if(samples[index] >= threshold) nSamplesAboveThreshold++; + } + + // If the prerequisite number of samples are above threshold return true + if(nSamplesAboveThreshold >= this.nSamplesAboveThreshold ) return true; + return false; + } + + /** + * + */ + private boolean pileUpCut(short[] sample){ + if(sample[2] > sample[1] || sample[3] > sample[2]) return true; + return false; + } +}
diff -N DataProcessingModule.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ DataProcessingModule.java 15 Mar 2013 21:05:28 -0000 1.1 @@ -0,0 +1,118 @@
+package org.lcsim.hps.recon.tracking.apv25; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.lcsim.detector.tracker.silicon.SiSensor; +import org.lcsim.event.EventHeader; +import org.lcsim.event.RawTrackerHit; +import org.lcsim.geometry.Detector; +import org.lcsim.hps.recon.tracking.SvtUtils; +import org.lcsim.hps.recon.tracking.apv25.Apv25DigitalData; +import org.lcsim.util.Driver; +/** + * + * @author Omar Moreno + * @version $Id: DataProcessingModule.java,v 1.1 2013/03/15 21:05:28 meeg Exp $ + */ +public abstract class DataProcessingModule extends Driver{ + + Map<SiSensor, SvtDataBlocks> sensorToDataBlocks = new HashMap<SiSensor, SvtDataBlocks>(); + + // Collection Names + String apv25DigitalDataCollectionName = "AVP25DigitalData"; + String rawTrackerHitsCollectionName = "SVTRawTrackerHits"; + + int nSamples = 0; // Number of samples which have been processed + int totalSamples = 6; // Number of samples which are read out + + /** + * Set the number of shaper signal samples to be readout + */ + public void setNumberOfSamplesToReadOut(int totalSamples){ + this.totalSamples = totalSamples; + } + + protected abstract List<RawTrackerHit> findRawHits(); + + @Override + public void detectorChanged(Detector detector){ + for(SiSensor sensor : SvtUtils.getInstance().getSensors()){ + sensorToDataBlocks.put(sensor, new SvtDataBlocks()); + } + } + + @Override + public void process(EventHeader event){ + + // If the event does not contain any data to process, skip it + if(!event.hasCollection(Apv25DigitalData.class, apv25DigitalDataCollectionName)) return; + + // Get the digital data from the event + List<Apv25DigitalData> digitalData = event.get(Apv25DigitalData.class, apv25DigitalDataCollectionName); + + // Block the data together + for(Apv25DigitalData digitalDatum : digitalData){ + SiSensor sensor = digitalDatum.getSensor(); + int apvN = digitalDatum.getApv(); + + double[] apv25DigitalOutput = new double[128]; + System.arraycopy(digitalDatum.getSamples(), 0, apv25DigitalOutput, 0, apv25DigitalOutput.length); + + for(int channel = 0; channel < apv25DigitalOutput.length; channel++){ + + // Calculate the physical number + int physicalChannel = 639 - (apvN*128 + 127 - channel); + + sensorToDataBlocks.get(sensor).addSample(physicalChannel, nSamples, (short) apv25DigitalOutput[channel]); + } + } + nSamples++; + + // If the expected number of samples has been collected, process the data + if(nSamples == totalSamples){ + + // Add RawTrackerHits to the event + event.put(rawTrackerHitsCollectionName, this.findRawHits(), RawTrackerHit.class, 0); + nSamples = 0; + } + } + + protected class SvtDataBlocks { + + Map<Integer /* sample number */, short[]> channelToSamples = new HashMap<Integer, short[]>(); + + /** + * + */ + public SvtDataBlocks(){ + } + + public void addSample(Integer physicalChannel, int sampleN, short value){ + if(!channelToSamples.containsKey(physicalChannel)) channelToSamples.put(physicalChannel, new short[6]); + channelToSamples.get(physicalChannel)[sampleN] = value; + } + + /** + * + */ + public short[] getSamples(int physicalChannel){ + return channelToSamples.get(physicalChannel); + } + + /** + * + */ + public String printSamples(int physicalChannel){ + String sampleString = "[ "; + short[] samples = this.getSamples(physicalChannel); + for(int index = 0; index < samples.length -1; index++){ + sampleString += samples[index] + ", "; + } + sampleString += samples[samples.length - 1] + "]"; + return sampleString; + } + } + +}
diff -u -r1.11 -r1.12 --- HPSSiSensorReadout.java 3 Aug 2012 00:05:26 -0000 1.11 +++ HPSSiSensorReadout.java 15 Mar 2013 21:05:28 -0000 1.12 @@ -39,8 +39,6 @@
//--- hps-java ---// import org.lcsim.hps.recon.tracking.apv25.HPSAPV25.APV25Channel.APV25AnalogPipeline;
-import org.lcsim.hps.recon.tracking.HPSDataProcessingModule; -import org.lcsim.hps.recon.tracking.HPSRTM;
import org.lcsim.hps.recon.tracking.SvtUtils; import org.lcsim.hps.util.ClockSingleton;
@@ -48,7 +46,7 @@
* Class used to Readout HPS APV25's * * @author Omar Moreno <[log in to unmask]>
- * @version $Id: HPSSiSensorReadout.java,v 1.11 2012/08/03 00:05:26 meeg Exp $
+ * @version $Id: HPSSiSensorReadout.java,v 1.12 2013/03/15 21:05:28 meeg Exp $
*/ public class HPSSiSensorReadout extends Driver {
diff -N HPSTrigger.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSTrigger.java 15 Mar 2013 21:05:28 -0000 1.1 @@ -0,0 +1,84 @@
+ +package org.lcsim.hps.util; + +//--- Java ---// +import java.util.ArrayList; +import java.util.List; + + +//--- org.lcsim ---// +import org.lcsim.event.EventHeader; + +//--- hps-java ---// +//import org.lcsim.hps.users.omoreno.tracking.HPSAPV25; +import org.lcsim.util.Driver; + + +/** + * Receives the ECal trigger signal and applies a trigger latency before + * sending the signal to other HPS detectors. A trigger signal is only + * accepted once within every trigger window. + * Note: Currently, only the SVT is supported + * + * @author Omar Moreno + * @version $Id: HPSTrigger.java,v 1.1 2013/03/15 21:05:28 meeg Exp $ + */ +public class HPSTrigger extends Driver { + + // Stores the trigger time stamp shifted by the trigger latency + public static final List<Double> trigger = new ArrayList<Double>(); + + // Once the trigger latency is set, it should not change + public static final double triggerLatency = 80.0; // ns + + // Trigger decision window + public static final double triggerWindow = 16.0; // ns + public static boolean triggerWindowBit = false; + + /** + * Constructor + */ + public HPSTrigger( ){ }; + + /** + * Add a trigger signal to the queue + * + */ + public static void addTrigger( ) + { + + // Only accept a single trigger within a given trigger window + if( !triggerWindowBit ){ + trigger.add( ClockSingleton.getTime() + triggerLatency ); + triggerWindowBit = true; + } + } + + /** + * Checks if there has been a trigger signal sent on a event + * by event basis. If a trigger signal has been sent and its + * timestamp, after applying the trigger latency, matches the + * system time, a trigger signal is sent to all HPS detectors. + * + */ + @Override + public void process( EventHeader event ) + { + super.process(event); + + // Only accept a single trigger for a given trigger window + if( ClockSingleton.getTime()%triggerWindow == 0 ) + triggerWindowBit = false; + + // Check if there are any pending triggers + if( !( trigger.isEmpty() ) ){ + if( ClockSingleton.getTime() == trigger.get( 0 ) ){ + + // Send a trigger signal to the SVT + System.out.println( "System has been triggered." ); +// HPSAPV25._trigger_bit = true; + trigger.remove( 0 ); + } + } + } +}
diff -N SiTrackerFixedTargetSensorSetup.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ SiTrackerFixedTargetSensorSetup.java 15 Mar 2013 21:05:28 -0000 1.1 @@ -0,0 +1,131 @@
+package org.lcsim.hps.recon.tracking; + +import hep.physics.matrix.BasicMatrix; +import hep.physics.vec.BasicHep3Vector; +import hep.physics.vec.VecOp; + +import java.util.List; + +import org.lcsim.detector.IDetectorElement; +import org.lcsim.detector.IRotation3D; +import org.lcsim.detector.ITranslation3D; +import org.lcsim.detector.RotationPassiveXYZ; +import org.lcsim.detector.Transform3D; +import org.lcsim.detector.Translation3D; +import org.lcsim.detector.solids.Polygon3D; +import org.lcsim.detector.solids.Trd; +import org.lcsim.detector.tracker.silicon.ChargeCarrier; +import org.lcsim.detector.tracker.silicon.SiSensor; +import org.lcsim.detector.tracker.silicon.SiSensorElectrodes; +import org.lcsim.detector.tracker.silicon.SiStrips; +import org.lcsim.geometry.Detector; +import org.lcsim.geometry.compact.Subdetector; +import org.lcsim.geometry.subdetector.SiTrackerFixedTarget2; +import org.lcsim.util.Driver; + +public class SiTrackerFixedTargetSensorSetup extends Driver { + + String subdetectorName; + + public SiTrackerFixedTargetSensorSetup() { + } + + public SiTrackerFixedTargetSensorSetup(String subdetectorName) { + this.subdetectorName = subdetectorName; + } + + public void setSubdetectorName(String subdetectorName) { + this.subdetectorName = subdetectorName; + } + + public void detectorChanged(Detector detector) { + if (subdetectorName == null) { + throw new RuntimeException("The subdetectorName was not set."); + } + + Subdetector subdetector = detector.getSubdetector(subdetectorName); + if (subdetector instanceof SiTrackerFixedTarget2) { + setupSensorDetectorElements(subdetector); + } else { + throw new RuntimeException("The subdetector " + subdetectorName + " is not an instance of SiTrackerFixedTarget2."); + } + } + + private void setupSensorDetectorElements(Subdetector subdet) { + System.out.println(this.getClass().getCanonicalName() + " - Setting up sensors for " + subdet.getName() + " ..."); + + for (IDetectorElement endcap : subdet.getDetectorElement().getChildren()) { + for (IDetectorElement layer : endcap.getChildren()) { + //int nwedges = layer.getChildren().size(); + for (IDetectorElement wedge : layer.getChildren()) { + for (IDetectorElement module : wedge.getChildren()) { + List<SiSensor> sensors = module.findDescendants(SiSensor.class); + + if (sensors.size() == 0) { + throw new RuntimeException("No sensors found in module."); + } + + //int sensorId = 0; + for (SiSensor sensor : sensors) { + Trd sensor_solid = (Trd) sensor.getGeometry().getLogicalVolume().getSolid(); + + Polygon3D n_side = sensor_solid.getFacesNormalTo(new BasicHep3Vector(0, -1, 0)).get(0); + Polygon3D p_side = sensor_solid.getFacesNormalTo(new BasicHep3Vector(0, 1, 0)).get(0); + + // Bias the sensor +// sensor.setBiasSurface(ChargeCarrier.ELECTRON, p_side); +// sensor.setBiasSurface(ChargeCarrier.HOLE, n_side); + + sensor.setBiasSurface(ChargeCarrier.HOLE, p_side); + sensor.setBiasSurface(ChargeCarrier.ELECTRON, n_side); + +// double strip_angle = Math.atan2(sensor_solid.getXHalfLength2() - sensor_solid.getXHalfLength1(), sensor_solid.getZHalfLength() * 2); + double strip_angle = 0.00; + ITranslation3D electrodes_position = new Translation3D(VecOp.mult(-p_side.getDistance(), new BasicHep3Vector(0, 0, 1))); // translate to outside of polygon + //ITranslation3D electrodes_position = new Translation3D(VecOp.mult(n_side.getDistance(), new BasicHep3Vector(0, 0, 1))); // translate to outside of polygon + + IRotation3D electrodes_rotation = new RotationPassiveXYZ(-Math.PI / 2, 0, strip_angle); + Transform3D electrodes_transform = new Transform3D(electrodes_position, electrodes_rotation); + + // Free calculation of readout electrodes, sense electrodes determined thereon + SiStrips readout_electrodes = new SiStrips(ChargeCarrier.HOLE, 0.060, sensor, electrodes_transform); + SiStrips sense_electrodes = new SiStrips(ChargeCarrier.HOLE,0.030,(readout_electrodes.getNCells()*2-1),sensor,electrodes_transform); + +// SiStrips readout_electrodes = new SiStrips(ChargeCarrier.ELECTRON, 0.060, sensor, electrodes_transform); +// SiStrips sense_electrodes = new SiStrips(ChargeCarrier.ELECTRON, 0.030, (readout_electrodes.getNCells() * 2 - 1), sensor, electrodes_transform); + + // SiSensorElectrodes sense_electrodes = new SiStrips(ChargeCarrier.HOLE, 0.060, sensor, electrodes_transform); + +//pristine conditions +/* + readout_electrodes.setCapacitanceIntercept(0); + readout_electrodes.setCapacitanceSlope(0.12); + sense_electrodes.setCapacitanceIntercept(0); + sense_electrodes.setCapacitanceSlope(0.12); +*/ + + readout_electrodes.setCapacitanceIntercept(0); + readout_electrodes.setCapacitanceSlope(0.16); + sense_electrodes.setCapacitanceIntercept(0); + sense_electrodes.setCapacitanceSlope(0.16); + + sensor.setSenseElectrodes(sense_electrodes); + sensor.setReadoutElectrodes(readout_electrodes); +// + +// double[][] transfer_efficiencies = {{1.0}}; + double[][] transfer_efficiencies = {{0.986, 0.419}}; + sensor.setTransferEfficiencies(ChargeCarrier.HOLE, new BasicMatrix(transfer_efficiencies)); +// sensor.setTransferEfficiencies(ChargeCarrier.ELECTRON, new BasicMatrix(transfer_efficiencies)); + // here + + //++sensorId; + } + } + } + } + } + } +} + +
diff -N StripHitsOnTrack.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ StripHitsOnTrack.java 15 Mar 2013 21:05:28 -0000 1.1 @@ -0,0 +1,92 @@
+/* + * TrackReconstructionDriver class + */ +package org.lcsim.hps.recon.tracking; + +import java.util.ArrayList; +import java.util.List; + +import org.lcsim.event.EventHeader; +import org.lcsim.event.LCRelation; +import org.lcsim.event.RelationalTable; +import org.lcsim.event.Track; +import org.lcsim.event.TrackerHit; +import org.lcsim.event.base.BaseRelationalTable; +import org.lcsim.fit.helicaltrack.HelicalTrackHit; +import org.lcsim.recon.tracking.seedtracker.SeedTrack; +import org.lcsim.util.Driver; +import org.lcsim.util.aida.AIDA; + +/** + * Driver to perform hit digitization and track reconstruction for the sATLAS detector + * + * @author M. Graham and R. Partridge + */ +public class StripHitsOnTrack extends Driver { + + private AIDA aida = AIDA.defaultInstance(); + List<Integer> passLayers = new ArrayList(); + + public StripHitsOnTrack() { + } + + + public void process( + EventHeader event) { + + List<Track> tracklist = event.get(Track.class, "MatchedTracks"); + List<HelicalTrackHit> hthits = event.get(HelicalTrackHit.class, "HelicalTrackHits"); + List<LCRelation> mcrelations = event.get(LCRelation.class, "HelicalTrackMCRelations"); + List<LCRelation> availablemcrelations = new ArrayList<LCRelation>(); + List<HelicalTrackHit> availablehits = new ArrayList<HelicalTrackHit>(); + List<HelicalTrackHit> hitsOnTracks = new ArrayList<HelicalTrackHit>(); + + RelationalTable hittomc = new BaseRelationalTable(RelationalTable.Mode.MANY_TO_MANY, RelationalTable.Weighting.UNWEIGHTED); + + + for (LCRelation relation : mcrelations) + if (relation != null&&relation.getFrom()!=null&&relation.getTo()!=null) + hittomc.add(relation.getFrom(), relation.getTo()); + + + int totaxontrack = 0; + int tothth = hthits.size(); + int toththontrack = 0; + for (Track track : tracklist) { + SeedTrack st = (SeedTrack) track; + List<TrackerHit> trackhits = st.getTrackerHits(); + for (TrackerHit th : trackhits) { + hitsOnTracks.add((HelicalTrackHit) th); + } + } + for (HelicalTrackHit hit : hthits) { + if (!(hitsOnTracks.contains(hit)) || keepHit(hit))// see if there is an overlap of raw hits in the helical track hit... + if (!availablehits.contains(hit)) { //only add if it's not already in the collection + for (LCRelation relation : mcrelations) { + if (relation.getFrom() == hit) + availablemcrelations.add(relation); + if (relation.getTo() == hit) + availablemcrelations.add(relation); + } + availablehits.add(hit); + } + } + +// System.out.println("Total axial hits = " + totax + "; total associated axial hits = " + totaxontrack); +// System.out.println("Total HelicalTrackHits = " + tothth+ "; total associated HelicalTrackHits = " + matchedhits.size()); + + event.put("RemainingHits", availablehits, HelicalTrackHit.class, 0); + //event.put("MatchedHTRelations", hitrelations, LCRelation.class, 0); + event.put("RemainingMCRelations", availablemcrelations, LCRelation.class, 0); + } + + public void setLayersToKeep(Integer layer) { + passLayers.add(layer); + } + + private boolean keepHit(HelicalTrackHit raw) { + for (Integer keep : passLayers) + if (raw.Layer() == keep) return true; + return false; + } +}
diff -N HPSSVTHitDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSSVTHitDriver.java 15 Mar 2013 21:05:28 -0000 1.1 @@ -0,0 +1,160 @@
+ +package org.lcsim.hps.recon.tracking; + + +//--- 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.tracker.silicon.SiSensor; +import org.lcsim.detector.tracker.silicon.SiTrackerModule; +import org.lcsim.event.EventHeader; +import org.lcsim.event.RawTrackerHit; +import org.lcsim.geometry.Detector; +import org.lcsim.recon.tracking.digitization.sisim.CDFSiSensorSim; +import org.lcsim.util.Driver; + + +//--- hps-java ---// +import org.lcsim.hps.util.ClockSingleton; +import org.lcsim.recon.tracking.digitization.sisim.config.SimTrackerHitReadoutDriver; +import org.lcsim.hps.recon.tracking.apv25.HPSSiSensorReadout; +import org.lcsim.hps.recon.tracking.apv25.HPSAPV25; +import org.lcsim.recon.tracking.digitization.sisim.NearestNeighborRMS; +import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHit; +import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitStrip1D; +import org.lcsim.recon.tracking.digitization.sisim.StripHitMaker; + +/** + * + * @author Omar Moreno <[log in to unmask]> + * @version $Id: HPSSVTHitDriver.java,v 1.1 2013/03/15 21:05:28 meeg Exp $ + */ +public class HPSSVTHitDriver extends Driver { + + +// HPSStripHitMaker stripClusterer; + + // + 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() + { + + CDFSiSensorSim stripSimulation = new CDFSiSensorSim(); + +// HPSNearestNeighborRMS stripClustering = new HPSNearestNeighborRMS(); + +// stripClustering.setSeedThreshold(278*4); +// stripClustering.setNeighborThreshold(278*3); +// stripClustering.setClusterThreshold(4); +// +// stripClusterer = new HPSStripHitMaker(stripSimulation, stripClustering); +// +// stripClusterer.setMaxClusterSize(10); +// stripClusterer.setCentralStripAveragingThreshold(4); +// +// double multiplier = 1.0; +// stripClusterer.SetOneClusterErr(multiplier/Math.sqrt(12)); +// stripClusterer.SetTwoClusterErr(multiplier/5); +// stripClusterer.SetThreeClusterErr(multiplier/3); +// stripClusterer.SetFourClusterErr(multiplier/2); +// stripClusterer.SetFiveClusterErr(multiplier/1); + + } + + /** + * 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); + + List<RawTrackerHit> rawHits = (List<RawTrackerHit>) event.get("RawTrackerHits"); + List<SiTrackerHit> hitsStrip1D = new ArrayList<SiTrackerHit>(); + + if(rawHits.size() > 0) System.out.println("It worked!"); + +// for(SiSensor sensor: processSensors){ +// hitsStrip1D.addAll(stripClusterer.makeHits(sensor)); +// +// } + + + if(hitsStrip1D.size() > 0){ + System.out.println(this.getClass().getName() + ": The Number of Clusters Found: " + hitsStrip1D.size()); + } + + event.put("_SiTrackerHitStrip1D",hitsStrip1D, SiTrackerHitStrip1D.class, 0, toString()); + } + + public String getStripHits1DName(){ + return "_SiTrackerHitStrip1D"; + } +}
diff -N MakeSensorsDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ MakeSensorsDriver.java 15 Mar 2013 21:05:28 -0000 1.1 @@ -0,0 +1,18 @@
+/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.lcsim.hps.recon.tracking; + +import org.lcsim.util.Driver; + +/** + * + * @author mgraham + */ +public class MakeSensorsDriver extends Driver { + + public MakeSensorsDriver() { + add(new SiTrackerFixedTargetSensorSetup("Tracker")); + } +}
diff -N HeavyPhotonLLDriver_2.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HeavyPhotonLLDriver_2.java 15 Mar 2013 21:05:28 -0000 1.1 @@ -0,0 +1,231 @@
+package org.lcsim.hps.users.mgraham.jlabrotation; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.lcsim.hps.event.HPSTransformations; +import org.lcsim.hps.recon.tracking.HelicalTrackHitDriver; +import org.lcsim.hps.recon.tracking.HPSTrackerHitDriver; +import org.lcsim.hps.recon.tracking.MakeSensorsDriver; + +import org.lcsim.hps.recon.tracking.SiTrackerSpectrometerSensorSetup; +import org.lcsim.recon.tracking.seedtracker.SeedStrategy; +import org.lcsim.recon.tracking.seedtracker.SeedTracker; +import org.lcsim.recon.tracking.seedtracker.StrategyXMLUtils; +import org.lcsim.recon.tracking.seedtracker.diagnostic.SeedTrackerDiagnostics; +import org.lcsim.util.Driver; +import org.lcsim.util.loop.LCIODriver; + +/** + * Driver for track reconstruction and analysis of HPS detector. + * + * @author M. Graham and R. Partridge + */ +public final class HeavyPhotonLLDriver extends Driver { + + //******************** + // set pname to the detector you want to run...HPS1pt8 is the default test detector (uses strategy file 1.3) + // see "setPName" method for list +// public String pName = "HPS1pt9"; + public String pName = "HPS1pt8"; +// JasAnalysisDriver jad; + DetailedAnalysisDriver dad; +// FastTrackAnalysisDriver ftad; +// KalmanFilterDriver kfd; + List<int[]> pairs = new ArrayList(); + List<Integer> passLayers = new ArrayList(); + //// Change the prefix for your site +// String strategyPrefix = "/nfs/sulky21/g.ec.u12/users/mgraham/AtlasUpgrade/hps-java/src/main/resources/"; + String strategyPrefix = "/Users/mgraham/NetBeansProjects/hps-java/src/main/resources/"; + //////////////////////////////////////// + // everything below will + // get overwritten by setPName + int nlayers = 10; + int fitlayers = 10; + // bfield needs to be set because tracking doesn't + // seme to deal with fields in the negative + // z-direction well (need to fix this) + double bfield = 0.5; + String detType = "Full"; + String axialStrategy = "HPS-Test-1pt8.xml"; + String finalStrategy = "HPS-Test-1pt8.xml"; + String llStrategy = "HPS-Test-1pt8.xml"; + public String outputFile = "foobar.slcio"; + public String plotsFile = "myplots.aida"; + public String outputTextName = "myevents.txt"; + /////////////// + + public HeavyPhotonLLDriver() { +// add(new MakeSensorsDriver()); + add(new SiTrackerSpectrometerSensorSetup("Tracker")); + setPName(pName); + + HPSTrackerHitDriver thd = new HPSTrackerHitDriver(); + add(thd); + + HelicalTrackHitDriver hthdriver = new HelicalTrackHitDriver(); + hthdriver.addCollection(((HPSTrackerHitDriver) thd).getStripHits1DName()); + hthdriver.setOutputCollectionName("HelicalTrackHits"); + hthdriver.HitRelationName("HelicalTrackHitRelations"); + hthdriver.MCRelationName("HelicalTrackMCRelations"); + for (int[] pair : pairs) + hthdriver.setStereoPair("Tracker", pair[0], pair[1]); + + if (detType.contains("Test")) { + System.out.println("Setting separation for a Test detector"); + hthdriver.setMaxSeperation(10.01); + hthdriver.setTolerance(0.01); + } else { + + hthdriver.setMaxSeperation(50.); + hthdriver.setTolerance(0.4); + } + hthdriver.setTransformToTracking(true); + add(hthdriver); + + List<SeedStrategy> sFinallist = StrategyXMLUtils.getStrategyListFromFile(new File(strategyPrefix + finalStrategy)); + SeedTracker stFinal = null; + stFinal = new SeedTracker(sFinallist); + + HPSTransformations hpstrans = new HPSTransformations(); + stFinal.setMaterialManagerTransform(hpstrans.getTransform()); + stFinal.setInputCollectionName("RotatedHelicalTrackHits"); + +// stFinal.setInputCollectionName("HelicalTrackHits"); + + stFinal.setTrkCollectionName("MatchedTracks"); + stFinal.setDiagnostics(new SeedTrackerDiagnostics()); + stFinal.setBField(bfield); + stFinal.setSectorParams(false); + stFinal.setTimingPlots(true); + + + + add(stFinal); + +// MultiTrackReco trd = new MultiTrackReco(strategyPrefix, detType, bfield, axialStrategy, finalStrategy, llStrategy, pairs, passLayers); +// add(trd); + + dad = new DetailedAnalysisDriver(10); + add(dad); + +// kfd = new KalmanFilterDriver(); +// add(kfd); +// uncomment this to look at occupancies + // add(new OccupancyDriver()); + } + + public void setOutputFile(String outputFile) { + System.out.println("Will output events to " + outputFile); + add(new LCIODriver(outputFile)); + } + + public void setPlotsFile(String plotsFile) { + System.out.println("Will output plots to " + plotsFile); +// jad.setOutputPlots(plotsFile); + } + + public void setOutputTextName(String outputTextName) { + System.out.println("Will output selected events to " + outputTextName); +// ftad.setOutputText(outputTextName); + } + + public void setPName(String pName) { + System.out.println("Setting parameter set to " + pName); + pairs.clear(); + if (pName.contentEquals("HPS3pt2")) { + detType = "Full"; + bfield = 1.0; + nlayers = 12; + fitlayers = 10; + axialStrategy = "DarkPhoton-Axial-HPS3pt2.xml"; + finalStrategy = "DarkPhoton-HPS3pt2.xml"; + llStrategy = "DarkPhoton-HPS3pt2-LongLived.xml"; + + int[] p1 = {1, 2}; + int[] p2 = {3, 4}; + int[] p3 = {5, 6}; + int[] p4 = {7, 8}; + int[] p5 = {9, 10}; + int[] p6 = {11, 12}; + pairs.add(p1); + pairs.add(p2); + pairs.add(p3); + pairs.add(p4); + pairs.add(p5); + pairs.add(p6); + passLayers.add(11); + } + if (pName.contentEquals("HPS3pt4")) { + detType = "Full"; + bfield = 0.5; + nlayers = 12; + fitlayers = 10; + axialStrategy = "DarkPhoton-Axial-HPS3pt2.xml"; + finalStrategy = "DarkPhoton-HPS3pt2.xml"; + llStrategy = "none"; + + int[] p1 = {1, 2}; + int[] p2 = {3, 4}; + int[] p3 = {5, 6}; + int[] p4 = {7, 8}; + int[] p5 = {9, 10}; + int[] p6 = {11, 12}; + pairs.add(p1); + pairs.add(p2); + pairs.add(p3); + pairs.add(p4); + pairs.add(p5); + pairs.add(p6); + passLayers.add(11); + } + + if (pName.contentEquals("HPS1pt8")) { + detType = "Test"; + nlayers = 10; + bfield = 0.5; + fitlayers = 10; + axialStrategy = "none"; // don't fit tracks axially first + finalStrategy = "HPS-Test-1pt3.xml"; + llStrategy = "none";// don't fit tracks ignoring first plane + + int[] p1 = {1, 2}; + int[] p2 = {3, 4}; + int[] p3 = {5, 6}; + int[] p4 = {7, 8}; + int[] p5 = {9, 10}; + + pairs.add(p1); + pairs.add(p2); + pairs.add(p3); + pairs.add(p4); + pairs.add(p5); +// passLayers.add(11); + } + + if (pName.contentEquals("HPS1pt9")) { + detType = "Test"; + nlayers = 10; + bfield = 0.25; + fitlayers = 10; + axialStrategy = "none"; // don't fit tracks axially first + finalStrategy = "HPS-Test-1pt3.xml"; + llStrategy = "none";// don't fit tracks ignoring first plane + + int[] p1 = {1, 2}; + int[] p2 = {3, 4}; + int[] p3 = {5, 6}; + int[] p4 = {7, 8}; + int[] p5 = {9, 10}; + + pairs.add(p1); + pairs.add(p2); + pairs.add(p3); + pairs.add(p4); + pairs.add(p5); +// passLayers.add(11); + } + + } +}
diff -N OccupancyDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ OccupancyDriver.java 15 Mar 2013 21:05:28 -0000 1.1 @@ -0,0 +1,305 @@
+/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.lcsim.hps.recon.tracking; + +import java.io.IOException; +import hep.aida.IHistogramFactory; +import hep.aida.IProfile1D; +import hep.physics.vec.Hep3Vector; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import java.util.Set; +import org.lcsim.detector.IDetectorElement; +import org.lcsim.detector.IReadout; +import org.lcsim.detector.identifier.IIdentifier; +import org.lcsim.detector.tracker.silicon.ChargeCarrier; +import org.lcsim.detector.tracker.silicon.SiSensor; +import org.lcsim.detector.tracker.silicon.SiSensorElectrodes; +import org.lcsim.detector.tracker.silicon.SiStrips; +import org.lcsim.detector.tracker.silicon.SiTrackerIdentifierHelper; +import org.lcsim.event.EventHeader; +import org.lcsim.event.MCParticle; +import org.lcsim.event.RawTrackerHit; +import org.lcsim.event.SimTrackerHit; +import org.lcsim.geometry.Detector; +import org.lcsim.recon.tracking.digitization.sisim.GenericReadoutChip; +import org.lcsim.recon.tracking.digitization.sisim.ReadoutChip; +import org.lcsim.util.Driver; +import org.lcsim.util.aida.AIDA; + +/** + * + * @author partridge + */ +public class OccupancyDriver extends Driver { + + private AIDA aida = AIDA.defaultInstance(); + private IHistogramFactory _hf; + List<String> _process_paths = new ArrayList<String>(); + List<IDetectorElement> _process_de = new ArrayList<IDetectorElement>(); + Set<SiSensor> _process_sensors = new HashSet<SiSensor>(); + public String outputPlots = "myOccupancyPlots.aida"; + Map<String, IProfile1D> occMap = new HashMap<String, IProfile1D>(); + int nevt = 0; + + public OccupancyDriver() { + + // Specify the detectors to process + _process_paths.add("Tracker"); + + // Define the efficiency histograms + _hf = aida.histogramFactory(); + } + + + public void process( + EventHeader event) { + String dir = "DigiOccupancy/"; + // Increment the event counter + nevt++; + +// System.out.println("B: " + event.getDetector().getFieldMap().getField(new BasicHep3Vector(0., 0., 0.))); + + ReadoutChip chip = new GenericReadoutChip(); + + int hittot = 0; + for (SiSensor sensor : _process_sensors) { + + SiSensorElectrodes electrodes = sensor.getReadoutElectrodes(ChargeCarrier.HOLE); +// SiSensorElectrodes electrodes = sensor.getReadoutElectrodes(ChargeCarrier.ELECTRON); +// if (sensor.hasPixels()) { +// System.out.println("Found some pixels"); +// electrodes = sensor.getReadoutElectrodes(ChargeCarrier.ELECTRON); + // } else { +// System.out.println("...got strips"); + // } + SiTrackerIdentifierHelper _sid_helper = (SiTrackerIdentifierHelper) sensor.getIdentifierHelper(); + + int nchan = electrodes.getNCells(); + + IReadout readout = sensor.getReadout(); + + List<RawTrackerHit> raw_hits = readout.getHits(RawTrackerHit.class); + + + + + String layer = sensor.getName().substring(8, 15); + + double nstrips = 1; //number of strips per step + double nstripsz = 1; //number of strips per step + int nbins = 1000; + double pitch=0.06; + double[] occVsY = new double[nbins]; + double[] occVsZ = new double[nbins]; + double miny = -nbins*pitch/2; + double maxy = nbins*pitch/2; + double minz = -nbins*pitch/2; + double maxz = nbins*pitch/2; + double step = (maxy - miny) / nbins; +// double nstrips=step/0.06; //number of strips per step + + double stepz = (maxz - minz) / nbins; +// double nstripsz=stepz/0.06; //number of strips per step + + + for (RawTrackerHit raw_hit : raw_hits) { + IIdentifier id = raw_hit.getIdentifier(); + Integer strip_id = _sid_helper.getElectrodeValue(id); + Hep3Vector local_pos = ((SiStrips) electrodes).getStripCenter(strip_id); + electrodes.getParentToLocal().inverse().transform(local_pos); + Hep3Vector global_pos = ((SiSensor) electrodes.getDetectorElement()).getGeometry().getLocalToGlobal().transformed(local_pos); + double ypos = global_pos.y(); + double zpos = global_pos.z(); + //System.out.println("ypos="+ypos+";zpos="+zpos); + if (ypos < maxy && ypos > miny) { +// System.out.println("Putting hit into occVsY"); + int bin = (int) ((ypos - miny) / step); + occVsY[bin]++; + } + if (zpos < maxz && zpos > minz) { +// System.out.println("Putting hit into occVsY"); + int bin = (int) ((zpos - minz) / stepz); + occVsZ[bin]++; + } + } + + String occvsyID = layer + " Occupancy vs y -- Near Beam"; + if (!occMap.containsKey(occvsyID)) + occMap.put(occvsyID, _hf.createProfile1D(occvsyID, nbins, miny, maxy)); + + String occvsyIDZ = layer + " Occupancy vs z -- Near Beam"; + if (!occMap.containsKey(occvsyIDZ)) + occMap.put(occvsyIDZ, _hf.createProfile1D(occvsyIDZ, nbins, minz, maxz)); + + for (int i = 0; i < nbins; i++) { + double binVal = step * i + miny + step / 2; + occMap.get(occvsyID).fill(binVal, occVsY[i] / nstrips); + + } + + for (int i = 0; i < nbins; i++) { + double binVal = stepz * i + minz + stepz / 2; + occMap.get(occvsyIDZ).fill(binVal, occVsZ[i] / nstripsz); + + } + + int nhits = raw_hits.size(); + hittot += nhits; + Set<SimTrackerHit> simhits = new HashSet<SimTrackerHit>(); + + /* + for (RawTrackerHit hit : raw_hits) { + double charge = chip.decodeCharge(hit); + aida.histogram1D("Hit charge", 100, 0., 100000.).fill(charge); + aida.cloud1D("Number of SimTrackerHits per raw hit").fill(hit.getSimTrackerHits().size()); + double energy = 0.; + for (SimTrackerHit shit : hit.getSimTrackerHits()) { + simhits.add(shit); + energy += 1000 * shit.getdEdx(); + } + aida.histogram1D("SimTrackerHit energy", 100, 0., 10.).fill(energy); + // aida.cloud2D("charge vs SimTrackerHit energy").fill(charge, energy); + } + */ + double occ = ((double) nhits) / ((double) nchan); +// double occ = ((double) nhits) / ((double) nchan); +// if (nhits > 0) { +// System.out.println("sensor " + sensor.getName() + " has nhits: " + nhits + " nchan: " + nchan + " occ: " + occ); +// } else { +// System.out.println("sensor " + sensor.getName() + " is empty "); +// } + + Hep3Vector pos = sensor.getGeometry().getPosition(); + + double x = pos.x(); + double y = pos.y(); + double z = pos.z(); + double r = Math.sqrt(x * x + y * y); + int xi = 2 * ((int) Math.round(x / 20)); + int zi = 2 * ((int) Math.round(Math.abs(z) / 20)); + aida.cloud1D("Sensor Occupancy").fill(occ); + +// if (!barrel) { +// continue; +// } +// String layer = sensor.getName().substring(8, 15); + aida.cloud1D(layer + " Occupancy").fill(occ); + if (y >= 0) + aida.cloud1D(layer + " Occupancy--positive y").fill(occ); + else + aida.cloud1D(layer + " Occupancy--negative y").fill(occ); + + + String identifier; + String identifier2; + String identifier3; + + //incredibly kludgy way to get the radii/z positions to display the way I want + + identifier = "Occupancy vs X"; + identifier2 = layer + " Occupancy vs y"; + identifier3 = layer + " Occupancy vs z"; + + //create the histograms if they are not already there... + if (!occMap.containsKey(identifier)) + occMap.put(identifier, _hf.createProfile1D(identifier, 120, 0., 120.)); + if (!occMap.containsKey(identifier2)) { + + occMap.put(identifier2, _hf.createProfile1D(identifier2, 24, -12., 12.)); + occMap.put(identifier3, _hf.createProfile1D(identifier3, 24, -12, 12.)); + + } + + + occMap.get(identifier).fill(x / 10, occ); + occMap.get(identifier2).fill(y / 10, occ); + occMap.get(identifier3).fill(z / 10, occ); + + } + +// System.out.println("Total number of hit channels: " + hittot); + /* + List<List<SimTrackerHit>> simall = + (List<List<SimTrackerHit>>) event.get(SimTrackerHit.class); + + for (List<SimTrackerHit> simcol : simall) { + for (SimTrackerHit hit : simcol) { + IDetectorElement de = hit.getDetectorElement(); + Hep3Vector pos = hit.getPositionVec(); + double x = pos.x(); + double y = pos.y(); + double z = pos.z(); + double r = Math.sqrt(x * x + y * y); + Hep3Vector p = hit.getMCParticle().getMomentum(); + double px = p.x(); + double py = p.y(); + double pz = p.z(); + double pr = Math.sqrt(px * px + py * py); + double eta = -Math.log(Math.tan(0.5 * Math.atan2(pr, pz))); + String detname = hit.getSubdetector().getName(); + int layer = hit.getLayer(); + aida.histogram1D("MC eta for Layer " + detname + layer, 50, -2.5, 2.5).fill(eta); + aida.histogram1D("SimTracker Hi z for Layer " + detname + layer, 50, -120., 120.).fill(z / 10); + // de. + } + } + + for (MCParticle mcp : event.getMCParticles()) { + if (mcp.getCharge() == 0) continue; + Hep3Vector p = mcp.getMomentum(); + double px = p.x(); + double py = p.y(); + double pz = p.z(); + double pr = Math.sqrt(px * px + py * py); + double eta = -Math.log(Math.tan(0.5 * Math.atan2(pr, pz))); + if (mcp.getGeneratorStatus() == mcp.FINAL_STATE) { + aida.histogram1D("MCP eta - final state",50,-2.5, 2.5).fill(eta); + } + if (mcp.getSimulatorStatus().isCreatedInSimulation()) { + aida.histogram1D("MCP eta - created in simulation",50, -2.5, 2.5).fill(eta); + } + } + */ + return; + } + + + public void endOfData() { + try { + aida.saveAs(outputPlots); + } catch (IOException ex) { +// Logger.getLogger(TrackAnalysisDriver.class.getName()).log(Level.SEVERE, null, ex); + } + } + + public void setOutputPlots(String output) { + this.outputPlots = output; + + } + + public void detectorChanged(Detector detector) { + System.out.println("In Occupancy Driver : " + detector.getName()); + super.detectorChanged(detector); + + // Process detectors specified by path, otherwise process entire detector + IDetectorElement detector_de = detector.getDetectorElement(); + System.out.println("In Occupancy Driver : detector_de = " + detector_de.getName()); + for (String de_path : _process_paths) + _process_de.add(detector_de.findDetectorElement(de_path)); + + if (_process_de.size() == 0) + _process_de.add(detector_de); + + for (IDetectorElement detector_element : _process_de) + _process_sensors.addAll(detector_element.findDescendants(SiSensor.class)); + + } +}
\ No newline at end of file
diff -N HeavyPhotonLLDriver_1.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HeavyPhotonLLDriver_1.java 15 Mar 2013 21:05:28 -0000 1.1 @@ -0,0 +1,180 @@
+package org.lcsim.hps.users.mgraham; + +import java.util.ArrayList; +import java.util.List; + +import org.lcsim.hps.recon.tracking.MakeSensorsDriver; +import org.lcsim.hps.recon.tracking.MultiTrackReco; +import org.lcsim.util.Driver; +import org.lcsim.util.loop.LCIODriver; + +/** + * Driver for track reconstruction and analysis of HPS detector. + * + * @author M. Graham and R. Partridge + */ +public final class HeavyPhotonLLDriver extends Driver { + + //******************** + // set pname to the detector you want to run...HPS1pt8 is the default test detector (uses strategy file 1.3) + // see "setPName" method for list +// public String pName = "HPS1pt9"; + public String pName = "HPS3pt4"; + JasAnalysisDriver jad; + DetailedAnalysisDriver dad; + FastTrackAnalysisDriver ftad; + KalmanFilterDriver kfd; + List<int[]> pairs = new ArrayList(); + List<Integer> passLayers = new ArrayList(); + //// Change the prefix for your site +// String strategyPrefix = "/nfs/sulky21/g.ec.u12/users/mgraham/AtlasUpgrade/hps-java/src/main/resources/"; + String strategyPrefix = "/Users/mgraham/NetBeansProjects/hps-java/src/main/resources/"; + //////////////////////////////////////// + // everything below will + // get overwritten by setPName + int nlayers = 10; + int fitlayers = 10; + // bfield needs to be set because tracking doesn't + // seme to deal with fields in the negative + // z-direction well (need to fix this) + double bfield = 0.5; + String detType = "Full"; + String axialStrategy = "HPS-Test-1pt8.xml"; + String finalStrategy = "HPS-Test-1pt8.xml"; + String llStrategy = "HPS-Test-1pt8.xml"; + public String outputFile = "foobar.slcio"; + public String plotsFile = "myplots.aida"; + public String outputTextName = "myevents.txt"; + /////////////// + + public HeavyPhotonLLDriver() { + add(new MakeSensorsDriver()); + + setPName(pName); + + MultiTrackReco trd = new MultiTrackReco(strategyPrefix, detType, bfield, axialStrategy, finalStrategy, llStrategy, pairs, passLayers); + add(trd); + + + + + kfd = new KalmanFilterDriver(); + + add(kfd); +// uncomment this to look at occupancies + // add(new OccupancyDriver()); + } + + public void setOutputFile(String outputFile) { + System.out.println("Will output events to " + outputFile); + add(new LCIODriver(outputFile)); + } + + public void setPlotsFile(String plotsFile) { + System.out.println("Will output plots to " + plotsFile); + jad.setOutputPlots(plotsFile); + } + + public void setOutputTextName(String outputTextName) { + System.out.println("Will output selected events to " + outputTextName); + ftad.setOutputText(outputTextName); + } + + public void setPName(String pName) { + System.out.println("Setting parameter set to " + pName); + pairs.clear(); + if (pName.contentEquals("HPS3pt2")) { + detType = "Full"; + bfield = 1.0; + nlayers = 12; + fitlayers=10; + axialStrategy = "DarkPhoton-Axial-HPS3pt2.xml"; + finalStrategy = "DarkPhoton-HPS3pt2.xml"; + llStrategy = "DarkPhoton-HPS3pt2-LongLived.xml"; + + int[] p1 = {1, 2}; + int[] p2 = {3, 4}; + int[] p3 = {5, 6}; + int[] p4 = {7, 8}; + int[] p5 = {9, 10}; + int[] p6 = {11, 12}; + pairs.add(p1); + pairs.add(p2); + pairs.add(p3); + pairs.add(p4); + pairs.add(p5); + pairs.add(p6); + passLayers.add(11); + } + if (pName.contentEquals("HPS3pt4")) { + detType = "Full"; + bfield = 0.5; + nlayers = 12; + fitlayers=10; + axialStrategy = "DarkPhoton-Axial-HPS3pt2.xml"; + finalStrategy = "DarkPhoton-HPS3pt2.xml"; + llStrategy = "none"; + + int[] p1 = {1, 2}; + int[] p2 = {3, 4}; + int[] p3 = {5, 6}; + int[] p4 = {7, 8}; + int[] p5 = {9, 10}; + int[] p6 = {11, 12}; + pairs.add(p1); + pairs.add(p2); + pairs.add(p3); + pairs.add(p4); + pairs.add(p5); + pairs.add(p6); + passLayers.add(11); + } + + if (pName.contentEquals("HPS1pt8")) { + detType = "Test"; + nlayers = 10; + bfield = 0.5; + fitlayers=10; + axialStrategy = "none"; // don't fit tracks axially first + finalStrategy = "HPS-Test-1pt3.xml"; + llStrategy = "none";// don't fit tracks ignoring first plane + + int[] p1 = {1, 2}; + int[] p2 = {3, 4}; + int[] p3 = {5, 6}; + int[] p4 = {7, 8}; + int[] p5 = {9, 10}; + + pairs.add(p1); + pairs.add(p2); + pairs.add(p3); + pairs.add(p4); + pairs.add(p5); +// passLayers.add(11); + } + + if (pName.contentEquals("HPS1pt9")) { + detType = "Test"; + nlayers = 10; + bfield = 0.25; + fitlayers=10; + axialStrategy = "none"; // don't fit tracks axially first + finalStrategy = "HPS-Test-1pt3.xml"; + llStrategy = "none";// don't fit tracks ignoring first plane + + int[] p1 = {1, 2}; + int[] p2 = {3, 4}; + int[] p3 = {5, 6}; + int[] p4 = {7, 8}; + int[] p5 = {9, 10}; + + pairs.add(p1); + pairs.add(p2); + pairs.add(p3); + pairs.add(p4); + pairs.add(p5); +// passLayers.add(11); + } + + } +}
diff -N SiTrackerSpectrometerSensorSetup.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ SiTrackerSpectrometerSensorSetup.java 15 Mar 2013 21:05:28 -0000 1.1 @@ -0,0 +1,130 @@
+package org.lcsim.hps.recon.tracking; + +import hep.physics.matrix.BasicMatrix; +import hep.physics.vec.BasicHep3Vector; +import hep.physics.vec.VecOp; + +import java.util.List; + +import org.lcsim.detector.IDetectorElement; +import org.lcsim.detector.IRotation3D; +import org.lcsim.detector.ITranslation3D; +import org.lcsim.detector.RotationPassiveXYZ; +import org.lcsim.detector.Transform3D; +import org.lcsim.detector.Translation3D; +import org.lcsim.detector.solids.Polygon3D; +import org.lcsim.detector.solids.Trd; +import org.lcsim.detector.tracker.silicon.ChargeCarrier; +import org.lcsim.detector.tracker.silicon.SiSensor; +import org.lcsim.detector.tracker.silicon.SiStrips; +import org.lcsim.geometry.Detector; +import org.lcsim.geometry.compact.Subdetector; +import org.lcsim.geometry.subdetector.SiTrackerSpectrometer; +import org.lcsim.util.Driver; + +public class SiTrackerSpectrometerSensorSetup extends Driver { + + String subdetectorName; + + public SiTrackerSpectrometerSensorSetup() { + } + + public SiTrackerSpectrometerSensorSetup(String subdetectorName) { + this.subdetectorName = subdetectorName; + } + + public void setSubdetectorName(String subdetectorName) { + this.subdetectorName = subdetectorName; + } + + public void detectorChanged(Detector detector) { + if (subdetectorName == null) { + throw new RuntimeException("The subdetectorName was not set."); + } + + Subdetector subdetector = detector.getSubdetector(subdetectorName); + if (subdetector instanceof SiTrackerSpectrometer) { + setupSensorDetectorElements(subdetector); + } else { + throw new RuntimeException("The subdetector " + subdetectorName + " is not an instance of SiTrackerSpectrometer."); + } + } + + private void setupSensorDetectorElements(Subdetector subdet) { + System.out.println(this.getClass().getCanonicalName() + " - Setting up sensors for " + subdet.getName() + " ..."); + int sensorId = 0; + + for (IDetectorElement endcap : subdet.getDetectorElement().getChildren()) { + for (IDetectorElement layer : endcap.getChildren()) { + //int nwedges = layer.getChildren().size(); + for (IDetectorElement wedge : layer.getChildren()) { + for (IDetectorElement module : wedge.getChildren()) { + List<SiSensor> sensors = module.findDescendants(SiSensor.class); + + if (sensors.size() == 0) { + throw new RuntimeException("No sensors found in module."); + } + + for (SiSensor sensor : sensors) { + Trd sensor_solid = (Trd) sensor.getGeometry().getLogicalVolume().getSolid(); + + Polygon3D n_side = sensor_solid.getFacesNormalTo(new BasicHep3Vector(0, -1, 0)).get(0); + Polygon3D p_side = sensor_solid.getFacesNormalTo(new BasicHep3Vector(0, 1, 0)).get(0); + + // Bias the sensor +// sensor.setBiasSurface(ChargeCarrier.ELECTRON, p_side); +// sensor.setBiasSurface(ChargeCarrier.HOLE, n_side); + + sensor.setBiasSurface(ChargeCarrier.HOLE, p_side); + sensor.setBiasSurface(ChargeCarrier.ELECTRON, n_side); + +// double strip_angle = Math.atan2(sensor_solid.getXHalfLength2() - sensor_solid.getXHalfLength1(), sensor_solid.getZHalfLength() * 2); + double strip_angle = 0.00; + ITranslation3D electrodes_position = new Translation3D(VecOp.mult(-p_side.getDistance(), new BasicHep3Vector(0, 0, 1))); // translate to outside of polygon + //ITranslation3D electrodes_position = new Translation3D(VecOp.mult(n_side.getDistance(), new BasicHep3Vector(0, 0, 1))); // translate to outside of polygon + + IRotation3D electrodes_rotation = new RotationPassiveXYZ(-Math.PI / 2, 0, strip_angle); + Transform3D electrodes_transform = new Transform3D(electrodes_position, electrodes_rotation); + + // Free calculation of readout electrodes, sense electrodes determined thereon + SiStrips readout_electrodes = new SiStrips(ChargeCarrier.HOLE, 0.060, sensor, electrodes_transform); + SiStrips sense_electrodes = new SiStrips(ChargeCarrier.HOLE,0.030,(readout_electrodes.getNCells()*2-1),sensor,electrodes_transform); + +// SiStrips readout_electrodes = new SiStrips(ChargeCarrier.ELECTRON, 0.060, sensor, electrodes_transform); +// SiStrips sense_electrodes = new SiStrips(ChargeCarrier.ELECTRON, 0.030, (readout_electrodes.getNCells() * 2 - 1), sensor, electrodes_transform); + + // SiSensorElectrodes sense_electrodes = new SiStrips(ChargeCarrier.HOLE, 0.060, sensor, electrodes_transform); + +//pristine conditions +/* + readout_electrodes.setCapacitanceIntercept(0); + readout_electrodes.setCapacitanceSlope(0.12); + sense_electrodes.setCapacitanceIntercept(0); + sense_electrodes.setCapacitanceSlope(0.12); +*/ + + readout_electrodes.setCapacitanceIntercept(0); + readout_electrodes.setCapacitanceSlope(0.16); + sense_electrodes.setCapacitanceIntercept(0); + sense_electrodes.setCapacitanceSlope(0.16); + + sensor.setSenseElectrodes(sense_electrodes); + sensor.setReadoutElectrodes(readout_electrodes); +// + +// double[][] transfer_efficiencies = {{1.0}}; + double[][] transfer_efficiencies = {{0.986, 0.419}}; + sensor.setTransferEfficiencies(ChargeCarrier.HOLE, new BasicMatrix(transfer_efficiencies)); +// sensor.setTransferEfficiencies(ChargeCarrier.ELECTRON, new BasicMatrix(transfer_efficiencies)); + // here + + sensor.setSensorID(++sensorId); + } + } + } + } + } + } +} + +
diff -N MultiTrackReco.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ MultiTrackReco.java 15 Mar 2013 21:05:28 -0000 1.1 @@ -0,0 +1,120 @@
+/* + * TrackReconstructionDriver class + */ +package org.lcsim.hps.recon.tracking; + +import java.io.File; +import java.util.List; + +import org.lcsim.recon.tracking.seedtracker.SeedStrategy; +import org.lcsim.recon.tracking.seedtracker.SeedTracker; +import org.lcsim.recon.tracking.seedtracker.StrategyXMLUtils; +import org.lcsim.recon.tracking.seedtracker.diagnostic.SeedTrackerDiagnostics; +import org.lcsim.util.Driver; + +/** + * Driver to perform hit digitization and track reconstruction for the sATLAS detector + * + * @author M. Graham and R. Partridge + */ +public class MultiTrackReco extends Driver { + + public MultiTrackReco(String strategyPrefix, String detType, double bField, String sAxialfile, String sFinalfile, String sLongLived, List<int[]> stereoPairs, List<Integer> passLayers) { +// Digitization and hit making driver for planar sensors + + HPSTrackerHitDriver thd = new HPSTrackerHitDriver(); + add(thd); + + HelicalTrackHitDriver hitdriver = new HelicalTrackHitDriver(); + hitdriver.addCollection(((HPSTrackerHitDriver) thd).getStripHits1DName()); + hitdriver.setOutputCollectionName("AxialTrackHits"); + hitdriver.HitRelationName("AxialTrackHitRelations"); + hitdriver.MCRelationName("AxialTrackMCRelations"); + + + add(hitdriver); + // Tracking code + + // Two step fitting method below... + // 1) fit the track with axial strips only + // 2) pair the xy strips and make all possible space points + // 3) run the ReReconstructoin driver to remove the space points + // which don't have an axial track associated + // 4) run track finding with the remaining points + + + if (!sAxialfile.contentEquals("none")) { + List<SeedStrategy> slist = StrategyXMLUtils.getStrategyListFromFile(new File(strategyPrefix + sAxialfile)); + SeedTracker st = new SeedTracker(slist); + st.setInputCollectionName("AxialTrackHits"); + st.setTrkCollectionName("AxialTracks"); + st.setBField(bField); + st.setTimingPlots(true); +// st.setDiagnostics(new SeedTrackerDiagnostics()); + st.setSectorParams(false); + add(st); + + } + + HelicalTrackHitDriver hthdriver = new HelicalTrackHitDriver(); + hthdriver.addCollection(((HPSTrackerHitDriver) thd).getStripHits1DName()); + hthdriver.setOutputCollectionName("HelicalTrackHits"); + hthdriver.HitRelationName("HelicalTrackHitRelations"); + hthdriver.MCRelationName("HelicalTrackMCRelations"); + + + for (int[] pair : stereoPairs) + hthdriver.setStereoPair("Tracker", pair[0], pair[1]); + + if (detType.contains("Test")) { + System.out.println("Setting separation for a Test detector"); + hthdriver.setMaxSeperation(10.01); + hthdriver.setTolerance(0.01); + } else { + + hthdriver.setMaxSeperation(50.); + hthdriver.setTolerance(0.4); + } + add(hthdriver); + + + if (!sAxialfile.contentEquals("none")) { + ReReconstructionDriver rrd = new ReReconstructionDriver(); + for (Integer pass : passLayers) + rrd.setLayersToKeep(pass); + add(rrd); + } + + List<SeedStrategy> sFinallist = StrategyXMLUtils.getStrategyListFromFile(new File(strategyPrefix + sFinalfile)); + SeedTracker stFinal = null; + stFinal = new SeedTracker(sFinallist); + if (!sAxialfile.contentEquals("none")) { + stFinal.setInputCollectionName("MatchedHTHits"); + stFinal.setTrkCollectionName("MatchedTracks"); + + } else { + stFinal.setInputCollectionName("HelicalTrackHits"); + stFinal.setTrkCollectionName("MatchedTracks"); + } +// stFinal.setDiagnostics(new SeedTrackerDiagnostics()); + stFinal.setBField(bField); + stFinal.setSectorParams(false); + stFinal.setTimingPlots(true); + + add(stFinal); + + if (!sLongLived.contentEquals("none")) { + StripHitsOnTrack shot = new StripHitsOnTrack(); + add(shot); + + List<SeedStrategy> sLLlist = StrategyXMLUtils.getStrategyListFromFile(new File(strategyPrefix + sLongLived)); + + SeedTracker stLL = new SeedTracker(sLLlist); + stLL.setInputCollectionName("RemainingHits"); + stLL.setTrkCollectionName("LLTracks"); + stLL.setTimingPlots(true); + + add(stLL); + } + } +}
diff -N ReReconstructionDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ReReconstructionDriver.java 15 Mar 2013 21:05:28 -0000 1.3 @@ -0,0 +1,100 @@
+/* + * TrackReconstructionDriver class + */ +package org.lcsim.hps.recon.tracking; + +import java.util.ArrayList; +import java.util.List; + +import org.lcsim.event.EventHeader; +import org.lcsim.event.LCRelation; +import org.lcsim.event.RawTrackerHit; +import org.lcsim.event.RelationalTable; +import org.lcsim.event.Track; +import org.lcsim.event.TrackerHit; +import org.lcsim.event.base.BaseRelationalTable; +import org.lcsim.fit.helicaltrack.HelicalTrackHit; +import org.lcsim.recon.tracking.seedtracker.SeedTrack; +import org.lcsim.util.Driver; +import org.lcsim.util.aida.AIDA; + +/** + * Driver to perform hit digitization and track reconstruction for the sATLAS detector + * + * @author M. Graham and R. Partridge + */ +public class ReReconstructionDriver extends Driver { + + private AIDA aida = AIDA.defaultInstance(); + List<Integer> passLayers = new ArrayList(); +// double pcut=5.2; + double pcut=0.95*2.2; + public ReReconstructionDriver() { + } + + + public void process( + EventHeader event) { + + List<Track> tracklist = event.get(Track.class, "AxialTracks"); + List<HelicalTrackHit> hthits = event.get(HelicalTrackHit.class, "HelicalTrackHits"); + List<HelicalTrackHit> axhits = event.get(HelicalTrackHit.class, "AxialTrackHits"); + List<LCRelation> mcrelations = event.get(LCRelation.class, "HelicalTrackMCRelations"); + List<LCRelation> hitrelations = new ArrayList<LCRelation>(); + List<LCRelation> matchedmcrelations = new ArrayList<LCRelation>(); + List<HelicalTrackHit> matchedhits = new ArrayList<HelicalTrackHit>(); + List<RawTrackerHit> axhitsontrack = new ArrayList<RawTrackerHit>(); + + RelationalTable hittomc = new BaseRelationalTable(RelationalTable.Mode.MANY_TO_MANY, RelationalTable.Weighting.UNWEIGHTED); + + for (LCRelation relation : mcrelations) + if (relation != null&&relation.getFrom()!=null&&relation.getTo()!=null) + hittomc.add(relation.getFrom(), relation.getTo()); + int totax = axhits.size(); + int totaxontrack = 0; + int tothth = hthits.size(); + int toththontrack = 0; + for (Track track : tracklist) { + double trMom=track.getPX(); + SeedTrack st = (SeedTrack) track; + List<TrackerHit> trackhits = st.getTrackerHits(); + for (TrackerHit th : trackhits) { + HelicalTrackHit hth = (HelicalTrackHit) th; + List<RawTrackerHit> rawhits = hth.getRawHits(); + totaxontrack += rawhits.size(); + if(trMom<pcut)axhitsontrack.addAll(rawhits); + } + } + for (HelicalTrackHit hit : hthits) { + List<RawTrackerHit> rawhits = hit.getRawHits(); + for (RawTrackerHit rh : rawhits) + if (axhitsontrack.contains(rh) || keepHit(rh))// see if there is an overlap of raw hits in the helical track hit... + if (!matchedhits.contains(hit)) { //only add if it's not already in the collection + for (LCRelation relation : mcrelations) { + if (relation.getFrom() == hit) + matchedmcrelations.add(relation); + if (relation.getTo() == hit) + matchedmcrelations.add(relation); + } + matchedhits.add(hit); + } + } + +// System.out.println("Total axial hits = " + totax + "; total associated axial hits = " + totaxontrack); +// System.out.println("Total HelicalTrackHits = " + tothth+ "; total associated HelicalTrackHits = " + matchedhits.size()); + + event.put("MatchedHTHits", matchedhits, HelicalTrackHit.class, 0); + //event.put("MatchedHTRelations", hitrelations, LCRelation.class, 0); + event.put("MatchedHTMCRelations", matchedmcrelations, LCRelation.class, 0); + } + + public void setLayersToKeep(Integer layer) { + passLayers.add(layer); + } + + private boolean keepHit(RawTrackerHit raw) { + for (Integer keep : passLayers) + if (raw.getLayerNumber() == keep) return true; + return false; + } +}
diff -N HeavyPhotonLLDriver.java --- HeavyPhotonLLDriver.java 1 Jun 2011 17:21:20 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,180 +0,0 @@
-package org.lcsim.hps.users.mgraham; - -import java.util.ArrayList; -import java.util.List; - -import org.lcsim.hps.recon.tracking.MakeSensorsDriver; -import org.lcsim.hps.recon.tracking.MultiTrackReco; -import org.lcsim.util.Driver; -import org.lcsim.util.loop.LCIODriver; - -/** - * Driver for track reconstruction and analysis of HPS detector. - * - * @author M. Graham and R. Partridge - */ -public final class HeavyPhotonLLDriver extends Driver { - - //******************** - // set pname to the detector you want to run...HPS1pt8 is the default test detector (uses strategy file 1.3) - // see "setPName" method for list -// public String pName = "HPS1pt9"; - public String pName = "HPS3pt4"; - JasAnalysisDriver jad; - DetailedAnalysisDriver dad; - FastTrackAnalysisDriver ftad; - KalmanFilterDriver kfd; - List<int[]> pairs = new ArrayList(); - List<Integer> passLayers = new ArrayList(); - //// Change the prefix for your site -// String strategyPrefix = "/nfs/sulky21/g.ec.u12/users/mgraham/AtlasUpgrade/hps-java/src/main/resources/"; - String strategyPrefix = "/Users/mgraham/NetBeansProjects/hps-java/src/main/resources/"; - //////////////////////////////////////// - // everything below will - // get overwritten by setPName - int nlayers = 10; - int fitlayers = 10; - // bfield needs to be set because tracking doesn't - // seme to deal with fields in the negative - // z-direction well (need to fix this) - double bfield = 0.5; - String detType = "Full"; - String axialStrategy = "HPS-Test-1pt8.xml"; - String finalStrategy = "HPS-Test-1pt8.xml"; - String llStrategy = "HPS-Test-1pt8.xml"; - public String outputFile = "foobar.slcio"; - public String plotsFile = "myplots.aida"; - public String outputTextName = "myevents.txt"; - /////////////// - - public HeavyPhotonLLDriver() { - add(new MakeSensorsDriver()); - - setPName(pName); - - MultiTrackReco trd = new MultiTrackReco(strategyPrefix, detType, bfield, axialStrategy, finalStrategy, llStrategy, pairs, passLayers); - add(trd); - - - - - kfd = new KalmanFilterDriver(); - - add(kfd); -// uncomment this to look at occupancies - // add(new OccupancyDriver()); - } - - public void setOutputFile(String outputFile) { - System.out.println("Will output events to " + outputFile); - add(new LCIODriver(outputFile)); - } - - public void setPlotsFile(String plotsFile) { - System.out.println("Will output plots to " + plotsFile); - jad.setOutputPlots(plotsFile); - } - - public void setOutputTextName(String outputTextName) { - System.out.println("Will output selected events to " + outputTextName); - ftad.setOutputText(outputTextName); - } - - public void setPName(String pName) { - System.out.println("Setting parameter set to " + pName); - pairs.clear(); - if (pName.contentEquals("HPS3pt2")) { - detType = "Full"; - bfield = 1.0; - nlayers = 12; - fitlayers=10; - axialStrategy = "DarkPhoton-Axial-HPS3pt2.xml"; - finalStrategy = "DarkPhoton-HPS3pt2.xml"; - llStrategy = "DarkPhoton-HPS3pt2-LongLived.xml"; - - int[] p1 = {1, 2}; - int[] p2 = {3, 4}; - int[] p3 = {5, 6}; - int[] p4 = {7, 8}; - int[] p5 = {9, 10}; - int[] p6 = {11, 12}; - pairs.add(p1); - pairs.add(p2); - pairs.add(p3); - pairs.add(p4); - pairs.add(p5); - pairs.add(p6); - passLayers.add(11); - } - if (pName.contentEquals("HPS3pt4")) { - detType = "Full"; - bfield = 0.5; - nlayers = 12; - fitlayers=10; - axialStrategy = "DarkPhoton-Axial-HPS3pt2.xml"; - finalStrategy = "DarkPhoton-HPS3pt2.xml"; - llStrategy = "none"; - - int[] p1 = {1, 2}; - int[] p2 = {3, 4}; - int[] p3 = {5, 6}; - int[] p4 = {7, 8}; - int[] p5 = {9, 10}; - int[] p6 = {11, 12}; - pairs.add(p1); - pairs.add(p2); - pairs.add(p3); - pairs.add(p4); - pairs.add(p5); - pairs.add(p6); - passLayers.add(11); - } - - if (pName.contentEquals("HPS1pt8")) { - detType = "Test"; - nlayers = 10; - bfield = 0.5; - fitlayers=10; - axialStrategy = "none"; // don't fit tracks axially first - finalStrategy = "HPS-Test-1pt3.xml"; - llStrategy = "none";// don't fit tracks ignoring first plane - - int[] p1 = {1, 2}; - int[] p2 = {3, 4}; - int[] p3 = {5, 6}; - int[] p4 = {7, 8}; - int[] p5 = {9, 10}; - - pairs.add(p1); - pairs.add(p2); - pairs.add(p3); - pairs.add(p4); - pairs.add(p5); -// passLayers.add(11); - } - - if (pName.contentEquals("HPS1pt9")) { - detType = "Test"; - nlayers = 10; - bfield = 0.25; - fitlayers=10; - axialStrategy = "none"; // don't fit tracks axially first - finalStrategy = "HPS-Test-1pt3.xml"; - llStrategy = "none";// don't fit tracks ignoring first plane - - int[] p1 = {1, 2}; - int[] p2 = {3, 4}; - int[] p3 = {5, 6}; - int[] p4 = {7, 8}; - int[] p5 = {9, 10}; - - pairs.add(p1); - pairs.add(p2); - pairs.add(p3); - pairs.add(p4); - pairs.add(p5); -// passLayers.add(11); - } - - } -}
diff -N HPSTrigger.java --- HPSTrigger.java 14 Oct 2011 18:46:44 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,84 +0,0 @@
- -package org.lcsim.hps.util; - -//--- Java ---// -import java.util.ArrayList; -import java.util.List; - - -//--- org.lcsim ---// -import org.lcsim.event.EventHeader; - -//--- hps-java ---// -//import org.lcsim.hps.users.omoreno.tracking.HPSAPV25; -import org.lcsim.util.Driver; - - -/** - * Receives the ECal trigger signal and applies a trigger latency before - * sending the signal to other HPS detectors. A trigger signal is only - * accepted once within every trigger window. - * Note: Currently, only the SVT is supported - * - * @author Omar Moreno - * @version $Id: HPSTrigger.java,v 1.2 2011/10/14 18:46:44 omoreno Exp $ - */ -public class HPSTrigger extends Driver { - - // Stores the trigger time stamp shifted by the trigger latency - public static final List<Double> trigger = new ArrayList<Double>(); - - // Once the trigger latency is set, it should not change - public static final double triggerLatency = 80.0; // ns - - // Trigger decision window - public static final double triggerWindow = 16.0; // ns - public static boolean triggerWindowBit = false; - - /** - * Constructor - */ - public HPSTrigger( ){ }; - - /** - * Add a trigger signal to the queue - * - */ - public static void addTrigger( ) - { - - // Only accept a single trigger within a given trigger window - if( !triggerWindowBit ){ - trigger.add( ClockSingleton.getTime() + triggerLatency ); - triggerWindowBit = true; - } - } - - /** - * Checks if there has been a trigger signal sent on a event - * by event basis. If a trigger signal has been sent and its - * timestamp, after applying the trigger latency, matches the - * system time, a trigger signal is sent to all HPS detectors. - * - */ - @Override - public void process( EventHeader event ) - { - super.process(event); - - // Only accept a single trigger for a given trigger window - if( ClockSingleton.getTime()%triggerWindow == 0 ) - triggerWindowBit = false; - - // Check if there are any pending triggers - if( !( trigger.isEmpty() ) ){ - if( ClockSingleton.getTime() == trigger.get( 0 ) ){ - - // Send a trigger signal to the SVT - System.out.println( "System has been triggered." ); -// HPSAPV25._trigger_bit = true; - trigger.remove( 0 ); - } - } - } -}
diff -N HeavyPhotonLLDriver.java --- HeavyPhotonLLDriver.java 26 Nov 2012 19:38:54 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,231 +0,0 @@
-package org.lcsim.hps.users.mgraham.jlabrotation; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import org.lcsim.hps.event.HPSTransformations; -import org.lcsim.hps.recon.tracking.HelicalTrackHitDriver; -import org.lcsim.hps.recon.tracking.HPSTrackerHitDriver; -import org.lcsim.hps.recon.tracking.MakeSensorsDriver; - -import org.lcsim.hps.recon.tracking.SiTrackerSpectrometerSensorSetup; -import org.lcsim.recon.tracking.seedtracker.SeedStrategy; -import org.lcsim.recon.tracking.seedtracker.SeedTracker; -import org.lcsim.recon.tracking.seedtracker.StrategyXMLUtils; -import org.lcsim.recon.tracking.seedtracker.diagnostic.SeedTrackerDiagnostics; -import org.lcsim.util.Driver; -import org.lcsim.util.loop.LCIODriver; - -/** - * Driver for track reconstruction and analysis of HPS detector. - * - * @author M. Graham and R. Partridge - */ -public final class HeavyPhotonLLDriver extends Driver { - - //******************** - // set pname to the detector you want to run...HPS1pt8 is the default test detector (uses strategy file 1.3) - // see "setPName" method for list -// public String pName = "HPS1pt9"; - public String pName = "HPS1pt8"; -// JasAnalysisDriver jad; - DetailedAnalysisDriver dad; -// FastTrackAnalysisDriver ftad; -// KalmanFilterDriver kfd; - List<int[]> pairs = new ArrayList(); - List<Integer> passLayers = new ArrayList(); - //// Change the prefix for your site -// String strategyPrefix = "/nfs/sulky21/g.ec.u12/users/mgraham/AtlasUpgrade/hps-java/src/main/resources/"; - String strategyPrefix = "/Users/mgraham/NetBeansProjects/hps-java/src/main/resources/"; - //////////////////////////////////////// - // everything below will - // get overwritten by setPName - int nlayers = 10; - int fitlayers = 10; - // bfield needs to be set because tracking doesn't - // seme to deal with fields in the negative - // z-direction well (need to fix this) - double bfield = 0.5; - String detType = "Full"; - String axialStrategy = "HPS-Test-1pt8.xml"; - String finalStrategy = "HPS-Test-1pt8.xml"; - String llStrategy = "HPS-Test-1pt8.xml"; - public String outputFile = "foobar.slcio"; - public String plotsFile = "myplots.aida"; - public String outputTextName = "myevents.txt"; - /////////////// - - public HeavyPhotonLLDriver() { -// add(new MakeSensorsDriver()); - add(new SiTrackerSpectrometerSensorSetup("Tracker")); - setPName(pName); - - HPSTrackerHitDriver thd = new HPSTrackerHitDriver(); - add(thd); - - HelicalTrackHitDriver hthdriver = new HelicalTrackHitDriver(); - hthdriver.addCollection(((HPSTrackerHitDriver) thd).getStripHits1DName()); - hthdriver.setOutputCollectionName("HelicalTrackHits"); - hthdriver.HitRelationName("HelicalTrackHitRelations"); - hthdriver.MCRelationName("HelicalTrackMCRelations"); - for (int[] pair : pairs) - hthdriver.setStereoPair("Tracker", pair[0], pair[1]); - - if (detType.contains("Test")) { - System.out.println("Setting separation for a Test detector"); - hthdriver.setMaxSeperation(10.01); - hthdriver.setTolerance(0.01); - } else { - - hthdriver.setMaxSeperation(50.); - hthdriver.setTolerance(0.4); - } - hthdriver.setTransformToTracking(true); - add(hthdriver); - - List<SeedStrategy> sFinallist = StrategyXMLUtils.getStrategyListFromFile(new File(strategyPrefix + finalStrategy)); - SeedTracker stFinal = null; - stFinal = new SeedTracker(sFinallist); - - HPSTransformations hpstrans = new HPSTransformations(); - stFinal.setMaterialManagerTransform(hpstrans.getTransform()); - stFinal.setInputCollectionName("RotatedHelicalTrackHits"); - -// stFinal.setInputCollectionName("HelicalTrackHits"); - - stFinal.setTrkCollectionName("MatchedTracks"); - stFinal.setDiagnostics(new SeedTrackerDiagnostics()); - stFinal.setBField(bfield); - stFinal.setSectorParams(false); - stFinal.setTimingPlots(true); - - - - add(stFinal); - -// MultiTrackReco trd = new MultiTrackReco(strategyPrefix, detType, bfield, axialStrategy, finalStrategy, llStrategy, pairs, passLayers); -// add(trd); - - dad = new DetailedAnalysisDriver(10); - add(dad); - -// kfd = new KalmanFilterDriver(); -// add(kfd); -// uncomment this to look at occupancies - // add(new OccupancyDriver()); - } - - public void setOutputFile(String outputFile) { - System.out.println("Will output events to " + outputFile); - add(new LCIODriver(outputFile)); - } - - public void setPlotsFile(String plotsFile) { - System.out.println("Will output plots to " + plotsFile); -// jad.setOutputPlots(plotsFile); - } - - public void setOutputTextName(String outputTextName) { - System.out.println("Will output selected events to " + outputTextName); -// ftad.setOutputText(outputTextName); - } - - public void setPName(String pName) { - System.out.println("Setting parameter set to " + pName); - pairs.clear(); - if (pName.contentEquals("HPS3pt2")) { - detType = "Full"; - bfield = 1.0; - nlayers = 12; - fitlayers = 10; - axialStrategy = "DarkPhoton-Axial-HPS3pt2.xml"; - finalStrategy = "DarkPhoton-HPS3pt2.xml"; - llStrategy = "DarkPhoton-HPS3pt2-LongLived.xml"; - - int[] p1 = {1, 2}; - int[] p2 = {3, 4}; - int[] p3 = {5, 6}; - int[] p4 = {7, 8}; - int[] p5 = {9, 10}; - int[] p6 = {11, 12}; - pairs.add(p1); - pairs.add(p2); - pairs.add(p3); - pairs.add(p4); - pairs.add(p5); - pairs.add(p6); - passLayers.add(11); - } - if (pName.contentEquals("HPS3pt4")) { - detType = "Full"; - bfield = 0.5; - nlayers = 12; - fitlayers = 10; - axialStrategy = "DarkPhoton-Axial-HPS3pt2.xml"; - finalStrategy = "DarkPhoton-HPS3pt2.xml"; - llStrategy = "none"; - - int[] p1 = {1, 2}; - int[] p2 = {3, 4}; - int[] p3 = {5, 6}; - int[] p4 = {7, 8}; - int[] p5 = {9, 10}; - int[] p6 = {11, 12}; - pairs.add(p1); - pairs.add(p2); - pairs.add(p3); - pairs.add(p4); - pairs.add(p5); - pairs.add(p6); - passLayers.add(11); - } - - if (pName.contentEquals("HPS1pt8")) { - detType = "Test"; - nlayers = 10; - bfield = 0.5; - fitlayers = 10; - axialStrategy = "none"; // don't fit tracks axially first - finalStrategy = "HPS-Test-1pt3.xml"; - llStrategy = "none";// don't fit tracks ignoring first plane - - int[] p1 = {1, 2}; - int[] p2 = {3, 4}; - int[] p3 = {5, 6}; - int[] p4 = {7, 8}; - int[] p5 = {9, 10}; - - pairs.add(p1); - pairs.add(p2); - pairs.add(p3); - pairs.add(p4); - pairs.add(p5); -// passLayers.add(11); - } - - if (pName.contentEquals("HPS1pt9")) { - detType = "Test"; - nlayers = 10; - bfield = 0.25; - fitlayers = 10; - axialStrategy = "none"; // don't fit tracks axially first - finalStrategy = "HPS-Test-1pt3.xml"; - llStrategy = "none";// don't fit tracks ignoring first plane - - int[] p1 = {1, 2}; - int[] p2 = {3, 4}; - int[] p3 = {5, 6}; - int[] p4 = {7, 8}; - int[] p5 = {9, 10}; - - pairs.add(p1); - pairs.add(p2); - pairs.add(p3); - pairs.add(p4); - pairs.add(p5); -// passLayers.add(11); - } - - } -}
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1