Index: fact/config/PixelMap_M0.txt
===================================================================
--- fact/config/PixelMap_M0.txt	(revision 10116)
+++ fact/config/PixelMap_M0.txt	(revision 10116)
@@ -0,0 +1,74 @@
+#######################################################################
+#
+# Mapping table to connect DRS channels to HV channels
+#
+# !!! only valid for M0 !!!
+#
+# =====================================================================
+#
+# needed for HV feedback -> read by DAQ and HV program
+# 
+# to be edited if DRS or HV channels change
+#
+# pixel ID is unsigned int 0 - 35, to be followed by : delimiter
+#
+# gAPD arrangement within pixel is NOT defined here
+#
+# =====================================================================
+#
+# allowed field separators: space and tab in arbitrary combination
+#
+# each entry has to end with ;
+#
+# lines _starting_ with # considered as comment (first character!)
+#
+#######################################################################
+
+
+#ID:  crate  board patch(chip) pixel(channel)  HV-crate HV-board HV-channel    PosX    PosY
+#--------------------------------------------------------------------------------------------------------
+00:	0	0	0	0		0	0	 0		5	5;
+01:	0	0	0	2		0	0	 1		4	5;
+02:	0	0	0	4		0 	0	 2		4	4;
+03:	0	0	0	6		0 	0	 3		5	4;
+#--------------------------------------------------------------------------------------------------------
+04:	0	0	1	0		0	0	 4		5	3;
+05:	0	0	1	2		0	0	 5		4	3;
+06:	0	0	1	4		0 	0	 6		4	2;
+07:	0	0	1	6		0 	0	 7		5	2;
+#--------------------------------------------------------------------------------------------------------
+08:	0	0	2	0		0	0	 8		5	1;
+09:	0	0	2	2		0	0	 9		4	1;
+10:	0	0	2	4		0 	0	10		4	0;
+11:	0	0	2	6		0 	0	11		5	0;
+#--------------------------------------------------------------------------------------------------------
+12:	0	0	3	0		0	0	12		3	5;
+13:	0	0	3	2		0	0	13		2	5;
+14:	0	0	3	4		0 	0	14		2	4;
+15:	0	0	3	6		0 	0	15		3	4;
+#--------------------------------------------------------------------------------------------------------
+16:	0	1	0	0		0	0	16		3	3;
+17:	0	1	0	2		0	0	17		2	3;
+18:	0	1	0	4		0 	1	 0		2	2;
+19:	0	1	0	6		0 	1	 1		3	2;
+#--------------------------------------------------------------------------------------------------------
+20:	0	1	1	0		0	1	 2		3	1;
+21:	0	1	1	2		0	1	 3		2	1;
+22:	0	1	1	4		0 	1	 4		2	0;
+23:	0	1	1	6		0 	1	 5		3	0;
+#--------------------------------------------------------------------------------------------------------
+24:	0	1	2	0		0	1	 6		1	5;
+25:	0	1	2	2		0	1	 7		0	5;
+26:	0	1	2	4		0 	1	 8		0	4;
+27:	0	1	2	6		0 	1	 9		1	4;
+#--------------------------------------------------------------------------------------------------------
+28:	0	1	3	0		0	1	10		1	3;
+29:	0	1	3	2		0	1	11		0	3;
+30:	0	1	3	4		0 	1	12		0	2;
+31:	0	1	3	6		0 	1	13		1	2;
+#--------------------------------------------------------------------------------------------------------
+32:	0	2	0	0		0	1	14		1	1;
+33:	0	2	0	2		0	1	15		0	1;
+34:	0	2	0	4		0 	1	16		0	0;
+35:	0	2	0	6		0 	1	17		1	0;
+#--------------------------------------------------------------------------------------------------------
Index: fact/pixelmap/Pixel.cc
===================================================================
--- fact/pixelmap/Pixel.cc	(revision 10114)
+++ fact/pixelmap/Pixel.cc	(revision 10116)
@@ -1,14 +1,17 @@
-#include "PixelMap.h"
+#include "Pixel.h"
 #include <iostream>
 
