source: trunk/MagicSoft/Mars/mfilter/MFSelBasic.cc@ 2902

Last change on this file since 2902 was 2781, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 7.0 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! Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2003
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MFSelBasic
29//
30// This is a class to evaluate basic cuts
31//
32// to be called after the calibration (when the number of photons is
33// available for all pixels)
34//
35// The basic cuts are :
36//
37// remove bad runs
38// thetamin < theta < thetamax
39// software trigger fullfilled (with minimum no.of photons = minphotons)
40//
41//
42/////////////////////////////////////////////////////////////////////////////
43
44#include "MFSelBasic.h"
45
46#include "MParList.h"
47
48#include "MMcEvt.hxx"
49
50#include "MCerPhotEvt.h"
51#include "MRawRunHeader.h"
52
53#include "MGeomPix.h"
54#include "MGeomCam.h"
55
56#include "MLog.h"
57#include "MLogManip.h"
58
59ClassImp(MFSelBasic);
60
61using namespace std;
62
63// --------------------------------------------------------------------------
64//
65// Default constructor.
66//
67MFSelBasic::MFSelBasic(const char *name, const char *title)
68{
69 fName = name ? name : "MFSelBasic";
70 fTitle = title ? title : "Filter to evaluate basic cuts";
71
72 // default values of cuts
73 SetCuts(13.0, 0.0, 60.0);
74}
75
76// --------------------------------------------------------------------------
77//
78// Set the cut values
79//
80//
81void MFSelBasic::SetCuts(Float_t minphotons,
82 Float_t thetamin, Float_t thetamax)
83{
84 fMinPhotons = minphotons;
85 fThetaMin = thetamin;
86 fThetaMax = thetamax;
87
88 *fLog << inf << "MFSelBasic cut values : fMinPhotons, fThetaMin, fThetaMax = ";
89 *fLog << fMinPhotons <<", " << fThetaMin << ", " << fThetaMax << endl;
90}
91
92// --------------------------------------------------------------------------
93//
94// Set the pointers
95//
96//
97Int_t MFSelBasic::PreProcess(MParList *pList)
98{
99 fRawRun = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
100 if (!fRawRun)
101 {
102 *fLog << dbginf << "MRawRunHeader not found... aborting." << endl;
103 return kFALSE;
104 }
105
106 fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
107 if (!fMcEvt)
108 {
109 *fLog << dbginf << "MMcEvt not found... aborting." << endl;
110 return kFALSE;
111 }
112
113 fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
114 if (!fEvt)
115 {
116 *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
117 return kFALSE;
118 }
119
120 fCam = (MGeomCam*)pList->FindObject("MGeomCam");
121 if (!fCam)
122 {
123 *fLog << dbginf << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
124 return kFALSE;
125 }
126
127 memset(fCut, 0, sizeof(fCut));
128
129 return kTRUE;
130}
131
132Int_t MFSelBasic::Set(Int_t rc)
133{
134 fCut[rc]++;
135 fResult=kTRUE;
136 return kTRUE;
137}
138
139// --------------------------------------------------------------------------
140//
141// Evaluate basic cuts
142//
143// bad events : fResult = kTRUE;
144// good events : fResult = kFALSE;
145//
146Int_t MFSelBasic::Process()
147{
148 const Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
149
150 fResult = kFALSE;
151
152 // remove bad runs for MC gammas
153 if (fMcEvt->GetEnergy() == 0.0 && fMcEvt->GetImpact() == 0.0)
154 {
155 if (fRawRun->GetRunNumber() == 601 ||
156 fRawRun->GetRunNumber() == 613 ||
157 fRawRun->GetRunNumber() == 614 )
158 return Set(1);
159 }
160
161 if (theta<fThetaMin)
162 return Set(2);
163
164 if (theta>fThetaMax)
165 return Set(3);
166
167 if (!SwTrigger())
168 return Set(4);
169
170 fCut[0]++;
171
172 return kTRUE;
173}
174// --------------------------------------------------------------------------
175//
176// Software trigger
177//
178// require 2 neighboring pixels (which are not in the outermost ring),
179// each having at least 'fMinPhotons' photons
180//
181//
182Bool_t MFSelBasic::SwTrigger()
183{
184 const Int_t entries = fEvt->GetNumPixels();
185
186 for (Int_t i=0; i<entries; i++)
187 {
188 const MCerPhotPix &pix = (*fEvt)[i];
189
190 const Int_t id = pix.GetPixId();
191 if (!pix.IsPixelUsed())
192 continue;
193
194 const Double_t photons = pix.GetNumPhotons();
195 if (photons < fMinPhotons)
196 continue;
197
198 // this pixel is used and has the required no.of photons
199 // check whether this is also true for a neigboring pixel
200
201 const MGeomPix &gpix = (*fCam)[id];
202 if ( gpix.IsInOutermostRing() )
203 continue;
204
205 const Int_t nneighbors = gpix.GetNumNeighbors();
206 for (Int_t n=0; n<nneighbors; n++)
207 {
208 const Int_t id1 = gpix.GetNeighbor(n);
209 if ( !fEvt->IsPixelUsed(id1) )
210 continue;
211
212 const MGeomPix &gpix1 = (*fCam)[id1];
213 if ( gpix1.IsInOutermostRing() )
214 continue;
215
216 const MCerPhotPix &pix1 = *fEvt->GetPixById(id1);
217
218 const Double_t photons1 = pix1.GetNumPhotons();
219 if (photons1 >= fMinPhotons)
220 return kTRUE;
221 }
222 }
223 return kFALSE;
224}
225
226// --------------------------------------------------------------------------
227//
228// Prints some statistics about the Basic selections.
229//
230Int_t MFSelBasic::PostProcess()
231{
232 if (GetNumExecutions()==0)
233 return kTRUE;
234
235 *fLog << inf << endl;
236 *fLog << GetDescriptor() << " execution statistics:" << endl;
237 *fLog << dec << setfill(' ');
238
239 *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
240 *fLog << (int)(fCut[1]*100/GetNumExecutions()) ;
241 *fLog << "%) Evts skipped due to: bad run " << endl;
242
243 *fLog << " " << setw(7) << fCut[2] << " (" << setw(3) ;
244 *fLog << (int)(fCut[2]*100/GetNumExecutions()) ;
245 *fLog << "%) Evts skipped due to: Zenith angle < " << fThetaMin << endl;
246
247 *fLog << " " << setw(7) << fCut[3] << " (" << setw(3) ;
248 *fLog << (int)(fCut[3]*100/GetNumExecutions()) ;
249 *fLog << "%) Evts skipped due to: Zenith angle > " << fThetaMax << endl;
250
251 *fLog << " " << setw(7) << fCut[4] << " (" << setw(3) ;
252 *fLog << (int)(fCut[4]*100/GetNumExecutions()) ;
253 *fLog << "%) Evts skipped due to: Software trigger not fullfilled" ;
254 *fLog << " (with fMinPhotons = " << fMinPhotons << ")" << endl;
255
256 *fLog << " " << fCut[0] << " (" << (int)(fCut[0]*100/GetNumExecutions()) ;
257 *fLog << "%) Evts survived Basic selections!" << endl;
258 *fLog << endl;
259
260 return kTRUE;
261}
Note: See TracBrowser for help on using the repository browser.