Changeset 10116 for fact/pixelmap
- Timestamp:
- 01/24/11 12:04:23 (14 years ago)
- Location:
- fact/pixelmap
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/pixelmap/Pixel.cc
r16 r10116 1 #include "Pixel Map.h"1 #include "Pixel.h" 2 2 #include <iostream> 3 3 4 Pixel::Pixel() : _DRSboard(999999999), _DRSchip(999999999), _DRSchannel(999999999), 5 _HVboard(999999999), _HVchain(999999999), _HVchannel(999999999) { } 4 Pixel::Pixel() : _FPAcrate(0), _FPAboard(0), _FPApatch(0), _FPApixel(0), 5 _HVcrate(0), _HVboard(0), _HVchannel(0), 6 _POSx(0), _POSy(0) { 6 7 7 Pixel::Pixel(unsigned int DRSboard, unsigned int DRSchip, unsigned int DRSchannel, 8 unsigned int HVboard, unsigned int HVchain, unsigned int HVchannel) 9 : _DRSboard(DRSboard), _DRSchip(DRSchip), _DRSchannel(DRSchannel), 10 _HVboard(HVboard), _HVchain(HVchain), _HVchannel(HVchannel) { 8 } 11 9 12 //???check here whether values make sense and eventually give error messages??? 10 Pixel::Pixel(unsigned int FPAcrate, unsigned int FPAboard, unsigned int FPApatch, unsigned int FPApixel, 11 unsigned int HVcrate, unsigned int HVboard, unsigned int HVchannel, 12 int POSx, int POSy) 13 : _FPAcrate(FPAcrate), _FPAboard(FPAboard), _FPApatch(FPApatch), _FPApixel(FPApixel), 14 _HVcrate(HVcrate), _HVboard(HVboard), _HVchannel(HVchannel), 15 _POSx(POSx), _POSy(POSy) { 13 16 14 17 } … … 16 19 std::ostream& operator << (std::ostream& s, const Pixel& pixel) { 17 20 18 return s << "DRSboard="<<pixel._DRSboard<<"\n" 19 << "DRSchip="<<pixel._DRSchip<<"\n" 20 << "DRSchannel="<<pixel._DRSchannel<<"\n" 21 return s << "FPAcrate="<<pixel._FPAcrate<<"\n" 22 << "FPAboard="<<pixel._FPAboard<<"\n" 23 << "FPApatch="<<pixel._FPApatch<<"\n" 24 << "FPApixel="<<pixel._FPApixel<<"\n" 25 << "HVcrate="<<pixel._HVcrate<<"\n" 21 26 << "HVboard="<<pixel._HVboard<<"\n" 22 << "HVchain="<<pixel._HVchain<<"\n" 23 << "HVchannel="<<pixel._HVchannel<<"\n"; 27 << "HVchannel="<<pixel._HVchannel<<"\n" 28 << "POSx="<<pixel._POSx<<"\n" 29 << "POSy="<<pixel._POSy<<"\n"; 24 30 25 31 } -
fact/pixelmap/Pixel.h
r9 r10116 8 8 private: 9 9 10 unsigned int _DRSboard; 11 unsigned int _DRSchip; 12 unsigned int _DRSchannel; 10 unsigned int _FPAcrate; 11 unsigned int _FPAboard; 12 unsigned int _FPApatch; 13 unsigned int _FPApixel; 13 14 15 unsigned int _HVcrate; 14 16 unsigned int _HVboard; 15 unsigned int _HVchain;16 17 unsigned int _HVchannel; 18 19 int _POSx; 20 int _POSy; 17 21 18 22 public: 19 23 20 24 Pixel(); 21 Pixel(unsigned int DRSboard, unsigned int DRSchip, unsigned int DRSchannel, 22 unsigned int HVboard, unsigned int HVchain, unsigned int HVchannel); 25 Pixel(unsigned int FPAcrate, unsigned int FPAboard, unsigned int FPApatch, unsigned int FPApixel, 26 unsigned int HVcrate, unsigned int HVboard, unsigned int HVchannel, 27 int POSx, int POSy); 23 28 24 29 ~Pixel() { } 25 30 26 //void SetPixelDRSboard(unsigned int DRSboard); 27 //void SetPixelDRSchip(unsigned int DRSchip); 28 //void SetPixelDRSchannel(unsigned int DRSchannel); 31 unsigned int GetPixelFPAcrate() const {return _FPAcrate;} 32 unsigned int GetPixelFPAboard() const {return _FPAboard;} 33 unsigned int GetPixelFPApatch() const {return _FPApatch;} 34 unsigned int GetPixelFPApixel() const {return _FPApixel;} 29 35 30 //void SetPixelHVboard(unsigned int HVboard);31 //void SetPixelHVchain(unsigned int HVchain);32 //void SetPixelHVchannel(unsigned int HVchannel);36 unsigned int GetPixelHVcrate() const {return _HVcrate;} 37 unsigned int GetPixelHVboard() const {return _HVboard;} 38 unsigned int GetPixelHVchannel() const {return _HVchannel;} 33 39 34 unsigned int GetPixelDRSboard() const {return _DRSboard;} 35 unsigned int GetPixelDRSchip() const {return _DRSchip;} 36 unsigned int GetPixelDRSchannel() const {return _DRSchannel;} 37 38 unsigned int GetPixelHVboard() const {return _HVboard;} 39 unsigned int GetPixelHVchain() const {return _HVchain;} 40 unsigned int GetPixelHVchannel() const {return _HVchannel;} 40 int GetPixelPOSx() const {return _POSx;} 41 int GetPixelPOSy() const {return _POSy;} 41 42 42 43 friend std::ostream& operator << (std::ostream& s, const Pixel& pixel); -
fact/pixelmap/PixelMap.cc
r18 r10116 6 6 #include <cctype> 7 7 8 PixelMap::PixelMap(std::string file, bool verbose) { 8 const unsigned int PixelMap::PM_ERROR_CODE; 9 10 PixelMap::PixelMap(std::string data, bool verbose) { 9 11 10 12 pixelmap.clear(); 11 ReadPixelMap(pixelmap, file, verbose);13 ReadPixelMap(pixelmap, data, verbose); 12 14 13 15 } … … 15 17 PixelMap::~PixelMap() { 16 18 17 for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {19 for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 18 20 delete ((*iter).second); 19 21 } … … 21 23 } 22 24 23 void PixelMap::ReadPixelMap(std::map<std::string, Pixel*>& pixelmap, std::string file, bool verbose) { 24 25 //std::string filename("PixelMap.txt"); 26 std::ifstream infile(file.c_str(), std::fstream::in); 25 void PixelMap::ReadPixelMap(std::map<unsigned int, Pixel*>& pixelmap, std::string data, bool verbose) { 27 26 28 27 if (verbose) { 29 std::cout<<"Reading mapping file: "<<file<<std::endl<<std::endl; 30 if (!infile.good()) { 31 std::cerr<<"ERROR in PixelMap::ReadPixelMap: File "<<file<<" cannot be found."<<std::endl; 32 } 33 } 34 35 while (infile.good()) { 28 std::cout<<"Creating pixelmap table"<<std::endl; 29 if (strlen(data.c_str()) == 0) { 30 std::cerr<<"WARNING in PixelMap::ReadPixelMap: input table is empty"<<std::endl; 31 } 32 } 33 34 std::string::size_type Next, EndNext = 0; 35 36 while (EndNext != std::string::npos) { 36 37 37 char line[1024]; 38 39 infile.getline(line, 1024); 40 41 if (line[0] == '#') { 42 if (verbose) { 43 std::cout << "Ignoring comment: " << line << std::endl; 38 Next = data.find_first_not_of(";", EndNext); 39 EndNext = data.find_first_of(";", Next); 40 41 // Stop if end of string reached 42 if (Next == std::string::npos) break; 43 44 std::string tokens = data.substr(Next, EndNext - Next); 45 46 if (tokens.find(":") != std::string::npos) { 47 48 char* ctokens = new char[tokens.size()+1]; 49 strcpy (ctokens, tokens.c_str()); 50 51 char delim[] = ":"; 52 char *name = NULL; //unformated name before : tokens 53 char name2[256] = ""; //formated name without whitespaces 54 char *rest = NULL; 55 56 name = strtok(ctokens, delim); 57 58 unsigned int count1 = 0; //count non-whitespace characters in name 59 60 for (unsigned int i = 0; i < strlen(name); i++) { 61 62 if ( !(isspace(name[i])) ) { 63 name2[count1] = name[i]; 64 count1+=1; 65 } 66 44 67 } 45 } 46 47 else { 48 49 if (strlen(line)!=0) {68 69 if( (count1 > 0) && (count1 < 5) ) { 70 71 unsigned int pixelID = (unsigned int)atoi(name2); 72 std::map<const unsigned int, Pixel*>::iterator found = pixelmap.find(pixelID); 50 73 51 char delim[] = ":"; 52 char *name = NULL; //unformated name before : tokens 53 char name2[256] = ""; //formated name without whitespaces 54 char *rest = NULL; 55 56 name = strtok(line, delim); 57 58 unsigned int count1 = 0; //count non-whitespace characters in name 59 unsigned int count2 = 0; //count number of - in name 60 61 for (unsigned int i = 0; i < strlen(name); i++) { 62 63 if ( !(isspace(name[i])) ) { 64 65 name2[count1] = name[i]; 66 count1+=1; 67 68 if ( (name[i] == 45) ) { 69 count2+=1; 70 } 71 72 } 73 74 } 75 76 //if (verbose) { 77 // std::cout << "Formated pixel name: " << name2 << std::endl; 78 //} 79 80 if( (count1 > 4) && (count1 < 7) && (count2 == 2) ) { 74 if( found == pixelmap.end() ) {//pixelID already existing? 81 75 82 76 rest = strtok(NULL, delim); … … 84 78 if(rest != NULL) { 85 79 86 unsigned int DRSboard = (unsigned int)strtod(rest, &rest); 87 unsigned int DRSchip = (unsigned int)strtod(rest, &rest); 88 unsigned int DRSchannel = (unsigned int)strtod(rest, &rest); 80 unsigned int FPAcrate = (unsigned int)strtod(rest, &rest); 81 unsigned int FPAboard = (unsigned int)strtod(rest, &rest); 82 unsigned int FPApatch = (unsigned int)strtod(rest, &rest); 83 unsigned int FPApixel = (unsigned int)strtod(rest, &rest); 84 unsigned int HVcrate = (unsigned int)strtod(rest, &rest); 89 85 unsigned int HVboard = (unsigned int)strtod(rest, &rest); 90 unsigned int HVchain = (unsigned int)strtod(rest, &rest);91 86 unsigned int HVchannel = (unsigned int)strtod(rest, &rest); 92 93 pixelmap[name2] = new Pixel(DRSboard, DRSchip, DRSchannel, 94 HVboard, HVchain, HVchannel); 95 87 int POSx = (int)strtod(rest, &rest); 88 int POSy = (int)strtod(rest, &rest); 89 90 pixelmap[pixelID] = new Pixel(FPAcrate, FPAboard, FPApatch, FPApixel, 91 HVcrate, HVboard, HVchannel, 92 POSx, POSy); 96 93 } 97 94 95 else { 96 97 pixelmap[pixelID] = new Pixel(); 98 99 } 100 98 101 } 99 102 … … 101 104 102 105 if (verbose) { 103 std::cout << "ERROR in PixelMap::ReadPixelMap: Wrong pixel name: " << name2 << " -> pixel not initialized" << std::endl;106 std::cout << "ERROR in PixelMap::ReadPixelMap: pixel ID already existing: " << pixelID << " -> pixel not initialized again" << std::endl; 104 107 } 105 108 106 109 } 107 110 108 } 111 } 109 112 110 113 else { 111 114 112 if (verbose){113 std::cout << " Skipping empty line" << std::endl;115 if (verbose) { 116 std::cout << "ERROR in PixelMap::ReadPixelMap: wrong pixel ID: " << name2 << " -> pixel not initialized" << std::endl; 114 117 } 115 118 116 119 } 117 120 118 } 119 121 delete[] ctokens; 122 123 } 124 125 else { 126 127 if(verbose){ 128 std::cout << "ERROR in PixelMap::ReadPixelMap: entry without pixel ID: " << tokens << " -> pixel not initialized" << std::endl; 129 } 130 131 } 132 120 133 } 121 134 … … 123 136 std::cout << std::endl << pixelmap.size() << " pixels found" << std::endl << std::endl; 124 137 } 125 126 infile.close();127 138 128 139 } … … 132 143 std::cout << "Printing entries of pixelmap:" << std::endl << std::endl; 133 144 134 for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) {145 for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 135 146 std::cout << (*iter).first << std::endl << "------------" << std::endl << *((*iter).second) << std::endl; 136 147 } … … 138 149 } 139 150 140 std::string PixelMap::DRS_to_Pixel(unsigned int DRSboard, unsigned int DRSchip, unsigned int DRSchannel, bool verbose) { 141 142 std::string pixelname = ""; 143 144 for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 145 146 if( ( ((*iter).second)->GetPixelDRSboard() == DRSboard ) && 147 ( ((*iter).second)->GetPixelDRSchip() == DRSchip ) && 148 ( ((*iter).second)->GetPixelDRSchannel() == DRSchannel ) ) { 149 150 pixelname = (*iter).first; 151 152 } 153 154 } 155 156 if(pixelname == ""){ 151 unsigned int PixelMap::FPA_to_Pixel(unsigned int FPAcrate, unsigned int FPAboard, unsigned int FPApatch, unsigned int FPApixel, bool verbose) { 152 153 unsigned int pixelID = PM_ERROR_CODE; 154 155 for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 156 157 if( ( ((*iter).second)->GetPixelFPAcrate() == FPAcrate ) && 158 ( ((*iter).second)->GetPixelFPAboard() == FPAboard ) && 159 ( ((*iter).second)->GetPixelFPApatch() == FPApatch ) && 160 ( ((*iter).second)->GetPixelFPApixel() == FPApixel ) ) { 161 162 pixelID = (*iter).first; 163 164 } 165 166 } 167 168 if(pixelID == PM_ERROR_CODE){ 157 169 158 170 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; 171 std::cout << "ERROR in PixelMap::FPA_to_Pixel: No pixel with FPA crate, board, patch, pixel = " 172 << FPAcrate << ", " 173 << FPAboard << ", " 174 << FPApatch << ", " 175 << FPApixel << " found in pixelmap" << std::endl; 163 176 } 164 177 165 178 } 166 179 167 return pixelname; 168 169 } 170 171 std::string PixelMap::HV_to_Pixel(unsigned int HVboard, unsigned int HVchain, unsigned int HVchannel, bool verbose) { 172 173 std::string pixelname = ""; 174 175 for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 176 177 if( ( ((*iter).second)->GetPixelHVboard() == HVboard ) && 178 ( ((*iter).second)->GetPixelHVchain() == HVchain ) && 180 return pixelID; 181 182 } 183 184 std::vector<unsigned int> PixelMap::HV_to_Pixel(unsigned int HVcrate, unsigned int HVboard, unsigned int HVchannel, bool verbose) { 185 186 unsigned int last_pixelID = PM_ERROR_CODE; 187 188 std::vector<unsigned int> PixelIDs; 189 190 for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 191 192 if( ( ((*iter).second)->GetPixelHVcrate() == HVcrate ) && 193 ( ((*iter).second)->GetPixelHVboard() == HVboard ) && 179 194 ( ((*iter).second)->GetPixelHVchannel() == HVchannel ) ) { 180 195 181 pixelname = (*iter).first; 182 183 } 184 185 } 186 187 if(pixelname == ""){ 188 189 if (verbose) { 190 std::cout << "ERROR in PixelMap::HV_to_Pixel: No pixel with HV board, chain, channel = " 196 last_pixelID = (*iter).first; 197 PixelIDs.push_back(last_pixelID); 198 199 } 200 201 } 202 203 if(last_pixelID == PM_ERROR_CODE){ 204 205 if (verbose) { 206 std::cout << "ERROR in PixelMap::HV_to_Pixel: No pixel with HV crate, board, channel = " 207 << HVcrate << ", " 191 208 << HVboard << ", " 192 << HVchain << ", "193 209 << HVchannel << " found in pixelmap" << std::endl; 194 210 } … … 196 212 } 197 213 198 return pixelname; 199 200 } 201 202 unsigned int PixelMap::Pixel_to_DRSboard(std::string pixelname, bool verbose) { 203 204 unsigned int DRSboard = 999999999; 205 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 } 220 221 } 222 223 return DRSboard; 224 225 } 226 227 unsigned int PixelMap::Pixel_to_DRSchip(std::string pixelname, bool verbose) { 228 229 unsigned int DRSchip = 999999999; 230 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 } 245 246 } 247 248 return DRSchip; 249 250 } 251 252 unsigned int PixelMap::Pixel_to_DRSchannel(std::string pixelname, bool verbose) { 253 254 unsigned int DRSchannel = 999999999; 255 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(); 214 return PixelIDs; 215 216 } 217 218 unsigned int PixelMap::POS_to_Pixel(int POSx, int POSy, bool verbose) { 219 220 unsigned int pixelID = PM_ERROR_CODE; 221 222 for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 223 224 if( ( ((*iter).second)->GetPixelPOSx() == POSx ) && 225 ( ((*iter).second)->GetPixelPOSy() == POSy ) ) { 226 227 pixelID = (*iter).first; 228 229 } 230 231 } 232 233 if(pixelID == PM_ERROR_CODE){ 234 235 if (verbose) { 236 std::cout << "ERROR in PixelMap::POS_to_Pixel: No pixel with position x, y = " 237 << POSx << ", " 238 << POSy << " found in pixelmap" << std::endl; 239 } 240 241 } 242 243 return pixelID; 244 245 } 246 247 unsigned int PixelMap::Pixel_to_FPAcrate(unsigned int pixelID, bool verbose) { 248 249 unsigned int FPAcrate = PM_ERROR_CODE; 250 251 for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 252 253 if( ((*iter).first) == pixelID ){ 254 FPAcrate = ((*iter).second)->GetPixelFPAcrate(); 255 } 256 257 } 258 259 if (FPAcrate == PM_ERROR_CODE) { 260 261 if (verbose) { 262 std::cout << "ERROR in PixelMap::Pixel_to_FPAcrate: No pixel with ID = " 263 << pixelID << " found in pixelmap" << std::endl; 264 } 265 266 } 267 268 return FPAcrate; 269 270 } 271 272 unsigned int PixelMap::Pixel_to_FPAboard(unsigned int pixelID, bool verbose) { 273 274 unsigned int FPAboard = PM_ERROR_CODE; 275 276 for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 277 278 if( ((*iter).first) == pixelID ){ 279 FPAboard = ((*iter).second)->GetPixelFPAboard(); 280 } 281 282 } 283 284 if (FPAboard == PM_ERROR_CODE) { 285 286 if (verbose) { 287 std::cout << "ERROR in PixelMap::Pixel_to_FPAboard: No pixel with ID = " 288 << pixelID << " found in pixelmap" << std::endl; 289 } 290 291 } 292 293 return FPAboard; 294 295 } 296 297 unsigned int PixelMap::Pixel_to_FPApatch(unsigned int pixelID, bool verbose) { 298 299 unsigned int FPApatch = PM_ERROR_CODE; 300 301 for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 302 303 if( ((*iter).first) == pixelID ){ 304 FPApatch = ((*iter).second)->GetPixelFPApatch(); 305 } 306 307 } 308 309 if (FPApatch == PM_ERROR_CODE) { 310 311 if (verbose) { 312 std::cout << "ERROR in PixelMap::Pixel_to_FPApatch: No pixel with ID = " 313 << pixelID << " found in pixelmap" << std::endl; 314 } 315 316 } 317 318 return FPApatch; 319 320 } 321 322 unsigned int PixelMap::Pixel_to_FPApixel(unsigned int pixelID, bool verbose) { 323 324 unsigned int FPApixel = PM_ERROR_CODE; 325 326 for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 327 328 if( ((*iter).first) == pixelID ){ 329 FPApixel = ((*iter).second)->GetPixelFPApixel(); 260 330 } 261 331 262 332 } 263 333 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 } 270 271 } 272 273 return DRSchannel; 274 275 } 276 277 unsigned int PixelMap::Pixel_to_HVboard(std::string pixelname, bool verbose) { 278 279 unsigned int HVboard = 999999999; 280 281 for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 282 283 if( ((*iter).first) == pixelname ){ 334 if (FPApixel == PM_ERROR_CODE) { 335 336 if (verbose) { 337 std::cout << "ERROR in PixelMap::Pixel_to_FPApixel: No pixel with ID = " 338 << pixelID << " found in pixelmap" << std::endl; 339 } 340 341 } 342 343 return FPApixel; 344 345 } 346 347 unsigned int PixelMap::Pixel_to_HVcrate(unsigned int pixelID, bool verbose) { 348 349 unsigned int HVcrate = PM_ERROR_CODE; 350 351 for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 352 353 if( ((*iter).first) == pixelID ){ 354 HVcrate = ((*iter).second)->GetPixelHVcrate(); 355 } 356 357 } 358 359 if (HVcrate == PM_ERROR_CODE) { 360 361 if (verbose) { 362 std::cout << "ERROR in PixelMap::Pixel_to_HVcrate: No pixel with ID = " 363 << pixelID << " found in pixelmap" << std::endl; 364 } 365 366 } 367 368 return HVcrate; 369 370 } 371 372 unsigned int PixelMap::Pixel_to_HVboard(unsigned int pixelID, bool verbose) { 373 374 unsigned int HVboard = PM_ERROR_CODE; 375 376 for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 377 378 if( ((*iter).first) == pixelID ){ 284 379 HVboard = ((*iter).second)->GetPixelHVboard(); 285 380 } … … 287 382 } 288 383 289 if (HVboard == 999999999) {290 291 if (verbose) { 292 std::cout << "ERROR in PixelMap::Pixel_to_HVboard: No pixel with name= "293 << pixel name<< " found in pixelmap" << std::endl;384 if (HVboard == PM_ERROR_CODE) { 385 386 if (verbose) { 387 std::cout << "ERROR in PixelMap::Pixel_to_HVboard: No pixel with ID = " 388 << pixelID << " found in pixelmap" << std::endl; 294 389 } 295 390 … … 300 395 } 301 396 302 unsigned int PixelMap::Pixel_to_HVchain(std::string pixelname, bool verbose) { 303 304 unsigned int HVchain = 999999999; 305 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 } 320 321 } 322 323 return HVchain; 324 325 } 326 327 unsigned int PixelMap::Pixel_to_HVchannel(std::string pixelname, bool verbose) { 328 329 unsigned int HVchannel = 999999999; 330 331 for( std::map<const std::string, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 332 333 if( ((*iter).first) == pixelname ){ 397 unsigned int PixelMap::Pixel_to_HVchannel(unsigned int pixelID, bool verbose) { 398 399 unsigned int HVchannel = PM_ERROR_CODE; 400 401 for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 402 403 if( ((*iter).first) == pixelID ){ 334 404 HVchannel = ((*iter).second)->GetPixelHVchannel(); 335 405 } … … 337 407 } 338 408 339 if (HVchannel == 999999999) {340 341 if (verbose) { 342 std::cout << "ERROR in PixelMap::Pixel_to_HVchannel: No pixel with name= "343 << pixel name<< " found in pixelmap" << std::endl;409 if (HVchannel == PM_ERROR_CODE) { 410 411 if (verbose) { 412 std::cout << "ERROR in PixelMap::Pixel_to_HVchannel: No pixel with ID = " 413 << pixelID << " found in pixelmap" << std::endl; 344 414 } 345 415 … … 349 419 350 420 } 421 422 int PixelMap::Pixel_to_POSx(unsigned int pixelID, bool verbose) { 423 424 int POSx = PM_ERROR_CODE; 425 426 for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 427 428 if( ((*iter).first) == pixelID ){ 429 POSx = ((*iter).second)->GetPixelPOSx(); 430 } 431 432 } 433 434 if (POSx == (int)PM_ERROR_CODE) { 435 436 if (verbose) { 437 std::cout << "ERROR in PixelMap::Pixel_to_POSx: No pixel with ID = " 438 << pixelID << " found in pixelmap" << std::endl; 439 } 440 441 } 442 443 return POSx; 444 445 } 446 447 int PixelMap::Pixel_to_POSy(unsigned int pixelID, bool verbose) { 448 449 int POSy = PM_ERROR_CODE; 450 451 for( std::map<const unsigned int, Pixel*>::iterator iter = pixelmap.begin(); iter != pixelmap.end(); ++iter ) { 452 453 if( ((*iter).first) == pixelID ){ 454 POSy = ((*iter).second)->GetPixelPOSy(); 455 } 456 457 } 458 459 if (POSy == (int)PM_ERROR_CODE) { 460 461 if (verbose) { 462 std::cout << "ERROR in PixelMap::Pixel_to_POSy: No pixel with ID = " 463 << pixelID << " found in pixelmap" << std::endl; 464 } 465 466 } 467 468 return POSy; 469 470 } -
fact/pixelmap/PixelMap.h
r18 r10116 3 3 4 4 #include "Pixel.h" 5 #include <vector> 5 6 #include <map> 6 7 #include <string> 7 #include <map>8 8 9 9 class PixelMap { … … 13 13 public: 14 14 15 PixelMap(std::string file, bool verbose=false); 15 static const unsigned int PM_ERROR_CODE = 999999999; 16 17 PixelMap(std::string data, bool verbose=false); 16 18 ~PixelMap(); 17 19 18 std::map< std::string, Pixel*> pixelmap;20 std::map<unsigned int, Pixel*> pixelmap; 19 21 20 void ReadPixelMap(std::map< std::string, Pixel*>& pixelmap, std::string file, bool verbose=false);22 void ReadPixelMap(std::map<unsigned int, Pixel*>& pixelmap, std::string data, bool verbose=false); 21 23 void Print(); 22 24 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); 25 unsigned int FPA_to_Pixel(unsigned int FPAcrate, unsigned int FPAboard, unsigned int FPApatch, unsigned int FPApixel, bool verbose=false); 26 std::vector<unsigned int> HV_to_Pixel(unsigned int HVcrate, unsigned int HVboard, unsigned int HVchannel, bool verbose=false); 27 unsigned int POS_to_Pixel(int POSx, int POSy, bool verbose=false); 25 28 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); 29 unsigned int Pixel_to_FPAcrate(unsigned int PixelID, bool verbose=false); 30 unsigned int Pixel_to_FPAboard(unsigned int PixelID, bool verbose=false); 31 unsigned int Pixel_to_FPApatch(unsigned int PixelID, bool verbose=false); 32 unsigned int Pixel_to_FPApixel(unsigned int PixelID, bool verbose=false); 29 33 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); 34 unsigned int Pixel_to_HVcrate(unsigned int PixelID, bool verbose=false); 35 unsigned int Pixel_to_HVboard(unsigned int PixelID, bool verbose=false); 36 unsigned int Pixel_to_HVchannel(unsigned int PixelID, bool verbose=false); 37 38 int Pixel_to_POSx(unsigned int PixelID, bool verbose=false); 39 int Pixel_to_POSy(unsigned int PixelID, bool verbose=false); 33 40 34 41 };
Note:
See TracChangeset
for help on using the changeset viewer.