seperated DigitizerClass to DigitizerPHA, DigitizerPSD, add prototye of FSUDAQ

This commit is contained in:
splitPoleDAQ 2022-08-04 17:27:33 -04:00
parent 240a35aba6
commit 14731d5dea
15 changed files with 1388 additions and 909 deletions

3
.gitignore vendored
View File

@ -1 +1,4 @@
*.o
test test
FSUDAQ

444
DigitizerClass.cpp Normal file
View File

@ -0,0 +1,444 @@
#include "DigitizerClass.h"
Digitizer::Digitizer(){
portID = -1;
boardID = -1;
handle = -1;
NChannel = 0;
ADCbits = 1;
DPPType = 0;
ADCFullSize = 0;
ch2ns = 0;
BoardInfo = {};
DPPControl2Adress = Register::DPP::PHA::DPPAlgorithmControl2;
VMEBaseAddress = 0;
LinkType = CAEN_DGTZ_USB; /// default USB
IOlev = CAEN_DGTZ_IOLevel_NIM; ///default NIM
AcqMode = CAEN_DGTZ_DPP_ACQ_MODE_List; ///default list mode
channelMask = 0xFFFF;
ret = -1;
isConnected = false;
}
Digitizer::Digitizer(int boardID, int portID){
Digitizer();
OpenDigitizer(boardID, portID);
}
Digitizer::~Digitizer(){
CloseDigitizer();
}
void Digitizer::Reset(){
ret = CAEN_DGTZ_Reset(handle);
if( ret != 0 ) ErrorMsg("Reset");
}
int Digitizer::OpenDigitizer(int boardID, int portID){
this->boardID = boardID;
this->portID = portID;
/***************************************************/
/** Open the digitizer and read board information */
/***************************************************/
printf("============= Opening Digitizer at Board %d, Port %d \n", boardID, portID);
///-------- try USB first
LinkType = CAEN_DGTZ_USB; /// Link Type
ret = (int) CAEN_DGTZ_OpenDigitizer(LinkType, boardID, 0, VMEBaseAddress, &handle);
if (ret != 0){ ///---------- try Optical link
LinkType = CAEN_DGTZ_OpticalLink ;
ret = (int) CAEN_DGTZ_OpenDigitizer(LinkType, portID, boardID, VMEBaseAddress, &handle);
}
if (ret != 0) {
printf("Can't open digitizer\n");
}else{
///----- Getting Board Info
ret = (int) CAEN_DGTZ_GetInfo(handle, &BoardInfo);
if (ret != 0) {
printf("Can't read board info\n");
}else{
isConnected = true;
printf("Connected to Model %s with handle %d using %s\n", BoardInfo.ModelName, handle, LinkType == CAEN_DGTZ_USB ? "USB" : "Optical Link");
NChannel = BoardInfo.Channels;
channelMask = pow(2, NChannel)-1;
switch(BoardInfo.Model){
case CAEN_DGTZ_V1730: ch2ns = 2.0; break; ///ns -> 500 MSamples/s
case CAEN_DGTZ_V1725: ch2ns = 4.0; break; ///ns -> 250 MSamples/s
}
printf("Sampling rate : %.0f MHz = %.1f ns \n", 1000/ch2ns, ch2ns);
printf("Number of Channels : %d = 0x%X\n", NChannel, channelMask);
printf("SerialNumber :\e[1m\e[33m %d\e[0m\n", BoardInfo.SerialNumber);
ADCbits = BoardInfo.ADC_NBits;
ADCFullSize = (unsigned int)( pow(2, ADCbits) -1 );
printf("ADC bit is \e[33m%d\e[0m, %d = 0x%x\n", ADCbits, ADCFullSize, ADCFullSize);
printf("ROC FPGA Release is %s\n", BoardInfo.ROC_FirmwareRel);
printf("AMC FPGA Release is %s\n", BoardInfo.AMC_FirmwareRel);
int DPPType;
sscanf(BoardInfo.AMC_FirmwareRel, "%d", &DPPType);
if (DPPType != V1730_DPP_PHA_CODE) {
printf("This digitizer does not have DPP-PHA firmware\n");
}
}
}
// Check firmware revision (DPP firmwares cannot be used with this demo */
sscanf(BoardInfo.AMC_FirmwareRel, "%d", &DPPType);
if (DPPType >= 128) {
printf("\t==== This digitizer has a DPP firmware!\n");
printf("\e[32m");
switch (DPPType){
case 0x80: printf("\tDPP-PHA for x724 boards \n"); break;
case 0x82: printf("\tDPP-CI for x720 boards \n"); break;
case 0x83: printf("\tDPP-PSD for x720 boards \n"); break;
case 0x84: printf("\tDPP-PSD for x751 boards \n"); break;
case 0x85: printf("\tDPP-ZLE for x751 boards \n"); break;
case 0x86: printf("\tDPP-PSD for x743 boards \n"); break;
case 0x87: printf("\tDPP-QDC for x740 boards \n"); break;
case 0x88: printf("\tDPP-PSD for x730 boards \n"); DPPControl2Adress = Register::DPP::PSD::DPPAlgorithmControl2; break;
case 0x8B: printf("\tDPP-PHA for x730 boards \n"); DPPControl2Adress = Register::DPP::PHA::DPPAlgorithmControl2; break;
case 0x8C: printf("\tDPP-ZLE for x730 boards \n"); break;
case 0x8D: printf("\tDPP-DAW for x730 boards \n"); break;
}
printf("\e[0m");
}
int probes[MAX_SUPPORTED_PROBES];
int numProbes;
ret = CAEN_DGTZ_GetDPP_SupportedVirtualProbes(handle, 1, probes, &numProbes);
printf("\t==== supported virtual probe (number of Probe : %d)\n", numProbes);
for( int i = 0 ; i < numProbes; i++){
switch (probes[i]){
case 0: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_Input\n"); break;
case 1: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_Delta\n"); break;
case 2: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_Delta2\n"); break;
case 3: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_Trapezoid\n"); break;
case 4: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_TrapezoidReduced\n"); break;
case 5: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_Baseline\n"); break;
case 6: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_Threshold\n"); break;
case 7: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_CFD\n"); break;
case 8: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_SmoothedInput\n"); break;
case 9: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_None\n"); break;
case 10: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_TRGWin\n"); break;
case 11: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_Armed\n"); break;
case 12: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_PkRun\n"); break;
case 13: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_Peaking\n"); break;
case 14: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_CoincWin\n"); break;
case 15: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_BLHoldoff\n"); break;
case 16: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_TRGHoldoff\n"); break;
case 17: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_TRGVal\n"); break;
case 18: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_ACQVeto\n"); break;
case 19: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_BFMVeto\n"); break;
case 20: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_ExtTRG\n"); break;
case 21: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_OverThr\n"); break;
case 22: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_TRGOut\n"); break;
case 23: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_Coincidence \n"); break;
case 24: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_PileUp \n"); break;
case 25: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_Gate \n"); break;
case 26: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_GateShort \n"); break;
case 27: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_Trigger \n"); break;
case 28: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_None \n"); break;
case 29: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_BLFreeze \n"); break;
case 30: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_Busy \n"); break;
case 31: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_PrgVeto \n"); break;
}
}
ErrorMsg("end of OpenDigitizer");
if( isConnected ) {
ProgramBoard();
}
return ret;
}
int Digitizer::CloseDigitizer(){
printf("-------- Closing Digtizer Board : %d Port : %d \n", boardID, portID);
printf(" Model %s with handle %d using %s\n", BoardInfo.ModelName, handle, LinkType == CAEN_DGTZ_USB ? "USB" : "Optical Link");
ret = CAEN_DGTZ_SWStopAcquisition(handle);
ret |= CAEN_DGTZ_CloseDigitizer(handle);
return ret;
}
void Digitizer::ErrorMsg(string header){
switch (ret){
///case CAEN_DGTZ_Success : /** 0 */ printf("%s | Operation completed successfully.\n", header.c_str()); break;
case CAEN_DGTZ_CommError : /** -1 */ printf("%s | Communication Error.\n", header.c_str()); break;
case CAEN_DGTZ_GenericError : /** -2 */ printf("%s | Unspecified error.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidParam : /** -3 */ printf("%s | Invalid parameter.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidLinkType : /** -4 */ printf("%s | Invalid Link Type.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidHandle : /** -5 */ printf("%s | Invalid device handler.\n", header.c_str()); break;
case CAEN_DGTZ_MaxDevicesError : /** -6 */ printf("%s | Maximum number of devices exceeded.\n", header.c_str()); break;
case CAEN_DGTZ_BadBoardType : /** -7 */ printf("%s | Operation not allowed on this type of board.\n", header.c_str()); break;
case CAEN_DGTZ_BadInterruptLev : /** -8 */ printf("%s | The interrupt level is not allowed.\n", header.c_str()); break;
case CAEN_DGTZ_BadEventNumber : /** -9 */ printf("%s | The event number is bad.\n", header.c_str()); break;
case CAEN_DGTZ_ReadDeviceRegisterFail : /** -10 */ printf("%s | Unable to read the registry.\n", header.c_str()); break;
case CAEN_DGTZ_WriteDeviceRegisterFail : /** -11 */ printf("%s | Unable to write the registry.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidChannelNumber : /** -13 */ printf("%s | The channel number is invalid.\n", header.c_str()); break;
case CAEN_DGTZ_ChannelBusy : /** -14 */ printf("%s | The channel is busy.\n", header.c_str()); break;
case CAEN_DGTZ_FPIOModeInvalid : /** -15 */ printf("%s | Invalid FPIO mode.\n", header.c_str()); break;
case CAEN_DGTZ_WrongAcqMode : /** -16 */ printf("%s | Wrong Acquistion mode.\n", header.c_str()); break;
case CAEN_DGTZ_FunctionNotAllowed : /** -17 */ printf("%s | This function is not allowed on this module.\n", header.c_str()); break;
case CAEN_DGTZ_Timeout : /** -18 */ printf("%s | Communication Timeout.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidBuffer : /** -19 */ printf("%s | The buffer is invalid.\n", header.c_str()); break;
case CAEN_DGTZ_EventNotFound : /** -20 */ printf("%s | The event is not found.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidEvent : /** -21 */ printf("%s | The event is invalid.\n", header.c_str()); break;
case CAEN_DGTZ_OutOfMemory : /** -22 */ printf("%s | Out of memory.\n", header.c_str()); break;
case CAEN_DGTZ_CalibrationError : /** -23 */ printf("%s | Unable to calibrate the board.\n", header.c_str()); break;
case CAEN_DGTZ_DigitizerNotFound : /** -24 */ printf("%s | Unbale to open the digitizer.\n", header.c_str()); break;
case CAEN_DGTZ_DigitizerAlreadyOpen : /** -25 */ printf("%s | The digitizer is already open.\n", header.c_str()); break;
case CAEN_DGTZ_DigitizerNotReady : /** -26 */ printf("%s | The digitizer is not ready.\n", header.c_str()); break;
case CAEN_DGTZ_InterruptNotConfigured : /** -27 */ printf("%s | The digitizer has no IRQ configured.\n", header.c_str()); break;
case CAEN_DGTZ_DigitizerMemoryCorrupted: /** -28 */ printf("%s | The digitizer flash memory is corrupted.\n", header.c_str()); break;
case CAEN_DGTZ_DPPFirmwareNotSupported : /** -29 */ printf("%s | The digitier DPP firmware is not supported in this lib version.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidLicense : /** -30 */ printf("%s | Invalid firmware licence.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidDigitizerStatus : /** -31 */ printf("%s | The digitizer is found in a corrupted status.\n", header.c_str()); break;
case CAEN_DGTZ_UnsupportedTrace : /** -32 */ printf("%s | The given trace is not supported.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidProbe : /** -33 */ printf("%s | The given probe is not supported.\n", header.c_str()); break;
case CAEN_DGTZ_UnsupportedBaseAddress : /** -34 */ printf("%s | The base address is not supported.\n", header.c_str()); break;
case CAEN_DGTZ_NotYetImplemented : /** -99 */ printf("%s | The function is not yet implemented.\n", header.c_str()); break;
}
}
int Digitizer::ProgramBoard(){
ret = CAEN_DGTZ_Reset(handle);
if (ret) {
printf("ERROR: can't reset the digitizer.\n");
return -1;
}
/// Board Configuration without PHA or PSD fireware
///bx0000 0000 0000 0000 0000 0000 0001 0000 =
/// | | +- (1) trigger overlap not allowed
/// | +- (3) test pattern disable
/// + (6) Self-trigger polarity, 1 = negative, 0 = Positive
ret = CAEN_DGTZ_WriteRegister(handle, (uint32_t) Register::BoardConfiguration , 0x000E0114); /// Channel Control Reg (indiv trg, seq readout) ??
/// Set the I/O level (CAEN_DGTZ_IOLevel_NIM or CAEN_DGTZ_IOLevel_TTL)
ret |= CAEN_DGTZ_SetIOLevel(handle, IOlev);
/// Set the enabled channels
ret |= CAEN_DGTZ_SetChannelEnableMask(handle, channelMask);
/// Set the number of samples for each waveform
SetRecordLength(100); /// default 100 * 8 = 800 ch
///ret |= CAEN_DGTZ_SetRecordLength(handle, recordLength);
/// Set Extras 2 to enable, this override Accusition mode, focring list mode
uint32_t value = 0x10E0114;
ret |= CAEN_DGTZ_WriteRegister(handle, Register::BoardConfiguration , value );
/// Set how many events to accumulate in the board memory before being available for readout
SetEventAggregation(0); /// when zero, digitizer auto set
///ret |= CAEN_DGTZ_SetDPPEventAggregation(handle, EventAggr, 0);
/// Set the digitizer acquisition mode (CAEN_DGTZ_SW_CONTROLLED or CAEN_DGTZ_S_IN_CONTROLLED)
ret |= CAEN_DGTZ_SetAcquisitionMode(handle, CAEN_DGTZ_SW_CONTROLLED); /// software command
ret |= CAEN_DGTZ_SetDPPAcquisitionMode(handle, AcqMode, CAEN_DGTZ_DPP_SAVE_PARAM_EnergyAndTime);
/** Set the digitizer's behaviour when an external trigger arrives:
CAEN_DGTZ_TRGMODE_DISABLED: do nothing
CAEN_DGTZ_TRGMODE_EXTOUT_ONLY: generate the Trigger Output signal
CAEN_DGTZ_TRGMODE_ACQ_ONLY = generate acquisition trigger
CAEN_DGTZ_TRGMODE_ACQ_AND_EXTOUT = generate both Trigger Output and acquisition trigger
see CAENDigitizer user manual, chapter "Trigger configuration" for details */
ret |= CAEN_DGTZ_SetExtTriggerInputMode(handle, CAEN_DGTZ_TRGMODE_ACQ_ONLY);
/** Set the mode used to syncronize the acquisition between different boards.
In this example the sync is disabled */
ret |= CAEN_DGTZ_SetRunSynchronizationMode(handle, CAEN_DGTZ_RUN_SYNC_Disabled);
ErrorMsg("End of ProgramBoard");
return ret;
}
//===========================================================
void Digitizer::WriteRegister(uint32_t address, uint32_t value, int ch ){
if( ch < 0 ) {
ret = CAEN_DGTZ_WriteRegister(handle, address + 0x7000, value);
}else{
ret = CAEN_DGTZ_WriteRegister(handle, address + (ch<<8), value);
}
ErrorMsg("WriteRegister");
}
uint32_t Digitizer::ReadRegister(uint32_t address, unsigned int ch, string str ){
uint32_t * Data = new uint32_t[NChannel];
if( ch < 0 ) {
ret = CAEN_DGTZ_ReadRegister(handle, address + 0x7000, Data);
}else{
ret = CAEN_DGTZ_ReadRegister(handle, address + (ch << 8), Data);
}
ErrorMsg("ReadRegister");
if( str != "" ) printf("%s : 0x%x \n", str.c_str(), Data[0]);
return Data[0];
}
void Digitizer::SetChannelMask(uint32_t mask){
channelMask = mask;
ret |= CAEN_DGTZ_SetChannelEnableMask(handle, channelMask);
ErrorMsg("SetChannelMask");
}
void Digitizer::SetRecordLength(unsigned int nSample, int ch){
WriteRegister( Register::DPP::RecordLength, nSample / 8, ch);
ErrorMsg("SetRecordLength");
}
void Digitizer::SetEventAggregation(unsigned int numEvent, int ch){
WriteRegister( Register::DPP::NumberEventsPerAggregate, numEvent, ch);
ErrorMsg("SetEventAggregation");
}
void Digitizer::SetInputDynamicRange(unsigned int TwoVol_0_or_halfVol_1, int ch){
WriteRegister( Register::InputDynamicRange, TwoVol_0_or_halfVol_1, ch);
ErrorMsg("SetInputDynamicRange");
}
void Digitizer::SetNumSamplePreTrigger(unsigned int nSample, int ch){
WriteRegister( Register::DPP::PreTrigger, nSample / 4, ch);
ErrorMsg("SetNumSamplePreTrigger");
}
void Digitizer::SetDCOffset(float offsetPrecentage, int ch){
WriteRegister( Register::DPP::ChannelDCOffset, uint( ADCFullSize * offsetPrecentage), ch );
ErrorMsg("SetDCOffset");
}
void Digitizer::SetVetoWidth(uint32_t bit, int ch){
WriteRegister( Register::DPP::VetoWidth, bit, ch);
ErrorMsg("SetVetoWidth");
}
void Digitizer::SetTriggerPolarity(bool RiseingIsZero, int ch ){
if( ch < 0 ) {
ret = 0;
for (int i = 0; i < NChannel; i++){
ret |= CAEN_DGTZ_SetTriggerPolarity(handle, i, CAEN_DGTZ_TriggerPolarity_t(RiseingIsZero));
}
}else{
ret = CAEN_DGTZ_SetTriggerPolarity(handle, ch, CAEN_DGTZ_TriggerPolarity_t(RiseingIsZero));
}
if( ret != 0 ) ErrorMsg("SetTriggerPolarity");
}
//============================== DPP-Alpgorthm Control
void Digitizer::SetDPPAlgorithmControl(uint32_t bit, int ch){
///============= DPP algorithm control is 32 bit
/// [ 0: 5] Trapazoid Rescaling. the trapazoid ADC is 48 bit. it need to bit-shift before the 0x3FFF (14 bit filter)
/// [ 8: 9] Decimation. 00 = disable, 01 = 2 samples, 10 = 4 samples, 11 = 8 sample
/// [10:11] Decimation Gain. This gain apply to the Trapazoid Rescaling and fine gain
/// [12:13] Peak Mean. sample for averaging the trapezoid height calculation. 00 = 1 sample, 01 = 4 samples, 10 = 16 sample, 11 = 64 sample
/// [16] pulse polarity. 0 = positve, 1 = negative
/// [18:19] Trigger mode. 00 = normal, 01 = coincident, 10 = reserved. 11 = anti coincident
/// [20:22] number of samples for the baseline average calculation. 000 = baseline disable (energy not subtraced with baseline)
/// 001 = 16 samples
/// 010 = 64 samples
/// 011 = 256 samples
/// 100 = 1024 samples
/// 101 = 4096 samples
/// 110 = 16384 samples
/// 111 = resertved.
/// [24] Disable self trigger. 0 = selftrigger used to acquire and propagated to the trigger logic;
/// 1 = selftrigger only propagated to the trigger logic.
/// [26] Enable Roll-Over flag. see manual 0 = disable, 1 = enable
/// [27] Enable pile-up flag.
///============= PHA - DPP algorithm control 2 is 32 bit
/// [ 0: 1] Local Shaped Trigger mode. see manual
/// [ 2] Enable Local Shaped Trigger
/// [ 4: 5] Local Trigger Validation mode, see manual
/// [ 6] Enable Local Trigger Validation
/// [ 8:10] Extra 2 word option. 000 = [0:15] baseline *4 [16:31] extended time stamp
/// 001 = reserved
/// 010 = [0:15] fine time stamp [16:31] extended time stamp
/// 011 = reserved
/// 100 = [0:15] total tigger counter [16:31] Lost trigger counter
/// 101 = [0:15] event after the zero crosiing [16:31] event before zero crossing
/// 110, 111 = reserved.
/// [14:15] source of veto. 00 = disable, 01 veto is common to all channels, 10 = veto for coupled channels, 11 = veto comes from negative saturation
/// [16:17] Select the step for the trigger counter rate flag. see manual
/// [18] baseline calculation is active also when the acquisition is not running. 0 = disbale, 1 = enable
/// [19] Tag correlated events. see manual 0 = disbale, 1 = enable
/// [29] Enable the optimization of the Baseline Restorer to avoid tails in the energy peaks. 0 = disbale, 1 = enable
WriteRegister( Register::DPP::DPPAlgorithmControl, bit, ch);
if( ret != 0 ) ErrorMsg("SetDPPAlgorithmControl");
}
void Digitizer::SetBits(uint32_t address, unsigned int bitValue, unsigned int bitLength, unsigned int bitSmallestPos, int ch){
uint32_t bit ;
uint32_t bitmask = (uint(pow(2, bitLength)-1) << bitSmallestPos);
if (ch < 0 ) ch = 0; /// take ch-0
bit = ReadRegister(address, 0);
bit = (bit & ~bitmask) | (bitValue << bitSmallestPos);
WriteRegister(address, bit, ch);
if( ret != 0 ) ErrorMsg("SetBits");
}
int Digitizer::SetAcqMode(string list_mixed){
if( list_mixed == "list"){
AcqMode = CAEN_DGTZ_DPP_ACQ_MODE_List; /// enables the acquisition of time stamps and energy value
}else if ( list_mixed == "mixed"){
AcqMode = CAEN_DGTZ_DPP_ACQ_MODE_Mixed; /// enables the acquisition of both waveforms, energies, and timestamps.
}else{
printf("############ AcqMode must be either list or mixed\n");
return -1;
}
int ret = 0;
if( isConnected ){
/********************* Set the DPP acquisition mode
This setting affects the modes Mixed and List (see CAEN_DGTZ_DPP_AcqMode_t definition for details)
CAEN_DGTZ_DPP_SAVE_PARAM_EnergyOnly Only energy (DPP-PHA) or charge (DPP-PSD/DPP-CI v2) is returned
CAEN_DGTZ_DPP_SAVE_PARAM_TimeOnly Only time is returned
CAEN_DGTZ_DPP_SAVE_PARAM_EnergyAndTime Both energy/charge and time are returned
CAEN_DGTZ_DPP_SAVE_PARAM_None No histogram data is returned */
if( AcqMode == CAEN_DGTZ_DPP_ACQ_MODE_List){
ret = CAEN_DGTZ_SetDPPAcquisitionMode(handle, AcqMode, CAEN_DGTZ_DPP_SAVE_PARAM_EnergyAndTime);
}
if( AcqMode == CAEN_DGTZ_DPP_ACQ_MODE_Mixed ){
///ret = CAEN_DGTZ_SetDPPAcquisitionMode(handle, AcqMode, CAEN_DGTZ_DPP_SAVE_PARAM_TimeOnly);
ret = CAEN_DGTZ_SetDPPAcquisitionMode(handle, AcqMode, CAEN_DGTZ_DPP_SAVE_PARAM_EnergyAndTime);
}
if( ret == 0 ) {
printf("Setting digitizer to \e[33m%s\e[0m mode.\n", list_mixed.c_str());
}else{
ErrorMsg("Set AcqMode");
}
}
return ret;
}
int Digitizer::GetChTemperature(int ch){
if( BoardInfo.Model != CAEN_DGTZ_V1730 &&
BoardInfo.Model != CAEN_DGTZ_V1725 &&
BoardInfo.Model != CAEN_DGTZ_V1751 ) return -404;
uint32_t * temp;
ret |= CAEN_DGTZ_ReadTemperature(handle, ch, temp);
if( ret != 0 ) ErrorMsg("GetChTemperature");
return temp[0];
}

View File

@ -18,51 +18,12 @@
#include "RegisterAddress.h" #include "RegisterAddress.h"
#define MaxNChannels 16 #define MaxNChannels 16
#define MaxRecordLength 0x1fff /// 8191 #define MaxRecordLength 0x3fff * 8
using namespace std; using namespace std;
/**
struct DigitizerChannelSetting { struct DigitizerChannelSetting {
/// combined all DPP, PHA, and PSD
unsigned int recordLength; /// ch
unsigned int EventAggr; /// number of events in one aggregate (0=automatic), number of event acculated for read-off
unsigned int dynamicRange; /// 0 = 2 Vpp, 1 = 0.5 Vpp
unsigned int preTrigger; /// the number of samples before the trigger in the waveform saved into memory
float DCOffsetPrecentage; /// precentage of Max ADC
uint32_t VetoWidth; /// see manual, uint32_t to ensure it is 32 bit
bool triggerPolarity; /// 0 = on rising edge, 1 = on falling edge
uint32_t DPPAlgorithmControl;
unsigned int baselineSampling;
unsigned int peakSampling;
bool pulsePolarity_DPP; /// 0 = positive, 1 = negative
bool rollOverFlag;
bool pileUpFlag;
uint32_t DPPAlgorithmControl2;
unsigned int triggerThreshold; /// [LSB]
unsigned int triggerHoldOff; /// [ch], Other triggers are inhibited for the overall Trigger HoldOff duration.
unsigned int shapedTriggerWidth;
/// PHA
unsigned int triggerSmoothingFactor; /// 0x0 = disabled; 0x1 = 2 sample; 0x2 = 4 samples; 0x4 = 8 samples; 0x8 = 16 samples; 0x10 = 32 samples; 0x20 = 64 samples; 0x3F = 128 samples
unsigned int inputRiseTime; /// [ch]
unsigned int trapRiseTime; /// [ch]
unsigned int trapFlatTop; /// [ch]
unsigned int decayTime; /// [ch]
unsigned int peakingTime; /// [ch] flatTop delay, where the samples are used for the calculation of the peak height
unsigned int peakHoldOff; /// [ch] how close must be two trapezoids to be considered piledup after the start of flat top
unsigned int fineGain;
unsigned int riseTimeValidWindow; /// [ch] used by the rise time discriminator (RTD) to reject pulses that overlap in the rise time
/// PDS /// PDS
unsigned int cfdSetting; unsigned int cfdSetting;
@ -76,7 +37,7 @@ struct DigitizerChannelSetting {
unsigned int pureGapThreshold; unsigned int pureGapThreshold;
unsigned int earlyBaselineFreeze; unsigned int earlyBaselineFreeze;
}; };*/
//################################################################ //################################################################
@ -93,11 +54,11 @@ class Digitizer{
///=================Settings ///=================Settings
void WriteRegister(uint32_t address, uint32_t value, int ch = -1); void WriteRegister(uint32_t address, uint32_t value, int ch = -1);
uint32_t ReadRegister(uint32_t address, unsigned int ch); uint32_t ReadRegister(uint32_t address, unsigned int ch = 0, string str = "");
///common for PHA and PSD digitizers ///common for PHA and PSD digitizers
void SetChannelMask(uint32_t mask); void SetChannelMask(uint32_t mask);
void SetRecordLength(unsigned int lenght, int ch = -1); /// when ch == -1, mean set all channels void SetRecordLength(unsigned int nSample, int ch = -1); /// when ch == -1, mean set all channels
void SetEventAggregation(unsigned int numEvent, int ch = -1); void SetEventAggregation(unsigned int numEvent, int ch = -1);
void SetInputDynamicRange(unsigned int TwoVol_0_or_halfVol_1, int ch = -1); void SetInputDynamicRange(unsigned int TwoVol_0_or_halfVol_1, int ch = -1);
void SetNumSamplePreTrigger(unsigned int nSample, int ch = -1 ); void SetNumSamplePreTrigger(unsigned int nSample, int ch = -1 );
@ -105,20 +66,10 @@ class Digitizer{
void SetVetoWidth(uint32_t bit, int ch = -1); /// See manual void SetVetoWidth(uint32_t bit, int ch = -1); /// See manual
void SetTriggerPolarity(bool RiseingIsZero, int ch = -1); void SetTriggerPolarity(bool RiseingIsZero, int ch = -1);
void SetDPPAlgorithmControl(uint32_t bit, bool useControl2 = false, int ch = -1); void SetBits(uint32_t address, unsigned int bitValue, unsigned int bitLength, unsigned int bitSmallestPos, int ch = -1);
void SetDPPAlgorithmControlBit(unsigned int bitValue, unsigned int bitLength, unsigned int bitSmallestPos, bool useControl2 = false, int ch = -1); void SetDPPAlgorithmControl(uint32_t bit, int ch = -1);
void SetTrapezoidRescaling(unsigned int rightShiftBits, int ch = -1); /// DPPAlgoritmControl bit-0:5
void SetPeakSampling(unsigned int bit, int ch = -1); /// DPPAlgoritmControl bit-10:11
void SetPulsePolarity(bool PositiveIsZero, int ch = -1); /// DPPAlgoritmControl bit-16
void SetBaselineSampling(unsigned int bit, int ch = -1); /// DPPAlgoritmControl bit-20:22
void SetRollOverFlag(bool isRollOver, int ch = -1); /// DPPAlgoritmControl bit-26
void SetPileUpFlag(bool isPileUpFlag, int ch = -1); /// DPPAlgoritmControl bit-27
//int SetChannelParity(int ch, bool isPositive); int SetAcqMode(string list_mixed);
//int SetChannelThreshold(int ch, string folder, int threshold);
//int SetInputDynamicRange(int ch, string folder, int dyRange);
int SetAcqMode(string mode);
///================ Get Settings ///================ Get Settings
int GetSerialNumber() {return BoardInfo.SerialNumber;} int GetSerialNumber() {return BoardInfo.SerialNumber;}
@ -126,14 +77,11 @@ class Digitizer{
float GetCh2ns() {return ch2ns;} float GetCh2ns() {return ch2ns;}
int GetNChannel() {return NChannel;} int GetNChannel() {return NChannel;}
int GetChTemperature(int ch) ; int GetChTemperature(int ch) ;
void PrintBoardConfiguration(); void PrintBoardConfiguration();
uint32_t GetChannelStatus(unsigned int ch); uint32_t GetChannelStatus(unsigned int ch);
///================ ACQ control ///================ ACQ control
void StopACQ(); void StopACQ();
void StartACQ(); void StartACQ();
@ -150,8 +98,8 @@ class Digitizer{
unsigned int ADCFullSize; /// pow(2, ADCbits) - 1 unsigned int ADCFullSize; /// pow(2, ADCbits) - 1
float ch2ns; /// channel to ns float ch2ns; /// channel to ns
CAEN_DGTZ_BoardInfo_t BoardInfo; CAEN_DGTZ_BoardInfo_t BoardInfo;
uint32_t DPPControl2Adress;
///----- adjustable parameters ///----- adjustable parameters
uint32_t VMEBaseAddress; /// For direct USB or Optical-link connection, VMEBaseAddress must be 0 uint32_t VMEBaseAddress; /// For direct USB or Optical-link connection, VMEBaseAddress must be 0
CAEN_DGTZ_ConnectionType LinkType; CAEN_DGTZ_ConnectionType LinkType;
@ -159,697 +107,15 @@ class Digitizer{
CAEN_DGTZ_DPP_AcqMode_t AcqMode; CAEN_DGTZ_DPP_AcqMode_t AcqMode;
uint32_t channelMask ; /// the channel mask from NChannel uint32_t channelMask ; /// the channel mask from NChannel
DigitizerChannelSetting setting[MaxNChannels];
///------- other parameters ///------- other parameters
int ret; /// return value, refer to CAEN_DGTZ_ErrorCode int ret; /// return value, refer to CAEN_DGTZ_ErrorCode
bool isConnected; bool isConnected;
///========== ///==========
virtual int ProgramBoard(); virtual int ProgramBoard();
void ErrorMsg(string header = ""); void ErrorMsg(string header = "");
}; };
//========================================== methods
Digitizer::Digitizer(){
portID = -1;
boardID = -1;
handle = -1;
NChannel = 0;
ADCbits = 1;
ch2ns = 0;
BoardInfo = {};
channelMask = 0xFFFF;
for( int ch = 0; ch < MaxNChannels ; ch ++ ) {
setting[ch] = {};
setting[ch].recordLength = 2000;
setting[ch].EventAggr = 0;
}
ret = -1;
isConnected = false;
VMEBaseAddress = 0;
LinkType = CAEN_DGTZ_USB; /// default USB
IOlev = CAEN_DGTZ_IOLevel_NIM; ///default NIM
AcqMode = CAEN_DGTZ_DPP_ACQ_MODE_List; ///default list mode
}
Digitizer::Digitizer(int boardID, int portID){
Digitizer();
OpenDigitizer(boardID, portID);
}
Digitizer::~Digitizer(){
CloseDigitizer();
}
void Digitizer::Reset(){
ret = CAEN_DGTZ_Reset(handle);
if( ret != 0 ) ErrorMsg("Reset");
}
int Digitizer::OpenDigitizer(int boardID, int portID){
this->boardID = boardID;
this->portID = portID;
/***************************************************/
/** Open the digitizer and read board information */
/***************************************************/
printf("============= Opening Digitizer at Board %d, Port %d \n", boardID, portID);
///-------- try USB first
LinkType = CAEN_DGTZ_USB; /// Link Type
ret = (int) CAEN_DGTZ_OpenDigitizer(LinkType, boardID, 0, VMEBaseAddress, &handle);
if (ret != 0){ ///---------- try Optical link
LinkType = CAEN_DGTZ_OpticalLink ;
ret = (int) CAEN_DGTZ_OpenDigitizer(LinkType, portID, boardID, VMEBaseAddress, &handle);
}
if (ret != 0) {
printf("Can't open digitizer\n");
}else{
///----- Getting Board Info
ret = (int) CAEN_DGTZ_GetInfo(handle, &BoardInfo);
if (ret != 0) {
printf("Can't read board info\n");
}else{
isConnected = true;
printf("Connected to Model %s with handle %d using %s\n", BoardInfo.ModelName, handle, LinkType == CAEN_DGTZ_USB ? "USB" : "Optical Link");
NChannel = BoardInfo.Channels;
channelMask = pow(2, NChannel)-1;
switch(BoardInfo.Model){
case CAEN_DGTZ_V1730: ch2ns = 2.0; break; ///ns -> 500 MSamples/s
case CAEN_DGTZ_V1725: ch2ns = 4.0; break; ///ns -> 250 MSamples/s
}
printf("Sampling rate : %.0f MHz = %.1f ns \n", 1000/ch2ns, ch2ns);
printf("Number of Channels : %d = 0x%X\n", NChannel, channelMask);
printf("SerialNumber :\e[1m\e[33m %d\e[0m\n", BoardInfo.SerialNumber);
ADCbits = BoardInfo.ADC_NBits;
ADCFullSize = (unsigned int)( pow(2, ADCbits) -1 );
printf("ADC bit is \e[33m%d\e[0m, %d = 0x%x\n", ADCbits, ADCFullSize, ADCFullSize);
printf("ROC FPGA Release is %s\n", BoardInfo.ROC_FirmwareRel);
printf("AMC FPGA Release is %s\n", BoardInfo.AMC_FirmwareRel);
int DPPType;
sscanf(BoardInfo.AMC_FirmwareRel, "%d", &DPPType);
if (DPPType != V1730_DPP_PHA_CODE) {
printf("This digitizer does not have DPP-PHA firmware\n");
}
}
}
// Check firmware revision (DPP firmwares cannot be used with this demo */
sscanf(BoardInfo.AMC_FirmwareRel, "%d", &DPPType);
if (DPPType >= 128) {
printf("\t==== This digitizer has a DPP firmware!\n");
printf("\e[32m");
switch (DPPType){
case 0x80: printf("\tDPP-PHA for x724 boards \n"); break;
case 0x82: printf("\tDPP-CI for x720 boards \n"); break;
case 0x83: printf("\tDPP-PSD for x720 boards \n"); break;
case 0x84: printf("\tDPP-PSD for x751 boards \n"); break;
case 0x85: printf("\tDPP-ZLE for x751 boards \n"); break;
case 0x86: printf("\tDPP-PSD for x743 boards \n"); break;
case 0x87: printf("\tDPP-QDC for x740 boards \n"); break;
case 0x88: printf("\tDPP-PSD for x730 boards \n"); break;
case 0x8B: printf("\tDPP-PHA for x730 boards \n"); break;
case 0x8C: printf("\tDPP-ZLE for x730 boards \n"); break;
case 0x8D: printf("\tDPP-DAW for x730 boards \n"); break;
}
printf("\e[0m");
}
int probes[MAX_SUPPORTED_PROBES];
int numProbes;
ret = CAEN_DGTZ_GetDPP_SupportedVirtualProbes(handle, 1, probes, &numProbes);
printf("\t==== supported virtual probe (number of Probe : %d)\n", numProbes);
for( int i = 0 ; i < numProbes; i++){
switch (probes[i]){
case 0: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_Input\n"); break;
case 1: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_Delta\n"); break;
case 2: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_Delta2\n"); break;
case 3: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_Trapezoid\n"); break;
case 4: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_TrapezoidReduced\n"); break;
case 5: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_Baseline\n"); break;
case 6: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_Threshold\n"); break;
case 7: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_CFD\n"); break;
case 8: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_SmoothedInput\n"); break;
case 9: printf("\t\t CAEN_DGTZ_DPP_VIRTUALPROBE_None\n"); break;
case 10: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_TRGWin\n"); break;
case 11: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_Armed\n"); break;
case 12: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_PkRun\n"); break;
case 13: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_Peaking\n"); break;
case 14: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_CoincWin\n"); break;
case 15: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_BLHoldoff\n"); break;
case 16: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_TRGHoldoff\n"); break;
case 17: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_TRGVal\n"); break;
case 18: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_ACQVeto\n"); break;
case 19: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_BFMVeto\n"); break;
case 20: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_ExtTRG\n"); break;
case 21: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_OverThr\n"); break;
case 22: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_TRGOut\n"); break;
case 23: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_Coincidence \n"); break;
case 24: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_PileUp \n"); break;
case 25: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_Gate \n"); break;
case 26: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_GateShort \n"); break;
case 27: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_Trigger \n"); break;
case 28: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_None \n"); break;
case 29: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_BLFreeze \n"); break;
case 30: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_Busy \n"); break;
case 31: printf("\t\t CAEN_DGTZ_DPP_DIGITALPROBE_PrgVeto \n"); break;
}
}
ErrorMsg("end of OpenDigitizer");
if( isConnected ) {
ProgramBoard();
}
return ret;
}
int Digitizer::CloseDigitizer(){
printf("-------- Closing Digtizer Board : %d Port : %d \n", boardID, portID);
printf(" Model %s with handle %d using %s\n", BoardInfo.ModelName, handle, LinkType == CAEN_DGTZ_USB ? "USB" : "Optical Link");
ret = CAEN_DGTZ_SWStopAcquisition(handle);
ret |= CAEN_DGTZ_CloseDigitizer(handle);
return ret;
}
void Digitizer::ErrorMsg(string header){
switch (ret){
case CAEN_DGTZ_Success : /** 0 */ printf("%s | Operation completed successfully.\n", header.c_str()); break;
case CAEN_DGTZ_CommError : /** -1 */ printf("%s | Communication Error.\n", header.c_str()); break;
case CAEN_DGTZ_GenericError : /** -2 */ printf("%s | Unspecified error.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidParam : /** -3 */ printf("%s | Invalid parameter.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidLinkType : /** -4 */ printf("%s | Invalid Link Type.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidHandle : /** -5 */ printf("%s | Invalid device handler.\n", header.c_str()); break;
case CAEN_DGTZ_MaxDevicesError : /** -6 */ printf("%s | Maximum number of devices exceeded.\n", header.c_str()); break;
case CAEN_DGTZ_BadBoardType : /** -7 */ printf("%s | Operation not allowed on this type of board.\n", header.c_str()); break;
case CAEN_DGTZ_BadInterruptLev : /** -8 */ printf("%s | The interrupt level is not allowed.\n", header.c_str()); break;
case CAEN_DGTZ_BadEventNumber : /** -9 */ printf("%s | The event number is bad.\n", header.c_str()); break;
case CAEN_DGTZ_ReadDeviceRegisterFail : /** -10 */ printf("%s | Unable to read the registry.\n", header.c_str()); break;
case CAEN_DGTZ_WriteDeviceRegisterFail : /** -11 */ printf("%s | Unable to write the registry.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidChannelNumber : /** -13 */ printf("%s | The channel number is invalid.\n", header.c_str()); break;
case CAEN_DGTZ_ChannelBusy : /** -14 */ printf("%s | The channel is busy.\n", header.c_str()); break;
case CAEN_DGTZ_FPIOModeInvalid : /** -15 */ printf("%s | Invalid FPIO mode.\n", header.c_str()); break;
case CAEN_DGTZ_WrongAcqMode : /** -16 */ printf("%s | Wrong Acquistion mode.\n", header.c_str()); break;
case CAEN_DGTZ_FunctionNotAllowed : /** -17 */ printf("%s | This function is not allowed on this module.\n", header.c_str()); break;
case CAEN_DGTZ_Timeout : /** -18 */ printf("%s | Communication Timeout.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidBuffer : /** -19 */ printf("%s | The buffer is invalid.\n", header.c_str()); break;
case CAEN_DGTZ_EventNotFound : /** -20 */ printf("%s | The event is not found.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidEvent : /** -21 */ printf("%s | The event is invalid.\n", header.c_str()); break;
case CAEN_DGTZ_OutOfMemory : /** -22 */ printf("%s | Out of memory.\n", header.c_str()); break;
case CAEN_DGTZ_CalibrationError : /** -23 */ printf("%s | Unable to calibrate the board.\n", header.c_str()); break;
case CAEN_DGTZ_DigitizerNotFound : /** -24 */ printf("%s | Unbale to open the digitizer.\n", header.c_str()); break;
case CAEN_DGTZ_DigitizerAlreadyOpen : /** -25 */ printf("%s | The digitizer is already open.\n", header.c_str()); break;
case CAEN_DGTZ_DigitizerNotReady : /** -26 */ printf("%s | The digitizer is not ready.\n", header.c_str()); break;
case CAEN_DGTZ_InterruptNotConfigured : /** -27 */ printf("%s | The digitizer has no IRQ configured.\n", header.c_str()); break;
case CAEN_DGTZ_DigitizerMemoryCorrupted: /** -28 */ printf("%s | The digitizer flash memory is corrupted.\n", header.c_str()); break;
case CAEN_DGTZ_DPPFirmwareNotSupported : /** -29 */ printf("%s | The digitier DPP firmware is not supported in this lib version.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidLicense : /** -30 */ printf("%s | Invalid firmware licence.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidDigitizerStatus : /** -31 */ printf("%s | The digitizer is found in a corrupted status.\n", header.c_str()); break;
case CAEN_DGTZ_UnsupportedTrace : /** -32 */ printf("%s | The given trace is not supported.\n", header.c_str()); break;
case CAEN_DGTZ_InvalidProbe : /** -33 */ printf("%s | The given probe is not supported.\n", header.c_str()); break;
case CAEN_DGTZ_UnsupportedBaseAddress : /** -34 */ printf("%s | The base address is not supported.\n", header.c_str()); break;
case CAEN_DGTZ_NotYetImplemented : /** -99 */ printf("%s | The function is not yet implemented.\n", header.c_str()); break;
}
}
void Digitizer::PrintBoardConfiguration(){
uint32_t * value = new uint32_t[1];
CAEN_DGTZ_ReadRegister(handle, (uint32_t) Register::BoardConfiguration, value);
printf(" 32 28 24 20 16 12 8 4 0\n");
printf(" | | | | | | | | |\n");
cout <<" Board Configuration : 0b" << bitset<32>(value[0]) << endl;
printf(" Bit[ 0] = Auto Data Flush \n");
printf(" Bit[16] = WaveForm Recording \n");
printf(" Bit[17] = Extended Time Tag \n");
printf(" Bit[18] = Record Time Stamp \n");
printf(" Bit[19] = Record Energy \n");
printf("====================================== \n");
}
int Digitizer::ProgramBoard(){
ret = CAEN_DGTZ_Reset(handle);
if (ret) {
printf("ERROR: can't reset the digitizer.\n");
return -1;
}
/// Board Configuration without PHA or PSD fireware
///bx0000 0000 0000 0000 0000 0000 0001 0000 =
/// | | +- (1) trigger overlap not allowed
/// | +- (3) test pattern disable
/// + (6) Self-trigger polarity, 1 = negative, 0 = Positive
ret = CAEN_DGTZ_WriteRegister(handle, (uint32_t) Register::BoardConfiguration , 0x000E0114); /// Channel Control Reg (indiv trg, seq readout) ??
/// Set the I/O level (CAEN_DGTZ_IOLevel_NIM or CAEN_DGTZ_IOLevel_TTL)
ret |= CAEN_DGTZ_SetIOLevel(handle, IOlev);
/// Set the enabled channels
ret |= CAEN_DGTZ_SetChannelEnableMask(handle, channelMask);
/// Set the number of samples for each waveform
SetRecordLength(2000); /// default 2000 ch
///ret |= CAEN_DGTZ_SetRecordLength(handle, recordLength);
/// Set how many events to accumulate in the board memory before being available for readout
SetEventAggregation(0);
///ret |= CAEN_DGTZ_SetDPPEventAggregation(handle, EventAggr, 0);
/// Set the digitizer acquisition mode (CAEN_DGTZ_SW_CONTROLLED or CAEN_DGTZ_S_IN_CONTROLLED)
ret |= CAEN_DGTZ_SetAcquisitionMode(handle, CAEN_DGTZ_SW_CONTROLLED); /// software command
ret |= CAEN_DGTZ_SetDPPAcquisitionMode(handle, AcqMode, CAEN_DGTZ_DPP_SAVE_PARAM_EnergyAndTime);
/** Set the digitizer's behaviour when an external trigger arrives:
CAEN_DGTZ_TRGMODE_DISABLED: do nothing
CAEN_DGTZ_TRGMODE_EXTOUT_ONLY: generate the Trigger Output signal
CAEN_DGTZ_TRGMODE_ACQ_ONLY = generate acquisition trigger
CAEN_DGTZ_TRGMODE_ACQ_AND_EXTOUT = generate both Trigger Output and acquisition trigger
see CAENDigitizer user manual, chapter "Trigger configuration" for details */
ret |= CAEN_DGTZ_SetExtTriggerInputMode(handle, CAEN_DGTZ_TRGMODE_ACQ_ONLY);
/** Set the mode used to syncronize the acquisition between different boards.
In this example the sync is disabled */
ret |= CAEN_DGTZ_SetRunSynchronizationMode(handle, CAEN_DGTZ_RUN_SYNC_Disabled);
if (ret) {
ErrorMsg("End of ProgramBoard");
return ret;
} else {
return 0;
}
}
//===========================================================
void Digitizer::WriteRegister(uint32_t address, uint32_t value, int ch ){
if( ch < 0 ) {
ret = CAEN_DGTZ_WriteRegister(handle, address + 0x7000, value);
}else{
ret = CAEN_DGTZ_WriteRegister(handle, address + (ch<<8), value);
}
if( ret != 0 ) ErrorMsg("WriteRegister");
}
uint32_t Digitizer::ReadRegister(uint32_t address, unsigned int ch = 0){
uint32_t * Data = new uint32_t[NChannel];
if( ch < 0 ) {
ret = CAEN_DGTZ_ReadRegister(handle, address + 0x7000, Data);
}else{
ret = CAEN_DGTZ_ReadRegister(handle, address + (ch << 8), Data);
}
if( ret != 0 ) ErrorMsg("ReadRegister");
///printf("ch = %2d | %d \n", ch, Data[0]);
return Data[0];
}
void Digitizer::SetChannelMask(uint32_t mask){
channelMask = mask;
ret |= CAEN_DGTZ_SetChannelEnableMask(handle, channelMask);
if( ret != 0 ) ErrorMsg("SetChannelMask");
}
void Digitizer::SetRecordLength(unsigned int lenght, int ch){
if ( ch < 0 ){
for( int i = 0; i < MaxNChannels; i++ ) setting[i].recordLength = min((int)lenght, MaxRecordLength );
ret |= CAEN_DGTZ_SetRecordLength(handle, lenght);
}else{
setting[ch].recordLength = min((int)lenght, MaxRecordLength );
WriteRegister((uint32_t) RegisterDPP::RecordLength, setting[ch].recordLength, ch);
}
if( ret != 0 ) ErrorMsg("SetRecordLength");
}
void Digitizer::SetEventAggregation(unsigned int numEvent, int ch){
if( ch < 0 ){
for( int i = 0; i < MaxNChannels; i++ ) setting[i].EventAggr = numEvent;
ret |= CAEN_DGTZ_SetDPPEventAggregation(handle, numEvent, 0);
}else{
setting[ch].EventAggr = numEvent;
WriteRegister((uint32_t) RegisterDPP::NumberEventsPerAggregate, numEvent, ch);
}
if( ret != 0 ) ErrorMsg("SetEventAggregation");
}
void Digitizer::SetInputDynamicRange(unsigned int TwoVol_0_or_halfVol_1, int ch){
if( ch < 0 ) {
for( int i = 0; i < MaxNChannels; i++) setting[i].dynamicRange = TwoVol_0_or_halfVol_1;
}else{
setting[ch].dynamicRange = TwoVol_0_or_halfVol_1;
}
WriteRegister((uint32_t) Register::InputDynamicRange, TwoVol_0_or_halfVol_1, ch);
if( ret != 0 ) ErrorMsg("SetInputDynamicRange");
}
void Digitizer::SetNumSamplePreTrigger(unsigned int nSample, int ch){
if( ch < 0 ) {
for( int i = 0; i < MaxNChannels; i++) setting[i].preTrigger = nSample;
}else{
setting[ch].preTrigger = nSample;
}
WriteRegister((uint32_t) RegisterDPP::PreTrigger, nSample, ch);
if( ret != 0 ) ErrorMsg("SetNumSamplePreTrigger");
}
void Digitizer::SetDCOffset(float offsetPrecentage, int ch){
if( ch < 0 ) {
for( int i = 0; i < MaxNChannels; i++) setting[i].DCOffsetPrecentage = offsetPrecentage;
}else{
setting[ch].DCOffsetPrecentage = offsetPrecentage;
}
WriteRegister((uint32_t) RegisterDPP::ChannelDCOffset, uint( ADCFullSize * offsetPrecentage), ch );
if( ret != 0 ) ErrorMsg("SetDCOffset");
}
void Digitizer::SetVetoWidth(uint32_t bit, int ch){
if( ch < 0 ) {
for( int i = 0; i < MaxNChannels; i++) setting[i].VetoWidth = bit;
}else{
setting[ch].VetoWidth = bit;
}
WriteRegister((uint32_t) RegisterDPP::VetoWidth, bit, ch);
if( ret != 0 ) ErrorMsg("SetVetoWidth");
}
void Digitizer::SetTriggerPolarity(bool RiseingIsZero, int ch ){
if( ch < 0 ) {
ret = 0;
for (int i = 0; i < NChannel; i++){
setting[i].triggerPolarity = RiseingIsZero;
ret |= CAEN_DGTZ_SetTriggerPolarity(handle, i, CAEN_DGTZ_TriggerPolarity_t(RiseingIsZero));
}
}else{
setting[ch].triggerPolarity = RiseingIsZero;
ret = CAEN_DGTZ_SetTriggerPolarity(handle, ch, CAEN_DGTZ_TriggerPolarity_t(RiseingIsZero));
}
if( ret != 0 ) ErrorMsg("SetTriggerPolarity");
}
//============================== DPP-Alpgorthm Control
void Digitizer::SetDPPAlgorithmControl(uint32_t bit, bool useControl2, int ch){
///============= DPP algorithm control is 32 bit
/// [ 0: 5] Trapazoid Rescaling. the trapazoid ADC is 48 bit. it need to bit-shift before the 0x3FFF (14 bit filter)
/// [ 8: 9] Decimation. 00 = disable, 01 = 2 samples, 10 = 4 samples, 11 = 8 sample
/// [10:11] Decimation Gain. This gain apply to the Trapazoid Rescaling and fine gain
/// [12:13] Peak Mean. sample for averaging the trapezoid height calculation. 00 = 1 sample, 01 = 4 samples, 10 = 16 sample, 11 = 64 sample
/// [16] pulse polarity. 0 = positve, 1 = negative
/// [18:19] Trigger mode. 00 = normal, 01 = coincident, 10 = reserved. 11 = anti coincident
/// [20:22] number of samples for the baseline average calculation. 000 = baseline disable (energy not subtraced with baseline)
/// 001 = 16 samples
/// 010 = 64 samples
/// 011 = 256 samples
/// 100 = 1024 samples
/// 101 = 4096 samples
/// 110 = 16384 samples
/// 111 = resertved.
/// [24] Disable self trigger. 0 = selftrigger used to acquire and propagated to the trigger logic;
/// 1 = selftrigger only propagated to the trigger logic.
/// [26] Enable Roll-Over flag. see manual 0 = disable, 1 = enable
/// [27] Enable pile-up flag.
///============= PHA - DPP algorithm control 2 is 32 bit
/// [ 0: 1] Local Shaped Trigger mode. see manual
/// [ 2] Enable Local Shaped Trigger
/// [ 4: 5] Local Trigger Validation mode, see manual
/// [ 6] Enable Local Trigger Validation
/// [ 8:10] Extra 2 word option. 000 = [0:15] baseline *4 [16:31] extended time stamp
/// 001 = reserved
/// 010 = [0:15] fine time stamp [16:31] extended time stamp
/// 011 = reserved
/// 100 = [0:15] total tigger counter [16:31] Lost trigger counter
/// 101 = [0:15] event after the zero crosiing [16:31] event before zero crossing
/// 110, 111 = reserved.
/// [14:15] source of veto. 00 = disable, 01 veto is common to all channels, 10 = veto for coupled channels, 11 = veto comes from negative saturation
/// [16:17] Select the step for the trigger counter rate flag. see manual
/// [18] baseline calculation is active also when the acquisition is not running. 0 = disbale, 1 = enable
/// [19] Tag correlated events. see manual 0 = disbale, 1 = enable
/// [29] Enable the optimization of the Baseline Restorer to avoid tails in the energy peaks. 0 = disbale, 1 = enable
uint32_t address = (uint32_t) RegisterDPP::DPPAlgorithmControl;
if( useControl2 == true) {
if (DPPType == 0x88) address = (uint32_t) RegisterPSD::DPPAlgorithmControl2;
if (DPPType == 0x8B) address = (uint32_t) RegisterPHA::DPPAlgorithmControl2;
if (DPPType != 0x88 && DPPType != 0x8B ) {
printf(" DPP version is nto PSD or PHA, not supported. \n");
return;
}
}
if (ch < 0 ){
for( int i = 0; i < MaxNChannels; i++) setting[i].DPPAlgorithmControl = bit;
WriteRegister( address, bit);
}else{
setting[ch].DPPAlgorithmControl = bit;
WriteRegister( address, bit, ch);
}
if( ret != 0 ) ErrorMsg("SetDPPAlgorithmControl");
}
void Digitizer::SetDPPAlgorithmControlBit(unsigned int bitValue, unsigned int bitLength, unsigned int bitSmallestPos, bool useControl2, int ch){
uint32_t address = (uint32_t) RegisterDPP::DPPAlgorithmControl;
if( useControl2 == true){
if (DPPType == 0x88) address = (uint32_t) RegisterPSD::DPPAlgorithmControl2;
if (DPPType == 0x8B) address = (uint32_t) RegisterPHA::DPPAlgorithmControl2;
if (DPPType != 0x88 && DPPType != 0x8B ) {
printf(" DPP version is nto PSD or PHA, not supported. \n");
return;
}
}
uint32_t bit ;
uint32_t bitmask = (uint(pow(2, bitLength)-1) << bitSmallestPos);
if (ch < 0 ){
/// take ch-0
bit = ReadRegister(address, 0);
bit = (bit & ~bitmask) | (bitValue << bitSmallestPos);
for( int i = 0; i < MaxNChannels; i++) setting[i].DPPAlgorithmControl = bit;
}else{
bit = ReadRegister(address, ch);
bit = (bit & ~bitmask) | (bitValue << bitSmallestPos);
setting[ch].DPPAlgorithmControl = bit;
}
WriteRegister(address, bit, ch);
if( ret != 0 ) ErrorMsg("SetDPPAlgorithmControlBit");
}
void Digitizer::SetTrapezoidRescaling(unsigned int rightShiftBits, int ch ){
SetDPPAlgorithmControlBit(rightShiftBits, 5, 0, false, ch);
if( ret != 0 ) ErrorMsg("SetTrapezoidRescaling");
}
void Digitizer::SetPeakSampling(unsigned int bit, int ch){
if (ch < 0 ){
for( int i = 0; i < MaxNChannels; i++) setting[i].peakSampling = bit;
}else{
setting[ch].peakSampling = bit;
}
SetDPPAlgorithmControlBit(bit, 2, 12, false, ch);
if( ret != 0 ) ErrorMsg("SetPeakSampling");
}
void Digitizer::SetPulsePolarity(bool PositiveIsZero, int ch){
if (ch < 0 ){
for( int i = 0; i < MaxNChannels; i++) setting[i].pulsePolarity_DPP = PositiveIsZero;
}else{
setting[ch].pulsePolarity_DPP = PositiveIsZero;
}
SetDPPAlgorithmControlBit(PositiveIsZero, 1, 16, false, ch);
if( ret != 0 ) ErrorMsg("SetPulsePolarity");
}
void Digitizer::SetBaselineSampling(unsigned int bit, int ch){
if (ch < 0 ){
for( int i = 0; i < MaxNChannels; i++) setting[i].baselineSampling = bit;
}else{
setting[ch].baselineSampling = bit;
}
SetDPPAlgorithmControlBit(bit, 2, 20, false, ch);
if( ret != 0 ) ErrorMsg("SetBaselineSampling");
}
void Digitizer::SetRollOverFlag(bool isRollOver, int ch){
if (ch < 0 ){
for( int i = 0; i < MaxNChannels; i++) setting[i].rollOverFlag = isRollOver;
}else{
setting[ch].rollOverFlag = isRollOver;
}
SetDPPAlgorithmControlBit(isRollOver, 1, 26, false, ch);
if( ret != 0 ) ErrorMsg("SetRollOverFlag");
}
void Digitizer::SetPileUpFlag(bool isPileUpFlag, int ch){
if (ch < 0 ){
for( int i = 0; i < MaxNChannels; i++) setting[i].pileUpFlag = isPileUpFlag;
}else{
setting[ch].pileUpFlag = isPileUpFlag;
}
SetDPPAlgorithmControlBit(isPileUpFlag, 1, 27, false, ch);
if( ret != 0 ) ErrorMsg("SetPileUpFlag");
}
int Digitizer::SetAcqMode(string mode){
return ret;
}
int Digitizer::GetChTemperature(int ch){
if( BoardInfo.Model != CAEN_DGTZ_V1730 &&
BoardInfo.Model != CAEN_DGTZ_V1725 &&
BoardInfo.Model != CAEN_DGTZ_V1751 ) return -404;
uint32_t * temp;
ret |= CAEN_DGTZ_ReadTemperature(handle, ch, temp);
if( ret != 0 ) ErrorMsg("GetChTemperature");
return temp[0];
}
//################################################################
class DigitizerPHA : public Digitizer {
public:
DigitizerPHA();
DigitizerPHA(int boardID, int portID = 0);
~DigitizerPHA();
int ProgramBoard();
void GetChannelSetting(int ch);
};
DigitizerPHA::DigitizerPHA(){
}
DigitizerPHA::DigitizerPHA(int boardID, int portID){
OpenDigitizer(boardID, portID);
}
DigitizerPHA::~DigitizerPHA(){
}
int DigitizerPHA::ProgramBoard(){
/// Board Configuration for PHA
///bx0000 0000 0000 1110 0000 0001 0001 0100 =
/// | | |||| | | | | ||+- (0) automatic data flush, 0 = disable
/// | | |||| | | | | |+- (1) decimated smae of waveform, 0 = disable
/// | | |||| | | | | +- (2) trigger propagation, required in case of coincident trigger
/// | | |||| | | | +- (8) indivual trigger: must be 1
/// | | |||| | | + (11) dual trace. use 12:13 bit and 14:15 bit for choice of trace. but the trace recorded in half ADC frequency.
/// | | |||| | + (12:13) Analog Probe 1, 00 = input, 01 = input 1st derivative, 10 = input 2nd derivative, 11 = Trapezoid
/// | | |||| + (14:15) Analog Probe 2, 00 = input, 01 = threshold, 10 = Trapezoid - Baseline, 11 = baseline
/// | | |||+ (16) Waveform recording, 0 = disable, 1 = enable
/// | | ||+ (17) Enable Extra 2, i.e. 64 bit timestamp
/// | | |+ (18) time stamp recording: must be 1
/// | | + (19) peak recording: must be 1
/// | + (20:23) Digital Virtual probe 1: in mixed mode, virual probe can be enabled. See manual
/// + (26:28) Digitial Virtual probe 2
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t) Register::BoardConfiguration , 0x000E0114); /// Channel Control Reg (indiv trg, seq readout) ??
ErrorMsg("PHA-ProgramBoard");
return ret;
}
void DigitizerPHA::GetChannelSetting(int ch){
uint32_t * value = new uint32_t[NChannel];
printf("\e[33m================================================\n");
printf("================ Getting setting for channel %d \n", ch);
printf("================================================\e[0m\n");
///DPP algorithm Control
CAEN_DGTZ_ReadRegister(handle, 0x1080 + (ch << 8), value);
printf(" 32 28 24 20 16 12 8 4 0\n");
printf(" | | | | | | | | |\n");
cout <<" DPP algorithm Control : 0b" << bitset<32>(value[0]) << endl;
int trapRescaling = int(value[0]) & 31 ;
int polarity = int(value[0] >> 16); /// in bit[16]
int baseline = int(value[0] >> 20) ; /// in bit[22:20]
int NsPeak = int(value[0] >> 12); /// in bit[13:12]
///DPP algorithm Control 2
CAEN_DGTZ_ReadRegister(handle, 0x10A0 + (ch << 8), value);
cout <<" DPP algorithm Control 2: 0b" << bitset<32>(value[0]) << endl;
printf("* = multiple of 8 \n");
printf("** = multiple of 16 \n");
printf("==========----- input \n");
CAEN_DGTZ_ReadRegister(handle, 0x1020 + (ch << 8), value); printf("%20s %d ch \n", "Record Length", value[0] * 8); ///Record length
CAEN_DGTZ_ReadRegister(handle, 0x1038 + (ch << 8), value); printf("%20s %d ch \n", "Pre-tigger", value[0] * 4); ///Pre-trigger
printf("%20s %s \n", "polarity", (polarity & 1) == 0 ? "Positive" : "negative"); ///Polarity
printf("%20s %.0f sample \n", "Ns baseline", pow(4, 1 + baseline & 7)); ///Ns baseline
CAEN_DGTZ_ReadRegister(handle, 0x1098 + (ch << 8), value); printf("%20s %.2f %% of %d\n", "DC offset", value[0] * 100./ ADCFullSize, ADCFullSize); ///DC offset
CAEN_DGTZ_ReadRegister(handle, 0x1028 + (ch << 8), value); printf("%20s %.1f Vpp \n", "input Dynamic", value[0] == 0 ? 2 : 0.5); ///InputDynamic
printf("==========----- discriminator \n");
CAEN_DGTZ_ReadRegister(handle, 0x106C + (ch << 8), value); printf("%20s %d LSB\n", "Threshold", value[0]); ///Threshold
CAEN_DGTZ_ReadRegister(handle, 0x1074 + (ch << 8), value); printf("%20s %d ch \n", "trigger hold off *", value[0] * 8); ///Trigger Hold off
CAEN_DGTZ_ReadRegister(handle, 0x1054 + (ch << 8), value); printf("%20s %d sample \n", "Fast Dis. smoothing", value[0] ); ///Fast Discriminator smoothing
CAEN_DGTZ_ReadRegister(handle, 0x1058 + (ch << 8), value); printf("%20s %.1f ns \n", "Input rise time **", value[0] * 8 * ch2ns); ///Input rise time
printf("==========----- Trapezoid \n");
CAEN_DGTZ_ReadRegister(handle, 0x1080 + (ch << 8), value); printf("%20s %d bit = Floor( rise x decay / 64 )\n", "Trap. Rescaling", trapRescaling ); ///Trap. Rescaling Factor
CAEN_DGTZ_ReadRegister(handle, 0x105C + (ch << 8), value); printf("%20s %.1f ns \n", "Trap. rise time **", value[0] * 8 * ch2ns ); ///Trap. rise time, 2 for 1 ch to 2ns
CAEN_DGTZ_ReadRegister(handle, 0x1060 + (ch << 8), value);
int flatTopTime = value[0] * 8 * ch2ns; printf("%20s %d ns \n", "Trap. flat time **", flatTopTime); ///Trap. flat time
CAEN_DGTZ_ReadRegister(handle, 0x1068 + (ch << 8), value); printf("%20s %.1f ns \n", "Decay time **", value[0] * 8 * ch2ns); ///Trap. pole zero
CAEN_DGTZ_ReadRegister(handle, 0x1064 + (ch << 8), value); printf("%20s %.1f ns = %.2f %% \n", "peaking time **", value[0] * 8 * ch2ns, value[0] * 800. * ch2ns / flatTopTime ); //Peaking time
printf("%20s %.0f sample\n", "Ns peak", pow(4, NsPeak & 3)); //Ns peak
CAEN_DGTZ_ReadRegister(handle, 0x1078 + (ch << 8), value); printf("%20s %.1f ns \n", "Peak hole off **", value[0] * 8 *ch2ns ); ///Peak hold off
printf("==========----- Other \n");
CAEN_DGTZ_ReadRegister(handle, 0x10C4 + (ch << 8), value); printf("%20s %d \n", "Energy fine gain ?", value[0]); ///Energy fine gain
printf("========================================= end of ch-%d\n", ch);
}
//################################################################
class DigitizerPSD : public Digitizer {
public:
DigitizerPSD();
DigitizerPSD(int boardID, int portID = 0);
~DigitizerPSD();
//int ProgramBoard();
//
//void GetChannelSetting(int ch);
};
DigitizerPSD::DigitizerPSD(){
}
DigitizerPSD::DigitizerPSD(int boardID, int portID){
OpenDigitizer(boardID, portID);
}
DigitizerPSD::~DigitizerPSD(){
}
#endif #endif

173
DigitizerPHA.cpp Normal file
View File

@ -0,0 +1,173 @@
#include "DigitizerPHA.h"
DigitizerPHA::DigitizerPHA(){
}
DigitizerPHA::DigitizerPHA(int boardID, int portID){
OpenDigitizer(boardID, portID);
}
DigitizerPHA::~DigitizerPHA(){
}
int DigitizerPHA::ProgramBoard(){
/// Set trigger propagation
/// Set analog probe 1 to input
/// Set analog probe 2 to Tranpedoiz - Baseline
/// disable waveform recording
/// enable extrac 2 word
/// record time stamp
/// record energy
/// digitial virtual probe 1 = Peaking
/// digitial virtual probe 2 = trigger
ret |= CAEN_DGTZ_WriteRegister(handle, Register::BoardConfiguration , 0x000E8114); /// Channel Control Reg (indiv trg, seq readout) ??
ErrorMsg("PHA-ProgramBoard");
return ret;
}
void DigitizerPHA::SetAnalogProbe1(unsigned int bit) { SetBits(Register::BoardConfiguration, bit, 2, 12); ErrorMsg("PHA-SetAnalogProbe1"); }
void DigitizerPHA::SetAnalogProbe2(unsigned int bit) { SetBits(Register::BoardConfiguration, bit, 2, 14); ErrorMsg("PHA-SetAnalogProbe1"); }
void DigitizerPHA::SetWaveFormRecording(bool OnOff) { SetBits(Register::BoardConfiguration, OnOff, 1, 16); ErrorMsg("PHA-SetWaveFormRecording"); }
void DigitizerPHA::SetExtra2WordOutput(bool OnOff) { SetBits(Register::BoardConfiguration, OnOff, 1, 17); ErrorMsg("PHA-SetExtra2WordOutput");}
void DigitizerPHA::SetTimeStampRecording(bool OnOff) { SetBits(Register::BoardConfiguration, OnOff, 1, 18); ErrorMsg("PHA-SetTimeStampRecording"); }
void DigitizerPHA::SetEnergyRecording(bool OnOff) { SetBits(Register::BoardConfiguration, OnOff, 1, 19); ErrorMsg("PHA-SetEnergyRecording");}
void DigitizerPHA::SetVirtualProbe1(unsigned int bit){ SetBits(Register::BoardConfiguration, bit, 4, 20); ErrorMsg("PHA-SetVirtualProbe1"); }
void DigitizerPHA::SetTrapezoidRescaling(unsigned int rightShiftBits, int ch ){ SetBits(Register::DPP::DPPAlgorithmControl, rightShiftBits, 5, 0, ch); ErrorMsg("SetTrapezoidRescaling"); }
void DigitizerPHA::SetPeakSampling(unsigned int bit, int ch) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 2, 12, ch); ErrorMsg("SetPeakSampling");}
void DigitizerPHA::SetPulsePolarity(bool PositiveIsZero, int ch) { SetBits(Register::DPP::DPPAlgorithmControl, PositiveIsZero, 1, 16, ch); ErrorMsg("SetPulsePolarity");}
void DigitizerPHA::SetBaselineSampling(unsigned int bit, int ch) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 3, 20, ch); ErrorMsg("SetBaselineSampling"); }
void DigitizerPHA::SetRollOverFlag(bool isRollOver, int ch) { SetBits(Register::DPP::DPPAlgorithmControl, isRollOver, 1, 26, ch); ErrorMsg("SetRollOverFlag");}
void DigitizerPHA::SetPileUpFlag(bool isPileUpFlag, int ch) { SetBits(Register::DPP::DPPAlgorithmControl, isPileUpFlag, 1, 27, ch); ErrorMsg("SetPileUpFlag");}
void DigitizerPHA::SetExtra2WordOption(unsigned int bit, int ch) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2, bit, 3, 8, ch); ErrorMsg("PHA-SetExtra2WordOption");}
void DigitizerPHA::SetTriggerThreshold(unsigned int threshold, int ch ) { WriteRegister(Register::DPP::PHA::TriggerThreshold, threshold & 0x03FF, ch); ErrorMsg("PHA-SetTriggerThreshold");}
void DigitizerPHA::SetTriggerHoldOff(unsigned int nSample, int ch ) { WriteRegister(Register::DPP::PHA::TriggerHoldOffWidth, nSample & 0x03FF, ch); ErrorMsg("PHA-SetTriggerHoldOff"); }
void DigitizerPHA::SetTriggerSmoothingFactor(unsigned int bit, int ch ) { WriteRegister(Register::DPP::PHA::RCCR2SmoothingFactor, bit & 0x0001, ch); ErrorMsg("PHA-SetTriggerSmoothingFactor");}
void DigitizerPHA::SetInputRiseTime(unsigned int nSample, int ch ) { WriteRegister(Register::DPP::PHA::InputRiseTime, nSample & 0x00FF, ch); ErrorMsg("PHA-SetInputRiseTime");}
void DigitizerPHA::SetTrapezoidRiseTime(unsigned int nSample, int ch ) { WriteRegister(Register::DPP::PHA::TrapezoidRiseTime, nSample & 0x0FFF, ch); ErrorMsg("PHA-SetTrapezoidRiseTime");}
void DigitizerPHA::SetTrapezoidFlatTop(unsigned int nSample, int ch ) { WriteRegister(Register::DPP::PHA::TrapezoidFlatTop, nSample & 0x0FFF, ch); ErrorMsg("PHA-SetTrapezoidFlatTop");}
void DigitizerPHA::SetDecayTime(unsigned int nSample, int ch ) { WriteRegister(Register::DPP::PHA::DecayTime, nSample & 0xFFFF, ch); ErrorMsg("PHA-SetDecayTime");}
void DigitizerPHA::SetPeakingTime(unsigned int nSample, int ch ) { WriteRegister(Register::DPP::PHA::PeakingTime, nSample & 0x0FFF, ch); ErrorMsg("PHA-SetPeakingTime");}
void DigitizerPHA::SetPeakingHoldOff(unsigned int nSample, int ch ) { WriteRegister(Register::DPP::PHA::PeakHoldOff, nSample & 0x03FF, ch); ErrorMsg("PHA-SetPeakingHoldOff");}
void DigitizerPHA::SetEnergyFineGain(unsigned int gain, int ch ) { WriteRegister(Register::DPP::PHA::FineGain, gain & 0xFFFF, ch); ErrorMsg("PHA-SetEnergyFineGain");}
void DigitizerPHA::SetRiseTimeValidWindow(unsigned int nSample, int ch ){ WriteRegister(Register::DPP::PHA::RiseTimeValidationWindow,nSample & 0x03FF, ch); ErrorMsg("PHA-SetRiseTimeValidWindow");}
void DigitizerPHA::PrintBoardConfiguration(){
uint32_t * value = new uint32_t[1];
CAEN_DGTZ_ReadRegister(handle, (uint32_t) Register::BoardConfiguration, value);
printf(" 32 28 24 20 16 12 8 4 0\n");
printf(" | | | | | | | | |\n");
cout <<" Board Configuration : 0b" << bitset<32>(value[0]) << endl;
printf(" Bit[ 0] = Auto Data Flush \n");
printf(" Bit[ 1] = Save decimated waveform \n");
printf(" Bit[ 2] = Trigger propagation \n");
printf(" Bit[ 3:10] = must be 001 0001 0 \n");
printf(" Bit[ 11] = Dual Trace \n");
printf(" Bit[12:13] = Analog probe 1 : 00 = input, 01 = RC-CR (1st derivative), 10 = RC-CR2 (2nd derivative), 11 = Trapezoid.\n");
printf(" Bit[14:15] = Analog probe 2 : 00 = input, 01 = Threshold, 10 = Trapezoid - Baseline, 11 = baseline.\n");
printf(" Bit[ 16] = WaveForm Recording \n");
printf(" Bit[ 17] = Extras 2 word enable \n");
printf(" Bit[ 18] = Record Time Stamp \n");
printf(" Bit[ 19] = Record Energy \n");
printf(" Bit[20:23] = Digital Virtual probe 1 : \n");
printf(" 0000: Peaking, shows where the energy is calculated; \n");
printf(" 0001: ”Armed”, digital input showing where the RCCR2 crosses the Threshold\n");
printf(" 0010: ”Peak Run”, starts with the trigger and last for the whole event\n");
printf(" 0011: ”Pileup”, shows where a pileup event occurred\n");
printf(" 0100: ”Peaking”, shows where the energy is calculated\n");
printf(" 0101: ”TRG Validation Win”, digital input showing the trigger validation acceptance window TVAW\n");
printf(" 0110: ”Baseline freeze”, shows where the algorithm stops calculating the baseline and its value is frozen\n");
printf(" 0111: ”TRG Holdoff”, shows the trigger holdoff parameter\n");
printf(" 1000: ”TRG Validation”, shows the trigger validation signal TRG_VAL \n");
printf(" 1001: ”Acq Busy”, this is 1 when the board is busy (saturated input signal or full memory board) or there is a veto\n");
printf(" 1010: ”Zero Cross. Win.”, shows the RT Discrimination Width\n");
printf(" 1011: ”Ext TRG”, shows the external trigger, when available\n");
printf(" 1100: ”Busy”, shows when the memory board is full.\n");
printf(" Bit[26:28] = Digital Virtual probe 2 : \n");
printf(" 000: Trigger\n");
printf(" other: Reserved\n");
printf("====================================== \n");
}
void DigitizerPHA::GetChannelSettingFromDigitizer(int ch){
uint32_t * value = new uint32_t[NChannel];
printf("\e[33m================================================\n");
printf("================ Setting for channel %d \n", ch);
printf("================================================\e[0m\n");
///DPP algorithm Control
CAEN_DGTZ_ReadRegister(handle, Register::DPP::DPPAlgorithmControl + (ch << 8), value);
printf(" 32 28 24 20 16 12 8 4 0\n");
printf(" | | | | | | | | |\n");
cout <<" DPP algorithm Control : 0b" << bitset<32>(value[0]) << endl;
int trapRescaling = int(value[0]) & 0x1f ;
int polarity = int(value[0] >> 16) & 0x1; /// in bit[16]
int baseline = int(value[0] >> 20) & 0x7; /// in bit[22:20]
int NsPeak = int(value[0] >> 12) & 0x3; /// in bit[13:12]
int rollOver = int(value[0] >> 26) & 0x1;
int pileUp = int(value[0] >> 27) & 0x1;
///DPP algorithm Control 2
CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::DPPAlgorithmControl2 + (ch << 8), value);
cout <<" DPP algorithm Control 2: 0b" << bitset<32>(value[0]) << endl;
int extras2WordOption = int(value[0] >> 8) & 0x3;
string extra2WordOptStr = "";
switch (extras2WordOption){
case 0 : extra2WordOptStr = "[0:15] Baseline *4 [16:31] Extended Time Stamp"; break;
case 2 : extra2WordOptStr = "[0:15] Fine Time Stamp [16:31] Extended Time Stamp"; break;
case 4 : extra2WordOptStr = "[0:15] Total Trigger Counter [16:31] Lost Trigger Counter"; break;
case 5 : extra2WordOptStr = "[0:15] Event After the Zero Crossing [16:31] Event Before the Zero Crossing"; break;
default: extra2WordOptStr = "Reserved"; break;
}
printf(" ch2ns : %.0f ns\n", ch2ns);
printf("==========----- input \n");
CAEN_DGTZ_ReadRegister(handle, Register::DPP::RecordLength + (ch << 8), value); printf("%24s %5d samples \n", "Record Length", ((value[0] * 8) & MaxRecordLength)); ///Record length
CAEN_DGTZ_ReadRegister(handle, Register::DPP::PreTrigger + (ch << 8), value); printf("%24s %5d samples \n", "Pre-tigger", value[0] * 4); ///Pre-trigger
printf("%24s %5.0f samples, DPP-[20:22]\n", "baseline mean", pow(4, 1 + baseline)); ///Ns baseline
printf("%24s %s, DPP-[16]\n", "polarity", polarity == 0 ? "Positive" : "negative"); ///Polarity
CAEN_DGTZ_ReadRegister(handle, Register::DPP::ChannelDCOffset + (ch << 8), value); printf("%24s %.2f %% of %d\n", "DC offset", value[0] * 100./ ADCFullSize, ADCFullSize); ///DC offset
CAEN_DGTZ_ReadRegister(handle, Register::DPP::InputDynamicRange + (ch << 8), value); printf("%24s %.1f Vpp \n", "input Dynamic", value[0] == 0 ? 2 : 0.5); ///InputDynamic
printf("==========----- discriminator \n");
CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::TriggerThreshold + (ch << 8), value); printf("%24s %4d LSB\n", "Threshold", value[0]); ///Threshold
CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::TriggerHoldOffWidth + (ch << 8), value); printf("%24s %4d samples, %5.0f ns \n", "trigger hold off", value[0], value[0] * 4 * ch2ns); ///Trigger Hold off
CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::RCCR2SmoothingFactor + (ch << 8), value); printf("%24s %4d samples \n", "Fast Dis. smoothing", (value[0] & 0x1f) * 2 ); ///Fast Discriminator smoothing
CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::ShapedTriggerWidth + (ch << 8), value); printf("%24s %4d samples, %5.0f ns \n", "Fast Dis. output width", value[0], value[0] * 4 * ch2ns); ///Fast Dis. output width
CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::InputRiseTime + (ch << 8), value); printf("%24s %4d samples, %5.0f ns \n", "Input rise time ", value[0], value[0] * 4 * ch2ns); ///Input rise time
printf("==========----- Trapezoid \n");
printf("%24s %4d bit = Floor( rise x decay / 64 ), DPP-[0:5]\n", "Trap. Rescaling", trapRescaling ); ///Trap. Rescaling Factor
CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::TrapezoidRiseTime + (ch << 8), value); printf("%24s %4d samples, %5.0f ns \n", "Trap. rise time", value[0], value[0] * 4 * ch2ns); ///Trap. rise time, 2 for 1 ch to 2ns
CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::TrapezoidFlatTop + (ch << 8), value); printf("%24s %4d samples, %5.0f ns \n", "Trap. flat time", value[0], value[0] * 4 * ch2ns); ///Trap. flat time
int flatTopTime = value[0] * 4 * ch2ns;
CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::DecayTime + (ch << 8), value); printf("%24s %4d samples, %5.0f ns \n", "Decay time", value[0], value[0] * 4 * ch2ns); ///Trap. pole zero
CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::PeakingTime + (ch << 8), value); printf("%24s %4d samples, %5.0f ns = %.2f %% of FlatTop\n", "Peaking time", value[0], value[0] * 4 * ch2ns, value[0] * 400. * ch2ns / flatTopTime ); ///Peaking time
CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::PeakHoldOff + (ch << 8), value); printf("%24s %4d samples, %5.0f ns \n", "Peak hole off", value[0], value[0] * 4 *ch2ns ); ///Peak hold off
printf("%24s %4.0f samples, DPP-[12:13]\n", "Peak mean", pow(4, NsPeak)); ///Ns peak
printf("==========----- Other \n");
CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::FineGain + (ch << 8), value); printf("%24s %d \n", "Energy fine gain", value[0]); ///Energy fine gain
CAEN_DGTZ_ReadRegister(handle, Register::DPP::ChannelADCTemperature + (ch << 8), value); printf("%24s %d C\n", "Temperature", value[0]); ///Temperature
CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::RiseTimeValidationWindow + (ch << 8), value); printf("%24s %.0f ns \n", "RiseTime Vaild Win.", value[0] * ch2ns);
CAEN_DGTZ_ReadRegister(handle, Register::DPP::NumberEventsPerAggregate + (ch << 8), value); printf("%24s %d \n", "Event Aggregate", value[0] & 0x3FF);
CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::ChannelStopAcquisition + (ch << 8), value); printf("%24s %d = %s \n", "Stop Acq bit", value[0] & 1 , (value[0] & 1 ) == 0 ? "Run" : "Stop");
CAEN_DGTZ_ReadRegister(handle, Register::DPP::ChannelStatus + (ch << 8), value); printf("%24s 0x%x \n", "Status bit", (value[0] & 0xff) );
CAEN_DGTZ_ReadRegister(handle, Register::DPP::AMCFirmwareRevision + (ch << 8), value); printf("%24s 0x%x \n", "AMC firmware rev.", value[0] );
CAEN_DGTZ_ReadRegister(handle, Register::DPP::VetoWidth + (ch << 8), value); printf("%24s 0x%x \n", "VetoWidth bit", value[0] );
printf("%24s %d = %s\n", "RollOverFlag, DPP-[26]", rollOver, rollOver ? "enable" : "disable" );
printf("%24s %d = %s\n", "Pile-upFlag, DPP-[27]", pileUp, pileUp ? "enable" : "disable" );
printf("%24s %d, %s \n", "Extra2 opt, DPP2-[8:10]", extras2WordOption, extra2WordOptStr.c_str());
printf("========================================= end of ch-%d\n", ch);
}

