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

Last change on this file since 2777 was 2754, checked in by raducci, 21 years ago
*** empty log message ***
File size: 7.5 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 kEvtIdxMax:
152 fHist->SetName("Max Slice Idx");
153 fHist->SetYTitle("t [slice id]");
154 fHist->SetPrettyPalette();
155 break;
156 case kEvtArrTime:
157 fHist->SetName("Arrival Time");
158 fHist->SetYTitle("t [slice id]");
159 fHist->SetPrettyPalette();
160 break;
161 }
162
163 return kTRUE;
164}
165
166Bool_t MHEvent::Fill(const MParContainer *par, const Stat_t weight)
167{
168 if (fHist->IsFreezed())
169 return kTRUE;
170
171 if (!par)
172 return kFALSE;
173
174 if (fRawEvtData)
175 fRawEvtData->Copy(*fClone);
176
177 switch (fType)
178 {
179 case kEvtSignal:
180 case kEvtPedestal:
181 fHist->SetCamContent(*(MCamEvent*)par, 0);
182 break;
183 case kEvtPedestalRMS:
184 fHist->SetCamContent(*(MCamEvent*)par, 0);
185 break;
186 case kEvtRelativeSignal:
187 fHist->SetCamContent(*(MCamEvent*)par, 0);
188 break;
189 case kEvtCleaningLevels:
190 {
191 TArrayF lvl(2);
192 lvl[0] = fImgCleanStd->GetCleanLvl2();
193 lvl[1] = fImgCleanStd->GetCleanLvl1();
194 fHist->SetCamContent(*(MCamEvent*)par, 0);
195 fHist->SetLevels(lvl);
196 }
197 break;
198 case kEvtIdxMax:
199 fHist->SetCamContent(*(MCamEvent*)par, 5);
200 break;
201 case kEvtArrTime:
202 fHist->SetCamContent(*(MCamEvent*)par, 0);
203 break;
204 }
205
206 TString s;
207 if (fRawEvtHeader)
208 {
209 s += "Event #";
210 s += fRawEvtHeader->GetDAQEvtNumber();
211 }
212 if (fRawEvtHeader && fRawRunHeader)
213 s += " of ";
214
215 if (fRawRunHeader)
216 {
217 s += "Run #";
218 s += fRawRunHeader->GetRunNumber();
219 }
220
221 if (fMcEvt)
222 {
223 TString txt("#splitline{");
224
225 switch (fMcEvt->GetPartId())
226 {
227 case kGAMMA:
228 txt += "Gamma: ";
229 break;
230 case kPROTON:
231 txt += "Proton: ";
232 break;
233 case kHELIUM:
234 txt += "Helium: ";
235 break;
236 default:
237 s += "Particle Id#";
238 s += fMcEvt->GetPartId();
239 s += ": ";
240 }
241
242 s.Insert(0, txt);
243
244 s += "}{ E=";
245
246 if (fMcEvt->GetEnergy()>1000)
247 s += Form("%.1fTeV", fMcEvt->GetEnergy()/1000);
248 else
249 if (fMcEvt->GetEnergy()>10)
250 s += Form("%dGeV", (Int_t)(fMcEvt->GetEnergy()+.5));
251 else
252 if (fMcEvt->GetEnergy()>1)
253 s += Form("%.1fGeV", fMcEvt->GetEnergy());
254 else
255 s += Form("%dMeV", (Int_t)(fMcEvt->GetEnergy()*1000+.5));
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.