source: trunk/MagicSoft/Mars/mimage/MCameraSmooth.cc@ 2006

Last change on this file since 2006 was 1940, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 4.4 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): Thomas Bretz 08/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2002
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26// //
27// MCameraSmooth //
28// //
29// This task fills each pixel in the camera with the average of the //
30// number of cerenkov photons from its surrounding pixels. This can //
31// be done using the central pixel or ignoring the central pixel. //
32// //
33/////////////////////////////////////////////////////////////////////////////
34#include "MCameraSmooth.h"
35
36#include "MLog.h"
37#include "MLogManip.h"
38
39#include "MParList.h"
40
41#include "MGeomPix.h"
42#include "MGeomCam.h"
43#include "MCerPhotPix.h"
44#include "MCerPhotEvt.h"
45#include "MBlindPixels.h"
46
47ClassImp(MCameraSmooth);
48
49// --------------------------------------------------------------------------
50//
51// Default constructor. You can specify the numer of loops how often a
52// smoothing should be done. The default is 1.
53//
54MCameraSmooth::MCameraSmooth(Byte_t n, const char *name, const char *title)
55 : fCounts(n), fUseCentralPixel(kTRUE)
56{
57 fName = name ? name : "MCameraSmooth";
58 fTitle = title ? title : "Task to smooth the camera";
59}
60
61// --------------------------------------------------------------------------
62//
63// - get the MCerPhotEvt from the parlist (abort if missing)
64// - get MGeomCam from the parameter list
65//
66Bool_t MCameraSmooth::PreProcess (MParList *pList)
67{
68 fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
69 if (!fEvt)
70 {
71 *fLog << err << dbginf << "MCerPhotEvt not found... aborting." << endl;
72 return kFALSE;
73 }
74
75 fGeomCam = (MGeomCam*)pList->FindObject("MGeomCam");
76 if (!fGeomCam)
77 {
78 *fLog << warn << dbginf << "No camera geometry available... aborting." << endl;
79
80 return kFALSE;
81 }
82 return kTRUE;
83}
84
85// --------------------------------------------------------------------------
86//
87// Do the smoothing
88//
89Bool_t MCameraSmooth::Process()
90{
91 const UShort_t entries = fEvt->GetNumPixels();
92
93 //
94 // remove the pixels in fPixelsID if they are set to be used,
95 // (set them to 'unused' state)
96 //
97
98 Double_t *photons = new Double_t[entries];
99 Double_t *errors = new Double_t[entries];
100
101 for (int n=0; n<fCounts; n++)
102 {
103 for (UShort_t i=0; i<entries; i++)
104 {
105 MCerPhotPix &pix = (*fEvt)[i];
106
107 const Int_t id = pix.GetPixId();
108
109 const MGeomPix &gpix = (*fGeomCam)[id];
110
111 const Int_t n = gpix.GetNumNeighbors();
112
113 Int_t num = fUseCentralPixel ? 1 : 0;
114 photons[i] = fUseCentralPixel ? pix.GetNumPhotons() : 0;
115 errors[i] = fUseCentralPixel ? pix.GetErrorPhot() : 0;
116
117 for (int j=0; j<n; j++)
118 {
119 const UShort_t nid = gpix.GetNeighbor(j);
120
121 const MCerPhotPix *evtpix = fEvt->GetPixById(nid);
122 if (evtpix)
123 {
124 photons[i] += evtpix->GetNumPhotons();
125 errors[i] += evtpix->GetErrorPhot();
126 }
127 num++;
128 }
129
130 photons[i] /= num;
131 errors[i] /= num;
132 }
133
134 for (UShort_t i=0; i<entries; i++)
135 (*fEvt)[i].Set(photons[i], errors[i]);
136 }
137
138 delete photons;
139 delete errors;
140
141 return kTRUE;
142}
143
Note: See TracBrowser for help on using the repository browser.