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

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