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

Last change on this file since 4226 was 3976, checked in by aliu, 20 years ago
*** empty log message ***
File size: 4.7 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//
29// Example:
30//
31// MIslands isl;
32// isl.SetName("MIslands1");
33
34// MImgCleanStd clean;
35// MIslandClean islclean(0.2);
36// islclean.SetInputName("MIslands1");
37// islclean.SetMethod(0); // for timing method
38//
39// tlist.AddToList(&clean);
40// tlist.AddToList(&islclean);
41//
42//
43// Input Containers:
44// MGeomCam
45// MCerPhotEvt
46// MPedestalCam
47// MArrivalTime
48// MIslands
49//
50// Output Containers:
51// MCerPhotEvt
52//
53/////////////////////////////////////////////////////////////////////////////
54#include "MIslandClean.h"
55
56#include <stdlib.h> // atof
57#include <fstream> // ofstream, SavePrimitive
58
59#include "MLog.h"
60#include "MLogManip.h"
61
62#include "MIslands.h"
63
64#include "MParList.h"
65
66#include "MGeomPix.h"
67#include "MGeomCam.h"
68
69#include "MCerPhotPix.h"
70#include "MCerPhotEvt.h"
71
72#include "MPedestalCam.h"
73#include "MPedestalPix.h"
74
75#include "MArrivalTimeCam.h"
76#include "MArrivalTimePix.h"
77
78ClassImp(MIslandClean);
79
80
81using namespace std;
82
83// --------------------------------------------------------------------------
84//
85// Default constructor.
86//
87MIslandClean::MIslandClean(const Float_t newThres, const char *name, const char *title)
88 : fIsl(NULL), fIslandCleaningMethod(kNoTiming), fIslCleanThres(newThres)
89{
90 fName = name ? name : "MIslandClean";
91 fTitle = title ? title : "Clean islands";
92}
93
94
95Int_t MIslandClean::PreProcess (MParList *pList)
96{
97 fCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
98 if (!fCam)
99 {
100 *fLog << dbginf << "MGeomCam not found (no geometry information available)... aborting." << endl;
101 return kFALSE;
102 }
103
104 fEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
105 if (!fEvt)
106 {
107 *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
108 return kFALSE;
109 }
110
111 fPed = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
112 if (!fPed)
113 {
114 *fLog << dbginf << "MPedestalCam not found... aborting." << endl;
115 return kFALSE;
116 }
117
118 fTime = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
119 if (!fTime)
120 {
121 *fLog << dbginf << "MArrivalTimeCam not found... aborting." << endl;
122 return kFALSE;
123 }
124
125 if (strlen(fIslName) > 0)
126 fIsl = (MIslands*)pList->FindObject(AddSerialNumber(fIslName));
127 else
128 fIsl = (MIslands*)pList->FindObject(AddSerialNumber("MIslands"));
129 if (!fIsl)
130 {
131 *fLog << dbginf << "MIslands not found... aborting." << endl;
132 return kFALSE;
133 }
134
135 return kTRUE;
136}
137
138
139
140Int_t MIslandClean::Process()
141{
142 //
143 //eliminates the island with a signal-to-noise
144 //lower than a given limit
145 //
146 //if ( fIslandCleaningMethod == kNoTiming ){
147 if ( fIslandCleaningMethod == 1 ){
148 Int_t nisl = fIsl->GetIslNum();
149
150 for(Int_t isl = 0; isl<nisl ; isl++)
151 {
152 if(fIsl->GetSigToNoise(isl) < fIslCleanThres)
153 {
154 for(Int_t idx = 0; idx<577; idx++)
155 {
156 MCerPhotPix &pix = (*fEvt)[idx];
157
158 if (fIsl->GetIslId(idx) == isl)
159 pix.SetPixelUnused();
160 }
161 }
162 }
163 }
164
165 //
166 //eliminates the island with a signal-to-noise
167 //lower than a given limit
168 //
169 //else if( fIslandCleaningMethod == kTiming ){
170 else if( fIslandCleaningMethod == 0 ){
171 Int_t nisl = fIsl->GetIslNum();
172
173 for(Int_t isl = 0; isl<nisl ; isl++)
174 {
175 //fIslCleanThreshold has different values, FIXME, put two variables
176
177 if(fIsl->GetTimeSpread(isl) > fIslCleanThres)
178 {
179 for(Int_t idx = 0;idx<577; idx++)
180 {
181 MCerPhotPix &pix = (*fEvt)[idx];
182
183 if (fIsl->GetIslId(idx) == isl)
184 pix.SetPixelUnused();
185 }
186 }
187
188 }
189 }
190
191 fEvt->SetReadyToSave();
192
193 return kTRUE;
194
195}
Note: See TracBrowser for help on using the repository browser.