source: trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.cc@ 5138

Last change on this file since 5138 was 4528, checked in by rico, 20 years ago
*** empty log message ***
File size: 6.1 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 05/2004 <mailto:jrico@ifae.es>
18!
19! Copyright: MAGIC Software Development, 2000-2004
20!
21!
22\* ======================================================================== */
23
24//////////////////////////////////////////////////////////////////////////////
25//
26// MDisplayHillas
27//
28// Display the camera event of type MCerPhotEvt plus the computed hillas
29// parameters.
30//
31// Input containers (in constructor):
32// MCerPhotEvt
33// MGeomCam
34//
35// Input containers
36// MHillas
37// [MSrcPosCam]
38// [MIslands]
39//
40// Output containers
41// [...]
42//
43//////////////////////////////////////////////////////////////////////////////
44#include <fstream>
45#include <math.h>
46
47#include "TVirtualPad.h"
48#include "TLine.h"
49#include "TEllipse.h"
50
51#include "MLog.h"
52#include "MLogManip.h"
53
54#include "MParList.h"
55#include "MHillasDisplay.h"
56#include "MCerPhotEvt.h"
57#include "MGeomCam.h"
58#include "MHillas.h"
59#include "MHillasSrc.h"
60#include "MNewImagePar.h"
61#include "MSrcPosCam.h"
62#include "MIslands.h"
63
64ClassImp(MHillasDisplay);
65
66using namespace std;
67
68static const TString gsDefName = "MHillasDisplay";
69static const TString gsDefTitle = "Hillas Camera display task";
70
71// -------------------------------------------------------------------------
72//
73// Constructor (see MDisplay documentation for more information)
74//
75MHillasDisplay::MHillasDisplay(MCerPhotEvt* event, MGeomCam* geom, Int_t type, const char* name, const char* title)
76 : MDisplay(event,geom,type), fHillas(NULL), fHillasSrc(NULL), fNewImage(NULL), fSrcPos(NULL), fIslands(NULL)
77{
78 fName = name ? name : gsDefName.Data();
79 fTitle = title ? title : gsDefTitle.Data();
80}
81// -------------------------------------------------------------------------
82//
83// Call for MHillas::PreProcess and look for MHillas and look for the
84// needed containers
85//
86Int_t MHillasDisplay::PreProcess(MParList* pList)
87{
88 if(!MDisplay::PreProcess(pList))
89 return kFALSE;
90
91 // Look for the MHillas container
92 if(!fHillas)
93 fHillas = (MHillas*)pList->FindObject(AddSerialNumber("MHillas"), "MHillas");
94 if(!fHillas)
95 *fLog << warn << "MHillasDisplay::PreProcess Warning: MHillas object not found" << endl;
96 else
97 {
98 gPad->cd(1);
99 Draw();
100 }
101
102 // Look for src dependent hillas parameters container
103 if(!fHillasSrc)
104 fHillasSrc = (MHillasSrc*)pList->FindObject(AddSerialNumber("MHillasSrc"), "MHillasSrc");
105
106
107 // Look for the MNewImagePar container
108 if(!fNewImage)
109 fNewImage = (MNewImagePar*)pList->FindObject(AddSerialNumber("MNewImagePar"), "MNewImagePar");
110 if(!fNewImage)
111 *fLog << warn << "MHillasDisplay::PreProcess Warning: MNewImagePar object not found" << endl;
112
113 // Look for the MSrcPosCam container
114 if(!fSrcPos)
115 fSrcPos = (MSrcPosCam*)pList->FindObject(AddSerialNumber("MSrcPosCam"), "MSrcPosCam");
116 if(!fSrcPos)
117 *fLog << warn << "MHillasDisplay::PreProcess Warning: MSrcPosCam object not found" << endl;
118
119 // Look for the MIslands container
120 if (strlen(fIslName) > 0)
121 fIslands = (MIslands*)pList->FindObject(AddSerialNumber(fIslName));
122 else
123 fIslands = (MIslands*)pList->FindObject(AddSerialNumber("MIslands"));
124 if (!fIslands)
125 *fLog << warn << "MHillasDisplay::PreProcess Warning: MIslands object not found" << endl;
126
127 return kTRUE;
128
129}
130// -------------------------------------------------------------------------
131//
132// Display event AND hillas parameters
133//
134Int_t MHillasDisplay::Process()
135{
136 // draw the hillas parameters
137 if(GetPauseMode())
138 {
139 if(fHillas)
140 fHillas->Print();
141 if(fHillasSrc)
142 fHillasSrc->Print();
143 if(fNewImage)
144 fNewImage->Print();
145 if(fIslands)
146 fIslands->Print();
147 }
148
149 // draw the event
150 if(!MDisplay::Process())
151 return kFALSE;
152 return kTRUE;
153}
154// -------------------------------------------------------------------------
155//
156// Stuff to be painted when canvas will be updated
157//
158void MHillasDisplay::Paint(Option_t* option)
159{
160 const Float_t OffsetW=20.0;
161 const Float_t OffsetL=300.0;
162
163 Float_t meanX = fHillas->GetMeanX();
164 Float_t meanY = fHillas->GetMeanY();
165 Float_t length = fHillas->GetLength();
166 Float_t width = fHillas->GetWidth();
167 Float_t delta = fHillas->GetDelta();
168
169
170 if (length<=0 || width<=0)
171 return;
172
173 // Length line
174 TLine lineL(-(length+OffsetL)*cos(delta) + meanX,
175 -(length+OffsetL)*sin(delta) + meanY,
176 (length+OffsetL)*cos(delta) + meanX,
177 (length+OffsetL)*sin(delta) + meanY);
178
179 lineL.SetLineWidth(1);
180 lineL.SetLineColor(2);
181 lineL.Paint();
182
183 // Width line
184 TLine lineW((width+OffsetW)*sin(delta) + meanX,
185 -(width+OffsetW)*cos(delta) + meanY,
186 -(width+OffsetW)*sin(delta) + meanX,
187 (width+OffsetW)*cos(delta) + meanY);
188
189 lineW.SetLineWidth(1);
190 lineW.SetLineColor(2);
191 lineW.Paint();
192
193 // Coordinate system
194 Float_t xSrc = fSrcPos? fSrcPos->GetX() : 0.;
195 Float_t ySrc = fSrcPos? fSrcPos->GetY() : 0.;
196 Float_t radius = GetGeomCam()->GetMaxRadius();
197 TLine lineX(-radius,ySrc,radius,ySrc);
198 TLine lineY(xSrc,-radius,xSrc,radius);
199 lineX.SetLineWidth(1);
200 lineX.SetLineColor(108);
201 lineY.SetLineWidth(1);
202 lineY.SetLineColor(108);
203 lineX.Paint();
204 lineY.Paint();
205
206 // COG line
207 TLine lineMean(xSrc,ySrc,meanX,meanY);
208 lineMean.SetLineWidth(1);
209 lineMean.SetLineColor(2);
210 lineMean.Paint();
211
212 // Hillas ellipse
213 TEllipse ellipse(meanX,meanY,length,width,0,360,delta*kRad2Deg+180);
214 ellipse.SetLineWidth(2);
215 ellipse.SetLineColor(2);
216 ellipse.Paint();
217}
Note: See TracBrowser for help on using the repository browser.