source: trunk/MagicSoft/Mars/mfilter/MFCosmics.cc@ 3416

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