Contents
Class HelicityGenerator
java.lang.Object
org.jlab.detector.helicity.HelicityGenerator
- All Implemented Interfaces:
Comparable<HelicityGenerator>
,Comparator<HelicityGenerator>
public final class HelicityGenerator
extends Object
implements Comparable<HelicityGenerator>, Comparator<HelicityGenerator>
Helicity Pseudo-Random Sequence.
This calculates the first helicity state in each pattern (quartet/octet/toggle),
according to the specs here:
https://hallaweb.jlab.org/equipment/daq/HelicityUsersGuideFeb4.pdf
Note, the convention above, and internally in this class, is HIGH=0=+ and LOW=1=-.
Note, this pseudorandom generator operates on raw helicity, and does not produce
the same sequence if you just reverse all the states, so the HWP-corrected
helicity cannot be used here.
User calls addState() until initialized()==true, then getState().
Public interface requires HelicityBit (not integers).
- Author:
- baltzell
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addState
(HelicityBit bit) Let the user add a state to initialize the sequence.void
addState
(HelicityState state) Let the user add a state to initialize the sequence.int
int
compareTo
(HelicityGenerator other) get
(int n) Get the nth state in the sequence.int
long
Get the timestamp of the first state in the generator sequence.final boolean
initialize
(List<HelicityState> states) Initialize with a list of states.boolean
Test whether the generator is sufficiently initialized such thatget(int)
method can be called, based on whether the number of added states is at leastREGISTER_SIZE
.void
reset()
Reset the generator, clearing all added states, in order to reuse thisHelicityGenerator
for a new sequence.void
setClock
(double clock) int
size()
Get the number of states currently in the generator's sequence.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
Constructor Details
-
Method Details
-
setClock
public void setClock(double clock) -
compareTo
- Specified by:
compareTo
in interfaceComparable<HelicityGenerator>
-
compare
- Specified by:
compare
in interfaceComparator<HelicityGenerator>
-
getTimestamp
public long getTimestamp()Get the timestamp of the first state in the generator sequence.- Returns:
- timestamp (4ns)
-
reset
public void reset()Reset the generator, clearing all added states, in order to reuse thisHelicityGenerator
for a new sequence. -
initialized
public boolean initialized()Test whether the generator is sufficiently initialized such thatget(int)
method can be called, based on whether the number of added states is at leastREGISTER_SIZE
.- Returns:
- whether the sequence is initialized
-
size
public int size()Get the number of states currently in the generator's sequence.- Returns:
- size
-
addState
Let the user add a state to initialize the sequence. This must be the first helicity state in the next pattern. States must be added serially and without skipped patterns. Requiresinitialized()
is false and a defined HelicityBit, else throws an exception..- Parameters:
bit
- the HelicityBit to add to the sequence. This must be the raw helicity, e.g. HelicityState.getHelicityRaw(), not the HWP-corrected version.
-
addState
Let the user add a state to initialize the sequence. This just callsaddState(HelicityBit)
with the rawinvalid reference
#HelicityBit
invalid reference
#HelicityState
initialized()
is false and a definedinvalid reference
#HelicityState
- Parameters:
state
- the HelicityState to add to the sequence.
-
get
Get the nth state in the sequence. Requires initialized()==true.- Parameters:
n
- number of states after the first one.- Returns:
- the nth HelicityBit in the sequence.
-
initialize
Initialize with a list of states. The states are first time-ordered, and error-checking is done to find the first valid sequence of sufficient length in the list and use it to initialize the generator, otherwise the return value will be false.- Parameters:
states
- list of HelicityState objects- Returns:
- success of initializing the generator
-
getOffset
public int getOffset()
-