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

Last change on this file since 3002 was 2979, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 7.6 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:
185 case kEvtPedestal:
186 fHist->SetCamContent(*event, 0);
187 break;
188 case kEvtPedestalRMS:
189 fHist->SetCamContent(*event, 1);
190 break;
191 case kEvtRelativeSignal:
192 fHist->SetCamContent(*event, 0);
193 break;
194 case kEvtCleaningLevels:
195 {
196 TArrayF lvl(2);
197 lvl[0] = fImgCleanStd->GetCleanLvl2();
198 lvl[1] = fImgCleanStd->GetCleanLvl1();
199 fHist->SetCamContent(*event, 0);
200 fHist->SetLevels(lvl);
201 }
202 break;
203 case kEvtIdxMax:
204 fHist->SetCamContent(*event, 5);
205 break;
206 case kEvtArrTime:
207 fHist->SetCamContent(*event, 0);
208 break;
209 }
210
211 TString s;
212 if (fRawEvtHeader)
213 {
214 s += "Event #";
215 s += fRawEvtHeader->GetDAQEvtNumber();
216 }
217 if (fRawEvtHeader && fRawRunHeader)
218 s += " of ";
219
220 if (fRawRunHeader)
221 {
222 s += "Run #";
223 s += fRawRunHeader->GetRunNumber();
224 }
225
226 if (fMcEvt)
227 {
228 TString txt("#splitline{");
229
230 switch (fMcEvt->GetPartId())
231 {
232 case kGAMMA:
233 txt += "Gamma: ";
234 break;
235 case kPROTON:
236 txt += "Proton: ";
237 break;
238 case kHELIUM:
239 txt += "Helium: ";
240 break;
241 default:
242 s += "Particle Id#";
243 s += fMcEvt->GetPartId();
244 s += ": ";
245 }
246
247 s.Insert(0, txt);
248
249 s += "}{ E=";
250
251 if (fMcEvt->GetEnergy()>1000)
252 s += Form("%.1fTeV", fMcEvt->GetEnergy()/1000);
253 else
254 if (fMcEvt->GetEnergy()>10)
255 s += Form("%dGeV", (Int_t)(fMcEvt->GetEnergy()+.5));
256 else
257 if (fMcEvt->GetEnergy()>1)
258 s += Form("%.1fGeV", fMcEvt->GetEnergy());
259 else
260 s += Form("%dMeV", (Int_t)(fMcEvt->GetEnergy()*1000+.5));
261
262 s += " r=";
263 s += (int)(fMcEvt->GetImpact()/100+.5);
264 s += "m Zd=";
265 s += (int)(fMcEvt->GetTheta()*180/TMath::Pi()+.5);
266 s += "\\circ ";
267 if (fMcEvt->GetPhotElfromShower()>=10000)
268 s += Form("%dk", (Int_t)(fMcEvt->GetPhotElfromShower()/1000.+.5));
269 else
270 if (fMcEvt->GetPhotElfromShower()>=1000)
271 s += Form("%.1fk", fMcEvt->GetPhotElfromShower()/1000.);
272 else
273 s += fMcEvt->GetPhotElfromShower();
274 s += "PhEl}";
275 }
276
277 gPad=NULL;
278 fHist->SetTitle(s);
279
280 return kTRUE;
281}
282
283void MHEvent::Draw(Option_t *)
284{
285 if (!fHist)
286 {
287 *fLog << warn << "MHEvent::Draw - fHist==NULL not initialized." << endl;
288 return;
289 }
290
291 if (!gPad)
292 MakeDefCanvas(this);
293 fHist->Draw();
294}
Note: See TracBrowser for help on using the repository browser.