source: trunk/MagicSoft/Mars/mfilter/MFSelStandard.cc@ 6204

Last change on this file since 6204 was 5431, checked in by wittek, 20 years ago
*** empty log message ***
File size: 6.7 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): Wolfgang Wittek, 04/2003 <mailto:wittek@mppmu.mpg.de>
19! Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2003
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MFSelStandard
29//
30// This is a class to evaluate the Standard Cuts
31//
32// WHAT ARE THE STANDARD CUTS? //
33//
34// to be called after the calculation of the image parameters
35// before the g/h separation
36//
37/////////////////////////////////////////////////////////////////////////////
38
39#include "MFSelStandard.h"
40
41#include "MParList.h"
42
43#include "MMcEvt.hxx"
44
45#include "MGeomPix.h"
46#include "MGeomCam.h"
47
48#include "MCerPhotEvt.h"
49
50#include "MLog.h"
51#include "MLogManip.h"
52
53#include "MHillas.h"
54#include "MHillasExt.h"
55#include "MHillasSrc.h"
56#include "MNewImagePar.h"
57
58ClassImp(MFSelStandard);
59
60using namespace std;
61
62// --------------------------------------------------------------------------
63//
64// Default constructor.
65//
66MFSelStandard::MFSelStandard(const char *hilsrcname,
67 const char *name, const char *title)
68 : fHilName("MHillas"), fHilSrcName(hilsrcname), fImgParName("MNewImagePar")
69{
70 fName = name ? name : "MFSelStandard";
71 fTitle = title ? title : "Class to evaluate the Standard Cuts";
72
73 // default values of cuts
74 SetCuts(92, 4, 60, 0.4, 1.05, 0.0, 0.0);
75}
76
77// --------------------------------------------------------------------------
78//
79// Set the values for the cuts
80//
81//
82void MFSelStandard::SetCuts(Float_t usedpixelsmax, Float_t corepixelsmin,
83 Float_t sizemin, Float_t distmin, Float_t distmax,
84 Float_t lengthmin, Float_t widthmin)
85{
86 fUsedPixelsMax = usedpixelsmax;
87 fCorePixelsMin = corepixelsmin;
88 fSizeMin = sizemin;
89 fDistMin = distmin;
90 fDistMax = distmax;
91 fLengthMin = lengthmin;
92 fWidthMin = widthmin;
93
94}
95
96// --------------------------------------------------------------------------
97//
98// MISSING
99//
100Int_t MFSelStandard::PreProcess(MParList *pList)
101{
102 fHil = (MHillas*)pList->FindObject(fHilName, "MHillas");
103 if (!fHil)
104 {
105 *fLog << err << fHilName << " [MHillas] not found... aborting." << endl;
106 return kFALSE;
107 }
108
109 fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc");
110 if (!fHilSrc)
111 {
112 *fLog << err << fHilSrcName << " [MHillasSrc] not found... aborting." << endl;
113 return kFALSE;
114 }
115
116 fNewImgPar = (MNewImagePar*)pList->FindObject(fImgParName, "MNewImagePar");
117 if (!fNewImgPar)
118 {
119 *fLog << err << fImgParName << " [MNewImagePar] not found... aborting." << endl;
120 return kFALSE;
121 }
122
123 MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
124 if (!cam)
125 {
126 *fLog << err << "MGeomCam (Camera Geometry) not found... aborting." << endl;
127 return kFALSE;
128 }
129
130 fMm2Deg = cam->GetConvMm2Deg();
131
132 memset(fCut, 0, sizeof(fCut));
133
134 //--------------------
135 *fLog << inf << "MFSelStandard cut values : fUsedPixelsMax, fCorePixelsMin = ";
136 *fLog << fUsedPixelsMax << ", " << fCorePixelsMin << endl;
137 *fLog << inf << " fSizeMin, fDistMin, fDistMax = " << fSizeMin ;
138 *fLog << ", " << fDistMin << ", " << fDistMax << endl;
139 *fLog << inf << " fLengthMin, fWidthMin = " << fLengthMin ;
140 *fLog << ", " << fWidthMin << endl;
141 //--------------------
142
143 return kTRUE;
144}
145
146Bool_t MFSelStandard::Set(Int_t rc)
147{
148 fResult = kTRUE;
149 fCut[rc]++;
150 return kTRUE;
151}
152// --------------------------------------------------------------------------
153//
154// Evaluate standard cuts
155//
156// if selections are fulfilled set fResult = kTRUE;
157//
158//
159Int_t MFSelStandard::Process()
160{
161 const Double_t length = fHil->GetLength() * fMm2Deg;
162 const Double_t width = fHil->GetWidth() * fMm2Deg;
163 const Double_t dist = fHilSrc->GetDist()* fMm2Deg;
164 //const Double_t delta = fHil->GetDelta() * kRad2Deg;
165 const Double_t size = fHil->GetSize();
166 const Int_t numusedpixels = fNewImgPar->GetNumUsedPixels();
167 const Int_t numcorepixels = fNewImgPar->GetNumCorePixels();
168
169 fResult = kFALSE;
170
171 if (numusedpixels>=fUsedPixelsMax || numcorepixels<fCorePixelsMin)
172 return Set(1);
173
174 if (size<=fSizeMin )
175 return Set(2);
176
177 if (dist<fDistMin || dist>fDistMax)
178 return Set(3);
179
180 if (length<=fLengthMin || width<=fWidthMin)
181 return Set(4);
182
183 fCut[0]++;
184 return kTRUE;
185}
186
187// --------------------------------------------------------------------------
188//
189// Prints some statistics about the Standard selections.
190//
191Int_t MFSelStandard::PostProcess()
192{
193 if (GetNumExecutions()==0)
194 return kTRUE;
195
196 *fLog << inf << endl;
197 *fLog << GetDescriptor() << " execution statistics:" << endl;
198 *fLog << dec << setfill(' ');
199 *fLog << " " << setw(7) << fCut[1] << " (" << setw(3);
200 *fLog << (int)(fCut[1]*100/GetNumExecutions()) ;
201 *fLog << "%) Evts skipped due to: Used pixels >= " << fUsedPixelsMax ;
202 *fLog << " or Core pixels < " << fCorePixelsMin << endl;
203
204 *fLog << " " << setw(7) << fCut[2] << " (" << setw(3) ;
205 *fLog << (int)(fCut[2]*100/GetNumExecutions()) ;
206 *fLog << "%) Evts skipped due to: SIZE <= " << fSizeMin << endl;
207
208 *fLog << " " << setw(7) << fCut[3] << " (" << setw(3) ;
209 *fLog << (int)(fCut[3]*100/GetNumExecutions()) ;
210 *fLog << "%) Evts skipped due to: DIST < " << fDistMin;
211 *fLog << " or DIST > " << fDistMax << endl;
212
213 *fLog << " " << setw(7) << fCut[4] << " (" << setw(3) ;
214 *fLog << (int)(fCut[4]*100/GetNumExecutions()) ;
215 *fLog << "%) Evts skipped due to: LENGTH <= " << fLengthMin;
216 *fLog << " or WIDTH <= " << fWidthMin << endl;
217
218 *fLog << " " << fCut[0] << " (" ;
219 *fLog << (int)(fCut[0]*100/GetNumExecutions()) ;
220 *fLog << "%) Evts survived Standard selections!" << endl;
221 *fLog << endl;
222
223 return kTRUE;
224}
Note: See TracBrowser for help on using the repository browser.