Package cnuphys.snr
Class NoiseReductionParameters
java.lang.Object
cnuphys.snr.NoiseReductionParameters
All the parameters needed for noise reduction. Each superlayer should have
its own object. Now should be thread safe.
- Author:
- heddle
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic SNRAnalysisLevel
static final int
protected ExtendedWord
cumulative left segments.static final int
protected ExtendedWord
cumulative right segments. -
Constructor Summary
ConstructorsConstructorDescriptionCreate the parameters used for SNR analysisNoiseReductionParameters
(int allowedMissingLayers, int[] leftLayerShifts, int[] rightLayerShifts) Create a NoiseReductionParameter using CLAS12 defaults for the number of superlayers, layers and wiresNoiseReductionParameters
(int numLayer, int numWire, int allowedMissingLayers, int[] leftLayerShifts, int[] rightLayerShifts) Create a NoiseReductionParameter using defaults for the number of superlayers, layers and wires -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHitsInMask
(int layer, int wire, int direction, WireList list) Add wires that are in the masks of the clean data corresponding to a given wire (segment candidate start), layer, and directionvoid
clear()
Clear all dataint
computeAdjacency
(int layer, int wire) Used in second stage analysis.void
Copy those parameters that can be editedvoid
Create all the workspace needed to remove the noise.int
Get the adjacency threshold, used in stage 2 analysis where we look for clusters.int
Returns the number of allowed missing layers.Get the cluster finderGet the list of clustersstatic NoiseReductionParameters
Get a default set of parameters with CLAS-like numbersint[]
Get the layer shifts for left leaning tracks.Get the left leaning segment staring wire positions.double
Get the occupancy of the packed data.int
Get the number of layers per superlayerint
Get the number of wires per layerdouble
Get the occupancy of the raw data.int[]
Get the layer shifts for right leaning tracks.Get the right leaning segment staring wire positions.This is meaningful only if the analysis has been performed.boolean
boolean
isNoiseHit
(int layer, int wire) Checks whether a given wire has a noise hit.int
maxShift
(int direction) Get the maximum shift for a given direction.int
missingLayersUsed
(int direction, int wire) Get the number of missing layers used to find a segment candidate starting at the given wire in layer 1 (1..6)void
packHit
(int layer, int wire) pack a hit into the raw datavoid
Remove the noise.void
setAdjacencyThreshold
(int adjacencyThreshold) Set the adjacency threshold, used in stage 2 analysis where we look for clusters.void
setAllowedMissingLayers
(int allowedMissingLayers) Set the number of allowed missing layers.void
setLeftLayerShifts
(int[] shifts) Set the left layer shifts used for left leaning segmentsstatic void
setLookForTracks
(boolean lookForTracks) Deprecated.doesn't do anything, kept for backwards capability.void
setPackedData
(ExtendedWord[] packedData) Set new raw data.void
setRightLayerShifts
(int[] shifts) Set the right layer shifts used for right leaning segmentsstatic void
Set the analysis level OneStage: the classic SNR noise analysis TwoStage: the centers of mass are used to remove noise within the masks but disjoint from the segment (hopefully).int
Total number of raw hits (all layers in this chamber/superlayer)int
Total number of noise reduced hits (all layers in this chamber/superlayer)
-
Field Details
-
_analysisLevel
-
LEFT_LEAN
public static final int LEFT_LEAN- See Also:
-
RIGHT_LEAN
public static final int RIGHT_LEAN- See Also:
-
leftSegments
cumulative left segments. These are "results". When analysis is complete, this will contain an on bit at any location in layer 1 that is a potential start of a left leaning segment. -
rightSegments
cumulative right segments. These are "results". When analysis is complete, this will contain an on bit at any location in layer 1 that is a potential start of a right leaning segment.
-
-
Constructor Details
-
NoiseReductionParameters
public NoiseReductionParameters()Create the parameters used for SNR analysis -
NoiseReductionParameters
public NoiseReductionParameters(int allowedMissingLayers, int[] leftLayerShifts, int[] rightLayerShifts) Create a NoiseReductionParameter using CLAS12 defaults for the number of superlayers, layers and wires- Parameters:
allowedMissingLayers
- the number of missing layers permitted.leftLayerShifts
- the shifts for left leaning tracks. Length should equal numLayers.rightLayerShifts
- the shifts for right leaning tracks. Length should equal numLayers.
-
NoiseReductionParameters
public NoiseReductionParameters(int numLayer, int numWire, int allowedMissingLayers, int[] leftLayerShifts, int[] rightLayerShifts) Create a NoiseReductionParameter using defaults for the number of superlayers, layers and wires- Parameters:
allowedMissingLayers
- the number of missing layers permitted.leftLayerShifts
- the shifts for left leaning tracks. Length should equal numLayers.rightLayerShifts
- the shifts for right leaning tracks. Length should equal numLayers.
-
-
Method Details
-
getDefaultParameters
Get a default set of parameters with CLAS-like numbers- Returns:
- a default set of parameters
-
getAdjacencyThreshold
public int getAdjacencyThreshold()Get the adjacency threshold, used in stage 2 analysis where we look for clusters. This is used to remove additional noise in the vicinity of segments that do not pass a connectedness test.- Returns:
- the adjacency threshold
-
setAdjacencyThreshold
public void setAdjacencyThreshold(int adjacencyThreshold) Set the adjacency threshold, used in stage 2 analysis where we look for clusters. This is used to remove additional noise in the vicinity of segments that do not pass a connectedness test.- Parameters:
adjacencyThreshold
- hte new threshold
-
getNumLayer
public int getNumLayer()Get the number of layers per superlayer- Returns:
- the number of layers per superlayer
-
getNumWire
public int getNumWire()Get the number of wires per layer- Returns:
- the number of wires per layer
-
copyEditableParameters
Copy those parameters that can be edited- Parameters:
source
- the source object.
-
createWorkSpace
public void createWorkSpace()Create all the workspace needed to remove the noise. -
isNoiseHit
public boolean isNoiseHit(int layer, int wire) Checks whether a given wire has a noise hit. Only sensible if analysis is complete.- Parameters:
layer
- the 0-based layer 0..5wire
- the 0-base wire 0..- Returns:
- true if this was a noise hit--i.e., it is in the raw data but not the analyzed data
-
clear
public void clear()Clear all data -
getAllowedMissingLayers
public int getAllowedMissingLayers()Returns the number of allowed missing layers.- Returns:
- the number of allowed missing layers.
-
getLeftLayerShifts
public int[] getLeftLayerShifts()Get the layer shifts for left leaning tracks.- Returns:
- the layer shifts for left leaning tracks.
-
setLeftLayerShifts
public void setLeftLayerShifts(int[] shifts) Set the left layer shifts used for left leaning segments- Parameters:
shifts
- the left layer shifts
-
getRightLayerShifts
public int[] getRightLayerShifts()Get the layer shifts for right leaning tracks.- Returns:
- the layer shifts for right leaning tracks.
-
setRightLayerShifts
public void setRightLayerShifts(int[] shifts) Set the right layer shifts used for right leaning segments- Parameters:
shifts
- the right layer shifts
-
getLeftSegments
Get the left leaning segment staring wire positions. This is meaningful only if the analysis has been performed.- Returns:
- the left leaning segment staring wire positions.
-
getRightSegments
Get the right leaning segment staring wire positions.This is meaningful only if the analysis has been performed.- Returns:
- the right leaning segment staring wire positions.
-
packHit
public void packHit(int layer, int wire) pack a hit into the raw data- Parameters:
layer
- the 0-based layerwire
- the 0-based wire
-
setPackedData
Set new raw data. The analyzed flag is set to false.- Parameters:
rawData
- the new raw data to set.
-
isAnalyzed
public boolean isAnalyzed()- Returns:
- the analyzed flag. If
tue
the data have been anaylzed, and noise bits removed from the packedData arrays.
-
removeNoise
public void removeNoise()Remove the noise. This is the actual algorithm. -
maxShift
public int maxShift(int direction) Get the maximum shift for a given direction. It is assumed that this is in the shift for the last layer.- Parameters:
direction
- either left (0) or right (1)- Returns:
- the maximum shift for a given direction
-
addHitsInMask
Add wires that are in the masks of the clean data corresponding to a given wire (segment candidate start), layer, and direction- Parameters:
layer
- the 0 based layer, for CLAS12 [0..5]wire
- the 0 based wire, for CLAS12 [0..111]direction
- either left (0) or right (1)list
- the list to add to
-
missingLayersUsed
public int missingLayersUsed(int direction, int wire) Get the number of missing layers used to find a segment candidate starting at the given wire in layer 1 (1..6)- Parameters:
direction
- LEFT_LEAN (0) or RIGHT_LEAN (1)wire
- the 0-based wire- Returns:
- the number of missing layers used at that position
-
getRawOccupancy
public double getRawOccupancy()Get the occupancy of the raw data. This should only be used by ced proper, not the test program.- Returns:
- the occupancy of the raw. Multiply by 100 to express as percent.
-
getNoiseReducedOccupancy
public double getNoiseReducedOccupancy()Get the occupancy of the packed data. This should only be used by ced proper, not the test program.- Returns:
- the occupancy of the raw. Multiply by 100 to express as percent.
-
setAllowedMissingLayers
public void setAllowedMissingLayers(int allowedMissingLayers) Set the number of allowed missing layers.- Parameters:
allowedMissingLayers
- the number to set
-
totalRawHitCount
public int totalRawHitCount()Total number of raw hits (all layers in this chamber/superlayer)- Returns:
- number of raw hits
-
totalReducedHitCount
public int totalReducedHitCount()Total number of noise reduced hits (all layers in this chamber/superlayer)- Returns:
- number of noise reduced hits
-
setSNRAnalysisLevel
Set the analysis level OneStage: the classic SNR noise analysis TwoStage: the centers of mass are used to remove noise within the masks but disjoint from the segment (hopefully). This might result in the loss of the segment!- Parameters:
level
- new level
-
getClusterFinder
Get the cluster finder- Returns:
- ther cluster finder
-
computeAdjacency
public int computeAdjacency(int layer, int wire) Used in second stage analysis. Adjaceny counts that are within "del" from the given wire, where del is 1 for the layer the wire is in an increases by 1 for every layer as you move up or down. Thus for CLAS12, del is [1..5]- Parameters:
layer
- the 0-based layer, for CLAS12 [0..5]wire
- the 0-base wire, for CLAS12 [0..111]- Returns:
- the adjacency value
-
getClusters
Get the list of clusters- Returns:
- the list of clusters
-
setLookForTracks
public static void setLookForTracks(boolean lookForTracks) Deprecated.doesn't do anything, kept for backwards capability.- Parameters:
lookForTracks
-
-