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

Last change on this file since 4702 was 4702, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 7.7 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 kEvtIdxMax:
155 fHist->SetName("Max Slice Idx");
156 fHist->SetYTitle("t [slice id]");
157 fHist->SetPrettyPalette();
158 break;
159 case kEvtArrTime:
160 fHist->SetName("Arrival Time");
161 fHist->SetYTitle("t [slice id]");
162 fHist->SetPrettyPalette();
163 break;
164 case kEvtTrigPix:
165 fHist->SetName("Triggered pix");
166 fHist->SetYTitle("ON/OFF");
167 fHist->SetPrettyPalette();
168 break;
169 case kEvtIslandIndex:
170 fHist->SetName("Island Index");
171 fHist->SetYTitle("Index");
172 fHist->SetPrettyPalette();
173 break;
174 }
175
176 return kTRUE;
177}
178
179Bool_t MHEvent::Fill(const MParContainer *par, const Stat_t weight)
180{
181 if (fHist->IsFreezed())
182 return kTRUE;
183
184 if (!par)
185 return kFALSE;
186
187 const MCamEvent *event = dynamic_cast<const MCamEvent*>(par);
188 if (!event)
189 {
190 *fLog << err << par->GetDescriptor() << " doesn't inherit from MCamEvent... abort." << endl;
191 return kFALSE;
192 }
193
194 if (fRawEvtData)
195 fRawEvtData->Copy(*fClone);
196
197 switch (fType)
198 {
199 case kEvtSignalRaw: // Get Content without pixel-size scaling
200 fHist->SetCamContent(*event, 3);
201 break;
202 case kEvtSignalDensity:
203 fHist->SetCamContent(*event, 0);
204 break;
205 case kEvtPedestal:
206 fHist->SetCamContent(*event, 0);
207 break;
208 case kEvtPedestalRMS:
209 fHist->SetCamContent(*event, 1);
210 break;
211 case kEvtRelativeSignal:
212 fHist->SetCamContent(*event, 0);
213 break;
214 case kEvtCleaningLevels:
215 {
216 TArrayF lvl(2);
217 lvl[0] = fImgCleanStd->GetCleanLvl2();
218 lvl[1] = fImgCleanStd->GetCleanLvl1();
219 fHist->SetCamContent(*event, 0);
220 fHist->SetLevels(lvl);
221 }
222 break;
223 case kEvtIdxMax:
224 fHist->SetCamContent(*event, 5);
225 break;
226 case kEvtArrTime:
227 fHist->SetCamContent(*event, 0);
228 break;
229 case kEvtTrigPix:
230 fHist->SetCamContent(*event, 0);
231 break;
232 case kEvtIslandIndex:
233 fHist->SetCamContent(*event, 5);
234 break;
235 }
236
237 TString s;
238 if (fRawEvtHeader)
239 {
240 s += "Event #";
241 s += fRawEvtHeader->GetDAQEvtNumber();
242 }
243 if (fRawEvtHeader && fRawRunHeader)
244 s += " of ";
245
246 if (fRawRunHeader)
247 {
248 s += "Run #";
249 s += fRawRunHeader->GetRunNumber();
250 }
251
252 if (fMcEvt)
253 {
254 TString txt("#splitline{");
255
256 txt += fMcEvt->GetParticleName();
257 txt += " ";
258
259 s.Insert(0, txt);
260
261 s += "}{ E=";
262
263 s+= fMcEvt->GetEnergyStr();
264
265 s += " r=";
266 s += (int)(fMcEvt->GetImpact()/100+.5);
267 s += "m Zd=";
268 s += (int)(fMcEvt->GetTheta()*180/TMath::Pi()+.5);
269 s += "\\circ ";
270 if (fMcEvt->GetPhotElfromShower()>=10000)
271 s += Form("%dk", (Int_t)(fMcEvt->GetPhotElfromShower()/1000.+.5));
272 else
273 if (fMcEvt->GetPhotElfromShower()>=1000)
274 s += Form("%.1fk", fMcEvt->GetPhotElfromShower()/1000.);
275 else
276 s += fMcEvt->GetPhotElfromShower();
277 s += "PhEl}";
278 }
279
280 gPad=NULL;
281 fHist->SetTitle(s);
282
283 return kTRUE;
284}
285
286void MHEvent::Draw(Option_t *)
287{
288 if (!fHist)
289 {
290 *fLog << warn << "MHEvent::Draw - fHist==NULL not initialized." << endl;
291 return;
292 }
293
294 if (!gPad)
295 MakeDefCanvas(this);
296 fHist->Draw();
297}
Note: See TracBrowser for help on using the repository browser.