Index: /tools/ddd/Functions.cpp
===================================================================
--- /tools/ddd/Functions.cpp	(revision 196)
+++ /tools/ddd/Functions.cpp	(revision 197)
@@ -58,4 +58,5 @@
   PhysPipeAction->setEnabled(true);
   EventNo->setRange(1, RD->RHeader->Events);
+  M0Display->setEnabled(true);
   M0Start->setRange(0,(RD->RHeader->Samples)-1);  
   M0Stop->setRange(0,(RD->RHeader->Samples)-1);
@@ -84,5 +85,6 @@
 void ddd::DisplayEvent(int) {
 
-  PixelID->setText(PixMap->DRS_to_Pixel(BoardNo->value(), ChannelNo->value()/10, ChannelNo->value()%10).c_str());  // Translate to pixel ID
+  PixelID->setText(PixMap->DRS_to_Pixel(BoardNo->value(), ChannelNo->value()/RD->RHeader->NChannels,
+					ChannelNo->value()%RD->RHeader->NChannels).c_str());  // Translate to pixel ID
   if(Socket->state() == QAbstractSocket::ConnectedState) return; // do not execute if socket is open
   
@@ -139,5 +141,14 @@
   // ************************************   
 
-  double z[6][6];//36 pixels
+  if (!(M0Display->isEnabled())) return;
+
+  double z[6][6] = {{0}};//36 pixels
+  bool IDerror = false;
+
+  //only interested in M0 data using DRS2
+  //if (RD->RHeader->NChannels == 9) IDerror = true;  
+
+  //only interested in M0 data using DRS4
+  if (RD->RHeader->NChannels == 10) IDerror = true;  
 
   for(unsigned int i=0; i<RD->RHeader->NBoards; i++) {//board loop
@@ -145,10 +156,16 @@
       for(unsigned int k=0; k<RD->RHeader->NChannels; k++) {//channel loop
 
-	//only interested in M0 data
-	if( ( (i==0 || i==1) && (j<=1) && (k<=7) ) || ( (i==2) && (j==0) && (k<=3) ) ) {
-
+	//for DRS2 data (requires the correct pixelmap!!!
+	//if( ( (i==0 || i==1) && (j<=1) && (k<=7) ) || ( (i==2) && (j==0) && (k<=3) ) ) {
+
+	//for DRS4 data (requires the correct pixelmap!!!
+	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) ) ) {
+	 
 	  //get module, superpixel and pixel number from pixel name
-
 	  std::string pixelname = PixMap->DRS_to_Pixel(i,j,k);
+	  if (pixelname == "") {
+	    IDerror = true;
+	    continue;
+	  }
 	  char pixelname_copy[256];
 	  memset(pixelname_copy,'\0',256);
@@ -189,6 +206,6 @@
 			     l)*RD->BStruct[i].ScaleFactor;
 
-	    if (sample > z[binx][biny]) {
-	      z[binx][biny]=sample;
+	    if (fabs(sample) > z[binx][biny]) {
+	      z[binx][biny]=fabs(sample);
 	    }
 
@@ -199,4 +216,11 @@
   }//board loop
 
+  if(IDerror){
+    QMessageBox::warning(this, "ddd Message","Sorry! The M0 display is not available for this data file because of a pixel ID mismatch.",QMessageBox::Ok);
+    if(M0Window->isVisible()) M0Window->hide();
+    M0Display->setEnabled(false);
+    return;
+  }
+
   //fill data to M0 display (event based)
   Signal2D->setData(SpectrogramDataM0(z));
@@ -251,5 +275,5 @@
         QMessageBox::No, QMessageBox::Yes) != QMessageBox::Yes) return;
 		
-	PhysPipeAction->setChecked(false);
+    PhysPipeAction->setChecked(false);
 	    
     Socket->connectToHost(IPAddress->text(),Port->value());
@@ -271,4 +295,7 @@
       CloseDatafile();
 
+      M0Window->hide();
+      M0Display->setEnabled(false);
+
       ChannelNo->setEnabled(true);
       BoardNo->setEnabled(true);
