Legend:
- Unmodified
- Added
- Removed
-
tools/ddd/Functions.cpp
r74 r81 22 22 23 23 // Write run header to temporary file 24 FILE *Tmpfile = tmpfile(); 25 if(Tmpfile==NULL) { 26 QMessageBox::warning(this, "ddd Message","Could not open temporary file.",QMessageBox::Ok); 27 CloseDatafile(); 28 return; 29 } 30 24 rewind(Tmpfile); 31 25 switch (RD->OpenDataFile(FilenameBox->text().toAscii().data(), Tmpfile)) { 32 26 case CTX_FOPEN: QMessageBox::warning(this, "ddd Message","Could not open file.",QMessageBox::Ok); … … 49 43 QString text = in.readAll(); 50 44 RunHeaderDisplay->setPlainText(text); 51 fclose(Tmpfile);52 45 53 46 // Enable spin boxes, set ranges and display first event … … 88 81 // +++ Read event header and display event (only called if Datafile is open) +++ 89 82 void ddd::DisplayEvent(int) { 83 84 PixelID->setText(PixMap->DRS_to_Pixel(BoardNo->value(), ChannelNo->value()/10, ChannelNo->value()%10).c_str()); // Translate to pixel ID 85 if(Socket->state() == QAbstractSocket::ConnectedState) return; // do not execute if socket is open 86 87 // Read event 88 rewind(Tmpfile); 89 if (RD->ReadEvent(EventNo->value(), Tmpfile) != CTX_OK) { 90 QMessageBox::warning(this, "ddd Warning","Could not read event.",QMessageBox::Ok); 91 EventHeaderDisplay->clear(); 92 return; 93 } 90 94 91 PixelID->setText(PixMap->DRS_to_Pixel(BoardNo->value(),ChannelNo->value()/10,ChannelNo->value()%10).c_str()); 92 if(Socket->state() == QAbstractSocket::ConnectedState) return; // do not execute if socket is open 93 94 // Read event 95 FILE *Tmpfile = tmpfile(); 96 97 switch(RD->ReadEvent(EventNo->value(), Tmpfile)) { 98 case !CTX_OK: 99 QMessageBox::warning(this, "ddd Warning","Could not read event.",QMessageBox::Ok); 100 EventHeaderDisplay->clear(); 101 break; 102 default: // Print event header and trigger cell information from event data 103 rewind(Tmpfile); 104 QTextStream in(Tmpfile); 105 QString text = in.readAll(); 106 text.append("\nTrigger cells: "); 107 for (unsigned int i=0; i<RD->RHeader->NBoards*RD->RHeader->NChips; i++) { 108 QString a; 109 text.append(a.sprintf("%d ", *((int *)RD->Data + i))); 110 } 111 EventHeaderDisplay->setPlainText(text); 112 113 // Case data in double format required by qwt library 114 double* x = new double [RD->RHeader->Samples]; 115 double* y = new double [RD->RHeader->Samples]; 116 117 for (unsigned int i=0; i<RD->RHeader->Samples; i++) { 118 x[i] = (double) (i/RD->BStruct[BoardNo->value()].NomFreq); 119 y[i] = (double) *((short *) (RD->Data + RD->RHeader->NBoards*RD->RHeader->NChips*sizeof(int)) + BoardNo->value()*RD->RHeader->NChips*RD->RHeader->NChannels * 120 RD->RHeader->Samples+ChannelNo->value()*RD->RHeader->Samples+i)*RD->BStruct[BoardNo->value()].ScaleFactor; 121 } 122 Signal->setData(x, y, RD->RHeader->Samples); 123 Signal->show(); 124 Zoomer->setZoomBase(Signal->boundingRect()); 125 126 //Get data for M0 display (event based) 127 128 double z[6][6];//36 pixels 129 130 for(unsigned int i=0; i<RD->RHeader->NBoards; i++) {//board loop 131 for(unsigned int j=0; j<RD->RHeader->NChips; j++) {//chip loop 132 for(unsigned int k=0; k<RD->RHeader->NChannels; k++) {//channel loop 133 134 //only interested in M0 data 135 if( ( (i==0 || i==1) && (j<=1) && (k<=7) ) || ( (i==2) && (j==0) && (k<=3) ) ) { 136 137 //get module, superpixel and pixel number from pixel name 138 139 std::string pixelname = PixMap->DRS_to_Pixel(i,j,k); 140 char pixelname_copy[256]; 141 memset(pixelname_copy,'\0',256); 142 pixelname.copy(pixelname_copy, 256); 143 144 char delim[] = "-"; 145 char *buffer = NULL; 146 int module = -1; 147 int superpixel = -1; 148 int pixel = -1; 149 150 buffer = strtok(pixelname_copy, delim); 151 module = atoi(buffer); 152 buffer = strtok(NULL, delim); 153 superpixel = atoi(buffer); 154 buffer = strtok(NULL, delim); 155 pixel = atoi(buffer); 156 157 //usual M0 mapping 158 //int binx = 5-(int((superpixel-1)/3)*2)-(int((pixel%4)/2)); 159 //int biny = 5-(((superpixel-1)%3)*2)-(int((pixel-1)/2)); 160 161 //M0 upside down 162 int binx = 5-(5-(int((superpixel-1)/3)*2)-(int((pixel%4)/2))); 163 int biny = 5-(5-(((superpixel-1)%3)*2)-(int((pixel-1)/2))); 164 165 //search maximum sample amplitude within user specified window 166 //start bin is always smaller than stop bin (taken care of by updated ranges) 167 int StartBin = (int)(M0Start->value()); 168 int StopBin = (int)(M0Stop->value()); 169 170 for(int l=StartBin; l<=StopBin; l++){ 171 172 float sample = *((short *) (RD->Data + RD->RHeader->NBoards*RD->RHeader->NChips*sizeof(int)) + 173 i*RD->RHeader->NChips*RD->RHeader->NChannels*RD->RHeader->Samples+ 174 j*RD->RHeader->NChannels*RD->RHeader->Samples+ 175 k*RD->RHeader->Samples+ 176 l)*RD->BStruct[i].ScaleFactor; 177 178 if (sample > z[binx][biny]) { 179 z[binx][biny]=sample; 180 } 181 182 }//sample loop 183 184 }//only M0 data 185 186 }//channel loop 187 }//chip loop 188 }//board loop 189 190 //fill data to M0 display (event based) 191 Signal2D->setData(SpectrogramDataM0(z)); 192 Graph2D->axisWidget(QwtPlot::yRight)->setColorMap(Signal2D->data().range(),Signal2D->colorMap()); 193 Graph2D->setAxisScale(QwtPlot::yRight,Signal2D->data().range().minValue(),Signal2D->data().range().maxValue() ); 194 Graph2D->replot(); 195 //Signal2D->show(); 196 197 //update ranges for start and stop bin to avoid startbin > stopbin 198 M0Start->setRange(0, M0Stop->value()); 199 M0Stop->setRange(M0Start->value(),(RD->RHeader->Samples)-1); 200 201 delete[] x; delete[] y; 202 203 } 204 if(Tmpfile!=NULL) fclose(Tmpfile); 95 // Print event header and trigger cell information from event data 96 rewind(Tmpfile); 97 QTextStream in(Tmpfile); 98 QString text = in.readAll(); 99 100 text.append("\nTrigger cells: "); 101 for (unsigned int i=0; i<RD->RHeader->NBoards*RD->RHeader->NChips; i++) { 102 QString a; 103 text.append(a.sprintf("%d ", *((int *)RD->Data + i))); 104 } 105 EventHeaderDisplay->setPlainText(text); 106 107 // Case data in double format required by qwt library 108 double *x = new double [RD->RHeader->Samples]; 109 double *y = new double [RD->RHeader->Samples]; 110 111 for (unsigned int i=0; i<RD->RHeader->Samples; i++) { 112 x[i] = (double) (i/RD->BStruct[BoardNo->value()].NomFreq); 113 y[i] = (double) *((short *) (RD->Data + RD->RHeader->NBoards*RD->RHeader->NChips*sizeof(int)) + BoardNo->value()*RD->RHeader->NChips*RD->RHeader->NChannels * 114 RD->RHeader->Samples+ChannelNo->value()*RD->RHeader->Samples+i)*RD->BStruct[BoardNo->value()].ScaleFactor; 115 } 116 117 Signal->setData(x, y, (int) RD->RHeader->Samples); 118 Signal->show(); 119 Zoomer->setZoomBase(Signal->boundingRect()); 120 121 delete[] x; delete[] y; 122 123 // ************************************ 124 // Get data for M0 display (event based) 125 // ************************************ 126 127 double z[6][6];//36 pixels 128 129 for(unsigned int i=0; i<RD->RHeader->NBoards; i++) {//board loop 130 for(unsigned int j=0; j<RD->RHeader->NChips; j++) {//chip loop 131 for(unsigned int k=0; k<RD->RHeader->NChannels; k++) {//channel loop 132 133 //only interested in M0 data 134 if( ( (i==0 || i==1) && (j<=1) && (k<=7) ) || ( (i==2) && (j==0) && (k<=3) ) ) { 135 136 //get module, superpixel and pixel number from pixel name 137 138 std::string pixelname = PixMap->DRS_to_Pixel(i,j,k); 139 char pixelname_copy[256]; 140 memset(pixelname_copy,'\0',256); 141 pixelname.copy(pixelname_copy, 256); 142 143 char delim[] = "-"; 144 char *buffer = NULL; 145 int module = -1; 146 int superpixel = -1; 147 int pixel = -1; 148 149 buffer = strtok(pixelname_copy, delim); 150 module = atoi(buffer); 151 buffer = strtok(NULL, delim); 152 superpixel = atoi(buffer); 153 buffer = strtok(NULL, delim); 154 pixel = atoi(buffer); 155 156 //usual M0 mapping 157 //int binx = 5-(int((superpixel-1)/3)*2)-(int((pixel%4)/2)); 158 //int biny = 5-(((superpixel-1)%3)*2)-(int((pixel-1)/2)); 159 160 //M0 upside down 161 int binx = 5-(5-(int((superpixel-1)/3)*2)-(int((pixel%4)/2))); 162 int biny = 5-(5-(((superpixel-1)%3)*2)-(int((pixel-1)/2))); 163 164 //search maximum sample amplitude within user specified window 165 //start bin is always smaller than stop bin (taken care of by updated ranges) 166 int StartBin = (int)(M0Start->value()); 167 int StopBin = (int)(M0Stop->value()); 168 169 for(int l=StartBin; l<=StopBin; l++){ 170 171 float sample = *((short *) (RD->Data + RD->RHeader->NBoards*RD->RHeader->NChips*sizeof(int)) + 172 i*RD->RHeader->NChips*RD->RHeader->NChannels*RD->RHeader->Samples+ 173 j*RD->RHeader->NChannels*RD->RHeader->Samples+ 174 k*RD->RHeader->Samples+ 175 l)*RD->BStruct[i].ScaleFactor; 176 177 if (sample > z[binx][biny]) { 178 z[binx][biny]=sample; 179 } 180 181 }//sample loop 182 }//only M0 data 183 }//channel loop 184 }//chip loop 185 }//board loop 186 187 //fill data to M0 display (event based) 188 Signal2D->setData(SpectrogramDataM0(z)); 189 Graph2D->axisWidget(QwtPlot::yRight)->setColorMap(Signal2D->data().range(),Signal2D->colorMap()); 190 Graph2D->setAxisScale(QwtPlot::yRight,Signal2D->data().range().minValue(),Signal2D->data().range().maxValue() ); 191 Graph2D->replot(); 192 193 //update ranges for start and stop bin to avoid startbin > stopbin 194 M0Start->setRange(0, M0Stop->value()); 195 M0Stop->setRange(M0Start->value(),(RD->RHeader->Samples)-1); 205 196 } 206 197 … … 304 295 if (WaitForData && Text.endsWith(QLatin1String("==END=="))) { 305 296 // Extract text between ==START== and ==END== 306 QByteArray Data =Text.mid(Text.lastIndexOf("==START==")+9,Text.length()-Text.lastIndexOf("==START==")-16).toAscii();297 QByteArray Data = Text.mid(Text.lastIndexOf("==START==")+9, Text.length() - Text.lastIndexOf("==START==")-16).toAscii(); 307 298 308 299 char *NextNumber = strtok(Data.data()," "); // Number of entries that follow -
tools/ddd/GUI.cpp
r66 r81 24 24 PixMap = new PixelMap("../../config/PixelMap.txt", false); 25 25 26 Tmpfile = tmpfile(); 27 if(Tmpfile==NULL) { 28 QMessageBox::warning(this, "ddd Message","Could not open temporary file.",QMessageBox::Ok); 29 } 30 26 31 //--------------------------------------------------------------------- 27 32 //**************************** Main window **************************** … … 107 112 Signal->attach(Graph); 108 113 Signal->setStyle(QwtPlotCurve::Steps); 114 115 AutoscaleBox = new QCheckBox("Autoscale", Central); 116 AutoscaleBox->setFont(QFont("Times", 10, QFont::Bold)); 117 AutoscaleBox->setToolTip("Scale axes automatically"); 118 119 GraphLayout = new QVBoxLayout; 120 GraphLayout->addWidget(Graph); 121 GraphLayout->addWidget(AutoscaleBox); 109 122 110 123 // Text boxes for run and event header … … 283 296 delete M0Window; 284 297 delete PixMap; delete RD; 298 299 fclose(Tmpfile); 285 300 } 286 301 -
tools/ddd/GUI.h
r66 r81 29 29 30 30 QPushButton *GetButton, *SocketButton, *Connect, *M0Display; 31 QCheckBox *ContinuousBox ;31 QCheckBox *ContinuousBox, *AutoscaleBox; 32 32 QToolButton *LoadButton; 33 33 QLineEdit *FilenameBox, *IPAddress, *Command, *PixelID; … … 39 39 QAction *OpenAction, *ConnectAction; 40 40 QGridLayout *SocketLayout, *MainLayout, *M0Layout; 41 QVBoxLayout *GraphLayout; 41 42 QFormLayout *CommandLayout, *PortLayout, *AddressLayout, *FormLayout, *SpinLayout, *M0StartLayout, *M0StopLayout; 42 43 … … 54 55 RawDataCTX *RD; 55 56 PixelMap *PixMap; 57 FILE *Tmpfile; 56 58 57 59 public:
Note:
See TracChangeset
for help on using the changeset viewer.