50
DigitizerPHA.h Normal file
View File

@ -0,0 +1,50 @@
#ifndef DIGITIZER_PHA_H
#define DIGITIZER_PHA_H
#include "DigitizerClass.h"
class DigitizerPHA : public Digitizer {
public:
DigitizerPHA();
DigitizerPHA(int boardID, int portID = 0);
~DigitizerPHA();
int ProgramBoard();
void SetAnalogProbe1(unsigned int bit);
void SetAnalogProbe2(unsigned int bit);
void SetWaveFormRecording(bool OnOff);
void SetExtra2WordOutput(bool OnOff);
void SetTimeStampRecording(bool OnOff);
void SetEnergyRecording(bool OnOff);
void SetVirtualProbe1(unsigned int bit);
void SetTrapezoidRescaling(unsigned int rightShiftBits, int ch = -1); /// DPPAlgoritmControl bit-0:5
void SetPeakSampling(unsigned int bit, int ch = -1); /// DPPAlgoritmControl bit-10:11
void SetPulsePolarity(bool PositiveIsZero, int ch = -1); /// DPPAlgoritmControl bit-16
void SetBaselineSampling(unsigned int bit, int ch = -1); /// DPPAlgoritmControl bit-20:22
void SetRollOverFlag(bool isRollOver, int ch = -1); /// DPPAlgoritmControl bit-26
void SetPileUpFlag(bool isPileUpFlag, int ch = -1); /// DPPAlgoritmControl bit-27
void SetExtra2WordOption(unsigned int bit, int ch = -1);
void SetTriggerThreshold(unsigned int threshold, int ch = -1 );
void SetTriggerHoldOff(unsigned int nSample, int ch = -1 );
void SetTriggerSmoothingFactor(unsigned int bit, int ch = -1 );
void SetInputRiseTime(unsigned int nSample, int ch = -1);
void SetTrapezoidRiseTime(unsigned int nSample, int ch = -1 );
void SetTrapezoidFlatTop(unsigned int nSample, int ch = -1 );
void SetDecayTime(unsigned int nSample, int ch = -1 );
void SetPeakingTime(unsigned int nSample, int ch = -1 );
void SetPeakingHoldOff(unsigned int nSample, int ch = -1 );
void SetEnergyFineGain(unsigned int gain, int ch = -1 );
void SetRiseTimeValidWindow(unsigned int nSample, int ch = -1 );
void PrintBoardConfiguration();
void GetChannelSettingFromDigitizer(int ch);
};
#endif

