| 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 | ! | 
|---|
| 20 | !   Copyright: MAGIC Software Development, 2000-2003 | 
|---|
| 21 | ! | 
|---|
| 22 | ! | 
|---|
| 23 | \* ======================================================================== */ | 
|---|
| 24 |  | 
|---|
| 25 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 26 | // | 
|---|
| 27 | // MNewImagePar | 
|---|
| 28 | // | 
|---|
| 29 | // Storage Container for new image parameters | 
|---|
| 30 | // | 
|---|
| 31 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 32 | #include "MNewImagePar.h" | 
|---|
| 33 |  | 
|---|
| 34 | #include <fstream.h> | 
|---|
| 35 |  | 
|---|
| 36 | #include "MLog.h" | 
|---|
| 37 | #include "MLogManip.h" | 
|---|
| 38 |  | 
|---|
| 39 | #include "MHillas.h" | 
|---|
| 40 |  | 
|---|
| 41 | #include "MGeomCam.h" | 
|---|
| 42 | #include "MGeomPix.h" | 
|---|
| 43 |  | 
|---|
| 44 | #include "MCerPhotEvt.h" | 
|---|
| 45 | #include "MCerPhotPix.h" | 
|---|
| 46 |  | 
|---|
| 47 |  | 
|---|
| 48 | ClassImp(MNewImagePar); | 
|---|
| 49 |  | 
|---|
| 50 | // -------------------------------------------------------------------------- | 
|---|
| 51 | // | 
|---|
| 52 | // Default constructor. | 
|---|
| 53 | // | 
|---|
| 54 | MNewImagePar::MNewImagePar(const char *name, const char *title) | 
|---|
| 55 | { | 
|---|
| 56 | fName  = name  ? name  : "MNewImagePar"; | 
|---|
| 57 | fTitle = title ? title : "New image parameters"; | 
|---|
| 58 | } | 
|---|
| 59 |  | 
|---|
| 60 | // -------------------------------------------------------------------------- | 
|---|
| 61 | // | 
|---|
| 62 | void MNewImagePar::Reset() | 
|---|
| 63 | { | 
|---|
| 64 | fLeakage1 = -1; | 
|---|
| 65 | fLeakage2 = -1; | 
|---|
| 66 |  | 
|---|
| 67 | fConc  = -1; | 
|---|
| 68 | fConc1 = -1; | 
|---|
| 69 |  | 
|---|
| 70 | fNumUsedPixels = -1; | 
|---|
| 71 | fNumCorePixels = -1; | 
|---|
| 72 | } | 
|---|
| 73 |  | 
|---|
| 74 | // -------------------------------------------------------------------------- | 
|---|
| 75 | // | 
|---|
| 76 | //  Calculation of new image parameters | 
|---|
| 77 | // | 
|---|
| 78 | void MNewImagePar::Calc(const MGeomCam &geom, const MCerPhotEvt &evt, | 
|---|
| 79 | const MHillas &hillas) | 
|---|
| 80 | { | 
|---|
| 81 | fNumUsedPixels = 0; | 
|---|
| 82 | fNumCorePixels = 0; | 
|---|
| 83 |  | 
|---|
| 84 | const UInt_t npixevt = evt.GetNumPixels(); | 
|---|
| 85 |  | 
|---|
| 86 | Double_t edgepix1 = 0; | 
|---|
| 87 | Double_t edgepix2 = 0; | 
|---|
| 88 |  | 
|---|
| 89 | Float_t maxpix1 = 0;                                 // [#phot] | 
|---|
| 90 | Float_t maxpix2 = 0;                                 // [#phot] | 
|---|
| 91 |  | 
|---|
| 92 | for (UInt_t i=0; i<npixevt; i++) | 
|---|
| 93 | { | 
|---|
| 94 | const MCerPhotPix &pix = evt[i]; | 
|---|
| 95 | if (!pix.IsPixelUsed()) | 
|---|
| 96 | continue; | 
|---|
| 97 |  | 
|---|
| 98 | const Int_t pixid = pix.GetPixId(); | 
|---|
| 99 |  | 
|---|
| 100 | const MGeomPix &gpix = geom[pixid]; | 
|---|
| 101 |  | 
|---|
| 102 | Double_t nphot = pix.GetNumPhotons(); | 
|---|
| 103 |  | 
|---|
| 104 | // | 
|---|
| 105 | // count photons in outer rings of camera | 
|---|
| 106 | // | 
|---|
| 107 | if (gpix.IsInOutermostRing()) | 
|---|
| 108 | edgepix1 += nphot; | 
|---|
| 109 | if (gpix.IsInOuterRing()) | 
|---|
| 110 | edgepix2 += nphot; | 
|---|
| 111 |  | 
|---|
| 112 | // | 
|---|
| 113 | // count used and core pixels | 
|---|
| 114 | // | 
|---|
| 115 | if (pix.IsPixelCore()) | 
|---|
| 116 | fNumCorePixels++; | 
|---|
| 117 |  | 
|---|
| 118 | fNumUsedPixels++; | 
|---|
| 119 |  | 
|---|
| 120 | // | 
|---|
| 121 | // Now we are working on absolute values of nphot, which | 
|---|
| 122 | // must take pixel size into account | 
|---|
| 123 | // | 
|---|
| 124 | nphot *= geom.GetPixRatio(pixid); | 
|---|
| 125 |  | 
|---|
| 126 | if (nphot>maxpix1) | 
|---|
| 127 | { | 
|---|
| 128 | maxpix2  = maxpix1; | 
|---|
| 129 | maxpix1  = nphot;                            // [1] | 
|---|
| 130 | continue;                                    // [1] | 
|---|
| 131 | } | 
|---|
| 132 |  | 
|---|
| 133 | if (nphot>maxpix2) | 
|---|
| 134 | maxpix2 = nphot;                             // [1] | 
|---|
| 135 | } | 
|---|
| 136 |  | 
|---|
| 137 | fLeakage1 = edgepix1 / hillas.GetSize(); | 
|---|
| 138 | fLeakage2 = edgepix2 / hillas.GetSize(); | 
|---|
| 139 |  | 
|---|
| 140 | fConc  = (maxpix1+maxpix2)/hillas.GetSize();         // [ratio] | 
|---|
| 141 | fConc1 = maxpix1/hillas.GetSize();                   // [ratio] | 
|---|
| 142 |  | 
|---|
| 143 | SetReadyToSave(); | 
|---|
| 144 | } | 
|---|
| 145 |  | 
|---|
| 146 | // -------------------------------------------------------------------------- | 
|---|
| 147 | // | 
|---|
| 148 | void MNewImagePar::Print(Option_t *) const | 
|---|
| 149 | { | 
|---|
| 150 | *fLog << all; | 
|---|
| 151 | *fLog << "New Image Parameters (" << GetName() << ")" << endl; | 
|---|
| 152 | *fLog << " - Leakage1        = " << fLeakage1      << endl; | 
|---|
| 153 | *fLog << " - Leakage2        = " << fLeakage2      << endl; | 
|---|
| 154 | *fLog << " - Conc            = " << fConc          << " (ratio)" << endl; | 
|---|
| 155 | *fLog << " - Conc1           = " << fConc1         << " (ratio)" << endl; | 
|---|
| 156 | *fLog << " - Used Pixels [#] = " << fNumUsedPixels << " Pixels" << endl; | 
|---|
| 157 | *fLog << " - Core Pixels [#] = " << fNumCorePixels << " Pixels" << endl; | 
|---|
| 158 | } | 
|---|