source: branches/AddingGoogleTestEnvironment/manalysisct1/MFCT1SelFinal.cc@ 18160

Last change on this file since 18160 was 6847, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 5.2 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
60using namespace std;
61
62// --------------------------------------------------------------------------
63//
64// Default constructor.
65//
66MFCT1SelFinal::MFCT1SelFinal(const char *hilsrcname,
67 const char *name, const char *title)
68 : fHilSrcName(hilsrcname), fHadronnessName("MHadronness")
69{
70 fName = name ? name : "MFCT1SelFinal";
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 MFCT1SelFinal::SetCuts(Float_t hadmax, Float_t alphamax, Float_t distmax)
83{
84 fHadronnessMax = hadmax;
85 fAlphaMax = alphamax;
86 fDistMax = distmax;
87
88 *fLog << inf << "MFCT1SelFinal cut values : fHadronnessMax, fAlphaMax, fDistMax = ";
89 *fLog << fHadronnessMax << ", " << fAlphaMax << ", " << fDistMax << endl;
90}
91
92// --------------------------------------------------------------------------
93//
94// Set the pointers
95//
96Int_t MFCT1SelFinal::PreProcess(MParList *pList)
97{
98 fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc");
99 if (!fHilSrc)
100 {
101 *fLog << dbginf << "MHillasSrc object " << fHilSrcName << " not found... aborting." << endl;
102 return kFALSE;
103 }
104
105 fHadronness = (MHadronness*)pList->FindObject(fHadronnessName, "MHadronness");
106 if (!fHadronness)
107 {
108 *fLog << dbginf << "MHadronness not found... aborting." << endl;
109 return kFALSE;
110 }
111
112 MGeomCam *cam = (MGeomCam*)pList->FindCreateObj("MGeomCamCT1","MGeomCam");
113 if (!cam)
114 {
115 *fLog << err << "MGeomCam (Camera Geometry) not found... aborting." << endl;
116 return kFALSE;
117 }
118
119 fMm2Deg = cam->GetConvMm2Deg();
120
121 memset(fCut, 0, sizeof(fCut));
122
123 return kTRUE;
124}
125
126Int_t MFCT1SelFinal::Set(Int_t rc)
127{
128 fCut[rc]++;
129 fResult=kTRUE;
130 return kTRUE;
131}
132
133// --------------------------------------------------------------------------
134//
135// Evaluate final cuts
136//
137// if cuts are fulfilled set fResult = kTRUE
138//
139Int_t MFCT1SelFinal::Process()
140{
141 const Double_t modalpha = fabs( fHilSrc->GetAlpha() );
142 const Double_t h = fHadronness->GetHadronness();
143
144 fResult = kFALSE;
145
146 if (h>fHadronnessMax)
147 return Set(1);
148
149 if (modalpha>fAlphaMax)
150 return Set(2);
151
152 if (fMm2Deg*fHilSrc->GetDist()>fDistMax)
153 return Set(3);
154
155 fCut[0]++;
156
157 return kTRUE;
158}
159
160// --------------------------------------------------------------------------
161//
162// Prints some statistics about the Final selections.
163//
164Int_t MFCT1SelFinal::PostProcess()
165{
166 if (GetNumExecutions()==0)
167 return kTRUE;
168
169 *fLog << inf << endl;
170 *fLog << GetDescriptor() << " execution statistics:" << endl;
171 *fLog << dec << setfill(' ');
172 *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
173 *fLog << (int)(fCut[1]*100/GetNumExecutions());
174 *fLog << "%) Evts skipped due to: hadronness > "<< fHadronnessMax;
175 *fLog << " (hadronness from '" << fHadronnessName << "')" << endl;
176
177 *fLog << " " << setw(7) << fCut[2] << " (" << setw(3) ;
178 *fLog << (int)(fCut[2]*100/GetNumExecutions());
179 *fLog << "%) Evts skipped due to: |ALPHA| > " << fAlphaMax;
180 *fLog << " [degrees]" << endl;
181
182 *fLog << " " << setw(7) << fCut[3] << " (" << setw(3) ;
183 *fLog << (int)(fCut[3]*100/GetNumExecutions());
184 *fLog << "%) Evts skipped due to: DIST > " << fDistMax;
185 *fLog << " [degrees]" << endl;
186
187 *fLog << " " << fCut[0] << " (" ;
188 *fLog << (int)(fCut[0]*100/GetNumExecutions());
189 *fLog << "%) Evts survived Final selections!" << endl;
190 *fLog << endl;
191
192 return kTRUE;
193}
Note: See TracBrowser for help on using the repository browser.