source: trunk/MagicSoft/Mars/mfilter/MFCT1SelBasic.cc@ 2235

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