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

Last change on this file since 2640 was 2209, checked in by tbretz, 21 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
49using namespace std;
50
51// --------------------------------------------------------------------------
52//
53// Default constructor. You can specify the numer of loops how often a
54// smoothing should be done. The default is 1.
55//
56MCameraSmooth::MCameraSmooth(Byte_t n, const char *name, const char *title)
57 : fCounts(n), fUseCentralPixel(kTRUE)
58{
59 fName = name ? name : "MCameraSmooth";
60 fTitle = title ? title : "Task to smooth the camera";
61}
62
63// --------------------------------------------------------------------------
64//
65// - get the MCerPhotEvt from the parlist (abort if missing)
66// - get MGeomCam from the parameter list
67//
68Int_t MCameraSmooth::PreProcess (MParList *pList)
69{
70 fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
71 if (!fEvt)
72 {
73 *fLog << err << dbginf << "MCerPhotEvt not found... aborting." << endl;
74 return kFALSE;
75 }
76
77 fGeomCam = (MGeomCam*)pList->FindObject("MGeomCam");
78 if (!fGeomCam)
79 {
80 *fLog << warn << dbginf << "No camera geometry available... aborting." << endl;
81
82 return kFALSE;
83 }
84 return kTRUE;
85}
86
87// --------------------------------------------------------------------------
88//
89// Do the smoothing
90//
91Int_t MCameraSmooth::Process()
92{
93 const UShort_t entries = fEvt->GetNumPixels();
94
95 //
96 // remove the pixels in fPixelsID if they are set to be used,
97 // (set them to 'unused' state)
98 //
99
100 Double_t *photons = new Double_t[entries];
101 Double_t *errors = new Double_t[entries];
102
103 for (int n=0; n<fCounts; n++)
104 {
105 for (UShort_t i=0; i<entries; i++)
106 {
107 MCerPhotPix &pix = (*fEvt)[i];
108
109 const Int_t id = pix.GetPixId();
110
111 const MGeomPix &gpix = (*fGeomCam)[id];
112
113 const Int_t n = gpix.GetNumNeighbors();
114
115 Int_t num = fUseCentralPixel ? 1 : 0;
116 photons[i] = fUseCentralPixel ? pix.GetNumPhotons() : 0;
117 errors[i] = fUseCentralPixel ? pix.GetErrorPhot() : 0;
118
119 for (int j=0; j<n; j++)
120 {
121 const UShort_t nid = gpix.GetNeighbor(j);
122
123 const MCerPhotPix *evtpix = fEvt->GetPixById(nid);
124 if (evtpix)
125 {
126 photons[i] += evtpix->GetNumPhotons();
127 errors[i] += evtpix->GetErrorPhot();
128 }
129 num++;
130 }
131
132 photons[i] /= num;
133 errors[i] /= num;
134 }
135
136 for (UShort_t i=0; i<entries; i++)
137 (*fEvt)[i].Set(photons[i], errors[i]);
138 }
139
140 delete photons;
141 delete errors;
142
143 return kTRUE;
144}
145
Note: See TracBrowser for help on using the repository browser.