source: trunk/MagicSoft/Mars/manalysis/MSelFinal.cc@ 1885

Last change on this file since 1885 was 1885, checked in by wittek, 21 years ago
*** empty log message ***
  • Property svn:executable set to *
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 02/2003 <mailto:wittek@mppmu.mpg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26// //
27// MSelFinal //
28// //
29// This is a task 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 "MSelFinal.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(MSelFinal);
55
56// --------------------------------------------------------------------------
57//
58// Default constructor.
59//
60MSelFinal::MSelFinal(const char *HilName, const char *HilSrcName,
61 const char *name, const char *title)
62{
63 fName = name ? name : "MSelFinal";
64 fTitle = title ? title : "Task to evaluate the Final Cuts";
65
66 fHilName = HilName;
67 fHilSrcName = HilSrcName;
68
69 fHadronnessCut = 0.2;
70 fAlphaCut = 100.0; //degrees
71}
72
73// --------------------------------------------------------------------------
74//
75//
76//
77//
78//
79Bool_t MSelFinal::PreProcess(MParList *pList)
80{
81 fHil = (MHillasExt*)pList->FindObject(fHilName, "MHillasExt");
82 if (!fHil)
83 {
84 *fLog << dbginf << "MHillasExt object " << fHilName << " not found... aborting." << endl;
85 return kFALSE;
86 }
87
88 fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc");
89 if (!fHilSrc)
90 {
91 *fLog << dbginf << "MHillasSrc object " << fHilSrcName << " not found... aborting." << endl;
92 return kFALSE;
93 }
94
95
96 fHadronness = (MHadronness*)pList->FindObject("MHadronness");
97 if (!fHadronness)
98 {
99 *fLog << dbginf << "MHadronness not found... aborting." << endl;
100 return kFALSE;
101 }
102
103
104 fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
105 if (!fMcEvt)
106 {
107 *fLog << dbginf << "MMcEvt not found... aborting." << endl;
108 return kFALSE;
109 }
110
111 memset(fErrors, 0, sizeof(fErrors));
112
113 return kTRUE;
114}
115
116// --------------------------------------------------------------------------
117//
118// Evaluate final cuts
119//
120// if cuts are fulfilled : return 0
121// if they are not fullfilled : skip the remaining tasks for this event
122//
123Bool_t MSelFinal::Process()
124{
125 //*fLog << "Entry MSelFinal; fHilSrc = " << fHilSrc << endl;
126
127
128
129 Int_t rc = 0;
130
131 Double_t modalpha = fabs( fHilSrc->GetAlpha() );
132
133 Double_t h = fHadronness->GetHadronness();
134
135 if ( h>fHadronnessCut )
136 {
137 //*fLog << "MSelFinal::Process; h, alpha = " << h << ", "
138 // << fHilSrc->GetAlpha() << endl;
139 rc = 1;
140 }
141
142 else if ( modalpha > fAlphaCut )
143 {
144 //*fLog << "MSelFinal::Process; h, alpha = " << h << ", "
145 // << fHilSrc->GetAlpha() << endl;
146 rc = 2;
147 }
148
149 fErrors[rc]++;
150
151 return rc==0 ? kTRUE : kCONTINUE;
152}
153
154// --------------------------------------------------------------------------
155//
156// Prints some statistics about the Final selections.
157//
158Bool_t MSelFinal::PostProcess()
159{
160 if (GetNumExecutions()==0)
161 return kTRUE;
162
163 *fLog << inf << endl;
164 *fLog << GetDescriptor() << " execution statistics:" << endl;
165 *fLog << dec << setfill(' ');
166 *fLog << " " << setw(7) << fErrors[1] << " (" << setw(3)
167 << (int)(fErrors[1]*100/GetNumExecutions())
168 << "%) Evts skipped due to: g/h separation cut (" << fHadronnessCut
169 << ")" << endl;
170
171 *fLog << " " << setw(7) << fErrors[2] << " (" << setw(3)
172 << (int)(fErrors[2]*100/GetNumExecutions())
173 << "%) Evts skipped due to: cut in ALPHA (" << fAlphaCut
174 << " degrees)" << endl;
175
176 *fLog << " " << fErrors[0] << " ("
177 << (int)(fErrors[0]*100/GetNumExecutions())
178 << "%) Evts survived Final selections!" << endl;
179 *fLog << endl;
180
181 return kTRUE;
182}
183
184
185
Note: See TracBrowser for help on using the repository browser.