Changeset 10118 for fact/tools/ddd
- Timestamp:
- 01/25/11 09:47:27 (14 years ago)
- Location:
- fact/tools/ddd
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/ddd/Functions.cpp
r198 r10118 57 57 BoardNo->setEnabled(true); 58 58 PixelID->setEnabled(true); 59 M0Start->setEnabled(true);60 M0Stop->setEnabled(true);61 59 PhysPipeAction->setEnabled(true); 62 60 EventNo->setRange(1, R->Events); 63 M0Display->setEnabled(true);64 M0Start->setRange(0, R->Samples-1);65 M0Stop->setRange(0, R->Samples-1);66 61 ChannelNo->setRange(0, R->NChannels-1); 67 62 ChipNo->setRange(0, R->NChips-1); … … 78 73 BoardNo->setEnabled(false); 79 74 PixelID->setEnabled(false); 80 M0Start->setEnabled(false);81 M0Stop->setEnabled(false);82 75 PhysPipeAction->setEnabled(false); 83 76 RunHeaderDisplay->clear(); … … 90 83 void ddd::DisplayEvent(int) { 91 84 92 PixelID->set Text(PixMap->DRS_to_Pixel(BoardNo->value(), ChipNo->value(), ChannelNo->value()).c_str()); // Translate to pixel ID85 PixelID->setValue(PixMap->FPA_to_Pixel(0, BoardNo->value(), ChipNo->value(), ChannelNo->value())); // Translate to pixel ID 93 86 if(Socket->state() == QAbstractSocket::ConnectedState) return; // do not execute if socket is open 94 87 … … 149 142 delete[] x; delete[] y; 150 143 151 // ************************************152 // Get data for M0 display (event based)153 // ************************************154 155 if (!(M0Display->isEnabled())) return;156 157 double z[6][6] = {{0}};//36 pixels158 bool IDerror = false;159 160 //only interested in M0 data using DRS2161 //if (RD->RHeader->NChannels == 9) IDerror = true;162 163 //only interested in M0 data using DRS4164 if (RD->RHeader->NChannels == 10) IDerror = true;165 166 for(unsigned int i=0; i<RD->RHeader->NBoards; i++) {//board loop167 for(unsigned int j=0; j<RD->RHeader->NChips; j++) {//chip loop168 for(unsigned int k=0; k<RD->RHeader->NChannels; k++) {//channel loop169 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 name177 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 mapping200 //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 down204 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 window208 //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 loop225 }//only M0 data226 }//channel loop227 }//chip loop228 }//board loop229 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 > stopbin244 M0Start->setRange(0, M0Stop->value());245 M0Stop->setRange(M0Start->value(),(RD->RHeader->Samples)-1);246 144 } 247 145 … … 252 150 else SocketWindow->show(); 253 151 } 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 262 152 263 153 // +++ Acquire data through socket (acquire botton only available if socket exists) +++ … … 307 197 CloseDatafile(); 308 198 309 M0Window->hide();310 M0Display->setEnabled(false);311 312 199 ChannelNo->setEnabled(true); 313 200 ChipNo->setEnabled(true); … … 416 303 417 304 // +++ 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 305 void 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 424 312 if(Board >= BoardNo->minimum() && Board <= BoardNo->maximum() && 425 313 Chip >= ChipNo->minimum() && Chip <= ChipNo->maximum() && … … 429 317 ChannelNo->setValue(Channel); 430 318 } 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); 432 320 else QMessageBox::warning(this, "ddd Message","Pixel ID out of current range.",QMessageBox::Ok); 433 321 } -
fact/tools/ddd/GUI.cpp
r198 r10118 22 22 // Instantiate without console output 23 23 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())); 25 29 26 30 Tmpfile = tmpfile(); … … 67 71 BoardNo->setToolTip("Mezzanine board number"); 68 72 69 // TextBox for pixel ID70 PixelID = new Q LineEdit(Central);73 // SpinBox for pixel ID 74 PixelID = new QSpinBox(Central); 71 75 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))); 73 79 PixelID->setToolTip("Pixel identification"); 74 80 … … 86 92 connect(SocketButton, SIGNAL(clicked()), this, SLOT(OpenSocketWindow())); 87 93 SocketButton->setToolTip("Open window for socket communication"); 88 89 // M0 display button90 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");94 94 95 95 // Acquire button and Continuous check box … … 150 150 MainLayout->addLayout(FormLayout, 2, 0); 151 151 MainLayout->addWidget(SocketButton, 6,0); 152 MainLayout->addWidget(M0Display, 3,0);153 152 MainLayout->addWidget(GetButton, 4,0); 154 153 MainLayout->addWidget(ContinuousBox, 5,0); … … 229 228 SocketLayout->addWidget(SocketOutput, 2, 0, 4, 4); 230 229 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 display267 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 display276 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 288 230 } 289 231 … … 291 233 // Qwt items 292 234 delete Grid; delete Signal; 293 delete Signal2D;294 235 // Layout items 295 236 delete PortLayout; delete CommandLayout; 296 delete M0StartLayout; delete M0StopLayout;297 237 delete AddressLayout; delete FormLayout; 298 238 delete SpinLayout; 299 239 // Other items 300 240 delete SocketWindow; 301 delete M0Window;302 241 delete PixMap; delete RD; 303 242 -
fact/tools/ddd/GUI.h
r198 r10118 10 10 #include <qwt_plot_zoomer.h> 11 11 #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>17 12 18 13 #include "../../drsdaq/RawDataCTX.h" 19 14 #include "../../pixelmap/PixelMap.h" 15 #include "dic.hxx" 20 16 21 17 #define SOCKET_TIMEOUT 10000 // Milliseconds to wait for socket connection … … 28 24 Q_OBJECT 29 25 30 QPushButton *GetButton, *SocketButton, *Connect , *M0Display;26 QPushButton *GetButton, *SocketButton, *Connect; 31 27 QCheckBox *ContinuousBox; 32 28 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; 35 31 QPlainTextEdit *RunHeaderDisplay, *EventHeaderDisplay, *SocketOutput; 36 32 QTabWidget *TabWidget; 37 33 QTcpSocket *Socket; 38 QWidget *SocketWindow, *Central , *M0Window;34 QWidget *SocketWindow, *Central; 39 35 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; 42 38 43 QwtPlot *Graph , *Graph2D;39 QwtPlot *Graph; 44 40 QwtPlotZoomer *Zoomer; 45 41 QwtPlotCurve *Signal; 46 42 QwtPlotPanner *Panner; 47 43 QwtPlotGrid *Grid; 48 QwtPlotSpectrogram *Signal2D; 49 QwtLinearColorMap colorMap; 50 44 51 45 void closeEvent(QCloseEvent *); 52 46 … … 66 60 void FileDialog(); 67 61 void OpenSocketWindow(); 68 void OpenM0Window();69 62 void GetSignalFromSocket(); 70 63 void MakeConnection(); … … 73 66 void GotDisconnected(); 74 67 void HandleZoom(const QwtDoubleRect &); 75 void TranslatePixelID( );68 void TranslatePixelID(int); 76 69 77 70 void MenuSave(); … … 81 74 void MenuAbout(); 82 75 }; 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 6 6 TARGET = 7 7 DEPENDPATH += . 8 INCLUDEPATH += . /ihp/local/qwt-5.2.1/include8 INCLUDEPATH += . .. $(QWTDIR)/include $(DIMDIR)/dim ../../drsdaq ../../pixelmap 9 9 10 10 # Input 11 11 HEADERS += GUI.h ../../pixelmap/Pixel.h ../../pixelmap/PixelMap.h ../../drsdaq/RawDataCTX.h 12 12 SOURCES += Functions.cpp GUI.cpp ../../pixelmap/Pixel.cc ../../pixelmap/PixelMap.cc ../../drsdaq/RawDataCTX.cc 13 LIBS += -L /ihp/local/qwt-5.2.1/lib -lqwt13 LIBS += -L$(QWTDIR)/lib -lqwt $(DIMDIR)/linux/libdim.a 14 14 QT += network
Note:
See TracChangeset
for help on using the changeset viewer.