source: trunk/MagicSoft/Mars/manalysis/MSelBasic.cc@ 1888

Last change on this file since 1888 was 1888, checked in by wittek, 22 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 6.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 02/2003 <mailto:wittek@mppmu.mpg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26// //
27// MSelBasic //
28// //
29// This is a task to evaluate basic cuts //
30// //
31// to be called after the calibration (when the number of photons is //
32// available for all pixels) //
33// //
34/////////////////////////////////////////////////////////////////////////////
35
36#include "MSelBasic.h"
37
38#include "MParList.h"
39
40#include "MHillas.h"
41#include "MCerPhotEvt.h"
42#include "MMcEvt.hxx"
43#include "MRawRunHeader.h"
44#include "MGeomCam.h"
45#include "MPedestalCam.h"
46#include "MPedestalPix.h"
47#include "MGeomPix.h"
48
49#include "MLog.h"
50#include "MLogManip.h"
51
52ClassImp(MSelBasic);
53
54// --------------------------------------------------------------------------
55//
56// Default constructor.
57//
58MSelBasic::MSelBasic(const char *name, const char *title)
59{
60 fName = name ? name : "MSelBasic";
61 fTitle = title ? title : "Task to evaluate basic cuts";
62
63 fThetaMin = 0.0;
64 fThetaMax = 60.0;
65}
66
67// --------------------------------------------------------------------------
68//
69//
70//
71//
72//
73Bool_t MSelBasic::PreProcess(MParList *pList)
74{
75 fRawRun = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
76 if (!fRawRun)
77 {
78 *fLog << dbginf << "MRawRunHeader not found... aborting." << endl;
79 return kFALSE;
80 }
81
82 fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
83 if (!fMcEvt)
84 {
85 *fLog << dbginf << "MMcEvt not found... aborting." << endl;
86 return kFALSE;
87 }
88
89 fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
90 if (!fEvt)
91 {
92 *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
93 return kFALSE;
94 }
95
96
97 fCam = (MGeomCam*)pList->FindObject("MGeomCam");
98 if (!fCam)
99 {
100 *fLog << dbginf << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
101 return kFALSE;
102 }
103
104 fPed = (MPedestalCam*)pList->FindObject("MPedestalCam");
105 if (!fPed)
106 {
107 *fLog << dbginf << "MPedestalCam missing in Parameter List... aborting." << endl;
108 return kFALSE;
109 }
110
111 memset(fCut, 0, sizeof(fCut));
112
113 return kTRUE;
114}
115
116// --------------------------------------------------------------------------
117//
118// Evaluate basic cuts
119//
120// if cuts are fulfilled : return 0
121// if they are not fullfilled : skip remaining tasks for this event
122//
123Bool_t MSelBasic::Process()
124{
125 Int_t rc = 0;
126
127 //if ( fRawRun->GetRunNumber() < 16279 )
128 //{
129 // rc = 1;
130 // return kCONTINUE;
131 //}
132
133 Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
134 if ( theta < fThetaMin )
135 {
136 *fLog << "MSelBasic::Process; Run, Event, Theta = "
137 << fRawRun->GetRunNumber()<< ", "
138 << fMcEvt->GetEvtNumber() << ", " << theta << endl;
139 rc = 1;
140 }
141
142 else if ( theta > fThetaMax )
143 {
144 rc = 2;
145 }
146
147 else if ( !SwTrigger() )
148 {
149 //*fLog << "MSelBasic::Process; SwTrigger = " << SwTrigger << endl;
150 rc = 3;
151 }
152
153 fCut[rc]++;
154
155 return rc==0 ? kTRUE : kCONTINUE;
156}
157// --------------------------------------------------------------------------
158//
159// Software trigger
160//
161// require 2 neighboring pixels (which are not in the outermost ring),
162// each having at least 'minphotons' photons
163//
164//
165Bool_t MSelBasic::SwTrigger()
166{
167 // minimum number of photons required
168 Double_t minphotons = 13.0;
169
170 const Int_t entries = fEvt->GetNumPixels();
171
172 for (Int_t i=0; i<entries; i++)
173 {
174 MCerPhotPix &pix = (*fEvt)[i];
175 Int_t id = pix.GetPixId();
176 if (!pix.IsPixelUsed()) continue;
177
178 Double_t photons = pix.GetNumPhotons();
179 if (photons < minphotons) continue;
180
181 // this pixel is used and has the required no.of photons
182 // check whether this is also true for a neigboring pixel
183
184 MGeomPix &gpix = (*fCam)[id];
185 if ( gpix.IsInOutermostRing() ) continue;
186
187 const Int_t nneighbors = gpix.GetNumNeighbors();
188 for (Int_t n=0; n<nneighbors; n++)
189 {
190 const Int_t id1 = gpix.GetNeighbor(n);
191 if ( !fEvt->IsPixelUsed(id1) ) continue;
192
193 MGeomPix &gpix1 = (*fCam)[id1];
194 if ( gpix1.IsInOutermostRing() ) continue;
195
196 //MCerPhotPix &pix1 = (*fEvt)[id1];
197 MCerPhotPix &pix1 = *(fEvt->GetPixById(id1));
198 if ( &pix1 == NULL )
199 {
200 *fLog << "MSelBasic::SwTrigger; &pix1 is NULL" << endl;
201 continue;
202 }
203
204 Double_t photons1 = pix1.GetNumPhotons();
205 if (photons1 >= minphotons) return kTRUE;
206 }
207 }
208 return kFALSE;
209}
210
211// --------------------------------------------------------------------------
212//
213// Prints some statistics about the Basic selections.
214//
215Bool_t MSelBasic::PostProcess()
216{
217 if (GetNumExecutions()==0)
218 return kTRUE;
219
220 *fLog << inf << endl;
221 *fLog << GetDescriptor() << " execution statistics:" << endl;
222 *fLog << dec << setfill(' ');
223 *fLog << " " << setw(7) << fCut[1] << " (" << setw(3)
224 << (int)(fCut[1]*100/GetNumExecutions())
225 << "%) Evts skipped due to: Zenith angle < " << fThetaMin << endl;
226
227 *fLog << " " << setw(7) << fCut[2] << " (" << setw(3)
228 << (int)(fCut[2]*100/GetNumExecutions())
229 << "%) Evts skipped due to: Zenith angle > " << fThetaMax << endl;
230
231 *fLog << " " << setw(7) << fCut[3] << " (" << setw(3)
232 << (int)(fCut[3]*100/GetNumExecutions())
233 << "%) Evts skipped due to: Software trigger not fullfilled" << endl;
234
235 *fLog << " " << fCut[0] << " (" << (int)(fCut[0]*100/GetNumExecutions())
236 << "%) Evts survived Basic selections!" << endl;
237 *fLog << endl;
238
239 return kTRUE;
240}
241
242
243
244
245
246
247
248
249
Note: See TracBrowser for help on using the repository browser.