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