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