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

Last change on this file since 4521 was 3500, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 5.0 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), fNumNeighbors(2)
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 Int_t num = 1;
94
95 const Int_t nneighbors = gpix.GetNumNeighbors();
96 for (Int_t n=0; n<nneighbors; n++)
97 {
98 const Int_t id = gpix.GetNeighbor(n);
99 if (!fEvt->IsPixelUsed(id))
100 continue;
101
102 if ((*fCam)[id].IsInOutermostRing())
103 continue;
104
105 const Double_t photons = fEvt->GetPixById(id)->GetNumPhotons();
106 if (photons >= fNumMinPhotons)
107 if (++num==fNumNeighbors)
108 return kTRUE;
109 }
110 }
111 return kFALSE;
112}
113
114// --------------------------------------------------------------------------
115//
116// Request pointer to MCerPhotEvt and MGeomCam from paremeter list
117//
118Int_t MFSoftwareTrigger::PreProcess(MParList *pList)
119{
120 fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
121 if (!fEvt)
122 {
123 *fLog << err << "MCerPhotEvt not found... aborting." << endl;
124 return kFALSE;
125 }
126
127 fCam = (MGeomCam*)pList->FindObject("MGeomCam");
128 if (!fCam)
129 {
130 *fLog << err << "MGeomCam not found... aborting." << endl;
131 return kFALSE;
132 }
133
134 memset(fCut, 0, sizeof(fCut));
135
136 return kTRUE;
137}
138
139// --------------------------------------------------------------------------
140//
141// Evaluate software trigger
142//
143Int_t MFSoftwareTrigger::Process()
144{
145 fResult = SwTrigger();
146
147 fCut[fResult ? 0 : 1]++;
148 return kTRUE;
149}
150
151// --------------------------------------------------------------------------
152//
153// Prints some statistics about the Basic selections.
154//
155Int_t MFSoftwareTrigger::PostProcess()
156{
157 if (GetNumExecutions()==0)
158 return kTRUE;
159
160 *fLog << inf << endl;
161 *fLog << GetDescriptor() << " execution statistics:" << endl;
162 *fLog << dec << setfill(' ');
163
164 *fLog << " " << setw(7) << fCut[0] << " (" << setw(3) ;
165 *fLog << (int)(fCut[0]*100/GetNumExecutions());
166 *fLog << "%) Evts fullfilled software trigger";
167 *fLog << " (NumPhotons>=" << fNumMinPhotons << ", NumNeighbors>=";
168 *fLog << (int)fNumNeighbors << ")" << endl;
169 *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
170 *fLog << (int)(fCut[1]*100/GetNumExecutions());
171 *fLog << "%) Evts didn't fullfill software trigger." << endl;
172
173 return kTRUE;
174}
Note: See TracBrowser for help on using the repository browser.