many many changes

This commit is contained in:
carina@hades 2022-08-23 13:43:05 -04:00
parent c5fd1b1f65
commit 4ead86783a
17 changed files with 938 additions and 398 deletions

View File

@ -9,176 +9,197 @@
#include <iostream> ///cout #include <iostream> ///cout
#include <bitset> #include <bitset>
#include "CAENDigitizer.h" //#include "CAENDigitizer.h"
#include "CAENDigitizerType.h" //#include "CAENDigitizerType.h"
//#include "macro.h"
#include "macro.h"
class Data{ class Data{
public: public:
unsigned int nByte; /// number of byte unsigned int nByte; /// number of byte
char *buffer; /// readout buffer char *buffer; /// readout buffer
uint32_t NumEvents[MaxNChannels];
uint32_t AllocatedSize; uint32_t AllocatedSize;
uint32_t BufferSize; uint32_t BufferSize;
CAEN_DGTZ_DPP_PHA_Event_t *Events[MaxNChannels]; /// events buffer ///uint32_t NumEvents[MaxNChannels];
CAEN_DGTZ_DPP_PHA_Waveforms_t *Waveform[MaxNChannels]; /// waveforms buffer ///CAEN_DGTZ_DPP_PHA_Event_t *Events[MaxNChannels]; /// events buffer
///CAEN_DGTZ_DPP_PHA_Waveforms_t *Waveform[MaxNChannels]; /// waveforms buffer
public: public:
Data(){ Data();
nByte = 0; ~Data();
buffer = NULL;
AllocatedSize = 0;
BufferSize = 0;
for( int i = 0 ; i < MaxNChannels; i++){
NumEvents[i] = 0;
Events[i] = NULL;
Waveform[i] = NULL;
}
}
~Data(){
delete buffer;
for( int i = 0 ; i < MaxNChannels; i++){
delete Events [i];
delete Waveform [i];
}
}
void AllocateMemory(){ void AllocateMemory();
void FreeMemory();
BufferSize = 100000; /// byte
buffer = (char *) malloc( BufferSize);
printf("Allocated %d byte for buffer \n", BufferSize);
for( int i = 0 ; i < MaxNChannels ; i++ ) Events[i] = (CAEN_DGTZ_DPP_PHA_Event_t *) malloc( BufferSize);
printf("Allocated %d byte for Events for each channel \n", BufferSize);
} void SaveBuffer(char * fileName);
void FreeMemory(){ void DecodeBuffer(int verbose = 0);
printf("======= Free memory, not impletment yet \n");
} protected:
unsigned int ReadBuffer(unsigned int nWord, int verbose = 0);
void ReadAllBuffer(int verbose = 0){
/// verbose : 0 = off, 1 = only energy + timestamp, 2 = show header, 3 = wave
if( buffer == NULL ) return;
unsigned int nw = 0;
do{
if( verbose >= 2 ) printf("######################################### Board Agg.\n");
unsigned int word = ReadBuffer(nw, verbose);
if( ( (word >> 28) & 0xF ) == 0xA ) { /// start of Board Agg
unsigned int nWord = word & 0x0FFFFFFF ;
if( verbose >= 2 ) printf(" number of words in this Agg : %d \n", nWord);
nw = nw + 1; word = ReadBuffer(nw, verbose);
unsigned int BoardID = ((word >> 27) & 0x1F);
bool BoardFailFlag = ((word >> 26) & 0x1 );
unsigned int ChannelMask = ( word & 0xFF ) ;
if( verbose >= 2 ) printf("Board ID : %d, FailFlag = %d, ChannelMask = 0x%x\n", BoardID, BoardFailFlag, ChannelMask);
nw = nw + 2;
unsigned int AggCounter = ReadBuffer(nw, verbose);
if( verbose >= 2 ) printf("Agg Counter : %d \n", AggCounter);
for( int chMask = 0; chMask < 8 ; chMask ++ ){
if( ((ChannelMask >> chMask) & 0x1 ) == 0 ) continue;
if( verbose >= 2 ) printf("---------------------- Dual Channel Block : %d\n", chMask *2 );
nw = nw + 1; word = ReadBuffer(nw, verbose);
bool hasFormatInfo = ((word >> 31) & 0x1);
unsigned int aggSize = ( word & 0x3FFFFFF ) ;
if( verbose >= 2 ) printf(" size : %d \n", aggSize);
unsigned int nSample = 0; /// wave form;
unsigned int nEvents = 0;
if( hasFormatInfo ){
nw = nw + 1; word = ReadBuffer(nw, verbose);
nSample = ( word & 0xFFFF ) * 8;
unsigned int digitalProbe = ( (word >> 16 ) & 0xF );
unsigned int analogProbe2 = ( (word >> 20 ) & 0x3 );
unsigned int analogProbe1 = ( (word >> 22 ) & 0x3 );
unsigned int extra2Option = ( (word >> 24 ) & 0x7 );
bool hasWaveForm = ( (word >> 27 ) & 0x1 );
bool hasExtra2 = ( (word >> 28 ) & 0x1 );
bool hasTimeStamp = ( (word >> 29 ) & 0x1 );
bool hasEnergy = ( (word >> 30 ) & 0x1 );
bool hasDualTrace = ( (word >> 31 ) & 0x1 );
if( verbose >= 2 ) printf("dualTrace : %d, Energy : %d, Time: %d, Wave : %d, Extra2: %d, Extra2Option: %d \n",
hasDualTrace, hasEnergy, hasTimeStamp, hasWaveForm, hasExtra2, extra2Option);
if( verbose >= 2 ) printf("Ana Probe 1 & 2: %d %d , Digi Probe: %d, nSample : %d \n",
analogProbe1, analogProbe2, digitalProbe, nSample);
nEvents = aggSize / (nSample/2 + 2 + hasExtra2 );
if( verbose >= 2 ) printf("=========== nEvents : %d \n", nEvents);
}else{
if( verbose >= 2 ) printf("does not has format info. unable to read buffer.\n");
break;
}
for( int ev = 0; ev < nEvents ; ev++){
if( verbose >= 2 ) printf("=================================== event : %d\n", ev);
nw = nw +1 ; word = ReadBuffer(nw, verbose);
bool channelTag = ((word >> 31) & 0x1);
unsigned int timeStamp = (word & 0x7FFFFFFF);
int channel = chMask*2 + channelTag;
if( verbose >= 2 ) printf("ch : %d, timeStamp %u \n", channel, timeStamp);
///===== read waveform
for( int wi = 0; wi < nSample/2; wi++){
nw = nw +1 ; word = ReadBuffer(nw, verbose - 2);
bool isTrigger1 = (( word >> 31 ) & 0x1 );
unsigned int wave1 = (( word >> 16) & 0x3FFF);
bool isTrigger0 = (( word >> 15 ) & 0x1 );
unsigned int wave0 = ( word & 0x3FFF);
if( verbose >= 3 && ev == 0 ){
printf("%4d| %5d, %d \n", 2*wi, wave0, isTrigger0);
printf("%4d| %5d, %d \n", 2*wi+1, wave1, isTrigger1);
}
}
nw = nw +1 ; word = ReadBuffer(nw, verbose);
unsigned int extra2 = word;
nw = nw +1 ; word = ReadBuffer(nw, verbose);
unsigned int extra = (( word >> 16) & 0x3FF);
unsigned int energy = (word & 0x7FFF);
bool pileUp = ((word >> 15) & 0x1);
if( verbose >= 2 ) printf("PileUp : %d , extra : 0x%04x, energy : %d \n", pileUp, extra, energy);
if( verbose >= 1 ) printf("ch : %2d, PileUp : %d , energy : %d, timestamp : %u\n",
channel, pileUp, energy, timeStamp);
}
}
}else{
if( verbose >= 2 ) printf("incorrect buffer header. \n");
break;
}
nw++;
}while(true);
}
unsigned int ReadBuffer(unsigned int nWord, int verbose = 0){
if( buffer == NULL ) return 0;
unsigned int word = 0;
for( int i = 0 ; i < 4 ; i++) word += ((buffer[i + 4 * nWord] & 0xFF) << 8*i);
if( verbose >= 2) printf("%d | 0x%08x\n", nWord, word);
return word;
}
}; };
//==========================================
inline Data::Data(){
nByte = 0;
buffer = NULL;
AllocatedSize = 0;
BufferSize = 0;
///for( int i = 0 ; i < MaxNChannels; i++){
/// NumEvents[i] = 0;
/// Events[i] = NULL;
/// Waveform[i] = NULL;
///}
}
inline Data::~Data(){
if( buffer != NULL ) delete buffer;
///for( int i = 0 ; i < MaxNChannels; i++){
/// delete Events [i];
/// delete Waveform [i];
///}
}
inline void Data::AllocateMemory(){
BufferSize = 100000; /// byte
buffer = (char *) malloc( BufferSize);
printf("Allocated %d byte for buffer \n", BufferSize);
///for( int i = 0 ; i < MaxNChannels ; i++ ) Events[i] = (CAEN_DGTZ_DPP_PHA_Event_t *) malloc( BufferSize);
///printf("Allocated %d byte for Events for each channel \n", BufferSize);
}
inline void Data::FreeMemory(){
printf("======= Free memory\n");
delete buffer;
}
inline unsigned int Data::ReadBuffer(unsigned int nWord, int verbose){
if( buffer == NULL ) return 0;
unsigned int word = 0;
for( int i = 0 ; i < 4 ; i++) word += ((buffer[i + 4 * nWord] & 0xFF) << 8*i);
if( verbose >= 2) printf("%d | 0x%08x\n", nWord, word);
return word;
}
inline void Data::SaveBuffer(char * fileName){
FILE * haha = fopen(fileName, "a+");
fwrite(buffer, nByte, 1, haha);
fclose(haha);
}
inline void Data::DecodeBuffer(int verbose){
/// verbose : 0 = off, 1 = only energy + timestamp, 2 = show header, 3 = wave
if( buffer == NULL ) {
printf(" buffer is empty \n");
return;
}
unsigned int nw = 0;
do{
if( verbose >= 2 ) printf("######################################### Board Agg.\n");
unsigned int word = ReadBuffer(nw, verbose);
if( ( (word >> 28) & 0xF ) == 0xA ) { /// start of Board Agg
unsigned int nWord = word & 0x0FFFFFFF ;
if( verbose >= 2 ) printf(" number of words in this Agg : %d \n", nWord);
nw = nw + 1; word = ReadBuffer(nw, verbose);
unsigned int BoardID = ((word >> 27) & 0x1F);
bool BoardFailFlag = ((word >> 26) & 0x1 );
unsigned int ChannelMask = ( word & 0xFF ) ;
if( verbose >= 2 ) printf("Board ID : %d, FailFlag = %d, ChannelMask = 0x%x\n", BoardID, BoardFailFlag, ChannelMask);
nw = nw + 2;
unsigned int AggCounter = ReadBuffer(nw, verbose);
if( verbose >= 2 ) printf("Agg Counter : %d \n", AggCounter);
for( int chMask = 0; chMask < 8 ; chMask ++ ){
if( ((ChannelMask >> chMask) & 0x1 ) == 0 ) continue;
if( verbose >= 2 ) printf("---------------------- Dual Channel Block : %d\n", chMask *2 );
nw = nw + 1; word = ReadBuffer(nw, verbose);
bool hasFormatInfo = ((word >> 31) & 0x1);
unsigned int aggSize = ( word & 0x3FFFFFF ) ;
if( verbose >= 2 ) printf(" size : %d \n", aggSize);
unsigned int nSample = 0; /// wave form;
unsigned int nEvents = 0;
if( hasFormatInfo ){
nw = nw + 1; word = ReadBuffer(nw, verbose);
nSample = ( word & 0xFFFF ) * 8;
unsigned int digitalProbe = ( (word >> 16 ) & 0xF );
unsigned int analogProbe2 = ( (word >> 20 ) & 0x3 );
unsigned int analogProbe1 = ( (word >> 22 ) & 0x3 );
unsigned int extra2Option = ( (word >> 24 ) & 0x7 );
bool hasWaveForm = ( (word >> 27 ) & 0x1 );
bool hasExtra2 = ( (word >> 28 ) & 0x1 );
bool hasTimeStamp = ( (word >> 29 ) & 0x1 );
bool hasEnergy = ( (word >> 30 ) & 0x1 );
bool hasDualTrace = ( (word >> 31 ) & 0x1 );
if( verbose >= 2 ) printf("dualTrace : %d, Energy : %d, Time: %d, Wave : %d, Extra2: %d, Extra2Option: %d \n",
hasDualTrace, hasEnergy, hasTimeStamp, hasWaveForm, hasExtra2, extra2Option);
if( verbose >= 2 ) printf("Ana Probe 1 & 2: %d %d , Digi Probe: %d, nSample : %d \n",
analogProbe1, analogProbe2, digitalProbe, nSample);
nEvents = aggSize / (nSample/2 + 2 + hasExtra2 );
if( verbose >= 2 ) printf("=========== nEvents : %d \n", nEvents);
}else{
if( verbose >= 2 ) printf("does not has format info. unable to read buffer.\n");
break;
}
for( int ev = 0; ev < nEvents ; ev++){
if( verbose >= 2 ) printf("=================================== event : %d\n", ev);
nw = nw +1 ; word = ReadBuffer(nw, verbose);
bool channelTag = ((word >> 31) & 0x1);
unsigned int timeStamp = (word & 0x7FFFFFFF);
int channel = chMask*2 + channelTag;
if( verbose >= 2 ) printf("ch : %d, timeStamp %u \n", channel, timeStamp);
///===== read waveform
for( int wi = 0; wi < nSample/2; wi++){
nw = nw +1 ; word = ReadBuffer(nw, verbose - 2);
bool isTrigger1 = (( word >> 31 ) & 0x1 );
unsigned int wave1 = (( word >> 16) & 0x3FFF);
bool isTrigger0 = (( word >> 15 ) & 0x1 );
unsigned int wave0 = ( word & 0x3FFF);
if( verbose >= 3 && ev == 0 ){
printf("%4d| %5d, %d \n", 2*wi, wave0, isTrigger0);
printf("%4d| %5d, %d \n", 2*wi+1, wave1, isTrigger1);
}
}
nw = nw +1 ; word = ReadBuffer(nw, verbose);
unsigned int extra2 = word;
nw = nw +1 ; word = ReadBuffer(nw, verbose);
unsigned int extra = (( word >> 16) & 0x3FF);
unsigned int energy = (word & 0x7FFF);
bool pileUp = ((word >> 15) & 0x1);
if( verbose >= 2 ) printf("PileUp : %d , extra : 0x%04x, energy : %d \n", pileUp, extra, energy);
if( verbose >= 1 ) printf("ch : %2d, PileUp : %d , energy : %d, timestamp : %u\n",
channel, pileUp, energy, timeStamp);
}
}
}else{
if( verbose >= 2 ) printf("incorrect buffer header. \n");
break;
}
nw++;
}while(true);
}
#endif #endif

