Changeset 10100 for fact/FADctrl/FAD.cc


Ignore:
Timestamp:
01/11/11 20:39:47 (14 years ago)
Author:
ogrimm
Message:
Amplitude calibration debugged
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/FADctrl/FAD.cc

    r10099 r10100  
    7171  BoardList = Tokenize(GetConfig("BoardList","129.217.160.119"));
    7272  BoardList = Tokenize("192.33.99.225");
    73 printf("%s ", BoardList[0].c_str());
     73
    7474  for (unsigned int i=0; i<BoardList.size(); i++) {
    7575    Boards.push_back(new class FADBoard(BoardList[i], 5000, this, i));
     
    689689
    690690                // Switch off SCLK
    691                 Boards[Brd]->Send(CMD_SCLK_OFF);
     691                //Boards[Brd]->Send(CMD_SCLK_OFF);
    692692
    693693        // Start accumulation
     
    705705        }
    706706  }
    707   printf("Got first average\n");
    708707
    709708  for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
    710709        // Determine baseline
    711710        for (unsigned int i=0; i<NChips; i++) for (unsigned int j=0; j<NChannels; j++) {
    712           for (unsigned int k=0; k<NBins; k++) Boards[Brd]->Baseline[i][j][k] = Boards[Brd]->Sum[i][j][k] / NumCalibEvents;
    713         }
    714                 // Switch on SCLK
    715                 Boards[Brd]->Send(CMD_SCLK_ON);
    716 
     711          for (unsigned int k=0; k<NBins; k++) {
     712                Boards[Brd]->Baseline[i][j][k] = Boards[Brd]->Sum[i][j][k] / NumCalibEvents;
     713          }
     714        }
     715
     716        // Switch on SCLK
     717        Boards[Brd]->Send(CMD_SCLK_ON);
    717718
    718719        // Set second DAC value
     
    723724
    724725                // Switch off SCLK
    725                 Boards[Brd]->Send(CMD_SCLK_OFF);
     726                //Boards[Brd]->Send(CMD_SCLK_OFF);
    726727
    727728        // Start accumulation
     
    749750        // Determine gain
    750751        for (unsigned int i=0; i<NChips; i++) for (unsigned int j=0; j<NChannels; j++) {
    751           for (unsigned int k=0; k<NBins; k++) Boards[Brd]->Gain[i][j][k] = ((Boards[Brd]->Sum[i][j][k] / NumCalibEvents)-Boards[Brd]->Baseline[i][j][k])/3000;
     752          for (unsigned int k=0; k<NBins; k++) {
     753                Boards[Brd]->Gain[i][j][k] = (Boards[Brd]->Sum[i][j][k] / NumCalibEvents)-Boards[Brd]->Baseline[i][j][k];
     754          }
    752755        }
    753756
     
    803806  bool Update;
    804807  struct FADBoard::BoardStatus S;
     808  double Temp;
    805809
    806810  gettimeofday(&LastUpdate, NULL);
     
    891895                  for (int i=0; i<S.ROI[Chip][Chan]; i++) {
    892896                        if (Boards[Brd]->ACalibTime == -1) Data[Count++] = Boards[Brd]->Data[Chip][Chan][i];
    893                         else Data[Count++] = (Boards[Brd]->Data[Chip][Chan][i] - Boards[Brd]->Baseline[Chip][Chan][(i+S.TriggerCell[Chip])%NBins]) * Boards[Brd]->Gain[Chip][Chan][(i+S.TriggerCell[Chip])%NBins];
     897                        else {
     898                        //Data[Count++] = (Boards[Brd]->Data[Chip][Chan][i] - Boards[Brd]->Baseline[Chip][Chan][(i+S.TriggerCell[Chip])%NBins]) * Boards[Brd]->Gain[Chip][Chan][(i+S.TriggerCell[Chip])%NBins];
     899                      Temp = (Boards[Brd]->Data[Chip][Chan][i] - Boards[Brd]->Baseline[Chip][Chan][(i+S.TriggerCell[Chip])%NBins]);
     900                          Temp *= Boards[Brd]->Gain[Chip][Chan][0]/Boards[Brd]->Gain[Chip][Chan][(i+S.TriggerCell[Chip])%NBins];
     901                          Data[Count++] = (short) Temp;
     902                        }
    894903                  }
    895904                  Count += NBins - S.ROI[Chip][Chan];
Note: See TracChangeset for help on using the changeset viewer.