-Pixel::Pixel() : _DRSboard(999999999), _DRSchip(999999999), _DRSchannel(999999999),
-		 _HVboard(999999999), _HVchain(999999999), _HVchannel(999999999) { }
+Pixel::Pixel() : _FPAcrate(0), _FPAboard(0), _FPApatch(0), _FPApixel(0),
+		 _HVcrate(0), _HVboard(0), _HVchannel(0),
+		 _POSx(0), _POSy(0) {
 
-Pixel::Pixel(unsigned int DRSboard, unsigned int DRSchip, unsigned int DRSchannel,
-	     unsigned int HVboard, unsigned int HVchain, unsigned int HVchannel)
-    : _DRSboard(DRSboard), _DRSchip(DRSchip), _DRSchannel(DRSchannel),
-      _HVboard(HVboard), _HVchain(HVchain), _HVchannel(HVchannel) {
+}
 
-    //???check here whether values make sense and eventually give error messages???
+Pixel::Pixel(unsigned int FPAcrate, unsigned int FPAboard, unsigned int FPApatch, unsigned int FPApixel,
+	     unsigned int HVcrate, unsigned int HVboard, unsigned int HVchannel,
+	     int POSx, int POSy)
+    : _FPAcrate(FPAcrate), _FPAboard(FPAboard), _FPApatch(FPApatch), _FPApixel(FPApixel),
+      _HVcrate(HVcrate), _HVboard(HVboard), _HVchannel(HVchannel),
+      _POSx(POSx), _POSy(POSy) {
 
 }
@@ -16,10 +19,13 @@
 std::ostream& operator << (std::ostream& s, const Pixel& pixel) {
   
-    return s << "DRSboard="<<pixel._DRSboard<<"\n"
-	     << "DRSchip="<<pixel._DRSchip<<"\n"
-	     << "DRSchannel="<<pixel._DRSchannel<<"\n"
+    return s << "FPAcrate="<<pixel._FPAcrate<<"\n"
+	     << "FPAboard="<<pixel._FPAboard<<"\n"
+	     << "FPApatch="<<pixel._FPApatch<<"\n"
+	     << "FPApixel="<<pixel._FPApixel<<"\n"
+	     << "HVcrate="<<pixel._HVcrate<<"\n"
 	     << "HVboard="<<pixel._HVboard<<"\n"
-	     << "HVchain="<<pixel._HVchain<<"\n"
-	     << "HVchannel="<<pixel._HVchannel<<"\n";
+	     << "HVchannel="<<pixel._HVchannel<<"\n"
+	     << "POSx="<<pixel._POSx<<"\n"
+	     << "POSy="<<pixel._POSy<<"\n";
 
 }
Index: fact/pixelmap/Pixel.h
===================================================================
--- fact/pixelmap/Pixel.h	(revision 10114)
+++ fact/pixelmap/Pixel.h	(revision 10116)
@@ -8,35 +8,36 @@
 private:
 
-    unsigned int _DRSboard;
-    unsigned int _DRSchip;
-    unsigned int _DRSchannel;
+    unsigned int _FPAcrate;
+    unsigned int _FPAboard;
+    unsigned int _FPApatch;
+    unsigned int _FPApixel;
 
+    unsigned int _HVcrate;
     unsigned int _HVboard;
-    unsigned int _HVchain;
     unsigned int _HVchannel;
+
+    int _POSx;
+    int _POSy;
 
 public:
     
     Pixel();
-    Pixel(unsigned int DRSboard, unsigned int DRSchip, unsigned int DRSchannel,
-	  unsigned int HVboard, unsigned int HVchain, unsigned int HVchannel);
+    Pixel(unsigned int FPAcrate, unsigned int FPAboard, unsigned int FPApatch, unsigned int FPApixel,
+	  unsigned int HVcrate, unsigned int HVboard, unsigned int HVchannel,
+	  int POSx, int POSy);
 
     ~Pixel() { }
 
-    //void SetPixelDRSboard(unsigned int DRSboard);
-    //void SetPixelDRSchip(unsigned int DRSchip);
-    //void SetPixelDRSchannel(unsigned int DRSchannel);
+    unsigned int GetPixelFPAcrate() const {return _FPAcrate;}
+    unsigned int GetPixelFPAboard() const {return _FPAboard;}
+    unsigned int GetPixelFPApatch() const {return _FPApatch;}
+    unsigned int GetPixelFPApixel() const {return _FPApixel;}
 
-    //void SetPixelHVboard(unsigned int HVboard);
-    //void SetPixelHVchain(unsigned int HVchain);
-    //void SetPixelHVchannel(unsigned int HVchannel);
+    unsigned int GetPixelHVcrate() const {return _HVcrate;}
+    unsigned int GetPixelHVboard() const {return _HVboard;}
+    unsigned int GetPixelHVchannel() const {return _HVchannel;}
 
-    unsigned int GetPixelDRSboard() const {return _DRSboard;}
-    unsigned int GetPixelDRSchip() const {return _DRSchip;}
-    unsigned int GetPixelDRSchannel() const {return _DRSchannel;}
-
-    unsigned int GetPixelHVboard() const {return _HVboard;}
-    unsigned int GetPixelHVchain() const {return _HVchain;}
-    unsigned int GetPixelHVchannel() const {return _HVchannel;}
+    int GetPixelPOSx() const {return _POSx;}
+    int GetPixelPOSy() const {return _POSy;}
 
     friend std::ostream& operator << (std::ostream& s, const Pixel& pixel);
Index: fact/pixelmap/PixelMap.cc
===================================================================
--- fact/pixelmap/PixelMap.cc	(revision 10114)
+++ fact/pixelmap/PixelMap.cc	(revision 10116)
@@ -6,8 +6,10 @@
 #include <cctype>
 
-PixelMap::PixelMap(std::string file, bool verbose) {
+const unsigned int PixelMap::PM_ERROR_CODE;
+
+PixelMap::PixelMap(std::string data, bool verbose) {
 
     pixelmap.clear();
-    ReadPixelMap(pixelmap, file, verbose);
+    ReadPixelMap(pixelmap, data, verbose);
 
 }
@@ -15,5 +17,5 @@
 PixelMap::~PixelMap() {
 
-    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
+    for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
 	delete ((*iter).second);
     }
@@ -21,62 +23,54 @@
 }
 
-void PixelMap::ReadPixelMap(std::map<std::string, Pixel*>& pixelmap, std::string file, bool verbose) {
-
-    //std::string filename("PixelMap.txt");
-    std::ifstream infile(file.c_str(), std::fstream::in);
+void PixelMap::ReadPixelMap(std::map<unsigned int, Pixel*>& pixelmap, std::string data, bool verbose) {
 
     if (verbose) {
-	std::cout<<"Reading mapping file: "<<file<<std::endl<<std::endl;    
-	if (!infile.good()) {
-	    std::cerr<<"ERROR in PixelMap::ReadPixelMap: File "<<file<<" cannot be found."<<std::endl;
-	}
-    }
-
-    while (infile.good()) {
+	std::cout<<"Creating pixelmap table"<<std::endl;    
+	if (strlen(data.c_str()) == 0) {
+	    std::cerr<<"WARNING in PixelMap::ReadPixelMap: input table is empty"<<std::endl;
+	}
+    }
+
+    std::string::size_type Next, EndNext = 0;
+
+    while (EndNext != std::string::npos) {
 	
-	char line[1024];
-
-	infile.getline(line, 1024);
-
-	if (line[0] == '#') {
-	    if (verbose) {
-		std::cout << "Ignoring comment: " << line << std::endl;
+	Next = data.find_first_not_of(";", EndNext);
+	EndNext = data.find_first_of(";", Next);
+
+	// Stop if end of string reached
+        if (Next == std::string::npos) break;
+    
+	std::string tokens = data.substr(Next, EndNext - Next);
+
+	if (tokens.find(":") != std::string::npos) {
+
+	    char* ctokens = new char[tokens.size()+1];
+	    strcpy (ctokens, tokens.c_str());
+		
+	    char delim[] = ":";
+	    char *name = NULL; //unformated name before : tokens
+	    char name2[256] = ""; //formated name without whitespaces
+	    char *rest = NULL;
+		
+	    name = strtok(ctokens, delim);
+
+	    unsigned int count1 = 0; //count non-whitespace characters in name
+
+	    for (unsigned int i = 0; i < strlen(name); i++) {
+
+		if ( !(isspace(name[i])) ) {		    
+		    name2[count1] = name[i];
+		    count1+=1;
+		}
+
 	    }
-	}
-
-	else {
-	    
-	    if (strlen(line)!=0) {
+
+	    if( (count1 > 0) && (count1 < 5) ) {
+
+		unsigned int pixelID = (unsigned int)atoi(name2);
+		std::map<const unsigned int, Pixel*>::iterator found = pixelmap.find(pixelID);
 		
-		char delim[] = ":";
-		char *name = NULL; //unformated name before : tokens
-		char name2[256] = ""; //formated name without whitespaces
-		char *rest = NULL;
-		
-		name = strtok(line, delim);
-
-		unsigned int count1 = 0; //count non-whitespace characters in name
-		unsigned int count2 = 0; //count number of - in name
-
-		for (unsigned int i = 0; i < strlen(name); i++) {
-
-		    if ( !(isspace(name[i])) ) {
-
-			name2[count1] = name[i];
-			count1+=1;
-
-			if ( (name[i] == 45) ) {
-			    count2+=1;
-			}
-
-		    }
-
-		}
-
-		//if (verbose) {
-		//  std::cout << "Formated pixel name: " << name2 << std::endl;
-		//}
-
-		if( (count1 > 4) && (count1 < 7) && (count2 == 2) ) {
+		if( found == pixelmap.end() ) {//pixelID already existing?
 
 		    rest = strtok(NULL, delim);
@@ -84,16 +78,25 @@
 		    if(rest != NULL) {
 			
-			unsigned int DRSboard = (unsigned int)strtod(rest, &rest);					    
-			unsigned int DRSchip = (unsigned int)strtod(rest, &rest);	    
-			unsigned int DRSchannel = (unsigned int)strtod(rest, &rest);
+			unsigned int FPAcrate = (unsigned int)strtod(rest, &rest);
+			unsigned int FPAboard = (unsigned int)strtod(rest, &rest);					    
+			unsigned int FPApatch = (unsigned int)strtod(rest, &rest);	    
+			unsigned int FPApixel = (unsigned int)strtod(rest, &rest);
+			unsigned int HVcrate = (unsigned int)strtod(rest, &rest);
 			unsigned int HVboard = (unsigned int)strtod(rest, &rest);
-			unsigned int HVchain = (unsigned int)strtod(rest, &rest);
 			unsigned int HVchannel = (unsigned int)strtod(rest, &rest);
-
-			pixelmap[name2] = new Pixel(DRSboard, DRSchip, DRSchannel,
-						    HVboard, HVchain, HVchannel);
-
+			int POSx = (int)strtod(rest, &rest);
+			int POSy = (int)strtod(rest, &rest);
+
+			pixelmap[pixelID] = new Pixel(FPAcrate, FPAboard, FPApatch, FPApixel,
+						      HVcrate, HVboard, HVchannel,
+						      POSx, POSy);
 		    }
 
+		    else {
+			
+			pixelmap[pixelID] = new Pixel();
+
+		    }
+
 		}
 
@@ -101,21 +104,31 @@
 
 		    if (verbose) {
-			std::cout << "ERROR in PixelMap::ReadPixelMap: Wrong pixel name: " << name2 << " -> pixel not initialized" << std::endl;
+			std::cout << "ERROR in PixelMap::ReadPixelMap: pixel ID already existing: " << pixelID << " -> pixel not initialized again" << std::endl;
 		    }
 
 		}
 
-	    } 
+	    }
 
 	    else {
 
-		if(verbose){
-		    std::cout << "Skipping empty line" << std::endl;
+		if (verbose) {
+		    std::cout << "ERROR in PixelMap::ReadPixelMap: wrong pixel ID: " << name2 << " -> pixel not initialized" << std::endl;
 		}
 
 	    }
 
-	}
-	
+	    delete[] ctokens;
+
+	} 
+
+	else {
+
+	    if(verbose){
+		std::cout << "ERROR in PixelMap::ReadPixelMap: entry without pixel ID: " << tokens << " -> pixel not initialized" << std::endl;
+	    }
+
+	}
+
     }
 
@@ -123,6 +136,4 @@
 	std::cout << std::endl << pixelmap.size() << " pixels found" << std::endl << std::endl;
     }
-
-    infile.close();
 								
 }
@@ -132,5 +143,5 @@
     std::cout << "Printing entries of pixelmap:" << std::endl << std::endl;
 
-    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
+    for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
 	std::cout << (*iter).first << std::endl << "------------" << std::endl << *((*iter).second) << std::endl;
     }
@@ -138,57 +149,62 @@
 }
 
-std::string PixelMap::DRS_to_Pixel(unsigned int DRSboard, unsigned int DRSchip, unsigned int DRSchannel, bool verbose) {
-
-    std::string pixelname = "";
-
-    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
-
-	if( ( ((*iter).second)->GetPixelDRSboard() == DRSboard ) &&
-	    ( ((*iter).second)->GetPixelDRSchip() == DRSchip ) &&
-	    ( ((*iter).second)->GetPixelDRSchannel() == DRSchannel ) ) {
-
-	    pixelname = (*iter).first;
-
-	}
-
-    }
-
-    if(pixelname == ""){
+unsigned int PixelMap::FPA_to_Pixel(unsigned int FPAcrate, unsigned int FPAboard, unsigned int FPApatch, unsigned int FPApixel, bool verbose) {
+
+    unsigned int pixelID = PM_ERROR_CODE;
+
+    for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
+
+	if( ( ((*iter).second)->GetPixelFPAcrate() == FPAcrate ) &&
+	    ( ((*iter).second)->GetPixelFPAboard() == FPAboard ) &&
+	    ( ((*iter).second)->GetPixelFPApatch() == FPApatch ) &&
+	    ( ((*iter).second)->GetPixelFPApixel() == FPApixel ) ) {
+
+	    pixelID = (*iter).first;
+
+	}
+
+    }
+
+    if(pixelID == PM_ERROR_CODE){
 	
 	if (verbose) {
-	    std::cout << "ERROR in PixelMap::DRS_to_Pixel: No pixel with DRS board, chip, channel = "
-		      << DRSboard << ", "
-		      << DRSchip << ", "
-		      << DRSchannel << " found in pixelmap" << std::endl;
+	    std::cout << "ERROR in PixelMap::FPA_to_Pixel: No pixel with FPA crate, board, patch, pixel = "
+		      << FPAcrate << ", "
+		      << FPAboard << ", "
+		      << FPApatch << ", "
+		      << FPApixel << " found in pixelmap" << std::endl;
 	}	
 
     }
 
-    return pixelname;
-
-}
-
-std::string PixelMap::HV_to_Pixel(unsigned int HVboard, unsigned int HVchain, unsigned int HVchannel, bool verbose) {
-
-    std::string pixelname = "";
-
-    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
-
-	if( ( ((*iter).second)->GetPixelHVboard() == HVboard ) &&
-	    ( ((*iter).second)->GetPixelHVchain() == HVchain ) &&
+    return pixelID;
+
+}
+
+std::vector<unsigned int> PixelMap::HV_to_Pixel(unsigned int HVcrate, unsigned int HVboard, unsigned int HVchannel, bool verbose) {
+
+    unsigned int last_pixelID = PM_ERROR_CODE;
+
+    std::vector<unsigned int> PixelIDs;
+
+    for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
+
+	if( ( ((*iter).second)->GetPixelHVcrate() == HVcrate ) &&
+	    ( ((*iter).second)->GetPixelHVboard() == HVboard ) &&
 	    ( ((*iter).second)->GetPixelHVchannel() == HVchannel ) ) {
 
-	    pixelname = (*iter).first;
-
-	}
-
-    }
-
-    if(pixelname == ""){
-
-	if (verbose) {
-	    std::cout << "ERROR in PixelMap::HV_to_Pixel: No pixel with HV board, chain, channel = "
+	    last_pixelID = (*iter).first;
+	    PixelIDs.push_back(last_pixelID);
+
+	}
+
+    }
+
+    if(last_pixelID == PM_ERROR_CODE){
+
+	if (verbose) {
+	    std::cout << "ERROR in PixelMap::HV_to_Pixel: No pixel with HV crate, board, channel = "
+		      << HVcrate << ", "
 		      << HVboard << ", "
-		      << HVchain << ", "
 		      << HVchannel << " found in pixelmap" << std::endl;
 	}	
@@ -196,90 +212,169 @@
     }
 
-    return pixelname;
-
-}
-
-unsigned int PixelMap::Pixel_to_DRSboard(std::string pixelname, bool verbose) {
-
-    unsigned int DRSboard = 999999999;
-
-    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
-
-	if( ((*iter).first) == pixelname ){
-	    DRSboard = ((*iter).second)->GetPixelDRSboard();
-	}
-
-    }
-
-    if (DRSboard == 999999999) {
-
-	if (verbose) {
-	    std::cout << "ERROR in PixelMap::Pixel_to_DRSboard: No pixel with name = "
-		      << pixelname << " found in pixelmap" << std::endl;
-	}
-
-    }
-
-    return DRSboard;
-
-}
-
-unsigned int PixelMap::Pixel_to_DRSchip(std::string pixelname, bool verbose) {
-
-    unsigned int DRSchip = 999999999;
-
-    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
-
-	if( ((*iter).first) == pixelname ){
-	    DRSchip = ((*iter).second)->GetPixelDRSchip();
-	}
-
-    }
-
-    if (DRSchip == 999999999) {
-
-	if (verbose) {
-	    std::cout << "ERROR in PixelMap::Pixel_to_DRSchip: No pixel with name = "
-		      << pixelname << " found in pixelmap" << std::endl;
-	}
-
-    }
-
-    return DRSchip;
-
-}
-
-unsigned int PixelMap::Pixel_to_DRSchannel(std::string pixelname, bool verbose) {
-
-    unsigned int DRSchannel = 999999999;
-
-    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
-
-	if( ((*iter).first) == pixelname ){
-	    DRSchannel = ((*iter).second)->GetPixelDRSchannel();
+    return PixelIDs;
+
+}
+
+unsigned int PixelMap::POS_to_Pixel(int POSx, int POSy, bool verbose) {
+
+    unsigned int pixelID = PM_ERROR_CODE;
+
+    for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
+
+	if( ( ((*iter).second)->GetPixelPOSx() == POSx ) &&
+	    ( ((*iter).second)->GetPixelPOSy() == POSy ) ) {
+
+	    pixelID = (*iter).first;
+
+	}
+
+    }
+
+    if(pixelID == PM_ERROR_CODE){
+	
+	if (verbose) {
+	    std::cout << "ERROR in PixelMap::POS_to_Pixel: No pixel with position x, y = "
+		      << POSx << ", "
+		      << POSy << " found in pixelmap" << std::endl;
+	}	
+
+    }
+
+    return pixelID;
+
+}
+
+unsigned int PixelMap::Pixel_to_FPAcrate(unsigned int pixelID, bool verbose) {
+
+    unsigned int FPAcrate = PM_ERROR_CODE;
+
+    for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
+
+	if( ((*iter).first) == pixelID ){
+	    FPAcrate = ((*iter).second)->GetPixelFPAcrate();
+	}
+
+    }
+
+    if (FPAcrate == PM_ERROR_CODE) {
+
+	if (verbose) {
+	    std::cout << "ERROR in PixelMap::Pixel_to_FPAcrate: No pixel with ID = "
+		      << pixelID << " found in pixelmap" << std::endl;
+	}
+
+    }
+
+    return FPAcrate;
+
+}
+
+unsigned int PixelMap::Pixel_to_FPAboard(unsigned int pixelID, bool verbose) {
+
+    unsigned int FPAboard = PM_ERROR_CODE;
+
+    for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
+
+	if( ((*iter).first) == pixelID ){
+	    FPAboard = ((*iter).second)->GetPixelFPAboard();
+	}
+
+    }
+
+    if (FPAboard == PM_ERROR_CODE) {
+
+	if (verbose) {
+	    std::cout << "ERROR in PixelMap::Pixel_to_FPAboard: No pixel with ID = "
+		      << pixelID << " found in pixelmap" << std::endl;
+	}
+
+    }
+
+    return FPAboard;
+
+}
+
+unsigned int PixelMap::Pixel_to_FPApatch(unsigned int pixelID, bool verbose) {
+
+    unsigned int FPApatch = PM_ERROR_CODE;
+
+    for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
+
+	if( ((*iter).first) == pixelID ){
+	    FPApatch = ((*iter).second)->GetPixelFPApatch();
+	}
+
+    }
+
+    if (FPApatch == PM_ERROR_CODE) {
+
+	if (verbose) {
+	    std::cout << "ERROR in PixelMap::Pixel_to_FPApatch: No pixel with ID = "
+		      << pixelID << " found in pixelmap" << std::endl;
+	}
+
+    }
+
+    return FPApatch;
+
+}
+
+unsigned int PixelMap::Pixel_to_FPApixel(unsigned int pixelID, bool verbose) {
+
+    unsigned int FPApixel = PM_ERROR_CODE;
+
+    for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
+
+	if( ((*iter).first) == pixelID ){
+	    FPApixel = ((*iter).second)->GetPixelFPApixel();
 	}
 
     }
     
