source: trunk/MagicSoft/Mars/mtemp/mifae/library/MIslandClean.cc@ 4800

Last change on this file since 4800 was 4293, checked in by aliu, 20 years ago
*** empty log message ***
File size: 5.4 KB
Line 
1/* ======================================================================== *\
2!
3!
4! Author(s): Ester Aliu, 3/2004
5!
6!
7\* ======================================================================== */
8
9/////////////////////////////////////////////////////////////////////////////
10//
11// MIslandClean
12//
13// The Island Cleaning task selects the islands you use for the Hillas
14// parameters calculation, after the normal image cleaning.
15//
16// There are two methods to make the selection:
17//
18// - No time method, as used is Whipple. It calculates an island parameter
19// called "signal to noise" and adds a new threshold that eliminates some
20// of the islands. The way the island is eliminated is seeting the pixels
21// of the islands as UNUSED
22//
23// - Time method, taking profit of the time information in MAGIC.
24// Calculates the maximum time difference (in time slices) for each island
25// and corrects for the island size. With an other new threshold "noise"
26// islands are supposed to be eliminated.
27//
28// Other cleanings that are allowed in this code are:
29//
30// - Resting only with the continent, i.e. the larger island
31//
32// Example:
33//
34// MIslands isl;
35// isl.SetName("MIslands1");
36
37// MImgCleanStd clean;
38// MIslandClean islclean(0.2);
39// islclean.SetInputName("MIslands1");
40// islclean.SetMethod(0); // for timing method
41//
42// tlist.AddToList(&clean);
43// tlist.AddToList(&islclean);
44//
45//
46// Input Containers:
47// MGeomCam
48// MCerPhotEvt
49// MPedestalCam
50// MArrivalTime
51// MIslands
52//
53// Output Containers:
54// MCerPhotEvt
55//
56/////////////////////////////////////////////////////////////////////////////
57#include "MIslandClean.h"
58
59#include <stdlib.h> // atof
60#include <fstream> // ofstream, SavePrimitive
61
62#include "MLog.h"
63#include "MLogManip.h"
64
65#include "MIslands.h"
66
67#include "MParList.h"
68
69#include "MGeomPix.h"
70#include "MGeomCam.h"
71
72#include "MCerPhotPix.h"
73#include "MCerPhotEvt.h"
74
75#include "MPedestalCam.h"
76#include "MPedestalPix.h"
77
78#include "MArrivalTimeCam.h"
79#include "MArrivalTimePix.h"
80
81ClassImp(MIslandClean);
82
83
84using namespace std;
85
86// --------------------------------------------------------------------------
87//
88// Default constructor.
89//
90MIslandClean::MIslandClean(const Float_t newThres, const char *name, const char *title)
91 : fIsl(NULL), fIslandCleaningMethod(kNoTiming), fIslCleanThres(newThres)
92{
93 fName = name ? name : "MIslandClean";
94 fTitle = title ? title : "Clean islands";
95}
96
97
98Int_t MIslandClean::PreProcess (MParList *pList)
99{
100 fCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
101 if (!fCam)
102 {
103 *fLog << dbginf << "MGeomCam not found (no geometry information available)... aborting." << endl;
104 return kFALSE;
105 }
106
107 fEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
108 if (!fEvt)
109 {
110 *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
111 return kFALSE;
112 }
113
114 fPed = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
115 if (!fPed)
116 {
117 *fLog << dbginf << "MPedestalCam not found... aborting." << endl;
118 return kFALSE;
119 }
120
121 fTime = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
122 if (!fTime)
123 {
124 *fLog << dbginf << "MArrivalTimeCam not found... aborting." << endl;
125 return kFALSE;
126 }
127
128 if (strlen(fIslName) > 0)
129 fIsl = (MIslands*)pList->FindObject(AddSerialNumber(fIslName));
130 else
131 fIsl = (MIslands*)pList->FindObject(AddSerialNumber("MIslands"));
132 if (!fIsl)
133 {
134 *fLog << dbginf << "MIslands not found... aborting." << endl;
135 return kFALSE;
136 }
137
138 return kTRUE;
139}
140
141
142
143Int_t MIslandClean::Process()
144{
145 //
146 //eliminates the island with a signal-to-noise
147 //lower than a given limit
148 //
149 //if ( fIslandCleaningMethod == kNoTiming ){
150 if ( fIslandCleaningMethod == 1 ){
151 Int_t nisl = fIsl->GetIslNum();
152
153 for(Int_t isl = 0; isl<nisl ; isl++)
154 {
155 if(fIsl->GetSigToNoise(isl) < fIslCleanThres)
156 {
157 for(Int_t idx = 0; idx<577; idx++)
158 {
159 MCerPhotPix &pix = (*fEvt)[idx];
160
161 if (fIsl->GetIslId(idx) == isl)
162 pix.SetPixelUnused();
163 }
164 }
165 }
166 }
167
168 //
169 //eliminates the island with a time spread
170 //higher than a given limit
171 //
172 //else if( fIslandCleaningMethod == kTiming ){
173 else if( fIslandCleaningMethod == 0 ){
174 Int_t nisl = fIsl->GetIslNum();
175
176 for(Int_t isl = 0; isl<nisl ; isl++)
177 {
178 //fIslCleanThreshold has different values, FIXME, put two variables
179
180 if(fIsl->GetTimeSpread(isl) > fIslCleanThres)
181 {
182 for(Int_t idx = 0;idx<577; idx++)
183 {
184 MCerPhotPix &pix = (*fEvt)[idx];
185
186 if (fIsl->GetIslId(idx) == isl)
187 pix.SetPixelUnused();
188 }
189 }
190
191 }
192 }
193
194 //
195 //eliminates all the islands except the continent,
196 //i.e. the larger island in the event
197 //
198 else if( fIslandCleaningMethod == 3 ){
199 Int_t nisl = fIsl->GetIslNum();
200
201 Int_t max = -1000;
202 Int_t idMax;
203
204 for(Int_t isl = 0; isl<nisl ; isl++)
205 {
206 if (fIsl->GetPixNum(isl)>max)
207 {
208 max = fIsl->GetPixNum(isl);
209 idMax = isl;
210 }
211 }
212
213 for(Int_t isl = 0; isl<nisl ; isl++)
214 {
215 if (isl != idMax)
216 {
217 for(Int_t idx = 0;idx<577; idx++)
218 {
219 MCerPhotPix &pix = (*fEvt)[idx];
220
221 if (fIsl->GetIslId(idx) == isl)
222 pix.SetPixelUnused();
223 }
224 }
225 }
226 }
227
228 fEvt->SetReadyToSave();
229
230 return kTRUE;
231
232}
Note: See TracBrowser for help on using the repository browser.