Changeset 12


Ignore:
Timestamp:
03/10/09 10:34:17 (16 years ago)
Author:
qweitzel
Message:
update of pixelmap class, whitespaces now ignored in pixelname, initialization of default pixel constructor changed
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pixelmap/Pixel.cc

    r9 r12  
    22#include <iostream>
    33
    4 Pixel::Pixel() : _DRSboard(-1), _DRSchip(-1), _DRSchannel(-1),
    5                  _HVboard(-1), _HVchain(-1), _HVchannel(-1) { }
     4Pixel::Pixel() : _DRSboard(999999999), _DRSchip(999999999), _DRSchannel(999999999),
     5                 _HVboard(999999999), _HVchain(999999999), _HVchannel(999999999) { }
    66
    77Pixel::Pixel(unsigned int DRSboard, unsigned int DRSchip, unsigned int DRSchannel,
  • pixelmap/PixelMap.cc

    r9 r12  
    44#include <cstring>
    55#include <cstdlib>
     6#include <cctype>
    67
    78PixelMap::PixelMap() {
     
    2728    std::cout<<"Reading mapping file: "<<filename<<std::endl<<std::endl;
    2829
    29     if (!infile.good()){
     30    if (!infile.good()) {
    3031        std::cerr<<"ERROR in PixelMap::ReadPixelMap: File "<<filename<<" cannot be found."<<std::endl;
    3132    }
     
    3334    while (infile.good()) {
    3435       
    35         char line[256];
    36 
    37         infile.getline(line, 256);
    38 
    39         if(line[0] == '#') {
    40             if(verbose) {
     36        char line[1024];
     37
     38        infile.getline(line, 1024);
     39
     40        if (line[0] == '#') {
     41            if (verbose) {
    4142                std::cout << "Ignoring comment: " << line << std::endl;
    4243            }
     
    4546        else {
    4647           
    47             if(strlen(line)!=0){
     48            if (strlen(line)!=0) {
    4849               
    4950                char delim[] = ":";
    50                 char *name = NULL;
     51                char *name = NULL; //unformated name before : tokens
     52                char name2[256] = ""; //formated name without whitespaces
    5153                char *rest = NULL;
    5254               
    5355                name = strtok(line, delim);
    5456
    55                 if(strlen(name) > 4){
     57                unsigned int count1 = 0; //count non-whitespace characters in name
     58                unsigned int count2 = 0; //count number of - in name
     59
     60                for (unsigned int i = 0; i < strlen(name); i++) {
     61
     62                    if ( !(isspace(name[i])) ) {
     63
     64                        name2[count1] = name[i];
     65                        count1+=1;
     66
     67                        if ( (name[i] == 45) ) {
     68                            count2+=1;
     69                        }
     70
     71                    }
     72
     73                }
     74
     75                if (verbose) {
     76                    std::cout << "Formated pixel name: " << name2 << std::endl;
     77                }
     78
     79                if( (count1 > 4) && (count1 < 7) && (count2 == 2) ) {
    5680
    5781                    rest = strtok(NULL, delim);
     
    6690                        unsigned int HVchannel = (unsigned int)strtod(rest, &rest);
    6791
    68                         pixelmap[name] = new Pixel(DRSboard, DRSchip, DRSchannel,
    69                                                    HVboard, HVchain, HVchannel);
     92                        pixelmap[name2] = new Pixel(DRSboard, DRSchip, DRSchannel,
     93                                                    HVboard, HVchain, HVchannel);
    7094
    7195                    }
     
    7599                else {
    76100
    77                     std::cout << "ERROR in PixelMap::ReadPixelMap: Wrong pixel name: " << name << "-> pixel not initialized" << std::endl;
     101                    std::cout << "ERROR in PixelMap::ReadPixelMap: Wrong pixel name: " << name2 << " -> pixel not initialized" << std::endl;
     102
     103                }
     104
     105            }
     106
     107            else {
     108
     109                if(verbose){
     110
     111                    std::cout << "Skipping empty line" << std::endl;
    78112
    79113                }
  • tools/pixelmap_test/PixelMap.txt

    r10 r12  
    99# to be edited if DRS or HV channels change
    1010#
    11 # !!! do NOT edit the pixel name (x-x-x) !!!
     11# Format for pixel names is (x-x-x), to be followed by : delimiter
    1212#
    1313# gAPD arrangement within pixel is NOT defined here
     
    1515# =====================================================================
    1616#
    17 # allowed field separators: space, tab, comma in arbitrary combination
     17# allowed field separators: space and tab in arbitrary combination
    1818#
    1919# empty lines allowed
    2020#
    21 # lines starting with # considered as comment
     21# lines _starting_ with # considered as comment (first character!)
    2222#
    2323# =====================================================================
Note: See TracChangeset for help on using the changeset viewer.