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

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