14
DigitizerPSD.cpp Normal file
View File

@ -0,0 +1,14 @@
#include "DigitizerPSD.h"
DigitizerPSD::DigitizerPSD(){
}
DigitizerPSD::DigitizerPSD(int boardID, int portID){
OpenDigitizer(boardID, portID);
}
DigitizerPSD::~DigitizerPSD(){
}

18
DigitizerPSD.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef DIGITIZER_PSD_H
#define DIGITIZER_PSD_H
#include "DigitizerClass.h"
class DigitizerPSD : public Digitizer {
public:
DigitizerPSD();
DigitizerPSD(int boardID, int portID = 0);
~DigitizerPSD();
//int ProgramBoard();
//
//void GetChannelSetting(int ch);
};
#endif

248
FSUDAQ.cpp Normal file
View File

@ -0,0 +1,248 @@
#include <TApplication.h>
#include <TGClient.h>
#include <TCanvas.h>
#include <TF1.h>
#include <TRandom.h>
#include <TGButton.h>
#include <TRootEmbeddedCanvas.h>
#include <TGMenu.h>
#include <TGLabel.h>
#include <TGNumberEntry.h>
#include <TGraph.h>
#include <TAxis.h>
#include <TF1.h>
#include <unistd.h>
#include <ctime>
#include "DigitizerPHA.h"
#include "DigitizerPSD.h"
#include "FSUDAQ.h"
enum MenuIdentifiers{
M_FILE_OPEN,
M_EXIT,
M_CH_SETTINGS_SUMMARY,
M_CH_SETTING,
M_MODULE_SETTINGS,
M_PROGRAM_SETTINGS,
M_FINDPEAKS,
M_SHOW_CHANNELS_RATE
};
//TODO timed Run, //pixie->SetDigitizerPresetRunTime(100000, 0);
///make static members
DigitizerPHA * MainWindow::digi = NULL;
TGTextEdit * MainWindow::teLog = NULL;
TRootEmbeddedCanvas * MainWindow::fEcanvas = NULL;
MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
digi = new DigitizerPHA(0,0);
/// Create a main frame
fMain = new TGMainFrame(p,w,h);
///fMain->SetWMPosition(500, 500); //does not work
fMain->Connect("CloseWindow()", "MainWindow", this, "GoodBye()");
///======================= menu
fMenuBar = new TGMenuBar(fMain, 1, 1, kHorizontalFrame);
fMain->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
fMenuFile = new TGPopupMenu(gClient->GetRoot());
fMenuFile->AddEntry("&Open Pixie16.config", M_FILE_OPEN);
fMenuFile->AddSeparator();
fMenuFile->AddEntry("E&xit", M_EXIT);
fMenuFile->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
fMenuSettings = new TGPopupMenu(gClient->GetRoot());
fMenuSettings->AddEntry("&Settings Summary", M_CH_SETTINGS_SUMMARY);
fMenuSettings->AddEntry("&Channel Setting", M_CH_SETTING);
fMenuSettings->AddSeparator();
fMenuSettings->AddEntry("&Digitizer Settings", M_MODULE_SETTINGS);
fMenuSettings->AddSeparator();
fMenuSettings->AddEntry("Program Settings", M_PROGRAM_SETTINGS);
fMenuSettings->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
fMenuBar->AddPopup("&Settings", fMenuSettings, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
fMenuUtility = new TGPopupMenu(gClient->GetRoot());
fMenuUtility->AddEntry("Plot Channels Rate", M_SHOW_CHANNELS_RATE);
fMenuSettings->AddSeparator();
fMenuUtility->AddEntry("Find &Peaks", M_FINDPEAKS);
fMenuUtility->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
fMenuBar->AddPopup("&Utility", fMenuUtility, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
TGLayoutHints * uniLayoutHints = new TGLayoutHints(kLHintsNormal, 2,2,10,0); ///left, right, top, bottom
/// Create a horizontal frame widget with buttons
TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain,200,40);
fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));
///================= signal Channel group
TGGroupFrame * group1 = new TGGroupFrame(hframe, "Single Channel", kHorizontalFrame);
hframe->AddFrame(group1 );
TGHorizontalFrame *hframe1 = new TGHorizontalFrame(group1,200,30);
group1->AddFrame(hframe1 );
///================= Create canvas widget
fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fMain,900,400);
fMain->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,10));
///================= Log massage
TGGroupFrame * groupLog = new TGGroupFrame(fMain, "Log Message", kHorizontalFrame);
fMain->AddFrame(groupLog, new TGLayoutHints(kLHintsCenterX, 5,5,0,5) );
teLog = new TGTextEdit(groupLog, w, 100);
groupLog->AddFrame(teLog, new TGLayoutHints(kLHintsNormal, 0,0,10,0));
/// Set a name to the main frame
fMain->SetWindowName("Pixie16 DAQ");
/// Map all subwindows of main frame
fMain->MapSubwindows();
/// Initialize the layout algorithm
fMain->Resize(fMain->GetDefaultSize());
fMain->SetWMPosition(200, 200); //does not work??
/// Map main frame
fMain->MapWindow();
/// setup thread
//saveDataThread = new TThread("hahaha", SaveData, (void *) 1);
//fillHistThread = new TThread("kakaka", FillHistogram, (void *) 1);
///settingsSummary = NULL;
///moduleSetting = NULL;
///channelSetting = NULL;
///scalarPanel = NULL;
///bStopRun->SetEnabled(false);
LogMsg("Boot OK and ready to run.");
///HandleMenu(M_CH_SETTINGS_SUMMARY);
}
MainWindow::~MainWindow() {
delete fMenuBar;
delete fMenuFile;
delete fMenuSettings;
delete fMenuUtility;
//delete modIDEntry;
//delete chEntry;
//delete tePath;
delete teLog;
//delete bStartRun;
//delete bStopRun;
//delete bFitTrace;
delete digi;
//delete settingsSummary;
//delete moduleSetting;
//delete channelSetting;
//delete scalarPanel;
//
//delete saveDataThread;
//delete fillHistThread;
//
//delete gTrace;
//
//delete configEditor;
/// Clean up used widgets: frames, buttons, layout hints
fMain->Cleanup();
delete fMain;
}
void MainWindow::HandleMenu(Int_t id){
switch(id){
///========================= File Open
case M_FILE_OPEN:{
}break;
///========================= Exit
case M_EXIT: GoodBye(); break;
///========================= Channel setting summary
case M_CH_SETTINGS_SUMMARY: {
}break;
case M_CH_SETTING:{
}break;
///========================= Module setting
case M_MODULE_SETTINGS:{
}break;
///========================= Program setting
case M_PROGRAM_SETTINGS:{
LogMsg("[Program settings] Not impelmented");
}break;
///====================== Show channel rate;
case M_SHOW_CHANNELS_RATE:{
}break;
///====================== Fit Gaussian
case M_FINDPEAKS:{
LogMsg("[Find Peaks] Not impelmented");
}break;
}
}
Double_t standardPulse(Double_t *x, Double_t * par){
/// par[0] = start time
/// par[1] = rise time
/// par[2] = decay time
/// par[3] = amplitude
/// par[4] = baseline
Double_t z = x[0] - par[0];
if( z <= 0 ) {
return par[4];
}else{
return par[3]*(1-TMath::Exp(-1*z/par[1]))*TMath::Exp(-1*z/par[2]) + par[4];
}
}
void MainWindow::GoodBye(){
//pixie->CloseDigitizers();
printf("----- bye bye ---- \n");
gApplication->Terminate(0);
}
void MainWindow::LogMsg(TString msg){
time_t now = time(0);
tm * ltm = localtime(&now);
int year = 1900 + ltm->tm_year;
int month = 1 + ltm->tm_mon;
int day = ltm->tm_mday;
int hour = ltm->tm_hour;
int minute = ltm->tm_min;
int secound = ltm->tm_sec;
teLog->AddLine(Form("[%4d-%02d-%02d %02d:%02d:%02d] ", year, month, day, hour, minute, secound) + msg);
teLog->LineDown();
teLog->ShowBottom();
}
//############################################
int main(int argc, char **argv) {
printf(" Welcome to pixie16 DQ \n");
TApplication theApp("App",&argc,argv);
new MainWindow(gClient->GetRoot(),800,800);
theApp.Run();
return 0;
}

