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

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