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

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