source: trunk/MagicSoft/Mars/mimage/MNewImagePar.cc@ 3464

Last change on this file since 3464 was 3183, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 5.0 KB
Line 
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-2004
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MNewImagePar
28//
29// Storage Container for new image parameters
30//
31// fLeakage1 ratio: (photons in most outer ring of pixels) over fSize
32// fLeakage2 ratio: (photons in the 2 outer rings of pixels) over fSize
33// fNumSaturatedPixels: number of pixels in which at least one slice
34// of the low gain FADC was saturated.
35//
36// Version 2:
37// ----------
38// - added fNumSaturatedPixels
39//
40/////////////////////////////////////////////////////////////////////////////
41#include "MNewImagePar.h"
42
43#include <fstream>
44
45#include "MLog.h"
46#include "MLogManip.h"
47
48#include "MHillas.h"
49
50#include "MGeomCam.h"
51#include "MGeomPix.h"
52
53#include "MCerPhotEvt.h"
54#include "MCerPhotPix.h"
55
56ClassImp(MNewImagePar);
57
58using namespace std;
59
60// --------------------------------------------------------------------------
61//
62// Default constructor.
63//
64MNewImagePar::MNewImagePar(const char *name, const char *title)
65{
66 fName = name ? name : "MNewImagePar";
67 fTitle = title ? title : "New image parameters";
68}
69
70// --------------------------------------------------------------------------
71//
72void MNewImagePar::Reset()
73{
74 fLeakage1 = -1;
75 fLeakage2 = -1;
76
77 fConc = -1;
78 fConc1 = -1;
79
80 fNumUsedPixels = -1;
81 fNumCorePixels = -1;
82
83 fNumSaturatedPixels = -1;
84}
85
86// --------------------------------------------------------------------------
87//
88// Calculation of new image parameters
89//
90void MNewImagePar::Calc(const MGeomCam &geom, const MCerPhotEvt &evt,
91 const MHillas &hillas)
92{
93 fNumUsedPixels = 0;
94 fNumCorePixels = 0;
95
96 fNumSaturatedPixels = 0;
97
98 const UInt_t npixevt = evt.GetNumPixels();
99
100 Double_t edgepix1 = 0;
101 Double_t edgepix2 = 0;
102
103 Float_t maxpix1 = 0; // [#phot]
104 Float_t maxpix2 = 0; // [#phot]
105
106 for (UInt_t i=0; i<npixevt; i++)
107 {
108 const MCerPhotPix &pix = evt[i];
109
110 // count saturated pixels
111 if (pix.IsPixelSaturated())
112 fNumSaturatedPixels++;
113
114 // skip unused pixels
115 if (!pix.IsPixelUsed())
116 continue;
117
118 // count used and core pixels
119 if (pix.IsPixelCore())
120 fNumCorePixels++;
121
122 // count used pixels
123 fNumUsedPixels++;
124
125 const Int_t pixid = pix.GetPixId();
126
127 const MGeomPix &gpix = geom[pixid];
128
129 Double_t nphot = pix.GetNumPhotons();
130
131 //
132 // count photons in outer rings of camera
133 //
134 if (gpix.IsInOutermostRing())
135 edgepix1 += nphot;
136 if (gpix.IsInOuterRing())
137 edgepix2 += nphot;
138
139 //
140 // Now we are working on absolute values of nphot, which
141 // must take pixel size into account
142 //
143 nphot *= geom.GetPixRatio(pixid);
144
145 if (nphot>maxpix1)
146 {
147 maxpix2 = maxpix1;
148 maxpix1 = nphot; // [1]
149 continue; // [1]
150 }
151
152 if (nphot>maxpix2)
153 maxpix2 = nphot; // [1]
154 }
155
156 fLeakage1 = edgepix1 / hillas.GetSize();
157 fLeakage2 = edgepix2 / hillas.GetSize();
158
159 fConc = (maxpix1+maxpix2)/hillas.GetSize(); // [ratio]
160 fConc1 = maxpix1/hillas.GetSize(); // [ratio]
161
162 SetReadyToSave();
163}
164
165// --------------------------------------------------------------------------
166//
167void MNewImagePar::Print(Option_t *) const
168{
169 *fLog << all;
170 *fLog << "New Image Parameters (" << GetName() << ")" << endl;
171 *fLog << " - Leakage1 [1] = " << fLeakage1 << endl;
172 *fLog << " - Leakage2 [1] = " << fLeakage2 << endl;
173 *fLog << " - Conc [1] = " << fConc << " (ratio)" << endl;
174 *fLog << " - Conc1 [1] = " << fConc1 << " (ratio)" << endl;
175 *fLog << " - Used Pixels [#] = " << fNumUsedPixels << " Pixels" << endl;
176 *fLog << " - Core Pixels [#] = " << fNumCorePixels << " Pixels" << endl;
177 *fLog << " - Sat. Pixels [#] = " << fNumSaturatedPixels << " Pixels" << endl;
178}
Note: See TracBrowser for help on using the repository browser.