Index: tools/ddd/Functions.cpp
===================================================================
--- tools/ddd/Functions.cpp	(revision 197)
+++ tools/ddd/Functions.cpp	(revision 198)
@@ -37,8 +37,10 @@
     default: break;
   }
-  if (RD->RHeader->MagicNum == MAGICNUM_OPEN) {
+  RunHeader *R = RD->RHeader;
+
+  if (R->MagicNum == MAGICNUM_OPEN) {
     QMessageBox::warning(this, "ddd Message","Magic number in run header indicates that the file has not been closed properly.",QMessageBox::Ok);
   }
-  if (RD->RHeader->MagicNum == MAGICNUM_ERROR) {
+  if (R->MagicNum == MAGICNUM_ERROR) {
     QMessageBox::warning(this, "ddd Message","Magic number in run header indicates that an error occurred while writing the file.",QMessageBox::Ok);
   }
@@ -52,4 +54,5 @@
   EventNo->setEnabled(true);
   ChannelNo->setEnabled(true);
+  ChipNo->setEnabled(true);
   BoardNo->setEnabled(true);
   PixelID->setEnabled(true);
@@ -57,10 +60,11 @@
   M0Stop->setEnabled(true);
   PhysPipeAction->setEnabled(true);
-  EventNo->setRange(1, RD->RHeader->Events);
+  EventNo->setRange(1, R->Events);
   M0Display->setEnabled(true);
-  M0Start->setRange(0,(RD->RHeader->Samples)-1);  
-  M0Stop->setRange(0,(RD->RHeader->Samples)-1);
-  ChannelNo->setRange(0, RD->RHeader->NChannels*RD->RHeader->NChips-1);
-  BoardNo->setRange(0, RD->RHeader->NBoards-1);
+  M0Start->setRange(0, R->Samples-1);  
+  M0Stop->setRange(0, R->Samples-1);
+  ChannelNo->setRange(0, R->NChannels-1);
+  ChipNo->setRange(0, R->NChips-1);
+  BoardNo->setRange(0, R->NBoards-1);
   DisplayEvent();
 }
@@ -71,4 +75,5 @@
     EventNo->setEnabled(false);
     ChannelNo->setEnabled(false);
+    ChipNo->setEnabled(false);
     BoardNo->setEnabled(false);
     PixelID->setEnabled(false);
@@ -85,6 +90,5 @@
 void ddd::DisplayEvent(int) {
 
-  PixelID->setText(PixMap->DRS_to_Pixel(BoardNo->value(), ChannelNo->value()/RD->RHeader->NChannels,
-					ChannelNo->value()%RD->RHeader->NChannels).c_str());  // Translate to pixel ID
+  PixelID->setText(PixMap->DRS_to_Pixel(BoardNo->value(), ChipNo->value(),	ChannelNo->value()).c_str());  // Translate to pixel ID
   if(Socket->state() == QAbstractSocket::ConnectedState) return; // do not execute if socket is open
   
@@ -104,5 +108,6 @@
     return;
   }
- 
+  RunHeader *R = RD->RHeader;
+
   // Print event header and trigger cell information from event data
   rewind(Tmpfile);
@@ -111,5 +116,5 @@
   
   text.append("\nTrigger cells: ");
-  for (unsigned int i=0; i<RD->RHeader->NBoards*RD->RHeader->NChips; i++) {
+  for (unsigned int i=0; i<R->NBoards*R->NChips; i++) {
     QString a;
     text.append(a.sprintf("%d ", *((int *)RD->Data + i)));
@@ -118,18 +123,25 @@
 
   // Case data in double format required by qwt library
-  double *x = new double [RD->RHeader->Samples];
-  double *y = new double [RD->RHeader->Samples];
-
-  for (unsigned int i=0; i<RD->RHeader->Samples; i++) {
+  double *x = new double [R->Samples];
+  double *y = new double [R->Samples];
+
+  for (unsigned int i=0; i<R->Samples; i++) {
     x[i] = (double) (i/RD->BStruct[BoardNo->value()].NomFreq);
 	if (PhysPipeAction->isChecked()) {
-      y[(i + *((int *) RD->Data + BoardNo->value()*RD->RHeader->NChips+ChannelNo->value()/RD->RHeader->NChannels))%1024] = (double) *((short *) (RD->Data + RD->RHeader->NBoards*RD->RHeader->NChips*sizeof(int)) + BoardNo->value()*RD->RHeader->NChips*RD->RHeader->NChannels * RD->RHeader->Samples + ChannelNo->value()*RD->RHeader->Samples + i)*RD->BStruct[BoardNo->value()].ScaleFactor;
+      y[(i + *((int *) RD->Data + BoardNo->value()*R->NChips+ChipNo->value()))%1024] =
+	    (double) *((short *) (RD->Data + R->NBoards*R->NChips*sizeof(int)) +
+	    BoardNo->value()*R->NChips*R->NChannels*R->Samples +
+   	    ChipNo->value()*R->NChannels*R->Samples + 
+	    ChannelNo->value()*RD->RHeader->Samples + i) * RD->BStruct[BoardNo->value()].ScaleFactor;
 	}
 	else {
-      y[i] = (double) *((short *) (RD->Data + RD->RHeader->NBoards*RD->RHeader->NChips*sizeof(int)) + BoardNo->value()*RD->RHeader->NChips*RD->RHeader->NChannels * RD->RHeader->Samples+ChannelNo->value()*RD->RHeader->Samples+(i))*RD->BStruct[BoardNo->value()].ScaleFactor;
+      y[i] = (double) *((short *) (RD->Data + R->NBoards*R->NChips*sizeof(int)) +
+	  	BoardNo->value()*R->NChips*R->NChannels*R->Samples +
+		ChipNo->value()*R->NChannels*R->Samples +
+		ChannelNo->value()*R->Samples + i) * RD->BStruct[BoardNo->value()].ScaleFactor;
 	}
   }
 
-  Signal->setData(x, y, (int) RD->RHeader->Samples);
+  Signal->setData(x, y, (int) R->Samples);
   Signal->show();
   Zoomer->setZoomBase(Signal->boundingRect());
@@ -255,5 +267,5 @@
   GetButton->setEnabled(false);
   WaitForData = true;
-  sprintf(Command, "read %d %d %d restart", BoardNo->value(), ChannelNo->value()/10, ChannelNo->value()%10);
+  sprintf(Command, "read %d %d %d restart", BoardNo->value(), ChipNo->value(), ChannelNo->value());
   Socket->write(Command);
 }
@@ -299,7 +311,9 @@
 
       ChannelNo->setEnabled(true);
+      ChipNo->setEnabled(true);
       BoardNo->setEnabled(true);
       PixelID->setEnabled(true);
       ChannelNo->setRange(0, 65535);
+      ChipNo->setRange(0, 65535);
       BoardNo->setRange(0, 65535);
       
@@ -390,4 +404,5 @@
   GetButton->setEnabled(false);
   ChannelNo->setEnabled(false);
+  ChipNo->setEnabled(false);
   BoardNo->setEnabled(false);
   PixelID->setEnabled(false);
@@ -407,8 +422,10 @@
   int Channel = PixMap->Pixel_to_DRSchannel(PixelID->text().toStdString());
 
-  if(Board>=BoardNo->minimum() && Board<=BoardNo->maximum() && 
-     (Chip*10+Channel)>=ChannelNo->minimum() && (Chip*10+Channel)<=ChannelNo->maximum()) { 
+  if(Board	>= BoardNo->minimum()	&& Board	<= BoardNo->maximum() && 
+     Chip	>= ChipNo->minimum()	&& Chip		<= ChipNo->maximum() &&
+     Channel>= ChannelNo->minimum() && Channel	<= ChannelNo->maximum()) { 
     BoardNo->setValue(Board);
-    ChannelNo->setValue(Chip*10+Channel);
+    ChipNo->setValue(Chip);
+    ChannelNo->setValue(Channel);
   }
   else if(Board==999999999) QMessageBox::warning(this, "ddd Message","Pixel ID unknown.",QMessageBox::Ok);
