Changeset 10118


Ignore:
Timestamp:
01/25/11 09:47:27 (14 years ago)
Author:
ogrimm
Message:
Adapted various programs to new PixelMap class
Location:
fact
Files:
4 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • fact/BIASctrl/Crate.cc

    r10096 r10118  
    3232          Present[i][j] = false;
    3333          Current[i][j] = 0;
    34           CurrentOffset[i][j] = 0;
    3534        }
    3635  }
     
    293292
    294293
    295 // ***** Determine offset for current measurement *****
    296 bool Crate::CurrentCalib(double Voltage) {
    297 
    298   // Set voltage of all channels and wait for current to settle
    299   if (GlobalSet((int) (Voltage/90*0xfff)) != 1) return false;
    300   sleep(1);
    301  
    302   // Measure current of all channels
    303   if (ReadAll() != 1) return false;
    304 
    305   for (int i=0; i<MAX_NUM_BOARDS; i++) for (int j=0; j<NUM_CHANNELS; j++) {
    306         CurrentOffset[i][j] = Current[i][j];
    307   }
    308   return true;
    309 }
    310 
    311 
    312294// ***** Set all voltages of board to zero *****
    313295void Crate::ClearVoltageArrays() {
     
    343325
    344326  if (Channel >= MAX_NUM_BOARDS*NUM_CHANNELS) return 0;
    345   else return Current[Channel/NUM_CHANNELS][Channel%NUM_CHANNELS]-CurrentOffset[Channel/NUM_CHANNELS][Channel%NUM_CHANNELS];
     327  else return Current[Channel/NUM_CHANNELS][Channel%NUM_CHANNELS];
    346328}
    347329
  • fact/BIASctrl/Crate.h

    r10096 r10118  
    3535        double Volt[MAX_NUM_BOARDS][NUM_CHANNELS];      // Voltage in Volt
    3636        float Current[MAX_NUM_BOARDS][NUM_CHANNELS];
    37         float CurrentOffset[MAX_NUM_BOARDS][NUM_CHANNELS]; // Offset for current measurement
    3837
    3938        std::vector<unsigned char> Communicate(std::string);
     
    6362        int GlobalSet(double);
    6463        bool Synch();
    65         bool CurrentCalib(double);
    6664        double GetVoltage(unsigned int);
    6765        unsigned int GetDAC(unsigned int);
  • fact/BIASctrl/User.cc

    r10107 r10118  
    1616  } CommandList[] =
    1717   {{"synch", &User::cmd_synch, 0, "", "Synchronize board"},
    18     {"hv", &User::cmd_hv, 2, "<id>|<ch>|<all> <v>", "Change bias of pixel or (all) chan. of active boards"},
     18    {"pixel", &User::cmd_hv, 2, "<pixel id> <v>", "Change bias of pixel"},
     19        {"channel", &User::cmd_hv, 2, "<channel|all> <v>", "Change bias of (all) channels of active boards"},
    1920    {"gs", &User::cmd_gs, 1, "[crate] <volt>", "Global voltage set"},
    2021        {"status", &User::cmd_status, 0, "[dac|current]", "Show status information (DAC values if requested)"},
    21         {"ccal", &User::cmd_ccal, 1, "<volt>", "Calibrate current measurement at given voltage"},
    2222        {"mode", &User::cmd_mode, 1, "<static|dynamic>", "Set voltage stabilization mode"},
    2323        {"load", &User::cmd_load, 1, "<file>", "Load and set bias settings from file"},
     
    6363  }
    6464
    65   // Create instances
    66   pm     = new PixelMap(GetConfig("PixMapTable"));
     65  // Create PixelMap instance (map from config server)
     66  DimRpcInfo RPC((char *) "ConfigRequest", (char *) "");
     67  RPC.setData((char *) "Misc PixelMap");
     68  PixMap = new PixelMap(std::string(RPC.getString(), RPC.getSize()));
    6769 
    6870  // Install DIM command (after all initialized)
     
    9092
    9193  delete DIMCommand;   
    92   delete pm;
     94  delete PixMap;
    9395  delete ConsoleOut;   
    9496  free(ConsoleText); 
     
    169171  for (unsigned int n=1; n < Parameter.size()-1; n+=2) {
    170172
    171         // Extract channel identification
    172         if (pm->Pixel_to_HVboard(Parameter[n]) != 999999999) {
    173       Crt.Min = Crt.Max = pm->Pixel_to_HVboard(Parameter[n]);
    174       Chan.Min = Chan.Max = pm->Pixel_to_HVchain(Parameter[n])*NUM_CHANNELS + pm->Pixel_to_HVchannel(Parameter[n]);
    175         }
     173        // Pixel identification?
     174        if (Match(Parameter[0], "pixel")) {
     175          // Skip if first character is not digit
     176          if (isdigit(Parameter[n][0] == 0)) continue;
     177          // Skip if pixel ID not existing
     178          if (PixMap->Pixel_to_HVcrate(atoi(Parameter[n].c_str())) == PixMap->PM_ERROR_CODE) continue;
     179
     180      Crt.Min = Crt.Max = PixMap->Pixel_to_HVcrate(atoi(Parameter[n].c_str()));
     181      Chan.Min = Chan.Max = PixMap->Pixel_to_HVboard(atoi(Parameter[n].c_str()))*NUM_CHANNELS + PixMap->Pixel_to_HVchannel(atoi(Parameter[n].c_str()));
     182        }
     183        // Channel identification
    176184        else {
    177185      vector<string> T = Tokenize(Parameter[n], "/");
     
    181189          Chan.Max = MAX_NUM_BOARDS*NUM_CHANNELS-1;
    182190         
    183           if (Parameter[n] == "-") continue;
    184 
    185191          if (T.size() == 2) {
    186192                if(!ConvertToRange(T[0], Crt) || !ConvertToRange(T[1], Chan)) {
     
    204210        }
    205211
    206 
    207212        // Loop over given crates and channels
    208213        for (int i=Crt.Min; i<=Crt.Max; i++) for (int j=Chan.Min; j<=Chan.Max; j++) {
     
    342347        }
    343348  }   
    344 }
    345 
    346 //
    347 // Determine current measurement offset
    348 //
    349 void User::cmd_ccal() {
    350 
    351   double Voltage;
    352    
    353   if (!ConvertToDouble(Parameter[1], &Voltage)) {
    354     PrintMessage("Error with format of voltage parameter\n"); 
    355         return;
    356   }
    357 
    358   // Execute current offset determination
    359   for (unsigned int i=0; i<Crates.size(); i++) {
    360         if (!Crates[i]->CurrentCalib(Voltage)) {
    361       PrintMessage("Error with current calibration of crate %d\n", i);
    362           return;
    363         }
    364 
    365         PrintMessage("Current calibration of crate %d done\n", i);
    366   }
    367349}
    368350
  • fact/BIASctrl/User.h

    r10070 r10118  
    2626        enum RunMode {mode_static, mode_dynamic};
    2727
    28         PixelMap *pm;
     28        PixelMap *PixMap;
    2929        DimCommand *DIMCommand;
    3030        DimService *ConsoleOut;
     
    6666        void cmd_exit();        void cmd_rate();
    6767        void cmd_timeout();     void cmd_reset();
    68         void cmd_help();        void cmd_ccal();
    69         void cmd_mode();
     68        void cmd_help();        void cmd_mode();
    7069};
    7170
  • fact/Evidence/Edd/Edd.cc

    r10112 r10118  
    2323class EddDim *Handler;
    2424QString DRSBoard = "drsdaq";
     25std::string PixelMapText;
    2526
    2627// History chooser function (opens plot for numeric data, TextHist for all other)
     
    10161017
    10171018// Constructor
    1018 EventScope::EventScope(QWidget *P): EddBasePlot(P), PixelMap("../../config/PixelMap.txt", false) {
     1019EventScope::EventScope(QWidget *P): EddBasePlot(P), PixelMap(PixelMapText, false) {
    10191020
    10201021  Name = DRSBoard+"/EventData";
     
    10641065  struct ItemDetails N;
    10651066 
    1066   N.Signal = NewCurve(QString::number(Board)+","+QString::number(Chip)+","+ QString::number(Channel)+ " (" + DRS_to_Pixel(Board, Chip, Channel).c_str() + ")");
     1067  N.Signal = NewCurve(QString::number(Board)+","+QString::number(Chip)+","+ QString::number(Channel)+ " (" + ToPixel(0, Board, Chip, Channel) + ")");
    10671068  N.Board = Board;
    10681069  N.Chip = Chip;
     
    10901091  ClearCurve(0);
    10911092
    1092   List.first().Signal->setTitle(QString::number(Board)+","+QString::number(Chip)+","+ QString::number(Channel) + " (" + DRS_to_Pixel(Board, Chip, Channel).c_str() + ")");
     1093  List.first().Signal->setTitle(QString::number(Board)+","+QString::number(Chip)+","+ QString::number(Channel) + " (" + ToPixel(0, Board, Chip, Channel) + ")");
    10931094  List.first().Board = Board;
    10941095  List.first().Chip = Chip;
     
    12691270}
    12701271
    1271 
     1272// Translate FPA ID to Pixel ID (use '-' instead of PM_ERROR_CODE)
     1273QString EventScope::ToPixel(unsigned int Crate, unsigned int Board, unsigned int Patch, unsigned int Pixel) {
     1274 
     1275  if (FPA_to_Pixel(Crate, Board, Patch, Pixel) == PM_ERROR_CODE) return "-";
     1276  else return QString::number(FPA_to_Pixel(Crate, Board, Patch, Pixel));
     1277}
     1278 
    12721279//------------------------------------------------------------------
    12731280//**************************** Tab pages ***************************
     
    14911498
    14921499  // Pixel ID
    1493   PixelID = new QLineEdit;
     1500  PixelID = new QSpinBox;
    14941501  PixelID->setMaximumWidth(60);
    1495   connect(PixelID, SIGNAL(returnPressed()), SLOT(TranslatePixelID()));
     1502  PixelID->setRange(-1, 9999);
     1503  PixelID->setSpecialValueText("n/a");
     1504  connect(PixelID, SIGNAL(valueChanged(int)), SLOT(TranslatePixelID(int)));
    14961505  PixelID->setToolTip("Pixel identification");
    14971506 
     
    15601569  StartStop(false);
    15611570  connect(Scope, SIGNAL(PixelData(QVector<double>)), SLOT(SetPixelData(QVector<double>)));
     1571
     1572  // Call to get initial pixel ID correct
     1573  UpdateScope(0);
    15621574}
    15631575
     
    15681580
    15691581// Translate pixel ID to board, chip, channel
    1570 void TP_DAQ::TranslatePixelID() {
    1571  
    1572   if (Scope->Pixel_to_DRSboard(PixelID->text().toStdString()) == 999999999) {
    1573         QMessageBox::warning(this, "Edd Message","Pixel ID unknown.",QMessageBox::Ok);
    1574   }
     1582void TP_DAQ::TranslatePixelID(int ID) {
     1583
     1584  // setValue() below will call UpdateScope() through signal, therefore need to store numbers here
     1585  unsigned int BoardNo = Scope->Pixel_to_FPAboard(ID);
     1586  unsigned int PatchNo = Scope->Pixel_to_FPApatch(ID);
     1587  unsigned int PixelNo = Scope->Pixel_to_FPApixel(ID);
     1588 
     1589  if (BoardNo == Scope->PM_ERROR_CODE) PixelID->setValue(-1);
    15751590  else {
    1576     Board->setValue(Scope->Pixel_to_DRSboard(PixelID->text().toStdString()));
    1577     Chip->setValue(Scope->Pixel_to_DRSchip(PixelID->text().toStdString()));
    1578     Channel->setValue(Scope->Pixel_to_DRSchannel(PixelID->text().toStdString()));
     1591    Board->setValue(BoardNo);
     1592    Chip->setValue(PatchNo);
     1593    Channel->setValue(PixelNo);
    15791594  }
    15801595}
     
    15991614
    16001615  // Update pixel ID
    1601   PixelID->setText(Scope->DRS_to_Pixel(Board->value(), Chip->value(), Channel->value()).c_str());
     1616  PixelID->setValue(Scope->FPA_to_Pixel(0, Board->value(), Chip->value(), Channel->value()));
     1617  if (PixelID->value() == (int) Scope->PM_ERROR_CODE) PixelID->setValue(-1);
     1618 
    16021619  // Update first trace
    16031620  Scope->UpdateFirst(Board->value(), Chip->value(), Channel->value());
     
    18851902  if (argc > 1) DRSBoard = "FADctrl";
    18861903
     1904  // Make RPC to get pixelmap
     1905  DimRpcInfo RPC((char *) "ConfigRequest", (char *) "");
     1906  RPC.setData((char *) "Misc PixelMap");
     1907  PixelMapText = std::string(RPC.getString(), RPC.getSize());
     1908
    18871909  QApplication app(argc, argv);
    18881910  GUI MainWindow;
  • fact/Evidence/Edd/Edd.h

    r10112 r10118  
    290290        void AddTrace(int, int, int);
    291291        void SetActive(bool);
     292        QString ToPixel(unsigned int, unsigned int, unsigned int, unsigned int);
    292293
    293294  private slots:
     
    339340    QPlainTextEdit *RunHeaderDisplay, *EventHeaderDisplay;
    340341
    341         QSpinBox *Channel, *Chip, *Board;
    342         QLineEdit *PixelID;
     342        QSpinBox *Channel, *Chip, *Board, *PixelID;
    343343        QFormLayout *FormLayout;
    344344        QWidget *Display;
     
    347347
    348348  private slots:
    349         void TranslatePixelID();
     349        void TranslatePixelID(int);
    350350        void UpdateScope(int);
    351351        void KeepCurrent();
  • fact/Feedback/Feedback.cc

    r269 r10118  
    1010#include "Feedback.h"
    1111#include "PixelMap.h"
    12 
    13 #define PIXMAP_LOCATION "../config/PixelMap.txt"
    1412
    1513static const char* FBState_Description[] = {
     
    4240Feedback::Feedback(): EvidenceServer(SERVER_NAME) {
    4341
    44   PixMap = new PixelMap(PIXMAP_LOCATION, false);
     42  // Make RPC to get pixelmap
     43  DimRpcInfo RPC((char *) "ConfigRequest", (char *) "");
     44  RPC.setData((char *) "Misc PixelMap");
     45
     46  PixMap = new PixelMap(std::string(RPC.getString(), RPC.getSize()));
    4547  TimeBarrier = 0;
    4648
     
    5254  fIDTable = Tokenize(GetConfig("IDTable"), " \t");
    5355  Multiplicity = new unsigned int [fIDTable.size()];
    54  
    55   multiset<string> A;
    56   char *Buf;
    57  
     56
     57  // Determine multiplicity of bias to pixel connection 
     58  std::vector<unsigned int> A;
    5859  for (unsigned int i=0; i<fIDTable.size(); i++) {
    59         if (asprintf(&Buf, "BiasID%d%d%d", PixMap->Pixel_to_HVboard(fIDTable[i]),
    60                 PixMap->Pixel_to_HVchain(fIDTable[i]), PixMap->Pixel_to_HVchannel(fIDTable[i])) == -1) Message(FATAL, "asprintf() failed");
    61         A.insert(Buf);
    62         free(Buf);
    63   }
    64  
    65   for (unsigned int i=0; i<fIDTable.size(); i++) {
    66         if (asprintf(&Buf, "BiasID%d%d%d", PixMap->Pixel_to_HVboard(fIDTable[i]),
    67                 PixMap->Pixel_to_HVchain(fIDTable[i]), PixMap->Pixel_to_HVchannel(fIDTable[i])) == -1) Message(FATAL, "asprintf() failed");
    68         Multiplicity[i] = A.count(Buf);
    69         free(Buf);
    70   }
    71 
     60        A = PixMap->HV_to_Pixel(PixMap->Pixel_to_HVcrate(atoi(fIDTable[i].c_str())), PixMap->Pixel_to_HVboard(atoi(fIDTable[i].c_str())), PixMap->Pixel_to_HVchannel(atoi(fIDTable[i].c_str())));
     61        Multiplicity[i] = A.size();
     62  }
     63 
    7264  // Initialise with zero content ???
    7365  Average    = new float [fIDTable.size()];
     
    227219  float Correction;
    228220
    229   // Refect data is feedback off or timestamp too early
     221  // Reject data if feedback off or timestamp too early
    230222  if (FBMode == Off || getCommand()->getTimestamp() < TimeBarrier) return;
    231223  TimeBarrier = 0;
     
    298290  // Send command (non-blocking since in handler thread)
    299291  if (!Cmd.str().empty()) {
    300         DimClient::sendCommandNB("Bias/Command", (char *) ("hv "+Cmd.str()).c_str());
     292        DimClient::sendCommandNB("Bias/Command", (char *) ("pixel "+Cmd.str()).c_str());
    301293  }
    302294
     
    385377  // Build command
    386378  for (unsigned int i=0; i<fIDTable.size(); i++) {
    387         Cmd << fIDTable[i] << " " << std::showpos << -U/2/Multiplicity[i] << " ";                                 
     379        Cmd << fIDTable[i] << " " << std::showpos << -U/2/Multiplicity[i] << " ";
    388380  }
    389381 
    390382  // Send command
    391383  if (!Cmd.str().empty()) {
    392         DimClient::sendCommand("Bias/Command", ("hv "+Cmd.str()).c_str());
     384        DimClient::sendCommand("Bias/Command", ("pixel "+Cmd.str()).c_str());
    393385  }
    394386
    395387  DiffVoltage = U;
    396388  SetFBMode(ResponseFirst);
    397   PrintMessage("HV Feedback: Decreasing voltages by %f for response measurement, acquiring data.\n",DiffVoltage/2);
     389  PrintMessage("Feedback: Decreasing voltages by %f for response measurement, acquiring data.\n",DiffVoltage/2);
    398390}
    399391
     
    439431void Feedback::commandHandler() {
    440432
    441   string Command = ToString("C", getCommand()->getData(), getCommand()->getSize());
     433  string Command = ToString((char *) "C", getCommand()->getData(), getCommand()->getSize());
    442434 
    443435  // Parse command into tokens
  • fact/Feedback/Makefile

    r269 r10118  
    1212
    1313CPPFLAGS = -DREVISION='"$(REVISION)"' -O3 -Wall
    14 LIBS = -lstdc++ -lz -lpthread -lutil -lfl -lreadline -ltermcap $(DIMDIR)/linux/libdim.a
     14LIBS = -L /usr/lib/termcap -lstdc++ -lz -lpthread -lutil -lfl -lreadline -ltermcap $(DIMDIR)/linux/libdim.a
    1515
    1616Feedback: $(OBJECTS)
  • fact/drsdaq/Makefile

    r269 r10118  
    2626
    2727CPPFLAGS = -DREVISION='"$(REVISION)"' -O3 -Wall $(VMECTRL)
    28 LIBS = -lstdc++ -lz -lpthread -lutil -lfl -lreadline -ltermcap $(VMELIB) $(DIMDIR)/linux/libdim.a
     28LIBS = -L /usr/lib/termcap -lstdc++ -lz -lpthread -lutil -lfl -lreadline -ltermcap $(VMELIB) $(DIMDIR)/linux/libdim.a
    2929
    3030drsdaq: $(OBJECTS)
  • fact/tools/Scripts/Logon

    r274 r10118  
    1212export LD_LIBRARY_PATH=$QWTDIR/lib:$DIMDIR/linux:$LD_LIBRARY_PATH
    1313export PATH=$DIMDIR/linux:$REPOS_DIR/tools/Scripts:$QTDIR/bin:.:$PATH
    14 
    15 echo
    16 echo Note: Operation needs Evidence configuration server running on $DIM_DNS_NODE
    17 echo "To start, log on as user 'daqct3' and execute 'start' script"
    18 echo "Contact: Oliver Grimm (32192) or Quirin Weitzel (33973)"
    19 echo
    2014
    2115# Check if repository is a mixed or locally modified version (only for login shell))
  • fact/tools/ddd/Functions.cpp

    r198 r10118  
    5757  BoardNo->setEnabled(true);
    5858  PixelID->setEnabled(true);
    59   M0Start->setEnabled(true);
    60   M0Stop->setEnabled(true);
    6159  PhysPipeAction->setEnabled(true);
    6260  EventNo->setRange(1, R->Events);
    63   M0Display->setEnabled(true);
    64   M0Start->setRange(0, R->Samples-1); 
    65   M0Stop->setRange(0, R->Samples-1);
    6661  ChannelNo->setRange(0, R->NChannels-1);
    6762  ChipNo->setRange(0, R->NChips-1);
     
    7873    BoardNo->setEnabled(false);
    7974    PixelID->setEnabled(false);
    80     M0Start->setEnabled(false);
    81     M0Stop->setEnabled(false);
    8275        PhysPipeAction->setEnabled(false);
    8376    RunHeaderDisplay->clear();
     
    9083void ddd::DisplayEvent(int) {
    9184
    92   PixelID->setText(PixMap->DRS_to_Pixel(BoardNo->value(), ChipNo->value(),      ChannelNo->value()).c_str());  // Translate to pixel ID
     85  PixelID->setValue(PixMap->FPA_to_Pixel(0, BoardNo->value(), ChipNo->value(),  ChannelNo->value()));  // Translate to pixel ID
    9386  if(Socket->state() == QAbstractSocket::ConnectedState) return; // do not execute if socket is open
    9487 
     
    149142  delete[] x;   delete[] y;
    150143
    151   // ************************************   
    152   // Get data for M0 display (event based)
    153   // ************************************   
    154 
    155   if (!(M0Display->isEnabled())) return;
    156 
    157   double z[6][6] = {{0}};//36 pixels
    158   bool IDerror = false;
    159 
    160   //only interested in M0 data using DRS2
    161   //if (RD->RHeader->NChannels == 9) IDerror = true; 
    162 
    163   //only interested in M0 data using DRS4
    164   if (RD->RHeader->NChannels == 10) IDerror = true; 
    165 
    166   for(unsigned int i=0; i<RD->RHeader->NBoards; i++) {//board loop
    167     for(unsigned int j=0; j<RD->RHeader->NChips; j++) {//chip loop
    168       for(unsigned int k=0; k<RD->RHeader->NChannels; k++) {//channel loop
    169 
    170         //for DRS2 data (requires the correct pixelmap!!!
    171         //if( ( (i==0 || i==1) && (j<=1) && (k<=7) ) || ( (i==2) && (j==0) && (k<=3) ) ) {
    172 
    173         //for DRS4 data (requires the correct pixelmap!!!
    174         if( ( (i==0 || i==1) && (j<=3) && (k==0 || k==2 || k==4 || k==6) ) || ( (i==2) && (j==0) && (k==0 || k==2 || k==4 || k==6) ) ) {
    175          
    176           //get module, superpixel and pixel number from pixel name
    177           std::string pixelname = PixMap->DRS_to_Pixel(i,j,k);
    178           if (pixelname == "") {
    179             IDerror = true;
    180             continue;
    181           }
    182           char pixelname_copy[256];
    183           memset(pixelname_copy,'\0',256);
    184           pixelname.copy(pixelname_copy, 256);
    185 
    186           char delim[] = "-";
    187           char *buffer = NULL;
    188           int module = -1;
    189           int superpixel = -1;
    190           int pixel = -1;
    191 
    192           buffer = strtok(pixelname_copy, delim);
    193           module = atoi(buffer);
    194           buffer = strtok(NULL, delim);
    195           superpixel = atoi(buffer);
    196           buffer = strtok(NULL, delim);
    197           pixel = atoi(buffer);
    198 
    199           //usual M0 mapping
    200           //int binx = 5-(int((superpixel-1)/3)*2)-(int((pixel%4)/2));
    201           //int biny = 5-(((superpixel-1)%3)*2)-(int((pixel-1)/2));
    202 
    203           //M0 upside down
    204           int binx = 5-(5-(int((superpixel-1)/3)*2)-(int((pixel%4)/2)));
    205           int biny = 5-(5-(((superpixel-1)%3)*2)-(int((pixel-1)/2)));
    206 
    207           //search maximum sample amplitude within user specified window
    208           //start bin is always smaller than stop bin (taken care of by updated ranges)
    209           int StartBin = (int)(M0Start->value());
    210           int StopBin = (int)(M0Stop->value());
    211 
    212           for(int l=StartBin; l<=StopBin; l++){
    213 
    214             float sample = *((short *) (RD->Data + RD->RHeader->NBoards*RD->RHeader->NChips*sizeof(int)) +
    215                              i*RD->RHeader->NChips*RD->RHeader->NChannels*RD->RHeader->Samples+
    216                              j*RD->RHeader->NChannels*RD->RHeader->Samples+
    217                              k*RD->RHeader->Samples+
    218                              l)*RD->BStruct[i].ScaleFactor;
    219 
    220             if (fabs(sample) > z[binx][biny]) {
    221               z[binx][biny]=fabs(sample);
    222             }
    223 
    224           }//sample loop
    225         }//only M0 data
    226       }//channel loop
    227     }//chip loop
    228   }//board loop
    229 
    230   if(IDerror){
    231     QMessageBox::warning(this, "ddd Message","Sorry! The M0 display is not available for this data file because of a pixel ID mismatch.",QMessageBox::Ok);
    232     if(M0Window->isVisible()) M0Window->hide();
    233     M0Display->setEnabled(false);
    234     return;
    235   }
    236 
    237   //fill data to M0 display (event based)
    238   Signal2D->setData(SpectrogramDataM0(z));
    239   Graph2D->axisWidget(QwtPlot::yRight)->setColorMap(Signal2D->data().range(),Signal2D->colorMap());
    240   Graph2D->setAxisScale(QwtPlot::yRight,Signal2D->data().range().minValue(),Signal2D->data().range().maxValue() );
    241   Graph2D->replot();
    242 
    243   //update ranges for start and stop bin to avoid startbin > stopbin
    244   M0Start->setRange(0, M0Stop->value()); 
    245   M0Stop->setRange(M0Start->value(),(RD->RHeader->Samples)-1);
    246144}
    247145
     
    252150  else SocketWindow->show();
    253151}
    254 
    255 // +++ Open sub window for M0 Display +++
    256 void ddd::OpenM0Window() {
    257 
    258   if(M0Window->isVisible()) M0Window->hide();
    259   else M0Window->show();
    260 }
    261 
    262152
    263153// +++ Acquire data through socket (acquire botton only available if socket exists) +++
     
    307197      CloseDatafile();
    308198
    309       M0Window->hide();
    310       M0Display->setEnabled(false);
    311 
    312199      ChannelNo->setEnabled(true);
    313200      ChipNo->setEnabled(true);
     
    416303
    417304// +++ Translate pixel ID +++
    418 void ddd::TranslatePixelID() {
    419  
    420   int Board = PixMap->Pixel_to_DRSboard(PixelID->text().toStdString());
    421   int Chip = PixMap->Pixel_to_DRSchip(PixelID->text().toStdString());
    422   int Channel = PixMap->Pixel_to_DRSchannel(PixelID->text().toStdString());
    423 
     305void ddd::TranslatePixelID(int ID) {
     306 
     307  // setValue() below will call UpdateScope() through signal, therefore need to store numbers here
     308  int Board = PixMap->Pixel_to_FPAboard(ID);
     309  int Chip = PixMap->Pixel_to_FPApatch(ID);
     310  int Channel = PixMap->Pixel_to_FPApixel(ID);
     311 
    424312  if(Board      >= BoardNo->minimum()   && Board        <= BoardNo->maximum() &&
    425313     Chip       >= ChipNo->minimum()    && Chip         <= ChipNo->maximum() &&
     
    429317    ChannelNo->setValue(Channel);
    430318  }
    431   else if(Board==999999999) QMessageBox::warning(this, "ddd Message","Pixel ID unknown.",QMessageBox::Ok);
     319  else if (Board == (int) PixMap->PM_ERROR_CODE) PixelID->setValue(-1);
    432320  else QMessageBox::warning(this, "ddd Message","Pixel ID out of current range.",QMessageBox::Ok);
    433321}
  • fact/tools/ddd/GUI.cpp

    r198 r10118  
    2222  // Instantiate without console output
    2323  RD = new RawDataCTX(true);
    24   PixMap = new PixelMap("../../config/PixelMap.txt", false);
     24
     25  // Instantiate PixelMap
     26  DimRpcInfo RPC((char *) "ConfigRequest", (char *) "");
     27  RPC.setData((char *) "Misc PixelMap");
     28  PixMap = new PixelMap(std::string(RPC.getString(), RPC.getSize()));
    2529   
    2630  Tmpfile = tmpfile();
     
    6771  BoardNo->setToolTip("Mezzanine board number");
    6872 
    69    // TextBox for pixel ID
    70   PixelID = new QLineEdit(Central);
     73  // SpinBox for pixel ID
     74  PixelID = new QSpinBox(Central);
    7175  PixelID->setEnabled(false);
    72   connect(PixelID, SIGNAL(returnPressed()), this, SLOT(TranslatePixelID()));
     76  PixelID->setRange(-1, 9999);
     77  PixelID->setSpecialValueText("n/a");
     78  connect(PixelID, SIGNAL(valueChanged(int)), this, SLOT(TranslatePixelID(int)));
    7379  PixelID->setToolTip("Pixel identification");
    7480 
     
    8692  connect(SocketButton, SIGNAL(clicked()), this, SLOT(OpenSocketWindow()));
    8793  SocketButton->setToolTip("Open window for socket communication");
    88 
    89   // M0 display button
    90   M0Display = new QPushButton("M0 Display",Central);
    91   M0Display->setFont(QFont("Times", 10, QFont::Bold));
    92   connect(M0Display, SIGNAL(clicked()), this, SLOT(OpenM0Window()));
    93   M0Display->setToolTip("Open window for M0 display");
    9494
    9595  // Acquire button and Continuous check box
     
    150150  MainLayout->addLayout(FormLayout, 2, 0);
    151151  MainLayout->addWidget(SocketButton, 6,0);
    152   MainLayout->addWidget(M0Display, 3,0);
    153152  MainLayout->addWidget(GetButton, 4,0);
    154153  MainLayout->addWidget(ContinuousBox, 5,0);
     
    229228  SocketLayout->addWidget(SocketOutput, 2, 0, 4, 4);
    230229
    231   //-----------------------------------------------------------------------
    232   //**************************** M0 window ****************************
    233   //-----------------------------------------------------------------------
    234    
    235   M0Window = new QWidget();
    236   M0Window->setWindowTitle("ddd - M0 Display");
    237 
    238   Graph2D = new QwtPlot(M0Window);
    239   Graph2D->setAutoReplot(true);
    240   Graph2D->setCanvasBackground(QColor(Qt::white));
    241 
    242   M0Start = new QSpinBox(M0Window);
    243   M0Start->setEnabled(false);
    244   connect(M0Start, SIGNAL(valueChanged(int)), this, SLOT(DisplayEvent(int)));
    245   M0Start->setToolTip("First bin/sample of time window");
    246   M0StartLayout = new QFormLayout; 
    247   M0StartLayout->addRow("First Bin", M0Start);
    248 
    249   M0Stop = new QSpinBox(M0Window);
    250   M0Stop->setEnabled(false);
    251   M0Stop->setRange(0,1023);
    252   M0Stop->setValue(1023);
    253   connect(M0Stop, SIGNAL(valueChanged(int)), this, SLOT(DisplayEvent(int)));
    254   M0Stop->setToolTip("Last bin/sample of time window");
    255   M0StopLayout = new QFormLayout; 
    256   M0StopLayout->addRow("Last Bin", M0Stop);
    257 
    258   M0Layout = new QGridLayout(M0Window);
    259   M0Layout->addWidget(Graph2D, 1,1,3,3);
    260   M0Layout->addLayout(M0StartLayout,4,1);
    261   M0Layout->addLayout(M0StopLayout,4,2);
    262 
    263   Signal2D = new QwtPlotSpectrogram;
    264   Signal2D->attach(Graph2D);
    265 
    266   //initialize raster data of M0 display
    267   double z[6][6];
    268   for (int i=0; i<6; i++){
    269       for (int j=0; j<6; j++){
    270           z[i][j]=i+j;
    271       }
    272   }
    273   Signal2D->setData(SpectrogramDataM0(z));
    274 
    275   //color (z-) axis of M0 display
    276   colorMap = QwtLinearColorMap(Qt::yellow, Qt::red); 
    277   Signal2D->setColorMap(colorMap);
    278 
    279   Graph2D->axisWidget(QwtPlot::yRight)->setTitle("Maximum Sample Amplitude (mV)");
    280   Graph2D->axisWidget(QwtPlot::yRight)->setColorBarEnabled(true);
    281   Graph2D->axisWidget(QwtPlot::yRight)->setColorMap(Signal2D->data().range(),Signal2D->colorMap());
    282 
    283   Graph2D->setAxisScale(QwtPlot::yRight,Signal2D->data().range().minValue(),Signal2D->data().range().maxValue());
    284   Graph2D->enableAxis(QwtPlot::yRight);
    285   Graph2D->plotLayout()->setAlignCanvasToScales(true);
    286   Graph2D->replot();
    287 
    288230}
    289231
     
    291233  // Qwt items
    292234  delete Grid;                  delete Signal;
    293   delete Signal2D;
    294235  // Layout items
    295236  delete PortLayout;            delete CommandLayout;
    296   delete M0StartLayout;         delete M0StopLayout;
    297237  delete AddressLayout;         delete FormLayout;
    298238  delete SpinLayout;
    299239  // Other items               
    300240  delete SocketWindow;
    301   delete M0Window;
    302241  delete PixMap;                delete RD;
    303242 
  • fact/tools/ddd/GUI.h

    r198 r10118  
    1010#include <qwt_plot_zoomer.h>
    1111#include <qwt_plot_panner.h>
    12 #include <qwt_plot_spectrogram.h>
    13 #include <qwt_raster_data.h>
    14 #include <qwt_scale_widget.h>
    15 #include <qwt_plot_layout.h>
    16 #include <qwt_color_map.h>
    1712
    1813#include "../../drsdaq/RawDataCTX.h"
    1914#include "../../pixelmap/PixelMap.h"
     15#include "dic.hxx"
    2016
    2117#define SOCKET_TIMEOUT 10000    // Milliseconds to wait for socket connection
     
    2824    Q_OBJECT
    2925
    30     QPushButton *GetButton, *SocketButton, *Connect, *M0Display;
     26    QPushButton *GetButton, *SocketButton, *Connect;
    3127    QCheckBox *ContinuousBox;
    3228    QToolButton *LoadButton;
    33     QLineEdit *FilenameBox, *IPAddress, *Command, *PixelID;
    34     QSpinBox *EventNo, *ChannelNo, *ChipNo, *BoardNo, *Port, *M0Start, *M0Stop;
     29    QLineEdit *FilenameBox, *IPAddress, *Command;
     30    QSpinBox *PixelID, *EventNo, *ChannelNo, *ChipNo, *BoardNo, *Port;
    3531    QPlainTextEdit *RunHeaderDisplay, *EventHeaderDisplay, *SocketOutput;
    3632    QTabWidget *TabWidget;
    3733    QTcpSocket *Socket;
    38     QWidget *SocketWindow, *Central, *M0Window;
     34    QWidget *SocketWindow, *Central;
    3935    QAction *OpenAction, *ConnectAction, *PhysPipeAction;
    40     QGridLayout *SocketLayout, *MainLayout, *M0Layout;
    41     QFormLayout *CommandLayout, *PortLayout, *AddressLayout, *FormLayout, *SpinLayout, *M0StartLayout, *M0StopLayout;
     36    QGridLayout *SocketLayout, *MainLayout;
     37    QFormLayout *CommandLayout, *PortLayout, *AddressLayout, *FormLayout, *SpinLayout;
    4238   
    43     QwtPlot *Graph, *Graph2D;
     39    QwtPlot *Graph;
    4440    QwtPlotZoomer *Zoomer;
    4541    QwtPlotCurve *Signal;
    4642    QwtPlotPanner *Panner;
    4743    QwtPlotGrid *Grid;
    48     QwtPlotSpectrogram *Signal2D;
    49     QwtLinearColorMap colorMap;
    50    
     44
    5145    void closeEvent(QCloseEvent *);
    5246
     
    6660    void FileDialog();
    6761    void OpenSocketWindow();
    68     void OpenM0Window();
    6962    void GetSignalFromSocket();
    7063    void MakeConnection();
     
    7366    void GotDisconnected();
    7467    void HandleZoom(const QwtDoubleRect &);
    75     void TranslatePixelID();
     68    void TranslatePixelID(int);
    7669   
    7770    void MenuSave();
     
    8174    void MenuAbout();
    8275};
    83 
    84 //Data class for 2D spectrogram (MO display specific)
    85 class SpectrogramDataM0: public QwtRasterData {
    86 
    87 private:
    88 
    89     double _z[6][6];
    90     double _zmin;
    91     double _zmax;
    92 
    93 public:
    94    
    95     SpectrogramDataM0(const double z[6][6]): QwtRasterData(QwtDoubleRect(0, 0, 6, 6)) {
    96         for (int i = 0; i<6; i++){
    97           for (int j = 0; j<6; j++){
    98               _z[i][j] = z[i][j];
    99               if (z[i][j] > _zmax) _zmax = z[i][j];
    100               if (z[i][j] < _zmin) _zmin = z[i][j];
    101            }
    102         }
    103     }
    104 
    105     virtual QwtRasterData *copy() const {
    106         return new SpectrogramDataM0(_z);
    107     }
    108 
    109     virtual QwtDoubleInterval range() const {
    110         return QwtDoubleInterval(_zmin, _zmax);
    111     }
    112 
    113     virtual void initRaster(const QwtDoubleRect = QwtDoubleRect(0, 0, 6, 6),
    114                             const QSize =QSize(1,1)) {};         
    115                
    116     virtual double value(double x, double y) const {
    117 
    118         unsigned int first = (unsigned int)x;
    119         unsigned int second = (unsigned int)y;
    120 
    121         const double v = _z[first][second];
    122         return v;
    123 
    124     }
    125 
    126 };
  • fact/tools/ddd/ddd.pro

    r229 r10118  
    66TARGET =
    77DEPENDPATH += .
    8 INCLUDEPATH += . /ihp/local/qwt-5.2.1/include
     8INCLUDEPATH += . .. $(QWTDIR)/include $(DIMDIR)/dim ../../drsdaq ../../pixelmap
    99
    1010# Input
    1111HEADERS += GUI.h ../../pixelmap/Pixel.h ../../pixelmap/PixelMap.h ../../drsdaq/RawDataCTX.h
    1212SOURCES += Functions.cpp GUI.cpp ../../pixelmap/Pixel.cc ../../pixelmap/PixelMap.cc ../../drsdaq/RawDataCTX.cc
    13 LIBS += -L/ihp/local/qwt-5.2.1/lib -lqwt
     13LIBS += -L$(QWTDIR)/lib -lqwt $(DIMDIR)/linux/libdim.a
    1414QT += network
Note: See TracChangeset for help on using the changeset viewer.