source: tags/Mars-V1.2/mpointing/MSrcPosRndm.cc

Last change on this file was 7690, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 2.9 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, 3/2006 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2006
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MSrcPosRndm
28//
29// Input Container:
30// MHSrcPosCam
31//
32// Output Container:
33// MSrcPosCam
34//
35/////////////////////////////////////////////////////////////////////////////
36#include "MSrcPosRndm.h"
37
38#include <TRandom.h>
39
40#include "MLog.h"
41#include "MLogManip.h"
42
43#include "MParList.h"
44
45#include "MGeomCam.h"
46#include "MSrcPosCam.h"
47#include "MHSrcPosCam.h"
48
49ClassImp(MSrcPosRndm);
50
51using namespace std;
52
53// --------------------------------------------------------------------------
54//
55// Search for 'MPointingPos'. Create if not found.
56//
57Int_t MSrcPosRndm::PreProcess(MParList *plist)
58{
59 MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
60 if (!geom)
61 {
62 *fLog << err << "ERROR - MGeomCam not found... aborting." << endl;
63 return kFALSE;
64 }
65
66 fSrcPos = (MSrcPosCam*)plist->FindCreateObj("MSrcPosCam");
67 if (!fSrcPos)
68 return kFALSE;
69
70 if (fDistOfSource<0)
71 {
72 fHist = (MHSrcPosCam*)plist->FindObject("MHSrcPosCam");
73 if (!fHist)
74 {
75 *fLog << inf << "MHSrcPosCam not found... skipping." << endl;
76 return kSKIP;
77 }
78
79 *fLog << inf << "MHSrcPosCam found... taken to produce a random distribution." << endl;
80 }
81 else
82 *fLog << inf << "Source position will be produced randomly in a distance of " << fDistOfSource << "° from the camera center!" << endl;
83
84 fConvMm2Deg = geom->GetConvMm2Deg();
85
86 return kTRUE;
87}
88
89// --------------------------------------------------------------------------
90//
91// See class description.
92//
93Int_t MSrcPosRndm::Process()
94{
95 Axis_t x, y;
96 if (fDistOfSource<0)
97 fHist->GetHist().GetRandom2(x, y);
98 else
99 {
100 const Double_t phi = gRandom->Uniform(TMath::TwoPi());
101 x = TMath::Cos(phi)*fDistOfSource;
102 y = TMath::Sin(phi)*fDistOfSource;
103 }
104
105 fSrcPos->SetXY(x/fConvMm2Deg, y/fConvMm2Deg);
106 return kTRUE;
107}
Note: See TracBrowser for help on using the repository browser.