79
FSUDAQ.h Normal file
View File

@ -0,0 +1,79 @@
#include <TQObject.h>
#include <RQ_OBJECT.h>
#include <TROOT.h>
#include <TClass.h>
#include <TGClient.h>
#include <TGMenu.h>
#include <TGTextEdit.h>
#include <TThread.h>
#include <TH1F.h>
#include <TGraph.h>
#include <TBenchmark.h>
#include <TGTextEditor.h>
#include "CAENDigitizer.h"
#include "DigitizerPHA.h"
#include "DigitizerPSD.h"
///#include "global_macro.h"
///#include "settingsSummary.h"
///#include "scalarPanel.h"
///#include "moduleSetting.h"
///#include "channelSetting.h"
class TGWindow;
class TGMainFrame;
class TRootEmbeddedCanvas;
class TGNumberEntry;
class MainWindow{
RQ_OBJECT("MainWindow")
private:
TGMainFrame *fMain;
static TRootEmbeddedCanvas *fEcanvas;
TGMenuBar *fMenuBar;
TGPopupMenu *fMenuFile, *fMenuSettings, *fMenuUtility;
//
//static TGNumberEntry * modIDEntry, *chEntry;
//TGNumberEntry * runIDEntry;
//TGTextEntry * tePath;
//
static TGTextEdit * teLog;
//
//TGTextButton *bStartRun;
//TGTextButton *bStopRun;
//TGTextButton *bFitTrace;
static DigitizerPHA * digi;
//
//SettingsSummary * settingsSummary;
//ModuleSetting * moduleSetting;
//ChannelSetting * channelSetting;
//ScalarPanel * scalarPanel;
//
//TThread * saveDataThread;
//TThread * fillHistThread;
//static TH1F * hEnergy[MAXMOD][MAXCH];
//static TH1F * hChannel[MAXMOD];
//static bool isEnergyHistFilled;
//TGraph * gTrace;
//
//TGTextEditor * configEditor;
public:
MainWindow(const TGWindow *p, UInt_t w, UInt_t h);
virtual ~MainWindow();
void HandleMenu(Int_t id);
//void GetADCTrace();
//void GetBaseLine();
//void Scope();
//void FitTrace();
//void StartRun();
//static void * SaveData(void* ptr ); /// thread
//void StopRun();
//void OpenScalar();
//static void * FillHistogram(void * ptr); /// thread
//void ChangeMod();
//void ChangeChannel();
void LogMsg(TString msg);
void GoodBye();
};

