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

Last change on this file since 4226 was 4222, checked in by rico, 20 years ago
*** empty log message ***
File size: 5.8 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 "MNewImagePar.h"
60#include "MSrcPosCam.h"
61#include "MIslands.h"
62
63ClassImp(MHillasDisplay);
64
65using namespace std;
66
67static const TString gsDefName = "MHillasDisplay";
68static const TString gsDefTitle = "Hillas Camera display task";
69
70// -------------------------------------------------------------------------
71//
72// Constructor (see MDisplay documentation for more information)
73//
74MHillasDisplay::MHillasDisplay(MCerPhotEvt* event, MGeomCam* geom, Int_t type, const char* name, const char* title)
75 : MDisplay(event,geom,type), fHillas(NULL), fNewImage(NULL), fSrcPos(NULL), fIslands(NULL)
76{
77 fName = name ? name : gsDefName.Data();
78 fTitle = title ? title : gsDefTitle.Data();
79}
80// -------------------------------------------------------------------------
81//
82// Call for MHillas::PreProcess and look for MHillas and look for the
83// needed containers
84//
85Int_t MHillasDisplay::PreProcess(MParList* pList)
86{
87 if(!MDisplay::PreProcess(pList))
88 return kFALSE;
89
90 // Look for the MHillas container
91 if(!fHillas)
92 fHillas = (MHillas*)pList->FindObject(AddSerialNumber("MHillas"), "MHillas");
93 if(!fHillas)
94 *fLog << warn << "MHillasDisplay::PreProcess Warning: MHillas object not found" << endl;
95 else
96 {
97 gPad->cd(1);
98 Draw();
99 }
100
101 // Look for the MNewImagePar container
102 if(!fNewImage)
103 fNewImage = (MNewImagePar*)pList->FindObject(AddSerialNumber("MNewImagePar"), "MNewImagePar");
104 if(!fNewImage)
105 *fLog << warn << "MHillasDisplay::PreProcess Warning: MNewImagePar object not found" << endl;
106
107 // Look for the MSrcPosCam container
108 if(!fSrcPos)
109 fSrcPos = (MSrcPosCam*)pList->FindObject(AddSerialNumber("MSrcPosCam"), "MSrcPosCam");
110 if(!fSrcPos)
111 *fLog << warn << "MHillasDisplay::PreProcess Warning: MSrcPosCam object not found" << endl;
112
113 // Look for the MIslands container
114 if (strlen(fIslName) > 0)
115 fIslands = (MIslands*)pList->FindObject(AddSerialNumber(fIslName));
116 else
117 fIslands = (MIslands*)pList->FindObject(AddSerialNumber("MIslands"));
118 if (!fIslands)
119 *fLog << warn << "MHillasDisplay::PreProcess Warning: MIslands object not found" << endl;
120
121 return kTRUE;
122
123}
124// -------------------------------------------------------------------------
125//
126// Display event AND hillas parameters
127//
128Int_t MHillasDisplay::Process()
129{
130 // draw the hillas parameters
131 if(GetPauseMode())
132 {
133 if(fHillas)
134 fHillas->Print();
135 if(fNewImage)
136 fNewImage->Print();
137 if(fIslands)
138 fIslands->Print();
139 }
140
141 // draw the event
142 if(!MDisplay::Process())
143 return kFALSE;
144 return kTRUE;
145}
146// -------------------------------------------------------------------------
147//
148// Stuff to be painted when canvas will be updated
149//
150void MHillasDisplay::Paint(Option_t* option)
151{
152 const Float_t OffsetW=20.0;
153 const Float_t OffsetL=300.0;
154
155 Float_t meanX = fHillas->GetMeanX();
156 Float_t meanY = fHillas->GetMeanY();
157 Float_t length = fHillas->GetLength();
158 Float_t width = fHillas->GetWidth();
159 Float_t delta = fHillas->GetDelta();
160
161
162 if (length<=0 || width<=0)
163 return;
164
165 // Length line
166 TLine lineL(-(length+OffsetL)*cos(delta) + meanX,
167 -(length+OffsetL)*sin(delta) + meanY,
168 (length+OffsetL)*cos(delta) + meanX,
169 (length+OffsetL)*sin(delta) + meanY);
170
171 lineL.SetLineWidth(1);
172 lineL.SetLineColor(2);
173 lineL.Paint();
174
175 // Width line
176 TLine lineW((width+OffsetW)*sin(delta) + meanX,
177 -(width+OffsetW)*cos(delta) + meanY,
178 -(width+OffsetW)*sin(delta) + meanX,
179 (width+OffsetW)*cos(delta) + meanY);
180
181 lineW.SetLineWidth(1);
182 lineW.SetLineColor(2);
183 lineW.Paint();
184
185 // Coordinate system
186 Float_t xSrc = fSrcPos? fSrcPos->GetX() : 0.;
187 Float_t ySrc = fSrcPos? fSrcPos->GetY() : 0.;
188 Float_t radius = GetGeomCam()->GetMaxRadius();
189 TLine lineX(-radius,ySrc,radius,ySrc);
190 TLine lineY(xSrc,-radius,xSrc,radius);
191 lineX.SetLineWidth(1);
192 lineX.SetLineColor(108);
193 lineY.SetLineWidth(1);
194 lineY.SetLineColor(108);
195 lineX.Paint();
196 lineY.Paint();
197
198 // COG line
199 TLine lineMean(xSrc,ySrc,meanX,meanY);
200 lineMean.SetLineWidth(1);
201 lineMean.SetLineColor(2);
202 lineMean.Paint();
203
204 // Hillas ellipse
205 TEllipse ellipse(meanX,meanY,length,width,0,360,delta*kRad2Deg+180);
206 ellipse.SetLineWidth(2);
207 ellipse.SetLineColor(2);
208 ellipse.Paint();
209}
Note: See TracBrowser for help on using the repository browser.