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 2001 <mailto:tbretz@uni-sw.gwdg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2001
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | ///////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MHHillasSrc
|
---|
28 | //
|
---|
29 | // This class contains histograms for every Hillas parameter
|
---|
30 | //
|
---|
31 | ///////////////////////////////////////////////////////////////////////
|
---|
32 | #include "MHHillasSrc.h"
|
---|
33 |
|
---|
34 | #include <math.h>
|
---|
35 |
|
---|
36 | #include <TH1.h>
|
---|
37 | #include <TPad.h>
|
---|
38 | #include <TCanvas.h>
|
---|
39 |
|
---|
40 | #include "MLog.h"
|
---|
41 | #include "MLogManip.h"
|
---|
42 |
|
---|
43 | #include "MGeomCam.h"
|
---|
44 |
|
---|
45 | #include "MParList.h"
|
---|
46 |
|
---|
47 | #include "MHillasSrc.h"
|
---|
48 |
|
---|
49 | ClassImp(MHHillasSrc);
|
---|
50 |
|
---|
51 | using namespace std;
|
---|
52 |
|
---|
53 | // --------------------------------------------------------------------------
|
---|
54 | //
|
---|
55 | // Setup four histograms for Alpha, and Dist
|
---|
56 | //
|
---|
57 | MHHillasSrc::MHHillasSrc(const char *name, const char *title)
|
---|
58 | : fUseMmScale(kTRUE)
|
---|
59 | {
|
---|
60 | //
|
---|
61 | // set the name and title of this object
|
---|
62 | //
|
---|
63 | fName = name ? name : "MHHillasSrc";
|
---|
64 | fTitle = title ? title : "Container for Hillas histograms";
|
---|
65 |
|
---|
66 | //
|
---|
67 | // loop over all Pixels and create two histograms
|
---|
68 | // one for the Low and one for the High gain
|
---|
69 | // connect all the histogram with the container fHist
|
---|
70 | //
|
---|
71 | fAlpha = new TH1F("Alpha", "Alpha of Ellipse", 90, -90, 90);
|
---|
72 | fDist = new TH1F("Dist", "Dist of Ellipse", 70, 0, 623);
|
---|
73 | fCosDA = new TH1F("CosDA", "cos(Delta,Alpha) of Ellipse", 101, -1, 1);
|
---|
74 | fDCA = new TH1F("DCA", "Distance of closest aproach", 101, -500, 500);
|
---|
75 | fDCADelta = new TH1F("DCADelta", "Angle between shower and x-axis", 80, 0, 360);
|
---|
76 |
|
---|
77 | fAlpha->SetDirectory(NULL);
|
---|
78 | fDist->SetDirectory(NULL);
|
---|
79 | fCosDA->SetDirectory(NULL);
|
---|
80 | fDCA->SetDirectory(NULL);
|
---|
81 | fDCADelta->SetDirectory(NULL);
|
---|
82 |
|
---|
83 | fAlpha->SetXTitle("\\alpha [\\circ]");
|
---|
84 | fDist->SetXTitle("Dist [mm]");
|
---|
85 | fCosDA->SetXTitle("cos(\\delta,\\alpha)");
|
---|
86 | fDCA->SetXTitle("DCA [\\circ]");
|
---|
87 | fDCADelta->SetXTitle("DCADelta [0, 2\\pi]");
|
---|
88 |
|
---|
89 | fAlpha->SetYTitle("Counts");
|
---|
90 | fDist->SetYTitle("Counts");
|
---|
91 | fCosDA->SetYTitle("Counts");
|
---|
92 | fDCA->SetYTitle("Counts");
|
---|
93 | fDCADelta->SetYTitle("Counts");
|
---|
94 |
|
---|
95 | fAlpha->SetMinimum(0);
|
---|
96 | fCosDA->SetMinimum(0);
|
---|
97 | fDCADelta->SetMinimum(0);
|
---|
98 | }
|
---|
99 |
|
---|
100 | // --------------------------------------------------------------------------
|
---|
101 | //
|
---|
102 | // Delete the four histograms
|
---|
103 | //
|
---|
104 | MHHillasSrc::~MHHillasSrc()
|
---|
105 | {
|
---|
106 | delete fAlpha;
|
---|
107 | delete fDist;
|
---|
108 | delete fCosDA;
|
---|
109 | delete fDCA;
|
---|
110 | delete fDCADelta;
|
---|
111 | }
|
---|
112 |
|
---|
113 | // --------------------------------------------------------------------------
|
---|
114 | //
|
---|
115 | // Setup the Binning for the histograms automatically if the correct
|
---|
116 | // instances of MBinning (with the names 'BinningAlpha' and 'BinningDist')
|
---|
117 | // are found in the parameter list
|
---|
118 | // Use this function if you want to set the conversion factor which
|
---|
119 | // is used to convert the mm-scale in the camera plain into the deg-scale
|
---|
120 | // used for histogram presentations. The conversion factor is part of
|
---|
121 | // the camera geometry. Please create a corresponding MGeomCam container.
|
---|
122 | //
|
---|
123 | Bool_t MHHillasSrc::SetupFill(const MParList *plist)
|
---|
124 | {
|
---|
125 | const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
|
---|
126 | if (!geom)
|
---|
127 | *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
|
---|
128 | else
|
---|
129 | {
|
---|
130 | fMm2Deg = geom->GetConvMm2Deg();
|
---|
131 | SetMmScale(kFALSE);
|
---|
132 | }
|
---|
133 |
|
---|
134 | ApplyBinning(*plist, "Alpha", fAlpha);
|
---|
135 | ApplyBinning(*plist, "Dist", fDist);
|
---|
136 | ApplyBinning(*plist, "DCA", fDCA);
|
---|
137 | ApplyBinning(*plist, "DCADelta", fDCADelta);
|
---|
138 |
|
---|
139 | return kTRUE;
|
---|
140 | }
|
---|
141 |
|
---|
142 | // --------------------------------------------------------------------------
|
---|
143 | //
|
---|
144 | // Fill the four histograms with data from a MHillas-Container.
|
---|
145 | // Be careful: Only call this with an object of type MHillas
|
---|
146 | //
|
---|
147 | Bool_t MHHillasSrc::Fill(const MParContainer *par, const Stat_t w)
|
---|
148 | {
|
---|
149 | if (!par)
|
---|
150 | {
|
---|
151 | *fLog << err << "MHHillasSrc::Fill: Pointer (!=NULL) expected." << endl;
|
---|
152 | return kFALSE;
|
---|
153 | }
|
---|
154 |
|
---|
155 | const MHillasSrc &h = *(MHillasSrc*)par;
|
---|
156 |
|
---|
157 | fAlpha->Fill(h.GetAlpha(), w);
|
---|
158 | fDist ->Fill(fUseMmScale ? h.GetDist() : fMm2Deg*h.GetDist(), w);
|
---|
159 | fCosDA->Fill(h.GetCosDeltaAlpha(), w);
|
---|
160 | fDCA ->Fill(fUseMmScale ? h.GetDCA() : fMm2Deg*h.GetDCA(), w);
|
---|
161 | fDCADelta->Fill(h.GetDCADelta(), w);
|
---|
162 |
|
---|
163 | return kTRUE;
|
---|
164 | }
|
---|
165 |
|
---|
166 | // --------------------------------------------------------------------------
|
---|
167 | //
|
---|
168 | // Use this function to setup your own conversion factor between degrees
|
---|
169 | // and millimeters. The conversion factor should be the one calculated in
|
---|
170 | // MGeomCam. Use this function with Caution: You could create wrong values
|
---|
171 | // by setting up your own scale factor.
|
---|
172 | //
|
---|
173 | void MHHillasSrc::SetMm2Deg(Float_t mmdeg)
|
---|
174 | {
|
---|
175 | if (mmdeg<=0)
|
---|
176 | {
|
---|
177 | *fLog << warn << dbginf << "Warning - Conversion factor <= 0 - nonsense. Ignored." << endl;
|
---|
178 | return;
|
---|
179 | }
|
---|
180 |
|
---|
181 | if (fMm2Deg>0)
|
---|
182 | *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
|
---|
183 |
|
---|
184 | fMm2Deg = mmdeg;
|
---|
185 | }
|
---|
186 |
|
---|
187 | // --------------------------------------------------------------------------
|
---|
188 | //
|
---|
189 | // With this function you can convert the histogram ('on the fly') between
|
---|
190 | // degrees and millimeters.
|
---|
191 | //
|
---|
192 | void MHHillasSrc::SetMmScale(Bool_t mmscale)
|
---|
193 | {
|
---|
194 | if (fUseMmScale == mmscale)
|
---|
195 | return;
|
---|
196 |
|
---|
197 | if (fMm2Deg<0)
|
---|
198 | {
|
---|
199 | *fLog << warn << GetDescriptor() << ": Warning - Sorry, no conversion factor for conversion available." << endl;
|
---|
200 | return;
|
---|
201 | }
|
---|
202 |
|
---|
203 | const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
|
---|
204 | MH::ScaleAxis(fDist, scale);
|
---|
205 | MH::ScaleAxis(fDCA, scale);
|
---|
206 |
|
---|
207 | fDist->SetXTitle(mmscale ? "Dist [mm]" : "Dist [\\circ]");
|
---|
208 | fDCA ->SetXTitle(mmscale ? "DCA [mm]" : "DCA [\\circ]");
|
---|
209 |
|
---|
210 | fUseMmScale = mmscale;
|
---|
211 | }
|
---|
212 |
|
---|
213 | // --------------------------------------------------------------------------
|
---|
214 | //
|
---|
215 | // Creates a new canvas and draws the two histograms into it.
|
---|
216 | // Be careful: The histograms belongs to this object and won't get deleted
|
---|
217 | // together with the canvas.
|
---|
218 | //
|
---|
219 | void MHHillasSrc::Draw(Option_t *o)
|
---|
220 | {
|
---|
221 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
---|
222 | pad->SetBorderMode(0);
|
---|
223 |
|
---|
224 | AppendPad("");
|
---|
225 |
|
---|
226 | // FIXME: Display Source position
|
---|
227 |
|
---|
228 | // FIXME: If same-option given make two independant y-axis!
|
---|
229 | const TString opt(o);
|
---|
230 | const Bool_t same = opt.Contains("same");
|
---|
231 |
|
---|
232 | if (!same)
|
---|
233 | pad->Divide(2,2);
|
---|
234 | else
|
---|
235 | {
|
---|
236 | fAlpha->SetName("AlphaSame");
|
---|
237 | fDist ->SetName("DistSame");
|
---|
238 | fCosDA->SetName("CosDASame");
|
---|
239 | fDCA ->SetName("DCASame");
|
---|
240 | fDCADelta->SetName("DCADeltaSame");
|
---|
241 |
|
---|
242 | fAlpha->SetDirectory(0);
|
---|
243 | fDist ->SetDirectory(0);
|
---|
244 | fCosDA->SetDirectory(0);
|
---|
245 | fDCA ->SetDirectory(0);
|
---|
246 | fDCADelta->SetDirectory(0);
|
---|
247 |
|
---|
248 | fAlpha->SetLineColor(kGreen);
|
---|
249 | fDist->SetLineColor(kGreen);
|
---|
250 | fDCA->SetLineColor(kGreen);
|
---|
251 | fCosDA->SetLineColor(kGreen);
|
---|
252 | fDCADelta->SetLineColor(kGreen);
|
---|
253 | }
|
---|
254 |
|
---|
255 | pad->cd(1);
|
---|
256 | gPad->SetBorderMode(0);
|
---|
257 | RemoveFromPad("AlphaSame");
|
---|
258 | fAlpha->Draw(same?"same":"");
|
---|
259 |
|
---|
260 | pad->cd(2);
|
---|
261 | gPad->SetBorderMode(0);
|
---|
262 | RemoveFromPad("DistSame");
|
---|
263 | fDist->Draw(same?"same":"");
|
---|
264 |
|
---|
265 | pad->cd(3);
|
---|
266 | gPad->SetBorderMode(0);
|
---|
267 | RemoveFromPad("DCASame");
|
---|
268 | fDCA->Draw(same?"same":"");
|
---|
269 |
|
---|
270 | pad->cd(4);
|
---|
271 | gPad->SetBorderMode(0);
|
---|
272 |
|
---|
273 | TVirtualPad *p = gPad;
|
---|
274 | if (!same)
|
---|
275 | p->Divide(1,2);
|
---|
276 | p->cd(1);
|
---|
277 | gPad->SetBorderMode(0);
|
---|
278 | RemoveFromPad("CosDASame");
|
---|
279 | fCosDA->Draw(same?"same":"");
|
---|
280 |
|
---|
281 | p->cd(2);
|
---|
282 | gPad->SetBorderMode(0);
|
---|
283 | RemoveFromPad("DCADeltaSame");
|
---|
284 | fDCADelta->Draw(same?"same":"");
|
---|
285 | }
|
---|
286 |
|
---|
287 | void MHHillasSrc::Paint(Option_t *opt)
|
---|
288 | {
|
---|
289 | if (fCosDA->GetEntries()==0)
|
---|
290 | return;
|
---|
291 |
|
---|
292 | TVirtualPad *savepad = gPad;
|
---|
293 | savepad->cd(4);
|
---|
294 | gPad->SetLogy();
|
---|
295 | gPad = savepad;
|
---|
296 | }
|
---|
297 |
|
---|
298 | TH1 *MHHillasSrc::GetHistByName(const TString name) const
|
---|
299 | {
|
---|
300 | if (name.Contains("Alpha", TString::kIgnoreCase))
|
---|
301 | return fAlpha;
|
---|
302 | if (name.Contains("Dist", TString::kIgnoreCase))
|
---|
303 | return fDist;
|
---|
304 | if (name.Contains("CosDA", TString::kIgnoreCase))
|
---|
305 | return fCosDA;
|
---|
306 |
|
---|
307 | return NULL;
|
---|
308 | }
|
---|