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

Last change on this file since 1919 was 1905, checked in by wittek, 23 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// 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 "MGeomPix.h"
49#include "MHadronness.h"
50
51#include "MLog.h"
52#include "MLogManip.h"
53
54ClassImp(MFCT1SelFinal);
55
56// --------------------------------------------------------------------------
57//
58// Default constructor.
59//
60MFCT1SelFinal::MFCT1SelFinal(const char *HilName, const char *HilSrcName,
61 const char *name, const char *title)
62{
63 fName = name ? name : "MFCT1SelFinal";
64 fTitle = title ? title : "Class to evaluate the Final Cuts";
65
66 fHilName = HilName;
67 fHilSrcName = HilSrcName;
68
69 // default values of cuts
70 SetCuts(1.0, 100.0);
71}
72
73// --------------------------------------------------------------------------
74//
75// Set cut values
76//
77//
78void MFCT1SelFinal::SetCuts(Float_t hadmax, Float_t alphamax)
79{
80 fHadronnessMax = hadmax;
81 fAlphaMax = alphamax;
82
83 *fLog << inf << "MFCT1SelFinal cut values : fHadronnessMax, fAlphaMax = "
84 << fHadronnessMax << ", " << fAlphaMax << endl;
85}
86
87// --------------------------------------------------------------------------
88//
89// Set the pointers
90//
91//
92Bool_t MFCT1SelFinal::PreProcess(MParList *pList)
93{
94 fHil = (MHillasExt*)pList->FindObject(fHilName, "MHillasExt");
95 if (!fHil)
96 {
97 *fLog << dbginf << "MHillasExt object " << fHilName << " not found... aborting." << endl;
98 return kFALSE;
99 }
100
101 fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc");
102 if (!fHilSrc)
103 {
104 *fLog << dbginf << "MHillasSrc object " << fHilSrcName << " not found... aborting." << endl;
105 return kFALSE;
106 }
107
108 fHadronness = (MHadronness*)pList->FindObject("MHadronness");
109 if (!fHadronness)
110 {
111 *fLog << dbginf << "MHadronness not found... aborting." << endl;
112 return kFALSE;
113 }
114
115 fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
116 if (!fMcEvt)
117 {
118 *fLog << dbginf << "MMcEvt not found... aborting." << endl;
119 return kFALSE;
120 }
121
122 memset(fCut, 0, sizeof(fCut));
123
124 return kTRUE;
125}
126
127// --------------------------------------------------------------------------
128//
129// Evaluate final cuts
130//
131// if cuts are fulfilled set fResult = kTRUE
132//
133Bool_t MFCT1SelFinal::Process()
134{
135 Int_t rc = 0;
136 fResult = kFALSE;
137
138 Double_t modalpha = fabs( fHilSrc->GetAlpha() );
139
140 Double_t h = fHadronness->GetHadronness();
141
142 if ( h>fHadronnessMax )
143 {
144 rc = 1;
145 fResult = kTRUE;
146 }
147
148 else if ( modalpha > fAlphaMax )
149 {
150 rc = 2;
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 << (int)(fCut[1]*100/GetNumExecutions())
173 << "%) Evts skipped due to: hadroness > "<< fHadronnessMax << endl;
174
175 *fLog << " " << setw(7) << fCut[2] << " (" << setw(3)
176 << (int)(fCut[2]*100/GetNumExecutions())
177 << "%) Evts skipped due to: |ALPHA| > " << fAlphaMax
178 << " [degrees]" << endl;
179
180 *fLog << " " << fCut[0] << " ("
181 << (int)(fCut[0]*100/GetNumExecutions())
182 << "%) Evts survived Final selections!" << endl;
183 *fLog << endl;
184
185 return kTRUE;
186}
Note: See TracBrowser for help on using the repository browser.