| 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, 03/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2007
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MSignalCam
|
|---|
| 28 | //
|
|---|
| 29 | // Class Version 1:
|
|---|
| 30 | // ----------------
|
|---|
| 31 | // - first version
|
|---|
| 32 | //
|
|---|
| 33 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 34 | #include "MSignalCam.h"
|
|---|
| 35 |
|
|---|
| 36 | #include <math.h>
|
|---|
| 37 | #include <limits.h>
|
|---|
| 38 | #include <fstream>
|
|---|
| 39 |
|
|---|
| 40 | #include <TArrayI.h>
|
|---|
| 41 | #include <TArrayD.h>
|
|---|
| 42 |
|
|---|
| 43 | #include "MLog.h"
|
|---|
| 44 | #include "MLogManip.h"
|
|---|
| 45 |
|
|---|
| 46 | #include "MGeomCam.h"
|
|---|
| 47 | #include "MGeomPix.h"
|
|---|
| 48 |
|
|---|
| 49 | ClassImp(MSignalCam);
|
|---|
| 50 | ClassImp(MSignalCamIter);
|
|---|
| 51 |
|
|---|
| 52 | using namespace std;
|
|---|
| 53 |
|
|---|
| 54 | // --------------------------------------------------------------------------
|
|---|
| 55 | //
|
|---|
| 56 | // Creates a MSignalPix object for each pixel in the event
|
|---|
| 57 | //
|
|---|
| 58 | MSignalCam::MSignalCam(const char *name, const char *title) /*: fNumPixels(0)*/
|
|---|
| 59 | {
|
|---|
| 60 | fName = name ? name : "MSignalCam";
|
|---|
| 61 | fTitle = title ? title : "(Number of Photon)-Event Information";
|
|---|
| 62 |
|
|---|
| 63 | fPixels = new TClonesArray("MSignalPix", 0);
|
|---|
| 64 |
|
|---|
| 65 | Reset();
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | // --------------------------------------------------------------------------
|
|---|
| 69 | //
|
|---|
| 70 | // Copy contants of obj into this instance.
|
|---|
| 71 | //
|
|---|
| 72 | void MSignalCam::Copy(TObject &obj) const
|
|---|
| 73 | {
|
|---|
| 74 | MSignalCam &cam = static_cast<MSignalCam&>(obj);
|
|---|
| 75 |
|
|---|
| 76 | cam.fNumIslands = fNumIslands;
|
|---|
| 77 | cam.fNumSinglePixels = fNumSinglePixels;
|
|---|
| 78 | cam.fSizeSinglePixels = fSizeSinglePixels;
|
|---|
| 79 | cam.fSizeSubIslands = fSizeSubIslands;
|
|---|
| 80 | cam.fSizeMainIsland = fSizeMainIsland;
|
|---|
| 81 |
|
|---|
| 82 | cam.fNumPixelsSaturatedHiGain = fNumPixelsSaturatedHiGain;
|
|---|
| 83 | cam.fNumPixelsSaturatedLoGain = fNumPixelsSaturatedLoGain;
|
|---|
| 84 |
|
|---|
| 85 | cam.fPixels->Delete();
|
|---|
| 86 |
|
|---|
| 87 | const UInt_t n = GetNumPixels();
|
|---|
| 88 |
|
|---|
| 89 | cam.InitSize(n);
|
|---|
| 90 |
|
|---|
| 91 | for (UInt_t i=0; i<n; i++)
|
|---|
| 92 | new ((*cam.fPixels)[i]) MSignalPix((*this)[i]);
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | // --------------------------------------------------------------------------
|
|---|
| 96 | //
|
|---|
| 97 | // reset counter and delete netries in list.
|
|---|
| 98 | //
|
|---|
| 99 | void MSignalCam::Reset()
|
|---|
| 100 | {
|
|---|
| 101 | fNumSinglePixels = 0;
|
|---|
| 102 | fSizeSinglePixels = 0;
|
|---|
| 103 | fSizeSubIslands = 0;
|
|---|
| 104 | fSizeMainIsland = 0;
|
|---|
| 105 | fNumIslands = -1;
|
|---|
| 106 |
|
|---|
| 107 | fNumPixelsSaturatedHiGain = -1;
|
|---|
| 108 | fNumPixelsSaturatedLoGain = -1;
|
|---|
| 109 |
|
|---|
| 110 | fPixels->R__FOR_EACH(TObject, Clear)();
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | // --------------------------------------------------------------------------
|
|---|
| 114 | //
|
|---|
| 115 | // Dump the cerenkov photon event to *fLog
|
|---|
| 116 | //
|
|---|
| 117 | void MSignalCam::Print(Option_t *) const
|
|---|
| 118 | {
|
|---|
| 119 | const Int_t entries = fPixels->GetEntries();
|
|---|
| 120 |
|
|---|
| 121 | *fLog << GetDescriptor() << dec << endl;
|
|---|
| 122 | *fLog << " Number of Pixels: " << GetNumPixels() << "(" << entries << ")" << endl;
|
|---|
| 123 |
|
|---|
| 124 | for (Int_t i=0; i<entries; i++ )
|
|---|
| 125 | (*this)[i].Print();
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | // --------------------------------------------------------------------------
|
|---|
| 129 | //
|
|---|
| 130 | // Count and return the number of unmapped pixels
|
|---|
| 131 | //
|
|---|
| 132 | Int_t MSignalCam::GetNumPixelsUnmapped() const
|
|---|
| 133 | {
|
|---|
| 134 | const UInt_t n = GetNumPixels();
|
|---|
| 135 |
|
|---|
| 136 | if (n <= 0)
|
|---|
| 137 | return -1;
|
|---|
| 138 |
|
|---|
| 139 | Int_t cnt=0;
|
|---|
| 140 | for (UInt_t i=0; i<n; i++)
|
|---|
| 141 | {
|
|---|
| 142 | if ((*this)[i].IsPixelUnmapped())
|
|---|
| 143 | cnt++;
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | return cnt;
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | // --------------------------------------------------------------------------
|
|---|
| 150 | //
|
|---|
| 151 | // get the minimum number of photons of all valid pixels in the list
|
|---|
| 152 | // If you specify a geometry the number of photons is weighted with the
|
|---|
| 153 | // area of the pixel
|
|---|
| 154 | //
|
|---|
| 155 | Float_t MSignalCam::GetNumPhotonsMin(const MGeomCam *geom) const
|
|---|
| 156 | {
|
|---|
| 157 | const UInt_t n = GetNumPixels();
|
|---|
| 158 |
|
|---|
| 159 | if (n <= 0)
|
|---|
| 160 | return -5.;
|
|---|
| 161 |
|
|---|
| 162 | Float_t minval = FLT_MAX;
|
|---|
| 163 |
|
|---|
| 164 | for (UInt_t i=0; i<n; i++)
|
|---|
| 165 | {
|
|---|
| 166 | const MSignalPix &pix = (*this)[i];
|
|---|
| 167 | if (!pix.IsPixelUsed())
|
|---|
| 168 | continue;
|
|---|
| 169 |
|
|---|
| 170 | Float_t testval = pix.GetNumPhotons();
|
|---|
| 171 |
|
|---|
| 172 | if (geom)
|
|---|
| 173 | testval *= geom->GetPixRatio(i);
|
|---|
| 174 |
|
|---|
| 175 | if (testval < minval)
|
|---|
| 176 | minval = testval;
|
|---|
| 177 | }
|
|---|
| 178 |
|
|---|
| 179 | return minval;
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | // --------------------------------------------------------------------------
|
|---|
| 183 | //
|
|---|
| 184 | // get the maximum number of photons of all valid pixels in the list
|
|---|
| 185 | // If you specify a geometry the number of photons is weighted with the
|
|---|
| 186 | // area of the pixel
|
|---|
| 187 | //
|
|---|
| 188 | Float_t MSignalCam::GetNumPhotonsMax(const MGeomCam *geom) const
|
|---|
| 189 | {
|
|---|
| 190 | const UInt_t n = GetNumPixels();
|
|---|
| 191 |
|
|---|
| 192 | if (n <= 0)
|
|---|
| 193 | return 50.;
|
|---|
| 194 |
|
|---|
| 195 | Float_t maxval = -FLT_MAX;
|
|---|
| 196 |
|
|---|
| 197 | for (UInt_t i=0; i<n; i++)
|
|---|
| 198 | {
|
|---|
| 199 | const MSignalPix &pix = (*this)[i];
|
|---|
| 200 | if (!pix.IsPixelUsed())
|
|---|
| 201 | continue;
|
|---|
| 202 |
|
|---|
| 203 | Float_t testval = pix.GetNumPhotons();
|
|---|
| 204 | if (geom)
|
|---|
| 205 | testval *= geom->GetPixRatio(i);
|
|---|
| 206 |
|
|---|
| 207 | if (testval > maxval)
|
|---|
| 208 | maxval = testval;
|
|---|
| 209 | }
|
|---|
| 210 | return maxval;
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 | // --------------------------------------------------------------------------
|
|---|
| 214 | //
|
|---|
| 215 | // get the minimum ratio of photons/error
|
|---|
| 216 | //
|
|---|
| 217 | Float_t MSignalCam::GetRatioMin(const MGeomCam *geom) const
|
|---|
| 218 | {
|
|---|
| 219 | const UInt_t n = GetNumPixels();
|
|---|
| 220 |
|
|---|
| 221 | if (n <= 0)
|
|---|
| 222 | return -5.;
|
|---|
| 223 |
|
|---|
| 224 | Float_t minval = FLT_MAX;
|
|---|
| 225 |
|
|---|
| 226 | for (UInt_t i=0; i<n; i++)
|
|---|
| 227 | {
|
|---|
| 228 | const MSignalPix &pix = (*this)[i];
|
|---|
| 229 | if (!pix.IsPixelUsed())
|
|---|
| 230 | continue;
|
|---|
| 231 |
|
|---|
| 232 | Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
|
|---|
| 233 | if (geom)
|
|---|
| 234 | testval *= geom->GetPixRatioSqrt(i);
|
|---|
| 235 |
|
|---|
| 236 | if (testval < minval)
|
|---|
| 237 | minval = testval;
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 | return minval;
|
|---|
| 241 | }
|
|---|
| 242 |
|
|---|
| 243 | // --------------------------------------------------------------------------
|
|---|
| 244 | //
|
|---|
| 245 | // get the maximum ratio of photons/error
|
|---|
| 246 | //
|
|---|
| 247 | Float_t MSignalCam::GetRatioMax(const MGeomCam *geom) const
|
|---|
| 248 | {
|
|---|
| 249 | const UInt_t n = GetNumPixels();
|
|---|
| 250 |
|
|---|
| 251 | if (n <= 0)
|
|---|
| 252 | return -5.;
|
|---|
| 253 |
|
|---|
| 254 | Float_t maxval = -FLT_MAX;
|
|---|
| 255 |
|
|---|
| 256 | for (UInt_t i=0; i<n; i++)
|
|---|
| 257 | {
|
|---|
| 258 | const MSignalPix &pix = (*this)[i];
|
|---|
| 259 | if (!pix.IsPixelUsed())
|
|---|
| 260 | continue;
|
|---|
| 261 |
|
|---|
| 262 | Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
|
|---|
| 263 | if (geom)
|
|---|
| 264 | testval *= geom->GetPixRatioSqrt(i);
|
|---|
| 265 |
|
|---|
| 266 | if (testval > maxval)
|
|---|
| 267 | maxval = testval;
|
|---|
| 268 | }
|
|---|
| 269 |
|
|---|
| 270 | return maxval;
|
|---|
| 271 | }
|
|---|
| 272 |
|
|---|
| 273 | // --------------------------------------------------------------------------
|
|---|
| 274 | //
|
|---|
| 275 | // get the minimum of error
|
|---|
| 276 | // If you specify a geometry the number of photons is weighted with the
|
|---|
| 277 | // area of the pixel
|
|---|
| 278 | //
|
|---|
| 279 | Float_t MSignalCam::GetErrorPhotMin(const MGeomCam *geom) const
|
|---|
| 280 | {
|
|---|
| 281 | const UInt_t n = GetNumPixels();
|
|---|
| 282 |
|
|---|
| 283 | if (n <= 0)
|
|---|
| 284 | return 50.;
|
|---|
| 285 |
|
|---|
| 286 | Float_t minval = FLT_MAX;
|
|---|
| 287 |
|
|---|
| 288 | for (UInt_t i=0; i<n; i++)
|
|---|
| 289 | {
|
|---|
| 290 | const MSignalPix &pix = (*this)[i];
|
|---|
| 291 | if (!pix.IsPixelUsed())
|
|---|
| 292 | continue;
|
|---|
| 293 |
|
|---|
| 294 | Float_t testval = pix.GetErrorPhot();
|
|---|
| 295 |
|
|---|
| 296 | if (geom)
|
|---|
| 297 | testval *= geom->GetPixRatio(i);
|
|---|
| 298 |
|
|---|
| 299 | if (testval < minval)
|
|---|
| 300 | minval = testval;
|
|---|
| 301 | }
|
|---|
| 302 | return minval;
|
|---|
| 303 | }
|
|---|
| 304 |
|
|---|
| 305 | // --------------------------------------------------------------------------
|
|---|
| 306 | //
|
|---|
| 307 | // get the maximum ratio of photons/error
|
|---|
| 308 | // If you specify a geometry the number of photons is weighted with the
|
|---|
| 309 | // area of the pixel
|
|---|
| 310 | //
|
|---|
| 311 | Float_t MSignalCam::GetErrorPhotMax(const MGeomCam *geom) const
|
|---|
| 312 | {
|
|---|
| 313 | const UInt_t n = GetNumPixels();
|
|---|
| 314 |
|
|---|
| 315 | if (n <= 0)
|
|---|
| 316 | return 50.;
|
|---|
| 317 |
|
|---|
| 318 | Float_t maxval = -FLT_MAX;
|
|---|
| 319 |
|
|---|
| 320 | for (UInt_t i=0; i<n; i++)
|
|---|
| 321 | {
|
|---|
| 322 | const MSignalPix &pix = (*this)[i];
|
|---|
| 323 | if (!pix.IsPixelUsed())
|
|---|
| 324 | continue;
|
|---|
| 325 |
|
|---|
| 326 | Float_t testval = pix.GetErrorPhot();
|
|---|
| 327 |
|
|---|
| 328 | if (geom)
|
|---|
| 329 | testval *= geom->GetPixRatio(i);
|
|---|
| 330 |
|
|---|
| 331 | if (testval > maxval)
|
|---|
| 332 | maxval = testval;
|
|---|
| 333 | }
|
|---|
| 334 | return maxval;
|
|---|
| 335 | }
|
|---|
| 336 |
|
|---|
| 337 | MSignalPix *MSignalCam::AddPixel(Int_t idx, Float_t nph, Float_t er)
|
|---|
| 338 | {
|
|---|
| 339 | MSignalPix *pix = static_cast<MSignalPix*>((*fPixels)[idx]);
|
|---|
| 340 | pix->Set(nph, er);
|
|---|
| 341 | return pix;
|
|---|
| 342 | }
|
|---|
| 343 |
|
|---|
| 344 | // --------------------------------------------------------------------------
|
|---|
| 345 | //
|
|---|
| 346 | // This function recursively finds all pixels of one island and assigns
|
|---|
| 347 | // the number num as island number to the pixel.
|
|---|
| 348 | //
|
|---|
| 349 | // 1) Check whether a pixel with the index idx exists, is unused
|
|---|
| 350 | // and has not yet a island number assigned.
|
|---|
| 351 | // 2) Assign the island number num to the pixel
|
|---|
| 352 | // 3) Loop over all its neighbors taken from the geometry geom. For all
|
|---|
| 353 | // neighbors recursively call this function (CalcIsland)
|
|---|
| 354 | // 4) Sum the size of the pixel and all neighbors newly assigned
|
|---|
| 355 | // (by CalcIsland) to this island
|
|---|
| 356 | //
|
|---|
| 357 | // Returns the sum of the pixel size.
|
|---|
| 358 | //
|
|---|
| 359 | Double_t MSignalCam::CalcIsland(const MGeomCam &geom, Int_t idx, Int_t num)
|
|---|
| 360 | {
|
|---|
| 361 | // Get the pixel information of a pixel with this index
|
|---|
| 362 | MSignalPix &pix = (*this)[idx];
|
|---|
| 363 |
|
|---|
| 364 | // If an island number was already assigned to this pixel... do nothing.
|
|---|
| 365 | if (pix.GetIdxIsland()>=0)
|
|---|
| 366 | return 0;
|
|---|
| 367 |
|
|---|
| 368 | // If the pixel is an unused pixel... do nothing.
|
|---|
| 369 | if (!pix.IsPixelUsed())
|
|---|
| 370 | return 0;
|
|---|
| 371 |
|
|---|
| 372 | // Assign the new island number num to this used pixel
|
|---|
| 373 | pix.SetIdxIsland(num);
|
|---|
| 374 |
|
|---|
| 375 | // Get the geometry information (neighbors) of this pixel
|
|---|
| 376 | const MGeomPix &gpix = geom[idx];
|
|---|
| 377 |
|
|---|
| 378 | // Get the size of this pixel
|
|---|
| 379 | Double_t size = pix.GetNumPhotons();
|
|---|
| 380 |
|
|---|
| 381 | // Now do the same with all its neighbors and sum the
|
|---|
| 382 | // sizes which they correspond to
|
|---|
| 383 | const Int_t n = gpix.GetNumNeighbors();
|
|---|
| 384 | for (int i=0; i<n; i++)
|
|---|
| 385 | size += CalcIsland(geom, gpix.GetNeighbor(i), num);
|
|---|
| 386 |
|
|---|
| 387 | // return size of this (sub)cluster
|
|---|
| 388 | return size;
|
|---|
| 389 | }
|
|---|
| 390 |
|
|---|
| 391 | // --------------------------------------------------------------------------
|
|---|
| 392 | //
|
|---|
| 393 | // Each pixel which is maked as used is assigned an island number
|
|---|
| 394 | // (starting from 0). A pixel without an island number assigned
|
|---|
| 395 | // has island number -1.
|
|---|
| 396 | //
|
|---|
| 397 | // The index 0 corresponds to the island with the highest size (sum
|
|---|
| 398 | // of GetNumPhotons() in island). The size is decreasing with
|
|---|
| 399 | // increasing indices.
|
|---|
| 400 | //
|
|---|
| 401 | // The information about pixel neighbory is taken from the geometry
|
|---|
| 402 | // MGeomCam geom;
|
|---|
| 403 | //
|
|---|
| 404 | // You can access this island number of a pixel with a call to
|
|---|
| 405 | // MSignalPix->GetIdxIsland. The total number of islands available
|
|---|
| 406 | // can be accessed with MSignalCam->GetNumIslands.
|
|---|
| 407 | //
|
|---|
| 408 | // CalcIslands returns the number of islands found. If an error occurs,
|
|---|
| 409 | // eg the geometry has less pixels than the highest index stored, -1 is
|
|---|
| 410 | // returned.
|
|---|
| 411 | //
|
|---|
| 412 | Int_t MSignalCam::CalcIslands(const MGeomCam &geom)
|
|---|
| 413 | {
|
|---|
| 414 | const UInt_t numpix = GetNumPixels();
|
|---|
| 415 |
|
|---|
| 416 | if (/*fMaxIndex<0 ||*/ numpix==0)
|
|---|
| 417 | {
|
|---|
| 418 | *fLog << err << "ERROR - MSignalCam doesn't contain pixels!" << endl;
|
|---|
| 419 | fNumIslands = 0;
|
|---|
| 420 | return -1;
|
|---|
| 421 | }
|
|---|
| 422 | /*
|
|---|
| 423 | if ((UInt_t)fMaxIndex>=geom.GetNumPixels())
|
|---|
| 424 | {
|
|---|
| 425 | *fLog << err << "ERROR - MSignalCam::CalcIslands: Size mismatch - geometry too small!" << endl;
|
|---|
| 426 | return -1;
|
|---|
| 427 | }
|
|---|
| 428 | */
|
|---|
| 429 | // Create a list to hold the sizes of the islands (The maximum
|
|---|
| 430 | // number of islands possible is roughly fNumPixels/4)
|
|---|
| 431 | TArrayD size(numpix/3);
|
|---|
| 432 |
|
|---|
| 433 | // Calculate Islands
|
|---|
| 434 | Int_t n=0;
|
|---|
| 435 | Float_t totsize = 0;
|
|---|
| 436 |
|
|---|
| 437 | for (UInt_t idx=0; idx<numpix; idx++)
|
|---|
| 438 | {
|
|---|
| 439 | const MSignalPix &pix = (*this)[idx];
|
|---|
| 440 | if (!pix.IsPixelUsed())
|
|---|
| 441 | continue;
|
|---|
| 442 |
|
|---|
| 443 | // This 'if' is necessary (although it is done in GetIsland, too)
|
|---|
| 444 | // because otherwise the counter (n) would be wrong.
|
|---|
| 445 | // So only 'start' a new island for used pixels (selected by
|
|---|
| 446 | // using the Iterator) which do not yet belong to another island.
|
|---|
| 447 | if (pix.GetIdxIsland()<0)
|
|---|
| 448 | {
|
|---|
| 449 | // Don't put this in one line! n is used twice...
|
|---|
| 450 | const Double_t sz = CalcIsland(geom, idx/*pix->GetPixId()*/, n);
|
|---|
| 451 | size[n++] = sz;
|
|---|
| 452 | totsize += sz;
|
|---|
| 453 | }
|
|---|
| 454 | }
|
|---|
| 455 |
|
|---|
| 456 | // Create an array holding the indices
|
|---|
| 457 | TArrayI idxarr(n);
|
|---|
| 458 |
|
|---|
| 459 | // Sort the sizes descending
|
|---|
| 460 | TMath::Sort(n, size.GetArray(), idxarr.GetArray(), kTRUE);
|
|---|
| 461 |
|
|---|
| 462 | // Replace island numbers by size indices -- After this
|
|---|
| 463 | // islands indices are sorted by the island size
|
|---|
| 464 | for (UInt_t idx=0; idx<numpix; idx++)
|
|---|
| 465 | {
|
|---|
| 466 | MSignalPix &pix = (*this)[idx];
|
|---|
| 467 | if (!pix.IsPixelUsed())
|
|---|
| 468 | continue;
|
|---|
| 469 |
|
|---|
| 470 | const Short_t i = pix.GetIdxIsland();
|
|---|
| 471 |
|
|---|
| 472 | // Find new index
|
|---|
| 473 | Short_t j;
|
|---|
| 474 | for (j=0; j<n; j++)
|
|---|
| 475 | if (idxarr[j]==i)
|
|---|
| 476 | break;
|
|---|
| 477 |
|
|---|
| 478 | pix.SetIdxIsland(j==n ? -1 : j);
|
|---|
| 479 | }
|
|---|
| 480 |
|
|---|
| 481 | // Now assign number of islands found
|
|---|
| 482 | fNumIslands = n;
|
|---|
| 483 | fSizeSubIslands = n>0 ? totsize-size[idxarr[0]] : 0;
|
|---|
| 484 | fSizeMainIsland = n>0 ? size[idxarr[0]] : 0;
|
|---|
| 485 |
|
|---|
| 486 | // return number of island
|
|---|
| 487 | return fNumIslands;
|
|---|
| 488 | }
|
|---|
| 489 |
|
|---|
| 490 | // --------------------------------------------------------------------------
|
|---|
| 491 | //
|
|---|
| 492 | // Compares the cleaning (fRing and fIsCore) of this object and the
|
|---|
| 493 | // argument. Return the result (kFALSE if different).
|
|---|
| 494 | //
|
|---|
| 495 | // If differences are found the pixels (the pixel from this object first)
|
|---|
| 496 | // is printed.
|
|---|
| 497 | //
|
|---|
| 498 | Bool_t MSignalCam::CompareCleaning(const MSignalCam &cam) const
|
|---|
| 499 | {
|
|---|
| 500 | const UInt_t n = GetNumPixels();
|
|---|
| 501 |
|
|---|
| 502 | if (n != cam.GetNumPixels())
|
|---|
| 503 | {
|
|---|
| 504 | *fLog << warn << "MSignalCam::CompareCleaning - Number of pixels mismatch." << endl;
|
|---|
| 505 | return kFALSE;
|
|---|
| 506 | }
|
|---|
| 507 |
|
|---|
| 508 | for (UInt_t i=0; i<n; i++)
|
|---|
| 509 | {
|
|---|
| 510 | const MSignalPix &p = (*this)[i];
|
|---|
| 511 | const MSignalPix &q = cam[i];
|
|---|
| 512 |
|
|---|
| 513 | if (p.GetRing()==q.GetRing() && p.IsPixelCore()==q.IsPixelCore())
|
|---|
| 514 | continue;
|
|---|
| 515 |
|
|---|
| 516 | *fLog << warn << "MSignalCam::CompareCleaning - Pixel #" << i << " mismatch." << endl;
|
|---|
| 517 | p.Print();
|
|---|
| 518 | q.Print();
|
|---|
| 519 | return kFALSE;
|
|---|
| 520 | }
|
|---|
| 521 | return kTRUE;
|
|---|
| 522 | }
|
|---|
| 523 |
|
|---|
| 524 | // --------------------------------------------------------------------------
|
|---|
| 525 | //
|
|---|
| 526 | // Compares the islands (fIdxIsland) of this object and the
|
|---|
| 527 | // argument. Return the result (kFALSE if different).
|
|---|
| 528 | //
|
|---|
| 529 | // If differences are found the pixels (the pixel from this object first)
|
|---|
| 530 | // is printed.
|
|---|
| 531 | //
|
|---|
| 532 | Bool_t MSignalCam::CompareIslands(const MSignalCam &cam) const
|
|---|
| 533 | {
|
|---|
| 534 | const UInt_t n = GetNumPixels();
|
|---|
| 535 |
|
|---|
| 536 | if (n != cam.GetNumPixels())
|
|---|
| 537 | {
|
|---|
| 538 | *fLog << warn << "MSignalCam::CompareIslands - Number of pixels mismatch." << endl;
|
|---|
| 539 | return kFALSE;
|
|---|
| 540 | }
|
|---|
| 541 |
|
|---|
| 542 | for (UInt_t i=0; i<n; i++)
|
|---|
| 543 | {
|
|---|
| 544 | const MSignalPix &p = (*this)[i];
|
|---|
| 545 | const MSignalPix &q = cam[i];
|
|---|
| 546 |
|
|---|
| 547 | if (p.GetIdxIsland()==q.GetIdxIsland())
|
|---|
| 548 | continue;
|
|---|
| 549 |
|
|---|
| 550 | *fLog << warn << "MSignalCam::CompareIslands - Pixel #" << i << " mismatch." << endl;
|
|---|
| 551 | p.Print();
|
|---|
| 552 | q.Print();
|
|---|
| 553 | return kFALSE;
|
|---|
| 554 | }
|
|---|
| 555 |
|
|---|
| 556 | return kTRUE;
|
|---|
| 557 | }
|
|---|
| 558 |
|
|---|
| 559 | // --------------------------------------------------------------------------
|
|---|
| 560 | //
|
|---|
| 561 | // Returns, depending on the type flag:
|
|---|
| 562 | //
|
|---|
| 563 | // 0: Number of Photons*PixRatio <default>
|
|---|
| 564 | // 1: Error*sqrt(PixRatio)
|
|---|
| 565 | // 2: Cleaning level = Num Photons*sqrt(PixRatio)/Error
|
|---|
| 566 | // 3: Number of Photons
|
|---|
| 567 | // 4: Error
|
|---|
| 568 | // 5: Island index
|
|---|
| 569 | // 6: arrival time of mapped pixels
|
|---|
| 570 | // 7: arrival time if signa avove 20phe
|
|---|
| 571 | // 8: arrival time
|
|---|
| 572 | // 10: arrival time if extracted from lo-gain
|
|---|
| 573 | // 11: arrival time if extracted from hi-gain (and signal above 20phe)
|
|---|
| 574 | //
|
|---|
| 575 | Bool_t MSignalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
|---|
| 576 | {
|
|---|
| 577 | if (idx<0 || (UInt_t)idx>GetNumPixels())
|
|---|
| 578 | return kFALSE;
|
|---|
| 579 |
|
|---|
| 580 | const MSignalPix &pix = (*this)[idx];
|
|---|
| 581 |
|
|---|
| 582 | // Used inlcudes status unampped
|
|---|
| 583 | if (!pix.IsPixelUsed() && (type<6 || type==8))
|
|---|
| 584 | return kFALSE;
|
|---|
| 585 |
|
|---|
| 586 | const Double_t ratio = cam.GetPixRatio(idx);
|
|---|
| 587 |
|
|---|
| 588 | switch (type)
|
|---|
| 589 | {
|
|---|
| 590 | case 1: // scaled error of phtoons
|
|---|
| 591 | val = pix.GetErrorPhot()*TMath::Sqrt(ratio);
|
|---|
| 592 | return kTRUE;
|
|---|
| 593 |
|
|---|
| 594 | case 2: // significance of number of photons
|
|---|
| 595 | if (pix.GetErrorPhot()<=0)
|
|---|
| 596 | return kFALSE;
|
|---|
| 597 | val = pix.GetNumPhotons()*TMath::Sqrt(ratio)/pix.GetErrorPhot();
|
|---|
| 598 | return kTRUE;
|
|---|
| 599 |
|
|---|
| 600 | case 3: // number of photo electrons
|
|---|
| 601 | val = pix.GetNumPhotons();
|
|---|
| 602 | break;
|
|---|
| 603 |
|
|---|
| 604 | case 4: // error of signal
|
|---|
| 605 | val = pix.GetErrorPhot();
|
|---|
| 606 | break;
|
|---|
| 607 |
|
|---|
| 608 | case 5: // index of island
|
|---|
| 609 | val = pix.GetIdxIsland();
|
|---|
| 610 | break;
|
|---|
| 611 |
|
|---|
| 612 | case 6: // arrival time of mapped pixels only
|
|---|
| 613 | if (pix.IsPixelUnmapped())
|
|---|
| 614 | return kFALSE;
|
|---|
| 615 | val = pix.GetArrivalTime();
|
|---|
| 616 | break;
|
|---|
| 617 |
|
|---|
| 618 | case 7: // pulse position above 50phe
|
|---|
| 619 | // The number of photons is not scaled with the ratio because
|
|---|
| 620 | // otherwise to many large pixels survive (maybe because the
|
|---|
| 621 | // fluctuations scale different than expected)
|
|---|
| 622 | if (pix.IsPixelUnmapped() || pix.GetNumPhotons()<50)
|
|---|
| 623 | return kFALSE;
|
|---|
| 624 | val = pix.GetArrivalTime();
|
|---|
| 625 | break;
|
|---|
| 626 |
|
|---|
| 627 | case 8: // arrival time
|
|---|
| 628 | val = pix.GetArrivalTime();
|
|---|
| 629 | break;
|
|---|
| 630 |
|
|---|
| 631 | /*
|
|---|
| 632 | case 10: // lo gain time
|
|---|
| 633 | if (pix.IsPixelUnmapped() || !pix.IsLoGainUsed() ||
|
|---|
| 634 | pix.GetNumPhotons()<320)
|
|---|
| 635 | return kFALSE;
|
|---|
| 636 | val = pix.GetArrivalTime();
|
|---|
| 637 | return kTRUE;
|
|---|
| 638 |
|
|---|
| 639 | case 11: // hi gain time
|
|---|
| 640 | // The number of photons is not scaled with the ratio because
|
|---|
| 641 | // otherwise to many large pixels survive (maybe because the
|
|---|
| 642 | // fluctuations scale different than expected)
|
|---|
| 643 | if (pix.IsPixelUnmapped() || pix.IsLoGainUsed() ||
|
|---|
| 644 | pix.GetNumPhotons()<50)
|
|---|
| 645 | return kFALSE;
|
|---|
| 646 | val = pix.GetArrivalTime();
|
|---|
| 647 | return kTRUE;
|
|---|
| 648 | */
|
|---|
| 649 |
|
|---|
| 650 | default:
|
|---|
| 651 | val = pix.GetNumPhotons()*ratio;
|
|---|
| 652 | return kTRUE;
|
|---|
| 653 | }
|
|---|
| 654 | return kTRUE;
|
|---|
| 655 | }
|
|---|
| 656 |
|
|---|
| 657 | void MSignalCam::DrawPixelContent(Int_t num) const
|
|---|
| 658 | {
|
|---|
| 659 | *fLog << warn << "MSignalCam::DrawPixelContent - not available." << endl;
|
|---|
| 660 | }
|
|---|
| 661 |
|
|---|
| 662 | TObject *MSignalCamIter::Next()
|
|---|
| 663 | {
|
|---|
| 664 | if (!fUsedOnly)
|
|---|
| 665 | {
|
|---|
| 666 | fIdx++;
|
|---|
| 667 | return TObjArrayIter::Next();
|
|---|
| 668 | }
|
|---|
| 669 |
|
|---|
| 670 | MSignalPix *pix;
|
|---|
| 671 | while ((pix = (MSignalPix*)TObjArrayIter::Next()))
|
|---|
| 672 | {
|
|---|
| 673 | fIdx++;
|
|---|
| 674 | if (pix->IsPixelUsed())
|
|---|
| 675 | return pix;
|
|---|
| 676 | }
|
|---|
| 677 | return pix;
|
|---|
| 678 | }
|
|---|