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