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 | // [MDCA]
|
---|
36 | //
|
---|
37 | // Output Containers:
|
---|
38 | // MSrcPosCam
|
---|
39 | // MDCA
|
---|
40 | //
|
---|
41 | //////////////////////////////////////////////////////////////////////////////
|
---|
42 |
|
---|
43 | #include <fstream>
|
---|
44 | #include <math.h>
|
---|
45 |
|
---|
46 | #include "MParList.h"
|
---|
47 |
|
---|
48 | #include "MSrcTranslate.h"
|
---|
49 | #include "MSrcPosCam.h"
|
---|
50 | #include "MDCA.h"
|
---|
51 |
|
---|
52 | #include "MLog.h"
|
---|
53 | #include "MLogManip.h"
|
---|
54 |
|
---|
55 | ClassImp(MSrcTranslate);
|
---|
56 |
|
---|
57 | using namespace std;
|
---|
58 |
|
---|
59 | static const TString gsDefName = "MSrcTranslate";
|
---|
60 | static const TString gsDefTitle = "De-rotate position of the source";
|
---|
61 |
|
---|
62 | // -------------------------------------------------------------------------
|
---|
63 | //
|
---|
64 | // Default constructor. The first (second) argument is the name of a container
|
---|
65 | // containing the source position in the camera plain, MScrPosCam (MDCA).
|
---|
66 | // The default is "MSrcPosCam" ("MDCA").
|
---|
67 | //
|
---|
68 | MSrcTranslate::MSrcTranslate(const char* srcPos, const char* dca, const char *name, const char *title)
|
---|
69 | : MSrcPlace(TString(gsDefName+"Hist").Data()), fShiftX(0.), fShiftY(0.), fTranslationIsRelative(kTRUE)
|
---|
70 | {
|
---|
71 | fName = name ? name : gsDefName.Data();
|
---|
72 | fTitle = title ? title : gsDefTitle.Data();
|
---|
73 |
|
---|
74 | SetSrcPosName(srcPos);
|
---|
75 | SetDCAName(dca);
|
---|
76 | }
|
---|
77 |
|
---|
78 | // -------------------------------------------------------------------------
|
---|
79 | //
|
---|
80 | // Look for/create the needed containers
|
---|
81 | //
|
---|
82 | Int_t MSrcTranslate::PreProcess(MParList *pList)
|
---|
83 | {
|
---|
84 | // look for/create MSrcPosCam and DCA
|
---|
85 | if(!MSrcPlace::PreProcess(pList))
|
---|
86 | return kFALSE;
|
---|
87 |
|
---|
88 | if(fShiftX==0. && fShiftY==0.)
|
---|
89 | *fLog << warn << "MSrcTranslate::PreProcess Warning: Null translation" << endl;
|
---|
90 |
|
---|
91 | return kTRUE;
|
---|
92 | }
|
---|
93 |
|
---|
94 | // -------------------------------------------------------------------------
|
---|
95 | //
|
---|
96 | // Perform the translation of the source position
|
---|
97 | //
|
---|
98 | Int_t MSrcTranslate::ComputeNewSrcPosition()
|
---|
99 | {
|
---|
100 | Double_t newX,newY;
|
---|
101 |
|
---|
102 | MSrcPosCam* srcPos = GetSrcPosCam();
|
---|
103 | MDCA* dca = GetDCA();
|
---|
104 |
|
---|
105 | if(fTranslationIsRelative)
|
---|
106 | {
|
---|
107 | newX=srcPos->GetX()+fShiftX;
|
---|
108 | newY=srcPos->GetY()+fShiftY;
|
---|
109 | }
|
---|
110 | else
|
---|
111 | {
|
---|
112 | newX=fShiftX;
|
---|
113 | newY=fShiftY;
|
---|
114 | }
|
---|
115 |
|
---|
116 | srcPos->SetX(newX);
|
---|
117 | srcPos->SetY(newY);
|
---|
118 | dca->SetRefPoint(newX,newY);
|
---|
119 |
|
---|
120 | return kTRUE;
|
---|
121 | }
|
---|