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

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