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): Markus Gaug 02/2004 <mailto:markus@ifae.es>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MFCosmics
|
---|
28 | //
|
---|
29 | // Filter to reject cosmics by the criterion that at least
|
---|
30 | // fMaxEmptyPixels pixels have values of lower than 3 Pedestal RMS.
|
---|
31 | // fMaxEmptyPixels is set to 230 by default which is slightly higher
|
---|
32 | // than the number of outer pixels in MAGIC (for the case that
|
---|
33 | // the outer pixels have some defect).
|
---|
34 | //
|
---|
35 | // ProProcess: Search for MPedestalCam, MExtractedSignalCam
|
---|
36 | //
|
---|
37 | // ReInit: Initialize number of used FADC slices
|
---|
38 | //
|
---|
39 | // Process: if fMaxEmptyPixels pixels lower than 3 pedRMS,
|
---|
40 | // the event is supposed to
|
---|
41 | // be a cosmic and kContinue is returned
|
---|
42 | //
|
---|
43 | //
|
---|
44 | // Input Containers:
|
---|
45 | // MRawEvtData
|
---|
46 | // MPedestalCam
|
---|
47 | // MExtractedSignalCam
|
---|
48 | //
|
---|
49 | // Output Containers:
|
---|
50 | //
|
---|
51 | //////////////////////////////////////////////////////////////////////////////
|
---|
52 | #include "MFCosmics.h"
|
---|
53 |
|
---|
54 | #include "MLog.h"
|
---|
55 | #include "MLogManip.h"
|
---|
56 |
|
---|
57 | #include "MParList.h"
|
---|
58 |
|
---|
59 | #include "MGeomCam.h"
|
---|
60 | #include "MRawEvtPixelIter.h"
|
---|
61 |
|
---|
62 | #include "MPedestalCam.h"
|
---|
63 | #include "MPedestalPix.h"
|
---|
64 |
|
---|
65 | #include "MExtractedSignalCam.h"
|
---|
66 | #include "MExtractedSignalPix.h"
|
---|
67 |
|
---|
68 | ClassImp(MFCosmics);
|
---|
69 |
|
---|
70 | using namespace std;
|
---|
71 | // --------------------------------------------------------------------------
|
---|
72 | //
|
---|
73 | // Default constructor.
|
---|
74 | //
|
---|
75 | MFCosmics::MFCosmics(const char *name, const char *title)
|
---|
76 | : fPedestals(NULL), fSignals(NULL),
|
---|
77 | fRawEvt(NULL), fMaxEmptyPixels(230)
|
---|
78 | {
|
---|
79 |
|
---|
80 | fName = name ? name : "MFCosmics";
|
---|
81 | fTitle = title ? title : "Filter to reject cosmics";
|
---|
82 | }
|
---|
83 |
|
---|
84 | // --------------------------------------------------------------------------
|
---|
85 | //
|
---|
86 | // The PreProcess searches for the following input containers:
|
---|
87 | // - MRawEvtData
|
---|
88 | // - MPedestalCam
|
---|
89 | // - MExtractedSignalCam
|
---|
90 | //
|
---|
91 | Int_t MFCosmics::PreProcess(MParList *pList)
|
---|
92 | {
|
---|
93 |
|
---|
94 | fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
|
---|
95 | if (!fRawEvt)
|
---|
96 | {
|
---|
97 | *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
|
---|
98 | return kFALSE;
|
---|
99 | }
|
---|
100 |
|
---|
101 | fPedestals = (MPedestalCam*)pList->FindObject("MPedestalCam");
|
---|
102 | if (!fPedestals)
|
---|
103 | {
|
---|
104 | *fLog << err << dbginf << "Cannot find MPedestalCam ... aborting" << endl;
|
---|
105 | return kFALSE;
|
---|
106 | }
|
---|
107 |
|
---|
108 | fSignals = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
|
---|
109 | if (!fSignals)
|
---|
110 | {
|
---|
111 | *fLog << err << dbginf << "Cannot find MExtractedSignalCam ... aborting" << endl;
|
---|
112 | return kFALSE;
|
---|
113 | }
|
---|
114 |
|
---|
115 | memset(fCut, 0, sizeof(fCut));
|
---|
116 |
|
---|
117 | return kTRUE;
|
---|
118 | }
|
---|
119 |
|
---|
120 |
|
---|
121 | // --------------------------------------------------------------------------
|
---|
122 | //
|
---|
123 | // The ReInit searches the following input containers for information:
|
---|
124 | // - MExtractedSignalCam
|
---|
125 | //
|
---|
126 | Bool_t MFCosmics::ReInit(MParList *pList )
|
---|
127 | {
|
---|
128 |
|
---|
129 | fSqrtHiGainSamples = TMath::Sqrt((Float_t) fSignals->GetNumUsedHiGainFADCSlices());
|
---|
130 |
|
---|
131 | return kTRUE;
|
---|
132 | }
|
---|
133 |
|
---|
134 |
|
---|
135 | // --------------------------------------------------------------------------
|
---|
136 | //
|
---|
137 | // Retrieve the integral of the FADC time slices and compare them to the
|
---|
138 | // pedestal values.
|
---|
139 | //
|
---|
140 | Int_t MFCosmics::Process()
|
---|
141 | {
|
---|
142 |
|
---|
143 | fResult = CosmicsRejection();
|
---|
144 |
|
---|
145 | fCut[fResult ? 0 : 1]++;
|
---|
146 | return kTRUE;
|
---|
147 | }
|
---|
148 |
|
---|
149 | // ---------------------------------------------------------
|
---|
150 | //
|
---|
151 | // Cosmics rejection:
|
---|
152 | //
|
---|
153 | // Requiring less than fMaxEmptyPixels pixels to have values
|
---|
154 | // lower than 3 Pedestal RMS.
|
---|
155 | //
|
---|
156 | // fMaxEmptyPixels is set to 230 by default which is slightly higher
|
---|
157 | // than the number of outer pixels in MAGIC (for the case that
|
---|
158 | // the outer pixels have some defect).
|
---|
159 | //
|
---|
160 | Bool_t MFCosmics::CosmicsRejection()
|
---|
161 | {
|
---|
162 |
|
---|
163 | MRawEvtPixelIter pixel(fRawEvt);
|
---|
164 |
|
---|
165 | Int_t cosmicpix = 0;
|
---|
166 |
|
---|
167 | //
|
---|
168 | // Create a first loop to sort out the cosmics ...
|
---|
169 | //
|
---|
170 | while (pixel.Next())
|
---|
171 | {
|
---|
172 |
|
---|
173 | const UInt_t idx = pixel.GetPixelId();
|
---|
174 |
|
---|
175 | MExtractedSignalPix &sig = (*fSignals)[idx];
|
---|
176 | MPedestalPix &ped = (*fPedestals)[idx];
|
---|
177 | const Float_t pedrms = ped.GetPedestalRms()*fSqrtHiGainSamples;
|
---|
178 | const Float_t sumhi = sig.GetExtractedSignalHiGain();
|
---|
179 |
|
---|
180 | //
|
---|
181 | // We consider a pixel as presumably due to cosmics
|
---|
182 | // if its sum of FADC slices is lower than 3 pedestal RMS
|
---|
183 | //
|
---|
184 | if (sumhi < 3.*pedrms )
|
---|
185 | cosmicpix++;
|
---|
186 | }
|
---|
187 |
|
---|
188 | //
|
---|
189 | // If the camera contains more than fMaxEmptyPixels
|
---|
190 | // presumed pixels due to cosmics, then the event is discarted.
|
---|
191 | //
|
---|
192 | if (cosmicpix > fMaxEmptyPixels)
|
---|
193 | return kTRUE;
|
---|
194 |
|
---|
195 | return kFALSE;
|
---|
196 | }
|
---|
197 |
|
---|
198 | Int_t MFCosmics::PostProcess()
|
---|
199 | {
|
---|
200 |
|
---|
201 | if (GetNumExecutions()==0)
|
---|
202 | return kTRUE;
|
---|
203 |
|
---|
204 | *fLog << inf << endl;
|
---|
205 | *fLog << GetDescriptor() << " execution statistics:" << endl;
|
---|
206 | *fLog << dec << setfill(' ');
|
---|
207 |
|
---|
208 | *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
|
---|
209 | *fLog << (int)(fCut[1]*100/GetNumExecutions()) ;
|
---|
210 | *fLog << "%) Evts skipped due to: Cosmics Rejection applied " ;
|
---|
211 | *fLog << " (with fMaxEmptyPixels = " << fMaxEmptyPixels << ")" << endl;
|
---|
212 |
|
---|
213 | *fLog << " " << fCut[0] << " (" << (int)(fCut[0]*100/GetNumExecutions()) ;
|
---|
214 | *fLog << "%) Evts survived the cosmics rejection!" << endl;
|
---|
215 | *fLog << endl;
|
---|
216 |
|
---|
217 | return kTRUE;
|
---|
218 | }
|
---|
219 |
|
---|