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

Last change on this file since 3253 was 3183, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 5.5 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 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// 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(230)
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 memset(fCut, 0, sizeof(fCut));
106
107 return kTRUE;
108}
109
110
111// --------------------------------------------------------------------------
112//
113// Initialize number of used FADC slices
114//
115Bool_t MFCosmics::ReInit(MParList *pList)
116{
117 fSqrtHiGainSamples = TMath::Sqrt((Float_t) fSignals->GetNumUsedHiGainFADCSlices());
118
119 return kTRUE;
120}
121
122
123// --------------------------------------------------------------------------
124//
125// Retrieve the integral of the FADC time slices and compare them to the
126// pedestal values.
127//
128Int_t MFCosmics::Process()
129{
130 fResult = CosmicsRejection();
131
132 fCut[fResult ? 0 : 1]++;
133 return kTRUE;
134}
135
136// ---------------------------------------------------------
137//
138// Cosmics rejection:
139//
140// Requiring less than fMaxEmptyPixels pixels to have values
141// lower than 3 Pedestal RMS.
142//
143// fMaxEmptyPixels is set to 230 by default which is slightly higher
144// than the number of outer pixels in MAGIC (for the case that
145// the outer pixels have some defect).
146//
147Bool_t MFCosmics::CosmicsRejection() const
148{
149 MRawEvtPixelIter pixel(fRawEvt);
150
151 Int_t cosmicpix = 0;
152
153 //
154 // Create a first loop to sort out the cosmics ...
155 //
156 while (pixel.Next())
157 {
158 const UInt_t idx = pixel.GetPixelId();
159
160 MExtractedSignalPix &sig = (*fSignals)[idx];
161 MPedestalPix &ped = (*fPedestals)[idx];
162
163 const Float_t pedrms = ped.GetPedestalRms()*fSqrtHiGainSamples;
164 const Float_t sumhi = sig.GetExtractedSignalHiGain();
165
166 //
167 // We consider a pixel as presumably due to cosmics
168 // if its sum of FADC slices is lower than 3 pedestal RMS
169 //
170 if (sumhi < 3.*pedrms )
171 cosmicpix++;
172 }
173
174 //
175 // If the camera contains more than fMaxEmptyPixels
176 // presumed pixels due to cosmics, then the event is discarted.
177 //
178 return cosmicpix > fMaxEmptyPixels;
179}
180
181Int_t MFCosmics::PostProcess()
182{
183 if (GetNumExecutions()==0)
184 return kTRUE;
185
186 *fLog << inf << endl;
187 *fLog << GetDescriptor() << " execution statistics:" << endl;
188 *fLog << dec << setfill(' ');
189
190 *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
191 *fLog << (int)(fCut[1]*100/GetNumExecutions()) ;
192 *fLog << "%) Evts skipped due to: Cosmics Rejection applied " ;
193 *fLog << " (with fMaxEmptyPixels = " << fMaxEmptyPixels << ")" << endl;
194
195 *fLog << " " << setw(7) << fCut[0] << " (" << setw(3) ;
196 *fLog << (int)(fCut[0]*100/GetNumExecutions()) ;
197 *fLog << "%) Evts survived the cosmics rejection!" << endl;
198 *fLog << endl;
199
200 return kTRUE;
201}
202
Note: See TracBrowser for help on using the repository browser.