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

Last change on this file since 2194 was 2173, 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//
95Bool_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
139// --------------------------------------------------------------------------
140//
141// Evaluate basic cuts
142//
143// if cuts are fulfilled : fResult = kTRUE;
144// if they are not fullfilled : fResult = kFALSE;
145//
146Bool_t MFCT1SelBasic::Process()
147{
148 const Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
149
150 Int_t rc = 0;
151 fResult = kFALSE;
152
153 if ( theta < fThetaMin )
154 {
155 rc = 1;
156 fResult = kTRUE;
157 }
158 else if ( theta > fThetaMax )
159 {
160 rc = 2;
161 fResult = kTRUE;
162 }
163 else if ( !SwTrigger() )
164 {
165 rc = 3;
166 fResult = kTRUE;
167 }
168
169 fCut[rc]++;
170
171 return kTRUE;
172}
173// --------------------------------------------------------------------------
174//
175// Software trigger
176//
177// require 2 neighboring pixels (which are not in the outermost ring),
178// each having at least 'fMinPhotons' photons
179//
180//
181Bool_t MFCT1SelBasic::SwTrigger()
182{
183 const Int_t entries = fEvt->GetNumPixels();
184
185 for (Int_t i=0; i<entries; i++)
186 {
187 const MCerPhotPix &pix = (*fEvt)[i];
188
189 const Int_t id = pix.GetPixId();
190 if (!pix.IsPixelUsed())
191 continue;
192
193 const Double_t photons = pix.GetNumPhotons();
194 if (photons < fMinPhotons)
195 continue;
196
197 // this pixel is used and has the required no.of photons
198 // check whether this is also true for a neigboring pixel
199
200 const MGeomPix &gpix = (*fCam)[id];
201 if ( gpix.IsInOutermostRing() )
202 continue;
203
204 const Int_t nneighbors = gpix.GetNumNeighbors();
205 for (Int_t n=0; n<nneighbors; n++)
206 {
207 const Int_t id1 = gpix.GetNeighbor(n);
208 if ( !fEvt->IsPixelUsed(id1) )
209 continue;
210
211 const MGeomPix &gpix1 = (*fCam)[id1];
212 if ( gpix1.IsInOutermostRing() )
213 continue;
214
215 const MCerPhotPix &pix1 = *fEvt->GetPixById(id1);
216
217 const Double_t photons1 = pix1.GetNumPhotons();
218 if (photons1 >= fMinPhotons)
219 return kTRUE;
220 }
221 }
222 return kFALSE;
223}
224
225// --------------------------------------------------------------------------
226//
227// Prints some statistics about the Basic selections.
228//
229Bool_t MFCT1SelBasic::PostProcess()
230{
231 if (GetNumExecutions()==0)
232 return kTRUE;
233
234 *fLog << inf << endl;
235 *fLog << GetDescriptor() << " execution statistics:" << endl;
236 *fLog << dec << setfill(' ');
237 *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
238 *fLog << (int)(fCut[1]*100/GetNumExecutions()) ;
239 *fLog << "%) Evts skipped due to: Zenith angle < " << fThetaMin << endl;
240
241 *fLog << " " << setw(7) << fCut[2] << " (" << setw(3) ;
242 *fLog << (int)(fCut[2]*100/GetNumExecutions()) ;
243 *fLog << "%) Evts skipped due to: Zenith angle > " << fThetaMax << endl;
244
245 *fLog << " " << setw(7) << fCut[3] << " (" << setw(3) ;
246 *fLog << (int)(fCut[3]*100/GetNumExecutions()) ;
247 *fLog << "%) Evts skipped due to: Software trigger not fullfilled" ;
248 *fLog << " (with fMinPhotons = " << fMinPhotons << ")" << endl;
249
250 *fLog << " " << fCut[0] << " (" << (int)(fCut[0]*100/GetNumExecutions()) ;
251 *fLog << "%) Evts survived Basic selections!" << endl;
252 *fLog << endl;
253
254 return kTRUE;
255}
Note: See TracBrowser for help on using the repository browser.