source: trunk/MagicSoft/Mars/mpointing/MSrcPosRndm.cc@ 9000

Last change on this file since 9000 was 8802, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 3.1 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 fSrcPosAnti = (MSrcPosCam*)plist->FindCreateObj("MSrcPosCam", "MSrcPosAnti");
71 if (!fSrcPosAnti)
72 return kFALSE;
73
74 if (fDistOfSource<0)
75 {
76 fHist = (MHSrcPosCam*)plist->FindObject("MHSrcPosCam");
77 if (!fHist)
78 {
79 *fLog << inf << "MHSrcPosCam not found... skipping." << endl;
80 return kSKIP;
81 }
82
83 *fLog << inf << "MHSrcPosCam found... taken to produce a random distribution." << endl;
84 }
85 else
86 *fLog << inf << "Source position will be produced randomly in a distance of " << fDistOfSource << "° from the camera center!" << endl;
87
88 fConvMm2Deg = geom->GetConvMm2Deg();
89
90 return kTRUE;
91}
92
93// --------------------------------------------------------------------------
94//
95// See class description.
96//
97Int_t MSrcPosRndm::Process()
98{
99 Axis_t x, y;
100 if (fDistOfSource<0)
101 fHist->GetHist().GetRandom2(x, y);
102 else
103 {
104 const Double_t phi = gRandom->Uniform(TMath::TwoPi());
105 x = TMath::Cos(phi)*fDistOfSource;
106 y = TMath::Sin(phi)*fDistOfSource;
107 }
108
109 fSrcPos->SetXY(x/fConvMm2Deg, y/fConvMm2Deg);
110 if (fDistOfSource>=0)
111 fSrcPosAnti->SetXY(-x/fConvMm2Deg, -y/fConvMm2Deg);
112 return kTRUE;
113}
Note: See TracBrowser for help on using the repository browser.