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

Last change on this file since 9437 was 9252, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 2.8 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)
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 return kTRUE;
81}
82
83// --------------------------------------------------------------------------
84//
85// Change the weight of each signal according to the access noise
86//
87Int_t MSimExcessNoise::Process()
88{
89 const UInt_t num = fEvt->GetNumPhotons();
90 for (UInt_t i=0; i<num; i++)
91 {
92 MPhotonData &ph = (*fEvt)[i];
93
94 const Float_t oldw = ph.GetWeight();
95 if (oldw<0)
96 continue;
97
98 const Float_t neww = gRandom->Gaus(oldw, 0.2*TMath::Sqrt(oldw));
99 ph.SetWeight(neww);
100 }
101
102 return kTRUE;
103}
Note: See TracBrowser for help on using the repository browser.