source: branches/AddingGoogleTestEnvironment/msimcamera/MSimExcessNoise.cc@ 19779

Last change on this file since 19779 was 9518, checked in by tbretz, 15 years ago
*** empty log message ***
File size: 3.3 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// 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 <TMath.h>
42#include <TRandom.h>
43
44#include "MLog.h"
45#include "MLogManip.h"
46
47#include "MParList.h"
48
49#include "MPhotonEvent.h"
50#include "MPhotonData.h"
51
52ClassImp(MSimExcessNoise);
53
54using namespace std;
55
56// --------------------------------------------------------------------------
57//
58// Default Constructor.
59//
60MSimExcessNoise::MSimExcessNoise(const char* name, const char *title)
61: fEvt(0), fExcessNoise(0.2)
62{
63 fName = name ? name : "MSimExcessNoise";
64 fTitle = title ? title : "Task to simulate the excess dependant noise (conversion photon to signal height)";
65}
66
67// --------------------------------------------------------------------------
68//
69// Check for the necessary parameter containers.
70//
71Int_t MSimExcessNoise::PreProcess(MParList *pList)
72{
73 fEvt = (MPhotonEvent*)pList->FindObject("MPhotonEvent");
74 if (!fEvt)
75 {
76 *fLog << err << "MPhotonEvent not found... aborting." << endl;
77 return kFALSE;
78 }
79
80 *fLog << inf << "Excess Noise Factor in use " << fExcessNoise << "%" << endl;
81
82 return kTRUE;
83}
84
85// --------------------------------------------------------------------------
86//
87// Change the weight of each signal according to the access noise
88//
89Int_t MSimExcessNoise::Process()
90{
91 const UInt_t num = fEvt->GetNumPhotons();
92 for (UInt_t i=0; i<num; i++)
93 {
94 MPhotonData &ph = (*fEvt)[i];
95
96 const Float_t oldw = ph.GetWeight();
97 if (oldw<0)
98 continue;
99
100 const Float_t neww = gRandom->Gaus(oldw, fExcessNoise*TMath::Sqrt(oldw));
101 ph.SetWeight(neww);
102 }
103
104 return kTRUE;
105}
106
107// --------------------------------------------------------------------------
108//
109// ExcessNoise: 0.2
110//
111Int_t MSimExcessNoise::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
112{
113 Bool_t rc = kFALSE;
114 if (IsEnvDefined(env, prefix, "ExcessNoise", print))
115 {
116 rc = kTRUE;
117 fExcessNoise = GetEnvValue(env, prefix, "ExcessNoise", fExcessNoise);
118 }
119
120 return rc;
121}
Note: See TracBrowser for help on using the repository browser.