View File

@ -233,7 +233,7 @@ void Digitizer::ErrorMsg(string header){
} }
int Digitizer::ProgramBoard(){ int Digitizer::ProgramBoard(){
printf("----- program Board\n"); printf("----- program Board\n");
ret = CAEN_DGTZ_Reset(handle); ret = CAEN_DGTZ_Reset(handle);
if (ret) { if (ret) {
@ -273,10 +273,9 @@ int Digitizer::ProgramBoard(){
CAEN_DGTZ_TRGMODE_ACQ_ONLY = generate acquisition trigger CAEN_DGTZ_TRGMODE_ACQ_ONLY = generate acquisition trigger
CAEN_DGTZ_TRGMODE_ACQ_AND_EXTOUT = generate both Trigger Output and acquisition trigger CAEN_DGTZ_TRGMODE_ACQ_AND_EXTOUT = generate both Trigger Output and acquisition trigger
see CAENDigitizer user manual, chapter "Trigger configuration" for details */ see CAENDigitizer user manual, chapter "Trigger configuration" for details */
//TODO set bit
ret |= CAEN_DGTZ_SetExtTriggerInputMode(handle, CAEN_DGTZ_TRGMODE_ACQ_ONLY); 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); ret |= CAEN_DGTZ_SetRunSynchronizationMode(handle, CAEN_DGTZ_RUN_SYNC_Disabled);
ErrorMsg("End of ProgramBoard"); ErrorMsg("End of ProgramBoard");
@ -285,46 +284,6 @@ 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);
@ -347,7 +306,8 @@ void Digitizer::StopACQ(){
unsigned int Digitizer::CalByteForBuffer(){ unsigned int Digitizer::CalByteForBuffer(){
unsigned int numAggBLT = ReadRegister(Register::DPP::MaxNumberOfAggregatePerBlackTransfer); //TODO
unsigned int numAggBLT = ReadRegister(Register::DPP::MaxNumberOfAggregatePerBlockTransfer);
/// Channel Mask /// Channel Mask
/// is takeing waveForm /// is takeing waveForm
@ -358,7 +318,7 @@ unsigned int Digitizer::CalByteForBuffer(){
} }
void Digitizer::ReadData(){ void Digitizer::ReadData(){
if( !isConnected ) return;
if( data->buffer == NULL ) { if( data->buffer == NULL ) {
printf("need allocate memory for readout buffer\n"); printf("need allocate memory for readout buffer\n");
return; return;
@ -371,34 +331,11 @@ void Digitizer::ReadData(){
return; return;
} }
ret = (CAEN_DGTZ_ErrorCode) CAEN_DGTZ_GetDPPEvents(handle, data->buffer, data->BufferSize, reinterpret_cast<void**>(&(data->Events)), data->NumEvents);
for( int i = 0 ; i < MaxNChannels; i++){
printf(" extracted %d events in ch-%02d\n", data->NumEvents[i], i);
}
ErrorMsg("GetDPPEvents");
printf("================================================\n");
///========== print events
for( int ch = 0; ch < NChannel; ch++){
printf("--------- ch - %d, %d\n", ch, data->NumEvents[ch]);
for( int ev = 0; ev < data->NumEvents[ch]; ev++){
printf("%4d, %lu, %d, %d, %d \n", ev, (data->Events[ch][ev]).TimeTag,
(data->Events[ch][ev]).Energy,
(data->Events[ch][ev]).Extras,
(data->Events[ch][ev]).Extras2);
}
}
FILE * haha = fopen("output.bin", "w+");
fwrite(data->buffer, data->nByte, 1, haha);
fclose(haha);
} }
//=========================================================== //===========================================================
void Digitizer::WriteRegister(uint32_t address, uint32_t value, int ch ){ void Digitizer::WriteRegister(uint32_t address, uint32_t value, int ch ){
if( !isConnected ) return;
if( address < 0x8000){ if( address < 0x8000){
///printf("0x%x, 0x%x=%u, ch:%d\n", address, value, value, ch); ///printf("0x%x, 0x%x=%u, ch:%d\n", address, value, value, ch);
if( ch < 0 ) { if( ch < 0 ) {
@ -415,6 +352,7 @@ void Digitizer::WriteRegister(uint32_t address, uint32_t value, int ch ){
} }
uint32_t Digitizer::ReadRegister(uint32_t address, int ch, string str ){ uint32_t Digitizer::ReadRegister(uint32_t address, int ch, string str ){
if( !isConnected ) return 0;
uint32_t * Data = new uint32_t[NChannel]; uint32_t * Data = new uint32_t[NChannel];
if( address < 0x8000) { if( address < 0x8000) {
if( ch < 0 ) { if( ch < 0 ) {
@ -431,6 +369,7 @@ uint32_t Digitizer::ReadRegister(uint32_t address, int ch, string str ){
} }
void Digitizer::SetChannelMask(uint32_t mask){ void Digitizer::SetChannelMask(uint32_t mask){
if( !isConnected ) return;
channelMask = mask; channelMask = mask;
ret |= CAEN_DGTZ_SetChannelEnableMask(handle, channelMask); ret |= CAEN_DGTZ_SetChannelEnableMask(handle, channelMask);
EditByteByRegister(Register::DPP::ChannelEnableMask); EditByteByRegister(Register::DPP::ChannelEnableMask);
@ -449,9 +388,9 @@ void Digitizer::SetEventAggregation(unsigned int numEvent, int ch){
ErrorMsg("SetEventAggregation"); ErrorMsg("SetEventAggregation");
} }
void Digitizer::SetMaxNumberOfAggregatePerBlackTransfer(unsigned int numEvent){ void Digitizer::SetMaxNumberOfAggregatePerBlockTransfer(unsigned int numEvent){
WriteRegister( Register::DPP::MaxNumberOfAggregatePerBlackTransfer,numEvent); WriteRegister( Register::DPP::MaxNumberOfAggregatePerBlockTransfer,numEvent);
ErrorMsg("SetMaxNumberOfAggregatePerBlackTransfer"); ErrorMsg("SetMaxNumberOfAggregatePerBlockTransfer");
} }
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");}
@ -461,6 +400,7 @@ void Digitizer::SetDCOffset(float offsetPrecentage, int ch)
void Digitizer::SetVetoWidth(uint32_t bit, int ch) { WriteRegister( Register::DPP::VetoWidth, bit, ch); ErrorMsg("SetVetoWidth");} void Digitizer::SetVetoWidth(uint32_t bit, int ch) { WriteRegister( Register::DPP::VetoWidth, bit, ch); ErrorMsg("SetVetoWidth");}
void Digitizer::SetTriggerPolarity(bool RiseingIsZero, int ch ){ void Digitizer::SetTriggerPolarity(bool RiseingIsZero, int ch ){
if( !isConnected ) return;
if ( DPPType >= 128 ) return; /// do thing for DPP firmware if ( DPPType >= 128 ) return; /// do thing for DPP firmware
if( ch < 0 ) { if( ch < 0 ) {
ret = 0; ret = 0;
@ -519,6 +459,17 @@ void Digitizer::SetDPPAlgorithmControl(uint32_t bit, int ch){
if( ret != 0 ) ErrorMsg("SetDPPAlgorithmControl"); if( ret != 0 ) ErrorMsg("SetDPPAlgorithmControl");
} }
unsigned int Digitizer::ReadBits(uint32_t address, unsigned int bitLength, unsigned int bitSmallestPos, int ch ){
uint32_t bit ;
uint32_t bitmask = (uint(pow(2, bitLength)-1) << bitSmallestPos);
int tempCh = ch;
if (ch < 0 && address < 0x8000 ) tempCh = 0; /// take ch-0
bit = ReadRegister(address, tempCh);
///printf("bit : 0x%x, bitmask : 0x%x \n", bit, bitmask);
bit = (bit & ~bitmask);
return bit;
}
void Digitizer::SetBits(uint32_t address, unsigned int bitValue, unsigned int bitLength, unsigned int bitSmallestPos, int ch){ void Digitizer::SetBits(uint32_t address, unsigned int bitValue, unsigned int bitLength, unsigned int bitSmallestPos, int ch){
///printf("address : 0x%x, value : 0x%x, len : %d, pos : %d, ch : %d \n", address, bitValue, bitLength, bitSmallestPos, ch); ///printf("address : 0x%x, value : 0x%x, len : %d, pos : %d, ch : %d \n", address, bitValue, bitLength, bitSmallestPos, ch);
uint32_t bit ; uint32_t bit ;
@ -533,10 +484,8 @@ void Digitizer::SetBits(uint32_t address, unsigned int bitValue, unsigned int bi
if( ret != 0 ) ErrorMsg("SetBits"); if( ret != 0 ) ErrorMsg("SetBits");
} }
void Digitizer::SetExtra2WordOutput(bool OnOff) { SetBits(Register::BoardConfiguration, OnOff, 1, 17); ErrorMsg("PHA-SetExtra2WordOutput");}
int Digitizer::GetChTemperature(int ch){ int Digitizer::GetChTemperature(int ch){
if( !isConnected ) return -404;
if( BoardInfo.Model != CAEN_DGTZ_V1730 && if( BoardInfo.Model != CAEN_DGTZ_V1730 &&
BoardInfo.Model != CAEN_DGTZ_V1725 && BoardInfo.Model != CAEN_DGTZ_V1725 &&
BoardInfo.Model != CAEN_DGTZ_V1751 ) return -404; BoardInfo.Model != CAEN_DGTZ_V1751 ) return -404;
@ -548,7 +497,7 @@ int Digitizer::GetChTemperature(int ch){
} }
void Digitizer::PrintACQStatue(){ void Digitizer::PrintACQStatue(){
if( !isConnected ) return;
unsigned int status = ReadRegister(Register::DPP::AcquisitionStatus); unsigned int status = ReadRegister(Register::DPP::AcquisitionStatus);
printf("=================== Print ACQ status \n"); printf("=================== Print ACQ status \n");

View File

@ -26,8 +26,7 @@ class Digitizer{
Digitizer(int boardID, int portID = 0); Digitizer(int boardID, int portID = 0);
~Digitizer(); ~Digitizer();
Data * data;
void Reset(); void Reset();
int OpenDigitizer(int boardID, int portID = 0, bool verbose = false);/// portID is for optical link for using PCIe card, from 0, 1, 2, 3 int OpenDigitizer(int boardID, int portID = 0, bool verbose = false);/// portID is for optical link for using PCIe card, from 0, 1, 2, 3
int CloseDigitizer(); int CloseDigitizer();
@ -48,33 +47,44 @@ class Digitizer{
void SetEventAggregation(unsigned int numEvent, int ch = -1); void SetEventAggregation(unsigned int numEvent, int ch = -1);
void SetAggregateOrganization(unsigned int bit); void SetAggregateOrganization(unsigned int bit);
void SetMaxNumberOfAggregatePerBlackTransfer(unsigned int numEvent); void SetMaxNumberOfAggregatePerBlockTransfer(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);
void SetExtra2WordOutput(bool OnOff);
int SetAcqMode(string list_mixed);
///================ Get Settings ///================ Get Settings
int GetSerialNumber() {return BoardInfo.SerialNumber;} int GetSerialNumber() {return BoardInfo.SerialNumber;}
int GetChannelMask() {return channelMask;} int GetChannelMask() {return channelMask;}
float GetCh2ns() {return ch2ns;} bool GetChannelOnOff(unsigned ch) {return (channelMask & ( 1 << ch) );}
int GetNChannel() {return NChannel;} float GetCh2ns() {return ch2ns;}
int GetHandle() {return handle;} int GetNChannel() {return NChannel;}
int GetHandle() {return handle;}
bool GetConnectionStatus() {return isConnected;}
int GetDPPType() {return DPPType;}
int GetChTemperature(int ch) ; int GetChTemperature(int ch) ;
bool GetConnectionStatus() {return isConnected;} unsigned int GetRecordLengthSample(int ch) {return ReadRegister(Register::DPP::RecordLength_G, ch) * 8;}
int GetDPPType() {return DPPType;} unsigned int GetInputDynamicRange(int ch) {return ReadRegister(Register::DPP::InputDynamicRange, ch);}
unsigned int GetPreTriggerSample(int ch) {return ReadRegister(Register::DPP::PreTrigger, ch) * 4;}
float GetDCOffset(int ch) {return 100.0 - ReadRegister(Register::DPP::ChannelDCOffset, ch) * 100. / 0xFFFFF; }
unsigned int GetVetoWidth(int ch) {return ReadRegister(Register::DPP::VetoWidth, ch);}
void PrintBoardConfiguration(); unsigned int GetEventAggregation(int ch = -1) {return ReadRegister(Register::DPP::NumberEventsPerAggregate_G, ch);}
void PrintACQStatue(); unsigned int GetAggregateOrganization() {return ReadRegister(Register::DPP::AggregateOrganization);}
unsigned int GetMaxNumberOfAggregatePerBlockTransfer() {return ReadRegister(Register::DPP::MaxNumberOfAggregatePerBlockTransfer);}
unsigned int ReadBits(uint32_t address, unsigned int bitLength, unsigned int bitSmallestPos, int ch = -1 );
unsigned int GetDPPAlgorithmControl(int ch = -1) {return ReadRegister(Register::DPP::DPPAlgorithmControl, ch);}
void PrintACQStatue();
///================ ACQ control ///================ ACQ control
void StopACQ(); void StopACQ();
void StartACQ(); void StartACQ();
void ReadData(); void ReadData();
Data * GetData(){ return data;}
unsigned int CalByteForBuffer(); unsigned int CalByteForBuffer();
@ -86,8 +96,11 @@ class Digitizer{
void EditByteByRegister(uint32_t registerAddress, int ch = -1); void EditByteByRegister(uint32_t registerAddress, int ch = -1);
unsigned long ReadSettingBinary(uint32_t filePos, int ch = -1); /// read from setting binary unsigned long ReadSettingBinary(uint32_t filePos, int ch = -1); /// read from setting binary
protected: protected:
Data * data;
///---- fixed parameter ///---- fixed parameter
int portID; /// port ID for optical link for using PCIe card, from 0, 1, 2, 3 int portID; /// port ID for optical link for using PCIe card, from 0, 1, 2, 3
int boardID; /// board identity int boardID; /// board identity

View File

@ -1,7 +1,7 @@
#include "DigitizerPHA.h" #include "DigitizerPHA.h"
DigitizerPHA::DigitizerPHA(){ DigitizerPHA::DigitizerPHA(){
DPPType = V1730_DPP_PHA_CODE;
} }
DigitizerPHA::DigitizerPHA(int boardID, int portID){ DigitizerPHA::DigitizerPHA(int boardID, int portID){
@ -18,22 +18,16 @@ int DigitizerPHA::ProgramBoard(){
printf("======== program board\n"); printf("======== program board\n");
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::RecordLength_G + 0x7000, 625); ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::RecordLength_G + 0x7000, 625);
if( ret != 0 ) { printf("==== set Record Length.\n"); return 0;} ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x4E8115);
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x4E8115); //TODO change to write register
ret = CAEN_DGTZ_SetAcquisitionMode(handle, CAEN_DGTZ_SW_CONTROLLED); /// software command ret = CAEN_DGTZ_SetAcquisitionMode(handle, CAEN_DGTZ_SW_CONTROLLED); /// software command
ret |= CAEN_DGTZ_SetIOLevel(handle, CAEN_DGTZ_IOLevel_NIM); ret |= CAEN_DGTZ_SetIOLevel(handle, CAEN_DGTZ_IOLevel_NIM);
ret |= CAEN_DGTZ_SetExtTriggerInputMode(handle, CAEN_DGTZ_TRGMODE_ACQ_ONLY); ret |= CAEN_DGTZ_SetExtTriggerInputMode(handle, CAEN_DGTZ_TRGMODE_ACQ_ONLY);
if( ret != 0 ) { printf("==== CAEN_DGTZ_SetExtTriggerInputMode.\n"); return 0;}
ret = CAEN_DGTZ_SetChannelEnableMask(handle, 0xFFFF); ret = CAEN_DGTZ_SetChannelEnableMask(handle, 0xFFFF);
if( ret != 0 ) { printf("==== CAEN_DGTZ_SetChannelEnableMask.\n"); return 0;}
ret = CAEN_DGTZ_SetNumEventsPerAggregate(handle, 0); //ret = CAEN_DGTZ_SetNumEventsPerAggregate(handle, 0);
if( ret != 0 ) { printf("==== CAEN_DGTZ_SetNumEventsPerAggregate. %d\n", ret); return 0;}
ret = CAEN_DGTZ_SetRunSynchronizationMode(handle, CAEN_DGTZ_RUN_SYNC_Disabled); ret = CAEN_DGTZ_SetRunSynchronizationMode(handle, CAEN_DGTZ_RUN_SYNC_Disabled);
if( ret != 0 ) { printf("==== set board error.\n"); return 0;} if( ret != 0 ) { printf("==== set board error.\n"); return 0;}
@ -58,7 +52,7 @@ int DigitizerPHA::ProgramBoard(){
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::NumberEventsPerAggregate_G + 0x7000, 5); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::NumberEventsPerAggregate_G + 0x7000, 5);
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::AggregateOrganization, 0); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::AggregateOrganization, 0);
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::MaxNumberOfAggregatePerBlackTransfer, 40); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::MaxNumberOfAggregatePerBlockTransfer, 40);
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::DPPAlgorithmControl + 0x7000, 0xe30200f); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::DPPAlgorithmControl + 0x7000, 0xe30200f);
if( ret != 0 ) { printf("==== set channels error.\n"); return 0;} if( ret != 0 ) { printf("==== set channels error.\n"); return 0;}
@ -68,36 +62,6 @@ int DigitizerPHA::ProgramBoard(){
return ret; return ret;
} }
void DigitizerPHA::SetAnalogProbe1(unsigned int bit) { SetBits(Register::DPP::BoardConfiguration, bit, 2, 12); ErrorMsg("PHA-SetAnalogProbe1"); }
void DigitizerPHA::SetAnalogProbe2(unsigned int bit) { SetBits(Register::DPP::BoardConfiguration, bit, 2, 14); ErrorMsg("PHA-SetAnalogProbe1"); }
void DigitizerPHA::SetWaveFormRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 16); ErrorMsg("PHA-SetWaveFormRecording"); }
void DigitizerPHA::SetTimeStampRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 18); ErrorMsg("PHA-SetTimeStampRecording"); }
void DigitizerPHA::SetEnergyRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 19); ErrorMsg("PHA-SetEnergyRecording");}
void DigitizerPHA::SetVirtualProbe1(unsigned int bit){ SetBits(Register::DPP::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_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::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::SetTriggerOutputWidth(unsigned int nSample, int ch ) { WriteRegister(Register::DPP::PHA::ShapedTriggerWidth, nSample & 0x03FF, ch); ErrorMsg("PHA-SetTriggerOutputWidth");}
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::AutoSetTrapezoidRescalingAndFindGate(double gain, int ch){ void DigitizerPHA::AutoSetTrapezoidRescalingAndFindGate(double gain, int ch){
@ -263,7 +227,7 @@ void DigitizerPHA::PrintChannelSettingFromDigitizer(int ch){
printf("========= events storage and transfer\n"); 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::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::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); CAEN_DGTZ_ReadRegister(handle, Register::DPP::MaxNumberOfAggregatePerBlockTransfer , 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

@ -12,39 +12,68 @@ class DigitizerPHA : public Digitizer {
int ProgramBoard(); int ProgramBoard();
void SetAnalogProbe1(unsigned int bit); void SetAutoDataFlush(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 0); ErrorMsg("PHA-SetAutoDataFlush"); }
void SetAnalogProbe2(unsigned int bit); void SetDualTrace(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 11); ErrorMsg("PHA-SetDualTrace"); }
void SetWaveFormRecording(bool OnOff); void SetAnalogProbe1(unsigned int bit) { SetBits(Register::DPP::BoardConfiguration, bit, 2, 12); ErrorMsg("PHA-SetAnalogProbe1"); }
void SetTimeStampRecording(bool OnOff); void SetAnalogProbe2(unsigned int bit) { SetBits(Register::DPP::BoardConfiguration, bit, 2, 14); ErrorMsg("PHA-SetAnalogProbe1"); }
void SetEnergyRecording(bool OnOff); void SetWaveFormRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 16); ErrorMsg("PHA-SetWaveFormRecording"); }
void SetVirtualProbe1(unsigned int bit); void SetEnableExtra2Word(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 17); ErrorMsg("PHA-SetEnableExtra2Word"); }
void SetTimeStampRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 18); ErrorMsg("PHA-SetTimeStampRecording"); }
void SetEnergyRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 19); ErrorMsg("PHA-SetEnergyRecording");}
void SetVirtualProbe1(unsigned int bit){ SetBits(Register::DPP::BoardConfiguration, bit, 4, 20); ErrorMsg("PHA-SetVirtualProbe1"); }
void AutoSetTrapezoidRescalingAndFindGate(double gain = 1, int ch = -1); void AutoSetTrapezoidRescalingAndFindGate(double gain = 1, int ch = -1);
void SetTrapezoidRescaling(unsigned int rightShiftBits, int ch = -1){ SetBits(Register::DPP::DPPAlgorithmControl, rightShiftBits, 5, 0, ch); ErrorMsg("PHA-SetTrapezoidRescaling"); }
void SetDecimation(unsigned int bit, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 2, 8, ch); ErrorMsg("PHA-SetDecimation");}
void SetDecimationGain(unsigned int bit, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 2, 10, ch); ErrorMsg("PHA-SetDecimationGain");}
void SetPeakSampling(unsigned int bit, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 2, 12, ch); ErrorMsg("PHA-SetPeakSampling");}
void SetPulsePolarity(bool PositiveIsZero, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, PositiveIsZero, 1, 16, ch); ErrorMsg("PHA-SetPulsePolarity");}
void SetTriggerMode(unsigned int bit, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 2, 18, ch); ErrorMsg("PHA-SetTriggerMode");}
void SetBaselineSampling(unsigned int bit, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 3, 20, ch); ErrorMsg("PHA-SetBaselineSampling"); }
void SetDisableSelfTrigger(bool OnOff, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, OnOff, 1, 24, ch); ErrorMsg("PHA-SetDisableSelfTrigger");}
void SetRollOverFlag(bool isRollOver, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, isRollOver, 1, 26, ch); ErrorMsg("PHA-SetRollOverFlag");}
void SetPileUpFlag(bool isPileUpFlag, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, isPileUpFlag, 1, 27, ch); ErrorMsg("PHA-SetPileUpFlag");}
void SetDPPAlgorithmControl2(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, ch); ErrorMsg("PHA-SetDPPAlgorithmControl2");}
void SetLocalShapedTriggerMode(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, 2, 0, ch); ErrorMsg("PHA-SetLocalShapedTriggerMode");}
void SetEnableLocalShapedTrigger(bool OnOff, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, OnOff, 1, 2, ch); ErrorMsg("PHA-SetEnableLocalShapedTrigger");}
void SetLocalTriggerValidationMode(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, 2, 4, ch); ErrorMsg("PHA-SetLocalTriggerValidationMode");}
void SetEnableLocalTriggerValidation(bool OnOff, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, OnOff, 1, 6, ch); ErrorMsg("PHA-SetEnableLocalTriggerValidation");}
void SetExtra2WordOption(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, 3, 8, ch); ErrorMsg("PHA-SetExtra2WordOption");}
void SetVetoSource(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, 2, 14, ch); ErrorMsg("PHA-SetVetoSource");}
void SetTriggerCounterRateStep(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, 2, 16, ch); ErrorMsg("PHA-SetTriggerCounterRateStep");}
void SetBaselineCalWhenACQOFF(bool OnOff, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, OnOff, 1, 18, ch); ErrorMsg("PHA-SetBaselineCalWhenACQOFF");}
void SetTagCorrelatedEvents(bool OnOff, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, OnOff, 1, 19, ch); ErrorMsg("PHA-SetTagCorrelatedEvents");}
void SetBaselineRestoreOptimization(bool OnOff, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, OnOff, 1, 29, ch); ErrorMsg("PHA-SetBaselineRestoreOptimization");}
void 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 SetDPPAlgorithmControl2(unsigned int bit, int ch = -1); void SetTriggerThreshold(unsigned int threshold, int ch = -1) { WriteRegister(Register::DPP::PHA::TriggerThreshold, threshold & 0x03FF, ch); ErrorMsg("PHA-SetTriggerThreshold");}
void SetTriggerHoldOff(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::TriggerHoldOffWidth, nSample & 0x03FF, ch); ErrorMsg("PHA-SetTriggerHoldOff"); }
void SetTriggerSmoothingFactor(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PHA::RCCR2SmoothingFactor, bit & 0x001F, ch); ErrorMsg("PHA-SetTriggerSmoothingFactor");}
void SetTriggerOutputWidth(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::ShapedTriggerWidth, nSample & 0x03FF, ch); ErrorMsg("PHA-SetTriggerOutputWidth");}
void SetInputRiseTime(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::InputRiseTime, nSample & 0x00FF, ch); ErrorMsg("PHA-SetInputRiseTime");}
void SetTriggerThreshold(unsigned int threshold, int ch = -1 ); void SetTrapezoidRiseTime(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::TrapezoidRiseTime, nSample & 0x0FFF, ch); ErrorMsg("PHA-SetTrapezoidRiseTime");}
void SetTriggerHoldOff(unsigned int nSample, int ch = -1 ); void SetTrapezoidFlatTop(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::TrapezoidFlatTop, nSample & 0x0FFF, ch); ErrorMsg("PHA-SetTrapezoidFlatTop");}
void SetTriggerSmoothingFactor(unsigned int bit, int ch = -1 ); void SetDecayTime(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::DecayTime, nSample & 0xFFFF, ch); ErrorMsg("PHA-SetDecayTime");}
void SetInputRiseTime(unsigned int nSample, int ch = -1); void SetPeakingTime(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::PeakingTime, nSample & 0x0FFF, ch); ErrorMsg("PHA-SetPeakingTime");}
void SetTriggerOutputWidth(unsigned int nSample, int ch = -1); void SetPeakingHoldOff(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::PeakHoldOff, nSample & 0x03FF, ch); ErrorMsg("PHA-SetPeakingHoldOff");}
void SetTrapezoidRiseTime(unsigned int nSample, int ch = -1 ); void SetEnergyFineGain(unsigned int gain, int ch = -1) { WriteRegister(Register::DPP::PHA::FineGain, gain & 0xFFFF, ch); ErrorMsg("PHA-SetEnergyFineGain");}
void SetTrapezoidFlatTop(unsigned int nSample, int ch = -1 ); void SetRiseTimeValidWindow(unsigned int nSample, int ch = -1){ WriteRegister(Register::DPP::PHA::RiseTimeValidationWindow,nSample & 0x03FF, ch); ErrorMsg("PHA-SetRiseTimeValidWindow");}
void SetDecayTime(unsigned int nSample, int ch = -1 );
void SetPeakingTime(unsigned int nSample, int ch = -1 ); ///=================== Get settings
void SetPeakingHoldOff(unsigned int nSample, int ch = -1 ); unsigned int GetAnalogProbe1() {return ReadBits(Register::DPP::BoardConfiguration, 2, 12);}
unsigned int GetAnalogProbe2() {return ReadBits(Register::DPP::BoardConfiguration, 2, 14);}
bool GetWaveFormRecarding() {return ReadBits(Register::DPP::BoardConfiguration, 1, 16);}
bool GetTimeStampRecording() {return ReadBits(Register::DPP::BoardConfiguration, 1, 18);}
bool GetEnergyRecording() {return ReadBits(Register::DPP::BoardConfiguration, 1, 19);}
unsigned int GetVirtualProbe1() {return ReadBits(Register::DPP::BoardConfiguration, 4, 20);}
void SetEnergyFineGain(unsigned int gain, int ch = -1 ); unsigned int GetTriggerThreshold(unsigned int ch) {return ReadRegister(Register::DPP::PHA::TriggerThreshold, ch);}
void SetRiseTimeValidWindow(unsigned int nSample, int ch = -1 );
void PrintBoardConfiguration(); void PrintBoardConfiguration();
void PrintChannelSettingFromDigitizer(int ch); void PrintChannelSettingFromDigitizer(int ch);

