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