149
FSUDAQDict.cxx Normal file
View File

@ -0,0 +1,149 @@
// Do NOT change. Changes will be lost next time file is generated
#define R__DICTIONARY_FILENAME FSUDAQDict
#define R__NO_DEPRECATION
/*******************************************************************/
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define G__DICTIONARY
#include "RConfig.h"
#include "TClass.h"
#include "TDictAttributeMap.h"
#include "TInterpreter.h"
#include "TROOT.h"
#include "TBuffer.h"
#include "TMemberInspector.h"
#include "TInterpreter.h"
#include "TVirtualMutex.h"
#include "TError.h"
#ifndef G__ROOT
#define G__ROOT
#endif
#include "RtypesImp.h"
#include "TIsAProxy.h"
#include "TFileMergeInfo.h"
#include <algorithm>
#include "TCollectionProxyInfo.h"
/*******************************************************************/
#include "TDataMember.h"
// Header files passed as explicit arguments
#include "FSUDAQ.h"
// Header files passed via #pragma extra_include
// The generated code does not explicitly qualify STL entities
namespace std {} using namespace std;
namespace ROOT {
static TClass *MainWindow_Dictionary();
static void MainWindow_TClassManip(TClass*);
static void delete_MainWindow(void *p);
static void deleteArray_MainWindow(void *p);
static void destruct_MainWindow(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const ::MainWindow*)
{
::MainWindow *ptr = nullptr;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(::MainWindow));
static ::ROOT::TGenericClassInfo
instance("MainWindow", "FSUDAQ.h", 25,
typeid(::MainWindow), ::ROOT::Internal::DefineBehavior(ptr, ptr),
&MainWindow_Dictionary, isa_proxy, 0,
sizeof(::MainWindow) );
instance.SetDelete(&delete_MainWindow);
instance.SetDeleteArray(&deleteArray_MainWindow);
instance.SetDestructor(&destruct_MainWindow);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const ::MainWindow*)
{
return GenerateInitInstanceLocal((::MainWindow*)nullptr);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal((const ::MainWindow*)nullptr); R__UseDummy(_R__UNIQUE_DICT_(Init));
// Dictionary for non-ClassDef classes
static TClass *MainWindow_Dictionary() {
TClass* theClass =::ROOT::GenerateInitInstanceLocal((const ::MainWindow*)nullptr)->GetClass();
MainWindow_TClassManip(theClass);
return theClass;
}
static void MainWindow_TClassManip(TClass* ){
}
} // end of namespace ROOT
namespace ROOT {
// Wrapper around operator delete
static void delete_MainWindow(void *p) {
delete ((::MainWindow*)p);
}
static void deleteArray_MainWindow(void *p) {
delete [] ((::MainWindow*)p);
}
static void destruct_MainWindow(void *p) {
typedef ::MainWindow current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class ::MainWindow
namespace {
void TriggerDictionaryInitialization_FSUDAQDict_Impl() {
static const char* headers[] = {
"FSUDAQ.h",
nullptr
};
static const char* includePaths[] = {
"/home/splitpole/cern/root/include/",
"/home/splitpole/FSUDAQ/",
nullptr
};
static const char* fwdDeclCode = R"DICTFWDDCLS(
#line 1 "FSUDAQDict dictionary forward declarations' payload"
#pragma clang diagnostic ignored "-Wkeyword-compat"
#pragma clang diagnostic ignored "-Wignored-attributes"
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
extern int __Cling_AutoLoading_Map;
class __attribute__((annotate("$clingAutoload$FSUDAQ.h"))) MainWindow;
)DICTFWDDCLS";
static const char* payloadCode = R"DICTPAYLOAD(
#line 1 "FSUDAQDict dictionary payload"
#define _BACKWARD_BACKWARD_WARNING_H
// Inline headers
#include "FSUDAQ.h"
#undef _BACKWARD_BACKWARD_WARNING_H
)DICTPAYLOAD";
static const char* classesHeaders[] = {
"MainWindow", payloadCode, "@",
nullptr
};
static bool isInitialized = false;
if (!isInitialized) {
TROOT::RegisterModule("FSUDAQDict",
headers, includePaths, payloadCode, fwdDeclCode,
TriggerDictionaryInitialization_FSUDAQDict_Impl, {}, classesHeaders, /*hasCxxModule*/false);
isInitialized = true;
}
}
static struct DictInit {
DictInit() {
TriggerDictionaryInitialization_FSUDAQDict_Impl();
}
} __TheDictionaryInitializer;
}
void TriggerDictionaryInitialization_FSUDAQDict() {
TriggerDictionaryInitialization_FSUDAQDict_Impl();
}

