source: trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcTranslate.cc@ 3986

Last change on this file since 3986 was 3973, checked in by rico, 21 years ago
*** empty log message ***
File size: 3.8 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! Author(s): Javier Rico 04/2004 <mailto:jrico@ifae.es>
18!
19! Copyright: MAGIC Software Development, 2000-2004
20!
21!
22\* ======================================================================== */
23
24//////////////////////////////////////////////////////////////////////////////
25//
26// MSrcTranslate
27//
28// Task to translate the position of the source, starting from previous source
29// position (fTranslationIsRelative=kTRUE) or from camera center
30// (fTranslationIsRelative=kFALSE)
31//
32// Input Containers:
33// MSrcPosCam
34//
35// Output Containers:
36// MSrcPosCam
37// MDCA
38//
39//////////////////////////////////////////////////////////////////////////////
40
41#include <fstream>
42#include <math.h>
43
44#include "MParList.h"
45
46#include "MSrcTranslate.h"
47#include "MSrcPosCam.h"
48#include "MDCA.h"
49
50
51#include "MLog.h"
52#include "MLogManip.h"
53
54ClassImp(MSrcTranslate);
55
56using namespace std;
57
58static const TString gsDefName = "MSrcTranslate";
59static const TString gsDefTitle = "De-rotate position of the source";
60
61// -------------------------------------------------------------------------
62//
63// Default constructor. The first (second) argument is the name of a container
64// containing the source position in the camera plain, MScrPosCam (MDCA).
65// The default is "MSrcPosCam" ("MDCA").
66//
67MSrcTranslate::MSrcTranslate(const char* srcPos, const char* dca, const char *name, const char *title)
68 : fSrcPos(NULL), fDCA(NULL), fShiftX(0.), fShiftY(0.), fTranslationIsRelative(kTRUE)
69{
70 fName = name ? name : gsDefName.Data();
71 fTitle = title ? title : gsDefTitle.Data();
72
73 fSrcPosName = srcPos;
74 fDCAName = dca;
75}
76
77// -------------------------------------------------------------------------
78//
79// Look for/create the needed containers
80//
81Int_t MSrcTranslate::PreProcess(MParList *pList)
82{
83 // look for/create MSrcPosCam
84 fSrcPos = (MSrcPosCam*)pList->FindObject(AddSerialNumber(fSrcPosName), "MSrcPosCam");
85 if (!fSrcPos)
86 {
87 *fLog << warn << AddSerialNumber(fSrcPosName) << " [MSrcPosCam] not found... creating default container." << endl;
88 fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", AddSerialNumber(fSrcPosName));
89 if(!fSrcPos)
90 return kFALSE;
91 }
92
93 // look for/create MDCA
94 fDCA = (MDCA*)pList->FindObject(AddSerialNumber(fDCAName), "MDCA");
95 if (!fDCA)
96 {
97 *fLog << warn << AddSerialNumber(fDCAName) << " [MDCA] not found... creating default container." << endl;
98 fDCA = (MDCA*)pList->FindCreateObj("MDCA", AddSerialNumber(fDCAName));
99 if(!fDCA)
100 return kFALSE;
101 }
102
103 if(fShiftX==0. && fShiftY==0.)
104 *fLog << warn << "MSrcTranslate::PreProcess Warning: Null translation" << endl;
105
106 return kTRUE;
107}
108
109// -------------------------------------------------------------------------
110//
111// Perform the translation of the source position
112//
113Int_t MSrcTranslate::Process()
114{
115 Double_t newX,newY;
116
117 if(fTranslationIsRelative)
118 {
119 newX=fSrcPos->GetX()+fShiftX;
120 newY=fSrcPos->GetY()+fShiftY;
121 }
122 else
123 {
124 newX=fShiftX;
125 newY=fShiftY;
126 }
127
128 fSrcPos->SetX(newX);
129 fSrcPos->SetY(newY);
130 fDCA->SetRefPoint(newX,newY);
131
132 return kTRUE;
133}
Note: See TracBrowser for help on using the repository browser.