| 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@uni-sw.gwdg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2001
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | // //
|
|---|
| 27 | // MPedestalCam //
|
|---|
| 28 | // //
|
|---|
| 29 | // Hold the Pedestal information for all pixels in the camera //
|
|---|
| 30 | // //
|
|---|
| 31 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 32 | #include "MPedestalCam.h"
|
|---|
| 33 | #include "MPedestalPix.h"
|
|---|
| 34 |
|
|---|
| 35 | #include <TClonesArray.h>
|
|---|
| 36 |
|
|---|
| 37 | #include "MLog.h"
|
|---|
| 38 | #include "MLogManip.h"
|
|---|
| 39 |
|
|---|
| 40 | #include "MGeomCam.h"
|
|---|
| 41 |
|
|---|
| 42 | ClassImp(MPedestalCam);
|
|---|
| 43 |
|
|---|
| 44 | using namespace std;
|
|---|
| 45 |
|
|---|
| 46 | // --------------------------------------------------------------------------
|
|---|
| 47 | //
|
|---|
| 48 | // Default constructor. Creates a MPedestalPix object for each pixel
|
|---|
| 49 | //
|
|---|
| 50 | MPedestalCam::MPedestalCam(const char *name, const char *title)
|
|---|
| 51 | : fNumTotSlices(0), fNumExtractSlices(0), fUseHists(kFALSE)
|
|---|
| 52 | {
|
|---|
| 53 | fName = name ? name : "MPedestalCam";
|
|---|
| 54 | fTitle = title ? title : "Storage container for all Pedestal Information in the camera";
|
|---|
| 55 |
|
|---|
| 56 | fArray = new TClonesArray("MPedestalPix", 1);
|
|---|
| 57 |
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | // --------------------------------------------------------------------------
|
|---|
| 61 | //
|
|---|
| 62 | // Delete the array conatining the pixel pedest information
|
|---|
| 63 | //
|
|---|
| 64 | MPedestalCam::~MPedestalCam()
|
|---|
| 65 | {
|
|---|
| 66 | delete fArray;
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | // --------------------------------------------------------------------------
|
|---|
| 70 | //
|
|---|
| 71 | // Set the size of the camera
|
|---|
| 72 | //
|
|---|
| 73 | void MPedestalCam::InitSize(const UInt_t i)
|
|---|
| 74 | {
|
|---|
| 75 | fArray->ExpandCreate(i);
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | // --------------------------------------------------------------------------
|
|---|
| 79 | //
|
|---|
| 80 | // This function returns the current size of the TClonesArray
|
|---|
| 81 | // independently if the MPedestalPix is filled with values or not.
|
|---|
| 82 | //
|
|---|
| 83 | // Get the size of the MPedestalCam
|
|---|
| 84 | //
|
|---|
| 85 | Int_t MPedestalCam::GetSize() const
|
|---|
| 86 | {
|
|---|
| 87 | return fArray->GetEntriesFast();
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | // --------------------------------------------------------------------------
|
|---|
| 91 | //
|
|---|
| 92 | // Get i-th pixel (pixel number)
|
|---|
| 93 | //
|
|---|
| 94 | MPedestalPix &MPedestalCam::operator[](Int_t i)
|
|---|
| 95 | {
|
|---|
| 96 | return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | // --------------------------------------------------------------------------
|
|---|
| 100 | //
|
|---|
| 101 | // Get i-th pixel (pixel number)
|
|---|
| 102 | //
|
|---|
| 103 | MPedestalPix &MPedestalCam::operator[](Int_t i) const
|
|---|
| 104 | {
|
|---|
| 105 | return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | void MPedestalCam::Clear(Option_t *o)
|
|---|
| 109 | {
|
|---|
| 110 | fArray->ForEach(TObject, Clear)();
|
|---|
| 111 |
|
|---|
| 112 | fNumTotSlices = 0;
|
|---|
| 113 | fNumExtractSlices = 0;
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | void MPedestalCam::InitUseHists()
|
|---|
| 117 | {
|
|---|
| 118 | fArray->ForEach(MPedestalPix, InitUseHists)();
|
|---|
| 119 |
|
|---|
| 120 | fUseHists = kTRUE;
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | void MPedestalCam::Print(Option_t *o) const
|
|---|
| 124 | {
|
|---|
| 125 | *fLog << all << GetDescriptor() << ":" << endl;
|
|---|
| 126 | int id = 0;
|
|---|
| 127 |
|
|---|
| 128 | TIter Next(fArray);
|
|---|
| 129 | MPedestalPix *pix;
|
|---|
| 130 | while ((pix=(MPedestalPix*)Next()))
|
|---|
| 131 | {
|
|---|
| 132 | id++;
|
|---|
| 133 |
|
|---|
| 134 | if (!pix->IsValid())
|
|---|
| 135 | continue;
|
|---|
| 136 |
|
|---|
| 137 | *fLog << id-1 << ": ";
|
|---|
| 138 | *fLog << pix->GetPedestal() << " " << pix->GetPedestalRms() << endl;
|
|---|
| 139 | }
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | Float_t MPedestalCam::GetPedestalMin(const MGeomCam *geom) const
|
|---|
| 143 | {
|
|---|
| 144 | if (fArray->GetEntries() <= 0)
|
|---|
| 145 | return 50.;
|
|---|
| 146 |
|
|---|
| 147 | Float_t minval = (*this)[0].GetPedestalRms();
|
|---|
| 148 |
|
|---|
| 149 | for (Int_t i=1; i<fArray->GetEntries(); i++)
|
|---|
| 150 | {
|
|---|
| 151 | const MPedestalPix &pix = (*this)[i];
|
|---|
| 152 |
|
|---|
| 153 | Float_t testval = pix.GetPedestalRms();
|
|---|
| 154 |
|
|---|
| 155 | if (geom)
|
|---|
| 156 | testval *= geom->GetPixRatio(i);
|
|---|
| 157 |
|
|---|
| 158 | if (testval < minval)
|
|---|
| 159 | minval = testval;
|
|---|
| 160 | }
|
|---|
| 161 | return minval;
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | Float_t MPedestalCam::GetPedestalMax(const MGeomCam *geom) const
|
|---|
| 165 | {
|
|---|
| 166 | if (fArray->GetEntries() <= 0)
|
|---|
| 167 | return 50.;
|
|---|
| 168 |
|
|---|
| 169 | Float_t maxval = (*this)[0].GetPedestalRms();
|
|---|
| 170 |
|
|---|
| 171 | for (Int_t i=1; i<fArray->GetEntries(); i++)
|
|---|
| 172 | {
|
|---|
| 173 | const MPedestalPix &pix = (*this)[i];
|
|---|
| 174 |
|
|---|
| 175 | Float_t testval = pix.GetPedestalRms();
|
|---|
| 176 |
|
|---|
| 177 | if (geom)
|
|---|
| 178 | testval *= geom->GetPixRatio(i);
|
|---|
| 179 |
|
|---|
| 180 | if (testval > maxval)
|
|---|
| 181 | maxval = testval;
|
|---|
| 182 | }
|
|---|
| 183 | return maxval;
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 | Bool_t MPedestalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
|---|
| 187 | {
|
|---|
| 188 |
|
|---|
| 189 | if (!(*this)[idx].IsValid())
|
|---|
| 190 | return kFALSE;
|
|---|
| 191 |
|
|---|
| 192 | if (idx == 559)
|
|---|
| 193 | return kFALSE;
|
|---|
| 194 |
|
|---|
| 195 | const Float_t ped = (*this)[idx].GetPedestal();
|
|---|
| 196 | const Float_t rms = (*this)[idx].GetPedestalRms();
|
|---|
| 197 |
|
|---|
| 198 | const Float_t pederr = rms/TMath::Sqrt((Float_t)fNumTotSlices);
|
|---|
| 199 | const Float_t rmserr = rms/TMath::Sqrt((Float_t)fNumTotSlices/2.);
|
|---|
| 200 |
|
|---|
| 201 | const Float_t mean = (*this)[idx].GetMean() / (Float_t)fNumExtractSlices;
|
|---|
| 202 | const Float_t meanerr = (*this)[idx].GetMeanErr() / (Float_t)fNumExtractSlices;
|
|---|
| 203 | const Float_t sigma = (*this)[idx].GetSigma() / TMath::Sqrt((Float_t) fNumExtractSlices);
|
|---|
| 204 | const Float_t sigmaerr = (*this)[idx].GetSigmaErr() / TMath::Sqrt((Float_t) fNumExtractSlices);
|
|---|
| 205 |
|
|---|
| 206 | switch (type)
|
|---|
| 207 | {
|
|---|
| 208 | case 0:
|
|---|
| 209 | val = ped;
|
|---|
| 210 | break;
|
|---|
| 211 | case 1:
|
|---|
| 212 | val = pederr;
|
|---|
| 213 | break;
|
|---|
| 214 | case 2:
|
|---|
| 215 | val = rms;
|
|---|
| 216 | break;
|
|---|
| 217 | case 3:
|
|---|
| 218 | val = rmserr;
|
|---|
| 219 | break;
|
|---|
| 220 | case 4:
|
|---|
| 221 | // if ((*this)[idx].IsFitValid())
|
|---|
| 222 | val = mean;
|
|---|
| 223 | // else
|
|---|
| 224 | // return kFALSE;
|
|---|
| 225 | break;
|
|---|
| 226 | case 5:
|
|---|
| 227 | // if ((*this)[idx].IsFitValid())
|
|---|
| 228 | val = meanerr;
|
|---|
| 229 | // else
|
|---|
| 230 | // return kFALSE;
|
|---|
| 231 | break;
|
|---|
| 232 | case 6:
|
|---|
| 233 | // if ((*this)[idx].IsFitValid())
|
|---|
| 234 | val = sigma;
|
|---|
| 235 | // else
|
|---|
| 236 | // return kFALSE;
|
|---|
| 237 | break;
|
|---|
| 238 | case 7:
|
|---|
| 239 | // if ((*this)[idx].IsFitValid())
|
|---|
| 240 | val = sigmaerr;
|
|---|
| 241 | // else
|
|---|
| 242 | // return kFALSE;
|
|---|
| 243 | break;
|
|---|
| 244 | case 8:
|
|---|
| 245 | // if ((*this)[idx].IsFitValid())
|
|---|
| 246 | val = (*this)[idx].GetProb();
|
|---|
| 247 | // else
|
|---|
| 248 | // return kFALSE;
|
|---|
| 249 | break;
|
|---|
| 250 | case 9:
|
|---|
| 251 | // if ((*this)[idx].IsFitValid())
|
|---|
| 252 | val = 2.*(ped-mean)/(ped+mean);
|
|---|
| 253 | // else
|
|---|
| 254 | // return kFALSE;
|
|---|
| 255 | break;
|
|---|
| 256 | case 10:
|
|---|
| 257 | val = TMath::Sqrt((pederr*pederr + meanerr*meanerr) * (ped*ped + mean*mean))
|
|---|
| 258 | *2./(ped+mean)/(ped+mean);
|
|---|
| 259 | break;
|
|---|
| 260 | case 11:
|
|---|
| 261 | val = 2.*(pederr - meanerr)/(pederr + meanerr);
|
|---|
| 262 | break;
|
|---|
| 263 | case 12:
|
|---|
| 264 | val = 2.*(rms-sigma)/(rms+sigma);
|
|---|
| 265 | break;
|
|---|
| 266 | case 13:
|
|---|
| 267 | val = TMath::Sqrt((rmserr*rmserr + sigmaerr*sigmaerr) * (rms*rms + sigma*sigma))
|
|---|
| 268 | *2./(rms+sigma)/(rms+sigma);
|
|---|
| 269 | break;
|
|---|
| 270 | case 14:
|
|---|
| 271 | // if ((*this)[idx].IsFitValid())
|
|---|
| 272 | val = 2.*(rmserr - sigmaerr)/(rmserr + sigmaerr);
|
|---|
| 273 | // else
|
|---|
| 274 | // return kFALSE;
|
|---|
| 275 | break;
|
|---|
| 276 | default:
|
|---|
| 277 | return kFALSE;
|
|---|
| 278 | }
|
|---|
| 279 | return kTRUE;
|
|---|
| 280 | }
|
|---|
| 281 |
|
|---|
| 282 | void MPedestalCam::DrawPixelContent(Int_t idx) const
|
|---|
| 283 | {
|
|---|
| 284 | (*this)[idx].Draw();
|
|---|
| 285 | }
|
|---|