source: trunk/MagicSoft/Mars/mtemp/mifae/library/MIslandsClean.cc@ 5295

Last change on this file since 5295 was 5170, checked in by aliu, 21 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 "MIslandsClean.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#include "MImgIsland.h"
67
68#include "MParList.h"
69
70#include "MGeomPix.h"
71#include "MGeomCam.h"
72
73#include "MCerPhotPix.h"
74#include "MCerPhotEvt.h"
75
76#include "MPedestalCam.h"
77#include "MPedestalPix.h"
78
79#include "MArrivalTimeCam.h"
80#include "MArrivalTimePix.h"
81
82ClassImp(MIslandsClean);
83
84
85using namespace std;
86
87// --------------------------------------------------------------------------
88//
89// Default constructor.
90//
91MIslandsClean::MIslandsClean(const Float_t newThres, const char *name, const char *title)
92 : fIsl(NULL), fIslandCleaningMethod(kNoTiming), fIslCleanThres(newThres)
93{
94 fName = name ? name : "MIslandsClean";
95 fTitle = title ? title : "Clean islands";
96}
97
98
99Int_t MIslandsClean::PreProcess (MParList *pList)
100{
101 fCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
102 if (!fCam)
103 {
104 *fLog << dbginf << "MGeomCam not found (no geometry information available)... aborting." << endl;
105 return kFALSE;
106 }
107
108 fEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
109 if (!fEvt)
110 {
111 *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
112 return kFALSE;
113 }
114
115 fPed = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
116 if (!fPed)
117 {
118 *fLog << dbginf << "MPedestalCam not found... aborting." << endl;
119 return kFALSE;
120 }
121
122 fTime = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
123 if (!fTime)
124 {
125 *fLog << dbginf << "MArrivalTimeCam not found... aborting." << endl;
126 return kFALSE;
127 }
128
129 if (strlen(fIslName) > 0)
130 fIsl = (MIslands*)pList->FindObject(AddSerialNumber(fIslName));
131 else
132 fIsl = (MIslands*)pList->FindObject(AddSerialNumber("MIslands"));
133 if (!fIsl)
134 {
135 *fLog << dbginf << "MIslands not found... aborting." << endl;
136 return kFALSE;
137 }
138
139 return kTRUE;
140}
141
142
143
144Int_t MIslandsClean::Process()
145{
146 //
147 //eliminates the island with a signal-to-noise
148 //lower than a given limit
149 //
150 //if ( fIslandCleaningMethod == kNoTiming ){
151
152 MImgIsland *imgIsl = new MImgIsland;
153 TIter Next(fIsl->GetList());
154
155 Int_t pixNum = 0;
156 Int_t idPix = -1;
157
158 if ( fIslandCleaningMethod == 1 ) {
159 while ((imgIsl=(MImgIsland*)Next())) {
160
161 if(imgIsl->GetSigToNoise() < fIslCleanThres)
162 {
163 pixNum = imgIsl->GetPixNum();
164
165 for(Int_t k = 0; k<pixNum; k++)
166 {
167 idPix = imgIsl->GetPixList(k);
168 MCerPhotPix &pix = (*fEvt)[idPix];
169 pix.SetPixelUnused();
170 }
171 }
172 }
173 }
174
175 //
176 //eliminates the island with a time spread
177 //higher than a given limit
178 //
179 //else if( fIslandCleaningMethod == kTiming ){
180 else if( fIslandCleaningMethod == 0 ){
181 while ((imgIsl=(MImgIsland*)Next())) {
182
183 //fIslCleanThreshold has different values, FIXME, put two variables
184 if(imgIsl->GetTimeSpread() > fIslCleanThres)
185 {
186 pixNum = imgIsl->GetPixNum();
187
188 for(Int_t k = 0; k<pixNum; k++)
189 {
190 idPix = imgIsl->GetPixList(k);
191 MCerPhotPix &pix = (*fEvt)[idPix];
192 pix.SetPixelUnused();
193 }
194 }
195 }
196
197 }
198
199 //
200 //eliminates all the islands except the continent,
201 //i.e. the larger island in the event
202 //
203 else if( fIslandCleaningMethod == 3 ){
204 Int_t i = 0;
205 while ((imgIsl=(MImgIsland*)Next())) {
206 if (i != 0){
207
208 pixNum = imgIsl->GetPixNum();
209
210 for(Int_t k = 0; k<pixNum; k++)
211 {
212 idPix = imgIsl->GetPixList(k);
213 MCerPhotPix &pix = (*fEvt)[idPix];
214 pix.SetPixelUnused();
215 }
216 }
217 i++;
218 }
219 }
220
221 fEvt->SetReadyToSave();
222
223 return kTRUE;
224
225}
Note: See TracBrowser for help on using the repository browser.