source: trunk/MagicSoft/Mars/mpointing/MHSrcPosCam.cc@ 7553

Last change on this file since 7553 was 7553, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 4.5 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, 2/2006 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2006
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MHSrcPosCam
28//
29//
30// FIXME: Use ReInit...
31//
32//////////////////////////////////////////////////////////////////////////////
33#include "MHSrcPosCam.h"
34
35#include <TCanvas.h>
36
37#include "MGeomCam.h"
38#include "MSrcPosCam.h"
39#include "MParameters.h"
40#include "MPointingPos.h"
41
42#include "MString.h"
43#include "MBinning.h"
44#include "MParList.h"
45
46#include "MLog.h"
47#include "MLogManip.h"
48
49ClassImp(MHSrcPosCam);
50
51using namespace std;
52
53// --------------------------------------------------------------------------
54//
55// Default Constructor
56//
57MHSrcPosCam::MHSrcPosCam(const char *name, const char *title)
58 : fTimeEffOn(NULL), fEffOnTime(NULL), fSourcePos(NULL)
59{
60 //
61 // set the name and title of this object
62 //
63 fName = name ? name : "MHSrcPosCam";
64 fTitle = title ? title : "Histogram for source position distribution";
65
66 fHist.SetName("SourcePos");
67 fHist.SetTitle("Source position distribution in camera coordinates");
68 fHist.SetXTitle("dx [\\circ]");
69 fHist.SetYTitle("dy [\\circ]");
70 fHist.SetZTitle("T_{eff} [s]");
71 fHist.SetDirectory(NULL);
72 fHist.UseCurrentStyle();
73
74 MBinning bins;
75 bins.SetEdges(51, -0.2499, 0.2499);
76
77 MH::SetBinning(&fHist, &bins, &bins);
78}
79
80Bool_t MHSrcPosCam::SetupFill(const MParList *pl)
81{
82 fTimeEffOn = (MTime*)pl->FindObject("MTimeEffectiveOnTime");
83 if (!fTimeEffOn)
84 {
85 *fLog << err << "ERROR - MTimeEffOnTime not found... aborting." << endl;
86 return kFALSE;
87 }
88
89 MGeomCam *geom = (MGeomCam*)pl->FindObject("MGeomCam");
90 if (!geom)
91 {
92 *fLog << err << "ERROR - MGeomCam not found... aborting." << endl;
93 return kFALSE;
94 }
95
96 fEffOnTime = (MParameterD*)pl->FindObject("MEffectiveOnTime");
97 if (!fEffOnTime)
98 {
99 *fLog << err << "ERROR - MEffectiveOnTime not found... aborting." << endl;
100 return kFALSE;
101 }
102
103 MPointingPos *pos = (MPointingPos*)pl->FindObject("MSourcePos", "MPointingPos");
104 if (!pos)
105 {
106 *fLog << warn << "ERROR - MSourcePos not found... aborting." << endl;
107 return kFALSE;
108 }
109
110 const TString src = pos->GetString("radec");
111 fHist.SetTitle(MString::Form("SrcPos distribution in camera: %s", src.Data()));
112
113 fHist.Reset();
114 fXY = TVector2();
115 fNum = 0;
116 fTimeLastEffOn = MTime();
117 fConvMm2Deg = geom->GetConvMm2Deg();
118
119 return kTRUE;
120}
121
122// --------------------------------------------------------------------------
123//
124//
125//
126Bool_t MHSrcPosCam::Fill(const MParContainer *par, const Stat_t w)
127{
128 const MSrcPosCam *cam = dynamic_cast<const MSrcPosCam*>(par);
129 if (!cam)
130 {
131 *fLog << err << dbginf << "Got no MSrcPosCam as argument of Fill()..." << endl;
132 return kFALSE;
133 }
134
135 fXY += cam->GetXY();
136 fNum++;
137
138 if (fTimeLastEffOn==MTime())
139 fTimeLastEffOn=*fTimeEffOn;
140
141 if (fTimeLastEffOn == *fTimeEffOn)
142 return kTRUE;
143
144 fXY *= fConvMm2Deg/fNum;
145
146 fHist.Fill(fXY.X(), fXY.Y(), fEffOnTime->GetVal());
147
148 fXY = TVector2();
149 fNum = 0;
150 fTimeLastEffOn = *fTimeEffOn;
151
152 return kTRUE;
153}
154
155// --------------------------------------------------------------------------
156//
157//
158//
159void MHSrcPosCam::Draw(Option_t *)
160{
161 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
162 pad->SetBorderMode(0);
163
164 AppendPad();
165
166 //pad->Divide(2,2);
167
168 gPad->SetLeftMargin(0.25);
169 gPad->SetRightMargin(0.25);
170
171 gPad->SetGridx();
172 gPad->SetGridy();
173
174 MH::SetPalette("glow1");
175 fHist.Draw("colz");
176}
177
Note: See TracBrowser for help on using the repository browser.