diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index 4854d30..e4e2e3c 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -31,9 +31,9 @@ Digitizer::Digitizer(){ } -Digitizer::Digitizer(int boardID, int portID){ +Digitizer::Digitizer(int boardID, int portID, bool verbose){ Digitizer(); - OpenDigitizer(boardID, portID); + OpenDigitizer(boardID, portID, verbose); } Digitizer::~Digitizer(){ @@ -309,7 +309,7 @@ void Digitizer::StopACQ(){ unsigned int Digitizer::CalByteForBuffer(){ //TODO - unsigned int numAggBLT = ReadRegister(Register::DPP::MaxNumberOfAggregatePerBlockTransfer); + unsigned int numAggBLT = ReadRegister(Register::DPP::MaxAggregatePerBlockTransfer); /// Channel Mask /// is takeing waveForm @@ -350,7 +350,7 @@ void Digitizer::WriteRegister(uint32_t address, uint32_t value, int ch ){ }else{ ret = CAEN_DGTZ_WriteRegister(handle, address, value); } - ErrorMsg("WriteRegister"); + ErrorMsg("WriteRegister:" + std::to_string(address)); } uint32_t Digitizer::ReadRegister(uint32_t address, int ch, string str ){ @@ -365,7 +365,7 @@ uint32_t Digitizer::ReadRegister(uint32_t address, int ch, string str ){ }else{ ret = CAEN_DGTZ_ReadRegister(handle, address, Data); } - ErrorMsg("ReadRegister"); + ErrorMsg("ReadRegister:" + std::to_string(address)); if( str != "" ) printf("%s : 0x%x \n", str.c_str(), Data[0]); return Data[0]; } @@ -383,6 +383,12 @@ void Digitizer::SetRecordLength(unsigned int ns, int ch){ if( ch >= 0 ) WriteRegister( Register::DPP::RecordLength_G, ns / ch2ns / 8 , ch + int(pow(-1, ch))); ErrorMsg("SetRecordLength"); } + +void Digitizer::SetAggregateOrganization(unsigned int bit){ + WriteRegister(Register::DPP::AggregateOrganization, bit & 0x7); + ErrorMsg("SetAggregateOrganization"); +} + void Digitizer::SetEventAggregation(unsigned int numEvent, int ch){ WriteRegister( Register::DPP::NumberEventsPerAggregate_G,numEvent, ch); @@ -390,11 +396,37 @@ void Digitizer::SetEventAggregation(unsigned int numEvent, int ch){ ErrorMsg("SetEventAggregation"); } -void Digitizer::SetMaxNumberOfAggregatePerBlockTransfer(unsigned int numEvent){ - WriteRegister( Register::DPP::MaxNumberOfAggregatePerBlockTransfer,numEvent); +void Digitizer::SetMaxAggregatePerBlockTransfer(unsigned int numEvent){ + WriteRegister( Register::DPP::MaxAggregatePerBlockTransfer,numEvent); ErrorMsg("SetMaxNumberOfAggregatePerBlockTransfer"); } + +void Digitizer::SetACQControl(uint32_t bit){ + WriteRegister( Register::DPP::AcquisitionControl, bit); + ErrorMsg("SetACQControl"); +} + +void Digitizer::SetGlobalTriggerMask(uint32_t bit){ + WriteRegister( Register::DPP::GlobalTriggerMask, bit); + ErrorMsg("SetGlobalTriggerMask"); +} + +void Digitizer::SetFrontPanelTRGOUTMask(uint32_t bit){ + WriteRegister( Register::DPP::FrontPanelTRGOUTEnableMask, bit); + ErrorMsg("SetFrontPanelTRGOUTMask"); +} + +void Digitizer::SetFrontPanelIOControl(uint32_t bit){ + WriteRegister( Register::DPP::FrontPanelIOControl, bit); + ErrorMsg("SetFrontPanelIOControl"); +} + +void Digitizer::SetTriggerValidationMask(uint32_t bit){ + WriteRegister( Register::DPP::TriggerValidationMask, bit); + ErrorMsg("SetTriggerValidationMask"); +} + 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::SetPreTriggerDuration(unsigned int ns, int ch) { WriteRegister( Register::DPP::PreTrigger, ns / ch2ns / 4, ch); ErrorMsg("SetPreTriggerSample");} @@ -415,7 +447,6 @@ void Digitizer::SetTriggerPolarity(bool RiseingIsZero, int ch ){ if( ret != 0 ) ErrorMsg("SetTriggerPolarity"); } -void Digitizer::SetAggregateOrganization(unsigned int bit){ WriteRegister(Register::DPP::AggregateOrganization, bit & 0x7); ErrorMsg("SetAggregateOrganization");} //============================== DPP-Alpgorthm Control void Digitizer::SetDPPAlgorithmControl(uint32_t bit, int ch){ @@ -562,21 +593,24 @@ void Digitizer::CreateAndSaveSettingBinary(string fileName){ settingFileExist = true; ///Save board setting - EditByteByRegister(Register::DPP::BoardConfiguration); /// 0x8000 - EditByteByRegister(Register::DPP::GlobalTriggerMask); /// 0x810C - EditByteByRegister(Register::DPP::ChannelEnableMask); /// 0x8120 - EditByteByRegister(Register::DPP::FrontPanelTRGOUTEnableMask); /// 0x8110 - EditByteByRegister(Register::DPP::FrontPanelIOControl); /// 0x811C - EditByteByRegister(Register::DPP::DisableExternalTrigger); /// 0x817C - EditByteByRegister(Register::DPP::TriggerValidationMask); /// 0x8180 - EditByteByRegister(Register::DPP::ROM_BoardVersion); /// 0xF030 - EditByteByRegister(Register::DPP::ROM_BoardFromFactor); /// 0xF034 - EditByteByRegister(Register::DPP::ROM_BoardIDByte1); /// 0xF038 - EditByteByRegister(Register::DPP::ROM_BoardIDByte0); /// 0xF03C - EditByteByRegister(Register::DPP::ROM_BoardSerialNumByte1); /// 0xF080 - EditByteByRegister(Register::DPP::ROM_BoardSerialNumByte0); /// 0xF084 - EditByteByRegister(Register::DPP::ROCFPGAFirmwareRevision); /// 0x8124 - EditByteByRegister(Register::DPP::BoardInfo); /// 0x8140 + EditByteByRegister(Register::DPP::BoardConfiguration); /// 0x8000 + EditByteByRegister(Register::DPP::AggregateOrganization); /// 0x800C + EditByteByRegister(Register::DPP::GlobalTriggerMask); /// 0x810C + EditByteByRegister(Register::DPP::ChannelEnableMask); /// 0x8120 + EditByteByRegister(Register::DPP::ROM_BoardVersion); /// 0xF030 + EditByteByRegister(Register::DPP::ROM_BoardFromFactor); /// 0xF034 + EditByteByRegister(Register::DPP::ROM_BoardIDByte1); /// 0xF038 + EditByteByRegister(Register::DPP::ROM_BoardIDByte0); /// 0xF03C + EditByteByRegister(Register::DPP::ROM_BoardSerialNumByte1); /// 0xF080 + EditByteByRegister(Register::DPP::ROM_BoardSerialNumByte0); /// 0xF084 + EditByteByRegister(Register::DPP::FrontPanelTRGOUTEnableMask); /// 0x8110 + EditByteByRegister(Register::DPP::FrontPanelIOControl); /// 0x811C + EditByteByRegister(Register::DPP::ROCFPGAFirmwareRevision); /// 0x8124 + EditByteByRegister(Register::DPP::BoardInfo); /// 0x8140 + EditByteByRegister(Register::DPP::DisableExternalTrigger); /// 0x817C + EditByteByRegister(Register::DPP::TriggerValidationMask); /// 0x8180 + EditByteByRegister(Register::DPP::MaxAggregatePerBlockTransfer); /// 0xEF1C + ///================ channel settings for( int ch = 0; ch < NChannel ; ch++){ diff --git a/ClassDigitizer.h b/ClassDigitizer.h index 5edfa60..6c20acb 100644 --- a/ClassDigitizer.h +++ b/ClassDigitizer.h @@ -23,7 +23,7 @@ class Digitizer{ public: Digitizer(); - Digitizer(int boardID, int portID = 0); + Digitizer(int boardID, int portID = 0, bool verbose = false); ~Digitizer(); @@ -47,11 +47,17 @@ class Digitizer{ void SetEventAggregation(unsigned int numEvent, int ch = -1); void SetAggregateOrganization(unsigned int bit); - void SetMaxNumberOfAggregatePerBlockTransfer(unsigned int numEvent); + void SetMaxAggregatePerBlockTransfer(unsigned int numEvent); 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 SetACQControl(uint32_t bit); + void SetGlobalTriggerMask(uint32_t bit); + void SetFrontPanelTRGOUTMask(uint32_t bit); + void SetFrontPanelIOControl(uint32_t bit); + void SetTriggerValidationMask(uint32_t bit); + //void SetBoardID(unsigned int ID) {WriteRegister(Register::DPP::BoardID, ID)); ///================ Get Settings @@ -74,7 +80,7 @@ class Digitizer{ unsigned int GetEventAggregation(int ch = -1) {return ReadRegister(Register::DPP::NumberEventsPerAggregate_G, ch);} unsigned int GetAggregateOrganization() {return ReadRegister(Register::DPP::AggregateOrganization);} - unsigned int GetMaxNumberOfAggregatePerBlockTransfer() {return ReadRegister(Register::DPP::MaxNumberOfAggregatePerBlockTransfer);} + unsigned int GetMaxNumberOfAggregatePerBlockTransfer() {return ReadRegister(Register::DPP::MaxAggregatePerBlockTransfer);} 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);} diff --git a/DigitizerPHA.cpp b/DigitizerPHA.cpp index 3e18c35..303e53d 100644 --- a/DigitizerPHA.cpp +++ b/DigitizerPHA.cpp @@ -4,8 +4,8 @@ DigitizerPHA::DigitizerPHA(){ DPPType = V1730_DPP_PHA_CODE; } -DigitizerPHA::DigitizerPHA(int boardID, int portID){ - OpenDigitizer(boardID, portID); +DigitizerPHA::DigitizerPHA(int boardID, int portID, bool verbose){ + OpenDigitizer(boardID, portID, verbose); } DigitizerPHA::~DigitizerPHA(){ @@ -52,7 +52,7 @@ int DigitizerPHA::ProgramBoard(){ ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::NumberEventsPerAggregate_G + 0x7000, 1000); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::AggregateOrganization, 0); - ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::MaxNumberOfAggregatePerBlockTransfer, 40); + ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::MaxAggregatePerBlockTransfer, 40); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::DPPAlgorithmControl + 0x7000, 0xe30200f); if( ret != 0 ) { printf("==== set channels error.\n"); return 0;} @@ -62,6 +62,189 @@ int DigitizerPHA::ProgramBoard(){ return ret; } +void DigitizerPHA::SetSetting(Setting::PHA settingName, float value, int ch){ + + unsigned int input = 0; + + switch(settingName){ + /// board setting + case Setting::PHA::AutoDataFlush_board_bool: input = value; SetBits(Register::DPP::BoardConfiguration, input, 1, 0); break; + case Setting::PHA::DualTrace_board_bool: input = value; SetBits(Register::DPP::BoardConfiguration, input, 1, 11); break; + case Setting::PHA::AnalogProbe1_board_2bit: input = value; SetBits(Register::DPP::BoardConfiguration, input, 2, 12); break; + case Setting::PHA::AnalogProbe2_board_2bit: input = value; SetBits(Register::DPP::BoardConfiguration, input, 2, 14); break; + case Setting::PHA::WavefromRecording_board_bool: input = value; SetBits(Register::DPP::BoardConfiguration, input, 1, 16); break; + case Setting::PHA::EnableExtra2Word_board_bool: input = value; SetBits(Register::DPP::BoardConfiguration, input, 1, 17); break; + case Setting::PHA::EnergyRecording_board_bool: input = value; SetBits(Register::DPP::BoardConfiguration, input, 1, 19); break; + case Setting::PHA::VirtualProbe_board_4bit: input = value; SetBits(Register::DPP::BoardConfiguration, input, 1, 20); break; + + /// DPP Algorithm Control 1 + case Setting::PHA::TrapazoidRescaling_5bit: input = value; SetBits(Register::DPP::DPPAlgorithmControl, input, 5, 0, ch); break; + case Setting::PHA::WaveformDecimation_2bit: input = value; SetBits(Register::DPP::DPPAlgorithmControl, input, 2, 8, ch); break; + case Setting::PHA::WaveformDecimationGain_2bit: input = value; SetBits(Register::DPP::DPPAlgorithmControl, input, 2, 10, ch); break; + case Setting::PHA::PeakSampling_2bit: input = value; SetBits(Register::DPP::DPPAlgorithmControl, input, 2, 12, ch); break; + case Setting::PHA::PulsePolarity_bool: input = value; SetBits(Register::DPP::DPPAlgorithmControl, input, 1, 16, ch); break; + case Setting::PHA::TriggerMode_2bit: input = value; SetBits(Register::DPP::DPPAlgorithmControl, input, 2, 18, ch); break; + case Setting::PHA::BaselineSampling_3bit: input = value; SetBits(Register::DPP::DPPAlgorithmControl, input, 3, 20, ch); break; + case Setting::PHA::DisableSelfTrigger_bool: input = value; SetBits(Register::DPP::DPPAlgorithmControl, input, 1, 24, ch); break; + case Setting::PHA::RolloverFlag_bool: input = value; SetBits(Register::DPP::DPPAlgorithmControl, input, 1, 26, ch); break; + case Setting::PHA::PileupFlag_bool: input = value; SetBits(Register::DPP::DPPAlgorithmControl, input, 1, 27, ch); break; + + /// DPP Algorithm Control 2 + case Setting::PHA::LocalShapedTrigger_bool: input = value; SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 1, 2, ch); break; + case Setting::PHA::LocalShapedTriggerMode_2bit: input = value; SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 2, 0, ch); break; + case Setting::PHA::LocalTriggerValidation_bool: input = value; SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 1, 6, ch); break; + case Setting::PHA::LocalTriggerValidationMode_2bit: input = value; SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 2, 4, ch); break; + case Setting::PHA::Extra2WordOption_3bit: input = value; SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 3, 8, ch); break; + case Setting::PHA::VetoSource_2bit: input = value; SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 2, 14, ch); break; + case Setting::PHA::TriggerCounterRateStep_2bit: input = value; SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 2, 16, ch); break; + case Setting::PHA::BaselineCalculationWhenACQOFF_bool: input = value; SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 1, 18, ch); break; + case Setting::PHA::TagCorrelatedEvents_bool: input = value; SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 1, 19, ch); break; + case Setting::PHA::BaselineRestoreOptimization_bool: input = value; SetBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 1, 29, ch); break; + + /// ACQ control + case Setting::PHA::StartStopMode_2bit: input = value; SetBits(Register::DPP::AcquisitionControl, input, 2, 0); break; + case Setting::PHA::StartStopACQ_bool: input = value; SetBits(Register::DPP::AcquisitionControl, input, 1, 2); break; + case Setting::PHA::PLLClockSource_bool: input = value; SetBits(Register::DPP::AcquisitionControl, input, 1, 6); break; + case Setting::PHA::VetoInForTRGOUT_bool: input = value; SetBits(Register::DPP::AcquisitionControl, input, 1, 12); break; + + /// Registers + case Setting::PHA::RecordLength_G_ns: input = value / 8 / ch2ns; WriteRegister(Register::DPP::RecordLength_G, input, ch) ; break; + case Setting::PHA::PreTriggerLength_ns: input = value / 4 / ch2ns; WriteRegister(Register::DPP::PreTrigger, input, ch) ; break; + case Setting::PHA::InputDynamicRange_bool: input = value; WriteRegister(Register::DPP::InputDynamicRange, input, ch) ; break; + case Setting::PHA::DCOffset_precentage: input = (1.0 - value) * 0xFFFF; WriteRegister(Register::DPP::ChannelDCOffset, input, ch) ; break; + + case Setting::PHA::EventPreAggregate_G_max1023: input = value; WriteRegister(Register::DPP::NumberEventsPerAggregate_G, input, ch) ; break; + case Setting::PHA::AggregateOrganization_board_3bit: input = value; WriteRegister(Register::DPP::AggregateOrganization , input, ch) ; break; + case Setting::PHA::MaxAggregatePreBlockTransfer_board_10bit: input = value; WriteRegister(Register::DPP::MaxAggregatePerBlockTransfer, input, ch) ; break; + + case Setting::PHA::VetoWidth_ns:{ + unsigned int input = 0 ; + if( value <= 4 * ch2ns ){ + input = 0; + }else if( 4 * ch2ns < value && value <= 1000 * ch2ns ){ + input = 1; + }else if(1000 * ch2ns < value && value <= 262000 * ch2ns){ + input = 2; + }else{ + input = 3; + } + WriteRegister(Register::DPP::VetoWidth, input, ch) ; + break; + } + + case Setting::PHA::TriggerThreshold_LSD: input = value; WriteRegister(Register::DPP::PHA::TriggerThreshold , input, ch); break; + case Setting::PHA::TriggerHoldOffWidth_ns: input = value / 4/ ch2ns; WriteRegister(Register::DPP::PHA::TriggerHoldOffWidth , input, ch); break; + case Setting::PHA::TriggerSmoothingFactor_5bit: input = value; WriteRegister(Register::DPP::PHA::RCCR2SmoothingFactor , input, ch); break; + case Setting::PHA::TriggerOutputWidth_ns: input = value / 4/ ch2ns; WriteRegister(Register::DPP::PHA::ShapedTriggerWidth , input, ch); break; + case Setting::PHA::InputRiseTime_ns: input = value / 4/ ch2ns; WriteRegister(Register::DPP::PHA::InputRiseTime , input, ch); break; + + case Setting::PHA::TrapezoidRiseTime_ns: input = value / 4/ ch2ns; WriteRegister(Register::DPP::PHA::TrapezoidRiseTime, input, ch); break; + case Setting::PHA::TrapezoidFlatTop_ns: input = value / 4/ ch2ns; WriteRegister(Register::DPP::PHA::TrapezoidFlatTop, input, ch); break; + case Setting::PHA::DecayTime_ns: input = value / 4/ ch2ns; WriteRegister(Register::DPP::PHA::DecayTime, input, ch); break; + case Setting::PHA::PeakingTime_ns: input = value / 4/ ch2ns; WriteRegister(Register::DPP::PHA::PeakingTime, input, ch); break; + case Setting::PHA::PeakingHoldOff_ns: input = value / 4/ ch2ns; WriteRegister(Register::DPP::PHA::PeakHoldOff, input, ch); break; + + case Setting::PHA::EnergyFineGain_16bit: input = value; WriteRegister(Register::DPP::PHA::FineGain, input, ch); break; + + case Setting::PHA::RiseTimeValidationWindow_ns: input = value / ch2ns; WriteRegister(Register::DPP::PHA::RiseTimeValidationWindow, input, ch); break; + + } + + ErrorMsg("PHA-" + std::to_string(settingName) ); + + +} + + +double DigitizerPHA::GetSetting(Setting::PHA settingName, int ch){ + + double value = 0; + unsigned int temp; + + switch(settingName){ + /// board setting + case Setting::PHA::AutoDataFlush_board_bool: temp = ReadBits(Register::DPP::BoardConfiguration, 1, 0); value = temp; break; + case Setting::PHA::DualTrace_board_bool: temp = ReadBits(Register::DPP::BoardConfiguration, 1, 11); value = temp; break; + case Setting::PHA::AnalogProbe1_board_2bit: temp = ReadBits(Register::DPP::BoardConfiguration, 2, 12); value = temp; break; + case Setting::PHA::AnalogProbe2_board_2bit: temp = ReadBits(Register::DPP::BoardConfiguration, 2, 14); value = temp; break; + case Setting::PHA::WavefromRecording_board_bool: temp = ReadBits(Register::DPP::BoardConfiguration, 1, 16); value = temp; break; + case Setting::PHA::EnableExtra2Word_board_bool: temp = ReadBits(Register::DPP::BoardConfiguration, 1, 17); value = temp; break; + case Setting::PHA::EnergyRecording_board_bool: temp = ReadBits(Register::DPP::BoardConfiguration, 1, 19); value = temp; break; + case Setting::PHA::VirtualProbe_board_4bit: temp = ReadBits(Register::DPP::BoardConfiguration, 4, 20); value = temp; break; + + /// DPP Algorithm Control 1 + case Setting::PHA::TrapazoidRescaling_5bit: temp = ReadBits(Register::DPP::DPPAlgorithmControl, 5, 0, ch); value = temp; break; + case Setting::PHA::WaveformDecimation_2bit: temp = ReadBits(Register::DPP::DPPAlgorithmControl, 2, 8, ch); value = temp; break; + case Setting::PHA::WaveformDecimationGain_2bit: temp = ReadBits(Register::DPP::DPPAlgorithmControl, 2, 10, ch); value = temp; break; + case Setting::PHA::PeakSampling_2bit: temp = ReadBits(Register::DPP::DPPAlgorithmControl, 2, 12, ch); value = pow(4, temp); break; + case Setting::PHA::PulsePolarity_bool: temp = ReadBits(Register::DPP::DPPAlgorithmControl, 1, 16, ch); value = temp; break; + case Setting::PHA::TriggerMode_2bit: temp = ReadBits(Register::DPP::DPPAlgorithmControl, 2, 18, ch); value = temp; break; + case Setting::PHA::BaselineSampling_3bit: temp = ReadBits(Register::DPP::DPPAlgorithmControl, 3, 20, ch); value = pow(4, 1 + temp); break; + case Setting::PHA::DisableSelfTrigger_bool: temp = ReadBits(Register::DPP::DPPAlgorithmControl, 1, 24, ch); value = temp; break; + case Setting::PHA::RolloverFlag_bool: temp = ReadBits(Register::DPP::DPPAlgorithmControl, 1, 26, ch); value = temp; break; + case Setting::PHA::PileupFlag_bool: temp = ReadBits(Register::DPP::DPPAlgorithmControl, 1, 27, ch); value = temp; break; + + /// DPP Algorithm Control 2 + case Setting::PHA::LocalShapedTriggerMode_2bit: temp = ReadBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 2, 0, ch); value = temp; break; + case Setting::PHA::LocalShapedTrigger_bool: temp = ReadBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 1, 2, ch); value = temp; break; + case Setting::PHA::LocalTriggerValidationMode_2bit: temp = ReadBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 2, 4, ch); value = temp; break; + case Setting::PHA::LocalTriggerValidation_bool: temp = ReadBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 1, 6, ch); value = temp; break; + case Setting::PHA::Extra2WordOption_3bit: temp = ReadBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 3, 8, ch); value = temp; break; + case Setting::PHA::VetoSource_2bit: temp = ReadBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 2, 14, ch); value = temp; break; + case Setting::PHA::TriggerCounterRateStep_2bit: temp = ReadBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 1, 16, ch); value = temp; break; + case Setting::PHA::BaselineCalculationWhenACQOFF_bool: temp = ReadBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 1, 18, ch); value = temp; break; + case Setting::PHA::TagCorrelatedEvents_bool: temp = ReadBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 1, 19, ch); value = temp; break; + case Setting::PHA::BaselineRestoreOptimization_bool: temp = ReadBits(Register::DPP::PHA::DPPAlgorithmControl2_G, 1, 29, ch); value = temp; break; + + /// ACQ control + case Setting::PHA::StartStopMode_2bit: temp = ReadBits(Register::DPP::AcquisitionControl, 2, 0); value = temp; break; + case Setting::PHA::StartStopACQ_bool: temp = ReadBits(Register::DPP::AcquisitionControl, 1, 2); value = temp; break; + case Setting::PHA::PLLClockSource_bool: temp = ReadBits(Register::DPP::AcquisitionControl, 1, 6); value = temp; break; + case Setting::PHA::VetoInForTRGOUT_bool: temp = ReadBits(Register::DPP::AcquisitionControl, 1, 12); value = temp; break; + + /// Registers + case Setting::PHA::RecordLength_G_ns: temp = ReadRegister(Register::DPP::RecordLength_G , ch); value = temp * 8 * ch2ns;break; + case Setting::PHA::PreTriggerLength_ns: temp = ReadRegister(Register::DPP::PreTrigger , ch); value = temp * 4 * ch2ns;break; + case Setting::PHA::InputDynamicRange_bool: temp = ReadRegister(Register::DPP::InputDynamicRange , ch); value = temp;break; + case Setting::PHA::DCOffset_precentage: temp = ReadRegister(Register::DPP::ChannelDCOffset , ch); value = 1.0 - temp * 1.0 / 0xFFFF ;break; + case Setting::PHA::EventPreAggregate_G_max1023: temp = ReadRegister(Register::DPP::NumberEventsPerAggregate_G , ch); value = temp; break; + + case Setting::PHA::VetoWidth_ns: { + temp = ReadRegister(Register::DPP::VetoWidth , ch); + switch( temp) { + case 0 : value = 4 * ch2ns; break; ///ns + case 1 : value = 1000 * ch2ns; break; ///ns + case 2 : value = 262000 * ch2ns; break; ///ns + case 3 : value = 66000000 * ch2ns; break; ///ns + default : value = temp; break; /// bit + } + break; + } + case Setting::PHA::AggregateOrganization_board_3bit:{ + temp = ReadRegister(Register::DPP::AggregateOrganization , ch); + value = ((temp & 0x007) < 2 ? 0 : (int)pow(2, temp & 7)); + break; + } + case Setting::PHA::MaxAggregatePreBlockTransfer_board_10bit: temp = ReadRegister(Register::DPP::MaxAggregatePerBlockTransfer , ch); value = temp; break; + + case Setting::PHA::TriggerThreshold_LSD: temp = ReadRegister(Register::DPP::PHA::TriggerThreshold , ch); value = temp; break; + case Setting::PHA::TriggerHoldOffWidth_ns: temp = ReadRegister(Register::DPP::PHA::TriggerHoldOffWidth , ch); value = temp * 4 * ch2ns; break; + case Setting::PHA::TriggerSmoothingFactor_5bit: temp = ReadRegister(Register::DPP::PHA::RCCR2SmoothingFactor , ch); value = (temp & 0x1f) * 2 * ch2ns;break; + case Setting::PHA::TriggerOutputWidth_ns: temp = ReadRegister(Register::DPP::PHA::ShapedTriggerWidth , ch); value = temp * 4 * ch2ns; break; + case Setting::PHA::InputRiseTime_ns: temp = ReadRegister(Register::DPP::PHA::InputRiseTime , ch); value = temp * 4 * ch2ns; break; + + case Setting::PHA::TrapezoidRiseTime_ns: temp = ReadRegister(Register::DPP::PHA::TrapezoidRiseTime , ch); value = temp * 4 * ch2ns; break; + case Setting::PHA::TrapezoidFlatTop_ns: temp = ReadRegister(Register::DPP::PHA::TrapezoidFlatTop , ch); value = temp * 4 * ch2ns; break; + case Setting::PHA::DecayTime_ns: temp = ReadRegister(Register::DPP::PHA::DecayTime , ch); value = temp * 4 * ch2ns; break; + case Setting::PHA::PeakingTime_ns: temp = ReadRegister(Register::DPP::PHA::PeakingTime , ch); value = temp * 4 * ch2ns; break; + case Setting::PHA::PeakingHoldOff_ns: temp = ReadRegister(Register::DPP::PHA::PeakHoldOff , ch); value = temp * 4 * ch2ns; break; + case Setting::PHA::EnergyFineGain_16bit: temp = ReadRegister(Register::DPP::PHA::FineGain , ch); value = temp; break; + case Setting::PHA::RiseTimeValidationWindow_ns: temp = ReadRegister(Register::DPP::PHA::RiseTimeValidationWindow , ch); value = temp * ch2ns; break; + + } + + return value; +} void DigitizerPHA::AutoSetTrapezoidRescalingAndFindGate(double gain, int ch){ @@ -192,14 +375,14 @@ void DigitizerPHA::PrintChannelSettingFromDigitizer(int ch){ printf("%24s %5.0f samples, DPP-[20:22]\n", "baseline mean", pow(4, 1 + baseline)); ///Ns baseline CAEN_DGTZ_ReadRegister(handle, Register::DPP::ChannelDCOffset + (ch << 8), value); printf("%24s %.2f %% \n", "DC offset", 100.0 - value[0] * 100./ 0xFFFF); ///DC offset CAEN_DGTZ_ReadRegister(handle, Register::DPP::InputDynamicRange + (ch << 8), value); printf("%24s %.1f Vpp \n", "input Dynamic", value[0] == 0 ? 2 : 0.5); ///InputDynamic - printf("%24s %s, DPP-[16]\n", "polarity", polarity == 0 ? "Positive" : "negative"); ///Polarity + printf("%24s %s, DPP-[16]\n", "polarity", polarity == 0 ? "Positive" : "negative"); ///Polarity printf("==========----- discriminator \n"); - CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::TriggerThreshold + (ch << 8), value); printf("%24s %4d LSB\n", "Threshold", value[0]); ///Threshold - CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::TriggerHoldOffWidth + (ch << 8), value); printf("%24s %4d samples, %5.0f ns \n", "trigger hold off", value[0], value[0] * 4 * ch2ns); ///Trigger Hold off + CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::TriggerThreshold + (ch << 8), value); printf("%24s %4d LSB\n", "Threshold", value[0]); ///Threshold + CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::TriggerHoldOffWidth + (ch << 8), value); printf("%24s %4d samples, %5.0f ns \n", "trigger hold off", value[0], value[0] * 4 * ch2ns); ///Trigger Hold off CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::RCCR2SmoothingFactor + (ch << 8), value); printf("%24s %4d samples, %5.0f ns \n", "Fast Dis. smoothing", (value[0] & 0x1f) * 2, (value[0] & 0x1f) * 2 * ch2ns ); ///Fast Discriminator smoothing - CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::ShapedTriggerWidth + (ch << 8), value); printf("%24s %4d samples, %5.0f ns \n", "Fast Dis. output width", value[0], value[0] * 4 * ch2ns); ///Fast Dis. output width - CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::InputRiseTime + (ch << 8), value); printf("%24s %4d samples, %5.0f ns \n", "Input rise time ", value[0], value[0] * 4 * ch2ns); ///Input rise time + CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::ShapedTriggerWidth + (ch << 8), value); printf("%24s %4d samples, %5.0f ns \n", "Fast Dis. output width", value[0], value[0] * 4 * ch2ns); ///Fast Dis. output width + CAEN_DGTZ_ReadRegister(handle, Register::DPP::PHA::InputRiseTime + (ch << 8), value); printf("%24s %4d samples, %5.0f ns \n", "Input rise time ", value[0], value[0] * 4 * ch2ns); ///Input rise time printf("==========----- Trapezoid \n"); 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 @@ -227,7 +410,7 @@ void DigitizerPHA::PrintChannelSettingFromDigitizer(int ch){ 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::MaxNumberOfAggregatePerBlockTransfer , value); printf("%24s %d \n", "Num of Agg. / ReadData", value[0] & 0x1FF); + CAEN_DGTZ_ReadRegister(handle, Register::DPP::MaxAggregatePerBlockTransfer , value); printf("%24s %d \n", "Num of Agg. / ReadData", value[0] & 0x1FF); printf("========================================= end of ch-%d\n", ch); diff --git a/DigitizerPHA.h b/DigitizerPHA.h index 0b005a3..566c3cf 100644 --- a/DigitizerPHA.h +++ b/DigitizerPHA.h @@ -7,21 +7,23 @@ class DigitizerPHA : public Digitizer { public: DigitizerPHA(); - DigitizerPHA(int boardID, int portID = 0); + DigitizerPHA(int boardID, int portID = 0, bool verbose = false); ~DigitizerPHA(); int ProgramBoard(); + + void SetSetting(Setting::PHA settingName, float value, int ch = -1); - void SetAutoDataFlush(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 0); ErrorMsg("PHA-SetAutoDataFlush"); } - void SetDualTrace(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 11); ErrorMsg("PHA-SetDualTrace"); } - void SetAnalogProbe1(unsigned int bit) { SetBits(Register::DPP::BoardConfiguration, bit, 2, 12); ErrorMsg("PHA-SetAnalogProbe1"); } - void SetAnalogProbe2(unsigned int bit) { SetBits(Register::DPP::BoardConfiguration, bit, 2, 14); ErrorMsg("PHA-SetAnalogProbe1"); } - void SetWaveFormRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 16); ErrorMsg("PHA-SetWaveFormRecording"); } - void SetEnableExtra2Word(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 17); ErrorMsg("PHA-SetEnableExtra2Word"); } - void SetTimeStampRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 18); ErrorMsg("PHA-SetTimeStampRecording"); } - void SetEnergyRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 19); ErrorMsg("PHA-SetEnergyRecording");} - void SetVirtualProbe1(unsigned int bit){ SetBits(Register::DPP::BoardConfiguration, bit, 4, 20); ErrorMsg("PHA-SetVirtualProbe1"); } - + void SetAutoDataFlush(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 0); ErrorMsg("PHA-SetAutoDataFlush"); } + void SetDualTrace(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 11); ErrorMsg("PHA-SetDualTrace"); } + void SetAnalogProbe1(unsigned short bit) { SetBits(Register::DPP::BoardConfiguration, bit, 2, 12); ErrorMsg("PHA-SetAnalogProbe1"); } + void SetAnalogProbe2(unsigned short bit) { SetBits(Register::DPP::BoardConfiguration, bit, 2, 14); ErrorMsg("PHA-SetAnalogProbe1"); } + void SetWaveFormRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 16); ErrorMsg("PHA-SetWaveFormRecording"); } + void SetEnableExtra2Word(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 17); ErrorMsg("PHA-SetEnableExtra2Word"); } + void SetTimeStampRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 18); ErrorMsg("PHA-SetTimeStampRecording"); } + void SetEnergyRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 19); ErrorMsg("PHA-SetEnergyRecording");} + void SetVirtualProbe1(unsigned short bit){ SetBits(Register::DPP::BoardConfiguration, bit, 4, 20); ErrorMsg("PHA-SetVirtualProbe1"); } + void 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"); } @@ -64,6 +66,8 @@ class DigitizerPHA : public Digitizer { void SetRiseTimeValidWindow(unsigned int nSample, int ch = -1){ WriteRegister(Register::DPP::PHA::RiseTimeValidationWindow,nSample & 0x03FF, ch); ErrorMsg("PHA-SetRiseTimeValidWindow");} ///=================== Get settings + double GetSetting(Setting::PHA settingName, 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);} diff --git a/RegisterAddress.h b/RegisterAddress.h index 32597ea..e10c7da 100644 --- a/RegisterAddress.h +++ b/RegisterAddress.h @@ -59,7 +59,7 @@ namespace Register { const uint32_t RelocationAddress = 0xEF10; /// R/W const uint32_t InterruptStatusID = 0xEF14; /// R/W const uint32_t InterruptEventNumber = 0xEF18; /// R/W - const uint32_t MaxNumberOfAggregatePerBlockTransfer = 0xEF1C; /// R/W + const uint32_t MaxAggregatePerBlockTransfer = 0xEF1C; /// R/W const uint32_t Scratch = 0xEF20; /// R/W const uint32_t SoftwareReset = 0xEF24; /// W const uint32_t SoftwareClear = 0xEF28; /// W @@ -117,7 +117,7 @@ namespace Register { const uint32_t RelocationAddress = 0xEF10; /// R/W const uint32_t InterruptStatusID = 0xEF14; /// R/W const uint32_t InterruptEventNumber = 0xEF18; /// R/W - const uint32_t MaxNumberOfAggregatePerBlockTransfer = 0xEF1C; /// R/W + const uint32_t MaxAggregatePerBlockTransfer = 0xEF1C; /// R/W const uint32_t Scratch = 0xEF20; /// R/W const uint32_t SoftwareReset = 0xEF24; /// W const uint32_t SoftwareClear = 0xEF28; /// W @@ -185,4 +185,78 @@ namespace Register { } } + +/// This provides an alternative way for control +namespace Setting{ + + enum PHA{ + /// board setting + AutoDataFlush_board_bool, + DualTrace_board_bool, + AnalogProbe1_board_2bit, + AnalogProbe2_board_2bit, + WavefromRecording_board_bool, + EnableExtra2Word_board_bool, + EnergyRecording_board_bool, + VirtualProbe_board_4bit, + + /// DPP Algorithm Control 1 + TrapazoidRescaling_5bit, + WaveformDecimation_2bit, + WaveformDecimationGain_2bit, + PeakSampling_2bit, + PulsePolarity_bool, + TriggerMode_2bit, + BaselineSampling_3bit, + DisableSelfTrigger_bool, + RolloverFlag_bool, + PileupFlag_bool, + + /// DPP Algorithm Control 2 + LocalShapedTrigger_bool, + LocalShapedTriggerMode_2bit, + LocalTriggerValidation_bool, + LocalTriggerValidationMode_2bit, + Extra2WordOption_3bit, + VetoSource_2bit, + TriggerCounterRateStep_2bit, + BaselineCalculationWhenACQOFF_bool, + TagCorrelatedEvents_bool, + BaselineRestoreOptimization_bool, + + ///ACQ control + StartStopMode_2bit, + StartStopACQ_bool, + PLLClockSource_bool, + VetoInForTRGOUT_bool, + + /// Registers + RecordLength_G_ns, + PreTriggerLength_ns, + InputDynamicRange_bool, + DCOffset_precentage, + VetoWidth_ns, + EventPreAggregate_G_max1023, + AggregateOrganization_board_3bit, + MaxAggregatePreBlockTransfer_board_10bit, + + TriggerThreshold_LSD, + TriggerHoldOffWidth_ns, + TriggerSmoothingFactor_5bit, + TriggerOutputWidth_ns, + InputRiseTime_ns, + + TrapezoidRiseTime_ns, + TrapezoidFlatTop_ns, + DecayTime_ns, + PeakingTime_ns, + PeakingHoldOff_ns, + EnergyFineGain_16bit, + RiseTimeValidationWindow_ns + + }; + + +} + #endif diff --git a/boardSetting.cpp b/boardSetting.cpp index a670c13..70d412e 100644 --- a/boardSetting.cpp +++ b/boardSetting.cpp @@ -71,10 +71,8 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d } ///========= Board Configure - TGGroupFrame * gBdCfg = new TGGroupFrame(vframe, "Board Configure", kHorizontalFrame); vframe->AddFrame(gBdCfg , new TGLayoutHints(kLHintsExpandX)); TGVerticalFrame * vBdCfg = new TGVerticalFrame(gBdCfg); gBdCfg->AddFrame(vBdCfg); - TGHorizontalFrame * hframeBdCfg1 = new TGHorizontalFrame(vBdCfg); vBdCfg->AddFrame(hframeBdCfg1, layoutHints); TGCheckButton * bAutoDataFlush = new TGCheckButton(hframeBdCfg1, "Auto Data Flush", 1); hframeBdCfg1->AddFrame(bAutoDataFlush, layoutHints); @@ -179,7 +177,32 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d cbFanCtrl->Select(0x30); cbFanCtrl->Resize(100, 20); + ///========== ACQ control + TGGroupFrame * gAcqCtrl = new TGGroupFrame(vframe, "ACQ Control", kHorizontalFrame); vframe->AddFrame(gAcqCtrl , new TGLayoutHints(kLHintsExpandX)); + TGVerticalFrame * vAcqCtrl = new TGVerticalFrame(gAcqCtrl); gAcqCtrl->AddFrame(vAcqCtrl); + TGHorizontalFrame * hfAcqCtrl = new TGHorizontalFrame(vAcqCtrl); vAcqCtrl->AddFrame(hfAcqCtrl, layoutHints); + + TGLabel * lbAcqMode = new TGLabel(hfAcqCtrl, "ACQ Mode"); hfAcqCtrl->AddFrame(lbAcqMode, layoutHints); + TGComboBox * cbAcqMode = new TGComboBox(hfAcqCtrl, "ACQ Mode", 1); hfAcqCtrl->AddFrame(cbAcqMode, layoutHints); + cbAcqMode->EnableTextInput(false); + cbAcqMode->AddEntry("Software", 0); + cbAcqMode->AddEntry("S-IN / GPI", 1); + cbAcqMode->AddEntry("1st Trig. Ctrl.", 2); + cbAcqMode->AddEntry("LVSD Ctrl.", 3); + cbAcqMode->Select(0); + cbAcqMode->Resize(100, 20); + + TGCheckButton * bAcqArm = new TGCheckButton(hfAcqCtrl, "ACQ Start/Arm", 1); hfAcqCtrl->AddFrame(bAcqArm, layoutHints); + bAcqArm->SetState(kButtonUp); + //bAcqArm->Connect("Clicked()", "BoardSetting", this, "SetAutoDataFlush()"); + TGLabel * lbPLLref = new TGLabel(hfAcqCtrl, "PLL Ref."); hfAcqCtrl->AddFrame(lbPLLref, layoutHints); + TGComboBox * cbPLLref = new TGComboBox(hfAcqCtrl, "PLL Ref.", 1); hfAcqCtrl->AddFrame(cbPLLref, layoutHints); + cbPLLref->EnableTextInput(false); + cbPLLref->AddEntry("internal", 0); + cbPLLref->AddEntry("external", 1); + cbPLLref->Select(0); + cbPLLref->Resize(100, 20); ///========= Trigger Configure TGGroupFrame * gTRGCfg = new TGGroupFrame(vframe, "Trigger Configure", kHorizontalFrame); vframe->AddFrame(gTRGCfg, new TGLayoutHints(kLHintsExpandX)); @@ -448,6 +471,12 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d txtVMEFIFO->SetTextColor(kGreen); + ///===== LVSD + TGHorizontalFrame * hframeLVSD = new TGHorizontalFrame(vframe); vframe->AddFrame(hframeLVSD, new TGLayoutHints(kLHintsCenterY , 5,5,3,4)); + TGLabel * lbLVSD = new TGLabel(hframeLVSD, "LVSD Control is not impletmented."); hframeLVSD->AddFrame(lbLVSD, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 5, 5, 3, 2)); + + + ///==================== Read digitizer Setting ReadDigitizerSetting(); diff --git a/channelSetting.cpp b/channelSetting.cpp index df3cdea..5df55f4 100644 --- a/channelSetting.cpp +++ b/channelSetting.cpp @@ -13,7 +13,6 @@ //TODO set MAX ///------------------------------------------------ NAME, DIGI, unit ... MAX TString settingName[NUM_CHANNEL_SETTING][3] = {{"Record Length", "3", "us"}, - {"Input Dynamic Range", "1", ""}, {"Events / Aggregate", "4", ""}, {"Pre-Trigger Length", "3", "us"}, {"Trigger Threshold", "5", "LSD"}, @@ -67,6 +66,8 @@ ChannelSetting::ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer fMain->SetWindowName("Channel Settings "); fMain->Connect("CloseWindow()", "ChannelSetting", this, "CloseWindow()"); + TGLayoutHints * layoutHints = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5,5,3,3); /// left, right, top, bottom + TGVerticalFrame * vframe = new TGVerticalFrame(fMain); fMain->AddFrame(vframe, new TGLayoutHints(kLHintsCenterX, 2,2,2,2)); @@ -98,37 +99,42 @@ ChannelSetting::ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer 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)); + TGGroupFrame * gfInput = new TGGroupFrame(vframe, "Input / Trigger", kHorizontalFrame); vframe->AddFrame(gfInput, new TGLayoutHints(kLHintsExpandX)); + TGVerticalFrame * vfInput = new TGVerticalFrame(gfInput); gfInput->AddFrame(vfInput); + TGHorizontalFrame * hfInput1 = new TGHorizontalFrame(vfInput); vfInput->AddFrame(hfInput1, layoutHints); - cbOnOff = new TGComboBox(hframeOnOff); + ///----------- on/off + TGLabel * lbOnOff = new TGLabel(hfInput1, "On/Off"); hfInput1->AddFrame(lbOnOff, new TGLayoutHints( kLHintsCenterY, 5, 5, 3, 4)); + cbOnOff = new TGComboBox(hfInput1); hfInput1->AddFrame(cbOnOff, new TGLayoutHints(kLHintsCenterY, 5,5,3,4)); 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); + TGLabel * lbPol = new TGLabel(hfInput1, "Polarity");hfInput1->AddFrame(lbPol, new TGLayoutHints( kLHintsCenterY, 5, 5, 3, 4)); + cbPolarity = new TGComboBox(hfInput1); hfInput1->AddFrame(cbPolarity, new TGLayoutHints(kLHintsCenterY, 5,5,3,4)); 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)); - - - + + ///---------- Input Dynamic Range + TGLabel * lbInputDynamicRange = new TGLabel(hfInput1, "Input Range");hfInput1->AddFrame(lbInputDynamicRange, new TGLayoutHints( kLHintsCenterY, 5, 5, 3, 4)); + cbInputDynamicRange = new TGComboBox(hfInput1); hfInput1->AddFrame(cbInputDynamicRange, new TGLayoutHints(kLHintsCenterY, 5,5,3,4)); + cbInputDynamicRange->AddEntry("2.0 Vpp", 0); + cbInputDynamicRange->AddEntry("0.5 Vpp", 1); + cbInputDynamicRange->Resize(width, 20); + cbInputDynamicRange->Select(0); + + ///---------- Record Length + TGLabel * lbRecordLength = new TGLabel(hfInput1, "Record Length");hfInput1->AddFrame(lbRecordLength, new TGLayoutHints( kLHintsCenterY, 5, 5, 3, 4)); + //TGNumberEntry* entry = new TGNumberEntry(hfInput1, temp, 0, 0, digi, TGNumberFormat::kNEANonNegative); + // entry[i]->Resize(width, 20); ///----- all other TGHorizontalFrame *hframe[NUM_CHANNEL_SETTING]; @@ -137,22 +143,6 @@ ChannelSetting::ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer 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); @@ -191,7 +181,7 @@ ChannelSetting::~ChannelSetting(){ delete boardIDEntry; delete cbOnOff; - delete cbTraceOnOff; + delete cbInputDynamicRange; delete cbPolarity; for ( int i = 0; i < NUM_CHANNEL_SETTING; i++){ @@ -236,14 +226,6 @@ void ChannelSetting::ChangePolarity(){ //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(); diff --git a/channelSetting.h b/channelSetting.h index d0c6b58..6288f96 100644 --- a/channelSetting.h +++ b/channelSetting.h @@ -3,12 +3,13 @@ #include #include +#include #include #include #include "ClassDigitizer.h" #include "macro.h" -#define NUM_CHANNEL_SETTING 21 +#define NUM_CHANNEL_SETTING 20 class TGWindow; class TGMainFrame; @@ -21,7 +22,7 @@ class ChannelSetting{ TGComboBox * cbOnOff; TGComboBox * cbPolarity; - TGComboBox * cbTraceOnOff; + TGComboBox * cbInputDynamicRange; TGNumberEntry * entry[NUM_CHANNEL_SETTING]; @@ -36,7 +37,6 @@ class ChannelSetting{ void ChangeCh(); void ChangeOnOff(); void ChangePolarity(); - void ChangeTraceOnOff(); void ChangeID(int id); bool isOpened; diff --git a/test.cpp b/test.cpp index 6207f47..9be8d6e 100644 --- a/test.cpp +++ b/test.cpp @@ -12,7 +12,7 @@ int main(int argc, char* argv[]){ for( int i = 0 ; i < nBoard; i++){ int board = i % 3; int port = i/3; - dig[i] = new DigitizerPHA(board, port); + dig[i] = new DigitizerPHA(board, port, true); dig[i]->CreateAndSaveSettingBinary("setting_" + to_string(dig[i]->GetSerialNumber()) + ".bin"); //dig[i].OpenSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin"); } @@ -23,6 +23,8 @@ int main(int argc, char* argv[]){ pha->PrintChannelSettingFromDigitizer(0); pha->PrintChannelSettingFromDigitizer(15); + pha->GetSetting(Setting::PHA::AnalogProbe1_board_2bit); + remove("test.bin"); Data * data = pha->GetData(); diff --git a/test_indep.cpp b/test_indep.cpp index 9da142c..5e915a5 100644 --- a/test_indep.cpp +++ b/test_indep.cpp @@ -91,7 +91,7 @@ void PrintChannelSettingFromDigitizer(int handle, int ch, float ch2ns){ 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::MaxNumberOfAggregatePerBlockTransfer , value); printf("%24s %d \n", "Num of Agg. / ReadData", value[0] & 0x1FF); + CAEN_DGTZ_ReadRegister(handle, Register::DPP::MaxAggregatePerBlockTransfer , value); printf("%24s %d \n", "Num of Agg. / ReadData", value[0] & 0x1FF); 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::NumberEventsPerAggregate_G + 0x7000, 5); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::AggregateOrganization, 0); - ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::MaxNumberOfAggregatePerBlockTransfer, 40); + ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::MaxAggregatePerBlockTransfer, 40); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::DPPAlgorithmControl + 0x7000, 0xe30200f);