| 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->ForEach(TObject, Clear)();
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | // --------------------------------------------------------------------------
|
|---|
| 172 | //
|
|---|
| 173 | // Reset event depending bits
|
|---|
| 174 | //
|
|---|
| 175 | void MBadPixelsCam::Reset()
|
|---|
| 176 | {
|
|---|
| 177 | fArray->ForEach(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 | // Counts the number of neighbors matching NOT UnsuitableType type
|
|---|
| 245 | //
|
|---|
| 246 | Short_t MBadPixelsCam::GetNumSuitableNeighbors(MBadPixelsPix::UnsuitableType_t type, const MGeomPix &pix) const
|
|---|
| 247 | {
|
|---|
| 248 | const Int_t n2 = pix.GetNumNeighbors();
|
|---|
| 249 |
|
|---|
| 250 | Int_t cnt=0;
|
|---|
| 251 | for (int j=0; j<n2; j++)
|
|---|
| 252 | {
|
|---|
| 253 | const Int_t id2 = pix.GetNeighbor(j);
|
|---|
| 254 | if (!(*this)[id2].IsUnsuitable(type))
|
|---|
| 255 | cnt++;
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | return cnt;
|
|---|
| 259 | }
|
|---|
| 260 |
|
|---|
| 261 | // --------------------------------------------------------------------------
|
|---|
| 262 | //
|
|---|
| 263 | // Calculate the number of pixels which are - under no circumstances -
|
|---|
| 264 | // interpolatable, called isolated. This means that a pixel (its own status
|
|---|
| 265 | // doesn't matter) has less than two reliable neighbor pixels.
|
|---|
| 266 | //
|
|---|
| 267 | // The second argument aidx is the area index (see MGeomCam, MGeomPix)
|
|---|
| 268 | // The default (or any value less than 0) means: all
|
|---|
| 269 | //
|
|---|
| 270 | // Returns -1 if the geometry doesn't match.
|
|---|
| 271 | //
|
|---|
| 272 | Short_t MBadPixelsCam::GetNumIsolated(MBadPixelsPix::UnsuitableType_t type, const MGeomCam &geom, Int_t aidx) const
|
|---|
| 273 | {
|
|---|
| 274 | const Int_t n = geom.GetNumPixels();
|
|---|
| 275 |
|
|---|
| 276 | if (n!=GetSize())
|
|---|
| 277 | {
|
|---|
| 278 | *fLog << err << GetDescriptor() << "ERROR - Geometry (" << geom.ClassName() << ") size mismatch!" << endl;
|
|---|
| 279 | return -1;
|
|---|
| 280 | }
|
|---|
| 281 |
|
|---|
| 282 | Short_t rc = 0;
|
|---|
| 283 | for (int i=0; i<n; i++)
|
|---|
| 284 | {
|
|---|
| 285 | const MGeomPix &pix = geom[i];
|
|---|
| 286 | if (aidx>=0 && pix.GetAidx()!=aidx)
|
|---|
| 287 | continue;
|
|---|
| 288 |
|
|---|
| 289 | if (GetNumSuitableNeighbors(type, pix)<2)
|
|---|
| 290 | rc++;
|
|---|
| 291 | }
|
|---|
| 292 | return rc;
|
|---|
| 293 | }
|
|---|
| 294 |
|
|---|
| 295 | // --------------------------------------------------------------------------
|
|---|
| 296 | //
|
|---|
| 297 | // This is a helper function which calculates the size of a single cluster
|
|---|
| 298 | // by iterative calling.
|
|---|
| 299 | //
|
|---|
| 300 | // If a pixel matches the criterias the counter is increased by 1 and
|
|---|
| 301 | // the function is called for all its neighbors. If
|
|---|
| 302 | //
|
|---|
| 303 | // The second argument aidx is the area index (see MGeomCam, MGeomPix)
|
|---|
| 304 | // The default (or any value less than 0) means: all
|
|---|
| 305 | //
|
|---|
| 306 | // Returns -1 if the geometry doesn't match.
|
|---|
| 307 | //
|
|---|
| 308 | Short_t MBadPixelsCam::GetNumMaxCluster(MBadPixelsPix::UnsuitableType_t type, TObjArray &list, Int_t idx, Int_t aidx) const
|
|---|
| 309 | {
|
|---|
| 310 | const MGeomPix *pix = (MGeomPix*)list[idx];
|
|---|
| 311 | if (!pix)
|
|---|
| 312 | return 0;
|
|---|
| 313 |
|
|---|
| 314 | if (GetNumSuitableNeighbors(type, *pix)>1)
|
|---|
| 315 | return 0;
|
|---|
| 316 |
|
|---|
| 317 | if (aidx>=0 && pix->GetAidx()!=aidx)
|
|---|
| 318 | return 1;
|
|---|
| 319 |
|
|---|
| 320 | list.RemoveAt(idx);
|
|---|
| 321 |
|
|---|
| 322 | Short_t cnt = 1;
|
|---|
| 323 | const Int_t n = pix->GetNumNeighbors();
|
|---|
| 324 | for (int i=0; i<n; i++)
|
|---|
| 325 | cnt += GetNumMaxCluster(type, list, pix->GetNeighbor(i), aidx);
|
|---|
| 326 |
|
|---|
| 327 | return cnt;
|
|---|
| 328 | }
|
|---|
| 329 |
|
|---|
| 330 | // --------------------------------------------------------------------------
|
|---|
| 331 | //
|
|---|
| 332 | // Returns the size of the biggest cluster with the given UnsuitableType
|
|---|
| 333 | // type and the given area index.
|
|---|
| 334 | //
|
|---|
| 335 | // The second argument aidx is the area index (see MGeomCam, MGeomPix)
|
|---|
| 336 | // The default (or any value less than 0) means: all
|
|---|
| 337 | //
|
|---|
| 338 | // Returns -1 if the geometry doesn't match.
|
|---|
| 339 | //
|
|---|
| 340 | Short_t MBadPixelsCam::GetNumMaxCluster(MBadPixelsPix::UnsuitableType_t type, const MGeomCam &geom, Int_t aidx) const
|
|---|
| 341 | {
|
|---|
| 342 | const Int_t n = geom.GetNumPixels();
|
|---|
| 343 |
|
|---|
| 344 | if (n!=GetSize())
|
|---|
| 345 | {
|
|---|
| 346 | *fLog << err << GetDescriptor() << "ERROR - Geometry (" << geom.ClassName() << ") size mismatch!" << endl;
|
|---|
| 347 | return -1;
|
|---|
| 348 | }
|
|---|
| 349 |
|
|---|
| 350 | TObjArray list(n);
|
|---|
| 351 | for (int i=0; i<n; i++)
|
|---|
| 352 | list.AddAt(&geom[i], i);
|
|---|
| 353 |
|
|---|
| 354 | Short_t max = 0;
|
|---|
| 355 | for (int i=0; i<n; i++)
|
|---|
| 356 | max = TMath::Max(GetNumMaxCluster(type, list, i, aidx), max);
|
|---|
| 357 |
|
|---|
| 358 | return max;
|
|---|
| 359 | }
|
|---|
| 360 |
|
|---|
| 361 | // --------------------------------------------------------------------------
|
|---|
| 362 | //
|
|---|
| 363 | // Print the contents of all bad pixels
|
|---|
| 364 | //
|
|---|
| 365 | void MBadPixelsCam::Print(Option_t *o) const
|
|---|
| 366 | {
|
|---|
| 367 | *fLog << all << GetDescriptor() << ":" << endl;
|
|---|
| 368 | *fLog << "Pixels without problems:" << endl;
|
|---|
| 369 |
|
|---|
| 370 | Int_t count = 0;
|
|---|
| 371 | Int_t full = 0;
|
|---|
| 372 |
|
|---|
| 373 | for (Int_t i=0; i<GetSize(); i++)
|
|---|
| 374 | {
|
|---|
| 375 | if (!(*this)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
|---|
| 376 | {
|
|---|
| 377 | *fLog << i << " ";
|
|---|
| 378 | full++;
|
|---|
| 379 | count ++;
|
|---|
| 380 | }
|
|---|
| 381 |
|
|---|
| 382 | if (count == 0)
|
|---|
| 383 | continue;
|
|---|
| 384 |
|
|---|
| 385 | if (!(full % 25))
|
|---|
| 386 | {
|
|---|
| 387 | full = 0;
|
|---|
| 388 | *fLog << endl;
|
|---|
| 389 | }
|
|---|
| 390 | }
|
|---|
| 391 | *fLog << endl;
|
|---|
| 392 | *fLog << count << " normal pixels" << endl;
|
|---|
| 393 | *fLog << endl;
|
|---|
| 394 |
|
|---|
| 395 | *fLog << "Pixels unsuited for the whole run:" << endl;
|
|---|
| 396 |
|
|---|
| 397 | full = 0;
|
|---|
| 398 | count = 0;
|
|---|
| 399 | for (Int_t i=0; i<GetSize(); i++)
|
|---|
| 400 | {
|
|---|
| 401 | if ((*this)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
|---|
| 402 | {
|
|---|
| 403 | *fLog << i << " ";
|
|---|
| 404 | full++;
|
|---|
| 405 | count ++;
|
|---|
| 406 | }
|
|---|
| 407 |
|
|---|
| 408 | if (count == 0)
|
|---|
| 409 | continue;
|
|---|
| 410 |
|
|---|
| 411 | if (!(full % 25))
|
|---|
| 412 | {
|
|---|
| 413 | full = 0;
|
|---|
| 414 | *fLog << endl;
|
|---|
| 415 | }
|
|---|
| 416 | }
|
|---|
| 417 |
|
|---|
| 418 | *fLog << endl;
|
|---|
| 419 | *fLog << count << " unsuited pixels per run :-(" << endl;
|
|---|
| 420 | *fLog << endl;
|
|---|
| 421 |
|
|---|
| 422 | *fLog << "Pixels unsuited for this event:" << endl;
|
|---|
| 423 |
|
|---|
| 424 | full = 0;
|
|---|
| 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 | full++;
|
|---|
| 432 | count ++;
|
|---|
| 433 | }
|
|---|
| 434 |
|
|---|
| 435 | if (count == 0)
|
|---|
| 436 | continue;
|
|---|
| 437 |
|
|---|
| 438 | if (!(full % 25))
|
|---|
| 439 | {
|
|---|
| 440 | full = 0;
|
|---|
| 441 | *fLog << endl;
|
|---|
| 442 | }
|
|---|
| 443 | }
|
|---|
| 444 |
|
|---|
| 445 | *fLog << endl;
|
|---|
| 446 | *fLog << count << " unsuited pixels per event :-(" << endl;
|
|---|
| 447 | *fLog << endl;
|
|---|
| 448 |
|
|---|
| 449 | full = 0;
|
|---|
| 450 | count = 0;
|
|---|
| 451 |
|
|---|
| 452 | *fLog << all << "Pixels unreliable for the whole run:" << endl;
|
|---|
| 453 |
|
|---|
| 454 | for (Int_t i=0; i<GetSize(); i++)
|
|---|
| 455 | {
|
|---|
| 456 | if ((*this)[i].IsUnsuitable(MBadPixelsPix::kUnreliableRun))
|
|---|
| 457 | {
|
|---|
| 458 | *fLog << i << " ";
|
|---|
| 459 | full++;
|
|---|
| 460 | count ++;
|
|---|
| 461 | }
|
|---|
| 462 |
|
|---|
| 463 | if (count == 0)
|
|---|
| 464 | continue;
|
|---|
| 465 |
|
|---|
| 466 | if (!(full % 25))
|
|---|
| 467 | {
|
|---|
| 468 | full = 0;
|
|---|
| 469 | *fLog << endl;
|
|---|
| 470 | }
|
|---|
| 471 | }
|
|---|
| 472 |
|
|---|
| 473 | *fLog << endl;
|
|---|
| 474 | *fLog << count << " unreliable pixels :-(" << endl;
|
|---|
| 475 | *fLog << endl;
|
|---|
| 476 | *fLog << endl;
|
|---|
| 477 | *fLog << all << "Unsuited pixels statistics:" << endl;
|
|---|
| 478 | *fLog << endl;
|
|---|
| 479 |
|
|---|
| 480 | PrintBadPixels(MBadPixelsPix::kPreviouslyExcluded,"Previously excluded");
|
|---|
| 481 | PrintBadPixels(MBadPixelsPix::kChargeIsPedestal,"Signal smaller 3 Pedestal RMS");
|
|---|
| 482 | PrintBadPixels(MBadPixelsPix::kChargeRelErrNotValid,"Signal Rel. error too large");
|
|---|
| 483 | PrintBadPixels(MBadPixelsPix::kLoGainSaturation,"Low Gain Saturation");
|
|---|
| 484 | PrintBadPixels(MBadPixelsPix::kMeanTimeInFirstBin,"Mean Arr. Time In First Extraction Bin");
|
|---|
| 485 | PrintBadPixels(MBadPixelsPix::kMeanTimeInLast2Bins,"Mean Arr. Time In Last 2 Extraction Bins");
|
|---|
| 486 | PrintBadPixels(MBadPixelsPix::kDeviatingNumPhes,"Deviating Number of Photo-electrons");
|
|---|
| 487 | PrintBadPixels(MBadPixelsPix::kDeviatingNumPhots,"Deviating Number of Photons");
|
|---|
| 488 | PrintBadPixels(MBadPixelsPix::kHiGainOverFlow,"High-Gain Histogram Overflow");
|
|---|
| 489 | PrintBadPixels(MBadPixelsPix::kLoGainOverFlow,"Low-Gain Histogram Overflow");
|
|---|
| 490 | PrintBadPixels(MBadPixelsPix::kDeadPedestalRms,"Presumably dead from Ped. Rms");
|
|---|
| 491 | PrintBadPixels(MBadPixelsPix::kFluctuatingArrivalTimes,"Fluctuating Pulse Arrival Times");
|
|---|
| 492 |
|
|---|
| 493 | *fLog << endl;
|
|---|
| 494 | *fLog << all << "Unreliable pixels statistics:" << endl;
|
|---|
| 495 | *fLog << endl;
|
|---|
| 496 |
|
|---|
| 497 | PrintBadPixels(MBadPixelsPix::kChargeSigmaNotValid,"Signal Sigma smaller Pedestal RMS");
|
|---|
| 498 | PrintBadPixels(MBadPixelsPix::kHiGainNotFitted ,"High Gain Signals could not be fitted");
|
|---|
| 499 | PrintBadPixels(MBadPixelsPix::kLoGainNotFitted ,"Low Gain Signals could not be fitted");
|
|---|
| 500 | PrintBadPixels(MBadPixelsPix::kRelTimeNotFitted ,"Relative Arr. Times could not be fitted");
|
|---|
| 501 | PrintBadPixels(MBadPixelsPix::kHiGainOscillating ,"High Gain Signals Oscillation");
|
|---|
| 502 | PrintBadPixels(MBadPixelsPix::kLoGainOscillating ,"Low Gain Signals Oscillation");
|
|---|
| 503 | PrintBadPixels(MBadPixelsPix::kRelTimeOscillating ,"Relative Arr. Times Oscillation");
|
|---|
| 504 | PrintBadPixels(MBadPixelsPix::kDeviatingFFactor ,"Deviating global F-Factor");
|
|---|
| 505 | }
|
|---|
| 506 |
|
|---|
| 507 | void MBadPixelsCam::PrintBadPixels( MBadPixelsPix::UncalibratedType_t typ, const char *text) const
|
|---|
| 508 | {
|
|---|
| 509 | *fLog << "Pixels with " << text << ": " << endl;
|
|---|
| 510 | UInt_t count = 0;
|
|---|
| 511 | UInt_t full = 0;
|
|---|
| 512 |
|
|---|
| 513 | for (Int_t i=0; i<GetSize(); i++)
|
|---|
| 514 | {
|
|---|
| 515 | if ((*this)[i].IsUncalibrated(typ))
|
|---|
| 516 | {
|
|---|
| 517 | *fLog << i << " ";
|
|---|
| 518 | full++;
|
|---|
| 519 | count++;
|
|---|
| 520 | }
|
|---|
| 521 |
|
|---|
| 522 | if (count == 0)
|
|---|
| 523 | continue;
|
|---|
| 524 |
|
|---|
| 525 | if (!(full % 25))
|
|---|
| 526 | {
|
|---|
| 527 | full = 0;
|
|---|
| 528 | *fLog << endl;
|
|---|
| 529 | }
|
|---|
| 530 | }
|
|---|
| 531 |
|
|---|
| 532 | *fLog << endl;
|
|---|
| 533 | *fLog << Form("%3i",count) << " pixels in total " << endl;
|
|---|
| 534 | }
|
|---|
| 535 |
|
|---|
| 536 | // --------------------------------------------------------------------------
|
|---|
| 537 | //
|
|---|
| 538 | // Read from an ascii file of the format:
|
|---|
| 539 | // pixel1 pixel2 pixel3 pixel4
|
|---|
| 540 | // while pixel1,2,3,4 are the pixel indices used in the software.
|
|---|
| 541 | //
|
|---|
| 542 | // To read the pixels corresponding to a given run you can give run!=0
|
|---|
| 543 | // and a file of the format:
|
|---|
| 544 | // 1234: 17 193 292
|
|---|
| 545 | // 1235: 17 193 292 293
|
|---|
| 546 | //
|
|---|
| 547 | void MBadPixelsCam::AsciiRead(istream &fin, UInt_t run=0)
|
|---|
| 548 | {
|
|---|
| 549 |
|
|---|
| 550 | Int_t len;
|
|---|
| 551 | TString str;
|
|---|
| 552 |
|
|---|
| 553 | while (1)
|
|---|
| 554 | {
|
|---|
| 555 | str.ReadLine(fin);
|
|---|
| 556 |
|
|---|
| 557 | if (str.IsNull())
|
|---|
| 558 | {
|
|---|
| 559 | *fLog << warn << GetDescriptor()
|
|---|
| 560 | << ": Cannot apply AsciiRead from istream pointer. "
|
|---|
| 561 | << "Either file does not exist or file is empty! " << endl;
|
|---|
| 562 | return;
|
|---|
| 563 | }
|
|---|
| 564 |
|
|---|
| 565 | Int_t r;
|
|---|
| 566 |
|
|---|
| 567 | const Int_t n = sscanf(str.Data(), " %d : %n", &r, &len);
|
|---|
| 568 | if (n!=1)
|
|---|
| 569 | return;
|
|---|
| 570 |
|
|---|
| 571 | if (run==0 || run && (UInt_t)r==run)
|
|---|
| 572 | break;
|
|---|
| 573 | }
|
|---|
| 574 |
|
|---|
| 575 | str.Remove(0, len);
|
|---|
| 576 |
|
|---|
| 577 | while (1)
|
|---|
| 578 | {
|
|---|
| 579 | Int_t idx;
|
|---|
| 580 | const Int_t n = sscanf(str.Data(), " %d %n", &idx, &len);
|
|---|
| 581 |
|
|---|
| 582 | if (n!=1)
|
|---|
| 583 | break;
|
|---|
| 584 |
|
|---|
| 585 | str.Remove(0, len);
|
|---|
| 586 |
|
|---|
| 587 | if (idx>=GetSize())
|
|---|
| 588 | InitSize(idx+1);
|
|---|
| 589 |
|
|---|
| 590 | (*this)[idx].SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
|
|---|
| 591 | (*this)[idx].SetUncalibrated(MBadPixelsPix::kPreviouslyExcluded);
|
|---|
| 592 | }
|
|---|
| 593 | }
|
|---|
| 594 |
|
|---|
| 595 | // --------------------------------------------------------------------------
|
|---|
| 596 | //
|
|---|
| 597 | // Write the information into an ascii file. If a run-number is given the
|
|---|
| 598 | // run-number will lead the line.
|
|---|
| 599 | //
|
|---|
| 600 | Bool_t MBadPixelsCam::AsciiWrite(ostream &fout, UInt_t run=0) const
|
|---|
| 601 | {
|
|---|
| 602 | if (run)
|
|---|
| 603 | fout << run << ":";
|
|---|
| 604 |
|
|---|
| 605 | for (int i=0; i<GetSize(); i++)
|
|---|
| 606 | if ((*this)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
|---|
| 607 | fout << " " << i;
|
|---|
| 608 |
|
|---|
| 609 | if (run && GetSize())
|
|---|
| 610 | fout << endl;
|
|---|
| 611 |
|
|---|
| 612 | return kTRUE;
|
|---|
| 613 | }
|
|---|
| 614 |
|
|---|
| 615 | // --------------------------------------------------------------------------
|
|---|
| 616 | //
|
|---|
| 617 | // The types are the following:
|
|---|
| 618 | // 0: MBadPixelsPix::GetInfo()[0]
|
|---|
| 619 | // 1: MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableRun)
|
|---|
| 620 | // 2: MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableEvt)
|
|---|
| 621 | // 3: MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnreliableRun)
|
|---|
| 622 | // 4: MBadPixelsPix::IsHiGainBad()
|
|---|
| 623 | // 5: MBadPixelsPix::IsLoGainBad()
|
|---|
| 624 | // 6: MBadPixelsPix::GetUnsuitableCalLevel()
|
|---|
| 625 | // 7: MBadPixelsPix::GetUnreliableCalLevel()
|
|---|
| 626 | // 8: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainNotFitted)
|
|---|
| 627 | // 9: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainNotFitted)
|
|---|
| 628 | // 10: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainOscillating)
|
|---|
| 629 | // 11: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainOscillating)
|
|---|
| 630 | // 12: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainSaturation )
|
|---|
| 631 | // 13: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeIsPedestal )
|
|---|
| 632 | // 14: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeErrNotValid)
|
|---|
| 633 | // 15: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeRelErrNotValid)
|
|---|
| 634 | // 16: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid )
|
|---|
| 635 | // 17: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin )
|
|---|
| 636 | // 18: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins )
|
|---|
| 637 | // 19: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kDeviatingNumPhes )
|
|---|
| 638 | // 20: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kRelTimeNotFitted )
|
|---|
| 639 | // 21: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kRelTimeOscillating )
|
|---|
| 640 | // 22: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kDeviatingNumPhots )
|
|---|
| 641 | // 23: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainOverFlow )
|
|---|
| 642 | // 24: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainOverFlow )
|
|---|
| 643 | // 102: MBadPixelsPix::IsUnsuitable()
|
|---|
| 644 | //
|
|---|
| 645 | Bool_t MBadPixelsCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
|---|
| 646 | {
|
|---|
| 647 |
|
|---|
| 648 | if (idx >= GetSize())
|
|---|
| 649 | return kFALSE;
|
|---|
| 650 |
|
|---|
| 651 | switch (type)
|
|---|
| 652 | {
|
|---|
| 653 | case 0:
|
|---|
| 654 | return (*this)[idx].GetInfo()[0];
|
|---|
| 655 | case 1:
|
|---|
| 656 | if (!(*this)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
|---|
| 657 | return kFALSE;
|
|---|
| 658 | val = 1;
|
|---|
| 659 | break;
|
|---|
| 660 | case 2:
|
|---|
| 661 | if (!(*this)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableEvt))
|
|---|
| 662 | return kFALSE;
|
|---|
| 663 | val = 1;
|
|---|
| 664 | break;
|
|---|
| 665 | case 3:
|
|---|
| 666 | if (!(*this)[idx].IsUnsuitable(MBadPixelsPix::kUnreliableRun))
|
|---|
| 667 | return kFALSE;
|
|---|
| 668 | val = 1;
|
|---|
| 669 | break;
|
|---|
| 670 | case 4:
|
|---|
| 671 | if (!(*this)[idx].IsHiGainBad())
|
|---|
| 672 | return kFALSE;
|
|---|
| 673 | val = 1;
|
|---|
| 674 | break;
|
|---|
| 675 | case 5:
|
|---|
| 676 | if (!(*this)[idx].IsLoGainBad())
|
|---|
| 677 | return kFALSE;
|
|---|
| 678 | val = 1;
|
|---|
| 679 | break;
|
|---|
| 680 | case 6:
|
|---|
| 681 | if (!(*this)[idx].GetUnsuitableCalLevel())
|
|---|
| 682 | return kFALSE;
|
|---|
| 683 | val = (*this)[idx].GetUnsuitableCalLevel();
|
|---|
| 684 | break;
|
|---|
| 685 | case 7:
|
|---|
| 686 | if (!(*this)[idx].GetUnreliableCalLevel())
|
|---|
| 687 | return kFALSE;
|
|---|
| 688 | val = (*this)[idx].GetUnreliableCalLevel();
|
|---|
| 689 | break;
|
|---|
| 690 | case 8:
|
|---|
| 691 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainNotFitted))
|
|---|
| 692 | return kFALSE;
|
|---|
| 693 | val = 1;
|
|---|
| 694 | break;
|
|---|
| 695 | case 9:
|
|---|
| 696 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainNotFitted))
|
|---|
| 697 | return kFALSE;
|
|---|
| 698 | val = 1;
|
|---|
| 699 | break;
|
|---|
| 700 | case 10:
|
|---|
| 701 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainOscillating))
|
|---|
| 702 | return kFALSE;
|
|---|
| 703 | val = 1;
|
|---|
| 704 | break;
|
|---|
| 705 | case 11:
|
|---|
| 706 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainOscillating))
|
|---|
| 707 | return kFALSE;
|
|---|
| 708 | val = 1;
|
|---|
| 709 | break;
|
|---|
| 710 | case 12:
|
|---|
| 711 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainSaturation ))
|
|---|
| 712 | return kFALSE;
|
|---|
| 713 | val = 1;
|
|---|
| 714 | break;
|
|---|
| 715 | case 13:
|
|---|
| 716 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeIsPedestal ))
|
|---|
| 717 | return kFALSE;
|
|---|
| 718 | val = 1;
|
|---|
| 719 | break;
|
|---|
| 720 | case 14:
|
|---|
| 721 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeErrNotValid))
|
|---|
| 722 | return kFALSE;
|
|---|
| 723 | val = 1;
|
|---|
| 724 | break;
|
|---|
| 725 | case 15:
|
|---|
| 726 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeRelErrNotValid))
|
|---|
| 727 | return kFALSE;
|
|---|
| 728 | val = 1;
|
|---|
| 729 | break;
|
|---|
| 730 | case 16:
|
|---|
| 731 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid ))
|
|---|
| 732 | return kFALSE;
|
|---|
| 733 | val = 1;
|
|---|
| 734 | break;
|
|---|
| 735 | case 17:
|
|---|
| 736 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin ))
|
|---|
| 737 | return kFALSE;
|
|---|
| 738 | val = 1;
|
|---|
| 739 | break;
|
|---|
| 740 | case 18:
|
|---|
| 741 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins ))
|
|---|
| 742 | return kFALSE;
|
|---|
| 743 | val = 1;
|
|---|
| 744 | break;
|
|---|
| 745 | case 19:
|
|---|
| 746 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kDeviatingNumPhes ))
|
|---|
| 747 | return kFALSE;
|
|---|
| 748 | val = 1;
|
|---|
| 749 | break;
|
|---|
| 750 | case 20:
|
|---|
| 751 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kRelTimeNotFitted ))
|
|---|
| 752 | return kFALSE;
|
|---|
| 753 | val = 1;
|
|---|
| 754 | break;
|
|---|
| 755 | case 21:
|
|---|
| 756 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kRelTimeOscillating))
|
|---|
| 757 | return kFALSE;
|
|---|
| 758 | val = 1;
|
|---|
| 759 | break;
|
|---|
| 760 | case 22:
|
|---|
| 761 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kDeviatingNumPhots))
|
|---|
| 762 | return kFALSE;
|
|---|
| 763 | val = 1;
|
|---|
| 764 | break;
|
|---|
| 765 | case 23:
|
|---|
| 766 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainOverFlow ))
|
|---|
| 767 | return kFALSE;
|
|---|
| 768 | val = 1;
|
|---|
| 769 | break;
|
|---|
| 770 | case 24:
|
|---|
| 771 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainOverFlow ))
|
|---|
| 772 | return kFALSE;
|
|---|
| 773 | val = 1;
|
|---|
| 774 | break;
|
|---|
| 775 | case 102:
|
|---|
| 776 | if (!(*this)[idx].IsUnsuitable())
|
|---|
| 777 | return kFALSE;
|
|---|
| 778 | val = 1;
|
|---|
| 779 | break;
|
|---|
| 780 | default:
|
|---|
| 781 | return kFALSE;
|
|---|
| 782 | }
|
|---|
| 783 |
|
|---|
| 784 | return kTRUE;
|
|---|
| 785 | }
|
|---|
| 786 |
|
|---|
| 787 | void MBadPixelsCam::DrawPixelContent(Int_t num) const
|
|---|
| 788 | {
|
|---|
| 789 | *fLog << warn << "MBadPixelsCam::DrawPixelContent - not available." << endl;
|
|---|
| 790 | }
|
|---|