Index: /pixelmap/Pixel.cc
===================================================================
--- /pixelmap/Pixel.cc	(revision 9)
+++ /pixelmap/Pixel.cc	(revision 9)
@@ -0,0 +1,25 @@
+#include "PixelMap.h"
+#include <iostream>
+
+Pixel::Pixel() : _DRSboard(-1), _DRSchip(-1), _DRSchannel(-1),
+		 _HVboard(-1), _HVchain(-1), _HVchannel(-1) { }
+
+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: /pixelmap/Pixel.h
===================================================================
--- /pixelmap/Pixel.h	(revision 9)
+++ /pixelmap/Pixel.h	(revision 9)
@@ -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: /pixelmap/PixelMap.cc
===================================================================
--- /pixelmap/PixelMap.cc	(revision 9)
+++ /pixelmap/PixelMap.cc	(revision 9)
@@ -0,0 +1,291 @@
+#include "PixelMap.h"
+#include <iostream>
+#include <fstream>
+#include <cstring>
+#include <cstdlib>
+
+PixelMap::PixelMap() {
+
+    pixelmap.clear();
+    ReadPixelMap(pixelmap, false);
+
+}
+
+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, bool verbose) {
+
+    std::string filename("PixelMap.txt");
+    std::ifstream infile(filename.c_str(), std::fstream::in);
+
+    std::cout<<"Reading mapping file: "<<filename<<std::endl<<std::endl;
+
+    if (!infile.good()){
+	std::cerr<<"ERROR in PixelMap::ReadPixelMap: File "<<filename<<" cannot be found."<<std::endl;
+    }
+
+    while (infile.good()) {
+	
+	char line[256];
+
+	infile.getline(line, 256);
+
+	if(line[0] == '#') {
+	    if(verbose) {
+		std::cout << "Ignoring comment: " << line << std::endl;
+	    }
+	}
+
+	else {
+	    
+	    if(strlen(line)!=0){
+		
+		char delim[] = ":";
+		char *name = NULL;
+		char *rest = NULL;
+		
+		name = strtok(line, delim);
+
+		if(strlen(name) > 4){
+
+		    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[name] = new Pixel(DRSboard, DRSchip, DRSchannel,
+						   HVboard, HVchain, HVchannel);
+
+		    }
+
+		}
+
+		else {
+
+		    std::cout << "ERROR in PixelMap::ReadPixelMap: Wrong pixel name: " << name << "-> pixel not initialized" << std::endl;
+
+		}
+
+	    }
+
+	}
+	
+    }
+
+    if(verbose){
+	for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
+	    std::cout << std::endl << (*iter).first << std::endl << "-----------" << std::endl << *((*iter).second);
+	}
+    }
+
+    std::cout << 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) {
+
+    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 == ""){
+
+	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) {
+
+    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 == ""){
+
+	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) {
+
+    unsigned int DRSboard = 999999999;
+
+    if(pixelmap[pixelname] != NULL) {
+
+	DRSboard = pixelmap[pixelname]->GetPixelDRSboard();
+
+    }
+
+    else {
+
+	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) {
+
+    unsigned int DRSchip = 999999999;
+
+    if(pixelmap[pixelname] != NULL) {
+
+	DRSchip = pixelmap[pixelname]->GetPixelDRSchip();
+
+    }
+
+    else {
+
+	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) {
+
+    unsigned int DRSchannel = 999999999;
+
+    if(pixelmap[pixelname] != NULL) {
+
+	DRSchannel = pixelmap[pixelname]->GetPixelDRSchannel();
+
+    }
+
+    else {
+
+	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) {
+
+    unsigned int HVboard = 999999999;
+
+    if(pixelmap[pixelname] != NULL) {
+
+	HVboard = pixelmap[pixelname]->GetPixelHVboard();
+
+    }
+
+    else {
+
+	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) {
+
+    unsigned int HVchain = 999999999;
+
+    if(pixelmap[pixelname] != NULL) {
+
+	HVchain = pixelmap[pixelname]->GetPixelHVchain();
+
+    }
+
+    else {
+
+	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) {
+
+    unsigned int HVchannel = 999999999;
+
+    if(pixelmap[pixelname] != NULL) {
+
+	HVchannel = pixelmap[pixelname]->GetPixelHVchannel();
+
+    }
+
+    else {
+
+	std::cout << "ERROR in PixelMap::Pixel_to_HVchannel: No pixel with name = "
+		  << pixelname << " found in pixelmap" << std::endl;
+
+    }
+
+    return HVchannel;
+
+}
Index: /pixelmap/PixelMap.h
===================================================================
--- /pixelmap/PixelMap.h	(revision 9)
+++ /pixelmap/PixelMap.h	(revision 9)
@@ -0,0 +1,36 @@
+#ifndef PIXELMAP_H
+#define PIXELMAP_H
+
+#include "Pixel.h"
+#include <map>
+#include <string>
+#include <map>
+
+class PixelMap {
+
+private:    
+
+public:
+    
+    PixelMap();
+    ~PixelMap();
+    
+    std::map<std::string, Pixel*> pixelmap;
+
+    void ReadPixelMap(std::map<std::string, Pixel*>& pixelmap, bool verbose=false);
+    void Print();
+
+    std::string DRS_to_Pixel(unsigned int DRSboard, unsigned int DRSchip, unsigned int DRSchannel);
+    std::string HV_to_Pixel(unsigned int HVboard, unsigned int HVchain, unsigned int HVchannel);
+    
+    unsigned int Pixel_to_DRSboard(std::string pixelname);
+    unsigned int Pixel_to_DRSchip(std::string pixelname);
+    unsigned int Pixel_to_DRSchannel(std::string pixelname);
+
+    unsigned int Pixel_to_HVboard(std::string pixelname);
+    unsigned int Pixel_to_HVchain(std::string pixelname);
+    unsigned int Pixel_to_HVchannel(std::string pixelname);
+
+};
+
+#endif
