source: trunk/MagicSoft/Mars/msimcamera/MSimExcessNoise.cc@ 9239

Last change on this file since 9239 was 9239, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 2.7 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 1/2009 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: Software Development, 2000-2009
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MSimExcessNoise
28//
29// This task adds the noise (usually signal height, i.e. excess, dependent)
30// to the photon signal.
31//
32// Input Containers:
33// MCorsikaEvent
34//
35// Output Containers:
36// MCorsikaEvent
37//
38//////////////////////////////////////////////////////////////////////////////
39#include "MSimExcessNoise.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(MSimExcessNoise);
52
53using namespace std;
54
55// --------------------------------------------------------------------------
56//
57// Default Constructor.
58//
59MSimExcessNoise::MSimExcessNoise(const char* name, const char *title)
60: fEvt(0)
61{
62 fName = name ? name : "MSimExcessNoise";
63 fTitle = title ? title : "Task to simulate the excess dependant noise (conversion photon to signal height)";
64}
65
66// --------------------------------------------------------------------------
67//
68// Check for the necessary parameter containers.
69//
70Int_t MSimExcessNoise::PreProcess(MParList *pList)
71{
72 fEvt = (MPhotonEvent*)pList->FindObject("MPhotonEvent");
73 if (!fEvt)
74 {
75 *fLog << err << "MPhotonEvent not found... aborting." << endl;
76 return kFALSE;
77 }
78
79 return kTRUE;
80}
81
82// --------------------------------------------------------------------------
83//
84// Change the weight of each signal according to the access noise
85//
86Int_t MSimExcessNoise::Process()
87{
88 const UInt_t num = fEvt->GetNumPhotons();
89 for (UInt_t i=0; i<num; i++)
90 {
91 MPhotonData &ph = (*fEvt)[i];
92
93 const Float_t oldw = ph.GetWeight();
94 if (oldw<0)
95 continue;
96
97 const Float_t neww = gRandom->Gaus(oldw, 0.2*TMath::Sqrt(oldw));
98 ph.SetWeight(neww);
99 }
100
101 return kTRUE;
102}
Note: See TracBrowser for help on using the repository browser.