BIN
FSUDAQDict_rdict.pcm Normal file

Binary file not shown.

1
FSUDAQLinkDef.h Normal file
View File

@ -0,0 +1 @@
#pragma link C++ class MainWindow;

View File

@ -1,35 +1,50 @@
######################################################################## ########################################################################
# #
## --- CAEN SpA - Computing Division ---
#
## CAENDigitizer Software Project
#
## Created : October 2009 (Rel. 1.0)
#
## Auth: A. Lucchesi
# #
######################################################################### #########################################################################
ARCH = `uname -m`
CC = g++ CC = g++
COPTS = -fPIC -DLINUX -w COPTS = -fPIC -DLINUX -O2 -std=c++17 -lpthread
DEPLIBS = -lCAENDigitizer CAENLIBS = -lCAENDigitizer
ROOTLIBS = `root-config --cflags --glibs` ROOTLIBS = `root-config --cflags --glibs`
OBJS = DigitizerClass.o DigitizerPHA.o DigitizerPSD.o FSUDAQ.o
######################################################################### #########################################################################
all : test all : test
#clean : clean :
# /bin/rm -f $(OBJS1) $(OBJS2) $(OUT2) ./CutsCreator ./BoxScore ./BoxScoreReader /bin/rm -f $(OBJS) test FSUDAQ FSUDAQDict.cxx *.pcm
test : test.cpp DigitizerClass.h DigitizerClass.o : DigitizerClass.cpp DigitizerClass.h RegisterAddress.h
$(CC) -o test test.cpp $(DEPLIBS) $(CC) $(COPTS) -c DigitizerClass.cpp
DigitizerPHA.o : DigitizerPHA.cpp DigitizerPHA.h DigitizerClass.o
$(CC) $(COPTS) -c DigitizerPHA.cpp
DigitizerPSD.o : DigitizerPSD.cpp DigitizerPSD.h DigitizerClass.o
$(CC) $(COPTS) -c DigitizerPSD.cpp
test : test.cpp DigitizerClass.o DigitizerPHA.o DigitizerPSD.o
$(CC) $(COPTS) -o test test.cpp DigitizerClass.o DigitizerPHA.o DigitizerPSD.o $(CAENLIBS)
FSUDAQDict.cxx : FSUDAQ.h FSUDAQLinkDef.h
@echo "----------- creating pcm and cxx for root"
@rootcling -f FSUDAQDict.cxx -c FSUDAQ.h -p FSUDAQLinkDef.h $(CAENLIBS)
FSUDAQ.o : FSUDAQ.h FSUDAQ.cpp FSUDAQDict.cxx
@echo "----------- creating FSUDAQ.o"
$(CC) $(COPTS) -c FSUDAQ.cpp DigitizerClass.cpp DigitizerPHA.cpp DigitizerPSD.cpp $(ROOTLIBS)
FSUDAQ : FSUDAQDict.cxx $(OBJS)
@echo "----------- creating FSUDAQ"
$(CC) $(COPTS) FSUDAQDict.cxx $(OBJS) -o FSUDAQ $(CAENLIBS) $(ROOTLIBS)
#CutsCreator: $(OBJS3) src/CutsCreator.c #CutsCreator: $(OBJS3) src/CutsCreator.c
# g++ -std=c++17 -pthread src/CutsCreator.c -o CutsCreator $(ROOTLIBS) # g++ -std=c++17 -pthread src/CutsCreator.c -o CutsCreator $(ROOTLIBS)

