| 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): Wolfgang Wittek 03/2003 <mailto:wittek@mppmu.mpg.de>
|
|---|
| 19 | ! Author(s): Thomas Bretz <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 |
|
|---|
| 26 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | //
|
|---|
| 28 | // MNewImagePar
|
|---|
| 29 | //
|
|---|
| 30 | // Storage Container for new image parameters
|
|---|
| 31 | //
|
|---|
| 32 | // Float_t fLeakage1; // (photons in most outer ring of pixels) over fSize
|
|---|
| 33 | // Float_t fLeakage2; // (photons in the 2 outer rings of pixels) over fSize
|
|---|
| 34 | // Float_t fInnerLeakage1; // (photons in most outer rings of inner pixels) over fInnerSize
|
|---|
| 35 | // Float_t fInnerLeakage2; // (photons in the 2 outer rings of inner pixels) over fInnerSize
|
|---|
| 36 | // Float_t fInnerSize; //
|
|---|
| 37 | //
|
|---|
| 38 | // Float_t fConc; // [ratio] concentration ratio: sum of the two highest pixels / fSize
|
|---|
| 39 | // Float_t fConc1; // [ratio] concentration ratio: sum of the highest pixel / fSize
|
|---|
| 40 | //
|
|---|
| 41 | // Float_t fUsedArea; // Area of pixels which survived the image cleaning
|
|---|
| 42 | // Float_t fCoreArea; // Area of core pixels
|
|---|
| 43 | // Short_t fNumUsedPixels; // Number of pixels which survived the image cleaning
|
|---|
| 44 | // Short_t fNumCorePixels; // number of core pixels
|
|---|
| 45 | // Short_t fNumHGSaturatedPixels; // number of pixels with saturating hi-gains
|
|---|
| 46 | // Short_t fNumSaturatedPixels; // number of pixels with saturating lo-gains
|
|---|
| 47 | //
|
|---|
| 48 | // Version 2:
|
|---|
| 49 | // ----------
|
|---|
| 50 | // - added fNumSaturatedPixels
|
|---|
| 51 | //
|
|---|
| 52 | // Version 3:
|
|---|
| 53 | // ----------
|
|---|
| 54 | // - added fNumHGSaturatedPixels
|
|---|
| 55 | // - added fInnerLeakage1
|
|---|
| 56 | // - added fInnerLeakage2
|
|---|
| 57 | // - added fInnerSize
|
|---|
| 58 | // - added fUsedArea
|
|---|
| 59 | // - added fCoreArea
|
|---|
| 60 | //
|
|---|
| 61 | // Version 4:
|
|---|
| 62 | // ----------
|
|---|
| 63 | // - moved cleaning/island independant parameters to MImagePar:
|
|---|
| 64 | // + removed fNumHGSaturatedPixels
|
|---|
| 65 | // + removed fNumSaturatedPixels
|
|---|
| 66 | //
|
|---|
| 67 | //
|
|---|
| 68 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 69 | #include "MNewImagePar.h"
|
|---|
| 70 |
|
|---|
| 71 | #include <fstream>
|
|---|
| 72 |
|
|---|
| 73 | #include "MLog.h"
|
|---|
| 74 | #include "MLogManip.h"
|
|---|
| 75 |
|
|---|
| 76 | #include "MHillas.h"
|
|---|
| 77 |
|
|---|
| 78 | #include "MGeomCam.h"
|
|---|
| 79 | #include "MGeomPix.h"
|
|---|
| 80 |
|
|---|
| 81 | #include "MCerPhotEvt.h"
|
|---|
| 82 | #include "MCerPhotPix.h"
|
|---|
| 83 |
|
|---|
| 84 | ClassImp(MNewImagePar);
|
|---|
| 85 |
|
|---|
| 86 | using namespace std;
|
|---|
| 87 |
|
|---|
| 88 | // --------------------------------------------------------------------------
|
|---|
| 89 | //
|
|---|
| 90 | // Default constructor.
|
|---|
| 91 | //
|
|---|
| 92 | MNewImagePar::MNewImagePar(const char *name, const char *title)
|
|---|
| 93 | {
|
|---|
| 94 | fName = name ? name : "MNewImagePar";
|
|---|
| 95 | fTitle = title ? title : "New image parameters";
|
|---|
| 96 |
|
|---|
| 97 | Reset();
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | // --------------------------------------------------------------------------
|
|---|
| 101 | //
|
|---|
| 102 | void MNewImagePar::Reset()
|
|---|
| 103 | {
|
|---|
| 104 | fLeakage1 = -1;
|
|---|
| 105 | fLeakage2 = -1;
|
|---|
| 106 |
|
|---|
| 107 | fInnerLeakage1 = -1;
|
|---|
| 108 | fInnerLeakage2 = -1;
|
|---|
| 109 | fInnerSize = -1;
|
|---|
| 110 |
|
|---|
| 111 | fConc = -1;
|
|---|
| 112 | fConc1 = -1;
|
|---|
| 113 |
|
|---|
| 114 | fNumUsedPixels = -1;
|
|---|
| 115 | fNumCorePixels = -1;
|
|---|
| 116 |
|
|---|
| 117 | fUsedArea = -1;
|
|---|
| 118 | fCoreArea = -1;
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | // --------------------------------------------------------------------------
|
|---|
| 122 | //
|
|---|
| 123 | // Calculation of new image parameters
|
|---|
| 124 | //
|
|---|
| 125 | void MNewImagePar::Calc(const MGeomCam &geom, const MCerPhotEvt &evt,
|
|---|
| 126 | const MHillas &hillas, Int_t island)
|
|---|
| 127 | {
|
|---|
| 128 | fNumUsedPixels = 0;
|
|---|
| 129 | fNumCorePixels = 0;
|
|---|
| 130 |
|
|---|
| 131 | fUsedArea = 0;
|
|---|
| 132 | fCoreArea = 0;
|
|---|
| 133 |
|
|---|
| 134 | fInnerSize = 0;
|
|---|
| 135 |
|
|---|
| 136 | Double_t edgepix1 = 0;
|
|---|
| 137 | Double_t edgepix2 = 0;
|
|---|
| 138 |
|
|---|
| 139 | Double_t edgepixin1 = 0;
|
|---|
| 140 | Double_t edgepixin2 = 0;
|
|---|
| 141 |
|
|---|
| 142 | Float_t maxpix1 = 0; // [#phot]
|
|---|
| 143 | Float_t maxpix2 = 0; // [#phot]
|
|---|
| 144 |
|
|---|
| 145 | MCerPhotPix *pix = 0;
|
|---|
| 146 |
|
|---|
| 147 | TIter Next(evt);
|
|---|
| 148 | while ((pix=(MCerPhotPix*)Next()))
|
|---|
| 149 | {
|
|---|
| 150 | // Check for requested islands
|
|---|
| 151 | if (island>=0 && pix->GetIdxIsland()!=island)
|
|---|
| 152 | continue;
|
|---|
| 153 |
|
|---|
| 154 | // Get geometry of pixel
|
|---|
| 155 | const Int_t pixid = pix->GetPixId();
|
|---|
| 156 | const MGeomPix &gpix = geom[pixid];
|
|---|
| 157 |
|
|---|
| 158 | // count used and core pixels
|
|---|
| 159 | if (pix->IsPixelCore())
|
|---|
| 160 | {
|
|---|
| 161 | fNumCorePixels++;
|
|---|
| 162 | fCoreArea += gpix.GetA();
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | // count used pixels
|
|---|
| 166 | fNumUsedPixels++;
|
|---|
| 167 | fUsedArea += gpix.GetA();
|
|---|
| 168 |
|
|---|
| 169 | Double_t nphot = pix->GetNumPhotons();
|
|---|
| 170 |
|
|---|
| 171 | //
|
|---|
| 172 | // count photons in outer rings of camera
|
|---|
| 173 | //
|
|---|
| 174 | if (gpix.IsInOutermostRing())
|
|---|
| 175 | edgepix1 += nphot;
|
|---|
| 176 | if (gpix.IsInOuterRing())
|
|---|
| 177 | edgepix2 += nphot;
|
|---|
| 178 |
|
|---|
| 179 | //
|
|---|
| 180 | // Now we are working on absolute values of nphot, which
|
|---|
| 181 | // must take pixel size into account
|
|---|
| 182 | //
|
|---|
| 183 | nphot *= geom.GetPixRatio(pixid);
|
|---|
| 184 |
|
|---|
| 185 | // count inner pixels: To dependent on MAGIC Camera --> FIXME
|
|---|
| 186 |
|
|---|
| 187 | if (pixid<397){
|
|---|
| 188 | fInnerSize += nphot;
|
|---|
| 189 | if(pixid>270){
|
|---|
| 190 | edgepixin2 += nphot;
|
|---|
| 191 | if(pixid>330)
|
|---|
| 192 | edgepixin1 += nphot;
|
|---|
| 193 | }
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | // Compute Concentration 1-2
|
|---|
| 197 | if (nphot>maxpix1)
|
|---|
| 198 | {
|
|---|
| 199 | maxpix2 = maxpix1;
|
|---|
| 200 | maxpix1 = nphot; // [1]
|
|---|
| 201 | continue; // [1]
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | if (nphot>maxpix2)
|
|---|
| 205 | maxpix2 = nphot; // [1]
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | fInnerLeakage1 = edgepixin1 / fInnerSize;
|
|---|
| 209 | fInnerLeakage2 = edgepixin2 / fInnerSize;
|
|---|
| 210 | fLeakage1 = edgepix1 / hillas.GetSize();
|
|---|
| 211 | fLeakage2 = edgepix2 / hillas.GetSize();
|
|---|
| 212 |
|
|---|
| 213 | fConc = (maxpix1+maxpix2)/hillas.GetSize(); // [ratio]
|
|---|
| 214 | fConc1 = maxpix1/hillas.GetSize(); // [ratio]
|
|---|
| 215 |
|
|---|
| 216 | SetReadyToSave();
|
|---|
| 217 | }
|
|---|
| 218 |
|
|---|
| 219 | // --------------------------------------------------------------------------
|
|---|
| 220 | //
|
|---|
| 221 | void MNewImagePar::Print(Option_t *) const
|
|---|
| 222 | {
|
|---|
| 223 | *fLog << all;
|
|---|
| 224 | *fLog << "New Image Parameters (" << GetName() << ")" << endl;
|
|---|
| 225 | *fLog << " - Leakage1 [1] = " << fLeakage1 << endl;
|
|---|
| 226 | *fLog << " - Leakage2 [1] = " << fLeakage2 << endl;
|
|---|
| 227 | *fLog << " - InnerLeakage1 [1] = " << fInnerLeakage1 << endl;
|
|---|
| 228 | *fLog << " - InnerLeakage2 [1] = " << fInnerLeakage2 << endl;
|
|---|
| 229 | *fLog << " - InnerSize [#] = " << fInnerSize << " CerPhot" << endl;
|
|---|
| 230 | *fLog << " - Conc [1] = " << fConc << " (ratio)" << endl;
|
|---|
| 231 | *fLog << " - Conc1 [1] = " << fConc1 << " (ratio)" << endl;
|
|---|
| 232 | *fLog << " - Used Pixels [#] = " << fNumUsedPixels << " Pixels" << endl;
|
|---|
| 233 | *fLog << " - Core Pixels [#] = " << fNumCorePixels << " Pixels" << endl;
|
|---|
| 234 | *fLog << " - Used Area [mm^2] = " << fUsedArea << endl;
|
|---|
| 235 | *fLog << " - Core Area [mm^2] = " << fCoreArea << endl;
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 | // -------------------------------------------------------------------------
|
|---|
| 239 | //
|
|---|
| 240 | // Print contents of MNewImagePar to *fLog, depending on the geometry in
|
|---|
| 241 | // units of deg.
|
|---|
| 242 | //
|
|---|
| 243 | void MNewImagePar::Print(const MGeomCam &geom) const
|
|---|
| 244 | {
|
|---|
| 245 | *fLog << all;
|
|---|
| 246 | *fLog << "New Image Parameters (" << GetName() << ")" << endl;
|
|---|
| 247 | *fLog << " - Leakage1 [1] = " << fLeakage1 << endl;
|
|---|
| 248 | *fLog << " - Leakage2 [1] = " << fLeakage2 << endl;
|
|---|
| 249 | *fLog << " - InnerLeakage1 [1] = " << fInnerLeakage1 << endl;
|
|---|
| 250 | *fLog << " - InnerLeakage2 [1] = " << fInnerLeakage2 << endl;
|
|---|
| 251 | *fLog << " - InnerSize [#] = " << fInnerSize << " CerPhot" << endl;
|
|---|
| 252 | *fLog << " - Conc [1] = " << fConc << " (ratio)" << endl;
|
|---|
| 253 | *fLog << " - Conc1 [1] = " << fConc1 << " (ratio)" << endl;
|
|---|
| 254 | *fLog << " - Used Pixels [#] = " << fNumUsedPixels << " Pixels" << endl;
|
|---|
| 255 | *fLog << " - Core Pixels [#] = " << fNumCorePixels << " Pixels" << endl;
|
|---|
| 256 | *fLog << " - Used Area [deg^2] = " << fUsedArea*geom.GetConvMm2Deg()*geom.GetConvMm2Deg() << endl;
|
|---|
| 257 | *fLog << " - Core Area [deg^2] = " << fCoreArea*geom.GetConvMm2Deg()*geom.GetConvMm2Deg() << endl;
|
|---|
| 258 | }
|
|---|