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 <wittek@mppmu.mpg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2002
|
---|
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 |
|
---|
52 | ClassImp(MSelBasic);
|
---|
53 |
|
---|
54 | // --------------------------------------------------------------------------
|
---|
55 | //
|
---|
56 | // Default constructor.
|
---|
57 | //
|
---|
58 | MSelBasic::MSelBasic(const char *name, const char *title)
|
---|
59 | {
|
---|
60 | fName = name ? name : "MSelBasic";
|
---|
61 | fTitle = title ? title : "Task to evaluate basic cuts";
|
---|
62 | }
|
---|
63 |
|
---|
64 | // --------------------------------------------------------------------------
|
---|
65 | //
|
---|
66 | //
|
---|
67 | //
|
---|
68 | //
|
---|
69 | //
|
---|
70 | Bool_t MSelBasic::PreProcess(MParList *pList)
|
---|
71 | {
|
---|
72 | fRawRun = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
---|
73 | if (!fRawRun)
|
---|
74 | {
|
---|
75 | *fLog << dbginf << "MRawRunHeader not found... aborting." << endl;
|
---|
76 | return kFALSE;
|
---|
77 | }
|
---|
78 |
|
---|
79 | fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
|
---|
80 | if (!fMcEvt)
|
---|
81 | {
|
---|
82 | *fLog << dbginf << "MMcEvt not found... aborting." << endl;
|
---|
83 | return kFALSE;
|
---|
84 | }
|
---|
85 |
|
---|
86 | fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
|
---|
87 | if (!fEvt)
|
---|
88 | {
|
---|
89 | *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
|
---|
90 | return kFALSE;
|
---|
91 | }
|
---|
92 |
|
---|
93 |
|
---|
94 | fCam = (MGeomCam*)pList->FindObject("MGeomCam");
|
---|
95 | if (!fCam)
|
---|
96 | {
|
---|
97 | *fLog << dbginf << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
|
---|
98 | return kFALSE;
|
---|
99 | }
|
---|
100 |
|
---|
101 | fPed = (MPedestalCam*)pList->FindObject("MPedestalCam");
|
---|
102 | if (!fPed)
|
---|
103 | {
|
---|
104 | *fLog << dbginf << "MPedestalCam missing in Parameter List... aborting." << endl;
|
---|
105 | return kFALSE;
|
---|
106 | }
|
---|
107 |
|
---|
108 | memset(fErrors, 0, sizeof(fErrors));
|
---|
109 |
|
---|
110 | return kTRUE;
|
---|
111 | }
|
---|
112 |
|
---|
113 | // --------------------------------------------------------------------------
|
---|
114 | //
|
---|
115 | // Evaluate basic cuts
|
---|
116 | //
|
---|
117 | // if cuts are fulfilled : return 0
|
---|
118 | // if they are not fullfilled : skip remaining tasks for this event
|
---|
119 | //
|
---|
120 | Bool_t MSelBasic::Process()
|
---|
121 | {
|
---|
122 | /*
|
---|
123 | //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
---|
124 | *fLog << "=========================================================" << endl;
|
---|
125 | *fLog << "" << endl;
|
---|
126 | *fLog << "MmcEvt data : " << endl;
|
---|
127 | *fLog << "" << endl;
|
---|
128 | fMcEvt->Print();
|
---|
129 | *fLog << "" << endl;
|
---|
130 | *fLog << "PartId() = " << fMcEvt->GetPartId() << endl;
|
---|
131 | *fLog << "Energy() = " << fMcEvt->GetEnergy() << endl;
|
---|
132 | *fLog << "Theta() = " << fMcEvt->GetTheta() << endl;
|
---|
133 |
|
---|
134 | *fLog << "Phi() = " << fMcEvt->GetPhi() << endl;
|
---|
135 | //*fLog << "CoreD() = " << fMcEvt->GetCoreD() << endl;
|
---|
136 | //*fLog << "CoreX() = " << fMcEvt->GetCoreX() << endl;
|
---|
137 |
|
---|
138 | //*fLog << "CoreY() = " << fMcEvt->GetCoreY() << endl;
|
---|
139 | *fLog << "Impact() = " << fMcEvt->GetImpact() << endl;
|
---|
140 | //*fLog << "PhotIni()= " << fMcEvt->GetPhotIni() << endl;
|
---|
141 |
|
---|
142 | //*fLog << "PassPhotAtm() = " << fMcEvt->GetPassPhotAtm() << endl;
|
---|
143 | //*fLog << "PassPhotRef() = " << fMcEvt->GetPassPhotRef() << endl;
|
---|
144 | //*fLog << "PassPhotCone() = " << fMcEvt->GetPassPhotCone() << endl;
|
---|
145 |
|
---|
146 | //*fLog << "PhotElfromShower() = " << fMcEvt->GetPhotElfromShower() << endl;
|
---|
147 | //*fLog << "PhotElinCamera() = " << fMcEvt->GetPhotElinCamera() << endl;
|
---|
148 | *fLog << "TelescopePhi() = " << fMcEvt->GetTelescopePhi() << endl;
|
---|
149 |
|
---|
150 | *fLog << "TelescopeTheta() = " << fMcEvt->GetTelescopeTheta() << endl;
|
---|
151 | *fLog << "Impact() = " << fMcEvt->GetImpact() << endl;
|
---|
152 | //*fLog << "PhotIni()= " << fMcEvt->GetPhotIni() << endl;
|
---|
153 | *fLog << "" << endl;
|
---|
154 | *fLog << "=========================================================" << endl;
|
---|
155 |
|
---|
156 | *fLog << "=========================================================" << endl;
|
---|
157 | *fLog << "" << endl;
|
---|
158 | *fLog << "MPedestalPix data : " << endl;
|
---|
159 | *fLog << "" << endl;
|
---|
160 |
|
---|
161 | Int_t ntot;
|
---|
162 | ntot = fPed->GetSize();
|
---|
163 | *fLog << "MeanRms() :" << endl;
|
---|
164 | for (Int_t i=0; i<ntot; i++)
|
---|
165 | {
|
---|
166 | MPedestalPix &pix = (*fPed)[i];
|
---|
167 | //*fLog << "Mean() = " << i << ", " << pix.GetMean() << endl;
|
---|
168 | //*fLog << "Sigma() = " << i << ", " << pix.GetSigma() << endl;
|
---|
169 | *fLog << pix.GetMeanRms() << " ";
|
---|
170 | //*fLog << "SigmaRms()= " << i << ", " << pix.GetSigmaRms() << endl;
|
---|
171 | }
|
---|
172 | *fLog << "" << endl;
|
---|
173 |
|
---|
174 | *fLog << "" << endl;
|
---|
175 | ntot = fEvt->GetNumPixels();
|
---|
176 | *fLog << "MCerPhotPix : pix.GetNumPhotons()" << endl;
|
---|
177 | for (Int_t i=0; i<ntot; i++)
|
---|
178 | {
|
---|
179 | MCerPhotPix &pix = (*fEvt)[i];
|
---|
180 | *fLog << pix.GetNumPhotons() << " ";
|
---|
181 | }
|
---|
182 | *fLog << "" << endl;
|
---|
183 |
|
---|
184 | *fLog << "" << endl;
|
---|
185 | ntot = fEvt->GetNumPixels();
|
---|
186 | *fLog << "MCerPhotPix : pix.GetErrorPhot()" << endl;
|
---|
187 | for (Int_t i=0; i<ntot; i++)
|
---|
188 | {
|
---|
189 | MCerPhotPix &pix = (*fEvt)[i];
|
---|
190 | *fLog << pix.GetErrorPhot() << " ";
|
---|
191 | }
|
---|
192 | *fLog << "" << endl;
|
---|
193 |
|
---|
194 | //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
---|
195 | */
|
---|
196 |
|
---|
197 |
|
---|
198 | Int_t rc = 0;
|
---|
199 |
|
---|
200 | //if ( fRawRun->GetRunNumber() < 16279 )
|
---|
201 | //{
|
---|
202 | // rc = 1;
|
---|
203 | // return kCONTINUE;
|
---|
204 | //}
|
---|
205 |
|
---|
206 | Double_t Theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
|
---|
207 | if ( Theta < 0.0 )
|
---|
208 | {
|
---|
209 | *fLog << "MSelBasic::Process; Run, Event, Theta = "
|
---|
210 | << fRawRun->GetRunNumber()<< ", "
|
---|
211 | << fMcEvt->GetEvtNumber() << ", " << Theta << endl;
|
---|
212 | rc = 1;
|
---|
213 | }
|
---|
214 |
|
---|
215 | else if ( Theta > 45.0 )
|
---|
216 | {
|
---|
217 | rc = 2;
|
---|
218 | }
|
---|
219 |
|
---|
220 | else if ( !SwTrigger() )
|
---|
221 | {
|
---|
222 | //*fLog << "MSelBasic::Process; SwTrigger = " << SwTrigger << endl;
|
---|
223 | rc = 3;
|
---|
224 | }
|
---|
225 |
|
---|
226 | fErrors[rc]++;
|
---|
227 |
|
---|
228 | return rc==0 ? kTRUE : kCONTINUE;
|
---|
229 | }
|
---|
230 | // --------------------------------------------------------------------------
|
---|
231 | //
|
---|
232 | // Software trigger
|
---|
233 | //
|
---|
234 | // require 2 neighboring pixels (which are not in the outermost ring),
|
---|
235 | // each having at least 'minphotons' photons
|
---|
236 | //
|
---|
237 | //
|
---|
238 | Bool_t MSelBasic::SwTrigger()
|
---|
239 | {
|
---|
240 | // minimum number of photons required
|
---|
241 | Double_t minphotons = 13.0;
|
---|
242 |
|
---|
243 | const Int_t entries = fEvt->GetNumPixels();
|
---|
244 |
|
---|
245 | //$$$$$$$$$$$$$$$$$$
|
---|
246 | //const Int_t nall = fPed->GetSize();
|
---|
247 | //*fLog << "nall = " << nall << endl;
|
---|
248 | //for (Int_t id=0; id<nall; id++)
|
---|
249 | //{
|
---|
250 | // MGeomPix &gpix = (*fCam)[id];
|
---|
251 | // if ( gpix.IsInOutermostRing() )
|
---|
252 | // {
|
---|
253 | // *fLog << "IsInOutermostRing : pixel no. = " << id << endl;
|
---|
254 | // }
|
---|
255 |
|
---|
256 | // if ( gpix.IsInOuterRing() )
|
---|
257 | // {
|
---|
258 | // *fLog << "IsInOuterRing : pixel no. = " << id << endl;
|
---|
259 | // }
|
---|
260 | //}
|
---|
261 | //$$$$$$$$$$$$$$$$$$
|
---|
262 |
|
---|
263 |
|
---|
264 | for (Int_t i=0; i<entries; i++)
|
---|
265 | {
|
---|
266 | MCerPhotPix &pix = (*fEvt)[i];
|
---|
267 | Int_t id = pix.GetPixId();
|
---|
268 | if (!pix.IsPixelUsed()) continue;
|
---|
269 |
|
---|
270 | Double_t photons = pix.GetNumPhotons();
|
---|
271 | if (photons < minphotons) continue;
|
---|
272 |
|
---|
273 | // this pixel is used and has the required no.of photons
|
---|
274 | // check whether this is also true for a neigboring pixel
|
---|
275 |
|
---|
276 | MGeomPix &gpix = (*fCam)[id];
|
---|
277 | if ( gpix.IsInOutermostRing() ) continue;
|
---|
278 |
|
---|
279 | const Int_t nneighbors = gpix.GetNumNeighbors();
|
---|
280 | for (Int_t n=0; n<nneighbors; n++)
|
---|
281 | {
|
---|
282 | const Int_t id1 = gpix.GetNeighbor(n);
|
---|
283 | if ( !fEvt->IsPixelUsed(id1) ) continue;
|
---|
284 |
|
---|
285 | MGeomPix &gpix1 = (*fCam)[id1];
|
---|
286 | if ( gpix1.IsInOutermostRing() ) continue;
|
---|
287 |
|
---|
288 | //MCerPhotPix &pix1 = (*fEvt)[id1];
|
---|
289 | MCerPhotPix &pix1 = *(fEvt->GetPixById(id1));
|
---|
290 | if ( &pix1 == NULL )
|
---|
291 | {
|
---|
292 | *fLog << "MSelBasic::SwTrigger; &pix1 is NULL" << endl;
|
---|
293 | continue;
|
---|
294 | }
|
---|
295 |
|
---|
296 | Double_t photons1 = pix1.GetNumPhotons();
|
---|
297 | if (photons1 >= minphotons) return kTRUE;
|
---|
298 | }
|
---|
299 | }
|
---|
300 | return kFALSE;
|
---|
301 | }
|
---|
302 |
|
---|
303 | // --------------------------------------------------------------------------
|
---|
304 | //
|
---|
305 | // Prints some statistics about the Basic selections.
|
---|
306 | //
|
---|
307 | Bool_t MSelBasic::PostProcess()
|
---|
308 | {
|
---|
309 | if (GetNumExecutions()==0)
|
---|
310 | return kTRUE;
|
---|
311 |
|
---|
312 | *fLog << inf << endl;
|
---|
313 | *fLog << GetDescriptor() << " execution statistics:" << endl;
|
---|
314 | *fLog << dec << setfill(' ');
|
---|
315 | *fLog << " " << setw(7) << fErrors[1] << " (" << setw(3) << (int)(fErrors[1]*100/GetNumExecutions()) << "%) Evts skipped due to: Zenith angle < 0" << endl;
|
---|
316 |
|
---|
317 | *fLog << " " << setw(7) << fErrors[2] << " (" << setw(3) << (int)(fErrors[2]*100/GetNumExecutions()) << "%) Evts skipped due to: Zenith angle too high" << endl;
|
---|
318 |
|
---|
319 | *fLog << " " << setw(7) << fErrors[3] << " (" << setw(3) << (int)(fErrors[3]*100/GetNumExecutions()) << "%) Evts skipped due to: Software trigger not fullfilled" << endl;
|
---|
320 |
|
---|
321 | *fLog << " " << fErrors[0] << " (" << (int)(fErrors[0]*100/GetNumExecutions()) << "%) Evts survived Basic selections!" << endl;
|
---|
322 | *fLog << endl;
|
---|
323 |
|
---|
324 | return kTRUE;
|
---|
325 | }
|
---|
326 |
|
---|