FSUDAQ/DigitizerClass.h

124 lines
3.8 KiB
C
Raw Normal View History

2022-08-03 19:00:41 -04:00
#ifndef DIGITIZER_H
#define DIGITIZER_H
#include <stdio.h>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring> ///memset
#include <iostream> ///cout
#include <bitset>
//#include <TQObject.h>
//#include <RQ_OBJECT.h>
#include "CAENDigitizer.h"
#include "CAENDigitizerType.h"
#include "RegisterAddress.h"
#define MaxNChannels 16
#define MaxRecordLength 0x3fff * 8
2022-08-03 19:00:41 -04:00
using namespace std;
/**
2022-08-03 19:00:41 -04:00
struct DigitizerChannelSetting {
/// PDS
unsigned int cfdSetting;
unsigned int chargeZeroSuppThreshold;
unsigned int shortGateWidth;
unsigned int longGateWidth;
unsigned int gateOffset;
unsigned int fixedBaseline;
unsigned int triggerLatency;
unsigned int thresholdPSDCut;
unsigned int pureGapThreshold;
unsigned int earlyBaselineFreeze;
};*/
2022-08-03 19:00:41 -04:00
//################################################################
class Digitizer{
public:
Digitizer();
Digitizer(int boardID, int portID = 0);
~Digitizer();
void Reset();
2022-08-04 18:02:03 -04:00
int OpenDigitizer(int boardID, int portID = 0, bool verbose = false);/// portID is for optical link for using PCIe card, from 0, 1, 2, 3
2022-08-03 19:00:41 -04:00
int CloseDigitizer();
///=================Settings
void WriteRegister(uint32_t address, uint32_t value, int ch = -1);
uint32_t ReadRegister(uint32_t address, unsigned int ch = 0, string str = "");
2022-08-03 19:00:41 -04:00
///common for PHA and PSD digitizers
void SetChannelMask(uint32_t mask);
void SetRecordLength(unsigned int nSample, int ch = -1); /// when ch == -1, mean set all channels
2022-08-03 19:00:41 -04:00
void SetEventAggregation(unsigned int numEvent, int ch = -1);
void SetInputDynamicRange(unsigned int TwoVol_0_or_halfVol_1, int ch = -1);
void SetNumSamplePreTrigger(unsigned int nSample, int ch = -1 );
void SetDCOffset(float offsetPrecentage, int ch = -1);
void SetVetoWidth(uint32_t bit, int ch = -1); /// See manual
void SetTriggerPolarity(bool RiseingIsZero, int ch = -1);
void SetBits(uint32_t address, unsigned int bitValue, unsigned int bitLength, unsigned int bitSmallestPos, int ch = -1);
void SetDPPAlgorithmControl(uint32_t bit, int ch = -1);
2022-08-03 19:00:41 -04:00
int SetAcqMode(string list_mixed);
2022-08-03 19:00:41 -04:00
///================ Get Settings
2022-08-04 18:02:03 -04:00
int GetSerialNumber() {return BoardInfo.SerialNumber;}
int GetChannelMask() {return channelMask;}
2022-08-03 19:00:41 -04:00
float GetCh2ns() {return ch2ns;}
2022-08-04 18:02:03 -04:00
int GetNChannel() {return NChannel;}
2022-08-03 19:00:41 -04:00
int GetChTemperature(int ch) ;
2022-08-04 18:02:03 -04:00
bool GetConnectionStatus() {return isConnected;}
int GetDPPType() {return DPPType;}
2022-08-03 19:00:41 -04:00
void PrintBoardConfiguration();
///================ ACQ control
void StopACQ();
void StartACQ();
protected:
///---- fixed parameter
int portID; /// port ID for optical link for using PCIe card, from 0, 1, 2, 3
int boardID; /// board identity
int handle; /// i don't know why, but better separete the handle from boardID
int NChannel; /// number of channel
int ADCbits; /// ADC bit
int DPPType; /// DPP verion
unsigned int ADCFullSize; /// pow(2, ADCbits) - 1
float ch2ns; /// channel to ns
CAEN_DGTZ_BoardInfo_t BoardInfo;
uint32_t DPPControl2Adress;
2022-08-03 19:00:41 -04:00
///----- adjustable parameters
uint32_t VMEBaseAddress; /// For direct USB or Optical-link connection, VMEBaseAddress must be 0
CAEN_DGTZ_ConnectionType LinkType;
CAEN_DGTZ_IOLevel_t IOlev; /// TTL signal (1 = 1.5 to 5V, 0 = 0 to 0.7V ) or NIM signal (1 = -1 to -0.8V, 0 = 0V)
CAEN_DGTZ_DPP_AcqMode_t AcqMode;
uint32_t channelMask ; /// the channel mask from NChannel
///------- other parameters
int ret; /// return value, refer to CAEN_DGTZ_ErrorCode
bool isConnected;
///==========
virtual int ProgramBoard();
2022-08-03 19:00:41 -04:00
void ErrorMsg(string header = "");
};
#endif