source: trunk/MagicSoft/Mars/mfilter/MFSelFinal.cc@ 6439

Last change on this file since 6439 was 5431, checked in by wittek, 20 years ago
*** empty log message ***
File size: 5.3 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!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MFSelFinal
28//
29// WHAT ARE THE FINAL CUTS?
30//
31// This is a class to evaluate the Final Cuts
32// (these cuts define the final sample of gammas;
33// relevant for the calculation of the effective collection areas)
34//
35// to be called after the calculation of the hadroness
36//
37/////////////////////////////////////////////////////////////////////////////
38#include "MFSelFinal.h"
39
40#include <math.h>
41
42#include "MParList.h"
43
44#include "MMcEvt.hxx"
45
46#include "MCerPhotEvt.h"
47
48#include "MGeomPix.h"
49#include "MGeomCam.h"
50
51#include "MLog.h"
52#include "MLogManip.h"
53
54#include "MHillasExt.h"
55#include "MHillasSrc.h"
56#include "MHadronness.h"
57
58ClassImp(MFSelFinal);
59
60using namespace std;
61
62// --------------------------------------------------------------------------
63//
64// Default constructor.
65//
66MFSelFinal::MFSelFinal(const char *hilsrcname,
67 const char *name, const char *title)
68 : fHilSrcName(hilsrcname), fHadronnessName("MHadronness")
69{
70 fName = name ? name : "MFSelFinal";
71 fTitle = title ? title : "Class to evaluate the Final Cuts";
72
73 // default values of cuts
74 SetCuts(1.0, 100.0, 10.);
75}
76
77// --------------------------------------------------------------------------
78//
79// Set cut values
80//
81//
82void MFSelFinal::SetCuts(Float_t hadmax, Float_t alphamax, Float_t distmax)
83{
84 fHadronnessMax = hadmax;
85 fAlphaMax = alphamax;
86 fDistMax = distmax;
87
88}
89
90// --------------------------------------------------------------------------
91//
92// Set the pointers
93//
94Int_t MFSelFinal::PreProcess(MParList *pList)
95{
96 fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc");
97 if (!fHilSrc)
98 {
99 *fLog << dbginf << "MHillasSrc object " << fHilSrcName << " not found... aborting." << endl;
100 return kFALSE;
101 }
102
103 fHadronness = (MHadronness*)pList->FindObject(fHadronnessName, "MHadronness");
104 if (!fHadronness)
105 {
106 *fLog << dbginf << "MHadronness not found... aborting." << endl;
107 return kFALSE;
108 }
109
110 MGeomCam *cam = (MGeomCam*)pList->FindCreateObj("MGeomCamMagic","MGeomCam");
111 if (!cam)
112 {
113 *fLog << err << "MGeomCam (Camera Geometry) not found... aborting." << endl;
114 return kFALSE;
115 }
116
117 fMm2Deg = cam->GetConvMm2Deg();
118
119 memset(fCut, 0, sizeof(fCut));
120
121 //----------------------
122 *fLog << inf << "MFSelFinal cut values : fHadronnessMax, fAlphaMax, fDistMax = ";
123 *fLog << fHadronnessMax << ", " << fAlphaMax << ", " << fDistMax << endl;
124 //----------------------
125
126 return kTRUE;
127}
128
129Int_t MFSelFinal::Set(Int_t rc)
130{
131 fCut[rc]++;
132 fResult=kTRUE;
133 return kTRUE;
134}
135
136// --------------------------------------------------------------------------
137//
138// Evaluate final cuts
139//
140// if cuts are fulfilled set fResult = kTRUE
141//
142Int_t MFSelFinal::Process()
143{
144 const Double_t modalpha = fabs( fHilSrc->GetAlpha() );
145 const Double_t h = fHadronness->GetHadronness();
146
147 fResult = kFALSE;
148
149 if (h>fHadronnessMax)
150 return Set(1);
151
152 if (modalpha>fAlphaMax)
153 return Set(2);
154
155 if (fMm2Deg*fHilSrc->GetDist()>fDistMax)
156 return Set(3);
157
158 fCut[0]++;
159
160 return kTRUE;
161}
162
163// --------------------------------------------------------------------------
164//
165// Prints some statistics about the Final selections.
166//
167Int_t MFSelFinal::PostProcess()
168{
169 if (GetNumExecutions()==0)
170 return kTRUE;
171
172 *fLog << inf << endl;
173 *fLog << GetDescriptor() << " execution statistics:" << endl;
174 *fLog << dec << setfill(' ');
175 *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
176 *fLog << (int)(fCut[1]*100/GetNumExecutions());
177 *fLog << "%) Evts skipped due to: hadronness > "<< fHadronnessMax;
178 *fLog << " (hadronness from '" << fHadronnessName << "')" << endl;
179
180 *fLog << " " << setw(7) << fCut[2] << " (" << setw(3) ;
181 *fLog << (int)(fCut[2]*100/GetNumExecutions());
182 *fLog << "%) Evts skipped due to: |ALPHA| > " << fAlphaMax;
183 *fLog << " [degrees]" << endl;
184
185 *fLog << " " << setw(7) << fCut[3] << " (" << setw(3) ;
186 *fLog << (int)(fCut[3]*100/GetNumExecutions());
187 *fLog << "%) Evts skipped due to: DIST > " << fDistMax;
188 *fLog << " [degrees]" << endl;
189
190 *fLog << " " << fCut[0] << " (" ;
191 *fLog << (int)(fCut[0]*100/GetNumExecutions());
192 *fLog << "%) Evts survived Final selections!" << endl;
193 *fLog << endl;
194
195 return kTRUE;
196}
Note: See TracBrowser for help on using the repository browser.