Package org.jlab.detector.helicity
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 SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddState(HelicityBit bit) Let the user add a state to initialize the sequence.voidaddState(HelicityState state) Let the user add a state to initialize the sequence.intintcompareTo(HelicityGenerator other) get(int n) Get the nth state in the sequence.intlongGet the timestamp of the first state in the generator sequence.final booleaninitialize(List<HelicityState> states) Initialize with a list of states.booleanTest 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.voidreset()Reset the generator, clearing all added states, in order to reuse thisHelicityGeneratorfor a new sequence.voidsetClock(double clock) intsize()Get the number of states currently in the generator's sequence.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparatorequals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
- 
Field Details- 
REGISTER_SIZEpublic static final int REGISTER_SIZE- See Also:
 
 
- 
- 
Constructor Details- 
HelicityGeneratorpublic HelicityGenerator()
 
- 
- 
Method Details- 
setClockpublic void setClock(double clock) 
- 
compareTo- Specified by:
- compareToin interface- Comparable<HelicityGenerator>
 
- 
compare- Specified by:
- comparein interface- Comparator<HelicityGenerator>
 
- 
getTimestamppublic long getTimestamp()Get the timestamp of the first state in the generator sequence.- Returns:
- timestamp (4ns)
 
- 
resetpublic void reset()Reset the generator, clearing all added states, in order to reuse thisHelicityGeneratorfor a new sequence.
- 
initializedpublic 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
 
- 
sizepublic int size()Get the number of states currently in the generator's sequence.- Returns:
- size
 
- 
addStateLet 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.
 
- 
addStateLet the user add a state to initialize the sequence. This just callsaddState(HelicityBit)with the raw#HelicityBitfrom the given#HelicityState. 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#HelicityState.- Parameters:
- state- the HelicityState to add to the sequence.
 
- 
getGet 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.
 
- 
initializeInitialize 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
 
- 
getOffsetpublic int getOffset()
 
-