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