source: trunk/MagicSoft/Mars/mfilter/MFSoftwareTrigger.cc@ 2936

Last change on this file since 2936 was 2704, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.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): Wolfgang Wittek, 04/2003 <mailto:wittek@mppmu.mpg.de>
19! Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2003
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MFSoftwareTrigger
29//
30// This is a class to evaluate a software trigger
31//
32// to be called after the calibration (when the number of photons is
33// available for all pixels)
34//
35// require 2 neighboring pixels (which are not in the outermost ring),
36// each having at least 'fNumMinPhotons' photons
37//
38//
39/////////////////////////////////////////////////////////////////////////////
40#include "MFSoftwareTrigger.h"
41
42#include "MLog.h"
43#include "MLogManip.h"
44
45#include "MParList.h"
46
47#include "MGeomPix.h"
48#include "MGeomCam.h"
49
50#include "MCerPhotEvt.h"
51
52ClassImp(MFSoftwareTrigger);
53
54using namespace std;
55
56// --------------------------------------------------------------------------
57//
58// Default constructor.
59//
60MFSoftwareTrigger::MFSoftwareTrigger(const char *name, const char *title)
61 : fNumMinPhotons(0)
62{
63 fName = name ? name : "MFSoftwareTrigger";
64 fTitle = title ? title : "Filter for software trigger";
65}
66
67// --------------------------------------------------------------------------
68//
69// Software trigger
70//
71// require 2 neighboring pixels (which are not in the outermost ring),
72// each having at least 'fNumMinPhotons' photons
73//
74Bool_t MFSoftwareTrigger::SwTrigger() const
75{
76 const Int_t entries = fEvt->GetNumPixels();
77
78 for (Int_t i=0; i<entries; i++)
79 {
80 const MCerPhotPix &pix = (*fEvt)[i];
81 if (!pix.IsPixelUsed())
82 continue;
83
84 if (pix.GetNumPhotons()<fNumMinPhotons)
85 continue;
86
87 // this pixel is used and has the required no.of photons
88 // check whether this is also true for a neigboring pixel
89 MGeomPix &gpix = (*fCam)[pix.GetPixId()];
90 if (gpix.IsInOutermostRing())
91 continue;
92
93 const Int_t nneighbors = gpix.GetNumNeighbors();
94 for (Int_t n=0; n<nneighbors; n++)
95 {
96 const Int_t id = gpix.GetNeighbor(n);
97 if (!fEvt->IsPixelUsed(id))
98 continue;
99
100 if ((*fCam)[id].IsInOutermostRing())
101 continue;
102
103 const Double_t photons = fEvt->GetPixById(id)->GetNumPhotons();
104 if (photons >= fNumMinPhotons)
105 return kTRUE;
106 }
107 }
108 return kFALSE;
109}
110
111// --------------------------------------------------------------------------
112//
113// Request pointer to MCerPhotEvt and MGeomCam from paremeter list
114//
115Int_t MFSoftwareTrigger::PreProcess(MParList *pList)
116{
117 fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
118 if (!fEvt)
119 {
120 *fLog << err << "MCerPhotEvt not found... aborting." << endl;
121 return kFALSE;
122 }
123
124 fCam = (MGeomCam*)pList->FindObject("MGeomCam");
125 if (!fCam)
126 {
127 *fLog << err << "MGeomCam not found... aborting." << endl;
128 return kFALSE;
129 }
130
131 memset(fCut, 0, sizeof(fCut));
132
133 return kTRUE;
134}
135
136// --------------------------------------------------------------------------
137//
138// Evaluate software trigger
139//
140Int_t MFSoftwareTrigger::Process()
141{
142 fResult = SwTrigger();
143
144 fCut[fResult ? 0 : 1]++;
145 return kTRUE;
146}
147
148// --------------------------------------------------------------------------
149//
150// Prints some statistics about the Basic selections.
151//
152Int_t MFSoftwareTrigger::PostProcess()
153{
154 if (GetNumExecutions()==0)
155 return kTRUE;
156
157 *fLog << inf << endl;
158 *fLog << GetDescriptor() << " execution statistics:" << endl;
159 *fLog << dec << setfill(' ');
160
161 *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
162 *fLog << (int)(fCut[1]*100/GetNumExecutions()) ;
163 *fLog << "%) Evts skipped due to: Software trigger not fullfilled" ;
164 *fLog << " (with fNumMinPhotons = " << fNumMinPhotons << ")" << endl;
165
166 *fLog << " " << fCut[0] << " (" << (int)(fCut[0]*100/GetNumExecutions()) ;
167 *fLog << "%) Evts survived software trigger!" << endl;
168 *fLog << endl;
169
170 return kTRUE;
171}
Note: See TracBrowser for help on using the repository browser.