source: trunk/MagicSoft/Mars/manalysis/MHillasCalc.cc@ 1683

Last change on this file since 1683 was 1542, checked in by tbretz, 22 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 5.1 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): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de>
19! Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
20!
21! Copyright: MAGIC Software Development, 2000-2002
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27// //
28// MHillasCalc //
29// //
30// This is a task to calculate the Hillas parameters from each event //
31// //
32// Input Containers: //
33// MCerPhotEvt, MGeomCam //
34// //
35// Output Containers: //
36// MHillas //
37// //
38/////////////////////////////////////////////////////////////////////////////
39
40#include "MHillasCalc.h"
41
42#include "MParList.h"
43
44#include "MHillas.h"
45#include "MCerPhotEvt.h"
46
47#include "MLog.h"
48#include "MLogManip.h"
49
50ClassImp(MHillasCalc);
51
52// --------------------------------------------------------------------------
53//
54// Default constructor.
55//
56MHillasCalc::MHillasCalc(const char *hil, const char *name, const char *title)
57{
58 fName = name ? name : "MHillasCalc";
59 fTitle = title ? title : "Task to calculate Hillas parameters";
60
61 fHilName = hil;
62}
63
64// --------------------------------------------------------------------------
65//
66// Check for a MCerPhotEvt object from which the Hillas are calculated.
67// Try to find the Geometry conatiner. And try to find the output
68// (Hillas) container or create one.
69//
70Bool_t MHillasCalc::PreProcess(MParList *pList)
71{
72 fCerPhotEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
73 if (!fCerPhotEvt)
74 {
75 *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
76 return kFALSE;
77 }
78
79 fGeomCam = (MGeomCam*)pList->FindObject("MGeomCam");
80 if (!fGeomCam)
81 {
82 *fLog << dbginf << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
83 return kFALSE;
84 }
85
86 fHillas = (MHillas*)pList->FindCreateObj(fHilName);
87 if (!fHillas)
88 return kFALSE;
89
90 memset(fErrors, 0, sizeof(fErrors));
91
92 return kTRUE;
93}
94
95// --------------------------------------------------------------------------
96//
97// If you want do complex descisions inside the calculations
98// we must move the calculation code inside this function
99//
100// If the calculation wasn't sucessfull skip this event
101//
102Bool_t MHillasCalc::Process()
103{
104 const Int_t rc = fHillas->Calc(*fGeomCam, *fCerPhotEvt);
105 if (rc<0 || rc>4)
106 {
107 *fLog << err << dbginf << "MHillas::Calc returned unknown error code!" << endl;
108 return kFALSE;
109 }
110 fErrors[rc]++;
111
112 return rc==0 ? kTRUE : kCONTINUE;
113}
114
115// --------------------------------------------------------------------------
116//
117// Prints some statistics about the hillas calculation. The percentage
118// is calculated with respect to the number of executions of this task.
119//
120Bool_t MHillasCalc::PostProcess()
121{
122 if (GetNumExecutions()==0)
123 return kTRUE;
124
125 *fLog << inf << endl;
126 *fLog << GetDescriptor() << " execution statistics:" << endl;
127 *fLog << dec << setfill(' ');
128 *fLog << " " << setw(7) << fErrors[1] << " (" << setw(3) << (int)(fErrors[1]*100/GetNumExecutions()) << "%) Evts skipped due to: Event has less than 3 pixels" << endl;
129 *fLog << " " << setw(7) << fErrors[2] << " (" << setw(3) << (int)(fErrors[2]*100/GetNumExecutions()) << "%) Evts skipped due to: Calculated Size == 0" << endl;
130 *fLog << " " << setw(7) << fErrors[3] << " (" << setw(3) << (int)(fErrors[3]*100/GetNumExecutions()) << "%) Evts skipped due to: Number of used pixels < 3" << endl;
131 *fLog << " " << setw(7) << fErrors[4] << " (" << setw(3) << (int)(fErrors[4]*100/GetNumExecutions()) << "%) Evts skipped due to: CorrXY==0" << endl;
132 *fLog << " " << fErrors[0] << " (" << (int)(fErrors[0]*100/GetNumExecutions()) << "%) Evts survived Hillas calculation!" << endl;
133 *fLog << endl;
134
135 return kTRUE;
136}
Note: See TracBrowser for help on using the repository browser.