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 |
|
---|
47 | #include "MMcRunHeader.hxx"
|
---|
48 |
|
---|
49 | ClassImp(MCameraSmooth);
|
---|
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 | //
|
---|
56 | MCameraSmooth::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 | //
|
---|
68 | Bool_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 | //
|
---|
91 | Bool_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 | photons[i] = fUseCentralPixel ? (*fEvt)[id].GetNumPhotons() : 0;
|
---|
116 | errors[i] = fUseCentralPixel ? (*fEvt)[id].GetErrorPhot() : 0;
|
---|
117 | for (int j=0; j<n; j++)
|
---|
118 | {
|
---|
119 | const UShort_t nid = gpix.GetNeighbor(j);
|
---|
120 |
|
---|
121 | photons[i] += (*fEvt)[nid].GetNumPhotons();
|
---|
122 | errors[i] += (*fEvt)[nid].GetErrorPhot();
|
---|
123 | }
|
---|
124 |
|
---|
125 | photons[i] /= fUseCentralPixel ? n+1 : n;
|
---|
126 | errors[i] /= fUseCentralPixel ? n+1 : n;
|
---|
127 | }
|
---|
128 |
|
---|
129 | for (UShort_t i=0; i<entries; i++)
|
---|
130 | (*fEvt)[i].Set(photons[i], errors[i]);
|
---|
131 | }
|
---|
132 |
|
---|
133 | delete photons;
|
---|
134 | delete errors;
|
---|
135 |
|
---|
136 | return kTRUE;
|
---|
137 | }
|
---|
138 |
|
---|