Changeset 10118 for fact/tools/ddd


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

Legend:

Unmodified
Added
Removed
  • 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.