-    if (DRSchannel == 999999999) {
-
-	if (verbose) {
-	    std::cout << "ERROR in PixelMap::Pixel_to_DRSchannel: No pixel with name = "
-		      << pixelname << " found in pixelmap" << std::endl;
-	}
-
-    }
-
-    return DRSchannel;
-
-}
-
-unsigned int PixelMap::Pixel_to_HVboard(std::string pixelname, bool verbose) {
-
-    unsigned int HVboard = 999999999;
-
-    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
-
-	if( ((*iter).first) == pixelname ){
+    if (FPApixel == PM_ERROR_CODE) {
+
+	if (verbose) {
+	    std::cout << "ERROR in PixelMap::Pixel_to_FPApixel: No pixel with ID = "
+		      << pixelID << " found in pixelmap" << std::endl;
+	}
+
+    }
+
+    return FPApixel;
+
+}
+
+unsigned int PixelMap::Pixel_to_HVcrate(unsigned int pixelID, bool verbose) {
+
+    unsigned int HVcrate = PM_ERROR_CODE;
+
+    for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
+
+	if( ((*iter).first) == pixelID ){
+	    HVcrate = ((*iter).second)->GetPixelHVcrate();
+	}
+
+    }
+
+    if (HVcrate == PM_ERROR_CODE) {
+
+	if (verbose) {
+	    std::cout << "ERROR in PixelMap::Pixel_to_HVcrate: No pixel with ID = "
+		      << pixelID << " found in pixelmap" << std::endl;
+	}
+
+    }
+
+    return HVcrate;
+
+}
+
+unsigned int PixelMap::Pixel_to_HVboard(unsigned int pixelID, bool verbose) {
+
+    unsigned int HVboard = PM_ERROR_CODE;
+
+    for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
+
+	if( ((*iter).first) == pixelID ){
 	    HVboard = ((*iter).second)->GetPixelHVboard();
 	}
@@ -287,9 +382,9 @@
     }
 
