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

Last change on this file since 4787 was 4716, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 7.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!
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 "MCerPhotEvt.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{
75 fName = "MHEvent";
76 fTitle = "Single Event display task";
77
78 fClone = new MRawEvtData("MHEventData");
79}
80
81// --------------------------------------------------------------------------
82//
83MHEvent::~MHEvent()
84{
85 if (fHist)
86 delete fHist;
87
88 delete fClone;
89}
90
91Bool_t MHEvent::SetupFill(const MParList *plist)
92{
93 MTaskList *tlist = (MTaskList*)plist->FindObject("MTaskList");
94
95 fImgCleanStd = tlist ? (MImgCleanStd*)tlist->FindObject("MImgCleanStd") : NULL;
96 fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
97
98 fRawEvtData = (MRawEvtData*)plist->FindObject("MRawEvtData");
99 if (!fRawEvtData)
100 *fLog << warn << "MRawEvtData not found..." << endl;
101
102 fRawRunHeader = (MRawRunHeader*)plist->FindObject("MRawRunHeader");
103 if (!fRawRunHeader)
104 *fLog << warn << dbginf << "MRawRunHeader not found..." << endl;
105
106 fRawEvtHeader = (MRawEvtHeader*)plist->FindObject("MRawEvtHeader");
107 if (!fRawEvtHeader)
108 *fLog << warn << dbginf << "MRawEvtHeader not found..." << endl;
109
110 MGeomCam *cam = (MGeomCam*)plist->FindObject("MGeomCam");
111 if (!cam)
112 {
113 *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
114 return kFALSE;
115 }
116
117 if (fHist)
118 delete (fHist);
119
120 fHist = new MHCamera(*cam);
121 fHist->AddNotify(fClone);
122
123 switch (fType)
124 {
125 case kEvtSignalRaw:
126 fHist->SetName("Signal (raw)");
127 fHist->SetYTitle("S [au]");
128 break;
129 case kEvtSignalDensity:
130 fHist->SetName("Signal density");
131 fHist->SetYTitle("S [au]");
132 break;
133 case kEvtPedestal:
134 fHist->SetName("Pedestal");
135 fHist->SetYTitle("P [au]");
136 break;
137 case kEvtPedestalRMS:
138 fHist->SetName("Pedestal RMS");
139 fHist->SetYTitle("\\sigma_{P} [au]");
140 break;
141 case kEvtRelativeSignal:
142 fHist->SetName("Signal/PedRMS");
143 fHist->SetYTitle("S/P_{rms}");
144 break;
145 case kEvtCleaningLevels:
146 if (!fImgCleanStd)
147 {
148 *fLog << err << "MImgCleanStd not found... aborting." << endl;
149 return kFALSE;
150 }
151 fHist->SetName("CleanLevels");
152 fHist->SetYTitle("L");
153 break;
154 case kEvtCleaningData:
155 fHist->SetName("CleanData");
156 fHist->SetYTitle("L");
157 break;
158 case kEvtIdxMax:
159 fHist->SetName("Max Slice Idx");
160 fHist->SetYTitle("t [slice id]");
161 fHist->SetPrettyPalette();
162 break;
163 case kEvtArrTime:
164 fHist->SetName("Arrival Time");
165 fHist->SetYTitle("t [slice id]");
166 fHist->SetPrettyPalette();
167 break;
168 case kEvtTrigPix:
169 fHist->SetName("Triggered pix");
170 fHist->SetYTitle("ON/OFF");
171 fHist->SetPrettyPalette();
172 break;
173 case kEvtIslandIndex:
174 fHist->SetName("Island Index");
175 fHist->SetYTitle("Index");
176 fHist->SetPrettyPalette();
177 break;
178 }
179
180 return kTRUE;
181}
182
183Bool_t MHEvent::Fill(const MParContainer *par, const Stat_t weight)
184{
185 if (fHist->IsFreezed())
186 return kTRUE;
187
188 if (!par)
189 return kFALSE;
190
191 const MCamEvent *event = dynamic_cast<const MCamEvent*>(par);
192 if (!event)
193 {
194 *fLog << err << par->GetDescriptor() << " doesn't inherit from MCamEvent... abort." << endl;
195 return kFALSE;
196 }
197
198 if (fRawEvtData)
199 fRawEvtData->Copy(*fClone);
200
201 switch (fType)
202 {
203 case kEvtSignalRaw: // Get Content without pixel-size scaling
204 fHist->SetCamContent(*event, 3);
205 break;
206 case kEvtSignalDensity:
207 fHist->SetCamContent(*event, 0);
208 break;
209 case kEvtPedestal:
210 fHist->SetCamContent(*event, 0);
211 break;
212 case kEvtPedestalRMS:
213 fHist->SetCamContent(*event, 1);
214 break;
215 case kEvtRelativeSignal:
216 fHist->SetCamContent(*event, 0);
217 break;
218 case kEvtCleaningLevels:
219 {
220 TArrayF lvl(2);
221 lvl[0] = fImgCleanStd->GetCleanLvl2();
222 lvl[1] = fImgCleanStd->GetCleanLvl1();
223 fHist->SetCamContent(*event, 0);
224 fHist->SetLevels(lvl);
225 }
226 break;
227 case kEvtCleaningData:
228 fHist->SetCamContent(*event, 0);
229 break;
230 case kEvtIdxMax:
231 fHist->SetCamContent(*event, 5);
232 break;
233 case kEvtArrTime:
234 fHist->SetCamContent(*event, 0);
235 break;
236 case kEvtTrigPix:
237 fHist->SetCamContent(*event, 0);
238 break;
239 case kEvtIslandIndex:
240 fHist->SetCamContent(*event, 5);
241 break;
242 }
243
244 TString s;
245 if (fRawEvtHeader)
246 {
247 s += "Event #";
248 s += fRawEvtHeader->GetDAQEvtNumber();
249 }
250 if (fRawEvtHeader && fRawRunHeader)
251 s += " of ";
252
253 if (fRawRunHeader)
254 {
255 s += "Run #";
256 s += fRawRunHeader->GetRunNumber();
257 }
258
259 if (fMcEvt)
260 {
261 TString txt("#splitline{");
262
263 txt += fMcEvt->GetParticleName();
264 txt += " ";
265
266 s.Insert(0, txt);
267
268 s += "}{ E=";
269
270 s+= fMcEvt->GetEnergyStr();
271
272 s += " r=";
273 s += (int)(fMcEvt->GetImpact()/100+.5);
274 s += "m Zd=";
275 s += (int)(fMcEvt->GetTheta()*180/TMath::Pi()+.5);
276 s += "\\circ ";
277 if (fMcEvt->GetPhotElfromShower()>=10000)
278 s += Form("%dk", (Int_t)(fMcEvt->GetPhotElfromShower()/1000.+.5));
279 else
280 if (fMcEvt->GetPhotElfromShower()>=1000)
281 s += Form("%.1fk", fMcEvt->GetPhotElfromShower()/1000.);
282 else
283 s += fMcEvt->GetPhotElfromShower();
284 s += "PhEl}";
285 }
286
287 gPad=NULL;
288 fHist->SetTitle(s);
289
290 return kTRUE;
291}
292
293void MHEvent::Draw(Option_t *)
294{
295 if (!fHist)
296 {
297 *fLog << warn << "MHEvent::Draw - fHist==NULL not initialized." << endl;
298 return;
299 }
300
301 if (!gPad)
302 MakeDefCanvas(this);
303 fHist->Draw();
304}
Note: See TracBrowser for help on using the repository browser.