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 |
|
---|
66 | ClassImp(MHEvent);
|
---|
67 |
|
---|
68 | using namespace std;
|
---|
69 |
|
---|
70 | // --------------------------------------------------------------------------
|
---|
71 | //
|
---|
72 | MHEvent::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 | //
|
---|
82 | MHEvent::~MHEvent()
|
---|
83 | {
|
---|
84 | if (fHist)
|
---|
85 | delete fHist;
|
---|
86 |
|
---|
87 | delete fClone;
|
---|
88 | }
|
---|
89 |
|
---|
90 | Bool_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 |
|
---|
164 | Bool_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 | if (fRawEvtData)
|
---|
173 | fRawEvtData->Copy(*fClone);
|
---|
174 |
|
---|
175 | switch (fType)
|
---|
176 | {
|
---|
177 | case kEvtSignal:
|
---|
178 | case kEvtPedestal:
|
---|
179 | fHist->SetCamContent(*(MCamEvent*)par, 0);
|
---|
180 | break;
|
---|
181 | case kEvtPedestalRMS:
|
---|
182 | fHist->SetCamContent(*(MCamEvent*)par, 0);
|
---|
183 | break;
|
---|
184 | case kEvtRelativeSignal:
|
---|
185 | fHist->SetCamContent(*(MCamEvent*)par, 0);
|
---|
186 | break;
|
---|
187 | case kEvtCleaningLevels:
|
---|
188 | {
|
---|
189 | TArrayF lvl(2);
|
---|
190 | lvl[0] = fImgCleanStd->GetCleanLvl2();
|
---|
191 | lvl[1] = fImgCleanStd->GetCleanLvl1();
|
---|
192 | fHist->SetCamContent(*(MCamEvent*)par, 0);
|
---|
193 | fHist->SetLevels(lvl);
|
---|
194 | }
|
---|
195 | break;
|
---|
196 | case kEvtIdxMax:
|
---|
197 | fHist->SetCamContent(*(MCamEvent*)par, 5);
|
---|
198 | break;
|
---|
199 | case kEvtArrTime:
|
---|
200 | fHist->SetCamContent(*(MCamEvent*)par, 0);
|
---|
201 | break;
|
---|
202 | }
|
---|
203 |
|
---|
204 | TString s;
|
---|
205 | if (fRawEvtHeader)
|
---|
206 | {
|
---|
207 | s += "Event #";
|
---|
208 | s += fRawEvtHeader->GetDAQEvtNumber();
|
---|
209 | }
|
---|
210 | if (fRawEvtHeader && fRawRunHeader)
|
---|
211 | s += " of ";
|
---|
212 |
|
---|
213 | if (fRawRunHeader)
|
---|
214 | {
|
---|
215 | s += "Run #";
|
---|
216 | s += fRawRunHeader->GetRunNumber();
|
---|
217 | }
|
---|
218 |
|
---|
219 | if (fMcEvt)
|
---|
220 | {
|
---|
221 | TString txt("#splitline{");
|
---|
222 |
|
---|
223 | switch (fMcEvt->GetPartId())
|
---|
224 | {
|
---|
225 | case kGAMMA:
|
---|
226 | txt += "Gamma: ";
|
---|
227 | break;
|
---|
228 | case kPROTON:
|
---|
229 | txt += "Proton: ";
|
---|
230 | break;
|
---|
231 | case kHELIUM:
|
---|
232 | txt += "Helium: ";
|
---|
233 | break;
|
---|
234 | default:
|
---|
235 | s += "Particle Id#";
|
---|
236 | s += fMcEvt->GetPartId();
|
---|
237 | s += ": ";
|
---|
238 | }
|
---|
239 |
|
---|
240 | s.Insert(0, txt);
|
---|
241 |
|
---|
242 | s += "}{ E=";
|
---|
243 |
|
---|
244 | if (fMcEvt->GetEnergy()>1000)
|
---|
245 | s += Form("%.1fTeV", fMcEvt->GetEnergy()/1000);
|
---|
246 | else
|
---|
247 | if (fMcEvt->GetEnergy()>10)
|
---|
248 | s += Form("%dGeV", (Int_t)(fMcEvt->GetEnergy()+.5));
|
---|
249 | else
|
---|
250 | if (fMcEvt->GetEnergy()>1)
|
---|
251 | s += Form("%.1fGeV", fMcEvt->GetEnergy());
|
---|
252 | else
|
---|
253 | s += Form("%dMeV", (Int_t)(fMcEvt->GetEnergy()*1000+.5));
|
---|
254 |
|
---|
255 | s += " r=";
|
---|
256 | s += (int)(fMcEvt->GetImpact()/100+.5);
|
---|
257 | s += "m Zd=";
|
---|
258 | s += (int)(fMcEvt->GetTheta()*180/TMath::Pi()+.5);
|
---|
259 | s += "\\circ ";
|
---|
260 | if (fMcEvt->GetPhotElfromShower()>=10000)
|
---|
261 | s += Form("%dk", (Int_t)(fMcEvt->GetPhotElfromShower()/1000.+.5));
|
---|
262 | else
|
---|
263 | if (fMcEvt->GetPhotElfromShower()>=1000)
|
---|
264 | s += Form("%.1fk", fMcEvt->GetPhotElfromShower()/1000.);
|
---|
265 | else
|
---|
266 | s += fMcEvt->GetPhotElfromShower();
|
---|
267 | s += "PhEl}";
|
---|
268 | }
|
---|
269 |
|
---|
270 | gPad=NULL;
|
---|
271 | fHist->SetTitle(s);
|
---|
272 |
|
---|
273 | return kTRUE;
|
---|
274 | }
|
---|
275 |
|
---|
276 | void MHEvent::Draw(Option_t *)
|
---|
277 | {
|
---|
278 | if (!fHist)
|
---|
279 | {
|
---|
280 | *fLog << warn << "MHEvent::Draw - fHist==NULL not initialized." << endl;
|
---|
281 | return;
|
---|
282 | }
|
---|
283 |
|
---|
284 | if (!gPad)
|
---|
285 | MakeDefCanvas(this);
|
---|
286 | fHist->Draw();
|
---|
287 | }
|
---|