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

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