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

Last change on this file since 4117 was 4117, checked in by rico, 20 years ago
*** empty log message ***
File size: 3.3 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). This task allows you to modify the position
31// of the source in an event-by-event basis
32//
33// Input Containers:
34// MSrcPosCam
35//
36// Output Containers:
37// MSrcPosCam
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
49#include "MLog.h"
50#include "MLogManip.h"
51
52ClassImp(MSrcTranslate);
53
54using namespace std;
55
56static const TString gsDefName = "MSrcTranslate";
57static const TString gsDefTitle = "De-rotate position of the source";
58
59// -------------------------------------------------------------------------
60//
61// Default constructor. The first (second) argument is the name of the
62// input (output) MSrcPosCam object containing the source position in the
63// camera plain
64//
65MSrcTranslate::MSrcTranslate(const char* srcPosIn, const char* srcPosOut, const char *name, const char *title)
66 : fShiftX(0.), fShiftY(0.), fTranslationIsRelative(kTRUE)
67{
68 fName = name ? name : gsDefName.Data();
69 fTitle = title ? title : gsDefTitle.Data();
70
71 SetInputSrcPosName(srcPosIn);
72 SetOutputSrcPosName(srcPosOut);
73
74 SetInternalHistoName(TString(fName)+"Hist");
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 if(!MSrcPlace::PreProcess(pList))
85 return kFALSE;
86
87 if(fShiftX==0. && fShiftY==0.)
88 *fLog << warn << "MSrcTranslate::PreProcess Warning: Null translation" << endl;
89
90 return kTRUE;
91}
92
93// -------------------------------------------------------------------------
94//
95// Perform the translation of the source position
96//
97Int_t MSrcTranslate::ComputeNewSrcPosition()
98{
99 Double_t newX,newY;
100
101 MSrcPosCam* srcPosOut = GetOutputSrcPosCam();
102
103 if(fTranslationIsRelative)
104 {
105 MSrcPosCam* srcPosIn = GetInputSrcPosCam();
106 newX=srcPosIn->GetX()+fShiftX;
107 newY=srcPosIn->GetY()+fShiftY;
108 }
109 else
110 {
111 newX=fShiftX;
112 newY=fShiftY;
113 }
114
115 srcPosOut->SetXY(newX,newY);
116
117 return kTRUE;
118}
Note: See TracBrowser for help on using the repository browser.