View File

@ -1,155 +1,158 @@
#ifndef REGISTERADDRESS_H #ifndef REGISTERADDRESS_H
#define REGISTERADDRESS_H #define REGISTERADDRESS_H
enum class Register : uint32_t {
namespace Register {
static uint32_t EventReadOutBuffer = 0x0000; /// R
EventReadOutBuffer = 0x0000, /// R
///========== Channel or Group ///========== Channel or Group
ChannelDummy32 = 0x1024, /// R/W static uint32_t ChannelDummy32 = 0x1024; /// R/W
InputDynamicRange = 0x1028, /// R/W static uint32_t InputDynamicRange = 0x1028; /// R/W
ChannelPulseWidth = 0x1070, /// R/W static uint32_t ChannelPulseWidth = 0x1070; /// R/W
ChannelTriggerThreshold = 0x1080, /// R/W static uint32_t ChannelTriggerThreshold = 0x1080; /// R/W
CoupleSelfTriggerLogic = 0x1084, /// R/W static uint32_t CoupleSelfTriggerLogic = 0x1084; /// R/W
ChannelStatus = 0x1088, /// R static uint32_t ChannelStatus = 0x1088; /// R
AMCFirmwareRevision = 0x108C, /// R static uint32_t AMCFirmwareRevision = 0x108C; /// R
ChannelDCOffset = 0x1098, /// R/W static uint32_t ChannelDCOffset = 0x1098; /// R/W
ChannelADCTemperature = 0x10A8, /// R static uint32_t ChannelADCTemperature = 0x10A8; /// R
ChannelSelfTriggerRateMeter = 0x10EC, /// R static uint32_t ChannelSelfTriggerRateMeter = 0x10EC; /// R
///========== Board ///========== Board
BoardConfiguration = 0x8000, /// R/W static uint32_t BoardConfiguration = 0x8000; /// R/W
BufferOrganization = 0x800C, /// R/W static uint32_t BufferOrganization = 0x800C; /// R/W
CustomSize = 0x8020, /// R/W static uint32_t CustomSize = 0x8020; /// R/W
ADCCalibration = 0x809C, /// W static uint32_t ADCCalibration = 0x809C; /// W
AcquisitionControl = 0x8100, /// R/W static uint32_t AcquisitionControl = 0x8100; /// R/W
AcquisitionStatus = 0x8104, /// R static uint32_t AcquisitionStatus = 0x8104; /// R
SoftwareTrigger = 0x8108, /// W static uint32_t SoftwareTrigger = 0x8108; /// W
GlobalTriggerMask = 0x810C, /// R/W static uint32_t GlobalTriggerMask = 0x810C; /// R/W
FrontPanelTRGOUTEnableMask = 0x8110, /// R/W static uint32_t FrontPanelTRGOUTEnableMask = 0x8110; /// R/W
PostTrigger = 0x8114, /// R/W static uint32_t PostTrigger = 0x8114; /// R/W
LVDSIOData = 0x8118, /// R/W static uint32_t LVDSIOData = 0x8118; /// R/W
FrontPanelIOControl = 0x811C, /// R/W static uint32_t FrontPanelIOControl = 0x811C; /// R/W
ChannelEnableMask = 0x8120, /// R/W static uint32_t ChannelEnableMask = 0x8120; /// R/W
ROCFPGAFirmwareRevision = 0x8124, /// R static uint32_t ROCFPGAFirmwareRevision = 0x8124; /// R
EventStored = 0x812C, /// R static uint32_t EventStored = 0x812C; /// R
VoltageLevelModeConfig = 0x8138, /// R/W static uint32_t VoltageLevelModeConfig = 0x8138; /// R/W
SoftwareClockSync = 0x813C, /// W static uint32_t SoftwareClockSync = 0x813C; /// W
BoardInfo = 0x8140, /// R static uint32_t BoardInfo = 0x8140; /// R
AnalogMonitorMode = 0x8144, /// R/W static uint32_t AnalogMonitorMode = 0x8144; /// R/W
EventSize = 0x814C, /// R static uint32_t EventSize = 0x814C; /// R
FanSpeedControl = 0x8168, /// R/W static uint32_t FanSpeedControl = 0x8168; /// R/W
MemoryBufferAlmostFullLevel = 0x816C, /// R/W static uint32_t MemoryBufferAlmostFullLevel = 0x816C; /// R/W
RunStartStopDelay = 0x8170, /// R/W static uint32_t RunStartStopDelay = 0x8170; /// R/W
BoardFailureStatus = 0x8178, /// R static uint32_t BoardFailureStatus = 0x8178; /// R
FrontPanelLVDSIONewFeatures = 0x81A0, /// R/W static uint32_t FrontPanelLVDSIONewFeatures = 0x81A0; /// R/W
BufferOccupancyGain = 0x81B4, /// R/W static uint32_t BufferOccupancyGain = 0x81B4; /// R/W
ChannelsShutdown = 0x81C0, /// W static uint32_t ChannelsShutdown = 0x81C0; /// W
ExtendedVetoDelay = 0x81C4, /// R/W static uint32_t ExtendedVetoDelay = 0x81C4; /// R/W
ReadoutControl = 0xEF00, /// R/W static uint32_t ReadoutControl = 0xEF00; /// R/W
ReadoutStatus = 0xEF04, /// R static uint32_t ReadoutStatus = 0xEF04; /// R
BoardID = 0xEF08, /// R/W static uint32_t BoardID = 0xEF08; /// R/W
MCSTBaseAddressAndControl = 0xEF0C, /// R/W static uint32_t MCSTBaseAddressAndControl = 0xEF0C; /// R/W
RelocationAddress = 0xEF10, /// R/W static uint32_t RelocationAddress = 0xEF10; /// R/W
InterruptStatusID = 0xEF14, /// R/W static uint32_t InterruptStatusID = 0xEF14; /// R/W
InterruptEventNumber = 0xEF18, /// R/W static uint32_t InterruptEventNumber = 0xEF18; /// R/W
MaxNumberOfEventsPerBLT = 0xEF1C, /// R/W static uint32_t MaxNumberOfEventsPerBLT = 0xEF1C; /// R/W
Scratch = 0xEF20, /// R/W static uint32_t Scratch = 0xEF20; /// R/W
SoftwareReset = 0xEF24, /// W static uint32_t SoftwareReset = 0xEF24; /// W
SoftwareClear = 0xEF28 /// W static uint32_t SoftwareClear = 0xEF28; /// W
};
///====== Common for PHA and PSD ///====== Common for PHA and PSD
enum class RegisterDPP : uint32_t { namespace DPP {
static uint32_t RecordLength = 0x1020; /// R/W
static uint32_t InputDynamicRange = 0x1028; /// R/W
static uint32_t NumberEventsPerAggregate = 0x1034; /// R/W
static uint32_t PreTrigger = 0x1038; /// R/W
static uint32_t TriggerThreshold = 0x106C; /// R/W
static uint32_t TriggerHoldOffWidth = 0x1074; /// R/W
static uint32_t DPPAlgorithmControl = 0x1080; /// R/W
static uint32_t ChannelStatus = 0x1088; /// R
static uint32_t AMCFirmwareRevision = 0x108C; /// R
static uint32_t ChannelDCOffset = 0x1098; /// R/W
static uint32_t ChannelADCTemperature = 0x10A8; /// R
static uint32_t IndividualSoftwareTrigger = 0x10C0; /// W
static uint32_t VetoWidth = 0x10D4; /// R/W
static uint32_t BoardConfiguration = 0x8000; /// R/W
static uint32_t AggregateOrganization = 0x800C; /// R/W
static uint32_t ADCCalibration = 0x809C; /// W
static uint32_t ChannelShutdown = 0x80BC; /// W
static uint32_t AcquisitionControl = 0x8100; /// R/W
static uint32_t AcquisitionStatus = 0x8104; /// R
static uint32_t SoftwareTrigger = 0x8108; /// W
static uint32_t GlobalTriggerMask = 0x810C; /// R/W
static uint32_t FrontPanelTRGOUTEnableMask = 0x8110; /// R/W
static uint32_t LVDSIOData = 0x8118; /// R/W
static uint32_t FrontPanelIOControl = 0x811C; /// R/W
static uint32_t ChannelEnableMask = 0x8120; /// R/W
static uint32_t ROCFPGAFirmwareRevision = 0x8124; /// R
static uint32_t EventStored = 0x812C; /// R
static uint32_t VoltageLevelModeConfig = 0x8138; /// R/W
static uint32_t SoftwareClockSync = 0x813C; /// W
static uint32_t BoardInfo = 0x8140; /// R
static uint32_t AnalogMonitorMode = 0x8144; /// R/W
static uint32_t EventSize = 0x814C; /// R
static uint32_t TimeBombDowncounter = 0x8158; /// R
static uint32_t FanSpeedControl = 0x8168; /// R/W
static uint32_t RunStartStopDelay = 0x8170; /// R/W
static uint32_t BoardFailureStatus = 0x8178; /// R
static uint32_t DisableExternalTrigger = 0x817C; /// R/W
static uint32_t TriggerValidationMask = 0x8180; /// R/W, 0x8180 + 4n
static uint32_t FrontPanelLVDSIONewFeatures = 0x81A0; /// R/W
static uint32_t BufferOccupancyGain = 0x81B4; /// R/W
static uint32_t ExtendedVetoDelay = 0x81C4; /// R/W
static uint32_t ReadoutControl = 0xEF00; /// R/W
static uint32_t ReadoutStatus = 0xEF04; /// R
static uint32_t BoardID = 0xEF08; /// R/W
static uint32_t MCSTBaseAddressAndControl = 0xEF0C; /// R/W
static uint32_t RelocationAddress = 0xEF10; /// R/W
static uint32_t InterruptStatusID = 0xEF14; /// R/W
static uint32_t InterruptEventNumber = 0xEF18; /// R/W
static uint32_t MaxNumberOfEventsPerBLT = 0xEF1C; /// R/W
static uint32_t Scratch = 0xEF20; /// R/W
static uint32_t SoftwareReset = 0xEF24; /// W
static uint32_t SoftwareClear = 0xEF28; /// W
RecordLength = 0x1020, /// R/W
InputDynamicRange = 0x1028, /// R/W
NumberEventsPerAggregate = 0x1034, /// R/W
PreTrigger = 0x1038, /// R/W
TriggerThreshold = 0x106C, /// R/W
TriggerHoldOffWidth = 0x1074, /// R/W
DPPAlgorithmControl = 0x1080, /// R/W
ChannelStatus = 0x1088, /// R
AMCFirmwareRevision = 0x108C, /// R
ChannelDCOffset = 0x1098, /// R/W
ChannelADCTemperature = 0x10A8, /// R
IndividualSoftwareTrigger = 0x10C0, /// W
VetoWidth = 0x10D4, /// R/W
BoardConfiguration = 0x8000, /// R/W
AggregateOrganization = 0x800C, /// R/W
ADCCalibration = 0x809C, /// W
ChannelShutdown = 0x80BC, /// W
AcquisitionControl = 0x8100, /// R/W
AcquisitionStatus = 0x8104, /// R
SoftwareTrigger = 0x8108, /// W
GlobalTriggerMask = 0x810C, /// R/W
FrontPanelTRGOUTEnableMask = 0x8110, /// R/W
LVDSIOData = 0x8118, /// R/W
FrontPanelIOControl = 0x811C, /// R/W
ChannelEnableMask = 0x8120, /// R/W
ROCFPGAFirmwareRevision = 0x8124, /// R
EventStored = 0x812C, /// R
VoltageLevelModeConfig = 0x8138, /// R/W
SoftwareClockSync = 0x813C, /// W
BoardInfo = 0x8140, /// R
AnalogMonitorMode = 0x8144, /// R/W
EventSize = 0x814C, /// R
TimeBombDowncounter = 0x8158, /// R
FanSpeedControl = 0x8168, /// R/W
RunStartStopDelay = 0x8170, /// R/W
BoardFailureStatus = 0x8178, /// R
DisableExternalTrigger = 0x817C, /// R/W
TriggerValidationMask = 0x8180, /// R/W, 0x8180 + 4n
FrontPanelLVDSIONewFeatures = 0x81A0, /// R/W
BufferOccupancyGain = 0x81B4, /// R/W
ExtendedVetoDelay = 0x81C4, /// R/W
ReadoutControl = 0xEF00, /// R/W
ReadoutStatus = 0xEF04, /// R
BoardID = 0xEF08, /// R/W
MCSTBaseAddressAndControl = 0xEF0C, /// R/W
RelocationAddress = 0xEF10, /// R/W
InterruptStatusID = 0xEF14, /// R/W
InterruptEventNumber = 0xEF18, /// R/W
MaxNumberOfEventsPerBLT = 0xEF1C, /// R/W
Scratch = 0xEF20, /// R/W
SoftwareReset = 0xEF24, /// W
SoftwareClear = 0xEF28 /// W
};
enum class RegisterPHA : uint32_t { namespace PHA {
DataFlush = 0x103C, /// W not sure static uint32_t DataFlush = 0x103C; /// W not sure
ChannelStopAcquisition = 0x1040, /// R/W not sure static uint32_t ChannelStopAcquisition = 0x1040; /// R/W not sure
RCCR2SmoothingFactor = 0x1054, /// R/W Trigger Filter smoothing, triggerSmoothingFactor static uint32_t RCCR2SmoothingFactor = 0x1054; /// R/W Trigger Filter smoothing, triggerSmoothingFactor
InputRiseTime = 0x1058, /// R/W OK static uint32_t InputRiseTime = 0x1058; /// R/W OK
TrapezoidRiseTime = 0x105C, /// R/W OK static uint32_t TrapezoidRiseTime = 0x105C; /// R/W OK
TrapezoidFlatTop = 0x1060, /// R/W OK static uint32_t TrapezoidFlatTop = 0x1060; /// R/W OK
PeakingTime = 0x1064, /// R/W OK static uint32_t PeakingTime = 0x1064; /// R/W OK
DecayTime = 0x1068, /// R/W OK static uint32_t DecayTime = 0x1068; /// R/W OK
TriggerThreshold = 0x106C, /// R/W OK static uint32_t TriggerThreshold = 0x106C; /// R/W OK
RiseTimeValidationWindow = 0x1070, /// R/W OK static uint32_t RiseTimeValidationWindow = 0x1070; /// R/W OK
TriggerHoldOffWidth = 0x1074, /// R/W OK static uint32_t TriggerHoldOffWidth = 0x1074; /// R/W OK
PeakHoldOff = 0x1078, /// R/W OK static uint32_t PeakHoldOff = 0x1078; /// R/W OK
ShapedTriggerWidth = 0x1084, /// R/W not sure static uint32_t ShapedTriggerWidth = 0x1084; /// R/W not sure
DPPAlgorithmControl2 = 0x10A0, /// R/W OK static uint32_t DPPAlgorithmControl2 = 0x10A0; /// R/W OK
FineGain = 0x10C4, /// R/W OK static uint32_t FineGain = 0x10C4; /// R/W OK
}; }
enum class RegisterPSD : uint32_t { namespace PSD {
CFDSetting = 0x103C, /// R/W static uint32_t CFDSetting = 0x103C; /// R/W
ForcedDataFlush = 0x1040, /// W static uint32_t ForcedDataFlush = 0x1040; /// W
ChargeZeroSuppressionThreshold = 0x1044, /// R/W static uint32_t ChargeZeroSuppressionThreshold = 0x1044; /// R/W
ShortGateWidth = 0x1054, /// R/W static uint32_t ShortGateWidth = 0x1054; /// R/W
LongGateWidth = 0x1058, /// R/W static uint32_t LongGateWidth = 0x1058; /// R/W
GateOffset = 0x105C, /// R/W static uint32_t GateOffset = 0x105C; /// R/W
TriggerThreshold = 0x1060, /// R/W static uint32_t TriggerThreshold = 0x1060; /// R/W
FixedBaseline = 0x1064, /// R/W static uint32_t FixedBaseline = 0x1064; /// R/W
TriggerLatency = 0x106C, /// R/W static uint32_t TriggerLatency = 0x106C; /// R/W
ShapedTriggerWidth = 0x1070, /// R/W static uint32_t ShapedTriggerWidth = 0x1070; /// R/W
TriggerHoldOffWidth = 0x1074, /// R/W static uint32_t TriggerHoldOffWidth = 0x1074; /// R/W
ThresholdForPSDCut = 0x1078, /// R/W static uint32_t ThresholdForPSDCut = 0x1078; /// R/W
PureGapThreshold = 0x107C, /// R/W static uint32_t PureGapThreshold = 0x107C; /// R/W
DPPAlgorithmControl2 = 0x1084, /// R/W static uint32_t DPPAlgorithmControl2 = 0x1084; /// R/W
EarlyBaselineFreeze = 0x10D8, /// R/W static uint32_t EarlyBaselineFreeze = 0x10D8; /// R/W
}; }
}
}
#endif #endif

