source: trunk/Mars/msimcamera/MSimPSF.cc@ 10047

Last change on this file since 10047 was 9301, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 3.1 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of CheObs, the Modular 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 appears 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, 1/2009 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: CheObs Software Development, 2000-2009
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MSimPSF
28//
29// This task makes a naiv simulation of the psf by smearing out the photons
30// in a plane (camera plane) by a 2D-Gaussian with fSigma
31//
32// Input Containers:
33// MPhotonEvent
34//
35// Output Containers:
36// MPhotonEvent
37//
38//////////////////////////////////////////////////////////////////////////////
39#include "MSimPSF.h"
40
41#include <TRandom.h>
42
43#include "MLog.h"
44#include "MLogManip.h"
45
46#include "MParList.h"
47
48#include "MPhotonEvent.h"
49#include "MPhotonData.h"
50
51ClassImp(MSimPSF);
52
53using namespace std;
54
55// --------------------------------------------------------------------------
56//
57// Default Constructor.
58//
59MSimPSF::MSimPSF(const char* name, const char *title)
60 : fEvt(0), fSigma(-1)
61{
62 fName = name ? name : "MSimPSF";
63 fTitle = title ? title : "Task to do a naiv simulation of the psf by smearout in the camera plane";
64}
65
66// --------------------------------------------------------------------------
67//
68// Search for MPhotonEvent
69//
70Int_t MSimPSF::PreProcess(MParList *pList)
71{
72 if (fSigma<=0)
73 return kSKIP;
74
75 fEvt = (MPhotonEvent*)pList->FindObject("MPhotonEvent");
76 if (!fEvt)
77 {
78 *fLog << err << "MPhotonEvent not found... aborting." << endl;
79 return kFALSE;
80 }
81
82 return kTRUE;
83}
84
85// --------------------------------------------------------------------------
86//
87// Smear out all photons by a gaussian with fSigma
88//
89Int_t MSimPSF::Process()
90{
91 const UInt_t num = fEvt->GetNumPhotons();
92
93 // Loop over all mirrors
94 for (UInt_t i=0; i<num; i++)
95 {
96 // Get i-th photon
97 MPhotonData &ph = (*fEvt)[i];
98
99 // Get random gaussian shift
100 const TVector2 v(gRandom->Gaus(0, fSigma), gRandom->Gaus(0, fSigma));
101
102 // Add random smear out
103 ph.SetPosition(ph.GetPos2()+v);
104 }
105
106 return kTRUE;
107}
108
109// --------------------------------------------------------------------------
110//
111// Sigma: 10
112//
113Int_t MSimPSF::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
114{
115 Bool_t rc = kFALSE;
116
117 if (IsEnvDefined(env, prefix, "Sigma", print))
118 {
119 rc = kTRUE;
120 fSigma = GetEnvValue(env, prefix, "Sigma", fSigma);
121 }
122
123 return rc;
124}
Note: See TracBrowser for help on using the repository browser.