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

Last change on this file since 2107 was 2076, checked in by moralejo, 22 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// MFCT1SelFinal
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 "MFCT1SelFinal.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(MFCT1SelFinal);
59
60// --------------------------------------------------------------------------
61//
62// Default constructor.
63//
64MFCT1SelFinal::MFCT1SelFinal(const char *hilsrcname,
65 const char *name, const char *title)
66 : fHilSrcName(hilsrcname), fHadronnessName("MHadronness")
67{
68 fName = name ? name : "MFCT1SelFinal";
69 fTitle = title ? title : "Class to evaluate the Final Cuts";
70
71 // default values of cuts
72 SetCuts(1.0, 100.0, 10.);
73}
74
75// --------------------------------------------------------------------------
76//
77// Set cut values
78//
79//
80void MFCT1SelFinal::SetCuts(Float_t hadmax, Float_t alphamax, Float_t distmax)
81{
82 fHadronnessMax = hadmax;
83 fAlphaMax = alphamax;
84 fDistMax = distmax;
85
86 *fLog << inf << "MFCT1SelFinal cut values : fHadronnessMax, fAlphaMax, fDistMax = ";
87 *fLog << fHadronnessMax << ", " << fAlphaMax << ", " << fDistMax << endl;
88}
89
90// --------------------------------------------------------------------------
91//
92// Set the pointers
93//
94Bool_t MFCT1SelFinal::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("MGeomCamCT1","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 return kTRUE;
122}
123
124// --------------------------------------------------------------------------
125//
126// Evaluate final cuts
127//
128// if cuts are fulfilled set fResult = kTRUE
129//
130Bool_t MFCT1SelFinal::Process()
131{
132 const Double_t modalpha = fabs( fHilSrc->GetAlpha() );
133 const Double_t h = fHadronness->GetHadronness();
134
135 Int_t rc = 0;
136 fResult = kFALSE;
137
138 if ( h>fHadronnessMax )
139 {
140 rc = 1;
141 fResult = kTRUE;
142 }
143 else if ( modalpha > fAlphaMax )
144 {
145 rc = 2;
146 fResult = kTRUE;
147 }
148 else if ( fMm2Deg*fHilSrc->GetDist() > fDistMax )
149 {
150 rc = 3;
151 fResult = kTRUE;
152 }
153
154 fCut[rc]++;
155
156 return kTRUE;
157}
158
159// --------------------------------------------------------------------------
160//
161// Prints some statistics about the Final selections.
162//
163Bool_t MFCT1SelFinal::PostProcess()
164{
165 if (GetNumExecutions()==0)
166 return kTRUE;
167
168 *fLog << inf << endl;
169 *fLog << GetDescriptor() << " execution statistics:" << endl;
170 *fLog << dec << setfill(' ');
171 *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
172 *fLog << (int)(fCut[1]*100/GetNumExecutions());
173 *fLog << "%) Evts skipped due to: hadronness > "<< fHadronnessMax;
174 *fLog << " (hadronness from '" << fHadronnessName << "')" << endl;
175
176 *fLog << " " << setw(7) << fCut[2] << " (" << setw(3) ;
177 *fLog << (int)(fCut[2]*100/GetNumExecutions());
178 *fLog << "%) Evts skipped due to: |ALPHA| > " << fAlphaMax;
179 *fLog << " [degrees]" << endl;
180
181 *fLog << " " << setw(7) << fCut[3] << " (" << setw(3) ;
182 *fLog << (int)(fCut[3]*100/GetNumExecutions());
183 *fLog << "%) Evts skipped due to: DIST > " << fDistMax;
184 *fLog << " [degrees]" << endl;
185
186 *fLog << " " << fCut[0] << " (" ;
187 *fLog << (int)(fCut[0]*100/GetNumExecutions());
188 *fLog << "%) Evts survived Final selections!" << endl;
189 *fLog << endl;
190
191 return kTRUE;
192}
Note: See TracBrowser for help on using the repository browser.