View File

@ -2,7 +2,7 @@
#include "DigitizerPSD.h" #include "DigitizerPSD.h"
DigitizerPSD::DigitizerPSD(){ DigitizerPSD::DigitizerPSD(){
DPPType = V1730_DPP_PSD_CODE;
} }
DigitizerPSD::DigitizerPSD(int boardID, int portID){ DigitizerPSD::DigitizerPSD(int boardID, int portID){
@ -12,3 +12,10 @@ DigitizerPSD::DigitizerPSD(int boardID, int portID){
DigitizerPSD::~DigitizerPSD(){ DigitizerPSD::~DigitizerPSD(){
} }
int DigitizerPSD::ProgramBoard(){
return ret;
}

View File

@ -9,10 +9,80 @@ class DigitizerPSD : public Digitizer {
DigitizerPSD(int boardID, int portID = 0); DigitizerPSD(int boardID, int portID = 0);
~DigitizerPSD(); ~DigitizerPSD();
//int ProgramBoard(); int ProgramBoard();
//
//void GetChannelSetting(int ch); void SetAutoDataFlush(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 0); ErrorMsg("PSD-SetAutoDataFlush"); }
void SetDualTrace(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 11); ErrorMsg("PSD-SetDualTrace"); }
void SetAnalogProbe(unsigned int bit) { SetBits(Register::DPP::BoardConfiguration, bit, 2, 12); ErrorMsg("PSD-SetAnalogProbe1"); }
void SetWaveFormRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 16); ErrorMsg("PSD-SetWaveFormRecording"); }
void SetEnableExtraWord(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 17); ErrorMsg("PSD-SetEnableExtraWord"); }
void SetTimeStampRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 18); ErrorMsg("PSD-SetTimeStampRecording"); }
void SetChargeRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 19); ErrorMsg("PSD-SetChargeRecording");}
void SetVirtualProbe1(unsigned int bit){ SetBits(Register::DPP::BoardConfiguration, bit, 3, 23); ErrorMsg("PSD-SetVirtualProbe1"); }
void SetVirtualProbe2(unsigned int bit){ SetBits(Register::DPP::BoardConfiguration, bit, 3, 26); ErrorMsg("PSD-SetVirtualProbe2"); }
void SetEnableDigitalTrace(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 31); ErrorMsg("PSD-SetEnableDigitalTrace");}
void SetChargeSensitivity(unsigned int bit, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 3, 0, ch); ErrorMsg("PSD-SetChargeSensitivity");}
void SetChargePedestal(bool OnOff, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, OnOff, 1, 4, ch); ErrorMsg("PSD-SetChargePedestal");}
void SetTriggerCounting(bool OnOff, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, OnOff, 1, 5, ch); ErrorMsg("PSD-SetTriggerCounting");}
void SetDiscriminationMode(bool LEDzero_CFDone, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, LEDzero_CFDone, 1, 6, ch); ErrorMsg("PSD-SetDiscriminationMode");}
void SetPileUpToTRIGOUT(bool OnOff, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, OnOff, 1, 7, ch); ErrorMsg("PSD-SetPileUpToTRIGOUT");}
void SetInternalTestPulse(bool OnOff, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, OnOff, 1, 8, ch); ErrorMsg("PSD-SetInternalTestPulse");}
void SetTestPulseRate(unsigned int bit, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 2, 9, ch); ErrorMsg("PSD-SetTestPulseRate");}
void SetBaelineRecalculateAfterLongGate(bool OnOff, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, OnOff, 1, 15, ch); ErrorMsg("PSD-SetBaelineRecalculateAfterLongGate");}
void SetPulsePolarity(bool PositiveIsZero, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, PositiveIsZero, 1, 16, ch); ErrorMsg("PSD-SetPulsePolarity");}
void SetTriggerMode(unsigned int bit, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 2, 18, ch); ErrorMsg("PSD-SetTriggerMode");}
void SetBaselineSampling(unsigned int bit, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 3, 20, ch); ErrorMsg("PSD-SetBaselineSampling");}
void SetDisableSelfTrigger(bool OnOff, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, OnOff, 1, 24, ch); ErrorMsg("PSD-SetDisableSelfTrigger");}
void SetDiscardQlongSmallerQThreshold(bool OnOff, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, OnOff, 1, 25, ch); ErrorMsg("PSD-SetDiscardQlongSmallerQThreshold");}
void SetPileUpRejection(bool OnOff, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, OnOff, 1, 26, ch); ErrorMsg("PSD-SetPileUpRejection");}
void SetEnablePSDcutBelowThreshold(bool OnOff, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, OnOff, 1, 27, ch); ErrorMsg("PSD-SetEnablePSDcutBelowThreshold");}
void SetEnablePSDcutAboveThreshold(bool OnOff, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, OnOff, 1, 28, ch); ErrorMsg("PSD-SetEnablePSDcutAboveThreshold");}
void SetOverRangeRejection(bool OnOff, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, OnOff, 1, 29, ch); ErrorMsg("PSD-SetOverRangeRejection");}
void SetDisableTriggerHysteresis(bool OnOff, int ch = -1) { SetBits(Register::DPP::DPPAlgorithmControl, OnOff, 1, 30, ch); ErrorMsg("PSD-SetDisableTriggerHysteresis");}
void SetDisableOppositeParityInhibitation(bool OnOff, int ch = -1){ SetBits(Register::DPP::DPPAlgorithmControl, OnOff, 1, 31, ch); ErrorMsg("PSD-SetDisableOppositeParityInhibitation");}
void SetDPPAlgorithmControl2(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PSD::DPPAlgorithmControl2_G, bit, ch); ErrorMsg("PSD-SetDPPAlgorithmControl2");}
void SetLocalShapedTriggerMode(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PSD::DPPAlgorithmControl2_G, bit, 2, 0, ch); ErrorMsg("PSD-SetLocalShapedTriggerMode");}
void SetEnableLocalShapedTrigger(bool OnOff, int ch = -1) { SetBits(Register::DPP::PSD::DPPAlgorithmControl2_G, OnOff, 1, 2, ch); ErrorMsg("PSD-SetEnableLocalShapedTrigger");}
void SetLocalTriggerValidationMode(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PSD::DPPAlgorithmControl2_G, bit, 2, 4, ch); ErrorMsg("PSD-SetLocalTriggerValidationMode");}
void SetEnableLocalTriggerValidation(bool OnOff, int ch = -1) { SetBits(Register::DPP::PSD::DPPAlgorithmControl2_G, OnOff, 1, 6, ch); ErrorMsg("PSD-SetEnableLocalTriggerValidation");}
void SetExtraWordOption(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, 3, 8, ch); ErrorMsg("PSD-SetExtraWordOption");}
void SetUseSmoothedSignal(bool OnOff, int ch = -1) { SetBits(Register::DPP::PSD::DPPAlgorithmControl2_G, OnOff, 1, 11, ch); ErrorMsg("PSD-SetUseSmoothedSignal");}
void SetInputSmoothingFactor(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, 4, 12, ch); ErrorMsg("PSD-SetInputSmoothingFactor");}
void SetTriggerCounterRateStep(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, 2, 16, ch); ErrorMsg("PSD-SetTriggerCounterRateStep");}
void SetVetoSource(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, 2, 18, ch); ErrorMsg("PSD-SetVetoSource");}
void SetMarkSaturatedPulse(bool OnOff, int ch = -1) { SetBits(Register::DPP::PSD::DPPAlgorithmControl2_G, OnOff, 1, 24, ch); ErrorMsg("PSD-SetMarkSaturatedPulse");}
void SetAdditionalLocalTriggerValidation(unsigned int bit, int ch = -1 ) { SetBits(Register::DPP::PSD::DPPAlgorithmControl2_G, bit, 2, 25, ch); ErrorMsg("PSD-SetAdditionalLocalTriggerValidation");}
void SetVetoMode(bool OnOff, int ch = -1) { SetBits(Register::DPP::PSD::DPPAlgorithmControl2_G, OnOff, 1, 27, ch); ErrorMsg("PSD-SetVetoMode");}
void SetTimestampResetWhenExtVetoActive(bool OnOff, int ch = -1) { SetBits(Register::DPP::PSD::DPPAlgorithmControl2_G, OnOff, 1, 28, ch); ErrorMsg("PSD-SetTimestampResetWhenExtVetoActive");}
void SetCFDSetting(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PSD::CFDSetting, bit & 0x0FFF, ch); ErrorMsg("PSD-SetCFDSetting");}
void SetCFDDelayUnit(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PSD::CFDSetting, bit, 8, 0, ch); ErrorMsg("PSD-SetCFDDelayUnit");}
void SetCFDFraction(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PSD::CFDSetting, bit, 2, 8, ch); ErrorMsg("PSD-SetCFDFraction");}
void SetCFDInterpolationPoint(unsigned int bit, int ch = -1) { SetBits(Register::DPP::PSD::CFDSetting, bit, 2, 10, ch); ErrorMsg("PSD-SetCFDInterpolationPoint");}
void SetForceDataFlush(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PSD::ForcedDataFlush, bit, ch); ErrorMsg("PSD-SetForceDataFlush");}
void SetChargeZeroSuppressionThreshold(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PSD::ChargeZeroSuppressionThreshold, bit & 0xFFFF, ch); ErrorMsg("PSD-SetChargeZeroSuppressionThreshold");}
void SetShortGateWidthSample(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PSD::ShortGateWidth, bit & 0x0FFF, ch); ErrorMsg("PSD-SetShortGateWidthSample");}
void SetLongGateWidthSample(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PSD::LongGateWidth, bit & 0xFFFF, ch); ErrorMsg("PSD-SetLongGateWidthSample");}
void SetGateOffsetSample(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PSD::GateOffset, bit & 0x00FF, ch); ErrorMsg("PSD-SetGateOffsetSample");}
void SetTriggerThreshold(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PSD::TriggerThreshold, bit & 0x3FFF, ch); ErrorMsg("PSD-SetTriggerThreshold");}
void SetTriggerLatency(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PSD::TriggerLatency, bit & 0x03FF, ch); ErrorMsg("PSD-SetTriggerLatency");}
void SetTriggerHoldOff(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PSD::TriggerHoldOffWidth, bit & 0xFFFF, ch); ErrorMsg("PSD-SetTriggerHoldOff");}
void SetThresholdforPSDcut(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PSD::ThresholdForPSDCut, bit & 0x03FF, ch); ErrorMsg("PSD-SetThresholdforPSDcut");}
void SetPurGapThreshold(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PSD::PurGapThreshold, bit & 0x0FFF, ch); ErrorMsg("PSD-SetPurGapThreshold");}
void SetShapedTriggerWidth(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PSD::ShapedTriggerWidth, bit & 0x03FF, ch); ErrorMsg("PSD-SetShapedTriggerWidth");}
void SetEarlyBaselineFreeze(unsigned int bit, int ch = -1) { WriteRegister(Register::DPP::PSD::EarlyBaselineFreeze, bit & 0x03FF, ch); ErrorMsg("PSD-SetEarlyBaselineFreeze");}
void SetFixedBaseline(unsigned int bit, int ch = -1) {
if ( bit == 0 ) SetBaselineSampling(3);
if ( bit > 0 ) {
SetBaselineSampling(0);
WriteRegister(Register::DPP::PSD::FixedBaseline, bit & 0x3FFF, ch);
ErrorMsg("PSD-SetTriggerThreshold");
}
}
}; };
#endif #endif

