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

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