| 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 | ! Author(s): Harald Kornmayer 1/2001
|
|---|
| 20 | ! Author(s): Rudolf Bock 10/2001 <mailto:Rudolf.Bock@cern.ch>
|
|---|
| 21 | ! Author(s): Wolfgang Wittek 6/2002 <mailto:wittek@mppmu.mpg.de>
|
|---|
| 22 | !
|
|---|
| 23 | ! Copyright: MAGIC Software Development, 2000-2003
|
|---|
| 24 | !
|
|---|
| 25 | !
|
|---|
| 26 | \* ======================================================================== */
|
|---|
| 27 |
|
|---|
| 28 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 29 | //
|
|---|
| 30 | // MConcentration
|
|---|
| 31 | //
|
|---|
| 32 | // Storage Container for image parameters
|
|---|
| 33 | //
|
|---|
| 34 | // basic image parameters
|
|---|
| 35 | //
|
|---|
| 36 | // Version 1:
|
|---|
| 37 | // ----------
|
|---|
| 38 | // fLength [mm] major axis of ellipse
|
|---|
| 39 | // fWidth [mm] minor axis
|
|---|
| 40 | // fDelta [rad] angle of major axis with x-axis
|
|---|
| 41 | // by definition the major axis is pointing into
|
|---|
| 42 | // the hemisphere x>0, thus -pi/2 < delta < pi/2
|
|---|
| 43 | // fSize [#CerPhot] total sum of pixels
|
|---|
| 44 | // fMeanX [mm] x of center of ellipse
|
|---|
| 45 | // fMeanY [mm] y of center of ellipse
|
|---|
| 46 | //
|
|---|
| 47 | // Version 2:
|
|---|
| 48 | // ----------
|
|---|
| 49 | // fNumCorePixels number of pixels called core
|
|---|
| 50 | // fNumUsedPixels number of pixels which survived the cleaning
|
|---|
| 51 | //
|
|---|
| 52 | // Version 3:
|
|---|
| 53 | // ----------
|
|---|
| 54 | // fNumCorePixels moved to MNewImagePar
|
|---|
| 55 | // fNumUsedPixels moved to MNewImagePar
|
|---|
| 56 | // fCosDelta added
|
|---|
| 57 | // fSinDelte added
|
|---|
| 58 | //
|
|---|
| 59 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 60 | #include "MConcentration.h"
|
|---|
| 61 |
|
|---|
| 62 | //#include <fstream>
|
|---|
| 63 |
|
|---|
| 64 | #include <TArrayF.h>
|
|---|
| 65 | #include <TArrayI.h>
|
|---|
| 66 | //#include <TEllipse.h>
|
|---|
| 67 |
|
|---|
| 68 | #include "MHillas.h"
|
|---|
| 69 |
|
|---|
| 70 | #include "MGeomPix.h"
|
|---|
| 71 | #include "MGeomCam.h"
|
|---|
| 72 |
|
|---|
| 73 | #include "MCerPhotPix.h"
|
|---|
| 74 | #include "MCerPhotEvt.h"
|
|---|
| 75 |
|
|---|
| 76 | #include "MLog.h"
|
|---|
| 77 | #include "MLogManip.h"
|
|---|
| 78 |
|
|---|
| 79 | ClassImp(MConcentration);
|
|---|
| 80 |
|
|---|
| 81 | using namespace std;
|
|---|
| 82 |
|
|---|
| 83 | // --------------------------------------------------------------------------
|
|---|
| 84 | //
|
|---|
| 85 | // Default constructor.
|
|---|
| 86 | //
|
|---|
| 87 | MConcentration::MConcentration(const char *name, const char *title)
|
|---|
| 88 | {
|
|---|
| 89 | fName = name ? name : "MConcentration";
|
|---|
| 90 | fTitle = title ? title : "Storage container for concentrations";
|
|---|
| 91 |
|
|---|
| 92 | Reset();
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | // --------------------------------------------------------------------------
|
|---|
| 96 | //
|
|---|
| 97 | // Destructor. Deletes the TEllipse if one exists.
|
|---|
| 98 | //
|
|---|
| 99 | MConcentration::~MConcentration()
|
|---|
| 100 | {
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | // --------------------------------------------------------------------------
|
|---|
| 104 | //
|
|---|
| 105 | // Initializes the values with defaults. For the default values see the
|
|---|
| 106 | // source code.
|
|---|
| 107 | //
|
|---|
| 108 | void MConcentration::Reset()
|
|---|
| 109 | {
|
|---|
| 110 | for (int i=0; i<9; i++)
|
|---|
| 111 | fConc[i] = -1;
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | // --------------------------------------------------------------------------
|
|---|
| 115 | //
|
|---|
| 116 | // Print the hillas Parameters to *fLog
|
|---|
| 117 | //
|
|---|
| 118 | void MConcentration::Print(Option_t *) const
|
|---|
| 119 | {
|
|---|
| 120 | *fLog << all;
|
|---|
| 121 | *fLog << "Concentrations (" << GetName() << ")" << endl;
|
|---|
| 122 | //*fLog << " - Length [mm] = " << fLength << endl;
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | // --------------------------------------------------------------------------
|
|---|
| 126 | //
|
|---|
| 127 | // Calculate the image parameters from a Cherenkov photon event
|
|---|
| 128 | // assuming Cher.photons/pixel and pixel coordinates are given
|
|---|
| 129 | // In case you don't call Calc from within an eventloop make sure, that
|
|---|
| 130 | // you call the Reset member function before.
|
|---|
| 131 | // Returns:
|
|---|
| 132 | // 0 no error
|
|---|
| 133 | // 1 number of pixels < 3
|
|---|
| 134 | // 2 size==0
|
|---|
| 135 | // 3 number of used pixel < 3
|
|---|
| 136 | // 4 CorrXY == 0
|
|---|
| 137 | //
|
|---|
| 138 | Int_t MConcentration::Calc(const MGeomCam &geom, const MCerPhotEvt &evt, const MHillas &hillas)
|
|---|
| 139 | {
|
|---|
| 140 | const UInt_t npixevt = evt.GetNumPixels();
|
|---|
| 141 |
|
|---|
| 142 | Float_t maxpix[9] = {0,0,0,0,0,0,0,0,0}; // [#phot]
|
|---|
| 143 |
|
|---|
| 144 | for (UInt_t i=0; i<npixevt; i++)
|
|---|
| 145 | {
|
|---|
| 146 | const MCerPhotPix &pix = evt[i];
|
|---|
| 147 |
|
|---|
| 148 | // skip unused pixels
|
|---|
| 149 | if (!pix.IsPixelUsed())
|
|---|
| 150 | continue;
|
|---|
| 151 |
|
|---|
| 152 | const Int_t pixid = pix.GetPixId();
|
|---|
| 153 |
|
|---|
| 154 | const MGeomPix &gpix = geom[pixid];
|
|---|
| 155 |
|
|---|
| 156 | Double_t nphot = pix.GetNumPhotons();
|
|---|
| 157 |
|
|---|
| 158 | //
|
|---|
| 159 | // Now we are working on absolute values of nphot, which
|
|---|
| 160 | // must take pixel size into account
|
|---|
| 161 | //
|
|---|
| 162 | nphot *= geom.GetPixRatio(pixid);
|
|---|
| 163 |
|
|---|
| 164 | // Compute Concentrations 1-8
|
|---|
| 165 |
|
|---|
| 166 | if(maxpix[0]<=nphot) {
|
|---|
| 167 | for(int i=0;i<8;i++)
|
|---|
| 168 | maxpix[8-i]=maxpix[7-i];
|
|---|
| 169 | maxpix[0]=nphot;
|
|---|
| 170 | }
|
|---|
| 171 | else
|
|---|
| 172 | for(int i=0;i<8;i++){
|
|---|
| 173 | if (nphot<maxpix[7-i]){
|
|---|
| 174 | for(int j=0;j<i-1;j++){
|
|---|
| 175 | maxpix[7-j]=maxpix[6-j]; // [1]
|
|---|
| 176 | }
|
|---|
| 177 | maxpix[8-i]=nphot;
|
|---|
| 178 | break;
|
|---|
| 179 | }
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | // Compute concentrations from the 8 pixels with higher signal
|
|---|
| 185 |
|
|---|
| 186 | fConc[0]=maxpix[0];
|
|---|
| 187 | for(int i=1;i<8;i++)
|
|---|
| 188 | {
|
|---|
| 189 | fConc[i]=fConc[i-1]+maxpix[i];
|
|---|
| 190 | }
|
|---|
| 191 |
|
|---|
| 192 | for(int i=0;i<8;i++)
|
|---|
| 193 | {
|
|---|
| 194 | fConc[i]/=hillas.GetSize(); // [ratio]
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | SetReadyToSave();
|
|---|
| 198 |
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 |
|
|---|