View File

@ -16,29 +16,29 @@
#include "DigitizerPHA.h" #include "DigitizerPHA.h"
#include "DigitizerPSD.h" #include "DigitizerPSD.h"
#include "FSUDAQ.h" #include "FSUDAQ.h"
enum MenuIdentifiers{ enum MenuIdentifiers{
M_DIGITIZER_SCAN,
M_FILE_OPEN, M_FILE_OPEN,
M_EXIT, M_EXIT,
M_CH_SETTINGS_SUMMARY, M_CH_SETTINGS_SUMMARY,
M_CH_SETTING, M_CH_SETTING,
M_MODULE_SETTINGS, M_BOARD_SETTINGS,
M_PROGRAM_SETTINGS, M_PROGRAM_SETTINGS,
M_FINDPEAKS, M_FINDPEAKS,
M_SHOW_CHANNELS_RATE M_SHOW_CHANNELS_RATE
}; };
///make static members ///make static members
DigitizerPHA * MainWindow::digi = NULL; Digitizer ** MainWindow::digi = NULL;
TGTextEdit * MainWindow::teLog = NULL; TGTextEdit * MainWindow::teLog = NULL;
TRootEmbeddedCanvas * MainWindow::fEcanvas = NULL; TRootEmbeddedCanvas * MainWindow::fEcanvas = NULL;
MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
DetectDigitizer(); nDigi = 0;
digi = new DigitizerPHA(0,0);
/// Create a main frame /// Create a main frame
fMain = new TGMainFrame(p,w,h); fMain = new TGMainFrame(p,w,h);
@ -48,6 +48,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
fMenuBar = new TGMenuBar(fMain, 1, 1, kHorizontalFrame); fMenuBar = new TGMenuBar(fMain, 1, 1, kHorizontalFrame);
fMain->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX)); fMain->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
fMenuFile = new TGPopupMenu(gClient->GetRoot()); fMenuFile = new TGPopupMenu(gClient->GetRoot());
fMenuFile->AddEntry("&Scan Digitizers", M_DIGITIZER_SCAN);
fMenuFile->AddEntry("&Open File", M_FILE_OPEN); fMenuFile->AddEntry("&Open File", M_FILE_OPEN);
fMenuFile->AddSeparator(); fMenuFile->AddSeparator();
fMenuFile->AddEntry("E&xit", M_EXIT); fMenuFile->AddEntry("E&xit", M_EXIT);
@ -58,7 +59,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
fMenuSettings->AddEntry("&Settings Summary", M_CH_SETTINGS_SUMMARY); fMenuSettings->AddEntry("&Settings Summary", M_CH_SETTINGS_SUMMARY);
fMenuSettings->AddEntry("&Channel Setting", M_CH_SETTING); fMenuSettings->AddEntry("&Channel Setting", M_CH_SETTING);
fMenuSettings->AddSeparator(); fMenuSettings->AddSeparator();
fMenuSettings->AddEntry("&Digitizer Settings", M_MODULE_SETTINGS); fMenuSettings->AddEntry("&Digitizer Settings", M_BOARD_SETTINGS);
fMenuSettings->AddSeparator(); fMenuSettings->AddSeparator();
fMenuSettings->AddEntry("Program Settings", M_PROGRAM_SETTINGS); fMenuSettings->AddEntry("Program Settings", M_PROGRAM_SETTINGS);
fMenuSettings->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)"); fMenuSettings->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
@ -75,6 +76,11 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain,200,40); TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain,200,40);
fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2)); fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));
///================= Open digitizers
TGTextButton *bOpenDigitizers = new TGTextButton(hframe,"Open Digitizers");
bOpenDigitizers->Connect("Clicked()","MainWindow",this,"DetectDigitizer()");
hframe->AddFrame(bOpenDigitizers, uniLayoutHints);
///================= signal Channel group ///================= signal Channel group
TGGroupFrame * group1 = new TGGroupFrame(hframe, "Single Channel", kHorizontalFrame); TGGroupFrame * group1 = new TGGroupFrame(hframe, "Single Channel", kHorizontalFrame);
hframe->AddFrame(group1 ); hframe->AddFrame(group1 );
@ -107,13 +113,13 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
//fillHistThread = new TThread("kakaka", FillHistogram, (void *) 1); //fillHistThread = new TThread("kakaka", FillHistogram, (void *) 1);
///settingsSummary = NULL; ///settingsSummary = NULL;
//boardSetting = NULL; boardSetting = NULL;
///channelSetting = NULL; channelSetting = NULL;
///scalarPanel = NULL; ///scalarPanel = NULL;
LogMsg("Ready to run."); LogMsg("Ready to run.");
///HandleMenu(M_CH_SETTINGS_SUMMARY); HandleMenu(M_BOARD_SETTINGS);
} }
MainWindow::~MainWindow() { MainWindow::~MainWindow() {
@ -122,16 +128,17 @@ MainWindow::~MainWindow() {
delete fMenuSettings; delete fMenuSettings;
delete fMenuUtility; delete fMenuUtility;
//delete modIDEntry; //delete boardIDEntry;
//delete chEntry; //delete chEntry;
//delete tePath; //delete tePath;
delete teLog; delete teLog;
delete digi; if( digi != NULL ) delete [] digi;
delete boardSetting;
delete channelSetting;
//delete settingsSummary; //delete settingsSummary;
//delete boardSetting;
//delete channelSetting;
//delete scalarPanel; //delete scalarPanel;
// //
//delete saveDataThread; //delete saveDataThread;
@ -146,6 +153,26 @@ MainWindow::~MainWindow() {
void MainWindow::HandleMenu(Int_t id){ void MainWindow::HandleMenu(Int_t id){
switch(id){ switch(id){
///========================= Scan digitizers
case M_DIGITIZER_SCAN:{
printf("============= detect digitizers \n");
//DetectDigitizer();
printf("============= Connect %d digitizers...\n", nDigi);
if( nDigi > 0 ) {
digi = new Digitizer *[nDigi];
for( int i = 0; i < nDigi; i++){
if( DPPType[i] == V1730_DPP_PSD_CODE ) {
digi[i] = new DigitizerPSD(boardID[i], portID[i]);
}else if( DPPType[i] == V1730_DPP_PHA_CODE ){
digi[i] = new DigitizerPHA(boardID[i], portID[i]);
}else{
digi[i] = new Digitizer(boardID[i], portID[i]);
}
}
}
}break;
///========================= File Open ///========================= File Open
case M_FILE_OPEN:{ case M_FILE_OPEN:{
@ -161,11 +188,24 @@ void MainWindow::HandleMenu(Int_t id){
}break; }break;
case M_CH_SETTING:{ case M_CH_SETTING:{
if( channelSetting == NULL ) {
channelSetting = new ChannelSetting(gClient->GetRoot(), 600, 600, digi, nDigi);
}else{
//if( !channelSetting->isOpened ) {
channelSetting = new ChannelSetting(gClient->GetRoot(), 600, 600, digi, nDigi);
//}
}
}break; }break;
///========================= Module setting ///========================= Board setting
case M_MODULE_SETTINGS:{ case M_BOARD_SETTINGS:{
if( boardSetting == NULL ) {
boardSetting = new BoardSetting(gClient->GetRoot(), 600, 600, digi, nDigi);
}else{
//if( !boardSetting->isOpened ) {
boardSetting = new BoardSetting(gClient->GetRoot(), 600, 600, digi, nDigi);
//}
}
}break; }break;
///========================= Program setting ///========================= Program setting
@ -191,13 +231,13 @@ void MainWindow::HandleMenu(Int_t id){
} }
void MainWindow::DetectDigitizer(){ void MainWindow::DetectDigitizer(){
Digitizer * dig = new Digitizer();
vector<int> DPPType; DPPType.clear();
vector<int> portID; portID.clear();
vector<int> boardID; boardID.clear();
int nDigi = 0; nDigi = 0;
Digitizer * dig = new Digitizer();
for( int port = 0; port < 4 ; port ++){ for( int port = 0; port < 4 ; port ++){
for( int board = 0; board < 3 ; board ++){ for( int board = 0; board < 3 ; board ++){
@ -207,6 +247,7 @@ void MainWindow::DetectDigitizer(){
DPPType.push_back(dig->GetDPPType()); DPPType.push_back(dig->GetDPPType());
portID.push_back(port); portID.push_back(port);
boardID.push_back(board); boardID.push_back(board);
serialNum.push_back(dig->GetSerialNumber());
dig->CloseDigitizer(); dig->CloseDigitizer();
} }
} }
@ -238,8 +279,9 @@ Double_t standardPulse(Double_t *x, Double_t * par){
void MainWindow::GoodBye(){ void MainWindow::GoodBye(){
digi->CloseDigitizer(); if( nDigi > 0 && digi != NULL) {
for(int i = 0; i < nDigi ; i++) digi[0]->CloseDigitizer();
}
printf("----- bye bye ---- \n"); printf("----- bye bye ---- \n");
gApplication->Terminate(0); gApplication->Terminate(0);

View File

@ -11,13 +11,16 @@
#include <TBenchmark.h> #include <TBenchmark.h>
#include <TGTextEditor.h> #include <TGTextEditor.h>
#include "CAENDigitizer.h" #include "CAENDigitizer.h"
#include "macro.h"
#include "DigitizerPHA.h" #include "DigitizerPHA.h"
#include "DigitizerPSD.h" #include "DigitizerPSD.h"
///#include "global_macro.h"
#include "boardSetting.h"
#include "channelSetting.h"
///#include "settingsSummary.h" ///#include "settingsSummary.h"
///#include "scalarPanel.h" ///#include "scalarPanel.h"
//#include "boardSetting.h"
//#include "channelSetting.h"
class TGWindow; class TGWindow;
class TGMainFrame; class TGMainFrame;
class TRootEmbeddedCanvas; class TRootEmbeddedCanvas;
@ -31,7 +34,7 @@ private:
TGMenuBar *fMenuBar; TGMenuBar *fMenuBar;
TGPopupMenu *fMenuFile, *fMenuSettings, *fMenuUtility; TGPopupMenu *fMenuFile, *fMenuSettings, *fMenuUtility;
//static TGNumberEntry * modIDEntry, *chEntry; //static TGNumberEntry * boardIDEntry, *chEntry;
//TGNumberEntry * runIDEntry; //TGNumberEntry * runIDEntry;
//TGTextEntry * tePath; //TGTextEntry * tePath;
// //
@ -41,12 +44,17 @@ private:
//TGTextButton *bStopRun; //TGTextButton *bStopRun;
//TGTextButton *bFitTrace; //TGTextButton *bFitTrace;
static DigitizerPHA * digi; int nDigi;
vector<int> DPPType;
vector<int> portID;
vector<int> boardID;
vector<int> serialNum;
static Digitizer ** digi;
BoardSetting * boardSetting;
ChannelSetting * channelSetting;
//SettingsSummary * settingsSummary; //SettingsSummary * settingsSummary;
///ModuleSetting * moduleSetting;
//ChannelSetting * channelSetting;
//ScalarPanel * scalarPanel; //ScalarPanel * scalarPanel;
// //
//TThread * saveDataThread; //TThread * saveDataThread;

View File

@ -11,7 +11,7 @@ CAENLIBS = -lCAENDigitizer
ROOTLIBS = `root-config --cflags --glibs` ROOTLIBS = `root-config --cflags --glibs`
OBJS = ClassDigitizer.o DigitizerPHA.o DigitizerPSD.o FSUDAQ.o OBJS = channelSetting.o boardSetting.o ClassDigitizer.o DigitizerPHA.o DigitizerPSD.o FSUDAQ.o
######################################################################### #########################################################################
@ -21,9 +21,6 @@ clean :
/bin/rm -f $(OBJS) test FSUDAQ FSUDAQDict.cxx *.pcm /bin/rm -f $(OBJS) test FSUDAQ FSUDAQDict.cxx *.pcm
#ClassData.o : ClassData.h macro.h
# $(CC) $(COPTS) -c ClassData.h -o ClassData.o
ClassDigitizer.o : ClassDigitizer.cpp ClassDigitizer.h RegisterAddress.h macro.h ClassData.h ClassDigitizer.o : ClassDigitizer.cpp ClassDigitizer.h RegisterAddress.h macro.h ClassData.h
$(CC) $(COPTS) -c ClassDigitizer.cpp $(CC) $(COPTS) -c ClassDigitizer.cpp
@ -38,8 +35,12 @@ test : test.cpp ClassDigitizer.o DigitizerPHA.o DigitizerPSD.o
$(CC) $(COPTS) -o test test.cpp ClassDigitizer.o DigitizerPHA.o DigitizerPSD.o $(CAENLIBS) $(CC) $(COPTS) -o test test.cpp ClassDigitizer.o DigitizerPHA.o DigitizerPSD.o $(CAENLIBS)
test_indep : test_indep.cpp RegisterAddress.h macro.h test_indep : test_indep.cpp RegisterAddress.h macro.h
@echo "--------- making test_indep"
$(CC) $(COPTS) -o test_indep test_indep.cpp $(CAENLIBS) $(CC) $(COPTS) -o test_indep test_indep.cpp $(CAENLIBS)
FSUDAQ : FSUDAQDict.cxx $(OBJS)
@echo "----------- creating FSUDAQ"
$(CC) $(COPTS) FSUDAQDict.cxx $(OBJS) -o FSUDAQ $(CAENLIBS) $(ROOTLIBS)
FSUDAQDict.cxx : FSUDAQ.h FSUDAQLinkDef.h FSUDAQDict.cxx : FSUDAQ.h FSUDAQLinkDef.h
@echo "----------- creating pcm and cxx for root" @echo "----------- creating pcm and cxx for root"
@ -50,10 +51,15 @@ FSUDAQ.o : FSUDAQ.h FSUDAQ.cpp FSUDAQDict.cxx
@echo "----------- creating FSUDAQ.o" @echo "----------- creating FSUDAQ.o"
$(CC) $(COPTS) -c FSUDAQ.cpp ClassDigitizer.cpp DigitizerPHA.cpp DigitizerPSD.cpp $(ROOTLIBS) $(CC) $(COPTS) -c FSUDAQ.cpp ClassDigitizer.cpp DigitizerPHA.cpp DigitizerPSD.cpp $(ROOTLIBS)
FSUDAQ : FSUDAQDict.cxx $(OBJS) boardSetting.o : boardSetting.h boardSetting.cpp
@echo "----------- creating FSUDAQ" @echo "----------- creating boardSetting.o"
$(CC) $(COPTS) FSUDAQDict.cxx $(OBJS) -o FSUDAQ $(CAENLIBS) $(ROOTLIBS) $(CC) $(COPTS) -c boardSetting.cpp $(ROOTLIBS)
channelSetting.o : channelSetting.h channelSetting.cpp
@echo "----------- creating channelSetting.o"
$(CC) $(COPTS) -c channelSetting.cpp $(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

@ -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 MaxNumberOfAggregatePerBlackTransfer = 0xEF1C; /// R/W const uint32_t MaxNumberOfAggregatePerBlockTransfer = 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 MaxNumberOfAggregatePerBlackTransfer = 0xEF1C; /// R/W const uint32_t MaxNumberOfAggregatePerBlockTransfer = 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
@ -178,7 +178,7 @@ namespace Register {
const uint32_t ShapedTriggerWidth = 0x1070; /// R/W const uint32_t ShapedTriggerWidth = 0x1070; /// R/W
const uint32_t TriggerHoldOffWidth = 0x1074; /// R/W const uint32_t TriggerHoldOffWidth = 0x1074; /// R/W
const uint32_t ThresholdForPSDCut = 0x1078; /// R/W const uint32_t ThresholdForPSDCut = 0x1078; /// R/W
const uint32_t PureGapThreshold = 0x107C; /// R/W const uint32_t PurGapThreshold = 0x107C; /// R/W
const uint32_t DPPAlgorithmControl2_G = 0x1084; /// R/W const uint32_t DPPAlgorithmControl2_G = 0x1084; /// R/W
const uint32_t EarlyBaselineFreeze = 0x10D8; /// R/W const uint32_t EarlyBaselineFreeze = 0x10D8; /// R/W
} }

117
boardSetting.cpp Normal file
View File

@ -0,0 +1,117 @@
#include <TApplication.h>
#include <TGClient.h>
#include <TCanvas.h>
#include <TF1.h>
#include <TRandom.h>
#include <TGButton.h>
#include <TRootEmbeddedCanvas.h>
#include <TGTableContainer.h>
#include <TGFileDialog.h>
#include "boardSetting.h"
TString boardSettingName[NUM_BOARD_SETTING] = {
"Model",
"Board Info",
"Link Type",
"Serial Number",
"Number of channels",
"Sampling rate",
"ADC bit",
"ROC version",
"AMC version",
"Channel Enable Mask",
"Board Config",
"Aggregate Organization",
"Max Num. Of Aggregate Per Block Transfer",
"Acquisition Control",
"Acquisition Status",
"Global Trigger Mask",
"Disable External Trigger",
"Trigger Validation Mask",
"Extended Veto Delay",
"Front Panel TRG-OUT Enable Mask",
"Front Panel IO Control",
"Front Panel LVDS IO New Features",
"LVDS IO Data",
"AnalogMonitor Mode",
"FanSpeed Control",
"Readout Control",
"Readout Status"
};
BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nBoard){
this->digi = digi;
fMain = new TGMainFrame(p,w,h);
fMain->SetWindowName("Board Settings ");
fMain->Connect("CloseWindow()", "BoardSetting", this, "CloseWindow()");
TGVerticalFrame * vframe = new TGVerticalFrame(fMain);
fMain->AddFrame(vframe, new TGLayoutHints(kLHintsCenterX, 2,2,2,2));
///==========Module choose
TGHorizontalFrame *hframe0 = new TGHorizontalFrame(vframe, w, 50 );
vframe->AddFrame(hframe0, new TGLayoutHints(kLHintsCenterX, 2,2,2,2));
TGLabel * lb0 = new TGLabel(hframe0, "Board ID :");
hframe0->AddFrame(lb0, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
boardIDEntry = new TGNumberEntry(hframe0, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
boardIDEntry->SetWidth(50);
boardIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, nBoard);
boardIDEntry->Connect("Modified()", "BoardSetting", this, "ChangeBoard()");
if( nBoard <= 1 ) boardIDEntry->SetState(false);
hframe0->AddFrame(boardIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4));
int modID = boardIDEntry->GetNumber();
int comboBoxWidth = 135;
int comboBoxHeigth = 30;
TGHorizontalFrame *hframe[NUM_BOARD_SETTING];
TGLabel * lb[NUM_BOARD_SETTING];
for( int i = 0 ; i < NUM_BOARD_SETTING; i++){
hframe[i] = new TGHorizontalFrame(vframe, 50, 50 );
vframe->AddFrame(hframe[i], new TGLayoutHints(kLHintsRight, 2,2,2,2));
//int temp = digi[0]->GetSerialNumber();
int temp = 0;
lb[i] = new TGLabel(hframe[i], boardSettingName[i]);
hframe[i]->AddFrame(lb[i], new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5, 5, 3, 4));
entry[i] = new TGTextEntry(hframe[i], new TGTextBuffer(1));
entry[i]->SetEnabled(false);
entry[i]->SetText( Form("0x%x", temp) );
hframe[i]->AddFrame(entry[i], new TGLayoutHints(kLHintsRight, 5,5,3,4));
}
fMain->MapSubwindows();
fMain->Resize(fMain->GetDefaultSize());
fMain->MapWindow();
isOpened = true;
}
BoardSetting::~BoardSetting(){
isOpened = false;
delete boardIDEntry;
//delete entry;
/// fMain must be delete last;
fMain->Cleanup();
delete fMain;
}
void BoardSetting::ChangeBoard(){
int boardID = boardIDEntry->GetNumber();
return;
}

36
boardSetting.h Normal file
View File

@ -0,0 +1,36 @@
#ifndef BOARD_SETTING_H
#define BOARD_SETTING_H
#include <TQObject.h>
#include <TGNumberEntry.h>
#include <TGComboBox.h>
#include <TGLabel.h>
#include "DigitizerPHA.h"
#include "DigitizerPSD.h"
#include "macro.h"
#define NUM_BOARD_SETTING 27
class TGWindow;
class TGMainFrame;
class BoardSetting{
private:
TGMainFrame * fMain;
TGNumberEntry * boardIDEntry;
TGTextEntry * entry[NUM_BOARD_SETTING];
Digitizer ** digi;
public:
BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nBoard);
virtual ~BoardSetting();
void CloseWindow() { printf("close BoardSetting window\n"); delete this; }
void ChangeBoard();
bool isOpened;
};
#endif

222
channelSetting.cpp Normal file
View File

@ -0,0 +1,222 @@
#include <TApplication.h>
#include <TGClient.h>
#include <TCanvas.h>
#include <TF1.h>
#include <TRandom.h>
#include <TGButton.h>
#include <TRootEmbeddedCanvas.h>
#include <TGTableContainer.h>
#include <TGFileDialog.h>
#include "channelSetting.h"
//TODO set MAX
///---------------------------------------------- NAME, DIGI, unit ... MAX
TString settingName[NUM_CHANNEL_SETTING][3] = {{"TRIGGER_RISETIME", "2", "us"},
{"TRIGGER_FLATTOP", "2", "us"},
{"TRIGGER_THRESHOLD", "0", "ADC"},
{"ENERGY_RISETIME", "1", "us"},
{"ENERGY_FLATTOP", "1", "us"},
{"TAU", "2", "us"},
{"TRACE_LENGTH", "2", "us"},
{"TRACE_DELAY", "2", "us"},
{"VOFFSET", "2", "V"},
{"XDT", "2", "us"},
{"BASELINE_PERCENT", "0", "%"},
{"BASELINE_AVERAGE", "0", ""},
{"BLCUT", "0", ""},
{"EMIN", "0", ""},
{"MultiplicityMaskL", "0", ""},
{"MultiplicityMaskH", "0", ""},
{"CHANNEL_CSRA", "0", ""}};
ChannelSetting::ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nDigi){
this->digi = digi;
fMain = new TGMainFrame(p,w,h);
fMain->SetWindowName("Channel Settings ");
fMain->Connect("CloseWindow()", "ChannelSetting", this, "CloseWindow()");
TGVerticalFrame * vframe = new TGVerticalFrame(fMain);
fMain->AddFrame(vframe, new TGLayoutHints(kLHintsCenterX, 2,2,2,2));
///==========Board choose
TGHorizontalFrame *hframe0 = new TGHorizontalFrame(vframe, w, 50 );
vframe->AddFrame(hframe0, new TGLayoutHints(kLHintsCenterX, 2,2,2,2));
TGLabel * lb0 = new TGLabel(hframe0, "Module ID :");
hframe0->AddFrame(lb0, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
boardIDEntry = new TGNumberEntry(hframe0, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
boardIDEntry->SetWidth(50);
boardIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, nDigi);
boardIDEntry->Connect("Modified()", "ChannelSetting", this, "ChangeBoard()");
if( nDigi <= 1 ) boardIDEntry->SetState(false);
NChannel = 16 ;// digi[0]->GetNChannel();
hframe0->AddFrame(boardIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4));
TGLabel * lb1 = new TGLabel(hframe0, "Channel :");
hframe0->AddFrame(lb1, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
chIDEntry = new TGNumberEntry(hframe0, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
chIDEntry->SetWidth(50);
chIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, NChannel-1);
chIDEntry->Connect("Modified()", "ChannelSetting", this, "ChangeCh()");
hframe0->AddFrame(chIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4));
int boardID = boardIDEntry->GetNumber();
int ch = chIDEntry->GetNumber();
int width = 80;
///----------- on/off
TGHorizontalFrame *hframeOnOff = new TGHorizontalFrame(vframe, 50, 50 );
vframe->AddFrame(hframeOnOff, new TGLayoutHints(kLHintsRight, 2,2,2,2));
cbOnOff = new TGComboBox(hframeOnOff);
cbOnOff->AddEntry("ON", 1);
cbOnOff->AddEntry("off", 0);
cbOnOff->Resize(width, 20);
//pixie->GetChannelOnOff(boardID, ch) ? cbOnOff->Select(1) : cbOnOff->Select(0);
cbOnOff->Connect("Selected(Int_t, Int_t)", "ChannelSetting", this, "ChangeOnOff()");
hframeOnOff->AddFrame(cbOnOff, new TGLayoutHints(kLHintsRight, 5,5,3,4));
TGLabel * lbOnOff = new TGLabel(hframeOnOff, "On/Off");
hframeOnOff->AddFrame(lbOnOff, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 3, 4));
///----------- Polarity
TGHorizontalFrame *hframePol = new TGHorizontalFrame(vframe, 50, 50 );
vframe->AddFrame(hframePol, new TGLayoutHints(kLHintsRight, 2,2,2,2));
cbPolarity = new TGComboBox(hframePol);
cbPolarity->AddEntry("Positive +", 1);
cbPolarity->AddEntry("Negative -", 0);
cbPolarity->Resize(width, 20);
//pixie->GetChannelPolarity(boardID, ch) ? cbPolarity->Select(1) : cbPolarity->Select(0);
cbPolarity->Connect("Selected(Int_t, Int_t)", "ChannelSetting", this, "ChangeOnOff()");
hframePol->AddFrame(cbPolarity, new TGLayoutHints(kLHintsRight, 5,5,3,4));
TGLabel * lbPol = new TGLabel(hframePol, "Polarity");
hframePol->AddFrame(lbPol, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 3, 4));
///----- all other
TGHorizontalFrame *hframe[NUM_CHANNEL_SETTING];
TGLabel * lb[NUM_CHANNEL_SETTING];
for( int i = 0 ; i < NUM_CHANNEL_SETTING; i++){
hframe[i] = new TGHorizontalFrame(vframe, 50, 50 );
vframe->AddFrame(hframe[i], new TGLayoutHints(kLHintsRight, 2,2,2,2));
///----------- Trace on/off
if(settingName[i][0] == "TAU"){
TGHorizontalFrame *hframeTraceOnOff = new TGHorizontalFrame(vframe, 50, 50 );
vframe->AddFrame(hframeTraceOnOff, new TGLayoutHints(kLHintsRight, 2,2,2,2));
cbTraceOnOff = new TGComboBox(hframeTraceOnOff);
cbTraceOnOff->AddEntry("On", 1);
cbTraceOnOff->AddEntry("Off", 0);
cbTraceOnOff->Resize(width, 20);
//pixie->GetChannelTraceOnOff(boardID, ch) ? cbTraceOnOff->Select(1) : cbTraceOnOff->Select(0);
cbTraceOnOff->Connect("Selected(Int_t, Int_t)", "ChannelSetting", this, "ChangeOnOff()");
hframeTraceOnOff->AddFrame(cbTraceOnOff, new TGLayoutHints(kLHintsRight, 5,5,3,4));
TGLabel * lbTraceOnOff = new TGLabel(hframeTraceOnOff, "Trace On/Off");
hframeTraceOnOff->AddFrame(lbTraceOnOff, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 3, 4));
}
double temp = 0; // pixie->GetChannelSetting(settingName[i][0].Data(), boardID, ch, false);
TGNumberFormat::EStyle digi = TGNumberFormat::kNESInteger;
if( settingName[i][1] == "0" ) digi = TGNumberFormat::kNESInteger;
if( settingName[i][1] == "1" ) digi = TGNumberFormat::kNESRealOne;
if( settingName[i][1] == "2" ) digi = TGNumberFormat::kNESRealTwo;
if( settingName[i][1] == "3" ) digi = TGNumberFormat::kNESRealThree;
entry[i] = new TGNumberEntry(hframe[i], temp, 0, 0, digi, TGNumberFormat::kNEANonNegative);
entry[i]->Resize(width, 20);
if( i >= NUM_CHANNEL_SETTING - 3 ) {
entry[i]->SetState(false);
}else{
entry[i]->Connect("Modified()", "ChannelSetting", this, Form("ChangeID(=%d)", i));
}
hframe[i]->AddFrame(entry[i], new TGLayoutHints(kLHintsRight, 5,5,3,4));
lb[i] = new TGLabel(hframe[i], settingName[i][0] + (settingName[i][2] != "" ? " [" + settingName[i][2] + "]" : ""));
hframe[i]->AddFrame(lb[i], new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 3, 4));
}
fMain->MapSubwindows();
fMain->Resize(fMain->GetDefaultSize());
fMain->MapWindow();
isOpened = true;
}
ChannelSetting::~ChannelSetting(){
isOpened = false;
delete boardIDEntry;
delete cbOnOff;
delete cbTraceOnOff;
delete cbPolarity;
for ( int i = 0; i < NUM_CHANNEL_SETTING; i++){
delete entry[i];
}
/// fMain must be delete last;
fMain->Cleanup();
delete fMain;
}
void ChannelSetting::ChangeBoard(){
ChangeCh();
}
void ChannelSetting::ChangeCh(){
int boardID = boardIDEntry->GetNumber();
int ch = chIDEntry->GetNumber();
//pixie->GetChannelOnOff(boardID, ch) ? cbOnOff->Select(1) : cbOnOff->Select(0);
//pixie->GetChannelPolarity(boardID, ch) ? cbPolarity->Select(1) : cbPolarity->Select(0);
//pixie->GetChannelTraceOnOff(boardID, ch) ? cbTraceOnOff->Select(1) : cbTraceOnOff->Select(0);
for( int i = 0 ; i < NUM_CHANNEL_SETTING; i++){
double temp = 0 ;//pixie->GetChannelSetting(settingName[i][0].Data(), boardID, ch, false);
entry[i]->SetNumber(temp );
}
}
void ChannelSetting::ChangeOnOff(){
short boardID = boardIDEntry->GetNumber();
short ch = chIDEntry->GetNumber();
int val = cbOnOff->GetSelected();
//pixie->SetChannelOnOff(val, boardID, ch);
//pixie->SaveSettings(pixie->GetSettingFile(boardIDEntry->GetNumber()));
}
void ChannelSetting::ChangePolarity(){
short boardID = boardIDEntry->GetNumber();
short ch = chIDEntry->GetNumber();
int val = cbPolarity->GetSelected();
//pixie->SetChannelPositivePolarity(val, boardID, ch);
//pixie->SaveSettings(pixie->GetSettingFile(boardIDEntry->GetNumber()));
}
void ChannelSetting::ChangeTraceOnOff(){
short boardID = boardIDEntry->GetNumber();
short ch = chIDEntry->GetNumber();
int val = cbTraceOnOff->GetSelected();
//pixie->SetChannelTraceOnOff(val, boardID, ch);
//pixie->SaveSettings(pixie->GetSettingFile(boardIDEntry->GetNumber()));
}
void ChannelSetting::ChangeID(int id){
short boardID = boardIDEntry->GetNumber();
short ch = chIDEntry->GetNumber();
double val = entry[id]->GetNumber();
//pixie->SetChannelSetting(settingName[id][0].Data(), val, boardID, ch, 1);
//pixie->SaveSettings(pixie->GetSettingFile(boardIDEntry->GetNumber()));
}

44
channelSetting.h Normal file
View File

@ -0,0 +1,44 @@
#ifndef CHANNEL_SETTING_H
#define CHANNEL_SETTING_H
#include <TQObject.h>
#include <TGNumberEntry.h>
#include <TGComboBox.h>
#include <TGLabel.h>
#include "ClassDigitizer.h"
#include "macro.h"
#define NUM_CHANNEL_SETTING 17
class TGWindow;
class TGMainFrame;
class ChannelSetting{
private:
TGMainFrame * fMain;
TGNumberEntry * boardIDEntry, * chIDEntry;
TGComboBox * cbOnOff;
TGComboBox * cbPolarity;
TGComboBox * cbTraceOnOff;
TGNumberEntry * entry[NUM_CHANNEL_SETTING];
Digitizer ** digi;
int NChannel;
public:
ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nDigi);
virtual ~ChannelSetting();
void CloseWindow() { printf("close ChannelSetting window\n"); delete this; }
void ChangeBoard();
void ChangeCh();
void ChangeOnOff();
void ChangePolarity();
void ChangeTraceOnOff();
void ChangeID(int id);
bool isOpened;
};
#endif

View File

@ -1,8 +1,11 @@
#include "DigitizerPHA.h" #include "DigitizerPHA.h"
//#include "DigitizerPSD.h" #include "DigitizerPSD.h"
#include "ClassData.h"
int main(int argc, char* argv[]){ int main(int argc, char* argv[]){
/**************
const int nBoard = 1; const int nBoard = 1;
DigitizerPHA *dig = new DigitizerPHA[nBoard]; DigitizerPHA *dig = new DigitizerPHA[nBoard];
//DigitizerPSD * psd = new DigitizerPSD(); //DigitizerPSD * psd = new DigitizerPSD();
@ -13,40 +16,11 @@ int main(int argc, char* argv[]){
dig[i].OpenDigitizer(board, port, true); dig[i].OpenDigitizer(board, port, true);
dig[i].CreateAndSaveSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin"); dig[i].CreateAndSaveSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin");
//dig[i].OpenSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin"); //dig[i].OpenSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin");
//dig[i].SetAcqMode("list");
//dig[i].PrintACQStatue();
} }
//dig[0].WriteRegister(Register::DPP::FrontPanelTRGOUTEnableMask, 0xFF, -1);
//dig[0].WriteRegister(Register::DPP::FrontPanelIOControl, 0x100, -1);
//dig[0].WriteRegister(Register::DPP::TriggerValidationMask, 0, -1);
//dig[0].SetDPPAlgorithmControl(0x830200E);
//dig[0].SetInputDynamicRange(2);
//dig[0].SetTriggerThreshold(20);
//dig[0].SetChannelMask(0x8000); /// only channel 15
//dig[0].SetChannelMask(0xffff); /// all channels
//dig[0].SetWaveFormRecording(true);
//dig[0].SetPileUpFlag(false);
//dig[0].SetBits(Register::DPP::BoardConfiguration, 0x0101, 4, 20); // TRG validation window
//dig[0].PrintBoardConfiguration(); //[20:23] vitural probe
//dig[0].PrintChannelSettingFromDigitizer(7);
//dig[0].PrintChannelSettingFromDigitizer(8);
//dig[0].PrintChannelSettingFromDigitizer(9);
//dig[0].PrintChannelSettingFromDigitizer(10);
dig[0].PrintBoardConfiguration(); dig[0].PrintBoardConfiguration();
dig[0].PrintChannelSettingFromDigitizer(4); dig[0].PrintChannelSettingFromDigitizer(4);
//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::GlobalTriggerMask, -1, "GlobalTrigger mask");
//dig[0].ReadRegister(Register::DPP::FrontPanelTRGOUTEnableMask, -1, "Front Planel Trig-OUT mask"); /// should be 0xFF
//dig[0].ReadRegister(Register::DPP::FrontPanelIOControl, -1, "Front Planel I/O control");
//dig[0].ReadRegister(Register::DPP::DisableExternalTrigger, -1, "Disable External Trigger");
//dig[0].ReadRegister(Register::DPP::TriggerValidationMask, -1, "Trigger validation Mask");
//dig[0].PrintChannelSettingFromDigitizer(15);
Data * data = dig[0].data; Data * data = dig[0].data;
data->AllocateMemory(); data->AllocateMemory();
@ -56,17 +30,55 @@ int main(int argc, char* argv[]){
for( int p = 0; p < 11; p++){ for( int p = 0; p < 11; p++){
sleep(1); sleep(1);
dig[0].ReadData(); dig[0].ReadData();
data->DecodeBuffer(1);
} }
//printf("|%s|\n", data->buffer);
dig[0].StopACQ(); dig[0].StopACQ();
data->ReadAllBuffer(1);
delete [] dig; delete [] dig;
//delete psd; //delete psd;
*********************/
///********************* method for using Data Class for decoding bin file
/**
FILE * haha = fopen("output.bin", "r");
fseek(haha, 0L, SEEK_END);
size_t inFileSize = ftell(haha);
printf("file size : %d Byte\n", (int) inFileSize);
fclose(haha);
haha = fopen("output.bin", "r");
char * buffer = new char[(int)inFileSize];
size_t dump = fread(buffer, inFileSize, 1, haha);
fclose(haha);
Data * data = new Data();
data->buffer = buffer;
data->DecodeBuffer(3);
/*********************/
///****************************** casting digitizer type
Digitizer ** dig = new Digitizer *[2] ;
//dig[0] = new Digitizer();
dig[0] = new DigitizerPHA();
dig[1] = new DigitizerPSD();
printf("%d \n", dig[0]->GetDPPType());
printf("%d \n", dig[1]->GetDPPType());
((DigitizerPHA *)dig[0])->PrintBoardConfiguration();
((DigitizerPHA *)dig[0])->SetDPPAlgorithmControl2(0x10000);
return 0; return 0;
} }

View File

@ -91,7 +91,7 @@ void PrintChannelSettingFromDigitizer(int handle, int ch, float ch2ns){
printf("========= events storage and transfer\n"); 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::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::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); CAEN_DGTZ_ReadRegister(handle, Register::DPP::MaxNumberOfAggregatePerBlockTransfer , 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);
@ -281,7 +281,7 @@ int main(int argc, char* argv[]){
//ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration , 0x10E0114 ); //ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration , 0x10E0114 );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::NumberEventsPerAggregate_G + 0x7000, 5); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::NumberEventsPerAggregate_G + 0x7000, 5);
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::AggregateOrganization, 0); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::AggregateOrganization, 0);
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::MaxNumberOfAggregatePerBlackTransfer, 40); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::MaxNumberOfAggregatePerBlockTransfer, 40);
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::DPPAlgorithmControl + 0x7000, 0xe30200f); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::DPPAlgorithmControl + 0x7000, 0xe30200f);