Index: fact/pixelmap/Pixel.cc
===================================================================
--- fact/pixelmap/Pixel.cc	(revision 9838)
+++ fact/pixelmap/Pixel.cc	(revision 9838)
@@ -0,0 +1,25 @@
+#include "PixelMap.h"
+#include <iostream>
+
+Pixel::Pixel() : _DRSboard(999999999), _DRSchip(999999999), _DRSchannel(999999999),
+		 _HVboard(999999999), _HVchain(999999999), _HVchannel(999999999) { }
+
+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???
+
+}
+
+std::ostream& operator << (std::ostream& s, const Pixel& pixel) {
+  
+    return s << "DRSboard="<<pixel._DRSboard<<"\n"
+	     << "DRSchip="<<pixel._DRSchip<<"\n"
+	     << "DRSchannel="<<pixel._DRSchannel<<"\n"
+	     << "HVboard="<<pixel._HVboard<<"\n"
+	     << "HVchain="<<pixel._HVchain<<"\n"
+	     << "HVchannel="<<pixel._HVchannel<<"\n";
+
+}
Index: fact/pixelmap/Pixel.h
===================================================================
--- fact/pixelmap/Pixel.h	(revision 9838)
+++ fact/pixelmap/Pixel.h	(revision 9838)
@@ -0,0 +1,46 @@
+#ifndef PIXEL_H
+#define PIXEL_H
+
+#include <ostream>
+
+class Pixel {
+
+private:
+
+    unsigned int _DRSboard;
+    unsigned int _DRSchip;
+    unsigned int _DRSchannel;
+
+    unsigned int _HVboard;
+    unsigned int _HVchain;
+    unsigned int _HVchannel;
+
+public:
+    
+    Pixel();
+    Pixel(unsigned int DRSboard, unsigned int DRSchip, unsigned int DRSchannel,
+	  unsigned int HVboard, unsigned int HVchain, unsigned int HVchannel);
+
+    ~Pixel() { }
+
+    //void SetPixelDRSboard(unsigned int DRSboard);
+    //void SetPixelDRSchip(unsigned int DRSchip);
+    //void SetPixelDRSchannel(unsigned int DRSchannel);
+
+    //void SetPixelHVboard(unsigned int HVboard);
+    //void SetPixelHVchain(unsigned int HVchain);
+    //void SetPixelHVchannel(unsigned int 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;}
+
+    friend std::ostream& operator << (std::ostream& s, const Pixel& pixel);
+
+};
+
+#endif
Index: fact/pixelmap/PixelMap.cc
===================================================================
--- fact/pixelmap/PixelMap.cc	(revision 9838)
+++ fact/pixelmap/PixelMap.cc	(revision 9838)
@@ -0,0 +1,350 @@
+#include "PixelMap.h"
+#include <iostream>
+#include <fstream>
+#include <cstring>
+#include <cstdlib>
+#include <cctype>
+
+PixelMap::PixelMap(std::string file, bool verbose) {
+
+    pixelmap.clear();
+    ReadPixelMap(pixelmap, file, verbose);
+
+}
+
+PixelMap::~PixelMap() {
+
+    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
+	delete ((*iter).second);
+    }
+
+}
+
+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);
+
+    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()) {
+	
+	char line[1024];
+
+	infile.getline(line, 1024);
+
+	if (line[0] == '#') {
+	    if (verbose) {
+		std::cout << "Ignoring comment: " << line << std::endl;
+	    }
+	}
+
+	else {
+	    
+	    if (strlen(line)!=0) {
+		
+		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) ) {
+
+		    rest = strtok(NULL, delim);
+		
+		    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 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);
+
+		    }
+
+		}
+
+		else {
+
+		    if (verbose) {
+			std::cout << "ERROR in PixelMap::ReadPixelMap: Wrong pixel name: " << name2 << " -> pixel not initialized" << std::endl;
+		    }
+
+		}
+
+	    } 
+
+	    else {
+
+		if(verbose){
+		    std::cout << "Skipping empty line" << std::endl;
+		}
+
+	    }
+
+	}
+	
+    }
+
+    if (verbose) {
+	std::cout << std::endl << pixelmap.size() << " pixels found" << std::endl << std::endl;
+    }
+
+    infile.close();
+								
+}
+
+void PixelMap::Print() {
+
+    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 ) {
+	std::cout << (*iter).first << std::endl << "------------" << std::endl << *((*iter).second) << std::endl;
+    }
+    
+}
+
+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 == ""){
+	
+	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;
+	}	
+
+    }
+
+    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 ) &&
+	    ( ((*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 = "
+		      << HVboard << ", "
+		      << HVchain << ", "
+		      << HVchannel << " found in pixelmap" << std::endl;
+	}	
+
+    }
+
+    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();
+	}
+
+    }
+    
+    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 ){
+	    HVboard = ((*iter).second)->GetPixelHVboard();
+	}
+
+    }
+
+    if (HVboard == 999999999) {
+
+	if (verbose) {
+	    std::cout << "ERROR in PixelMap::Pixel_to_HVboard: No pixel with name = "
+		      << pixelname << " found in pixelmap" << std::endl;
+	}
+
+    }
+
+    return HVboard;
+
+}
+
+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 ){
+	    HVchannel = ((*iter).second)->GetPixelHVchannel();
+	}
+
+    }
+
+    if (HVchannel == 999999999) {
+
+	if (verbose) {
+	    std::cout << "ERROR in PixelMap::Pixel_to_HVchannel: No pixel with name = "
+		      << pixelname << " found in pixelmap" << std::endl;
+	}
+
+   }
+
+    return HVchannel;
+
+}
Index: fact/pixelmap/PixelMap.h
===================================================================
--- fact/pixelmap/PixelMap.h	(revision 9838)
+++ fact/pixelmap/PixelMap.h	(revision 9838)
@@ -0,0 +1,36 @@
+#ifndef PIXELMAP_H
+#define PIXELMAP_H
+
+#include "Pixel.h"
+#include <map>
+#include <string>
+#include <map>
+
+class PixelMap {
+
+private:    
+
+public:
+    
+    PixelMap(std::string file, bool verbose=false);
+    ~PixelMap();
+    
+    std::map<std::string, Pixel*> pixelmap;
+
+    void ReadPixelMap(std::map<std::string, Pixel*>& pixelmap, std::string file, 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 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_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);
+
+};
+
+#endif
