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