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 Details

  • Constructor Details

    • HelicityGenerator

      public HelicityGenerator()
  • Method Details

    • setClock

      public void setClock(double clock)
    • compareTo

      public int compareTo(HelicityGenerator other)
      Specified by:
      compareTo in interface Comparable<HelicityGenerator>
    • compare

      public int compare(HelicityGenerator o1, HelicityGenerator o2)
      Specified by:
      compare in interface Comparator<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 this HelicityGenerator for a new sequence.
    • initialized

      public boolean initialized()
      Test whether the generator is sufficiently initialized such that get(int) method can be called, based on whether the number of added states is at least REGISTER_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

      public void addState(HelicityBit bit)
      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. Requires initialized() 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

      public void addState(HelicityState state)
      Let the user add a state to initialize the sequence. This just calls addState(HelicityBit) with the raw #HelicityBit from the given #HelicityState. This must be the first helicity state in the next pattern. States must be added serially and without skipped patterns. Requires initialized() is false and a defined #HelicityState.
      Parameters:
      state - the HelicityState to add to the sequence.
    • get

      public HelicityBit get(int n)
      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

      public final boolean initialize(List<HelicityState> states)
      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()