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

Last change on this file since 3227 was 3142, checked in by tbretz, 22 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
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 kEvtSignal:
125 fHist->SetName("Signal");
126 fHist->SetYTitle("S [au]");
127 break;
128 case kEvtPedestal:
129 fHist->SetName("Pedestal");
130 fHist->SetYTitle("P [au]");
131 break;
132 case kEvtPedestalRMS:
133 fHist->SetName("Pedestal RMS");
134 fHist->SetYTitle("\\sigma_{P} [au]");
135 break;
136 case kEvtRelativeSignal:
137 fHist->SetName("Signal/PedRMS");
138 fHist->SetYTitle("S/P_{rms}");
139 break;
140 case kEvtCleaningLevels:
141 if (!fImgCleanStd)
142 {
143 *fLog << err << "MImgCleanStd not found... aborting." << endl;
144 return kFALSE;
145 }
146 fHist->SetName("CleanLevels");
147 fHist->SetYTitle("L");
148 break;
149 case kEvtIdxMax:
150 fHist->SetName("Max Slice Idx");
151 fHist->SetYTitle("t [slice id]");
152 fHist->SetPrettyPalette();
153 break;
154 case kEvtArrTime:
155 fHist->SetName("Arrival Time");
156 fHist->SetYTitle("t [slice id]");
157 fHist->SetPrettyPalette();
158 break;
159 }
160
161 return kTRUE;
162}
163
164Bool_t MHEvent::Fill(const MParContainer *par, const Stat_t weight)
165{
166 if (fHist->IsFreezed())
167 return kTRUE;
168
169 if (!par)
170 return kFALSE;
171
172 const MCamEvent *event = dynamic_cast<const MCamEvent*>(par);
173 if (!event)
174 {
175 *fLog << err << par->GetDescriptor() << " doesn't inherit from MCamEvent... abort." << endl;
176 return kFALSE;
177 }
178
179 if (fRawEvtData)
180 fRawEvtData->Copy(*fClone);
181
182 switch (fType)
183 {
184 case kEvtSignal: // Get NumPhotons without pixel-size scaling
185 // fHist->SetCamContent(*event, 3);
186 // break;
187 case kEvtPedestal:
188 fHist->SetCamContent(*event, 0);
189 break;
190 case kEvtPedestalRMS:
191 fHist->SetCamContent(*event, 1);
192 break;
193 case kEvtRelativeSignal:
194 fHist->SetCamContent(*event, 0);
195 break;
196 case kEvtCleaningLevels:
197 {
198 TArrayF lvl(2);
199 lvl[0] = fImgCleanStd->GetCleanLvl2();
200 lvl[1] = fImgCleanStd->GetCleanLvl1();
201 fHist->SetCamContent(*event, 0);
202 fHist->SetLevels(lvl);
203 }
204 break;
205 case kEvtIdxMax:
206 fHist->SetCamContent(*event, 5);
207 break;
208 case kEvtArrTime:
209 fHist->SetCamContent(*event, 0);
210 break;
211 }
212
213 TString s;
214 if (fRawEvtHeader)
215 {
216 s += "Event #";
217 s += fRawEvtHeader->GetDAQEvtNumber();
218 }
219 if (fRawEvtHeader && fRawRunHeader)
220 s += " of ";
221
222 if (fRawRunHeader)
223 {
224 s += "Run #";
225 s += fRawRunHeader->GetRunNumber();
226 }
227
228 if (fMcEvt)
229 {
230 TString txt("#splitline{");
231
232 switch (fMcEvt->GetPartId())
233 {
234 case kGAMMA:
235 txt += "Gamma: ";
236 break;
237 case kPROTON:
238 txt += "Proton: ";
239 break;
240 case kHELIUM:
241 txt += "Helium: ";
242 break;
243 default:
244 s += "Particle Id#";
245 s += fMcEvt->GetPartId();
246 s += ": ";
247 }
248
249 s.Insert(0, txt);
250
251 s += "}{ E=";
252
253 if (fMcEvt->GetEnergy()>1000)
254 s += Form("%.1fTeV", fMcEvt->GetEnergy()/1000);
255 else
256 if (fMcEvt->GetEnergy()>10)
257 s += Form("%dGeV", (Int_t)(fMcEvt->GetEnergy()+.5));
258 else
259 if (fMcEvt->GetEnergy()>1)
260 s += Form("%.1fGeV", fMcEvt->GetEnergy());
261 else
262 s += Form("%dMeV", (Int_t)(fMcEvt->GetEnergy()*1000+.5));
263
264 s += " r=";
265 s += (int)(fMcEvt->GetImpact()/100+.5);
266 s += "m Zd=";
267 s += (int)(fMcEvt->GetTheta()*180/TMath::Pi()+.5);
268 s += "\\circ ";
269 if (fMcEvt->GetPhotElfromShower()>=10000)
270 s += Form("%dk", (Int_t)(fMcEvt->GetPhotElfromShower()/1000.+.5));
271 else
272 if (fMcEvt->GetPhotElfromShower()>=1000)
273 s += Form("%.1fk", fMcEvt->GetPhotElfromShower()/1000.);
274 else
275 s += fMcEvt->GetPhotElfromShower();
276 s += "PhEl}";
277 }
278
279 gPad=NULL;
280 fHist->SetTitle(s);
281
282 return kTRUE;
283}
284
285void MHEvent::Draw(Option_t *)
286{
287 if (!fHist)
288 {
289 *fLog << warn << "MHEvent::Draw - fHist==NULL not initialized." << endl;
290 return;
291 }
292
293 if (!gPad)
294 MakeDefCanvas(this);
295 fHist->Draw();
296}
Note: See TracBrowser for help on using the repository browser.