Changeset 16 for pixelmap


Ignore:
Timestamp:
03/23/09 15:38:22 (16 years ago)
Author:
qweitzel
Message:
bug fixed in pixelmap, verbose mode added
Location:
pixelmap
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pixelmap/Pixel.cc

    r12 r16  
    1010      _HVboard(HVboard), _HVchain(HVchain), _HVchannel(HVchannel) {
    1111
    12     //check here whether values make sense and eventually give error messages
     12    //???check here whether values make sense and eventually give error messages???
    1313
    1414}
  • pixelmap/PixelMap.cc

    r12 r16  
    66#include <cctype>
    77
    8 PixelMap::PixelMap() {
     8PixelMap::PixelMap(bool verbose) {
    99
    1010    pixelmap.clear();
    11     ReadPixelMap(pixelmap, false);
     11    ReadPixelMap(pixelmap, verbose);
    1212
    1313}
     
    2626    std::ifstream infile(filename.c_str(), std::fstream::in);
    2727
    28     std::cout<<"Reading mapping file: "<<filename<<std::endl<<std::endl;
    29 
    30     if (!infile.good()) {
    31         std::cerr<<"ERROR in PixelMap::ReadPixelMap: File "<<filename<<" cannot be found."<<std::endl;
     28    if (verbose) {
     29        std::cout<<"Reading mapping file: "<<filename<<std::endl<<std::endl;   
     30        if (!infile.good()) {
     31            std::cerr<<"ERROR in PixelMap::ReadPixelMap: File "<<filename<<" cannot be found."<<std::endl;
     32        }
    3233    }
    3334
     
    7374                }
    7475
    75                 if (verbose) {
    76                     std::cout << "Formated pixel name: " << name2 << std::endl;
    77                 }
     76                //if (verbose) {
     77                //  std::cout << "Formated pixel name: " << name2 << std::endl;
     78                //}
    7879
    7980                if( (count1 > 4) && (count1 < 7) && (count2 == 2) ) {
     
    99100                else {
    100101
    101                     std::cout << "ERROR in PixelMap::ReadPixelMap: Wrong pixel name: " << name2 << " -> pixel not initialized" << std::endl;
     102                    if (verbose) {
     103                        std::cout << "ERROR in PixelMap::ReadPixelMap: Wrong pixel name: " << name2 << " -> pixel not initialized" << std::endl;
     104                    }
    102105
    103106                }
     
    108111
    109112                if(verbose){
    110 
    111113                    std::cout << "Skipping empty line" << std::endl;
    112 
    113114                }
    114115
     
    119120    }
    120121
    121     if(verbose){
    122         for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
    123             std::cout << std::endl << (*iter).first << std::endl << "-----------" << std::endl << *((*iter).second);
    124         }
    125     }
    126 
    127     std::cout << pixelmap.size() << " pixels found" << std::endl << std::endl;
     122    if (verbose) {
     123        std::cout << std::endl << pixelmap.size() << " pixels found" << std::endl << std::endl;
     124    }
    128125
    129126    infile.close();
     
    141138}
    142139
    143 std::string PixelMap::DRS_to_Pixel(unsigned int DRSboard, unsigned int DRSchip, unsigned int DRSchannel) {
     140std::string PixelMap::DRS_to_Pixel(unsigned int DRSboard, unsigned int DRSchip, unsigned int DRSchannel, bool verbose) {
    144141
    145142    std::string pixelname = "";
     
    158155
    159156    if(pixelname == ""){
    160 
    161         std::cout << "ERROR in PixelMap::DRS_to_Pixel: No pixel with DRS board, chip, channel = "
    162                   << DRSboard << ", "
    163                   << DRSchip << ", "
    164                   << DRSchannel << " found in pixelmap" << std::endl;
    165157       
     158        if (verbose) {
     159            std::cout << "ERROR in PixelMap::DRS_to_Pixel: No pixel with DRS board, chip, channel = "
     160                      << DRSboard << ", "
     161                      << DRSchip << ", "
     162                      << DRSchannel << " found in pixelmap" << std::endl;
     163        }       
     164
    166165    }
    167166
     
    170169}
    171170
    172 std::string PixelMap::HV_to_Pixel(unsigned int HVboard, unsigned int HVchain, unsigned int HVchannel) {
     171std::string PixelMap::HV_to_Pixel(unsigned int HVboard, unsigned int HVchain, unsigned int HVchannel, bool verbose) {
    173172
    174173    std::string pixelname = "";
     
    188187    if(pixelname == ""){
    189188
    190         std::cout << "ERROR in PixelMap::HV_to_Pixel: No pixel with HV board, chain, channel = "
    191                   << HVboard << ", "
    192                   << HVchain << ", "
    193                   << HVchannel << " found in pixelmap" << std::endl;
    194        
     189        if (verbose) {
     190            std::cout << "ERROR in PixelMap::HV_to_Pixel: No pixel with HV board, chain, channel = "
     191                      << HVboard << ", "
     192                      << HVchain << ", "
     193                      << HVchannel << " found in pixelmap" << std::endl;
     194        }       
     195
    195196    }
    196197
     
    199200}
    200201
    201 unsigned int PixelMap::Pixel_to_DRSboard(std::string pixelname) {
     202unsigned int PixelMap::Pixel_to_DRSboard(std::string pixelname, bool verbose) {
    202203
    203204    unsigned int DRSboard = 999999999;
    204205
    205     if(pixelmap[pixelname] != NULL) {
    206 
    207         DRSboard = pixelmap[pixelname]->GetPixelDRSboard();
    208 
    209     }
    210 
    211     else {
    212 
    213         std::cout << "ERROR in PixelMap::Pixel_to_DRSboard: No pixel with name = "
    214                   << pixelname << " found in pixelmap" << std::endl;
     206    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
     207
     208        if( ((*iter).first) == pixelname ){
     209            DRSboard = ((*iter).second)->GetPixelDRSboard();
     210        }
     211
     212    }
     213
     214    if (DRSboard == 999999999) {
     215
     216        if (verbose) {
     217            std::cout << "ERROR in PixelMap::Pixel_to_DRSboard: No pixel with name = "
     218                      << pixelname << " found in pixelmap" << std::endl;
     219        }
    215220
    216221    }
     
    220225}
    221226
    222 unsigned int PixelMap::Pixel_to_DRSchip(std::string pixelname) {
     227unsigned int PixelMap::Pixel_to_DRSchip(std::string pixelname, bool verbose) {
    223228
    224229    unsigned int DRSchip = 999999999;
    225230
    226     if(pixelmap[pixelname] != NULL) {
    227 
    228         DRSchip = pixelmap[pixelname]->GetPixelDRSchip();
    229 
    230     }
    231 
    232     else {
    233 
    234         std::cout << "ERROR in PixelMap::Pixel_to_DRSchip: No pixel with name = "
    235                   << pixelname << " found in pixelmap" << std::endl;
     231    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
     232
     233        if( ((*iter).first) == pixelname ){
     234            DRSchip = ((*iter).second)->GetPixelDRSchip();
     235        }
     236
     237    }
     238
     239    if (DRSchip == 999999999) {
     240
     241        if (verbose) {
     242            std::cout << "ERROR in PixelMap::Pixel_to_DRSchip: No pixel with name = "
     243                      << pixelname << " found in pixelmap" << std::endl;
     244        }
    236245
    237246    }
     
    241250}
    242251
    243 unsigned int PixelMap::Pixel_to_DRSchannel(std::string pixelname) {
     252unsigned int PixelMap::Pixel_to_DRSchannel(std::string pixelname, bool verbose) {
    244253
    245254    unsigned int DRSchannel = 999999999;
    246255
    247     if(pixelmap[pixelname] != NULL) {
    248 
    249         DRSchannel = pixelmap[pixelname]->GetPixelDRSchannel();
    250 
    251     }
    252 
    253     else {
    254 
    255         std::cout << "ERROR in PixelMap::Pixel_to_DRSchannel: No pixel with name = "
    256                   << pixelname << " found in pixelmap" << std::endl;
     256    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
     257
     258        if( ((*iter).first) == pixelname ){
     259            DRSchannel = ((*iter).second)->GetPixelDRSchannel();
     260        }
     261
     262    }
     263   
     264    if (DRSchannel == 999999999) {
     265
     266        if (verbose) {
     267            std::cout << "ERROR in PixelMap::Pixel_to_DRSchannel: No pixel with name = "
     268                      << pixelname << " found in pixelmap" << std::endl;
     269        }
    257270
    258271    }
     
    262275}
    263276
    264 unsigned int PixelMap::Pixel_to_HVboard(std::string pixelname) {
     277unsigned int PixelMap::Pixel_to_HVboard(std::string pixelname, bool verbose) {
    265278
    266279    unsigned int HVboard = 999999999;
    267280
    268     if(pixelmap[pixelname] != NULL) {
    269 
    270         HVboard = pixelmap[pixelname]->GetPixelHVboard();
    271 
    272     }
    273 
    274     else {
    275 
    276         std::cout << "ERROR in PixelMap::Pixel_to_HVboard: No pixel with name = "
    277                   << pixelname << " found in pixelmap" << std::endl;
     281    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
     282
     283        if( ((*iter).first) == pixelname ){
     284            HVboard = ((*iter).second)->GetPixelHVboard();
     285        }
     286
     287    }
     288
     289    if (HVboard == 999999999) {
     290
     291        if (verbose) {
     292            std::cout << "ERROR in PixelMap::Pixel_to_HVboard: No pixel with name = "
     293                      << pixelname << " found in pixelmap" << std::endl;
     294        }
    278295
    279296    }
     
    283300}
    284301
    285 unsigned int PixelMap::Pixel_to_HVchain(std::string pixelname) {
     302unsigned int PixelMap::Pixel_to_HVchain(std::string pixelname, bool verbose) {
    286303
    287304    unsigned int HVchain = 999999999;
    288305
    289     if(pixelmap[pixelname] != NULL) {
    290 
    291         HVchain = pixelmap[pixelname]->GetPixelHVchain();
    292 
    293     }
    294 
    295     else {
    296 
    297         std::cout << "ERROR in PixelMap::Pixel_to_HVchain: No pixel with name = "
    298                   << pixelname << " found in pixelmap" << std::endl;
     306    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
     307
     308        if( ((*iter).first) == pixelname ){
     309            HVchain = ((*iter).second)->GetPixelHVchain();
     310        }
     311
     312    }
     313
     314    if (HVchain == 999999999) {
     315
     316        if (verbose) {
     317            std::cout << "ERROR in PixelMap::Pixel_to_HVchain: No pixel with name = "
     318                      << pixelname << " found in pixelmap" << std::endl;
     319        }
    299320
    300321    }
     
    304325}
    305326
    306 unsigned int PixelMap::Pixel_to_HVchannel(std::string pixelname) {
     327unsigned int PixelMap::Pixel_to_HVchannel(std::string pixelname, bool verbose) {
    307328
    308329    unsigned int HVchannel = 999999999;
    309330
    310     if(pixelmap[pixelname] != NULL) {
    311 
    312         HVchannel = pixelmap[pixelname]->GetPixelHVchannel();
    313 
    314     }
    315 
    316     else {
    317 
    318         std::cout << "ERROR in PixelMap::Pixel_to_HVchannel: No pixel with name = "
    319                   << pixelname << " found in pixelmap" << std::endl;
    320 
    321     }
     331    for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {
     332
     333        if( ((*iter).first) == pixelname ){
     334            HVchannel = ((*iter).second)->GetPixelHVchannel();
     335        }
     336
     337    }
     338
     339    if (HVchannel == 999999999) {
     340
     341        if (verbose) {
     342            std::cout << "ERROR in PixelMap::Pixel_to_HVchannel: No pixel with name = "
     343                      << pixelname << " found in pixelmap" << std::endl;
     344        }
     345
     346   }
    322347
    323348    return HVchannel;
  • pixelmap/PixelMap.h

    r9 r16  
    1313public:
    1414   
    15     PixelMap();
     15    PixelMap(bool verbose=false);
    1616    ~PixelMap();
    1717   
     
    2121    void Print();
    2222
    23     std::string DRS_to_Pixel(unsigned int DRSboard, unsigned int DRSchip, unsigned int DRSchannel);
    24     std::string HV_to_Pixel(unsigned int HVboard, unsigned int HVchain, unsigned int HVchannel);
     23    std::string DRS_to_Pixel(unsigned int DRSboard, unsigned int DRSchip, unsigned int DRSchannel, bool verbose=false);
     24    std::string HV_to_Pixel(unsigned int HVboard, unsigned int HVchain, unsigned int HVchannel, bool verbose=false);
    2525   
    26     unsigned int Pixel_to_DRSboard(std::string pixelname);
    27     unsigned int Pixel_to_DRSchip(std::string pixelname);
    28     unsigned int Pixel_to_DRSchannel(std::string pixelname);
     26    unsigned int Pixel_to_DRSboard(std::string pixelname, bool verbose=false);
     27    unsigned int Pixel_to_DRSchip(std::string pixelname, bool verbose=false);
     28    unsigned int Pixel_to_DRSchannel(std::string pixelname, bool verbose=false);
    2929
    30     unsigned int Pixel_to_HVboard(std::string pixelname);
    31     unsigned int Pixel_to_HVchain(std::string pixelname);
    32     unsigned int Pixel_to_HVchannel(std::string pixelname);
     30    unsigned int Pixel_to_HVboard(std::string pixelname, bool verbose=false);
     31    unsigned int Pixel_to_HVchain(std::string pixelname, bool verbose=false);
     32    unsigned int Pixel_to_HVchannel(std::string pixelname, bool verbose=false);
    3333
    3434};
Note: See TracChangeset for help on using the changeset viewer.