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