View File

@ -1,14 +1,15 @@
#include "DigitizerClass.h" #include "DigitizerPHA.h"
//#include "DigitizerPSD.h"
int main(int argc, char* argv[]){ int main(int argc, char* argv[]){
DigitizerPHA * dig = new DigitizerPHA[2]; DigitizerPHA * dig = new DigitizerPHA[2];
DigitizerPSD * psd = new DigitizerPSD(); //DigitizerPSD * psd = new DigitizerPSD();
dig[0].OpenDigitizer(0,0); dig[0].OpenDigitizer(0,0);
dig[1].OpenDigitizer(1,0); dig[1].OpenDigitizer(1,0);
psd->OpenDigitizer(2,0); //psd->OpenDigitizer(2,0);
printf("======================= \n"); printf("======================= \n");
@ -16,21 +17,36 @@ int main(int argc, char* argv[]){
//dig[0].SetDCOffset(0.2); //dig[0].SetDCOffset(0.2);
//dig[0].SetDCOffset(0.3, 1); //dig[0].SetDCOffset(0.3, 1);
dig[0].SetTrapezoidRescaling(0x1F); //dig[0].SetRecordLength(2000);
dig[0].SetPulsePolarity(1); //dig[0].SetEventAggregation(0);
dig[0].SetPulsePolarity(0, 1); //dig[0].SetInputDynamicRange(0);
//dig[0].SetNumSamplePreTrigger(500);
//dig[0].SetDCOffset(0.1);
//dig[0].SetTriggerPolarity(0);
//
//dig[0].SetTrapezoidRescaling(31);
//dig[0].SetPeakSampling(3);
//dig[0].SetPulsePolarity(1);
//dig[0].SetBaselineSampling(4);
//dig[0].SetRollOverFlag(0);
//dig[0].SetPileUpFlag(1);
//dig[0].SetPulsePolarity(0, 1);
//for( int ch = 0; ch < dig[0].GetNChannel(); ch++){ //for( int ch = 0; ch < dig[0].GetNChannel(); ch++){
// uint32_t data = dig[0].ReadRegister((uint32_t) RegisterDPP::ChannelDCOffset, ch); // uint32_t data = dig[0].ReadRegister((uint32_t) RegisterDPP::ChannelDCOffset, ch);
// printf(" %d %% \n", data ); // printf(" %d %% \n", data );
//} //}
dig[0].GetChannelSetting(0); dig[0].SetTriggerThreshold(2400);
dig[0].GetChannelSetting(1); dig[0].SetTriggerHoldOff(100);
printf("temp : %d \n", dig[0].GetChTemperature(1)); dig[0].PrintBoardConfiguration();
dig[0].GetChannelSettingFromDigitizer(0);
dig[0].GetChannelSettingFromDigitizer(1);
delete [] dig; delete [] dig;
//delete psd;
return 0; return 0;
} }