| 1 | /* ======================================================================== *\ | 
|---|
| 2 | ! | 
|---|
| 3 | ! * | 
|---|
| 4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction | 
|---|
| 5 | ! * Software. It is distributed to you in the hope that it can be a useful | 
|---|
| 6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes. | 
|---|
| 7 | ! * It is distributed WITHOUT ANY WARRANTY. | 
|---|
| 8 | ! * | 
|---|
| 9 | ! * Permission to use, copy, modify and distribute this software and its | 
|---|
| 10 | ! * documentation for any purpose is hereby granted without fee, | 
|---|
| 11 | ! * provided that the above copyright notice appear in all copies and | 
|---|
| 12 | ! * that both that copyright notice and this permission notice appear | 
|---|
| 13 | ! * in supporting documentation. It is provided "as is" without express | 
|---|
| 14 | ! * or implied warranty. | 
|---|
| 15 | ! * | 
|---|
| 16 | ! | 
|---|
| 17 | ! | 
|---|
| 18 | !   Author(s): Thomas Bretz 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de> | 
|---|
| 19 | !              Markus Gaug  3/2004 <mailto:markus@ifae.es> | 
|---|
| 20 | ! | 
|---|
| 21 | !   Copyright: MAGIC Software Development, 2000-2004 | 
|---|
| 22 | ! | 
|---|
| 23 | ! | 
|---|
| 24 | \* ======================================================================== */ | 
|---|
| 25 |  | 
|---|
| 26 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 27 | // | 
|---|
| 28 | // MBadPixelsCam | 
|---|
| 29 | // | 
|---|
| 30 | // | 
|---|
| 31 | // Storage container to store bad pixel of the camera... | 
|---|
| 32 | // | 
|---|
| 33 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 34 | #include "MBadPixelsCam.h" | 
|---|
| 35 |  | 
|---|
| 36 | #include <iostream> | 
|---|
| 37 |  | 
|---|
| 38 | #include <TClonesArray.h> | 
|---|
| 39 |  | 
|---|
| 40 | #include "MLog.h" | 
|---|
| 41 | #include "MLogManip.h" | 
|---|
| 42 |  | 
|---|
| 43 | #include "MBadPixelsPix.h" | 
|---|
| 44 |  | 
|---|
| 45 | #include "MGeomCam.h" | 
|---|
| 46 | #include "MGeomPix.h" | 
|---|
| 47 |  | 
|---|
| 48 | ClassImp(MBadPixelsCam); | 
|---|
| 49 |  | 
|---|
| 50 | using namespace std; | 
|---|
| 51 |  | 
|---|
| 52 | // -------------------------------------------------------------------------- | 
|---|
| 53 | // | 
|---|
| 54 | // Default constructor. | 
|---|
| 55 | // | 
|---|
| 56 | MBadPixelsCam::MBadPixelsCam(const char *name, const char *title) | 
|---|
| 57 | { | 
|---|
| 58 | fName  = name  ? name  : "MBadPixelsCam"; | 
|---|
| 59 | fTitle = title ? title : "Storage container to store bad pixel information"; | 
|---|
| 60 |  | 
|---|
| 61 | fArray = new TClonesArray("MBadPixelsPix", 1); | 
|---|
| 62 | } | 
|---|
| 63 |  | 
|---|
| 64 | MBadPixelsCam::MBadPixelsCam(const MBadPixelsCam &cam) | 
|---|
| 65 | { | 
|---|
| 66 | fName  = "MBadPixelsCam"; | 
|---|
| 67 | fTitle = "Storage container to store bad pixel information"; | 
|---|
| 68 |  | 
|---|
| 69 | fArray = new TClonesArray("MBadPixelsPix", 1); | 
|---|
| 70 | cam.Copy(*this); | 
|---|
| 71 | } | 
|---|
| 72 |  | 
|---|
| 73 | // -------------------------------------------------------------------------- | 
|---|
| 74 | // | 
|---|
| 75 | // Delete the array conatining the bad pixel information | 
|---|
| 76 | // | 
|---|
| 77 | MBadPixelsCam::~MBadPixelsCam() | 
|---|
| 78 | { | 
|---|
| 79 | delete fArray; | 
|---|
| 80 | } | 
|---|
| 81 |  | 
|---|
| 82 | // -------------------------------------------------------------------------- | 
|---|
| 83 | // | 
|---|
| 84 | // Set the size of the camera | 
|---|
| 85 | // | 
|---|
| 86 | void MBadPixelsCam::InitSize(const UInt_t i) | 
|---|
| 87 | { | 
|---|
| 88 | fArray->ExpandCreate(i); | 
|---|
| 89 | } | 
|---|
| 90 |  | 
|---|
| 91 | // -------------------------------------------------------------------------- | 
|---|
| 92 | // | 
|---|
| 93 | // Get the size of the MBadPixelsCam | 
|---|
| 94 | // | 
|---|
| 95 | Int_t MBadPixelsCam::GetSize() const | 
|---|
| 96 | { | 
|---|
| 97 | return fArray->GetEntriesFast(); | 
|---|
| 98 | } | 
|---|
| 99 |  | 
|---|
| 100 | // -------------------------------------------------------------------------- | 
|---|
| 101 | // | 
|---|
| 102 | // Copy 'constructor' | 
|---|
| 103 | // | 
|---|
| 104 | void MBadPixelsCam::Copy(TObject &object) const | 
|---|
| 105 | { | 
|---|
| 106 | MBadPixelsCam &cam = (MBadPixelsCam&)object; | 
|---|
| 107 |  | 
|---|
| 108 | const Int_t n = GetSize(); | 
|---|
| 109 |  | 
|---|
| 110 | if (n==0) | 
|---|
| 111 | return; | 
|---|
| 112 |  | 
|---|
| 113 | cam.InitSize(n); | 
|---|
| 114 | for (int i=0; i<n; i++) | 
|---|
| 115 | (*this)[i].Copy(cam[i]); | 
|---|
| 116 | } | 
|---|
| 117 |  | 
|---|
| 118 | // -------------------------------------------------------------------------- | 
|---|
| 119 | // | 
|---|
| 120 | // Get i-th pixel (pixel number) | 
|---|
| 121 | // | 
|---|
| 122 | MBadPixelsPix &MBadPixelsCam::operator[](Int_t i) | 
|---|
| 123 | { | 
|---|
| 124 | return *static_cast<MBadPixelsPix*>(fArray->UncheckedAt(i)); | 
|---|
| 125 | } | 
|---|
| 126 |  | 
|---|
| 127 | // -------------------------------------------------------------------------- | 
|---|
| 128 | // | 
|---|
| 129 | // Get i-th pixel (pixel number) | 
|---|
| 130 | // | 
|---|
| 131 | const MBadPixelsPix &MBadPixelsCam::operator[](Int_t i) const | 
|---|
| 132 | { | 
|---|
| 133 | return *static_cast<MBadPixelsPix*>(fArray->UncheckedAt(i)); | 
|---|
| 134 | } | 
|---|
| 135 |  | 
|---|
| 136 | // -------------------------------------------------------------------------- | 
|---|
| 137 | // | 
|---|
| 138 | // Merge two MBadPixelsCam together, see also MBadPixelsPix::Merge | 
|---|
| 139 | // | 
|---|
| 140 | void MBadPixelsCam::Merge(const MBadPixelsCam &cam) | 
|---|
| 141 | { | 
|---|
| 142 | const Int_t n = cam.GetSize(); | 
|---|
| 143 | if (n==0) | 
|---|
| 144 | { | 
|---|
| 145 | *fLog << warn << "MBadPixelsCam::Merge: Container empty." << endl; | 
|---|
| 146 | return; | 
|---|
| 147 | } | 
|---|
| 148 |  | 
|---|
| 149 | if (GetSize()==0) | 
|---|
| 150 | InitSize(n); | 
|---|
| 151 |  | 
|---|
| 152 | if (n!=GetSize()) | 
|---|
| 153 | { | 
|---|
| 154 | *fLog << warn << "MBadPixelsCam::Merge: Size mismatch... ignored." << endl; | 
|---|
| 155 | return; | 
|---|
| 156 | } | 
|---|
| 157 |  | 
|---|
| 158 | for (int i=0; i<n; i++) | 
|---|
| 159 | (*this)[i].Merge(cam[i]); | 
|---|
| 160 | } | 
|---|
| 161 |  | 
|---|
| 162 | // -------------------------------------------------------------------------- | 
|---|
| 163 | // | 
|---|
| 164 | // Clear the contents of all bad pixels (set=0 means Ok) | 
|---|
| 165 | // | 
|---|
| 166 | void MBadPixelsCam::Clear(Option_t *o) | 
|---|
| 167 | { | 
|---|
| 168 | fArray->R__FOR_EACH(TObject, Clear)(); | 
|---|
| 169 | } | 
|---|
| 170 |  | 
|---|
| 171 | // -------------------------------------------------------------------------- | 
|---|
| 172 | // | 
|---|
| 173 | // Reset event depending bits | 
|---|
| 174 | // | 
|---|
| 175 | void MBadPixelsCam::Reset() | 
|---|
| 176 | { | 
|---|
| 177 | fArray->R__FOR_EACH(MParContainer, Reset)(); | 
|---|
| 178 | } | 
|---|
| 179 |  | 
|---|
| 180 | // -------------------------------------------------------------------------- | 
|---|
| 181 | // | 
|---|
| 182 | // Calculate the number of pixels without the given type-flags. | 
|---|
| 183 | // | 
|---|
| 184 | // The second argument aidx is the area index (see MGeomCam, MGeomPix) | 
|---|
| 185 | // The default (or any value less than 0) means: all | 
|---|
| 186 | // | 
|---|
| 187 | // Returns -1 if the geometry doesn't match. | 
|---|
| 188 | // | 
|---|
| 189 | Short_t MBadPixelsCam::GetNumSuitable(MBadPixelsPix::UnsuitableType_t type, const MGeomCam *geom, Int_t aidx) const | 
|---|
| 190 | { | 
|---|
| 191 | const UInt_t n = GetSize(); | 
|---|
| 192 |  | 
|---|
| 193 | if (aidx>=0 && (!geom || geom->GetNumPixels()!=n)) | 
|---|
| 194 | { | 
|---|
| 195 | *fLog << err << GetDescriptor() << "ERROR - Geometry (" << geom->ClassName() << ") size mismatch!" << endl; | 
|---|
| 196 | return -1; | 
|---|
| 197 | } | 
|---|
| 198 |  | 
|---|
| 199 | Short_t rc = 0; | 
|---|
| 200 | for (UInt_t i=0; i<n; i++) | 
|---|
| 201 | { | 
|---|
| 202 | if (aidx>=0 && geom && (*geom)[i].GetAidx()!=aidx) | 
|---|
| 203 | continue; | 
|---|
| 204 |  | 
|---|
| 205 | if (!(*this)[i].IsUnsuitable(type)) | 
|---|
| 206 | rc++; | 
|---|
| 207 | } | 
|---|
| 208 | return rc; | 
|---|
| 209 | } | 
|---|
| 210 |  | 
|---|
| 211 | // -------------------------------------------------------------------------- | 
|---|
| 212 | // | 
|---|
| 213 | // Calculate the number of pixels with the given type-flags. | 
|---|
| 214 | // | 
|---|
| 215 | // The second argument aidx is the area index (see MGeomCam, MGeomPix) | 
|---|
| 216 | // The default (or any value less than 0) means: all | 
|---|
| 217 | // | 
|---|
| 218 | // Returns -1 if the geometry doesn't match. | 
|---|
| 219 | // | 
|---|
| 220 | Short_t MBadPixelsCam::GetNumUnsuitable(MBadPixelsPix::UnsuitableType_t type, const MGeomCam *geom, Int_t aidx) const | 
|---|
| 221 | { | 
|---|
| 222 | const UInt_t n = GetSize(); | 
|---|
| 223 |  | 
|---|
| 224 | if (aidx>=0 && geom && geom->GetNumPixels()!=n) | 
|---|
| 225 | { | 
|---|
| 226 | *fLog << err << GetDescriptor() << "ERROR - Geometry (" << geom->ClassName() << ") size mismatch!" << endl; | 
|---|
| 227 | return -1; | 
|---|
| 228 | } | 
|---|
| 229 |  | 
|---|
| 230 | Short_t rc = 0; | 
|---|
| 231 | for (UInt_t i=0; i<n; i++) | 
|---|
| 232 | { | 
|---|
| 233 | if (aidx>=0 && geom && (*geom)[i].GetAidx()!=aidx) | 
|---|
| 234 | continue; | 
|---|
| 235 |  | 
|---|
| 236 | if ((*this)[i].IsUnsuitable(type)) | 
|---|
| 237 | rc++; | 
|---|
| 238 | } | 
|---|
| 239 | return rc; | 
|---|
| 240 | } | 
|---|
| 241 |  | 
|---|
| 242 | // -------------------------------------------------------------------------- | 
|---|
| 243 | // | 
|---|
| 244 | // Count the number of unsuitable pixels. | 
|---|
| 245 | // | 
|---|
| 246 | Short_t MBadPixelsCam::GetNumUnsuitable() const | 
|---|
| 247 | { | 
|---|
| 248 | const UInt_t n = GetSize(); | 
|---|
| 249 |  | 
|---|
| 250 | Short_t rc = 0; | 
|---|
| 251 | for (UInt_t i=0; i<n; i++) | 
|---|
| 252 | if ((*this)[i].IsUnsuitable()) | 
|---|
| 253 | rc++; | 
|---|
| 254 |  | 
|---|
| 255 | return rc; | 
|---|
| 256 | } | 
|---|
| 257 |  | 
|---|
| 258 | // -------------------------------------------------------------------------- | 
|---|
| 259 | // | 
|---|
| 260 | // Counts the number of neighbors matching NOT UnsuitableType type | 
|---|
| 261 | // | 
|---|
| 262 | Short_t MBadPixelsCam::GetNumSuitableNeighbors(MBadPixelsPix::UnsuitableType_t type, const MGeomPix &pix) const | 
|---|
| 263 | { | 
|---|
| 264 | const Int_t n2 = pix.GetNumNeighbors(); | 
|---|
| 265 |  | 
|---|
| 266 | Int_t cnt=0; | 
|---|
| 267 | for (int j=0; j<n2; j++) | 
|---|
| 268 | { | 
|---|
| 269 | const Int_t id2 = pix.GetNeighbor(j); | 
|---|
| 270 | if (!(*this)[id2].IsUnsuitable(type)) | 
|---|
| 271 | cnt++; | 
|---|
| 272 | } | 
|---|
| 273 |  | 
|---|
| 274 | return cnt; | 
|---|
| 275 | } | 
|---|
| 276 |  | 
|---|
| 277 | // -------------------------------------------------------------------------- | 
|---|
| 278 | // | 
|---|
| 279 | // Calculate the number of pixels which are - under no circumstances - | 
|---|
| 280 | // interpolatable, called isolated. This means that a pixel (its own status | 
|---|
| 281 | // doesn't matter) has less than two reliable neighbor pixels. | 
|---|
| 282 | // | 
|---|
| 283 | // The second argument aidx is the area index (see MGeomCam, MGeomPix) | 
|---|
| 284 | // The default (or any value less than 0) means: all | 
|---|
| 285 | // | 
|---|
| 286 | // Returns -1 if the geometry doesn't match. | 
|---|
| 287 | // | 
|---|
| 288 | Short_t MBadPixelsCam::GetNumIsolated(MBadPixelsPix::UnsuitableType_t type, const MGeomCam &geom, Int_t aidx) const | 
|---|
| 289 | { | 
|---|
| 290 | const Int_t n = geom.GetNumPixels(); | 
|---|
| 291 |  | 
|---|
| 292 | if (n!=GetSize()) | 
|---|
| 293 | { | 
|---|
| 294 | *fLog << err << GetDescriptor() << "ERROR - Geometry (" << geom.ClassName() << ") size mismatch!" << endl; | 
|---|
| 295 | return -1; | 
|---|
| 296 | } | 
|---|
| 297 |  | 
|---|
| 298 | Short_t rc = 0; | 
|---|
| 299 | for (int i=0; i<n; i++) | 
|---|
| 300 | { | 
|---|
| 301 | const MGeomPix &pix = geom[i]; | 
|---|
| 302 | if (aidx>=0 && pix.GetAidx()!=aidx) | 
|---|
| 303 | continue; | 
|---|
| 304 |  | 
|---|
| 305 | if (GetNumSuitableNeighbors(type, pix)<2) | 
|---|
| 306 | rc++; | 
|---|
| 307 | } | 
|---|
| 308 | return rc; | 
|---|
| 309 | } | 
|---|
| 310 |  | 
|---|
| 311 | // -------------------------------------------------------------------------- | 
|---|
| 312 | // | 
|---|
| 313 | // This is a helper function which calculates the size of a single cluster | 
|---|
| 314 | // by iterative calling. | 
|---|
| 315 | // | 
|---|
| 316 | // If a pixel matches the criterias the counter is increased by 1 and | 
|---|
| 317 | // the function is called for all its neighbors. If | 
|---|
| 318 | // | 
|---|
| 319 | // The second argument aidx is the area index (see MGeomCam, MGeomPix) | 
|---|
| 320 | // The default (or any value less than 0) means: all | 
|---|
| 321 | // | 
|---|
| 322 | // Returns -1 if the geometry doesn't match. | 
|---|
| 323 | // | 
|---|
| 324 | Short_t MBadPixelsCam::GetNumMaxCluster(MBadPixelsPix::UnsuitableType_t type, TObjArray &list, Int_t idx, Int_t aidx) const | 
|---|
| 325 | { | 
|---|
| 326 | const MGeomPix *pix = (MGeomPix*)list[idx]; | 
|---|
| 327 | if (!pix) | 
|---|
| 328 | return 0; | 
|---|
| 329 |  | 
|---|
| 330 | // Check whether more than one neighbor contains useful information, | 
|---|
| 331 | // which mean it can later be interpolated | 
|---|
| 332 | if (GetNumSuitableNeighbors(type, *pix)>1) | 
|---|
| 333 | return 0; | 
|---|
| 334 |  | 
|---|
| 335 | // If the requested area-index is valid check whether it is the requested one | 
|---|
| 336 | if (aidx>=0 && pix->GetAidx()!=aidx) | 
|---|
| 337 | return 1; | 
|---|
| 338 |  | 
|---|
| 339 | // Remove the pixel from the list of pixels to be checked | 
|---|
| 340 | list.RemoveAt(idx); | 
|---|
| 341 |  | 
|---|
| 342 | // Do the same for the neighbor pixels recursively and count the 1-results | 
|---|
| 343 | Short_t cnt = 1; | 
|---|
| 344 | const Int_t n = pix->GetNumNeighbors(); | 
|---|
| 345 | for (int i=0; i<n; i++) | 
|---|
| 346 | cnt += GetNumMaxCluster(type, list, pix->GetNeighbor(i), aidx); | 
|---|
| 347 |  | 
|---|
| 348 | // return the number of neighbor pixels/clusters which have unsuitable-type type | 
|---|
| 349 | return cnt; | 
|---|
| 350 | } | 
|---|
| 351 |  | 
|---|
| 352 | // -------------------------------------------------------------------------- | 
|---|
| 353 | // | 
|---|
| 354 | // Returns the size of the biggest cluster with the given UnsuitableType | 
|---|
| 355 | // type and the given area index. | 
|---|
| 356 | // | 
|---|
| 357 | // The second argument aidx is the area index (see MGeomCam, MGeomPix) | 
|---|
| 358 | // The default (or any value less than 0) means: all | 
|---|
| 359 | // | 
|---|
| 360 | // Returns -1 if the geometry doesn't match. | 
|---|
| 361 | // | 
|---|
| 362 | Short_t MBadPixelsCam::GetNumMaxCluster(MBadPixelsPix::UnsuitableType_t type, const MGeomCam &geom, Int_t aidx) const | 
|---|
| 363 | { | 
|---|
| 364 | const Int_t n = geom.GetNumPixels(); | 
|---|
| 365 |  | 
|---|
| 366 | if (n!=GetSize()) | 
|---|
| 367 | { | 
|---|
| 368 | *fLog << err << GetDescriptor() << "ERROR - Geometry (" << geom.ClassName() << ") size mismatch!" << endl; | 
|---|
| 369 | return -1; | 
|---|
| 370 | } | 
|---|
| 371 |  | 
|---|
| 372 | TObjArray list(n); | 
|---|
| 373 | for (int i=0; i<n; i++) | 
|---|
| 374 | list.AddAt(&geom[i], i); | 
|---|
| 375 |  | 
|---|
| 376 | Short_t max = 0; | 
|---|
| 377 | for (int i=0; i<n; i++) | 
|---|
| 378 | max = TMath::Max(GetNumMaxCluster(type, list, i, aidx), max); | 
|---|
| 379 |  | 
|---|
| 380 | return max; | 
|---|
| 381 | } | 
|---|
| 382 |  | 
|---|
| 383 | // -------------------------------------------------------------------------- | 
|---|
| 384 | // | 
|---|
| 385 | // Print the contents of all bad pixels | 
|---|
| 386 | // | 
|---|
| 387 | void MBadPixelsCam::Print(Option_t *o) const | 
|---|
| 388 | { | 
|---|
| 389 | *fLog << all << GetDescriptor() << ":" << endl; | 
|---|
| 390 | *fLog << "Pixels without problems:" << endl; | 
|---|
| 391 |  | 
|---|
| 392 | Int_t count = 0; | 
|---|
| 393 | Int_t full  = 0; | 
|---|
| 394 |  | 
|---|
| 395 | for (Int_t i=0; i<GetSize(); i++) | 
|---|
| 396 | { | 
|---|
| 397 | if (!(*this)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) | 
|---|
| 398 | { | 
|---|
| 399 | *fLog << i << " "; | 
|---|
| 400 | full++; | 
|---|
| 401 | count ++; | 
|---|
| 402 | } | 
|---|
| 403 |  | 
|---|
| 404 | if (count == 0) | 
|---|
| 405 | continue; | 
|---|
| 406 |  | 
|---|
| 407 | if (!(full % 25)) | 
|---|
| 408 | { | 
|---|
| 409 | full = 0; | 
|---|
| 410 | *fLog << endl; | 
|---|
| 411 | } | 
|---|
| 412 | } | 
|---|
| 413 | *fLog << endl; | 
|---|
| 414 | *fLog << count << " normal pixels" << endl; | 
|---|
| 415 | *fLog << endl; | 
|---|
| 416 |  | 
|---|
| 417 | *fLog << "Pixels unsuited for the whole run:" << endl; | 
|---|
| 418 |  | 
|---|
| 419 | full  = 0; | 
|---|
| 420 | count = 0; | 
|---|
| 421 | for (Int_t i=0; i<GetSize(); i++) | 
|---|
| 422 | { | 
|---|
| 423 | if ((*this)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) | 
|---|
| 424 | { | 
|---|
| 425 | *fLog << i << " "; | 
|---|
| 426 | full++; | 
|---|
| 427 | count ++; | 
|---|
| 428 | } | 
|---|
| 429 |  | 
|---|
| 430 | if (count == 0) | 
|---|
| 431 | continue; | 
|---|
| 432 |  | 
|---|
| 433 | if (!(full % 25)) | 
|---|
| 434 | { | 
|---|
| 435 | full = 0; | 
|---|
| 436 | *fLog << endl; | 
|---|
| 437 | } | 
|---|
| 438 | } | 
|---|
| 439 |  | 
|---|
| 440 | *fLog << endl; | 
|---|
| 441 | *fLog << count << " unsuited pixels per run :-(" << endl; | 
|---|
| 442 | *fLog << endl; | 
|---|
| 443 |  | 
|---|
| 444 | *fLog << "Pixels unsuited for this event:" << endl; | 
|---|
| 445 |  | 
|---|
| 446 | full  = 0; | 
|---|
| 447 | count = 0; | 
|---|
| 448 | for (Int_t i=0; i<GetSize(); i++) | 
|---|
| 449 | { | 
|---|
| 450 | if ((*this)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableEvt)) | 
|---|
| 451 | { | 
|---|
| 452 | *fLog << i << " "; | 
|---|
| 453 | full++; | 
|---|
| 454 | count ++; | 
|---|
| 455 | } | 
|---|
| 456 |  | 
|---|
| 457 | if (count == 0) | 
|---|
| 458 | continue; | 
|---|
| 459 |  | 
|---|
| 460 | if (!(full % 25)) | 
|---|
| 461 | { | 
|---|
| 462 | full  = 0; | 
|---|
| 463 | *fLog << endl; | 
|---|
| 464 | } | 
|---|
| 465 | } | 
|---|
| 466 |  | 
|---|
| 467 | *fLog << endl; | 
|---|
| 468 | *fLog << count << " unsuited pixels per event :-(" << endl; | 
|---|
| 469 | *fLog << endl; | 
|---|
| 470 |  | 
|---|
| 471 | full  = 0; | 
|---|
| 472 | count = 0; | 
|---|
| 473 |  | 
|---|
| 474 | *fLog << all << "Pixels unreliable for the whole run:" << endl; | 
|---|
| 475 |  | 
|---|
| 476 | for (Int_t i=0; i<GetSize(); i++) | 
|---|
| 477 | { | 
|---|
| 478 | if ((*this)[i].IsUnsuitable(MBadPixelsPix::kUnreliableRun)) | 
|---|
| 479 | { | 
|---|
| 480 | *fLog << i << " "; | 
|---|
| 481 | full++; | 
|---|
| 482 | count ++; | 
|---|
| 483 | } | 
|---|
| 484 |  | 
|---|
| 485 | if (count == 0) | 
|---|
| 486 | continue; | 
|---|
| 487 |  | 
|---|
| 488 | if (!(full % 25)) | 
|---|
| 489 | { | 
|---|
| 490 | full  = 0; | 
|---|
| 491 | *fLog << endl; | 
|---|
| 492 | } | 
|---|
| 493 | } | 
|---|
| 494 |  | 
|---|
| 495 | *fLog << endl; | 
|---|
| 496 | *fLog << count << " unreliable pixels :-(" << endl; | 
|---|
| 497 | *fLog << endl; | 
|---|
| 498 | *fLog << endl; | 
|---|
| 499 | *fLog << all << "Unsuited pixels statistics:" << endl; | 
|---|
| 500 | *fLog << endl; | 
|---|
| 501 |  | 
|---|
| 502 | PrintBadPixels(MBadPixelsPix::kPreviouslyExcluded,"Previously excluded"); | 
|---|
| 503 | PrintBadPixels(MBadPixelsPix::kChargeIsPedestal,"Signal smaller 3 Pedestal RMS"); | 
|---|
| 504 | PrintBadPixels(MBadPixelsPix::kChargeRelErrNotValid,"Signal Rel. error too large"); | 
|---|
| 505 | PrintBadPixels(MBadPixelsPix::kLoGainSaturation,"Low Gain Saturation"); | 
|---|
| 506 | PrintBadPixels(MBadPixelsPix::kMeanTimeInFirstBin,"Mean Arr. Time In First Extraction Bin"); | 
|---|
| 507 | PrintBadPixels(MBadPixelsPix::kMeanTimeInLast2Bins,"Mean Arr. Time In Last 2 Extraction Bins"); | 
|---|
| 508 | PrintBadPixels(MBadPixelsPix::kDeviatingNumPhes,"Deviating Number of Photo-electrons"); | 
|---|
| 509 | PrintBadPixels(MBadPixelsPix::kDeviatingNumPhots,"Deviating Number of Photons"); | 
|---|
| 510 | PrintBadPixels(MBadPixelsPix::kHiGainOverFlow,"High-Gain Histogram Overflow"); | 
|---|
| 511 | PrintBadPixels(MBadPixelsPix::kLoGainOverFlow,"Low-Gain Histogram Overflow"); | 
|---|
| 512 | PrintBadPixels(MBadPixelsPix::kDeadPedestalRms,"Presumably dead from Ped. Rms"); | 
|---|
| 513 | PrintBadPixels(MBadPixelsPix::kFluctuatingArrivalTimes,"Fluctuating Pulse Arrival Times"); | 
|---|
| 514 |  | 
|---|
| 515 | *fLog << endl; | 
|---|
| 516 | *fLog << all << "Unreliable pixels statistics:" << endl; | 
|---|
| 517 | *fLog << endl; | 
|---|
| 518 |  | 
|---|
| 519 | PrintBadPixels(MBadPixelsPix::kChargeSigmaNotValid,"Signal Sigma smaller Pedestal RMS"); | 
|---|
| 520 | PrintBadPixels(MBadPixelsPix::kHiGainNotFitted    ,"High Gain Signals could not be fitted"); | 
|---|
| 521 | PrintBadPixels(MBadPixelsPix::kLoGainNotFitted    ,"Low  Gain Signals could not be fitted"); | 
|---|
| 522 | PrintBadPixels(MBadPixelsPix::kRelTimeNotFitted   ,"Relative Arr. Times could not be fitted"); | 
|---|
| 523 | PrintBadPixels(MBadPixelsPix::kHiGainOscillating  ,"High Gain Signals Oscillation"); | 
|---|
| 524 | PrintBadPixels(MBadPixelsPix::kLoGainOscillating  ,"Low  Gain Signals Oscillation"); | 
|---|
| 525 | PrintBadPixels(MBadPixelsPix::kRelTimeOscillating ,"Relative Arr. Times Oscillation"); | 
|---|
| 526 | PrintBadPixels(MBadPixelsPix::kDeviatingFFactor   ,"Deviating global F-Factor"); | 
|---|
| 527 | } | 
|---|
| 528 |  | 
|---|
| 529 | void MBadPixelsCam::PrintBadPixels( MBadPixelsPix::UncalibratedType_t typ, const char *text) const | 
|---|
| 530 | { | 
|---|
| 531 | *fLog << "Pixels with " << text << ": " << endl; | 
|---|
| 532 | UInt_t count = 0; | 
|---|
| 533 | UInt_t full  = 0; | 
|---|
| 534 |  | 
|---|
| 535 | for (Int_t i=0; i<GetSize(); i++) | 
|---|
| 536 | { | 
|---|
| 537 | if ((*this)[i].IsUncalibrated(typ)) | 
|---|
| 538 | { | 
|---|
| 539 | *fLog << i << " "; | 
|---|
| 540 | full++; | 
|---|
| 541 | count++; | 
|---|
| 542 | } | 
|---|
| 543 |  | 
|---|
| 544 | if (count == 0) | 
|---|
| 545 | continue; | 
|---|
| 546 |  | 
|---|
| 547 | if (!(full % 25)) | 
|---|
| 548 | { | 
|---|
| 549 | full  = 0; | 
|---|
| 550 | *fLog << endl; | 
|---|
| 551 | } | 
|---|
| 552 | } | 
|---|
| 553 |  | 
|---|
| 554 | *fLog << endl; | 
|---|
| 555 | *fLog << Form("%3i",count) << " pixels in total " << endl; | 
|---|
| 556 | } | 
|---|
| 557 |  | 
|---|
| 558 | // -------------------------------------------------------------------------- | 
|---|
| 559 | // | 
|---|
| 560 | // Read from an ascii file of the format: | 
|---|
| 561 | //    pixel1 pixel2 pixel3 pixel4 | 
|---|
| 562 | // while pixel1,2,3,4 are the pixel indices used in the software. | 
|---|
| 563 | // | 
|---|
| 564 | // To read the pixels corresponding to a given run you can give run!=0 | 
|---|
| 565 | // and a file of the format: | 
|---|
| 566 | //   1234: 17 193 292 | 
|---|
| 567 | //   1235: 17 193 292 293 | 
|---|
| 568 | // | 
|---|
| 569 | void MBadPixelsCam::AsciiRead(istream &fin, UInt_t run=0) | 
|---|
| 570 | { | 
|---|
| 571 |  | 
|---|
| 572 | Int_t len; | 
|---|
| 573 | TString str; | 
|---|
| 574 |  | 
|---|
| 575 | while (1) | 
|---|
| 576 | { | 
|---|
| 577 | str.ReadLine(fin); | 
|---|
| 578 |  | 
|---|
| 579 | if (str.IsNull()) | 
|---|
| 580 | { | 
|---|
| 581 | *fLog << warn << GetDescriptor() | 
|---|
| 582 | << ": Cannot apply AsciiRead from istream pointer. " | 
|---|
| 583 | << "Either file does not exist or file is empty! " << endl; | 
|---|
| 584 | return; | 
|---|
| 585 | } | 
|---|
| 586 |  | 
|---|
| 587 | Int_t r; | 
|---|
| 588 |  | 
|---|
| 589 | const Int_t n = sscanf(str.Data(), " %d : %n", &r, &len); | 
|---|
| 590 | if (n!=1) | 
|---|
| 591 | return; | 
|---|
| 592 |  | 
|---|
| 593 | if (run==0 || run && (UInt_t)r==run) | 
|---|
| 594 | break; | 
|---|
| 595 | } | 
|---|
| 596 |  | 
|---|
| 597 | str.Remove(0, len); | 
|---|
| 598 |  | 
|---|
| 599 | while (1) | 
|---|
| 600 | { | 
|---|
| 601 | Int_t idx; | 
|---|
| 602 | const Int_t n = sscanf(str.Data(), " %d %n", &idx, &len); | 
|---|
| 603 |  | 
|---|
| 604 | if (n!=1) | 
|---|
| 605 | break; | 
|---|
| 606 |  | 
|---|
| 607 | str.Remove(0, len); | 
|---|
| 608 |  | 
|---|
| 609 | if (idx>=GetSize()) | 
|---|
| 610 | InitSize(idx+1); | 
|---|
| 611 |  | 
|---|
| 612 | (*this)[idx].SetUnsuitable(MBadPixelsPix::kUnsuitableRun); | 
|---|
| 613 | (*this)[idx].SetUncalibrated(MBadPixelsPix::kPreviouslyExcluded); | 
|---|
| 614 | } | 
|---|
| 615 | } | 
|---|
| 616 |  | 
|---|
| 617 | // -------------------------------------------------------------------------- | 
|---|
| 618 | // | 
|---|
| 619 | // Write the information into an ascii file. If a run-number is given the | 
|---|
| 620 | // run-number will lead the line. | 
|---|
| 621 | // | 
|---|
| 622 | Bool_t MBadPixelsCam::AsciiWrite(ostream &fout, UInt_t run=0) const | 
|---|
| 623 | { | 
|---|
| 624 | if (run) | 
|---|
| 625 | fout << run << ":"; | 
|---|
| 626 |  | 
|---|
| 627 | for (int i=0; i<GetSize(); i++) | 
|---|
| 628 | if ((*this)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) | 
|---|
| 629 | fout << " " << i; | 
|---|
| 630 |  | 
|---|
| 631 | if (run && GetSize()) | 
|---|
| 632 | fout << endl; | 
|---|
| 633 |  | 
|---|
| 634 | return kTRUE; | 
|---|
| 635 | } | 
|---|
| 636 |  | 
|---|
| 637 | // -------------------------------------------------------------------------- | 
|---|
| 638 | // | 
|---|
| 639 | // The types are the following: | 
|---|
| 640 | // 0: MBadPixelsPix::GetInfo()[0] | 
|---|
| 641 | // 1: MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableRun) | 
|---|
| 642 | // 2: MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableEvt) | 
|---|
| 643 | // 3: MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnreliableRun) | 
|---|
| 644 | // 4: MBadPixelsPix::IsHiGainBad() | 
|---|
| 645 | // 5: MBadPixelsPix::IsLoGainBad() | 
|---|
| 646 | // 6: MBadPixelsPix::GetUnsuitableCalLevel() | 
|---|
| 647 | // 7: MBadPixelsPix::GetUnreliableCalLevel() | 
|---|
| 648 | // 8: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainNotFitted) | 
|---|
| 649 | // 9: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainNotFitted) | 
|---|
| 650 | // 10: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainOscillating) | 
|---|
| 651 | // 11: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainOscillating) | 
|---|
| 652 | // 12: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainSaturation ) | 
|---|
| 653 | // 13: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeIsPedestal ) | 
|---|
| 654 | // 14: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeErrNotValid) | 
|---|
| 655 | // 15: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeRelErrNotValid) | 
|---|
| 656 | // 16: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid ) | 
|---|
| 657 | // 17: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin  ) | 
|---|
| 658 | // 18: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins ) | 
|---|
| 659 | // 19: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kDeviatingNumPhes    ) | 
|---|
| 660 | // 20: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kRelTimeNotFitted    ) | 
|---|
| 661 | // 21: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kRelTimeOscillating  ) | 
|---|
| 662 | // 22: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kDeviatingNumPhots   ) | 
|---|
| 663 | // 23: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainOverFlow      ) | 
|---|
| 664 | // 24: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainOverFlow      ) | 
|---|
| 665 | // 102: MBadPixelsPix::IsUnsuitable() | 
|---|
| 666 | // | 
|---|
| 667 | Bool_t MBadPixelsCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const | 
|---|
| 668 | { | 
|---|
| 669 |  | 
|---|
| 670 | if (idx >= GetSize()) | 
|---|
| 671 | return kFALSE; | 
|---|
| 672 |  | 
|---|
| 673 | switch (type) | 
|---|
| 674 | { | 
|---|
| 675 | case 0: | 
|---|
| 676 | return (*this)[idx].GetInfo()[0]; | 
|---|
| 677 | case 1: | 
|---|
| 678 | if  (!(*this)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) | 
|---|
| 679 | return kFALSE; | 
|---|
| 680 | val = 1; | 
|---|
| 681 | break; | 
|---|
| 682 | case 2: | 
|---|
| 683 | if  (!(*this)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableEvt)) | 
|---|
| 684 | return kFALSE; | 
|---|
| 685 | val = 1; | 
|---|
| 686 | break; | 
|---|
| 687 | case 3: | 
|---|
| 688 | if  (!(*this)[idx].IsUnsuitable(MBadPixelsPix::kUnreliableRun)) | 
|---|
| 689 | return kFALSE; | 
|---|
| 690 | val = 1; | 
|---|
| 691 | break; | 
|---|
| 692 | case 4: | 
|---|
| 693 | if  (!(*this)[idx].IsHiGainBad()) | 
|---|
| 694 | return kFALSE; | 
|---|
| 695 | val = 1; | 
|---|
| 696 | break; | 
|---|
| 697 | case 5: | 
|---|
| 698 | if  (!(*this)[idx].IsLoGainBad()) | 
|---|
| 699 | return kFALSE; | 
|---|
| 700 | val = 1; | 
|---|
| 701 | break; | 
|---|
| 702 | case 6: | 
|---|
| 703 | if  (!(*this)[idx].GetUnsuitableCalLevel()) | 
|---|
| 704 | return kFALSE; | 
|---|
| 705 | val = (*this)[idx].GetUnsuitableCalLevel(); | 
|---|
| 706 | break; | 
|---|
| 707 | case 7: | 
|---|
| 708 | if  (!(*this)[idx].GetUnreliableCalLevel()) | 
|---|
| 709 | return kFALSE; | 
|---|
| 710 | val = (*this)[idx].GetUnreliableCalLevel(); | 
|---|
| 711 | break; | 
|---|
| 712 | case 8: | 
|---|
| 713 | if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainNotFitted)) | 
|---|
| 714 | return kFALSE; | 
|---|
| 715 | val = 1; | 
|---|
| 716 | break; | 
|---|
| 717 | case 9: | 
|---|
| 718 | if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainNotFitted)) | 
|---|
| 719 | return kFALSE; | 
|---|
| 720 | val = 1; | 
|---|
| 721 | break; | 
|---|
| 722 | case 10: | 
|---|
| 723 | if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainOscillating)) | 
|---|
| 724 | return kFALSE; | 
|---|
| 725 | val = 1; | 
|---|
| 726 | break; | 
|---|
| 727 | case 11: | 
|---|
| 728 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainOscillating)) | 
|---|
| 729 | return kFALSE; | 
|---|
| 730 | val = 1; | 
|---|
| 731 | break; | 
|---|
| 732 | case 12: | 
|---|
| 733 | if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainSaturation )) | 
|---|
| 734 | return kFALSE; | 
|---|
| 735 | val = 1; | 
|---|
| 736 | break; | 
|---|
| 737 | case 13: | 
|---|
| 738 | if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeIsPedestal )) | 
|---|
| 739 | return kFALSE; | 
|---|
| 740 | val = 1; | 
|---|
| 741 | break; | 
|---|
| 742 | case 14: | 
|---|
| 743 | if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeErrNotValid)) | 
|---|
| 744 | return kFALSE; | 
|---|
| 745 | val = 1; | 
|---|
| 746 | break; | 
|---|
| 747 | case 15: | 
|---|
| 748 | if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeRelErrNotValid)) | 
|---|
| 749 | return kFALSE; | 
|---|
| 750 | val = 1; | 
|---|
| 751 | break; | 
|---|
| 752 | case 16: | 
|---|
| 753 | if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid )) | 
|---|
| 754 | return kFALSE; | 
|---|
| 755 | val = 1; | 
|---|
| 756 | break; | 
|---|
| 757 | case 17: | 
|---|
| 758 | if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin  )) | 
|---|
| 759 | return kFALSE; | 
|---|
| 760 | val = 1; | 
|---|
| 761 | break; | 
|---|
| 762 | case 18: | 
|---|
| 763 | if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins )) | 
|---|
| 764 | return kFALSE; | 
|---|
| 765 | val = 1; | 
|---|
| 766 | break; | 
|---|
| 767 | case 19: | 
|---|
| 768 | if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kDeviatingNumPhes )) | 
|---|
| 769 | return kFALSE; | 
|---|
| 770 | val = 1; | 
|---|
| 771 | break; | 
|---|
| 772 | case 20: | 
|---|
| 773 | if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kRelTimeNotFitted )) | 
|---|
| 774 | return kFALSE; | 
|---|
| 775 | val = 1; | 
|---|
| 776 | break; | 
|---|
| 777 | case 21: | 
|---|
| 778 | if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kRelTimeOscillating)) | 
|---|
| 779 | return kFALSE; | 
|---|
| 780 | val = 1; | 
|---|
| 781 | break; | 
|---|
| 782 | case 22: | 
|---|
| 783 | if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kDeviatingNumPhots)) | 
|---|
| 784 | return kFALSE; | 
|---|
| 785 | val = 1; | 
|---|
| 786 | break; | 
|---|
| 787 | case 23: | 
|---|
| 788 | if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainOverFlow    )) | 
|---|
| 789 | return kFALSE; | 
|---|
| 790 | val = 1; | 
|---|
| 791 | break; | 
|---|
| 792 | case 24: | 
|---|
| 793 | if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainOverFlow   )) | 
|---|
| 794 | return kFALSE; | 
|---|
| 795 | val = 1; | 
|---|
| 796 | break; | 
|---|
| 797 | case 102: | 
|---|
| 798 | if  (!(*this)[idx].IsUnsuitable()) | 
|---|
| 799 | return kFALSE; | 
|---|
| 800 | val = 1; | 
|---|
| 801 | break; | 
|---|
| 802 | default: | 
|---|
| 803 | return kFALSE; | 
|---|
| 804 | } | 
|---|
| 805 |  | 
|---|
| 806 | return kTRUE; | 
|---|
| 807 | } | 
|---|
| 808 |  | 
|---|
| 809 | void MBadPixelsCam::DrawPixelContent(Int_t num) const | 
|---|
| 810 | { | 
|---|
| 811 | *fLog << warn << "MBadPixelsCam::DrawPixelContent - not available." << endl; | 
|---|
| 812 | } | 
|---|