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

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