| 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 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | ! Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es>
|
|---|
| 20 | ! Author(s): Florian Goebel 06/2004 <mailto:fgoebel@mppmu.mpg.de>
|
|---|
| 21 | !
|
|---|
| 22 | ! Copyright: MAGIC Software Development, 2000-2007
|
|---|
| 23 | !
|
|---|
| 24 | !
|
|---|
| 25 | \* ======================================================================== */
|
|---|
| 26 |
|
|---|
| 27 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 28 | //
|
|---|
| 29 | // MPedestalCam
|
|---|
| 30 | //
|
|---|
| 31 | // Hold the Pedestal information for all pixels in the camera
|
|---|
| 32 | //
|
|---|
| 33 | // Class Version 2:
|
|---|
| 34 | // ----------------
|
|---|
| 35 | // + fNumSlices
|
|---|
| 36 | // - fTotalEntries
|
|---|
| 37 | //
|
|---|
| 38 | // Class Version 3:
|
|---|
| 39 | // ----------------
|
|---|
| 40 | // + fNumEvents
|
|---|
| 41 | //
|
|---|
| 42 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 43 | #include "MPedestalCam.h"
|
|---|
| 44 | #include "MPedestalPix.h"
|
|---|
| 45 |
|
|---|
| 46 | #include <TArrayI.h>
|
|---|
| 47 | #include <TArrayF.h>
|
|---|
| 48 | #include <TArrayD.h>
|
|---|
| 49 |
|
|---|
| 50 | #include <TClonesArray.h>
|
|---|
| 51 |
|
|---|
| 52 | #include "MLog.h"
|
|---|
| 53 | #include "MLogManip.h"
|
|---|
| 54 |
|
|---|
| 55 | #include "MParList.h"
|
|---|
| 56 |
|
|---|
| 57 | #include "MGeomCam.h"
|
|---|
| 58 | #include "MGeomPix.h"
|
|---|
| 59 |
|
|---|
| 60 | #include "MBadPixelsCam.h"
|
|---|
| 61 | #include "MBadPixelsPix.h"
|
|---|
| 62 |
|
|---|
| 63 | ClassImp(MPedestalCam);
|
|---|
| 64 |
|
|---|
| 65 | using namespace std;
|
|---|
| 66 |
|
|---|
| 67 | // --------------------------------------------------------------------------
|
|---|
| 68 | //
|
|---|
| 69 | // Default constructor.
|
|---|
| 70 | //
|
|---|
| 71 | // Creates a TClonesArray of MPedestalPix containers, initialized to 1 entry, destinated
|
|---|
| 72 | // to hold one container per pixel. Later, a call to MPedestalCam::InitSize()
|
|---|
| 73 | // has to be performed (in MGeomApply).
|
|---|
| 74 | //
|
|---|
| 75 | // Creates a TClonesArray of MPedestalPix containers, initialized to 1 entry, destinated
|
|---|
| 76 | // to hold one container per pixel AREA. Later, a call to MPedestalCam::InitAreas()
|
|---|
| 77 | // has to be performed (in MGeomApply).
|
|---|
| 78 | //
|
|---|
| 79 | // Creates a TClonesArray of MPedestalPix containers, initialized to 1 entry, destinated
|
|---|
| 80 | // to hold one container per camera SECTOR. Later, a call to MPedestalCam::InitSectors()
|
|---|
| 81 | // has to be performed (in MGeomApply).
|
|---|
| 82 | //
|
|---|
| 83 | MPedestalCam::MPedestalCam(const char *name, const char *title)
|
|---|
| 84 | : fNumSlices(0), fNumEvents(0)
|
|---|
| 85 | {
|
|---|
| 86 | fName = name ? name : "MPedestalCam";
|
|---|
| 87 | fTitle = title ? title : "Storage container for all Pedestal Information in the camera";
|
|---|
| 88 |
|
|---|
| 89 | fArray = new TClonesArray("MPedestalPix", 1);
|
|---|
| 90 | fAverageAreas = new TClonesArray("MPedestalPix", 1);
|
|---|
| 91 | fAverageSectors = new TClonesArray("MPedestalPix", 1);
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | // --------------------------------------------------------------------------
|
|---|
| 95 | //
|
|---|
| 96 | // Deletes the following TClonesArray's of MPedestalPix containers (if exist):
|
|---|
| 97 | // - fArray
|
|---|
| 98 | // - fAverageAreas
|
|---|
| 99 | // - fAverageSectors
|
|---|
| 100 | //
|
|---|
| 101 | MPedestalCam::~MPedestalCam()
|
|---|
| 102 | {
|
|---|
| 103 | delete fArray;
|
|---|
| 104 | delete fAverageAreas;
|
|---|
| 105 | delete fAverageSectors;
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | // --------------------------------------------------------------------------
|
|---|
| 109 | //
|
|---|
| 110 | // Copy 'constructor'
|
|---|
| 111 | //
|
|---|
| 112 | void MPedestalCam::Copy(TObject &obj) const
|
|---|
| 113 | {
|
|---|
| 114 |
|
|---|
| 115 | MParContainer::Copy(obj);
|
|---|
| 116 |
|
|---|
| 117 | MPedestalCam &cam = (MPedestalCam&)obj;
|
|---|
| 118 |
|
|---|
| 119 | Int_t n = GetSize();
|
|---|
| 120 |
|
|---|
| 121 | if (n==0)
|
|---|
| 122 | return;
|
|---|
| 123 |
|
|---|
| 124 | cam.InitSize(n);
|
|---|
| 125 | for (int i=0; i<n; i++)
|
|---|
| 126 | (*this)[i].Copy(cam[i]);
|
|---|
| 127 |
|
|---|
| 128 | cam.fNumEvents = fNumEvents;
|
|---|
| 129 | cam.fNumSlices = fNumSlices;
|
|---|
| 130 |
|
|---|
| 131 | n = GetNumAverageArea();
|
|---|
| 132 | cam.InitAverageAreas(n);
|
|---|
| 133 | for (int i=0; i<n; i++)
|
|---|
| 134 | GetAverageArea(i).Copy(cam.GetAverageArea(i));
|
|---|
| 135 |
|
|---|
| 136 | n = GetNumAverageSector();
|
|---|
| 137 | cam.InitAverageSectors(n);
|
|---|
| 138 | for (int i=0; i<n; i++)
|
|---|
| 139 | GetAverageSector(i).Copy(cam.GetAverageSector(i));
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | // --------------------------------------------------------------------------
|
|---|
| 143 | //
|
|---|
| 144 | // Set the size of the camera
|
|---|
| 145 | //
|
|---|
| 146 | void MPedestalCam::InitSize(const UInt_t i)
|
|---|
| 147 | {
|
|---|
| 148 | fArray->ExpandCreate(i);
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | // -------------------------------------------------------------------
|
|---|
| 152 | //
|
|---|
| 153 | // Calls TClonesArray::ExpandCreate() for:
|
|---|
| 154 | // - fAverageAreas
|
|---|
| 155 | //
|
|---|
| 156 | void MPedestalCam::InitAverageAreas(const UInt_t i)
|
|---|
| 157 | {
|
|---|
| 158 | fAverageAreas->ExpandCreate(i);
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | // -------------------------------------------------------------------
|
|---|
| 162 | //
|
|---|
| 163 | // Calls TClonesArray::ExpandCreate() for:
|
|---|
| 164 | // - fAverageSectors
|
|---|
| 165 | //
|
|---|
| 166 | void MPedestalCam::InitAverageSectors(const UInt_t i)
|
|---|
| 167 | {
|
|---|
| 168 | fAverageSectors->ExpandCreate(i);
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | // -------------------------------------------------------------------
|
|---|
| 172 | //
|
|---|
| 173 | // Calls:
|
|---|
| 174 | // - InitSize()
|
|---|
| 175 | // - InitAverageAreas()
|
|---|
| 176 | // - InitAverageSectors()
|
|---|
| 177 | //
|
|---|
| 178 | void MPedestalCam::Init(const MGeomCam &geom)
|
|---|
| 179 | {
|
|---|
| 180 | InitSize (geom.GetNumPixels() );
|
|---|
| 181 | InitAverageAreas (geom.GetNumAreas() );
|
|---|
| 182 | InitAverageSectors(geom.GetNumSectors());
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | // --------------------------------------------------------------------------
|
|---|
| 186 | //
|
|---|
| 187 | // This function returns the current size of the TClonesArray
|
|---|
| 188 | // independently if the MPedestalPix is filled with values or not.
|
|---|
| 189 | //
|
|---|
| 190 | // Get the size of the MPedestalCam
|
|---|
| 191 | //
|
|---|
| 192 | Int_t MPedestalCam::GetSize() const
|
|---|
| 193 | {
|
|---|
| 194 | return fArray->GetEntriesFast();
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | // --------------------------------------------------------------------------
|
|---|
| 198 | //
|
|---|
| 199 | // Returns the current size of the TClonesArray fAverageAreas
|
|---|
| 200 | // independently if the MPedestalPix is filled with values or not.
|
|---|
| 201 | //
|
|---|
| 202 | const Int_t MPedestalCam::GetNumAverageArea() const
|
|---|
| 203 | {
|
|---|
| 204 | return fAverageAreas->GetEntriesFast();
|
|---|
| 205 | }
|
|---|
| 206 |
|
|---|
| 207 | // --------------------------------------------------------------------------
|
|---|
| 208 | //
|
|---|
| 209 | // Returns the current size of the TClonesArray fAverageSectors
|
|---|
| 210 | // independently if the MPedestalPix is filled with values or not.
|
|---|
| 211 | //
|
|---|
| 212 | const Int_t MPedestalCam::GetNumAverageSector() const
|
|---|
| 213 | {
|
|---|
| 214 | return fAverageSectors->GetEntriesFast();
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | // --------------------------------------------------------------------------
|
|---|
| 218 | //
|
|---|
| 219 | // Get i-th pixel (pixel number)
|
|---|
| 220 | //
|
|---|
| 221 | MPedestalPix &MPedestalCam::operator[](Int_t i)
|
|---|
| 222 | {
|
|---|
| 223 | return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
|
|---|
| 224 | }
|
|---|
| 225 |
|
|---|
| 226 | // --------------------------------------------------------------------------
|
|---|
| 227 | //
|
|---|
| 228 | // Get i-th pixel (pixel number)
|
|---|
| 229 | //
|
|---|
| 230 | const MPedestalPix &MPedestalCam::operator[](Int_t i) const
|
|---|
| 231 | {
|
|---|
| 232 | return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
|
|---|
| 233 | }
|
|---|
| 234 |
|
|---|
| 235 | // --------------------------------------------------------------------------
|
|---|
| 236 | //
|
|---|
| 237 | // Get i-th average pixel (area number)
|
|---|
| 238 | //
|
|---|
| 239 | MPedestalPix &MPedestalCam::GetAverageArea(UInt_t i)
|
|---|
| 240 | {
|
|---|
| 241 | return *static_cast<MPedestalPix*>(fAverageAreas->UncheckedAt(i));
|
|---|
| 242 | }
|
|---|
| 243 |
|
|---|
| 244 | // --------------------------------------------------------------------------
|
|---|
| 245 | //
|
|---|
| 246 | // Get i-th average pixel (area number)
|
|---|
| 247 | //
|
|---|
| 248 | const MPedestalPix &MPedestalCam::GetAverageArea(UInt_t i) const
|
|---|
| 249 | {
|
|---|
| 250 | return *static_cast<MPedestalPix*>(fAverageAreas->UncheckedAt(i));
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 | // --------------------------------------------------------------------------
|
|---|
| 254 | //
|
|---|
| 255 | // Get i-th average pixel (sector number)
|
|---|
| 256 | //
|
|---|
| 257 | MPedestalPix &MPedestalCam::GetAverageSector(UInt_t i)
|
|---|
| 258 | {
|
|---|
| 259 | return *static_cast<MPedestalPix*>(fAverageSectors->UncheckedAt(i));
|
|---|
| 260 | }
|
|---|
| 261 |
|
|---|
| 262 | // --------------------------------------------------------------------------
|
|---|
| 263 | //
|
|---|
| 264 | // Get i-th average pixel (sector number)
|
|---|
| 265 | //
|
|---|
| 266 | const MPedestalPix &MPedestalCam::GetAverageSector(UInt_t i) const
|
|---|
| 267 | {
|
|---|
| 268 | return *static_cast<MPedestalPix*>(fAverageSectors->UncheckedAt(i));
|
|---|
| 269 | }
|
|---|
| 270 |
|
|---|
| 271 | // --------------------------------------
|
|---|
| 272 | //
|
|---|
| 273 | // Calls the ForEach macro for the TClonesArray fArray with the argument Clear()
|
|---|
| 274 | //
|
|---|
| 275 | // Loops over the fAverageAreas, calling the function Clear() for
|
|---|
| 276 | // every entry in fAverageAreas
|
|---|
| 277 | //
|
|---|
| 278 | // Loops over the fAverageSectors, calling the function Clear() for
|
|---|
| 279 | // every entry in fAverageSectors
|
|---|
| 280 | //
|
|---|
| 281 | void MPedestalCam::Clear(Option_t *o)
|
|---|
| 282 | {
|
|---|
| 283 | { fArray->R__FOR_EACH(TObject, Clear)(); }
|
|---|
| 284 | { fAverageAreas->R__FOR_EACH(TObject, Clear)(); }
|
|---|
| 285 | { fAverageSectors->R__FOR_EACH(TObject, Clear)(); }
|
|---|
| 286 |
|
|---|
| 287 | fNumSlices = 0;
|
|---|
| 288 | }
|
|---|
| 289 |
|
|---|
| 290 | void MPedestalCam::PrintArr(const TCollection &list) const
|
|---|
| 291 | {
|
|---|
| 292 | Int_t id = 0;
|
|---|
| 293 |
|
|---|
| 294 | TIter Next(&list);
|
|---|
| 295 | MPedestalPix *pix = 0;
|
|---|
| 296 |
|
|---|
| 297 | while ((pix=(MPedestalPix*)Next()))
|
|---|
| 298 | *fLog << Form("Nr.: %4i Pedestal: %5.2f RMS: %5.2f ABOffset: %5.2f ",
|
|---|
| 299 | id++, pix->GetPedestal(), pix->GetPedestalRms(), pix->GetPedestalABoffset()) << endl;
|
|---|
| 300 | }
|
|---|
| 301 |
|
|---|
| 302 | void MPedestalCam::Print(Option_t *option) const
|
|---|
| 303 | {
|
|---|
| 304 | *fLog << all << GetDescriptor();
|
|---|
| 305 | *fLog << " - Events=" << fNumEvents << ", Slices=" << fNumSlices << ":" << endl;
|
|---|
| 306 |
|
|---|
| 307 | *fLog << endl;
|
|---|
| 308 | *fLog << "Event-by-event averaged areas:" << endl;
|
|---|
| 309 | PrintArr(*fAverageAreas);
|
|---|
| 310 |
|
|---|
| 311 | *fLog << endl;
|
|---|
| 312 | *fLog << "Event-by-event averaged sectors:" << endl;
|
|---|
| 313 | PrintArr(*fAverageSectors);
|
|---|
| 314 |
|
|---|
| 315 | if (TString(option).Contains("all", TString::kIgnoreCase))
|
|---|
| 316 | {
|
|---|
| 317 | *fLog << endl;
|
|---|
| 318 | *fLog << "Pixels:" << endl;
|
|---|
| 319 | PrintArr(*fArray);
|
|---|
| 320 | }
|
|---|
| 321 | }
|
|---|
| 322 |
|
|---|
| 323 | /*
|
|---|
| 324 | Float_t MPedestalCam::GetPedestalMin(const MGeomCam *geom) const
|
|---|
| 325 | {
|
|---|
| 326 | if (fArray->GetEntries() <= 0)
|
|---|
| 327 | return 50.;
|
|---|
| 328 |
|
|---|
| 329 | Float_t minval = (*this)[0].GetPedestalRms();
|
|---|
| 330 |
|
|---|
| 331 | for (Int_t i=1; i<fArray->GetEntries(); i++)
|
|---|
| 332 | {
|
|---|
| 333 | const MPedestalPix &pix = (*this)[i];
|
|---|
| 334 |
|
|---|
| 335 | Float_t testval = pix.GetPedestalRms();
|
|---|
| 336 |
|
|---|
| 337 | if (geom)
|
|---|
| 338 | testval *= geom->GetPixRatio(i);
|
|---|
| 339 |
|
|---|
| 340 | if (testval < minval)
|
|---|
| 341 | minval = testval;
|
|---|
| 342 | }
|
|---|
| 343 | return minval;
|
|---|
| 344 | }
|
|---|
| 345 |
|
|---|
| 346 | Float_t MPedestalCam::GetPedestalMax(const MGeomCam *geom) const
|
|---|
| 347 | {
|
|---|
| 348 | if (fArray->GetEntries() <= 0)
|
|---|
| 349 | return 50.;
|
|---|
| 350 |
|
|---|
| 351 | Float_t maxval = (*this)[0].GetPedestalRms();
|
|---|
| 352 |
|
|---|
| 353 | for (Int_t i=1; i<fArray->GetEntries(); i++)
|
|---|
| 354 | {
|
|---|
| 355 | const MPedestalPix &pix = (*this)[i];
|
|---|
| 356 |
|
|---|
| 357 | Float_t testval = pix.GetPedestalRms();
|
|---|
| 358 |
|
|---|
| 359 | if (geom)
|
|---|
| 360 | testval *= geom->GetPixRatio(i);
|
|---|
| 361 |
|
|---|
| 362 | if (testval > maxval)
|
|---|
| 363 | maxval = testval;
|
|---|
| 364 | }
|
|---|
| 365 | return maxval;
|
|---|
| 366 | }
|
|---|
| 367 | */
|
|---|
| 368 |
|
|---|
| 369 | // --------------------------------------------------------------------------
|
|---|
| 370 | //
|
|---|
| 371 | // Calculates the average pedestal for pixel sizes.
|
|---|
| 372 | // The geometry container is used to get the necessary
|
|---|
| 373 | // geometry information (area index) If the bad pixel
|
|---|
| 374 | // container is given all pixels which have the flag 'kUnsuitableRun' are ignored
|
|---|
| 375 | // in the calculation of the size average.
|
|---|
| 376 | //
|
|---|
| 377 | // Returns a TArrayF of dimension 2:
|
|---|
| 378 | // arr[0]: averaged pedestal (default: -1.)
|
|---|
| 379 | // arr[1]: Error (rms) of averaged pedestal (default: 0.)
|
|---|
| 380 | //
|
|---|
| 381 | TArrayF MPedestalCam::GetAveragedPedPerArea(const MGeomCam &geom, const UInt_t ai, MBadPixelsCam *bad)
|
|---|
| 382 | {
|
|---|
| 383 |
|
|---|
| 384 | const Int_t np = GetSize();
|
|---|
| 385 |
|
|---|
| 386 | Double_t mean = 0.;
|
|---|
| 387 | Double_t mean2 = 0.;
|
|---|
| 388 | Int_t nr = 0;
|
|---|
| 389 |
|
|---|
| 390 | for (int i=0; i<np; i++)
|
|---|
| 391 | {
|
|---|
| 392 | if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
|---|
| 393 | continue;
|
|---|
| 394 |
|
|---|
| 395 | const UInt_t aidx = geom[i].GetAidx();
|
|---|
| 396 |
|
|---|
| 397 | if (ai != aidx)
|
|---|
| 398 | continue;
|
|---|
| 399 |
|
|---|
| 400 | const MPedestalPix &pix = (*this)[i];
|
|---|
| 401 |
|
|---|
| 402 | mean += pix.GetPedestal();
|
|---|
| 403 | mean2 += pix.GetPedestal()*pix.GetPedestal();
|
|---|
| 404 | nr ++;
|
|---|
| 405 |
|
|---|
| 406 | }
|
|---|
| 407 |
|
|---|
| 408 | TArrayF arr(2);
|
|---|
| 409 | arr[0] = nr ? mean/nr : -1.;
|
|---|
| 410 | arr[1] = nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0;
|
|---|
| 411 | return arr;
|
|---|
| 412 | }
|
|---|
| 413 |
|
|---|
| 414 | // --------------------------------------------------------------------------
|
|---|
| 415 | //
|
|---|
| 416 | // Calculates the average pedestal rms for pixel sizes.
|
|---|
| 417 | // The geometry container is used to get the necessary
|
|---|
| 418 | // geometry information (area index) If the bad pixel
|
|---|
| 419 | // container is given all pixels which have the flag 'kUnsuitableRun' are ignored
|
|---|
| 420 | // in the calculation of the size average.
|
|---|
| 421 | //
|
|---|
| 422 | // Returns a TArrayF of dimension 2:
|
|---|
| 423 | // arr[0]: averaged pedestal RMS (default: -1.)
|
|---|
| 424 | // arr[1]: Error (rms) of averaged pedestal RMS (default: 0.)
|
|---|
| 425 | //
|
|---|
| 426 | TArrayF MPedestalCam::GetAveragedRmsPerArea(const MGeomCam &geom, const UInt_t ai, MBadPixelsCam *bad)
|
|---|
| 427 | {
|
|---|
| 428 |
|
|---|
| 429 | const Int_t np = GetSize();
|
|---|
| 430 |
|
|---|
| 431 | Double_t rms = 0.;
|
|---|
| 432 | Double_t rms2 = 0.;
|
|---|
| 433 | Int_t nr = 0;
|
|---|
| 434 |
|
|---|
| 435 | for (int i=0; i<np; i++)
|
|---|
| 436 | {
|
|---|
| 437 | if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
|---|
| 438 | continue;
|
|---|
| 439 |
|
|---|
| 440 | const UInt_t aidx = geom[i].GetAidx();
|
|---|
| 441 |
|
|---|
| 442 | if (ai != aidx)
|
|---|
| 443 | continue;
|
|---|
| 444 |
|
|---|
| 445 | const MPedestalPix &pix = (*this)[i];
|
|---|
| 446 |
|
|---|
| 447 | rms += pix.GetPedestalRms();
|
|---|
| 448 | rms2 += pix.GetPedestalRms()*pix.GetPedestalRms();
|
|---|
| 449 | nr ++;
|
|---|
| 450 | }
|
|---|
| 451 |
|
|---|
| 452 | TArrayF arr(2);
|
|---|
| 453 | arr[0] = nr ? rms/nr : -1;
|
|---|
| 454 | arr[1] = nr>1 ? TMath::Sqrt((rms2 - rms*rms/nr)/(nr-1)) : 0;
|
|---|
| 455 | return arr;
|
|---|
| 456 | }
|
|---|
| 457 |
|
|---|
| 458 | // --------------------------------------------------------------------------
|
|---|
| 459 | //
|
|---|
| 460 | // Calculates the average pedestal for camera sectors.
|
|---|
| 461 | // The geometry container is used to get the necessary
|
|---|
| 462 | // geometry information (area index) If the bad pixel
|
|---|
| 463 | // container is given all pixels which have the flag 'kUnsuitableRun' are ignored
|
|---|
| 464 | // in the calculation of the size average.
|
|---|
| 465 | //
|
|---|
| 466 | // Returns a TArrayF of dimension 2:
|
|---|
| 467 | // arr[0]: averaged pedestal (default: -1.)
|
|---|
| 468 | // arr[1]: Error (rms) of averaged pedestal (default: 0.)
|
|---|
| 469 | //
|
|---|
| 470 | TArrayF MPedestalCam::GetAveragedPedPerSector(const MGeomCam &geom, const UInt_t sec, MBadPixelsCam *bad)
|
|---|
| 471 | {
|
|---|
| 472 |
|
|---|
| 473 | const Int_t np = GetSize();
|
|---|
| 474 |
|
|---|
| 475 | Double_t mean = 0.;
|
|---|
| 476 | Double_t mean2 = 0.;
|
|---|
| 477 | Int_t nr = 0;
|
|---|
| 478 |
|
|---|
| 479 | for (int i=0; i<np; i++)
|
|---|
| 480 | {
|
|---|
| 481 | if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
|---|
| 482 | continue;
|
|---|
| 483 |
|
|---|
| 484 | const UInt_t sector = geom[i].GetSector();
|
|---|
| 485 |
|
|---|
| 486 | if (sec != sector)
|
|---|
| 487 | continue;
|
|---|
| 488 |
|
|---|
| 489 | const MPedestalPix &pix = (*this)[i];
|
|---|
| 490 |
|
|---|
| 491 | mean += pix.GetPedestal();
|
|---|
| 492 | mean2 += pix.GetPedestal()*pix.GetPedestal();
|
|---|
| 493 | nr ++;
|
|---|
| 494 |
|
|---|
| 495 | }
|
|---|
| 496 |
|
|---|
| 497 | TArrayF arr(2);
|
|---|
| 498 | arr[0] = nr ? mean/nr : -1;
|
|---|
| 499 | arr[1] = nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0;
|
|---|
| 500 | return arr;
|
|---|
| 501 | }
|
|---|
| 502 |
|
|---|
| 503 | // --------------------------------------------------------------------------
|
|---|
| 504 | //
|
|---|
| 505 | // Calculates the average pedestal rms for camera sectors.
|
|---|
| 506 | // The geometry container is used to get the necessary
|
|---|
| 507 | // geometry information (area index) If the bad pixel
|
|---|
| 508 | // container is given all pixels which have the flag 'kUnsuitableRun' are ignored
|
|---|
| 509 | // in the calculation of the size average.
|
|---|
| 510 | //
|
|---|
| 511 | // Returns a TArrayF of dimension 2:
|
|---|
| 512 | // arr[0]: averaged pedestal RMS (default: -1.)
|
|---|
| 513 | // arr[1]: Error (rms) of averaged pedestal RMS (default: 0.)
|
|---|
| 514 | //
|
|---|
| 515 | TArrayF MPedestalCam::GetAveragedRmsPerSector(const MGeomCam &geom, const UInt_t sec, MBadPixelsCam *bad)
|
|---|
| 516 | {
|
|---|
| 517 |
|
|---|
| 518 | const Int_t np = GetSize();
|
|---|
| 519 |
|
|---|
| 520 | Double_t rms = 0.;
|
|---|
| 521 | Double_t rms2 = 0.;
|
|---|
| 522 | Int_t nr = 0;
|
|---|
| 523 |
|
|---|
| 524 | for (int i=0; i<np; i++)
|
|---|
| 525 | {
|
|---|
| 526 | if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
|---|
| 527 | continue;
|
|---|
| 528 |
|
|---|
| 529 | const UInt_t sector = geom[i].GetSector();
|
|---|
| 530 |
|
|---|
| 531 | if (sec != sector)
|
|---|
| 532 | continue;
|
|---|
| 533 |
|
|---|
| 534 | const MPedestalPix &pix = (*this)[i];
|
|---|
| 535 |
|
|---|
| 536 | rms += pix.GetPedestalRms();
|
|---|
| 537 | rms2 += pix.GetPedestalRms()*pix.GetPedestalRms();
|
|---|
| 538 | nr ++;
|
|---|
| 539 |
|
|---|
| 540 | }
|
|---|
| 541 |
|
|---|
| 542 | TArrayF arr(2);
|
|---|
| 543 | arr[0] = nr ? rms/nr : -1;
|
|---|
| 544 | arr[1] = nr>1 ? TMath::Sqrt((rms2 - rms*rms/nr)/(nr-1)) : 0;
|
|---|
| 545 | return arr;
|
|---|
| 546 | }
|
|---|
| 547 |
|
|---|
| 548 |
|
|---|
| 549 | Bool_t MPedestalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
|---|
| 550 | {
|
|---|
| 551 | if (GetSize() <= idx)
|
|---|
| 552 | return kFALSE;
|
|---|
| 553 |
|
|---|
| 554 | if (!(*this)[idx].IsValid())
|
|---|
| 555 | return kFALSE;
|
|---|
| 556 |
|
|---|
| 557 | const Float_t ped = (*this)[idx].GetPedestal();
|
|---|
| 558 | const Float_t rms = (*this)[idx].GetPedestalRms();
|
|---|
| 559 | const UInt_t num = (*this)[idx].GetNumEvents()*fNumSlices;
|
|---|
| 560 |
|
|---|
| 561 | switch (type)
|
|---|
| 562 | {
|
|---|
| 563 | case 0:
|
|---|
| 564 | val = ped;
|
|---|
| 565 | break;
|
|---|
| 566 | case 1:
|
|---|
| 567 | val = fNumSlices>0 ? rms/TMath::Sqrt((Float_t)num)
|
|---|
| 568 | : (*this)[idx].GetPedestalError();
|
|---|
| 569 | break;
|
|---|
| 570 | case 2:
|
|---|
| 571 | val = rms;
|
|---|
| 572 | break;
|
|---|
| 573 | case 3:
|
|---|
| 574 | val = fNumSlices>0 ? rms/TMath::Sqrt((Float_t)num*2.)
|
|---|
| 575 | : (*this)[idx].GetPedestalRmsError();
|
|---|
| 576 | break;
|
|---|
| 577 | default:
|
|---|
| 578 | return kFALSE;
|
|---|
| 579 | }
|
|---|
| 580 | return kTRUE;
|
|---|
| 581 | }
|
|---|
| 582 |
|
|---|
| 583 | void MPedestalCam::DrawPixelContent(Int_t idx) const
|
|---|
| 584 | {
|
|---|
| 585 | *fLog << warn << "MPedestalCam::DrawPixelContent - not available." << endl;
|
|---|
| 586 | }
|
|---|