snapshot, don't understand why triggered but zero energy

This commit is contained in:
carina@hades 2022-08-15 18:54:55 -04:00
parent 0a6f866f7a
commit be16a4369b
6 changed files with 149 additions and 69 deletions

View File

@ -285,6 +285,46 @@ int Digitizer::ProgramBoard(){
} }
//========================================================= ACQ control //========================================================= ACQ control
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);
}
SetExtra2WordOutput(true);
if( ret == 0 ) {
printf("Setting digitizer to \e[33m%s\e[0m mode.\n", list_mixed.c_str());
}else{
ErrorMsg("Set AcqMode");
}
}
return ret;
}
void Digitizer::StartACQ(){ void Digitizer::StartACQ(){
if ( AcqRun ) return; if ( AcqRun ) return;
ret = CAEN_DGTZ_SWStartAcquisition(handle); ret = CAEN_DGTZ_SWStartAcquisition(handle);
@ -305,8 +345,22 @@ void Digitizer::StopACQ(){
AcqRun = false; AcqRun = false;
} }
unsigned int Digitizer::CalByteForBuffer(){
unsigned int numAggBLT = ReadRegister(Register::DPP::MaxNumberOfAggregatePerBlackTransfer);
/// Channel Mask
/// is takeing waveForm
/// Record Length
return 0;
}
void Digitizer::ReadData(){ void Digitizer::ReadData(){
/// The Event Aggreation defined how many events in one ReadData. when 0 = automatics
uint32_t BufferSize = 10000000; uint32_t BufferSize = 10000000;
//char buffer[10000]; //char buffer[10000];
@ -341,6 +395,19 @@ void Digitizer::ReadData(){
} }
ErrorMsg("GetDPPEvents"); ErrorMsg("GetDPPEvents");
printf("================================================\n");
///========== print events
for( int ch = 0; ch < NChannel; ch++){
printf("--------- ch - %d, %d\n", ch, NumEvents[ch]);
for( int ev = 0; ev < NumEvents[ch]; ev++){
printf("%4d, %lu, %d, %d, %d \n", ev, Events[ch][ev].TimeTag,
Events[ch][ev].Energy,
Events[ch][ev].Extras,
Events[ch][ev].Extras2);
}
}
FILE * haha = fopen("output.bin", "w+"); FILE * haha = fopen("output.bin", "w+");
fwrite(buffer, BufferSize, 1, haha); fwrite(buffer, BufferSize, 1, haha);
@ -399,6 +466,12 @@ void Digitizer::SetEventAggregation(unsigned int numEvent, int ch){
if( ch >= 0 ) WriteRegister( Register::DPP::NumberEventsPerAggregate_G,numEvent, ch + int(pow(-1, ch))); if( ch >= 0 ) WriteRegister( Register::DPP::NumberEventsPerAggregate_G,numEvent, ch + int(pow(-1, ch)));
ErrorMsg("SetEventAggregation"); ErrorMsg("SetEventAggregation");
} }
void Digitizer::SetMaxNumberOfAggregatePerBlackTransfer(unsigned int numEvent){
WriteRegister( Register::DPP::MaxNumberOfAggregatePerBlackTransfer,numEvent);
ErrorMsg("SetMaxNumberOfAggregatePerBlackTransfer");
}
void Digitizer::SetInputDynamicRange(unsigned int TwoVol_0_or_halfVol_1, int ch){ WriteRegister( Register::DPP::InputDynamicRange, TwoVol_0_or_halfVol_1, ch); ErrorMsg("SetInputDynamicRange");} void Digitizer::SetInputDynamicRange(unsigned int TwoVol_0_or_halfVol_1, int ch){ WriteRegister( Register::DPP::InputDynamicRange, TwoVol_0_or_halfVol_1, ch); ErrorMsg("SetInputDynamicRange");}
void Digitizer::SetPreTriggerSample(unsigned int nSample, int ch) { WriteRegister( Register::DPP::PreTrigger, nSample / 4, ch); ErrorMsg("SetPreTriggerSample");} void Digitizer::SetPreTriggerSample(unsigned int nSample, int ch) { WriteRegister( Register::DPP::PreTrigger, nSample / 4, ch); ErrorMsg("SetPreTriggerSample");}
void Digitizer::SetPreTriggerDuration(unsigned int ns, int ch) { WriteRegister( Register::DPP::PreTrigger, ns / ch2ns / 4, ch); ErrorMsg("SetPreTriggerSample");} void Digitizer::SetPreTriggerDuration(unsigned int ns, int ch) { WriteRegister( Register::DPP::PreTrigger, ns / ch2ns / 4, ch); ErrorMsg("SetPreTriggerSample");}
@ -418,6 +491,8 @@ void Digitizer::SetTriggerPolarity(bool RiseingIsZero, int ch ){
if( ret != 0 ) ErrorMsg("SetTriggerPolarity"); if( ret != 0 ) ErrorMsg("SetTriggerPolarity");
} }
void Digitizer::SetAggregateOrganization(unsigned int bit){ WriteRegister(Register::DPP::AggregateOrganization, bit & 0x7); ErrorMsg("SetAggregateOrganization");}
//============================== DPP-Alpgorthm Control //============================== DPP-Alpgorthm Control
void Digitizer::SetDPPAlgorithmControl(uint32_t bit, int ch){ void Digitizer::SetDPPAlgorithmControl(uint32_t bit, int ch){
///============= DPP algorithm control is 32 bit ///============= DPP algorithm control is 32 bit
@ -478,47 +553,6 @@ void Digitizer::SetBits(uint32_t address, unsigned int bitValue, unsigned int bi
void Digitizer::SetExtra2WordOutput(bool OnOff) { SetBits(Register::BoardConfiguration, OnOff, 1, 17); ErrorMsg("PHA-SetExtra2WordOutput");} void Digitizer::SetExtra2WordOutput(bool OnOff) { SetBits(Register::BoardConfiguration, OnOff, 1, 17); ErrorMsg("PHA-SetExtra2WordOutput");}
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);
}
SetExtra2WordOutput(true);
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){ int Digitizer::GetChTemperature(int ch){
if( BoardInfo.Model != CAEN_DGTZ_V1730 && if( BoardInfo.Model != CAEN_DGTZ_V1730 &&
@ -531,7 +565,6 @@ int Digitizer::GetChTemperature(int ch){
return temp[0]; return temp[0];
} }
void Digitizer::PrintACQStatue(){ void Digitizer::PrintACQStatue(){
unsigned int status = ReadRegister(Register::DPP::AcquisitionStatus); unsigned int status = ReadRegister(Register::DPP::AcquisitionStatus);
@ -551,7 +584,6 @@ void Digitizer::PrintACQStatue(){
} }
//========================================== setting file IO //========================================== setting file IO
void Digitizer::OpenSettingBinary(string fileName){ void Digitizer::OpenSettingBinary(string fileName){
settingFile = NULL; settingFile = NULL;

View File

@ -39,7 +39,6 @@ class Digitizer{
///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 ns, int ch = -1); /// when ch == -1, mean set all channels void SetRecordLength(unsigned int ns, int ch = -1); /// when ch == -1, mean set all channels
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 SetPreTriggerSample(unsigned int nSample, int ch = -1 ); void SetPreTriggerSample(unsigned int nSample, int ch = -1 );
void SetPreTriggerDuration(unsigned int ns, int ch = -1 ); void SetPreTriggerDuration(unsigned int ns, int ch = -1 );
@ -47,6 +46,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); ///not used for DPP firmware void SetTriggerPolarity(bool RiseingIsZero, int ch = -1); ///not used for DPP firmware
void SetEventAggregation(unsigned int numEvent, int ch = -1);
void SetAggregateOrganization(unsigned int bit);
void SetMaxNumberOfAggregatePerBlackTransfer(unsigned int numEvent);
void SetBits(uint32_t address, unsigned int bitValue, unsigned int bitLength, unsigned int bitSmallestPos, int ch = -1); void SetBits(uint32_t address, unsigned int bitValue, unsigned int bitLength, unsigned int bitSmallestPos, int ch = -1);
void SetDPPAlgorithmControl(uint32_t bit, int ch = -1); void SetDPPAlgorithmControl(uint32_t bit, int ch = -1);
@ -73,6 +76,8 @@ class Digitizer{
void StartACQ(); void StartACQ();
void ReadData(); void ReadData();
unsigned int CalByteForBuffer();
///================ Setting ///================ Setting
void OpenSettingBinary(string fileName); void OpenSettingBinary(string fileName);
//TODO void LoadSettingBinary(string fileName); //TODO void LoadSettingBinary(string fileName);

View File

@ -30,34 +30,37 @@ int DigitizerPHA::ProgramBoard(){
SetRecordLength(2000); SetRecordLength(2000);
SetPreTriggerDuration(500); SetPreTriggerDuration(500);
SetBaselineSampling(5); SetBaselineSampling(3);
SetDCOffset(0.2); SetDCOffset(0.2);
SetInputDynamicRange(0); SetInputDynamicRange(0);
SetPulsePolarity(0); SetPulsePolarity(0);
SetTriggerThreshold(100); SetTriggerThreshold(64);
SetTriggerHoldOff(480); SetTriggerHoldOff(30);
SetTriggerSmoothingFactor(2); SetTriggerSmoothingFactor(2);
SetTriggerOutputWidth(0); SetTriggerOutputWidth(6);
SetInputRiseTime(96); SetInputRiseTime(6);
SetTrapezoidRescaling(19); //SetTrapezoidRescaling(23);
SetTrapezoidRiseTime(200); SetTrapezoidRiseTime(6);
SetTrapezoidFlatTop(50); SetTrapezoidFlatTop(62);
AutoSetTrapezoidRescaling();
SetDecayTime(3125); SetDecayTime(3125);
SetPeakingTime(5); SetPeakingTime(12);
SetPeakingHoldOff(62); SetPeakingHoldOff(62);
SetPeakSampling(2); SetPeakSampling(2);
SetEnergyFineGain(1); SetEnergyFineGain(0xDFB1);
SetRiseTimeValidWindow(0); SetRiseTimeValidWindow(0);
SetEventAggregation(0);
SetEventAggregation(10); /// max 511
SetMaxNumberOfAggregatePerBlackTransfer(4);
SetAggregateOrganization(0); ///0 or 1 = no division in buffer, n = 2^n divsions
SetRollOverFlag(1); SetRollOverFlag(1);
SetPileUpFlag(1); SetPileUpFlag(1);
SetExtra2WordOption(2); SetExtra2WordOption(2);
//WriteRegister(Register::DPP::DPPAlgorithmControl, 0xc300013);
ErrorMsg("PHA-ProgramBoard"); ErrorMsg("PHA-ProgramBoard");
printf("End of program board and channels\n"); printf("End of program board and channels\n");
@ -78,8 +81,10 @@ void DigitizerPHA::SetBaselineSampling(unsigned int bit, int ch) { S
void DigitizerPHA::SetRollOverFlag(bool isRollOver, int ch) { SetBits(Register::DPP::DPPAlgorithmControl, isRollOver, 1, 26, ch); ErrorMsg("SetRollOverFlag");} 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::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_G, bit, 3, 8, ch); ErrorMsg("PHA-SetExtra2WordOption");} void DigitizerPHA::SetExtra2WordOption(unsigned int bit, int ch) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, 3, 8, ch); ErrorMsg("PHA-SetExtra2WordOption");}
void DigitizerPHA::SetDPPAlgorithmControl2(unsigned int bit, int ch) { WriteRegister(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, ch); ErrorMsg("PHA-SetDPPAlgorithmControl2");}
void DigitizerPHA::SetTriggerThreshold(unsigned int threshold, int ch ) { WriteRegister(Register::DPP::PHA::TriggerThreshold, threshold & 0x03FF, ch); ErrorMsg("PHA-SetTriggerThreshold");} 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::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 & 0x001F, ch); ErrorMsg("PHA-SetTriggerSmoothingFactor");} void DigitizerPHA::SetTriggerSmoothingFactor(unsigned int bit, int ch ) { WriteRegister(Register::DPP::PHA::RCCR2SmoothingFactor, bit & 0x001F, ch); ErrorMsg("PHA-SetTriggerSmoothingFactor");}
@ -93,6 +98,24 @@ void DigitizerPHA::SetPeakingHoldOff(unsigned int nSample, int ch ) { WriteR
void DigitizerPHA::SetEnergyFineGain(unsigned int gain, int ch ) { WriteRegister(Register::DPP::PHA::FineGain, gain & 0xFFFF, ch); ErrorMsg("PHA-SetEnergyFineGain");} 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::SetRiseTimeValidWindow(unsigned int nSample, int ch ){ WriteRegister(Register::DPP::PHA::RiseTimeValidationWindow,nSample & 0x03FF, ch); ErrorMsg("PHA-SetRiseTimeValidWindow");}
void DigitizerPHA::AutoSetTrapezoidRescaling(int ch){
int startCh = 0;
int endCh = MaxNChannels;
if( ch >= 0 ){
startCh = ch;
endCh = ch;
}
for( int i = startCh ; i <= endCh; i++){
double riseTime = ReadRegister(Register::DPP::PHA::TrapezoidRiseTime, i) * 4 * ch2ns;
double flatTop = ReadRegister(Register::DPP::PHA::TrapezoidFlatTop, i) * 4 * ch2ns;
unsigned int shift = (unsigned int ) ( log(riseTime * flatTop ) / log(2.0));
SetTrapezoidRescaling(shift, i);
}
ErrorMsg("SetTrapezoidRescaling");
}
void DigitizerPHA::PrintBoardConfiguration(){ void DigitizerPHA::PrintBoardConfiguration(){
if( !isConnected ) return; if( !isConnected ) return;
@ -146,7 +169,8 @@ void DigitizerPHA::PrintChannelSettingFromDigitizer(int ch){
CAEN_DGTZ_ReadRegister(handle, Register::DPP::DPPAlgorithmControl + (ch << 8), value); CAEN_DGTZ_ReadRegister(handle, Register::DPP::DPPAlgorithmControl + (ch << 8), value);
printf(" 32 28 24 20 16 12 8 4 0\n"); printf(" 32 28 24 20 16 12 8 4 0\n");
printf(" | | | | | | | | |\n"); printf(" | | | | | | | | |\n");
cout <<" DPP algorithm Control : 0b" << bitset<32>(value[0]) << endl; cout <<" DPP algorithm Control : 0b" << bitset<32>(value[0]);
printf(" = 0x%x\n", value[0]);
int trapRescaling = int(value[0]) & 0x1f ; int trapRescaling = int(value[0]) & 0x1f ;
int polarity = int(value[0] >> 16) & 0x1; /// in bit[16] int polarity = int(value[0] >> 16) & 0x1; /// in bit[16]
@ -157,13 +181,14 @@ void DigitizerPHA::PrintChannelSettingFromDigitizer(int ch){
///DPP algorithm Control 2 ///DPP algorithm Control 2
CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::DPPAlgorithmControl2_G + (ch << 8), value); CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::DPPAlgorithmControl2_G + (ch << 8), value);
cout <<" DPP algorithm Control 2: 0b" << bitset<32>(value[0]) << endl; cout <<" DPP algorithm Control 2: 0b" << bitset<32>(value[0]) ;
printf(" = 0x%x\n", value[0]);
int extras2WordOption = int(value[0] >> 8) & 0x3; int extras2WordOption = int(value[0] >> 8) & 0x3;
string extra2WordOptStr = ""; string extra2WordOptStr = "";
switch (extras2WordOption){ switch (extras2WordOption){
case 0 : extra2WordOptStr = "[0:15] Baseline *4 [16:31] Extended Time Stamp"; break; 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 2 : extra2WordOptStr = "[0:9] Fine Time Stamp [10:15] Reserved [16:31] Extended Time Stamp"; break;
case 4 : extra2WordOptStr = "[0:15] Total Trigger Counter [16:31] Lost Trigger Counter"; 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; case 5 : extra2WordOptStr = "[0:15] Event After the Zero Crossing [16:31] Event Before the Zero Crossing"; break;
default: extra2WordOptStr = "Reserved"; break; default: extra2WordOptStr = "Reserved"; break;
@ -187,10 +212,12 @@ void DigitizerPHA::PrintChannelSettingFromDigitizer(int ch){
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 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("==========----- 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::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
int riseTime = value[0] * 4 * ch2ns;
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 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; int flatTopTime = value[0] * 4 * ch2ns;
double shift = log(riseTime * flatTopTime ) / log(2);
printf("%24s %4d bit =? %.1f = Ceil( Log(rise [ns] x decay [ns])/Log(2) ), DPP-[0:5]\n", "Trap. Rescaling", trapRescaling, shift ); ///Trap. Rescaling Factor
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::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::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 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
@ -200,7 +227,6 @@ void DigitizerPHA::PrintChannelSettingFromDigitizer(int ch){
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::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::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::PHA::RiseTimeValidationWindow + (ch << 8), value); printf("%24s %.0f ns \n", "RiseTime Vaild Win.", value[0] * ch2ns);
CAEN_DGTZ_ReadRegister(handle, Register::DPP::NumberEventsPerAggregate_G + (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::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::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::AMCFirmwareRevision + (ch << 8), value); printf("%24s 0x%x \n", "AMC firmware rev.", value[0] );
@ -208,6 +234,10 @@ void DigitizerPHA::PrintChannelSettingFromDigitizer(int ch){
printf("%24s %d = %s\n", "RollOverFlag, DPP-[26]", rollOver, rollOver ? "enable" : "disable" ); 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", "Pile-upFlag, DPP-[27]", pileUp, pileUp ? "enable" : "disable" );
printf("%24s %d, %s \n", "Extra2 opt, DPP2-[8:10]", extras2WordOption, extra2WordOptStr.c_str()); printf("%24s %d, %s \n", "Extra2 opt, DPP2-[8:10]", extras2WordOption, extra2WordOptStr.c_str());
printf("========= events storage and transfer\n");
CAEN_DGTZ_ReadRegister(handle, Register::DPP::NumberEventsPerAggregate_G + (ch << 8), value); printf("%24s %d \n", "Event Aggregate", value[0] & 0x3FF);
CAEN_DGTZ_ReadRegister(handle, Register::DPP::AggregateOrganization, value); printf("%24s %d \n", "Buffer Division", ((value[0] & 0x007) < 2 ? 0 : (int)pow(2, value[0] & 7)));
CAEN_DGTZ_ReadRegister(handle, Register::DPP::MaxNumberOfAggregatePerBlackTransfer , value); printf("%24s %d \n", "Num of Agg. / ReadData", value[0] & 0x1FF);
printf("========================================= end of ch-%d\n", ch); printf("========================================= end of ch-%d\n", ch);

View File

@ -20,6 +20,7 @@ class DigitizerPHA : public Digitizer {
void SetVirtualProbe1(unsigned int bit); void SetVirtualProbe1(unsigned int bit);
void SetTrapezoidRescaling(unsigned int rightShiftBits, int ch = -1); /// DPPAlgoritmControl bit-0:5 void SetTrapezoidRescaling(unsigned int rightShiftBits, int ch = -1); /// DPPAlgoritmControl bit-0:5
void AutoSetTrapezoidRescaling(int ch = -1); /// Set the rescalling from the risetime and flattop
void SetPeakSampling(unsigned int bit, int ch = -1); /// DPPAlgoritmControl bit-10:11 void SetPeakSampling(unsigned int bit, int ch = -1); /// DPPAlgoritmControl bit-10:11
void SetPulsePolarity(bool PositiveIsZero, int ch = -1); /// DPPAlgoritmControl bit-16 void SetPulsePolarity(bool PositiveIsZero, int ch = -1); /// DPPAlgoritmControl bit-16
void SetBaselineSampling(unsigned int bit, int ch = -1); /// DPPAlgoritmControl bit-20:22 void SetBaselineSampling(unsigned int bit, int ch = -1); /// DPPAlgoritmControl bit-20:22
@ -27,6 +28,8 @@ class DigitizerPHA : public Digitizer {
void SetPileUpFlag(bool isPileUpFlag, int ch = -1); /// DPPAlgoritmControl bit-27 void SetPileUpFlag(bool isPileUpFlag, int ch = -1); /// DPPAlgoritmControl bit-27
void SetExtra2WordOption(unsigned int bit, int ch = -1); void SetExtra2WordOption(unsigned int bit, int ch = -1);
void SetDPPAlgorithmControl2(unsigned int bit, int ch = -1);
void SetTriggerThreshold(unsigned int threshold, int ch = -1 ); void SetTriggerThreshold(unsigned int threshold, int ch = -1 );
void SetTriggerHoldOff(unsigned int nSample, int ch = -1 ); void SetTriggerHoldOff(unsigned int nSample, int ch = -1 );
void SetTriggerSmoothingFactor(unsigned int bit, int ch = -1 ); void SetTriggerSmoothingFactor(unsigned int bit, int ch = -1 );

View File

@ -59,7 +59,7 @@ namespace Register {
const uint32_t RelocationAddress = 0xEF10; /// R/W const uint32_t RelocationAddress = 0xEF10; /// R/W
const uint32_t InterruptStatusID = 0xEF14; /// R/W const uint32_t InterruptStatusID = 0xEF14; /// R/W
const uint32_t InterruptEventNumber = 0xEF18; /// R/W const uint32_t InterruptEventNumber = 0xEF18; /// R/W
const uint32_t MaxNumberOfEventsPerBLT = 0xEF1C; /// R/W const uint32_t MaxNumberOfAggregatePerBlackTransfer = 0xEF1C; /// R/W
const uint32_t Scratch = 0xEF20; /// R/W const uint32_t Scratch = 0xEF20; /// R/W
const uint32_t SoftwareReset = 0xEF24; /// W const uint32_t SoftwareReset = 0xEF24; /// W
const uint32_t SoftwareClear = 0xEF28; /// W const uint32_t SoftwareClear = 0xEF28; /// W
@ -117,7 +117,7 @@ namespace Register {
const uint32_t RelocationAddress = 0xEF10; /// R/W const uint32_t RelocationAddress = 0xEF10; /// R/W
const uint32_t InterruptStatusID = 0xEF14; /// R/W const uint32_t InterruptStatusID = 0xEF14; /// R/W
const uint32_t InterruptEventNumber = 0xEF18; /// R/W const uint32_t InterruptEventNumber = 0xEF18; /// R/W
const uint32_t MaxNumberOfEventsPerBLT = 0xEF1C; /// R/W const uint32_t MaxNumberOfAggregatePerBlackTransfer = 0xEF1C; /// R/W
const uint32_t Scratch = 0xEF20; /// R/W const uint32_t Scratch = 0xEF20; /// R/W
const uint32_t SoftwareReset = 0xEF24; /// W const uint32_t SoftwareReset = 0xEF24; /// W
const uint32_t SoftwareClear = 0xEF28; /// W const uint32_t SoftwareClear = 0xEF28; /// W

View File

@ -19,12 +19,22 @@ int main(int argc, char* argv[]){
//dig[0].WriteRegister(Register::DPP::FrontPanelTRGOUTEnableMask, 0xFF, -1); //dig[0].WriteRegister(Register::DPP::FrontPanelTRGOUTEnableMask, 0xFF, -1);
//dig[0].WriteRegister(Register::DPP::FrontPanelIOControl, 0x100, -1); //dig[0].WriteRegister(Register::DPP::FrontPanelIOControl, 0x100, -1);
//dig[0].WriteRegister(Register::DPP::TriggerValidationMask, 0, -1); //dig[0].WriteRegister(Register::DPP::TriggerValidationMask, 0, -1);
//dig[0].SetDPPAlgorithmControl(0x830200E);
dig[0].SetInputDynamicRange(2);
dig[0].SetTriggerThreshold(20);
//dig[0].SetTriggerThreshold(100); //dig[0].SetChannelMask(0x8000); /// only channel 15
//dig[0].SetChannelMask(0xffff); /// all channels
dig[0].SetWaveFormRecording(false);
//dig[0].SetPileUpFlag(false);
//dig[0].SetBits(Register::DPP::BoardConfiguration, 0x0101, 4, 20); // TRG validation window //dig[0].SetBits(Register::DPP::BoardConfiguration, 0x0101, 4, 20); // TRG validation window
dig[0].PrintBoardConfiguration(); //[20:23] vitural probe //dig[0].PrintBoardConfiguration(); //[20:23] vitural probe
dig[0].PrintChannelSettingFromDigitizer(15); //dig[0].PrintChannelSettingFromDigitizer(7);
//dig[0].PrintChannelSettingFromDigitizer(8);
//dig[0].PrintChannelSettingFromDigitizer(9);
//dig[0].PrintChannelSettingFromDigitizer(10);
dig[0].PrintChannelSettingFromDigitizer(4);
//dig[0].ReadRegister(Register::DPP::PHA::DPPAlgorithmControl2_G, 13, "DPP Control 2"); //dig[0].ReadRegister(Register::DPP::PHA::DPPAlgorithmControl2_G, 13, "DPP Control 2");
//dig[0].ReadRegister(Register::DPP::AcquisitionControl, -1, "Acq control"); // [0:1] //dig[0].ReadRegister(Register::DPP::AcquisitionControl, -1, "Acq control"); // [0:1]
//dig[0].ReadRegister(Register::DPP::GlobalTriggerMask, -1, "GlobalTrigger mask"); //dig[0].ReadRegister(Register::DPP::GlobalTriggerMask, -1, "GlobalTrigger mask");
@ -45,7 +55,7 @@ int main(int argc, char* argv[]){
dig[0].StartACQ(); dig[0].StartACQ();
sleep(5); sleep(1);
dig[0].ReadData(); dig[0].ReadData();