source: trunk/MagicSoft/Mars/manalysisct1/MFCT1SelBasic.cc@ 8095

Last change on this file since 8095 was 8095, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 7.3 KB
Line 
1// @(#)root/physics:$Name: not supported by cvs2svn $:$Id: MFCT1SelBasic.cc,v 1.5 2006-10-17 13:58:36 tbretz Exp $
2
3/* ======================================================================== *\
4!
5! *
6! * This file is part of MARS, the MAGIC Analysis and Reconstruction
7! * Software. It is distributed to you in the hope that it can be a useful
8! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
9! * It is distributed WITHOUT ANY WARRANTY.
10! *
11! * Permission to use, copy, modify and distribute this software and its
12! * documentation for any purpose is hereby granted without fee,
13! * provided that the above copyright notice appear in all copies and
14! * that both that copyright notice and this permission notice appear
15! * in supporting documentation. It is provided "as is" without express
16! * or implied warranty.
17! *
18!
19!
20! Author(s): Wolfgang Wittek, 04/2003 <mailto:wittek@mppmu.mpg.de>
21! Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
22!
23! Copyright: MAGIC Software Development, 2000-2003
24!
25! $Name: not supported by cvs2svn $$Id: MFCT1SelBasic.cc,v 1.5 2006-10-17 13:58:36 tbretz Exp $
26!
27\* ======================================================================== */
28
29/////////////////////////////////////////////////////////////////////////////
30//
31// MFCT1SelBasic
32//
33// This is a class to evaluate basic cuts
34//
35// to be called after the calibration (when the number of photons is
36// available for all pixels)
37//
38// The basic cuts are :
39//
40// remove bad runs
41// thetamin < theta < thetamax
42// software trigger fullfilled (with minimum no.of photons = minphotons)
43//
44//
45/////////////////////////////////////////////////////////////////////////////
46
47#include "MFCT1SelBasic.h"
48
49#include "MParList.h"
50
51#include "MMcEvt.hxx"
52
53#include "MCerPhotEvt.h"
54#include "MRawRunHeader.h"
55
56#include "MGeomPix.h"
57#include "MGeomCam.h"
58
59#include "MLog.h"
60#include "MLogManip.h"
61
62ClassImp(MFCT1SelBasic);
63
64using namespace std;
65
66// --------------------------------------------------------------------------
67//
68// Default constructor.
69//
70MFCT1SelBasic::MFCT1SelBasic(const char *name, const char *title)
71{
72 fName = name ? name : "MFCT1SelBasic";
73 fTitle = title ? title : "Filter to evaluate basic cuts";
74
75 // default values of cuts
76 SetCuts(13.0, 0.0, 60.0);
77}
78
79// --------------------------------------------------------------------------
80//
81// Set the cut values
82//
83//
84void MFCT1SelBasic::SetCuts(Float_t minphotons,
85 Float_t thetamin, Float_t thetamax)
86{
87 fMinPhotons = minphotons;
88 fThetaMin = thetamin;
89 fThetaMax = thetamax;
90
91 *fLog << inf << "MFCT1SelBasic cut values : fMinPhotons, fThetaMin, fThetaMax = ";
92 *fLog << fMinPhotons <<", " << fThetaMin << ", " << fThetaMax << endl;
93}
94
95// --------------------------------------------------------------------------
96//
97// Set the pointers
98//
99//
100Int_t MFCT1SelBasic::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 fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
110 if (!fMcEvt)
111 {
112 *fLog << dbginf << "MMcEvt 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 return kTRUE;
133}
134
135Int_t MFCT1SelBasic::Set(Int_t rc)
136{
137 fCut[rc]++;
138 fResult=kTRUE;
139 return kTRUE;
140}
141
142// --------------------------------------------------------------------------
143//
144// Evaluate basic cuts
145//
146// bad events : fResult = kTRUE;
147// good events : fResult = kFALSE;
148//
149Int_t MFCT1SelBasic::Process()
150{
151 const Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
152
153 fResult = kFALSE;
154
155 // remove bad runs for MC gammas
156 if (fMcEvt->GetEnergy() == 0.0 && fMcEvt->GetImpact() == 0.0)
157 {
158 if (fRawRun->GetRunNumber() == 601 ||
159 fRawRun->GetRunNumber() == 613 ||
160 fRawRun->GetRunNumber() == 614 )
161 return Set(1);
162 }
163
164 if (theta<fThetaMin)
165 return Set(2);
166
167 if (theta>fThetaMax)
168 return Set(3);
169
170 if (!SwTrigger())
171 return Set(4);
172
173 fCut[0]++;
174
175 return kTRUE;
176}
177// --------------------------------------------------------------------------
178//
179// Software trigger
180//
181// require 2 neighboring pixels (which are not in the outermost ring),
182// each having at least 'fMinPhotons' photons
183//
184//
185Bool_t MFCT1SelBasic::SwTrigger()
186{
187 const Int_t entries = fEvt->GetNumPixels();
188
189 for (Int_t i=0; i<entries; i++)
190 {
191 const MCerPhotPix &pix = (*fEvt)[i];
192
193 const Int_t id = pix.GetPixId();
194 if (!pix.IsPixelUsed())
195 continue;
196
197 const Double_t photons = pix.GetNumPhotons();
198 if (photons < fMinPhotons)
199 continue;
200
201 // this pixel is used and has the required no.of photons
202 // check whether this is also true for a neigboring pixel
203
204 const MGeomPix &gpix = (*fCam)[id];
205 if ( gpix.IsInOutermostRing() )
206 continue;
207
208 const Int_t nneighbors = gpix.GetNumNeighbors();
209 for (Int_t n=0; n<nneighbors; n++)
210 {
211 const Int_t id1 = gpix.GetNeighbor(n);
212 if ( !fEvt->IsPixelUsed(id1) )
213 continue;
214
215 const MGeomPix &gpix1 = (*fCam)[id1];
216 if ( gpix1.IsInOutermostRing() )
217 continue;
218
219 const MCerPhotPix &pix1 = *fEvt->GetPixById(id1);
220
221 const Double_t photons1 = pix1.GetNumPhotons();
222 if (photons1 >= fMinPhotons)
223 return kTRUE;
224 }
225 }
226 return kFALSE;
227}
228
229// --------------------------------------------------------------------------
230//
231// Prints some statistics about the Basic selections.
232//
233Int_t MFCT1SelBasic::PostProcess()
234{
235 if (GetNumExecutions()==0)
236 return kTRUE;
237
238 *fLog << inf << endl;
239 *fLog << GetDescriptor() << " execution statistics:" << endl;
240 *fLog << dec << setfill(' ');
241
242 *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
243 *fLog << (int)(fCut[1]*100/GetNumExecutions()) ;
244 *fLog << "%) Evts skipped due to: bad run " << endl;
245
246 *fLog << " " << setw(7) << fCut[2] << " (" << setw(3) ;
247 *fLog << (int)(fCut[2]*100/GetNumExecutions()) ;
248 *fLog << "%) Evts skipped due to: Zenith angle < " << fThetaMin << endl;
249
250 *fLog << " " << setw(7) << fCut[3] << " (" << setw(3) ;
251 *fLog << (int)(fCut[3]*100/GetNumExecutions()) ;
252 *fLog << "%) Evts skipped due to: Zenith angle > " << fThetaMax << endl;
253
254 *fLog << " " << setw(7) << fCut[4] << " (" << setw(3) ;
255 *fLog << (int)(fCut[4]*100/GetNumExecutions()) ;
256 *fLog << "%) Evts skipped due to: Software trigger not fullfilled" ;
257 *fLog << " (with fMinPhotons = " << fMinPhotons << ")" << endl;
258
259 *fLog << " " << fCut[0] << " (" << (int)(fCut[0]*100/GetNumExecutions()) ;
260 *fLog << "%) Evts survived Basic selections!" << endl;
261 *fLog << endl;
262
263 return kTRUE;
264}
Note: See TracBrowser for help on using the repository browser.