Changeset 12507 for trunk/FACT++/src/PixelMap.h
- Timestamp:
- 11/13/11 18:06:05 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/PixelMap.h
r12407 r12507 20 20 int cbpx; /// Hardware index as CBPX 21 21 int gapd; /// gAPD index 22 float Vgapd; /// gAPD Bias voltage22 // float Vgapd; /// gAPD Bias voltage 23 23 int hv_board; /// Bias suppply board 24 24 int hv_channel; /// Bias supply channel … … 62 62 std::stringstream str(buf); 63 63 64 int idummy; 64 int idummy; 65 float fdummy; 65 66 66 67 PixelMapEntry entry; … … 71 72 str >> idummy; 72 73 str >> entry.gapd; 73 str >> entry.Vgapd;74 str >> fdummy; //entry.Vgapd; 74 75 str >> entry.hv_board; 75 76 str >> entry.hv_channel; … … 140 141 } 141 142 143 /* 142 144 float Vgapd(int board, int channel) const 143 145 { … … 180 182 181 183 return avg; 182 } 183 }; 184 185 #endif 184 }*/ 185 }; 186 187 struct BiasMapEntry 188 { 189 int hv_board; /// Bias suppply board 190 int hv_channel; /// Bias supply channel 191 float Vnom; /// Channel bias voltage nominal 192 float Voff; /// Channel bias voltage offset 193 194 int hv() const { return hv_channel+hv_board*32; } 195 }; 196 197 class BiasMap : public std::vector<BiasMapEntry> 198 { 199 public: 200 static const BiasMapEntry empty; 201 202 BiasMap() : std::vector<BiasMapEntry>(416) 203 { 204 } 205 206 bool Read(const std::string &fname) 207 { 208 std::ifstream fin(fname); 209 210 int l = 0; 211 212 std::string buf; 213 while (getline(fin, buf, '\n')) 214 { 215 if (l>416) 216 break; 217 218 buf = Tools::Trim(buf); 219 if (buf[0]=='#') 220 continue; 221 222 std::stringstream str(buf); 223 224 BiasMapEntry entry; 225 226 str >> entry.hv_board; 227 str >> entry.hv_channel; 228 str >> entry.Vnom; 229 str >> entry.Voff; 230 231 if (entry.hv_channel+32*entry.hv_board>=416) 232 { 233 #ifdef DEBUG 234 cerr << "Invalid board/channel read from " << fname << "." << endl; 235 #endif 236 return false; 237 } 238 239 (*this)[l++] = entry; 240 } 241 242 return l==1440; 243 } 244 245 const BiasMapEntry &hv(int board, int channel) const 246 { 247 for (std::vector<BiasMapEntry>::const_iterator it=begin(); it!=end(); it++) 248 if (it->hv_board==board && it->hv_channel==channel) 249 return *it; 250 #ifdef DEBUG 251 std::cerr << "PixelMap: hv " << board << "/" << channel << " not found" << std::endl; 252 #endif 253 return empty; 254 } 255 256 const BiasMapEntry &hv(int idx) const 257 { 258 return hv(idx/32, idx%32); 259 } 260 261 float Vgapd(int board, int channel) const 262 { 263 const BiasMapEntry &entry = hv(board, channel); 264 return entry.Vnom+entry.Voff; 265 } 266 267 float Vgapd(int idx) const 268 { 269 return Vgapd(idx/32, idx%32); 270 } 271 272 std::vector<float> Vgapd() const 273 { 274 std::vector<float> volt(416); 275 276 for (std::vector<BiasMapEntry>::const_iterator it=begin(); it!=end(); it++) 277 { 278 const int ch = it->hv_board*32 + it->hv_channel; 279 volt[ch] += it->Vnom+it->Voff; 280 } 281 282 return volt; 283 } 284 }; 285 286 #endif
Note:
See TracChangeset
for help on using the changeset viewer.