FSUDAQ/DAQ/Obsolete/DigitizerPHA.h
2022-10-31 15:00:04 -04:00

100 lines
9.1 KiB
C++

#ifndef DIGITIZER_PHA_H
#define DIGITIZER_PHA_H
#include "ClassDigitizer.h"
class DigitizerPHA : public Digitizer {
public:
DigitizerPHA();
DigitizerPHA(int boardID, int portID = 0, bool verbose = false);
~DigitizerPHA();
int ProgramBoard();
///=================== Set Settings
void SetSetting(Setting::PHA settingName, float value, int ch = -1);
void SetTrapezoidRescaling(unsigned int rightShiftBits, int ch = -1){ SetBits(Register::DPP::DPPAlgorithmControl, rightShiftBits, 5, 0, ch); ErrorMsg("PHA-SetTrapezoidRescaling"); }
void SetEnergyFineGain(unsigned int gain, int ch = -1) { WriteRegister(Register::DPP::PHA::FineGain, gain & 0xFFFF, ch); ErrorMsg("PHA-SetEnergyFineGain");}
void AutoSetTrapezoidRescalingAndFindGate(double gain = 1, int ch = -1);
///=================== Get settings
double GetSetting(Setting::PHA settingName, int ch = -1);
void PrintBoardConfiguration();
void PrintACQControl();
void PrintGlobalTriggerMask();
void PrintFrontPanelTRIGOUTEnableMask();
void PrintFrontPanelIOControl();
void PrintTriggerValidationMask();
void PrintBoardInfoRegister();
void PrintBoardFailureState();
void PrintReadoutControl();
void PrintReadoutStatu();
void PrintChannelSettingFromDigitizer(int ch); ///inlcluded DPP Algorithm Control 1, 2
///####################################################
///========= Old way Set and Get
/**
void SetAutoDataFlush(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 0); ErrorMsg("PHA-SetAutoDataFlush"); }
void SetDualTrace(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 11); ErrorMsg("PHA-SetDualTrace"); }
void SetAnalogProbe1(unsigned short bit) { SetBits(Register::DPP::BoardConfiguration, bit, 2, 12); ErrorMsg("PHA-SetAnalogProbe1"); }
void SetAnalogProbe2(unsigned short bit) { SetBits(Register::DPP::BoardConfiguration, bit, 2, 14); ErrorMsg("PHA-SetAnalogProbe1"); }
void SetWaveFormRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 16); ErrorMsg("PHA-SetWaveFormRecording"); }
void SetEnableExtra2Word(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 17); ErrorMsg("PHA-SetEnableExtra2Word"); }
void SetTimeStampRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 18); ErrorMsg("PHA-SetTimeStampRecording"); }
void SetEnergyRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 19); ErrorMsg("PHA-SetEnergyRecording");}
void SetVirtualProbe1(unsigned short bit){ SetBits(Register::DPP::BoardConfiguration, bit, 4, 20); ErrorMsg("PHA-SetVirtualProbe1"); }
void SetDecimation(unsigned int bit, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 2, 8, ch); ErrorMsg("PHA-SetDecimation");}
void SetDecimationGain(unsigned int bit, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 2, 10, ch); ErrorMsg("PHA-SetDecimationGain");}
void SetPeakSampling(unsigned int bit, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 2, 12, ch); ErrorMsg("PHA-SetPeakSampling");}
void SetPulsePolarity(bool PositiveIsZero, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, PositiveIsZero, 1, 16, ch); ErrorMsg("PHA-SetPulsePolarity");}
void SetTriggerMode(unsigned int bit, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 2, 18, ch); ErrorMsg("PHA-SetTriggerMode");}
void SetBaselineSampling(unsigned int bit, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 3, 20, ch); ErrorMsg("PHA-SetBaselineSampling"); }
void SetDisableSelfTrigger(bool OnOff, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, OnOff, 1, 24, ch); ErrorMsg("PHA-SetDisableSelfTrigger");}
void SetRollOverFlag(bool isRollOver, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, isRollOver, 1, 26, ch); ErrorMsg("PHA-SetRollOverFlag");}
void SetPileUpFlag(bool isPileUpFlag, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, isPileUpFlag, 1, 27, ch); ErrorMsg("PHA-SetPileUpFlag");}
void SetDPPAlgorithmControl2(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, ch); ErrorMsg("PHA-SetDPPAlgorithmControl2");}
void SetLocalShapedTriggerMode(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, 2, 0, ch); ErrorMsg("PHA-SetLocalShapedTriggerMode");}
void SetEnableLocalShapedTrigger(bool OnOff, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, OnOff, 1, 2, ch); ErrorMsg("PHA-SetEnableLocalShapedTrigger");}
void SetLocalTriggerValidationMode(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, 2, 4, ch); ErrorMsg("PHA-SetLocalTriggerValidationMode");}
void SetEnableLocalTriggerValidation(bool OnOff, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, OnOff, 1, 6, ch); ErrorMsg("PHA-SetEnableLocalTriggerValidation");}
void SetExtra2WordOption(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, 3, 8, ch); ErrorMsg("PHA-SetExtra2WordOption");}
void SetVetoSource(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, 2, 14, ch); ErrorMsg("PHA-SetVetoSource");}
void SetTriggerCounterRateStep(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, 2, 16, ch); ErrorMsg("PHA-SetTriggerCounterRateStep");}
void SetBaselineCalWhenACQOFF(bool OnOff, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, OnOff, 1, 18, ch); ErrorMsg("PHA-SetBaselineCalWhenACQOFF");}
void SetTagCorrelatedEvents(bool OnOff, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, OnOff, 1, 19, ch); ErrorMsg("PHA-SetTagCorrelatedEvents");}
void SetBaselineRestoreOptimization(bool OnOff, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, OnOff, 1, 29, ch); ErrorMsg("PHA-SetBaselineRestoreOptimization");}
void SetTriggerThreshold(unsigned int threshold, int ch = -1) { WriteRegister(Register::DPP::PHA::TriggerThreshold, threshold & 0x03FF, ch); ErrorMsg("PHA-SetTriggerThreshold");}
void SetTriggerHoldOff(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::TriggerHoldOffWidth, nSample & 0x03FF, ch); ErrorMsg("PHA-SetTriggerHoldOff"); }
void SetTriggerSmoothingFactor(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PHA::RCCR2SmoothingFactor, bit & 0x001F, ch); ErrorMsg("PHA-SetTriggerSmoothingFactor");}
void SetTriggerOutputWidth(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::ShapedTriggerWidth, nSample & 0x03FF, ch); ErrorMsg("PHA-SetTriggerOutputWidth");}
void SetInputRiseTime(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::InputRiseTime, nSample & 0x00FF, ch); ErrorMsg("PHA-SetInputRiseTime");}
void SetTrapezoidRiseTime(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::TrapezoidRiseTime, nSample & 0x0FFF, ch); ErrorMsg("PHA-SetTrapezoidRiseTime");}
void SetTrapezoidFlatTop(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::TrapezoidFlatTop, nSample & 0x0FFF, ch); ErrorMsg("PHA-SetTrapezoidFlatTop");}
void SetDecayTime(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::DecayTime, nSample & 0xFFFF, ch); ErrorMsg("PHA-SetDecayTime");}
void SetPeakingTime(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::PeakingTime, nSample & 0x0FFF, ch); ErrorMsg("PHA-SetPeakingTime");}
void SetPeakingHoldOff(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::PeakHoldOff, nSample & 0x03FF, ch); ErrorMsg("PHA-SetPeakingHoldOff");}
void SetRiseTimeValidWindow(unsigned int nSample, int ch = -1){ WriteRegister(Register::DPP::PHA::RiseTimeValidationWindow,nSample & 0x03FF, ch); ErrorMsg("PHA-SetRiseTimeValidWindow");}
unsigned int GetAnalogProbe1() {return ReadBits(Register::DPP::BoardConfiguration, 2, 12);}
unsigned int GetAnalogProbe2() {return ReadBits(Register::DPP::BoardConfiguration, 2, 14);}
bool GetWaveFormRecarding() {return ReadBits(Register::DPP::BoardConfiguration, 1, 16);}
bool GetTimeStampRecording() {return ReadBits(Register::DPP::BoardConfiguration, 1, 18);}
bool GetEnergyRecording() {return ReadBits(Register::DPP::BoardConfiguration, 1, 19);}
unsigned int GetVirtualProbe1() {return ReadBits(Register::DPP::BoardConfiguration, 4, 20);}
unsigned int GetTriggerThreshold(unsigned int ch) {return ReadRegister(Register::DPP::PHA::TriggerThreshold, ch);}
*/
};
#endif