-    if (HVboard == 999999999) {
-
-	if (verbose) {
-	    std::cout << "ERROR in PixelMap::Pixel_to_HVboard: No pixel with name = "
-		      << pixelname << " found in pixelmap" << std::endl;
+    if (HVboard == PM_ERROR_CODE) {
+
+	if (verbose) {
+	    std::cout << "ERROR in PixelMap::Pixel_to_HVboard: No pixel with ID = "
+		      << pixelID << " found in pixelmap" << std::endl;
 	}
 
@@ -300,36 +395,11 @@
 }
 
-unsigned int PixelMap::Pixel_to_HVchain(std::string pixelname, bool verbose) {
-
-    unsigned int HVchain = 999999999;
-
-    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
-
-	if( ((*iter).first) == pixelname ){
-	    HVchain = ((*iter).second)->GetPixelHVchain();
-	}
-
-    }
-
-    if (HVchain == 999999999) {
-
-	if (verbose) {
-	    std::cout << "ERROR in PixelMap::Pixel_to_HVchain: No pixel with name = "
-		      << pixelname << " found in pixelmap" << std::endl;
-	}
-
-    }
-
-    return HVchain;
-
-}
-
-unsigned int PixelMap::Pixel_to_HVchannel(std::string pixelname, bool verbose) {
-
-    unsigned int HVchannel = 999999999;
-
-    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
-
-	if( ((*iter).first) == pixelname ){
+unsigned int PixelMap::Pixel_to_HVchannel(unsigned int pixelID, bool verbose) {
+
+    unsigned int HVchannel = PM_ERROR_CODE;
+
+    for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
+
+	if( ((*iter).first) == pixelID ){
 	    HVchannel = ((*iter).second)->GetPixelHVchannel();
 	}
@@ -337,9 +407,9 @@
     }
 
-    if (HVchannel == 999999999) {
-
-	if (verbose) {
-	    std::cout << "ERROR in PixelMap::Pixel_to_HVchannel: No pixel with name = "
-		      << pixelname << " found in pixelmap" << std::endl;
+    if (HVchannel == PM_ERROR_CODE) {
+
+	if (verbose) {
+	    std::cout << "ERROR in PixelMap::Pixel_to_HVchannel: No pixel with ID = "
+		      << pixelID << " found in pixelmap" << std::endl;
 	}
 
@@ -349,2 +419,52 @@
 
 }
+
+int PixelMap::Pixel_to_POSx(unsigned int pixelID, bool verbose) {
+
+    int POSx = PM_ERROR_CODE;
+
+    for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
+
+	if( ((*iter).first) == pixelID ){
+	    POSx = ((*iter).second)->GetPixelPOSx();
+	}
+
+    }
+
+    if (POSx == (int)PM_ERROR_CODE) {
+
+	if (verbose) {
+	    std::cout << "ERROR in PixelMap::Pixel_to_POSx: No pixel with ID = "
+		      << pixelID << " found in pixelmap" << std::endl;
+	}
+
+   }
+
+    return POSx;
+
+}
+
+int PixelMap::Pixel_to_POSy(unsigned int pixelID, bool verbose) {
+
+    int POSy = PM_ERROR_CODE;
+
+    for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
+
+	if( ((*iter).first) == pixelID ){
+	    POSy = ((*iter).second)->GetPixelPOSy();
+	}
+
+    }
+
+    if (POSy == (int)PM_ERROR_CODE) {
+
+	if (verbose) {
+	    std::cout << "ERROR in PixelMap::Pixel_to_POSy: No pixel with ID = "
+		      << pixelID << " found in pixelmap" << std::endl;
+	}
+
+   }
+
+    return POSy;
+
+}
Index: fact/pixelmap/PixelMap.h
===================================================================
--- fact/pixelmap/PixelMap.h	(revision 10114)
+++ fact/pixelmap/PixelMap.h	(revision 10116)
@@ -3,7 +3,7 @@
 
 #include "Pixel.h"
+#include <vector>
 #include <map>
 #include <string>
-#include <map>
 
 class PixelMap {
@@ -13,22 +13,29 @@
 public:
     
-    PixelMap(std::string file, bool verbose=false);
+    static const unsigned int PM_ERROR_CODE = 999999999;
+    
+    PixelMap(std::string data, bool verbose=false);
     ~PixelMap();
     
-    std::map<std::string, Pixel*> pixelmap;
+    std::map<unsigned int, Pixel*> pixelmap;
 
-    void ReadPixelMap(std::map<std::string, Pixel*>& pixelmap, std::string file, bool verbose=false);
+    void ReadPixelMap(std::map<unsigned int, Pixel*>& pixelmap, std::string data, bool verbose=false);
     void Print();
 
-    std::string DRS_to_Pixel(unsigned int DRSboard, unsigned int DRSchip, unsigned int DRSchannel, bool verbose=false);
-    std::string HV_to_Pixel(unsigned int HVboard, unsigned int HVchain, unsigned int HVchannel, bool verbose=false);
+    unsigned int FPA_to_Pixel(unsigned int FPAcrate, unsigned int FPAboard, unsigned int FPApatch, unsigned int FPApixel, bool verbose=false);
+    std::vector<unsigned int> HV_to_Pixel(unsigned int HVcrate, unsigned int HVboard, unsigned int HVchannel, bool verbose=false);
+    unsigned int POS_to_Pixel(int POSx, int POSy, bool verbose=false);
     
-    unsigned int Pixel_to_DRSboard(std::string pixelname, bool verbose=false);
-    unsigned int Pixel_to_DRSchip(std::string pixelname, bool verbose=false);
-    unsigned int Pixel_to_DRSchannel(std::string pixelname, bool verbose=false);
+    unsigned int Pixel_to_FPAcrate(unsigned int PixelID, bool verbose=false);
+    unsigned int Pixel_to_FPAboard(unsigned int PixelID, bool verbose=false);
+    unsigned int Pixel_to_FPApatch(unsigned int PixelID, bool verbose=false);
+    unsigned int Pixel_to_FPApixel(unsigned int PixelID, bool verbose=false);
 
-    unsigned int Pixel_to_HVboard(std::string pixelname, bool verbose=false);
-    unsigned int Pixel_to_HVchain(std::string pixelname, bool verbose=false);
-    unsigned int Pixel_to_HVchannel(std::string pixelname, bool verbose=false);
+    unsigned int Pixel_to_HVcrate(unsigned int PixelID, bool verbose=false);
+    unsigned int Pixel_to_HVboard(unsigned int PixelID, bool verbose=false);
+    unsigned int Pixel_to_HVchannel(unsigned int PixelID, bool verbose=false);
+
+    int Pixel_to_POSx(unsigned int PixelID, bool verbose=false);
+    int Pixel_to_POSy(unsigned int PixelID, bool verbose=false);
 
 };
Index: fact/tools/pixelmap_test/PixelMapTest.cc
===================================================================
--- fact/tools/pixelmap_test/PixelMapTest.cc	(revision 10114)
+++ fact/tools/pixelmap_test/PixelMapTest.cc	(revision 10116)
@@ -1,53 +1,75 @@
 //simple test program to check the PixelMap class
+//Q. Weitzel, ETH Zurich, December 14, 2010
 
 #include "../../pixelmap/PixelMap.h"
 #include <iostream>
 
+using namespace std;
+
 int main(){
 
-    std::cout << std::endl;
-    std::cout << "==============================" << std::endl;
-    std::cout << "PixelMap Test Program" << std::endl;
-    std::cout << "==============================" << std::endl;
-    std::cout << std::endl;
+    cout << endl;
+    cout << "==============================" << endl;
+    cout << "PixelMap Test Program" << endl;
+    cout << "==============================" << endl;
+    cout << endl;
 
-    PixelMap* pm = new PixelMap("Test_PixelMap.txt", true);
+    cout << "Return value when asking for a non-existing pixel: " << PixelMap::PM_ERROR_CODE << endl;
+    cout << endl;
 
+    //PixelMap* pm = new PixelMap("", true);
+    PixelMap* pm = new PixelMap("0:   0 0 0 0   0 2 0   0 0;   1:   0 0 0 1   0 0 1   -1 -1;   237:   0 0 0 2   0 0 1   0 -1;", true);
+    
     pm->Print();
 
-    std::string drs1 = pm->DRS_to_Pixel(0,0,0,true);
-    std::cout << "Name: " << drs1 << std::endl;
+    unsigned int fpa;
+    fpa = pm->FPA_to_Pixel(0,0,0,0,true);
+    cout << "PixelID: " << fpa << endl;
+    fpa = pm->FPA_to_Pixel(0,1,0,0,true);
+    cout << "PixelID: " << fpa << endl;
+    fpa = pm->FPA_to_Pixel(0,0,0,0,true);
+    cout << "PixelID: " << fpa << endl;
 
-    std::string drs2 = pm->DRS_to_Pixel(1,0,0,true);
-    std::cout << "Name: " << drs2 << std::endl;
+    vector<unsigned int> hv;
+    hv = pm->HV_to_Pixel(6,1,8,true);
+    cout << hv.size() << " PixelIDs found: ";
+    for (unsigned int i=0; i < hv.size(); i++){cout << hv[i] << " ";}
+    cout << endl;
+    hv = pm->HV_to_Pixel(6,9,1,true);
+    cout << hv.size() << " PixelIDs found: ";
+    for (unsigned int i=0; i < hv.size(); i++){cout << hv[i] << " ";}
+    cout << endl;
+    hv = pm->HV_to_Pixel(0,0,1,true);
+    cout << hv.size() << " PixelIDs found: ";
+    for (unsigned int i=0; i < hv.size(); i++){cout << hv[i] << " ";}
+    cout << endl;
+    hv = pm->HV_to_Pixel(0,0,1,true);
+    cout << hv.size() << " PixelIDs found: ";
+    for (unsigned int i=0; i < hv.size(); i++){cout << hv[i] << " ";}
+    cout << endl;
 
-    std::string drs3 = pm->DRS_to_Pixel(0,0,0,true);
-    std::cout << "Name: " << drs3 << std::endl;
+    unsigned int pos;
+    pos = pm->POS_to_Pixel(-1,-1,true);
+    cout << "PixelID: " << pos << endl;
+    pos = pm->POS_to_Pixel(-10,1,true);
+    cout << "PixelID: " << pos << endl;
 
-    std::string hv1 = pm->HV_to_Pixel(6,1,8,true);
-    std::cout << "Name: " << hv1 << std::endl;
+    unsigned int fpab;
+    fpab = pm->Pixel_to_FPAboard(0,true);
+    cout << "Board: " << fpab << endl;
+    fpab = pm->Pixel_to_FPAboard(5,true);
+    cout << "Board: " << fpab << endl;
 
-    std::string hv2 = pm->HV_to_Pixel(6,9,1,true);
-    std::cout << "Name: " << hv2 << std::endl;
+    unsigned int hvboard;
+    hvboard = pm->Pixel_to_HVboard(0,true);
+    cout << "Board: " << hvboard << endl;
+    hvboard = pm->Pixel_to_HVboard(5,true);
+    cout << "Board: " << hvboard << endl;
 
-    std::string hv3 = pm->HV_to_Pixel(1,0,0,true);
-    std::cout << "Name: " << hv3 << std::endl;
-
-    unsigned int drsb1 = pm->Pixel_to_DRSboard("0-1-1",true);
-    std::cout << "Board: " << drsb1 << std::endl;
-
-    unsigned int drsb2 = pm->Pixel_to_DRSboard("1-0-0",true);
-    std::cout << "Board: " << drsb2 << std::endl;
-
-    pm->Print();
-
-    std::string drs4 = pm->DRS_to_Pixel(0,0,1,true);
-    std::cout << "Name: " << drs4 << std::endl;
-
-    unsigned int hvchain1 = pm->Pixel_to_HVchain("0-1-1",true);
-    std::cout << "Chain: " << hvchain1 << std::endl;
-
-    unsigned int hvchain2 = pm->Pixel_to_HVchain("1-0-0",true);
-    std::cout << "Chain: " << hvchain2 << std::endl;
+    int posy;
+    posy = pm->Pixel_to_POSy(1,true);
+    cout << "POSy: " << posy << endl;
+    posy = pm->Pixel_to_POSy(15,true);
+    cout << "POSy: " << posy << endl;
 
     delete pm;
Index: fact/tools/pixelmap_test/Test_PixelMap.txt
===================================================================
--- fact/tools/pixelmap_test/Test_PixelMap.txt	(revision 10114)
+++ fact/tools/pixelmap_test/Test_PixelMap.txt	(revision 10116)
@@ -25,11 +25,11 @@
 # pixel numbering: module-superpixel-pixel
 #
-######################################################################
+#######################################################################
 
 
-#Pixel:  DRS-board DRS-chip DRS-channel   HV board HV-chain HV-channel
-#---------------------------------------------------------------------
+#Pixel:  DRS-board DRS-chip DRS-channel    HV-crate HV-board HV-channel
+#----------------------------------------------------------------------
 0-1-1:		0	0	0		0	2	0
 0-1-2:		0	0	1		0	0	1
 10-2-3:		7	8	6		6 	9	1 	
-#---------------------------------------------------------------------
+#----------------------------------------------------------------------
