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 |
|
---|
57 | ClassImp(MFCT1SelBasic);
|
---|
58 |
|
---|
59 | // --------------------------------------------------------------------------
|
---|
60 | //
|
---|
61 | // Default constructor.
|
---|
62 | //
|
---|
63 | MFCT1SelBasic::MFCT1SelBasic(const char *name, const char *title)
|
---|
64 | {
|
---|
65 | fName = name ? name : "MFCT1SelBasic";
|
---|
66 | fTitle = title ? title : "Filter to evaluate basic cuts";
|
---|
67 |
|
---|
68 | // default values of cuts
|
---|
69 | SetCuts(13.0, 0.0, 60.0);
|
---|
70 | }
|
---|
71 |
|
---|
72 | // --------------------------------------------------------------------------
|
---|
73 | //
|
---|
74 | // Set the cut values
|
---|
75 | //
|
---|
76 | //
|
---|
77 | void MFCT1SelBasic::SetCuts(Float_t minphotons,
|
---|
78 | Float_t thetamin, Float_t thetamax)
|
---|
79 | {
|
---|
80 | fMinPhotons = minphotons;
|
---|
81 | fThetaMin = thetamin;
|
---|
82 | fThetaMax = thetamax;
|
---|
83 |
|
---|
84 | *fLog << inf << "MFCT1SelBasic cut values : fMinPhotons, fThetaMin, fThetaMax = ";
|
---|
85 | *fLog << fMinPhotons <<", " << fThetaMin << ", " << fThetaMax << endl;
|
---|
86 | }
|
---|
87 |
|
---|
88 | // --------------------------------------------------------------------------
|
---|
89 | //
|
---|
90 | // Set the pointers
|
---|
91 | //
|
---|
92 | //
|
---|
93 | Bool_t MFCT1SelBasic::PreProcess(MParList *pList)
|
---|
94 | {
|
---|
95 | /*
|
---|
96 | fRawRun = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
---|
97 | if (!fRawRun)
|
---|
98 | {
|
---|
99 | *fLog << dbginf << "MRawRunHeader not found... aborting." << endl;
|
---|
100 | return kFALSE;
|
---|
101 | }
|
---|
102 | */
|
---|
103 |
|
---|
104 | fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
|
---|
105 | if (!fMcEvt)
|
---|
106 | {
|
---|
107 | *fLog << dbginf << "MMcEvt not found... aborting." << endl;
|
---|
108 | return kFALSE;
|
---|
109 | }
|
---|
110 |
|
---|
111 | fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
|
---|
112 | if (!fEvt)
|
---|
113 | {
|
---|
114 | *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
|
---|
115 | return kFALSE;
|
---|
116 | }
|
---|
117 |
|
---|
118 | fCam = (MGeomCam*)pList->FindObject("MGeomCam");
|
---|
119 | if (!fCam)
|
---|
120 | {
|
---|
121 | *fLog << dbginf << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
|
---|
122 | return kFALSE;
|
---|
123 | }
|
---|
124 | /*
|
---|
125 | fPed = (MPedestalCam*)pList->FindObject("MPedestalCam");
|
---|
126 | if (!fPed)
|
---|
127 | {
|
---|
128 | *fLog << dbginf << "MPedestalCam missing in Parameter List... aborting." << endl;
|
---|
129 | return kFALSE;
|
---|
130 | }
|
---|
131 | */
|
---|
132 | memset(fCut, 0, sizeof(fCut));
|
---|
133 |
|
---|
134 | return kTRUE;
|
---|
135 | }
|
---|
136 |
|
---|
137 | // --------------------------------------------------------------------------
|
---|
138 | //
|
---|
139 | // Evaluate basic cuts
|
---|
140 | //
|
---|
141 | // if cuts are fulfilled : fResult = kTRUE;
|
---|
142 | // if they are not fullfilled : fResult = kFALSE;
|
---|
143 | //
|
---|
144 | Bool_t MFCT1SelBasic::Process()
|
---|
145 | {
|
---|
146 | const Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
|
---|
147 |
|
---|
148 | Int_t rc = 0;
|
---|
149 | fResult = kFALSE;
|
---|
150 |
|
---|
151 | if ( theta < fThetaMin )
|
---|
152 | {
|
---|
153 | rc = 1;
|
---|
154 | fResult = kTRUE;
|
---|
155 | }
|
---|
156 | else if ( theta > fThetaMax )
|
---|
157 | {
|
---|
158 | rc = 2;
|
---|
159 | fResult = kTRUE;
|
---|
160 | }
|
---|
161 | else if ( !SwTrigger() )
|
---|
162 | {
|
---|
163 | rc = 3;
|
---|
164 | fResult = kTRUE;
|
---|
165 | }
|
---|
166 |
|
---|
167 | fCut[rc]++;
|
---|
168 |
|
---|
169 | return kTRUE;
|
---|
170 | }
|
---|
171 | // --------------------------------------------------------------------------
|
---|
172 | //
|
---|
173 | // Software trigger
|
---|
174 | //
|
---|
175 | // require 2 neighboring pixels (which are not in the outermost ring),
|
---|
176 | // each having at least 'fMinPhotons' photons
|
---|
177 | //
|
---|
178 | //
|
---|
179 | Bool_t MFCT1SelBasic::SwTrigger()
|
---|
180 | {
|
---|
181 | const Int_t entries = fEvt->GetNumPixels();
|
---|
182 |
|
---|
183 | for (Int_t i=0; i<entries; i++)
|
---|
184 | {
|
---|
185 | const MCerPhotPix &pix = (*fEvt)[i];
|
---|
186 |
|
---|
187 | const Int_t id = pix.GetPixId();
|
---|
188 | if (!pix.IsPixelUsed())
|
---|
189 | continue;
|
---|
190 |
|
---|
191 | const Double_t photons = pix.GetNumPhotons();
|
---|
192 | if (photons < fMinPhotons)
|
---|
193 | continue;
|
---|
194 |
|
---|
195 | // this pixel is used and has the required no.of photons
|
---|
196 | // check whether this is also true for a neigboring pixel
|
---|
197 |
|
---|
198 | const MGeomPix &gpix = (*fCam)[id];
|
---|
199 | if ( gpix.IsInOutermostRing() )
|
---|
200 | continue;
|
---|
201 |
|
---|
202 | const Int_t nneighbors = gpix.GetNumNeighbors();
|
---|
203 | for (Int_t n=0; n<nneighbors; n++)
|
---|
204 | {
|
---|
205 | const Int_t id1 = gpix.GetNeighbor(n);
|
---|
206 | if ( !fEvt->IsPixelUsed(id1) )
|
---|
207 | continue;
|
---|
208 |
|
---|
209 | const MGeomPix &gpix1 = (*fCam)[id1];
|
---|
210 | if ( gpix1.IsInOutermostRing() )
|
---|
211 | continue;
|
---|
212 |
|
---|
213 | const MCerPhotPix &pix1 = *fEvt->GetPixById(id1);
|
---|
214 |
|
---|
215 | const Double_t photons1 = pix1.GetNumPhotons();
|
---|
216 | if (photons1 >= fMinPhotons)
|
---|
217 | return kTRUE;
|
---|
218 | }
|
---|
219 | }
|
---|
220 | return kFALSE;
|
---|
221 | }
|
---|
222 |
|
---|
223 | // --------------------------------------------------------------------------
|
---|
224 | //
|
---|
225 | // Prints some statistics about the Basic selections.
|
---|
226 | //
|
---|
227 | Bool_t MFCT1SelBasic::PostProcess()
|
---|
228 | {
|
---|
229 | if (GetNumExecutions()==0)
|
---|
230 | return kTRUE;
|
---|
231 |
|
---|
232 | *fLog << inf << endl;
|
---|
233 | *fLog << GetDescriptor() << " execution statistics:" << endl;
|
---|
234 | *fLog << dec << setfill(' ');
|
---|
235 | *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
|
---|
236 | *fLog << (int)(fCut[1]*100/GetNumExecutions()) ;
|
---|
237 | *fLog << "%) Evts skipped due to: Zenith angle < " << fThetaMin << endl;
|
---|
238 |
|
---|
239 | *fLog << " " << setw(7) << fCut[2] << " (" << setw(3) ;
|
---|
240 | *fLog << (int)(fCut[2]*100/GetNumExecutions()) ;
|
---|
241 | *fLog << "%) Evts skipped due to: Zenith angle > " << fThetaMax << endl;
|
---|
242 |
|
---|
243 | *fLog << " " << setw(7) << fCut[3] << " (" << setw(3) ;
|
---|
244 | *fLog << (int)(fCut[3]*100/GetNumExecutions()) ;
|
---|
245 | *fLog << "%) Evts skipped due to: Software trigger not fullfilled" ;
|
---|
246 | *fLog << " (with fMinPhotons = " << fMinPhotons << ")" << endl;
|
---|
247 |
|
---|
248 | *fLog << " " << fCut[0] << " (" << (int)(fCut[0]*100/GetNumExecutions()) ;
|
---|
249 | *fLog << "%) Evts survived Basic selections!" << endl;
|
---|
250 | *fLog << endl;
|
---|
251 |
|
---|
252 | return kTRUE;
|
---|
253 | }
|
---|