source: trunk/MagicSoft/Mars/mhist/MHEvent.cc@ 9214

Last change on this file since 9214 was 9153, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 9.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!
18! Author(s): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MHEvent
28//
29// Display a single event in a canvas with as many informations as
30// possible, such as event number, run number, ...
31//
32// WARNING: This class is not yet ready!
33//
34// Input Containers:
35// MGeomCam
36// [MTaskList]
37// [MImgCleanStd]
38// [MRawEvtData]
39// [MRawRunHeader]
40// [MRawEvtHeader]
41//
42// Output Containers:
43// -/-
44//
45//////////////////////////////////////////////////////////////////////////////
46#include "MHEvent.h"
47
48#include <TStyle.h>
49#include <TCanvas.h>
50
51#include "MLog.h"
52#include "MLogManip.h"
53
54#include "MMcEvt.hxx"
55#include "MMcTrig.hxx"
56
57#include "MHCamera.h"
58#include "MParList.h"
59#include "MTaskList.h"
60#include "MParList.h"
61#include "MSignalCam.h"
62#include "MRawEvtHeader.h"
63#include "MRawRunHeader.h"
64#include "MRawEvtData.h"
65#include "MImgCleanStd.h"
66
67ClassImp(MHEvent);
68
69using namespace std;
70
71// --------------------------------------------------------------------------
72//
73MHEvent::MHEvent(EventType_t type) : fHist(NULL), fType(type),
74 fMinimum(-1111), fMaximum(-1111)
75{
76 fName = "MHEvent";
77 fTitle = "Single Event display task";
78
79 fClone = new MRawEvtData("MHEventData");
80}
81
82// --------------------------------------------------------------------------
83//
84MHEvent::~MHEvent()
85{
86 if (fHist)
87 delete fHist;
88
89 delete fClone;
90}
91
92Bool_t MHEvent::SetupFill(const MParList *plist)
93{
94 MTaskList *tlist = (MTaskList*)plist->FindObject("MTaskList");
95
96 fImgCleanStd = tlist ? (MImgCleanStd*)tlist->FindObject("MImgCleanStd") : NULL;
97 fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
98 fTime = (MTime*)plist->FindObject("MTime");
99
100 fRawEvtData = (MRawEvtData*)plist->FindObject("MRawEvtData");
101 if (!fRawEvtData)
102 *fLog << warn << "MRawEvtData not found..." << endl;
103
104 fRawRunHeader = (MRawRunHeader*)plist->FindObject("MRawRunHeader");
105 if (!fRawRunHeader)
106 *fLog << warn << dbginf << "MRawRunHeader not found..." << endl;
107
108 fRawEvtHeader = (MRawEvtHeader*)plist->FindObject("MRawEvtHeader");
109 if (!fRawEvtHeader)
110 *fLog << warn << dbginf << "MRawEvtHeader not found..." << endl;
111
112 MGeomCam *cam = (MGeomCam*)plist->FindObject("MGeomCam");
113 if (!cam)
114 {
115 *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
116 return kFALSE;
117 }
118
119 if (fHist)
120 delete (fHist);
121
122 fHist = new MHCamera(*cam);
123 fHist->AddNotify(fClone);
124
125 fHist->SetMinimum(fMinimum);
126 fHist->SetMaximum(fMaximum);
127
128 switch (fType)
129 {
130 case kEvtSignalRaw:
131 fHist->SetName("Signal (raw)");
132 fHist->SetYTitle("S [au]");
133 break;
134 case kEvtSignalDensity:
135 fHist->SetName("Signal density");
136 fHist->SetYTitle("S [au]");
137 break;
138 case kEvtPedestal:
139 fHist->SetName("Pedestal");
140 fHist->SetYTitle("P [au]");
141 break;
142 case kEvtPedestalRMS:
143 fHist->SetName("Pedestal RMS");
144 fHist->SetYTitle("\\sigma_{P} [au]");
145 break;
146 case kEvtPedPhot:
147 fHist->SetName("Pedestal");
148 fHist->SetYTitle("P [\\gamma]");
149 break;
150 case kEvtPedPhotRMS:
151 fHist->SetName("Pedestal RMS");
152 fHist->SetYTitle("\\sigma_{P} [\\gamma]");
153 break;
154 case kEvtCleaningLevels:
155 if (!fImgCleanStd)
156 {
157 *fLog << err << "MImgCleanStd not found... aborting." << endl;
158 return kFALSE;
159 }
160 fHist->SetName("CleanLevels");
161 fHist->SetYTitle("L");
162 break;
163 case kEvtCleaningData:
164 fHist->SetName("CleanData");
165 fHist->SetYTitle("L");
166 break;
167 case kEvtIdxMax:
168 fHist->SetName("Max Slice Idx");
169 fHist->SetYTitle("t [slice id]");
170 fHist->SetPrettyPalette();
171 break;
172 case kEvtArrTime:
173 case kEvtArrTimeCleaned:
174 fHist->SetName("Arrival Time");
175 fHist->SetYTitle("t [slice id]");
176 fHist->SetPrettyPalette();
177 break;
178 case kEvtTrigPix:
179 fHist->SetName("Triggered pix");
180 fHist->SetYTitle("ON/OFF");
181 fHist->SetPrettyPalette();
182 break;
183 case kEvtIslandIndex:
184 fHist->SetName("Island Index");
185 fHist->SetYTitle("Index");
186 fHist->SetPrettyPalette();
187 break;
188 }
189
190 return kTRUE;
191}
192
193Int_t MHEvent::Fill(const MParContainer *par, const Stat_t weight)
194{
195 if (fHist->IsFreezed())
196 return kTRUE;
197
198 if (!par)
199 {
200 *fLog << err << "ERROR - par==NULL... abort." << endl;
201 return kERROR;
202 }
203
204 const MCamEvent *event = dynamic_cast<const MCamEvent*>(par);
205 if (!event)
206 {
207 *fLog << err << par->GetDescriptor() << " doesn't inherit from MCamEvent... abort." << endl;
208 return kERROR;
209 }
210
211 if (fRawEvtData)
212 fRawEvtData->Copy(*fClone);
213
214 switch (fType)
215 {
216 case kEvtSignalRaw: // Get Content without pixel-size scaling
217 fHist->SetCamContent(*event, 3);
218 break;
219 case kEvtSignalDensity:
220 fHist->SetCamContent(*event, 0);
221 break;
222 case kEvtPedestal:
223 fHist->SetCamContent(*event, 0);
224 break;
225 case kEvtPedestalRMS:
226 fHist->SetCamContent(*event, 2);
227 break;
228 case kEvtPedPhot:
229 fHist->SetCamContent(*event, 4);
230 break;
231 case kEvtPedPhotRMS:
232 fHist->SetCamContent(*event, 5);
233 break;
234 case kEvtCleaningLevels:
235 {
236 TArrayF lvl(2);
237 lvl[0] = fImgCleanStd->GetCleanLvl2();
238 lvl[1] = fImgCleanStd->GetCleanLvl1();
239 fHist->SetCamContent(*event, 0);
240 fHist->SetLevels(lvl);
241 }
242 break;
243 case kEvtCleaningData:
244 fHist->SetCamContent(*event, 0);
245 break;
246// case kEvtIdxMax:
247// fHist->SetCamContent(*event, 3/*5*/);
248// break;
249 case kEvtArrTime:
250 fHist->SetCamContent(*event, 6);
251 break;
252 case kEvtArrTimeCleaned:
253 fHist->SetCamContent(*event, 8);
254 break;
255 case kEvtTrigPix:
256 fHist->SetCamContent(*event, 0);
257 break;
258 case kEvtIslandIndex:
259 fHist->SetCamContent(*event, 5);
260 break;
261 default:
262 *fLog << "ERROR - Case " << (int)fType << " not implemented..." << endl;
263 }
264
265 TString s;
266 if (fRawEvtHeader)
267 {
268 s += "Event #";
269 s += fRawEvtHeader->GetDAQEvtNumber();
270 }
271
272 if (fRawEvtHeader && fRawRunHeader)
273 s += " of ";
274
275 if (fRawRunHeader)
276 s += fRawRunHeader->GetStringID();
277
278 if (fTime)
279 {
280 s += " (";
281 s += fTime->GetString();
282 s += ")";
283 }
284
285 if (fMcEvt)
286 s = fMcEvt->GetDescription(s);
287
288 gPad=NULL;
289 fHist->SetTitle(s);
290
291 return kTRUE;
292}
293
294void MHEvent::Paint(Option_t *)
295{
296 TVirtualPad *pad = gPad;
297
298 pad->GetPad(2)->cd(1);
299 if (gPad->FindObject("Proj"))
300 {
301 TH1 *h=fHist->Projection("Proj");
302 if (h->GetMaximum()>0)
303 gPad->SetLogy();
304 }
305
306 pad->GetPad(2)->cd(2);
307 if (gPad->FindObject("ProfRad"))
308 fHist->RadialProfile("ProfRad");
309
310 pad->GetPad(2)->cd(3);
311 if (gPad->FindObject("ProfAz"))
312 fHist->AzimuthProfile("ProfAz");
313}
314
315void MHEvent::Draw(Option_t *)
316{
317 if (!fHist)
318 {
319 *fLog << warn << "MHEvent::Draw - fHist==NULL not initialized." << endl;
320 return;
321 }
322
323 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
324 pad->SetBorderMode(0);
325
326 AppendPad();
327
328 pad->Divide(2,1);
329
330 pad->cd(1);
331 gPad->SetPad(0.01, 0.01, 0.75, 0.99);
332 gPad->SetBorderMode(0);
333 fHist->Draw();
334
335 pad->cd(2);
336 gPad->SetPad(0.75, 0.01, 0.99, 0.99);
337 gPad->SetBorderMode(0);
338 gPad->Divide(1,3);
339
340 pad = gPad;
341
342 pad->cd(1);
343 gPad->SetBorderMode(0);
344
345 TH1 *h = fHist->Projection("Proj", 50);
346 h->SetTitle("Projection");
347 h->SetBit(kCanDelete);
348 h->Draw();
349
350 pad->cd(2);
351 gPad->SetBorderMode(0);
352
353 h = (TH1*)fHist->RadialProfile("ProfRad", 20);
354 h->SetTitle("Radial Profile");
355 h->SetBit(kCanDelete|TH1::kNoStats);
356 h->Draw();
357
358 pad->cd(3);
359 gPad->SetBorderMode(0);
360 h = (TH1*)fHist->AzimuthProfile("ProfAz", 30);
361 h->SetTitle("Azimuth Profile");
362 h->SetBit(kCanDelete|TH1::kNoStats);
363 h->Draw();
364}
Note: See TracBrowser for help on using the repository browser.