diff --git a/DigitizerPHA.cpp b/DigitizerPHA.cpp index 0e84aae..6ed558b 100644 --- a/DigitizerPHA.cpp +++ b/DigitizerPHA.cpp @@ -107,15 +107,34 @@ void DigitizerPHA::SetSetting(Setting::PHA settingName, float value, int ch){ 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; + /// Global Trigger Mask + case Setting::PHA::GlobalTrgMask_8bit: input = value; SetBits(Register::DPP::GlobalTriggerMask, input, 8, 0); break; + case Setting::PHA::GlobalTrgMajorityCoincienceWindow_4bit: input = value; SetBits(Register::DPP::GlobalTriggerMask, input, 4, 20); break; + case Setting::PHA::GlobalTrgMajorityLevel_3bit: input = value; SetBits(Register::DPP::GlobalTriggerMask, input, 3, 24); break; + case Setting::PHA::GlobalTrgExternalTrigger_bool: input = value; SetBits(Register::DPP::GlobalTriggerMask, input, 1, 30); break; + case Setting::PHA::GlobalTrgSoftwareTrigger_bool: input = value; SetBits(Register::DPP::GlobalTriggerMask, input, 1, 31); break; + + /// Front Panel TRG-OUT Mask + case Setting::PHA::FrontTRGOUTMask_8bit: input = value; SetBits(Register::DPP::FrontPanelTRGOUTEnableMask, input, 8, 0); break; + case Setting::PHA::FrontTRGOUTLogic_2bit: input = value; SetBits(Register::DPP::FrontPanelTRGOUTEnableMask, input, 2, 8); break; + case Setting::PHA::FrontTRGOUTMajorityLevel_3bit: input = value; SetBits(Register::DPP::FrontPanelTRGOUTEnableMask, input, 3, 10); break; + case Setting::PHA::FrontTRGOUTExternalTrigger_bool: input = value; SetBits(Register::DPP::FrontPanelTRGOUTEnableMask, input, 1, 30); break; + case Setting::PHA::FrontTRGOUTSoftwareTrigger_bool: input = value; SetBits(Register::DPP::FrontPanelTRGOUTEnableMask, input, 1, 31); break; + + /// Front Plane I/O + case Setting::PHA::FrontPanelIO_LEMO_bool: input = value; SetBits(Register::DPP::FrontPanelIOControl, input, 1, 0); break; + case Setting::PHA::FrontPanelIO_TRGOUT_bool: input = value; SetBits(Register::DPP::FrontPanelIOControl, input, 1, 1); break; + case Setting::PHA::FrontPanelIO_TRGINCtrl_bool: input = value; SetBits(Register::DPP::FrontPanelIOControl, input, 1, 10); break; + case Setting::PHA::FrontPanelIO_TRGINtoMezzanines_bool: input = value; SetBits(Register::DPP::FrontPanelIOControl, input, 1, 11); break; + case Setting::PHA::FrontPanelIO_TRGOUTmode_6bit: input = value; SetBits(Register::DPP::FrontPanelIOControl, input, 6, 14); break; + /// Trigger Validation Mask - case Setting::PHA::TriggerValidationMask_8bit: input = value; SetBits(Register::DPP::TriggerValidationMask, input, 8, 0); break; - case Setting::PHA::TriggerValidationOperation_2bit: input = value; SetBits(Register::DPP::TriggerValidationMask, input, 2, 8); break; - case Setting::PHA::TriggerValidationMajority_3bit: input = value; SetBits(Register::DPP::TriggerValidationMask, input, 3, 10); break; - case Setting::PHA::ExternalTrigger_bool: input = value; SetBits(Register::DPP::TriggerValidationMask, input, 1, 30); break; - case Setting::PHA::SoftwareTrigger_bool: input = value; SetBits(Register::DPP::TriggerValidationMask, input, 1, 31); break; - - case Setting::PHA::RunStartStopDelay_8bit: input = value; WriteRegister(Register::DPP::RunStartStopDelay, input); break; - + case Setting::PHA::TriggerValidationMask_8bit: input = value; SetBits(Register::DPP::TriggerValidationMask, input, 8, 0); break; + case Setting::PHA::TriggerValidationOperation_2bit: input = value; SetBits(Register::DPP::TriggerValidationMask, input, 2, 8); break; + case Setting::PHA::TriggerValidationMajority_3bit: input = value; SetBits(Register::DPP::TriggerValidationMask, input, 3, 10); break; + case Setting::PHA::TriggerValidationExternalTrigger_bool: input = value; SetBits(Register::DPP::TriggerValidationMask, input, 1, 30); break; + case Setting::PHA::TriggerValidationSoftwareTrigger_bool: input = value; SetBits(Register::DPP::TriggerValidationMask, input, 1, 31); 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; @@ -158,8 +177,12 @@ void DigitizerPHA::SetSetting(Setting::PHA settingName, float value, int ch){ case Setting::PHA::RiseTimeValidationWindow_ns: input = value / ch2ns; WriteRegister(Register::DPP::PHA::RiseTimeValidationWindow, input, ch); break; /// Others - //case Setting::PHA::FanSpeedControl_bool: input = value; WriteRegister(Register::DPP::PHA::FanSpeedControl, input); break; - + case Setting::PHA::FanSpeedControl_bool: input = value; WriteRegister(Register::DPP::FanSpeedControl, input); break; + case Setting::PHA::RunStartStopDelay_8bit: input = value; WriteRegister(Register::DPP::RunStartStopDelay, input); break; + case Setting::PHA::DisableExternalTrigger_bool: input = value; WriteRegister(Register::DPP::DisableExternalTrigger, input); break; + case Setting::PHA::ExtendedVetoDelay_16bit: input = value; WriteRegister(Register::DPP::ExtendedVetoDelay, input); break; + case Setting::PHA::AnalogMonitorMode_3bit: input = value; WriteRegister(Register::DPP::AnalogMonitorMode, input); break; + } ErrorMsg("PHA-" + std::to_string(settingName) ); @@ -215,15 +238,34 @@ double DigitizerPHA::GetSetting(Setting::PHA settingName, int ch){ 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; + + /// Global Trigger Mask + case Setting::PHA::GlobalTrgMask_8bit: temp = ReadBits(Register::DPP::GlobalTriggerMask, 8, 0); value = temp; break; + case Setting::PHA::GlobalTrgMajorityCoincienceWindow_4bit: temp = ReadBits(Register::DPP::GlobalTriggerMask, 4, 20); value = temp; break; + case Setting::PHA::GlobalTrgMajorityLevel_3bit: temp = ReadBits(Register::DPP::GlobalTriggerMask, 3, 24); value = temp; break; + case Setting::PHA::GlobalTrgExternalTrigger_bool: temp = ReadBits(Register::DPP::GlobalTriggerMask, 1, 30); value = temp; break; + case Setting::PHA::GlobalTrgSoftwareTrigger_bool: temp = ReadBits(Register::DPP::GlobalTriggerMask, 1, 31); value = temp; break; + + /// Front Panel TRG-OUT Mask + case Setting::PHA::FrontTRGOUTMask_8bit: temp = ReadBits(Register::DPP::FrontPanelTRGOUTEnableMask, 8, 0); value = temp; break; + case Setting::PHA::FrontTRGOUTLogic_2bit: temp = ReadBits(Register::DPP::FrontPanelTRGOUTEnableMask, 2, 8); value = temp; break; + case Setting::PHA::FrontTRGOUTMajorityLevel_3bit: temp = ReadBits(Register::DPP::FrontPanelTRGOUTEnableMask, 3, 10); value = temp; break; + case Setting::PHA::FrontTRGOUTExternalTrigger_bool: temp = ReadBits(Register::DPP::FrontPanelTRGOUTEnableMask, 1, 30); value = temp; break; + case Setting::PHA::FrontTRGOUTSoftwareTrigger_bool: temp = ReadBits(Register::DPP::FrontPanelTRGOUTEnableMask, 1, 31); value = temp; break; + + /// Front Plane I/O + case Setting::PHA::FrontPanelIO_LEMO_bool: temp = ReadBits(Register::DPP::FrontPanelIOControl, 1, 0); value = temp; break; + case Setting::PHA::FrontPanelIO_TRGOUT_bool: temp = ReadBits(Register::DPP::FrontPanelIOControl, 1, 1); value = temp; break; + case Setting::PHA::FrontPanelIO_TRGINCtrl_bool: temp = ReadBits(Register::DPP::FrontPanelIOControl, 1, 10); value = temp; break; + case Setting::PHA::FrontPanelIO_TRGINtoMezzanines_bool: temp = ReadBits(Register::DPP::FrontPanelIOControl, 1, 11); value = temp; break; + case Setting::PHA::FrontPanelIO_TRGOUTmode_6bit: temp = ReadBits(Register::DPP::FrontPanelIOControl, 6, 14); value = temp; break; /// Trigger Validation Mask - case Setting::PHA::TriggerValidationMask_8bit: temp = ReadBits(Register::DPP::TriggerValidationMask, 8, 0); value = temp; break; - case Setting::PHA::TriggerValidationOperation_2bit: temp = ReadBits(Register::DPP::TriggerValidationMask, 2, 8); value = temp; break; - case Setting::PHA::TriggerValidationMajority_3bit: temp = ReadBits(Register::DPP::TriggerValidationMask, 3, 10); value = temp; break; - case Setting::PHA::ExternalTrigger_bool: temp = ReadBits(Register::DPP::TriggerValidationMask, 1, 30); value = temp; break; - case Setting::PHA::SoftwareTrigger_bool: temp = ReadBits(Register::DPP::TriggerValidationMask, 1, 31); value = temp; break; - - case Setting::PHA::RunStartStopDelay_8bit: temp = ReadRegister(Register::DPP::RunStartStopDelay); value = temp & 0xFF; break; + case Setting::PHA::TriggerValidationMask_8bit: temp = ReadBits(Register::DPP::TriggerValidationMask, 8, 0); value = temp; break; + case Setting::PHA::TriggerValidationOperation_2bit: temp = ReadBits(Register::DPP::TriggerValidationMask, 2, 8); value = temp; break; + case Setting::PHA::TriggerValidationMajority_3bit: temp = ReadBits(Register::DPP::TriggerValidationMask, 3, 10); value = temp; break; + case Setting::PHA::TriggerValidationExternalTrigger_bool: temp = ReadBits(Register::DPP::TriggerValidationMask, 1, 30); value = temp; break; + case Setting::PHA::TriggerValidationSoftwareTrigger_bool: temp = ReadBits(Register::DPP::TriggerValidationMask, 1, 31); value = temp; break; /// Registers case Setting::PHA::RecordLength_G_ns: temp = ReadRegister(Register::DPP::RecordLength_G , ch); value = temp * 8 * ch2ns;break; @@ -265,8 +307,12 @@ double DigitizerPHA::GetSetting(Setting::PHA settingName, int ch){ case Setting::PHA::RiseTimeValidationWindow_ns: temp = ReadRegister(Register::DPP::PHA::RiseTimeValidationWindow , ch); value = temp * ch2ns; break; /// Others - case Setting::PHA::FanSpeedControl_bool: temp = ReadRegister(Register::DPP::FanSpeedControl); value = temp & 0x8; break; - + case Setting::PHA::FanSpeedControl_bool: temp = ReadRegister(Register::DPP::FanSpeedControl); value = temp & 0x8; break; + case Setting::PHA::RunStartStopDelay_8bit: temp = ReadRegister(Register::DPP::RunStartStopDelay); value = temp & 0xFF; break; + case Setting::PHA::DisableExternalTrigger_bool: temp = ReadRegister(Register::DPP::DisableExternalTrigger); value = temp & 0x1; break; + case Setting::PHA::ExtendedVetoDelay_16bit: temp = ReadRegister(Register::DPP::ExtendedVetoDelay); value = temp & 0xffff; break; + case Setting::PHA::AnalogMonitorMode_3bit: temp = ReadRegister(Register::DPP::AnalogMonitorMode); value = temp & 0x7; break; + } return value; @@ -364,11 +410,11 @@ void DigitizerPHA::PrintACQControl(){ } ///==== ACQ Start/Arm - printf(" Bit[ 2] = %d = Start/Arm (%s)", value & 0x4, (value & 0x4) == 0 ? "STOP" : "RUN" ); - printf(" Bit[ 6] = %d = PLL Ref. Clock (%s)", value & 0x40, (value & 0x40) == 0 ? "Internal" : "External" ); - printf(" Bit[ 8] = %d = LVDS I/O Busy Enable (%s)", value & 0x100, (value & 0x100) == 0 ? "Disabled" : "Enabled" ); - printf(" Bit[ 8] = %d = LVDS I/O Veto Enable (%s)", value & 0x200, (value & 0x200) == 0 ? "Disabled" : "Enabled" ); - printf(" Bit[ 12] = %d = Veto-in as veto for TRG-OUT (%s)", value & 0x1000, (value & 0x1000) == 0 ? "not used" : "used" ); + printf(" Bit[ 2] = %d = Start/Arm (%s)\n", value & 0x4, (value & 0x4) == 0 ? "STOP" : "RUN" ); + printf(" Bit[ 6] = %d = PLL Ref. Clock (%s)\n", value & 0x40, (value & 0x40) == 0 ? "Internal" : "External" ); + printf(" Bit[ 8] = %d = LVDS I/O Busy Enable (%s)\n", value & 0x100, (value & 0x100) == 0 ? "Disabled" : "Enabled" ); + printf(" Bit[ 8] = %d = LVDS I/O Veto Enable (%s)\n", value & 0x200, (value & 0x200) == 0 ? "Disabled" : "Enabled" ); + printf(" Bit[ 12] = %d = Veto-in as veto for TRG-OUT (%s)\n", value & 0x1000, (value & 0x1000) == 0 ? "not used" : "used" ); } @@ -377,12 +423,12 @@ void DigitizerPHA::PrintGlobalTriggerMask(){ if( !isConnected ) return; uint32_t value = PrintRegister(Register::DPP::GlobalTriggerMask, "Global Trigger Mask"); - printf(" Bit[ 7:0] = 0x%x = Enabled Paired Channel", value & 0xff ); - printf(" Bit[23:20] = %.0f ns = Majority Coincidence Window", (( value >> 20 ) & 0xf) * 4 * ch2ns ); - printf(" Bit[26:24] = %d = Majority Level", (( value >> 24 ) & 0x7) ); - printf(" Bit[ 29] = %d = LVDS Trigger(%s)", (( value >> 29 ) & 0x1), (( value >> 29 ) & 0x1) == 0 ? "disabled" : "enabled" ); - printf(" Bit[ 30] = %d = External Trigger(%s)", (( value >> 30 ) & 0x1), (( value >> 30 ) & 0x1) == 0 ? "disabled" : "enabled" ); - printf(" Bit[ 31] = %d = Software Trigger(%s)", (( value >> 31 ) & 0x1), (( value >> 31 ) & 0x1) == 0 ? "disabled" : "enabled" ); + printf(" Bit[ 7:0] = 0x%x = Enabled Paired Channel\n", value & 0xff ); + printf(" Bit[23:20] = %.0f ns = Majority Coincidence Window\n", (( value >> 20 ) & 0xf) * 4 * ch2ns ); + printf(" Bit[26:24] = %d = Majority Level\n", (( value >> 24 ) & 0x7) ); + printf(" Bit[ 29] = %d = LVDS Trigger(%s)\n", (( value >> 29 ) & 0x1), (( value >> 29 ) & 0x1) == 0 ? "disabled" : "enabled" ); + printf(" Bit[ 30] = %d = External Trigger(%s)\n", (( value >> 30 ) & 0x1), (( value >> 30 ) & 0x1) == 0 ? "disabled" : "enabled" ); + printf(" Bit[ 31] = %d = Software Trigger(%s)\n", (( value >> 31 ) & 0x1), (( value >> 31 ) & 0x1) == 0 ? "disabled" : "enabled" ); } @@ -390,38 +436,132 @@ void DigitizerPHA::PrintFrontPanelTRIGOUTEnableMask(){ if( !isConnected ) return; uint32_t value = PrintRegister(Register::DPP::FrontPanelTRGOUTEnableMask, "Front Panel TRG-OUT Mask"); + printf(" Bit[ 7:0] = 0x%x = Enabled Paired Channel\n", value & 0xff ); + printf(" Bit[ 9:8] = %d = TRG-OUT Logic (", (value >> 8) & 0x3 ); + switch ( ( value>>8) & 0x3 ){ + case 0 : printf("OR)\n"); break; + case 1 : printf("AND)\n"); break; + case 2 : printf("MAjority)\n"); break; + } + printf(" Bit[12:10] = %d = Majority Level\n", (value >> 10) & 0x7 ); + printf(" Bit[ 29] = %d = LVDS Trigger(%s)\n", (( value >> 29 ) & 0x1), (( value >> 29 ) & 0x1) == 0 ? "disabled" : "enabled" ); + printf(" Bit[ 30] = %d = External Trigger(%s)\n", (( value >> 30 ) & 0x1), (( value >> 30 ) & 0x1) == 0 ? "disabled" : "enabled" ); + printf(" Bit[ 31] = %d = Software Trigger(%s)\n", (( value >> 31 ) & 0x1), (( value >> 31 ) & 0x1) == 0 ? "disabled" : "enabled" ); + } void DigitizerPHA::PrintFrontPanelIOControl(){ if( !isConnected ) return; uint32_t value = PrintRegister(Register::DPP::FrontPanelIOControl, "Front Panel I/O Control"); + printf(" Bit[ 0] = %d = LEMO I/O (%s)\n", value & 0x1, (value & 0x1) == 0 ? "NIM" : "TTL" ); + printf(" Bit[ 1] = %d = TRG-OUT (%s)\n", (value >> 1) & 0x1, ((value >> 1) & 0x1) == 0 ? "enabled" : "high impedance" ); + printf(" Bit[ 2] = %d = LVDS I/O [3:0] (%s)\n", (value >> 2) & 0x1, ((value >> 2) & 0x1) == 0 ? "input" : "output" ); + printf(" Bit[ 3] = %d = LVDS I/O [7:4] (%s)\n", (value >> 3) & 0x1, ((value >> 3) & 0x1) == 0 ? "input" : "output" ); + printf(" Bit[ 4] = %d = LVDS I/O [11:8] (%s)\n", (value >> 4) & 0x1, ((value >> 4) & 0x1) == 0 ? "input" : "output" ); + printf(" Bit[ 5] = %d = LVDS I/O [15:12] (%s)\n", (value >> 5) & 0x1, ((value >> 5) & 0x1) == 0 ? "input" : "output" ); + printf(" Bit[ 7:6] = %d = LVDS I/O Signal Config (", (value >> 6) & 0x3); + switch ((value >> 6) & 0x3){ + case 0 : printf("general pupose)\n"); break; + case 1 : printf("programmed)\n"); break; + case 2 : printf("pattern mode)\n"); break; + } + printf(" Bit[ 8] = %d = LVDS I/O feature (%s)\n", (value >> 8) & 0x1, ((value >> 8) & 0x1) == 0? "old" : "new" ); + printf(" Bit[ 9] = %d = LVDS I/O Latch Mode (%s)\n", (value >> 9) & 0x1, ((value >> 9) & 0x1) == 0? "global trigger" : "external trigger" ); + printf(" Bit[ 10] = %d = TRG-IN control (%s)\n", (value >> 10) & 0x1, ((value >> 10) & 0x1) == 0? "trigger sync with the edge of TRG-IN" : "triger sync with whole TRG-IN"); + printf(" Bit[ 11] = %d = TRG-IN to Mezzanines (%s)\n", (value >> 11) & 0x1, ((value >> 11) & 0x1) == 0? "by motherboard" : "directly to mezzanine"); + printf(" Bit[ 14] = %d = Force TRG-OUT(%s)\n", (value >> 14) & 0x1, ((value >> 14) & 0x1) == 0? "0" : "1"); + printf(" Bit[ 15] = %d = TRG-OUT mode(%s)\n", (value >> 15) & 0x1, ((value >> 15) & 0x1) == 0? "internal" : "Forced"); + printf(" Bit[17:16] = %d = TRG-OUT mode(", (value >> 16) & 0x3); + switch ((value >> 16) & 0x3) { + case 0 : printf("Trigger)\n"); break; + case 1 : printf("Motherboard Probe)\n"); break; + case 2 : printf("Channel Probe)\n"); break; + case 3 : printf("S-IN)\n"); break; + } + printf(" Bit[19:18] = %d = Motherboard Probe(", (value >> 18) & 0x3); + switch ((value >> 18) & 0x3) { + case 0 : printf("RUN)\n"); break; + case 1 : printf("Clock)\n"); break; + case 2 : printf("Clock Phase)\n"); break; + case 3 : printf("BUSY/UNLOCK)\n"); break; + } + printf(" Bit[22:21] = %d = Patten Configure(%s)", (value >> 21) & 0x3, ((value >> 21) & 0x3) == 0 ? "default" : "Reserved"); + } void DigitizerPHA::PrintTriggerValidationMask(){ if( !isConnected ) return; uint32_t value = PrintRegister(Register::DPP::TriggerValidationMask, "Trigger Validation Mask"); + printf(" Bit[ 7:0] = 0x%x = Enabled Paired Channel\n", value & 0xff ); + printf(" Bit[ 9:8] = %d = Operation (\n", (value >> 8) & 0x3 ); + switch ( (value >> 8) & 0x3 ) { + case 0 : printf("OR)\n"); break; + case 1 : printf("AND)\n"); break; + case 2 : printf("Majority)\n"); break; + case 3 : printf("Reserved)\n"); break; + } + printf(" Bit[12:10] = %d = Majority Level\n", (value >> 10) & 0x7 ); + printf(" Bit[ 28] = %d = LVDS I/O Global Trigger(%s)\n", (value >> 28) & 0x1, ((value >> 28) & 0x1) == 0 ? "disabled" : "enabled" ); + printf(" Bit[ 29] = %d = LVDS I/O individual Trigger(%s)\n", (value >> 29) & 0x1, ((value >> 29) & 0x1) == 0 ? "disabled" : "enabled" ); + printf(" Bit[ 30] = %d = External Trigger(%s)\n", (value >> 30) & 0x1, ((value >> 30) & 0x1) == 0 ? "disabled" : "enabled" ); + printf(" Bit[ 31] = %d = Software Trigger(%s)\n", (value >> 31) & 0x1, ((value >> 31) & 0x1) == 0 ? "disabled" : "enabled" ); + } void DigitizerPHA::PrintBoardInfoRegister(){ if( !isConnected ) return; uint32_t value = PrintRegister(Register::DPP::BoardInfo, "Board Info"); + + printf(" Bit[ 7:0] = %d = Digitizer Family Code ", value & 0xff ); + switch ( value & 0xff ) { + case 0x0E : printf("( 725 family )\n"); break; + case 0x0B : printf("( 730 family )\n"); break; + } + printf(" Bit[ 15:8] = %d = Channel Memory Code ", (value >> 8 ) & 0xff ); + switch ( (value >> 8 )& 0xff ) { + case 0x01 : printf("( 640 kSample per channel)\n"); break; + case 0x08 : printf("( 5.12 MSample per channel)\n"); break; + } + printf(" Bit[23:16] = %d = Channel Number ", (value >> 16 ) & 0xff ); + switch ( (value >> 16 )& 0xff ) { + case 0x10 : printf("( 16 Channel )\n"); break; + case 0x08 : printf("( 8 Channel )\n"); break; + } + } void DigitizerPHA::PrintBoardFailureState(){ if( !isConnected ) return; uint32_t value = PrintRegister(Register::DPP::BoardFailureStatus, "Board Failure State"); + + printf(" Bit[4] = %d = PLL Lock Loss (%s)\n", (value >> 4) & 0x1, ( (value >> 4) & 0x1 ) == 0 ? "no error" : "Lock Loss"); + printf(" Bit[5] = %d = Temperature Failure (%s)\n", (value >> 5) & 0x1, ( (value >> 5) & 0x1 ) == 0 ? "no error" : "over heat"); + printf(" Bit[6] = %d = ADC Power Down (%s)\n", (value >> 6) & 0x1, ( (value >> 6) & 0x1 ) == 0 ? "no error" : "down"); } void DigitizerPHA::PrintReadoutControl(){ if( !isConnected ) return; uint32_t value = PrintRegister(Register::DPP::ReadoutControl, "Readout Control"); + + printf(" Bit[2:0] = %d = VME Interrupt Level %s\n", value & 0x3, ( value & 0x3 ) == 0 ? "(disabled)" : ""); + printf(" Bit[ 3] = %d = Optical Link Interrupt (%s)\n", (value >> 3) & 0x1, ( (value >> 3) & 0x1 ) == 0 ? "disabled" : "enabled"); + printf(" Bit[ 4] = %d = VME Bus Error / Event Aligned Readout (%s)\n", (value >> 4) & 0x1, ((value >> 4) & 0x1) == 0 ? "disabled" : "enabled") ; + printf(" Bit[ 5] = %d = VME Align64 Mode (%s)\n", (value >> 5) & 0x1, ((value >> 5) & 0x1) == 0 ? "disabled" : "enabled") ; + printf(" Bit[ 6] = %d = VME Base Address Relocation (%s)\n", (value >> 6) & 0x1, ((value >> 6) & 0x1) == 0 ? "disabled" : "enabled") ; + printf(" Bit[ 7] = %d = Interrupt Release Mode (%s)\n", (value >> 7) & 0x1, ((value >> 7) & 0x1) == 0 ? "Release On Register Access" : "Release On Acknowledge") ; + printf(" Bit[ 8] = %d = Extended Block Transfer Space (%s)\n", (value >> 8) & 0x1, ((value >> 8) & 0x1) == 0 ? "Release On Register Access" : "Release On Acknowledge") ; + } void DigitizerPHA::PrintReadoutStatu(){ if( !isConnected ) return; uint32_t value = PrintRegister(Register::DPP::ReadoutStatus, "Readout Status"); + + printf(" Bit[0] = %d = Event Ready (%s)\n", value & 0x1, (value & 0x1) == 0? "no date" : "ready"); + printf(" Bit[2] = %d = Bus Error (%s)\n", (value >> 2) & 0x1, ((value >> 2) & 0x1) == 0? "no error" : "error occurred"); + printf(" Bit[3] = %d = VME FIFO Flag (%s)\n", (value >> 3) & 0x1, ((value >> 3) & 0x1) == 0? "not empty" : "empty"); } void DigitizerPHA::PrintChannelSettingFromDigitizer(int ch){ diff --git a/DigitizerPHA.h b/DigitizerPHA.h index eb1fb7f..eff99b1 100644 --- a/DigitizerPHA.h +++ b/DigitizerPHA.h @@ -12,8 +12,31 @@ class DigitizerPHA : public Digitizer { int ProgramBoard(); + ///=================== Set Settings void SetSetting(Setting::PHA settingName, float value, int ch = -1); + + void SetTrapezoidRescaling(unsigned int rightShiftBits, int ch = -1){ SetBits(Register::DPP::DPPAlgorithmControl, rightShiftBits, 5, 0, ch); ErrorMsg("PHA-SetTrapezoidRescaling"); } + void SetEnergyFineGain(unsigned int gain, int ch = -1) { WriteRegister(Register::DPP::PHA::FineGain, gain & 0xFFFF, ch); ErrorMsg("PHA-SetEnergyFineGain");} + void AutoSetTrapezoidRescalingAndFindGate(double gain = 1, int ch = -1); + ///=================== Get settings + double GetSetting(Setting::PHA settingName, int ch = -1); + + void PrintBoardConfiguration(); + void PrintACQControl(); + void PrintGlobalTriggerMask(); + void PrintFrontPanelTRIGOUTEnableMask(); + void PrintFrontPanelIOControl(); + void PrintTriggerValidationMask(); + void PrintBoardInfoRegister(); + void PrintBoardFailureState(); + void PrintReadoutControl(); + void PrintReadoutStatu(); + void PrintChannelSettingFromDigitizer(int ch); ///inlcluded DPP Algorithm Control 1, 2 + + ///#################################################### + ///========= Old way Set and Get + /** 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"); } @@ -24,9 +47,6 @@ class DigitizerPHA : public Digitizer { 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"); } 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");} @@ -49,7 +69,6 @@ class DigitizerPHA : public Digitizer { 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 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");} @@ -62,11 +81,8 @@ class DigitizerPHA : public Digitizer { void SetPeakingTime(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::PeakingTime, nSample & 0x0FFF, ch); ErrorMsg("PHA-SetPeakingTime");} void SetPeakingHoldOff(unsigned int nSample, int ch = -1) { WriteRegister(Register::DPP::PHA::PeakHoldOff, nSample & 0x03FF, ch); ErrorMsg("PHA-SetPeakingHoldOff");} - void SetEnergyFineGain(unsigned int gain, int ch = -1) { WriteRegister(Register::DPP::PHA::FineGain, gain & 0xFFFF, ch); ErrorMsg("PHA-SetEnergyFineGain");} 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);} @@ -76,18 +92,7 @@ class DigitizerPHA : public Digitizer { unsigned int GetVirtualProbe1() {return ReadBits(Register::DPP::BoardConfiguration, 4, 20);} unsigned int GetTriggerThreshold(unsigned int ch) {return ReadRegister(Register::DPP::PHA::TriggerThreshold, ch);} - - void PrintBoardConfiguration(); - void PrintACQControl(); - void PrintGlobalTriggerMask(); - void PrintFrontPanelTRIGOUTEnableMask(); - void PrintFrontPanelIOControl(); - void PrintTriggerValidationMask(); - void PrintBoardInfoRegister(); - void PrintBoardFailureState(); - void PrintReadoutControl(); - void PrintReadoutStatu(); - void PrintChannelSettingFromDigitizer(int ch); ///inlcluded DPP Algorithm Control 1, 2 + */ }; diff --git a/RegisterAddress.h b/RegisterAddress.h index 1237ee4..4f1049d 100644 --- a/RegisterAddress.h +++ b/RegisterAddress.h @@ -231,16 +231,40 @@ namespace Setting{ StartStopACQ_bool, PLLClockSource_bool, VetoInForTRGOUT_bool, + + /// Global Trigger Mask + GlobalTrgMask_8bit, + GlobalTrgMajorityCoincienceWindow_4bit, + GlobalTrgMajorityLevel_3bit, + GlobalTrgExternalTrigger_bool, + GlobalTrgSoftwareTrigger_bool, + + /// Front Panel TRG-OUT Mask + FrontTRGOUTMask_8bit, + FrontTRGOUTLogic_2bit, + FrontTRGOUTMajorityLevel_3bit, + FrontTRGOUTExternalTrigger_bool, + FrontTRGOUTSoftwareTrigger_bool, + + /// Front Plane I/O + FrontPanelIO_LEMO_bool, + FrontPanelIO_TRGOUT_bool, + FrontPanelIO_TRGINCtrl_bool, + FrontPanelIO_TRGINtoMezzanines_bool, + FrontPanelIO_TRGOUTmode_6bit, /// Trigger Validation Mask TriggerValidationMask_8bit, TriggerValidationOperation_2bit, TriggerValidationMajority_3bit, - ExternalTrigger_bool, - SoftwareTrigger_bool, - - RunStartStopDelay_8bit, + TriggerValidationExternalTrigger_bool, + TriggerValidationSoftwareTrigger_bool, + /// Readout Control + //ReadoutCtrl_VMEInterruptLevel_3bit, + //ReadoutCtrl_OpticalLinkInterrupt_bool, + //ReadoutCtrl_VMEBusError_bool, + /// Registers RecordLength_G_ns, PreTriggerLength_ns, @@ -266,7 +290,11 @@ namespace Setting{ RiseTimeValidationWindow_ns, /// Others - FanSpeedControl_bool + FanSpeedControl_bool, + RunStartStopDelay_8bit, + DisableExternalTrigger_bool, + ExtendedVetoDelay_16bit, + AnalogMonitorMode_3bit }; diff --git a/boardSetting.cpp b/boardSetting.cpp index 99039db..cec0fbc 100644 --- a/boardSetting.cpp +++ b/boardSetting.cpp @@ -326,7 +326,6 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d bTRGOUTLVDSTrigger = new TGCheckButton(vTRGMsk4, "", 1); vTRGMsk4->AddFrame(bTRGOUTLVDSTrigger, layoutHints); bTRGOUTLVDSTrigger->SetState(kButtonUp); - TGVerticalFrame * vTRGMsk5 = new TGVerticalFrame(hframeTRGCfg); hframeTRGCfg->AddFrame(vTRGMsk5, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4)); TGLabel * lbExtTrigger = new TGLabel(vTRGMsk5, "Ext."); vTRGMsk5->AddFrame(lbExtTrigger, layoutHints); TGLabel * lbdummy2 = new TGLabel(vTRGMsk5, "Trg."); vTRGMsk5->AddFrame(lbdummy2, layoutHints); @@ -336,7 +335,7 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d bTRGExtTrigger = new TGCheckButton(vTRGMsk5, "", 1); vTRGMsk5->AddFrame(bTRGExtTrigger, layoutHints); bTRGExtTrigger->SetState(kButtonUp); bTRGOUTExtTrigger = new TGCheckButton(vTRGMsk5, "", 1); vTRGMsk5->AddFrame(bTRGOUTExtTrigger, layoutHints); - bTRGExtTrigger->SetState(kButtonUp); + bTRGOUTExtTrigger->SetState(kButtonUp); TGVerticalFrame * vTRGMsk6 = new TGVerticalFrame(hframeTRGCfg); hframeTRGCfg->AddFrame(vTRGMsk6, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4)); @@ -351,8 +350,8 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d bTRGOUTSoftwareTrigger->SetState(kButtonDown); TGHorizontalFrame * hframeTRGCfg2 = new TGHorizontalFrame(vTRGCfg); vTRGCfg->AddFrame(hframeTRGCfg2, new TGLayoutHints(kLHintsCenterY | kLHintsRight, 2,2,2,2)); - bTRGValMskLVSDGLB = new TGCheckButton(hframeTRGCfg2, "LVSD Global Trg. Valid", 1); hframeTRGCfg2->AddFrame(bTRGValMskLVSDGLB, new TGLayoutHints(kLHintsCenterY , 5, 5, 3, 4)); - bTRGValMskLVSDLCL = new TGCheckButton(hframeTRGCfg2, "LVSD Local Trg. Valid", 1); hframeTRGCfg2->AddFrame(bTRGValMskLVSDLCL, new TGLayoutHints(kLHintsCenterY , 5, 5, 3, 4)); + //bTRGValMskLVSDGLB = new TGCheckButton(hframeTRGCfg2, "LVSD Global Trg. Valid", 1); hframeTRGCfg2->AddFrame(bTRGValMskLVSDGLB, new TGLayoutHints(kLHintsCenterY , 5, 5, 3, 4)); + //bTRGValMskLVSDLCL = new TGCheckButton(hframeTRGCfg2, "LVSD Local Trg. Valid", 1); hframeTRGCfg2->AddFrame(bTRGValMskLVSDLCL, new TGLayoutHints(kLHintsCenterY , 5, 5, 3, 4)); ///"Disable External Trigger", bEnableExtTRG = new TGCheckButton(hframeTRGCfg2, "Enable Ext. Trigger", 1); hframeTRGCfg2->AddFrame(bEnableExtTRG, new TGLayoutHints(kLHintsCenterY , 5, 5, 3, 4)); @@ -676,9 +675,56 @@ void BoardSetting::ChangeBoard(){ numRunStartStopDelay->SetNumber( pha->GetSetting(Setting::PHA::RunStartStopDelay_8bit)); /// Global Trigger Mask + temp = pha->ReadRegister(Register::DPP::GlobalTriggerMask); + for( int i = 0; i < 8; i++){ + cbGbTRGMskCh[i]->SetState( ((temp >> i ) & 0x1) == 0 ? kButtonUp : kButtonDown ); + } + numMajorCoinWin->SetNumber( (temp >> 20 ) & 0x7 ); + GlbMajorLevel->SetNumber( ( temp >> 24) & 0x7 ); + bGLBLVDSTrigger->SetState( (( temp >> 29) & 0x1 ) == 0 ? kButtonUp : kButtonDown); + bGLBExtTrigger->SetState( (( temp >> 30) & 0x1 ) == 0 ? kButtonUp : kButtonDown); + bGLBSoftwareTrigger->SetState( (( temp >> 31) & 0x1 ) == 0 ? kButtonUp : kButtonDown); + + /// Trigger Validation Mask + temp = pha->ReadRegister(Register::DPP::TriggerValidationMask); + for( int i = 0; i < 8; i++){ + cbTRGValMskCh[i]->SetState( ((temp >> i ) & 0x1) == 0 ? kButtonUp : kButtonDown ); + } + cbTRGMODE->Select( ( temp >> 8 ) & 0x3) ; + TRGMajorLevel->SetNumber( ( temp >> 10 ) & 0x3); + bTRGExtTrigger->SetState( (( temp >> 30) & 0x1 ) == 0 ? kButtonUp : kButtonDown); + bTRGSoftwareTrigger->SetState( (( temp >> 31) & 0x1 ) == 0 ? kButtonUp : kButtonDown); + + //bTRGValMskLVSDGLB->SetState( (( temp >> 28) & 0x1 ) == 0 ? kButtonUp : kButtonDown); + //bTRGValMskLVSDLCL->SetState( (( temp >> 29) & 0x1 ) == 0 ? kButtonUp : kButtonDown); + + /// Front Panel TRG-OUT Enable Mask + temp = pha->ReadRegister(Register::DPP::FrontPanelTRGOUTEnableMask); + for( int i = 0; i < 8; i++){ + cbTRGOUTMskCh[i]->SetState( ((temp >> i ) & 0x1) == 0 ? kButtonUp : kButtonDown ); + } + cbTRGOUTMODE->Select( ( temp >> 8 ) & 0x3) ; + TRGOUTMajorLevel->SetNumber( ( temp >> 10 ) & 0x7); + bTRGOUTLVDSTrigger->SetState( (( temp >> 29) & 0x1 ) == 0 ? kButtonUp : kButtonDown); + bTRGOUTExtTrigger->SetState( (( temp >> 30) & 0x1 ) == 0 ? kButtonUp : kButtonDown); + bTRGOUTSoftwareTrigger->SetState( (( temp >> 30) & 0x1 ) == 0 ? kButtonUp : kButtonDown); + bEnableExtTRG->SetState( pha->GetSetting(Setting::PHA::DisableExternalTrigger_bool) == 1.0 ? kButtonDown : kButtonUp); + //numExtendVetoDelay->SetNumber( pha->GetSetting(Setting::PHA:: + + /// Front Panel I/O Control + temp = pha->ReadRegister(Register::DPP::FrontPanelIOControl); + cbLEMOIO->Select( temp & 0x1 ); + cbTRGOUTmode->Select( (temp >> 14) & 0x3F ); + bTRGOUTImp->SetState( ((temp >> 1) & 0x1 ) == 0 ? kButtonUp : kButtonDown) ; + cbTRGINCtrl->Select( (temp >> 10) & 0x1 ); + cbTRGINMezzanines->Select( (temp >> 11) & 0x1 ); + + cbAnaMonitor->Select( pha->GetSetting(Setting::PHA::AnalogMonitorMode_3bit) ); + + //numBufferOccpGain pha = NULL; ///unlink the pointer }else if( digi[boardID]->GetDPPType() == V1730_DPP_PSD_CODE ) {