source: tags/Mars-V1.1/mhist/MHEvent.cc

Last change on this file was 8434, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 9.2 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
193Bool_t MHEvent::Fill(const MParContainer *par, const Stat_t weight)
194{
195 if (fHist->IsFreezed())
196 return kTRUE;
197
198 if (!par)
199 return kFALSE;
200
201 const MCamEvent *event = dynamic_cast<const MCamEvent*>(par);
202 if (!event)
203 {
204 *fLog << err << par->GetDescriptor() << " doesn't inherit from MCamEvent... abort." << endl;
205 return kFALSE;
206 }
207
208 if (fRawEvtData)
209 fRawEvtData->Copy(*fClone);
210
211 switch (fType)
212 {
213 case kEvtSignalRaw: // Get Content without pixel-size scaling
214 fHist->SetCamContent(*event, 3);
215 break;
216 case kEvtSignalDensity:
217 fHist->SetCamContent(*event, 0);
218 break;
219 case kEvtPedestal:
220 fHist->SetCamContent(*event, 0);
221 break;
222 case kEvtPedestalRMS:
223 fHist->SetCamContent(*event, 2);
224 break;
225 case kEvtPedPhot:
226 fHist->SetCamContent(*event, 4);
227 break;
228 case kEvtPedPhotRMS:
229 fHist->SetCamContent(*event, 5);
230 break;
231 case kEvtCleaningLevels:
232 {
233 TArrayF lvl(2);
234 lvl[0] = fImgCleanStd->GetCleanLvl2();
235 lvl[1] = fImgCleanStd->GetCleanLvl1();
236 fHist->SetCamContent(*event, 0);
237 fHist->SetLevels(lvl);
238 }
239 break;
240 case kEvtCleaningData:
241 fHist->SetCamContent(*event, 0);
242 break;
243// case kEvtIdxMax:
244// fHist->SetCamContent(*event, 3/*5*/);
245// break;
246 case kEvtArrTime:
247 fHist->SetCamContent(*event, 6);
248 break;
249 case kEvtArrTimeCleaned:
250 fHist->SetCamContent(*event, 8);
251 break;
252 case kEvtTrigPix:
253 fHist->SetCamContent(*event, 0);
254 break;
255 case kEvtIslandIndex:
256 fHist->SetCamContent(*event, 5);
257 break;
258 default:
259 *fLog << "ERROR - Case " << (int)fType << " not implemented..." << endl;
260 }
261
262 TString s;
263 if (fRawEvtHeader)
264 {
265 s += "Event #";
266 s += fRawEvtHeader->GetDAQEvtNumber();
267 }
268 if (fRawEvtHeader && fRawRunHeader)
269 s += " of ";
270
271 if (fRawRunHeader)
272 {
273 s += "Run #";
274 s += fRawRunHeader->GetRunNumber();
275 }
276 if (fTime)
277 {
278 s += " (";
279 s += fTime->GetString();
280 s += ")";
281 }
282
283 if (fMcEvt)
284 s = fMcEvt->GetDescription(s);
285
286 gPad=NULL;
287 fHist->SetTitle(s);
288
289 return kTRUE;
290}
291
292void MHEvent::Paint(Option_t *)
293{
294 TVirtualPad *pad = gPad;
295
296 pad->GetPad(2)->cd(1);
297 if (gPad->FindObject(Form("Proj_%p", this)))
298 {
299 TH1 *h=fHist->Projection(Form("Proj_%p", this));
300 if (h->GetMaximum()>0)
301 gPad->SetLogy();
302 }
303
304 pad->GetPad(2)->cd(2);
305 if (gPad->FindObject(Form("ProfR_%p", this)))
306 fHist->RadialProfile(Form("ProfR_%p", this));
307
308 pad->GetPad(2)->cd(3);
309 if (gPad->FindObject(Form("ProfA_%p", this)))
310 fHist->AzimuthProfile(Form("ProfA_%p", this));
311}
312
313void MHEvent::Draw(Option_t *)
314{
315 if (!fHist)
316 {
317 *fLog << warn << "MHEvent::Draw - fHist==NULL not initialized." << endl;
318 return;
319 }
320
321 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
322 pad->SetBorderMode(0);
323
324 AppendPad();
325
326 pad->Divide(2,1);
327
328 pad->cd(1);
329 gPad->SetPad(0.01, 0.01, 0.75, 0.99);
330 gPad->SetBorderMode(0);
331 fHist->Draw();
332
333 pad->cd(2);
334 gPad->SetPad(0.75, 0.01, 0.99, 0.99);
335 gPad->SetBorderMode(0);
336 gPad->Divide(1,3);
337
338 pad = gPad;
339
340 pad->cd(1);
341 gPad->SetBorderMode(0);
342
343 TH1 *h = fHist->Projection(Form("Proj_%p", this), 50);
344 h->SetTitle("Projection");
345 h->SetBit(kCanDelete);
346 h->Draw();
347
348 pad->cd(2);
349 gPad->SetBorderMode(0);
350
351 h = (TH1*)fHist->RadialProfile(Form("ProfR_%p", this), 20);
352 h->SetTitle("Radial Profile");
353 h->SetBit(kCanDelete|TH1::kNoStats);
354 h->Draw();
355
356 pad->cd(3);
357 gPad->SetBorderMode(0);
358 h = (TH1*)fHist->AzimuthProfile(Form("ProfA_%p", this), 30);
359 h->SetTitle("Azimuth Profile");
360 h->SetBit(kCanDelete|TH1::kNoStats);
361 h->Draw();
362}
Note: See TracBrowser for help on using the repository browser.