source: trunk/MagicSoft/Mars/mfilter/MFCT1SelFinal.cc@ 2010

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