Changeset 12891 for fact/FADctrl
- Timestamp:
- 02/15/12 17:23:07 (13 years ago)
- Location:
- fact/FADctrl
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/FADctrl/FAD.cc
r11385 r12891 44 44 {"update", &FAD::cmd_update, false, 1, "<sec>", "Minimum delay between updates to DIM event service"}, 45 45 {"socketmode", &FAD::cmd_socketmode, true, 1, "<com|daq>", "Choose which Sockets are used for data transmission"}, 46 {"dynrange", &FAD::cmd_dynrange, true, 0, "", "Determine dynamic range using calibration DAC"}, 46 47 {"exit", &FAD::cmd_exit, false, 0, "", "Exit program"}, 47 48 {"help", &FAD::cmd_help, false, 0, "", "Print help"}}; … … 612 613 613 614 // 615 // Determine dynamic range 616 // 617 void FAD::cmd_dynrange() { 618 619 // Set number of events required for measurement 620 if (Parameter.size()==1 || !ConvertToInt(Parameter[1], &NumEventsRequested) || NumEventsRequested<=0) { 621 NumEventsRequested = DEFAULT_NUM_CALIB_EVENTS; 622 } 623 624 // Start calibration by setting mode 625 Mode = dynrange; 626 Message(INFO, "Starting determination of dynamic range with %d events", NumEventsRequested); 627 } 628 629 630 // 614 631 // Print status 615 632 // … … 650 667 else if (Mode == acalib) PrintMessage("Current mode is ACALIB (3x%d events, slowest board %d has %d events)\n", NumEventsRequested, SlowestBoard, MinCount); 651 668 else if (Mode == datarun) PrintMessage("Current mode is DATARUN (%d events requested, %d events taken)\n", NumEventsRequested, NumEvents); 669 else if (Mode == dynrange) PrintMessage("Current mode is DYNRANGE (%d events requested)\n", NumEventsRequested); 652 670 return; 653 671 } … … 784 802 } 785 803 786 if (Mode == acalib ) {804 if (Mode == acalib || Mode == dynrange) { 787 805 Mode = idle; 788 806 Message(INFO, "Mode set to IDLE"); -
fact/FADctrl/FAD.h
r11289 r12891 31 31 32 32 public: 33 enum ModeType {idle, datarun, acalib };33 enum ModeType {idle, datarun, acalib, dynrange}; 34 34 ModeType Mode; 35 35 … … 81 81 void cmd_phase(); void cmd_send(); 82 82 void cmd_stop(); void cmd_update(); 83 void cmd_take(); 83 void cmd_take(); void cmd_dynrange(); 84 84 85 85 void EnableDomino(); -
fact/FADctrl/FADBoard.cc
r11458 r12891 723 723 } 724 724 } 725 726 727 728 // 729 // Dynamic range determination 730 // 731 void FADBoard::DynamicRange() { 732 733 #if 0 734 vector<unsigned short> ROICmd; 735 unsigned short DACCmd[] = {htons(CMD_Write | (BADDR_DAC + 1)), 0, htons(CMD_Write | (BADDR_DAC + 2)), 0, htons(CMD_Write | (BADDR_DAC + 3)), 0, htons(CMD_Execute) }; 736 string Message = string("ACALIBDONE")+Name+"\n"; 737 738 switch (StateDR) { 739 // ====== Check if dynamic range measurement should start and initialise ===== 740 case standbye: 741 if (m->Mode != m->dynrange) break; 742 743 // Save initial board status, and set all ROIs to 1024 744 InitialStatus = GetStatus(); 745 746 for (unsigned int i=0; i<NChips*NChannels; i++) { 747 ROICmd.push_back(htons(CMD_Write | (BADDR_ROI + i))); 748 ROICmd.push_back(htons(NBins)); 749 } 750 ROICmd.push_back(htons(CMD_Execute)); 751 Send(&ROICmd[0], ROICmd.size()*sizeof(unsigned short)); 752 753 // Start measurement 754 DAC_DR = 0; 755 StateDR = setdac; 756 SetStatus("Starting dynamic range measurement"); 757 break; 758 759 // ====== Set calibration DAC ===== 760 case setdac: 761 // Check for stopping 762 if (m->Mode != m->dynrange) { 763 StateDR = cleanup; 764 break; 765 } 766 767 if (DAC_DR > 66000) { 768 StateDR = cleanup; 769 break; 770 } 771 772 // Set new DAC values 773 DACCmd[1] = htons(DAC_DR); 774 DACCmd[3] = htons(DAC_DR); 775 DACCmd[5] = htons(DAC_DR); 776 Send(DACCmd, sizeof(DACCmd)); 777 778 StateDR = measure; 779 break; 780 781 // ====== Determine mean and sigma ===== 782 case measure: 783 // Check for stopping 784 if (m->Mode != m->dynrange) { 785 StateDR = cleanup; 786 break; 787 } 788 789 Mean = 0; 790 Sigma = 0; 791 for (unsigned int Chip=0; Chip<NChips; Chip++) { 792 for (unsigned int Chan=0; Chan<NChannels; Chan++) { 793 for (int i=0; i<Status.ROI[Chip][Chan]; i++) { 794 Mean += Data[Chip][Chan][i]; 795 Sigma += Data[Chip][Chan][i]*Data[Chip][Chan][i]; 796 } 797 Mean /= Status.ROI[Chip][Chan]; 798 Sigma = sqrt(Status.ROI[Chip][Chan]/(Status.ROI[Chip][Chan]-1)*(Sigma/Status.ROI[Chip][Chan]-Mean*Mean)); 799 } 800 } 801 802 DAC_DR += 1000; 803 804 StateDR = setdac; 805 break; 806 807 // ====== Write back original ROI and DAC settings ===== 808 case cleanup: 809 // ROI values 810 ROICmd.clear(); 811 for (unsigned int i=0; i<NChips*NChannels; i++) { 812 ROICmd.push_back(htons(CMD_Write | (BADDR_ROI + i))); 813 ROICmd.push_back(htons(InitialStatus.ROI[i/NChannels][i%NChannels])); 814 } 815 ROICmd.push_back(htons(CMD_Execute)); 816 Send(&ROICmd[0], ROICmd.size()*sizeof(unsigned short)); 817 818 // DAC values 819 DACCmd[1] = htons(InitialStatus.DAC[1]); 820 DACCmd[3] = htons(InitialStatus.DAC[2]); 821 DACCmd[5] = htons(InitialStatus.DAC[3]); 822 Send(DACCmd, sizeof(DACCmd)); 823 824 StateDR = wait; 825 break; 826 827 // ====== Wait for Mode not being idle ===== 828 case wait: 829 if (m->Mode == m->idle) StateDR = standbye; 830 break; 831 } 832 #endif 833 } -
fact/FADctrl/FADBoard.h
r11385 r12891 96 96 void Lock(); 97 97 void Unlock(); 98 void DynamicRange(); 98 99 99 100 unsigned short Port;
Note:
See TracChangeset
for help on using the changeset viewer.