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-2002
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MHHillasExt
|
---|
28 | //
|
---|
29 | // This class contains histograms for every Hillas parameter
|
---|
30 | //
|
---|
31 | /////////////////////////////////////////////////////////////////////////////
|
---|
32 | #include "MHHillasExt.h"
|
---|
33 |
|
---|
34 | #include <math.h>
|
---|
35 |
|
---|
36 | #include <TH1.h>
|
---|
37 | #include <TPad.h>
|
---|
38 | #include <TLegend.h>
|
---|
39 | #include <TCanvas.h>
|
---|
40 |
|
---|
41 | #include "MLog.h"
|
---|
42 | #include "MLogManip.h"
|
---|
43 |
|
---|
44 | #include "MGeomCam.h"
|
---|
45 |
|
---|
46 | #include "MParList.h"
|
---|
47 |
|
---|
48 | #include "MBinning.h"
|
---|
49 | #include "MHillasExt.h"
|
---|
50 | #include "MHillasSrc.h"
|
---|
51 |
|
---|
52 | ClassImp(MHHillasExt);
|
---|
53 |
|
---|
54 | // --------------------------------------------------------------------------
|
---|
55 | //
|
---|
56 | // Setup four histograms for Width, Length
|
---|
57 | //
|
---|
58 | MHHillasExt::MHHillasExt(const char *name, const char *title)
|
---|
59 | : fMm2Deg(1), fUseMmScale(kTRUE), fHilName("MHillas")
|
---|
60 | {
|
---|
61 | //
|
---|
62 | // set the name and title of this object
|
---|
63 | //
|
---|
64 | fName = name ? name : "MHHillasExt";
|
---|
65 | fTitle = title ? title : "Container for extended 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 | fHConc1.SetLineColor(kBlue);
|
---|
73 | fHConc.SetFillStyle(0);
|
---|
74 |
|
---|
75 | fHConc.SetDirectory(NULL);
|
---|
76 | fHConc1.SetDirectory(NULL);
|
---|
77 | fHAsym.SetDirectory(NULL);
|
---|
78 | fHM3Long.SetDirectory(NULL);
|
---|
79 | fHM3Trans.SetDirectory(NULL);
|
---|
80 |
|
---|
81 | fHConc.SetName("Conc2");
|
---|
82 | fHConc1.SetName("Conc1");
|
---|
83 | fHAsym.SetName("Asymmetry");
|
---|
84 | fHM3Long.SetName("3rd Mom Long");
|
---|
85 | fHM3Trans.SetName("3rd Mom Trans");
|
---|
86 |
|
---|
87 | fHConc.SetTitle("Ratio: Conc");
|
---|
88 | fHConc1.SetTitle("Ratio: Conc1");
|
---|
89 | fHAsym.SetTitle("Asymmetry");
|
---|
90 | fHM3Long.SetTitle("3^{rd} Moment Longitudinal");
|
---|
91 | fHM3Trans.SetTitle("3^{rd} Moment Transverse");
|
---|
92 |
|
---|
93 | fHConc.SetXTitle("Ratio");
|
---|
94 | fHConc1.SetXTitle("Ratio");
|
---|
95 | fHAsym.SetXTitle("Asym [mm]");
|
---|
96 | fHM3Long.SetXTitle("3^{rd} M_{l} [mm]");
|
---|
97 | fHM3Trans.SetXTitle("3^{rd} M_{t} [mm]");
|
---|
98 |
|
---|
99 | fHConc.SetYTitle("Counts");
|
---|
100 | fHConc1.SetYTitle("Counts");
|
---|
101 | fHAsym.SetYTitle("Counts");
|
---|
102 | fHM3Long.SetYTitle("Counts");
|
---|
103 | fHM3Trans.SetYTitle("Counts");
|
---|
104 |
|
---|
105 | fHConc.SetFillStyle(4000);
|
---|
106 | fHConc1.SetFillStyle(4000);
|
---|
107 | fHAsym.SetFillStyle(4000);
|
---|
108 | fHM3Long.SetFillStyle(4000);
|
---|
109 | fHM3Trans.SetFillStyle(4000);
|
---|
110 |
|
---|
111 | MBinning bins;
|
---|
112 |
|
---|
113 | bins.SetEdges(100, 0, 1);
|
---|
114 | bins.Apply(fHConc);
|
---|
115 | bins.Apply(fHConc1);
|
---|
116 |
|
---|
117 | bins.SetEdges(101, -326, 326);
|
---|
118 | bins.Apply(fHM3Long);
|
---|
119 | bins.Apply(fHM3Trans);
|
---|
120 |
|
---|
121 | bins.SetEdges(101, -593, 593);
|
---|
122 | bins.Apply(fHAsym);
|
---|
123 | }
|
---|
124 |
|
---|
125 | // --------------------------------------------------------------------------
|
---|
126 | //
|
---|
127 | // Setup the Binning for the histograms automatically if the correct
|
---|
128 | // instances of MBinning (with the names 'BinningWidth' and 'BinningLength')
|
---|
129 | // are found in the parameter list
|
---|
130 | // Use this function if you want to set the conversion factor which
|
---|
131 | // is used to convert the mm-scale in the camera plain into the deg-scale
|
---|
132 | // used for histogram presentations. The conversion factor is part of
|
---|
133 | // the camera geometry. Please create a corresponding MGeomCam container.
|
---|
134 | //
|
---|
135 | Bool_t MHHillasExt::SetupFill(const MParList *plist)
|
---|
136 | {
|
---|
137 | fHillasExt = (MHillasExt*)plist->FindObject(fHilName, "MHillasExt");
|
---|
138 | if (!fHillasExt)
|
---|
139 | {
|
---|
140 | *fLog << err << fHilName << "[MHillasExt] not found in parameter list... aborting." << endl;
|
---|
141 | return kFALSE;
|
---|
142 | }
|
---|
143 |
|
---|
144 | const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
|
---|
145 | if (!geom)
|
---|
146 | *fLog << warn << GetDescriptor() << ": No Camera Geometry available. Using mm-scale for histograms." << endl;
|
---|
147 | else
|
---|
148 | {
|
---|
149 | fMm2Deg = geom->GetConvMm2Deg();
|
---|
150 | SetMmScale(kFALSE);
|
---|
151 | }
|
---|
152 |
|
---|
153 | ApplyBinning(*plist, "Conc", &fHConc);
|
---|
154 | ApplyBinning(*plist, "Conc1", &fHConc1);
|
---|
155 | ApplyBinning(*plist, "Asym", &fHAsym);
|
---|
156 | ApplyBinning(*plist, "M3Long", &fHM3Long);
|
---|
157 | ApplyBinning(*plist, "M3Trans", &fHM3Trans);
|
---|
158 |
|
---|
159 | return kTRUE;
|
---|
160 | }
|
---|
161 |
|
---|
162 | // --------------------------------------------------------------------------
|
---|
163 | //
|
---|
164 | // Fill the four histograms with data from a MHillas-Container.
|
---|
165 | // Be careful: Only call this with an object of type MHillas
|
---|
166 | //
|
---|
167 | Bool_t MHHillasExt::Fill(const MParContainer *par)
|
---|
168 | {
|
---|
169 | const MHillasSrc *src = (MHillasSrc*)par;
|
---|
170 |
|
---|
171 | const Double_t scale = TMath::Sign(fUseMmScale?1:fMm2Deg, (src ? src->GetCosDeltaAlpha() : 1));
|
---|
172 |
|
---|
173 | fHConc.Fill(fHillasExt->GetConc());
|
---|
174 | fHConc1.Fill(fHillasExt->GetConc1());
|
---|
175 |
|
---|
176 | fHAsym.Fill(scale*fHillasExt->GetAsym());
|
---|
177 | fHM3Long.Fill(scale*fHillasExt->GetM3Long());
|
---|
178 | fHM3Trans.Fill(scale*fHillasExt->GetM3Trans());
|
---|
179 | //fHAsymna.Fill(scale*ext.GetAsymna());
|
---|
180 | //fHAsym0.Fill(scale*ext.GetAsym0());
|
---|
181 |
|
---|
182 | return kTRUE;
|
---|
183 | }
|
---|
184 |
|
---|
185 | // --------------------------------------------------------------------------
|
---|
186 | //
|
---|
187 | // With this function you can convert the histogram ('on the fly') between
|
---|
188 | // degrees and millimeters.
|
---|
189 | //
|
---|
190 | void MHHillasExt::SetMmScale(Bool_t mmscale)
|
---|
191 | {
|
---|
192 | if (fUseMmScale == mmscale)
|
---|
193 | return;
|
---|
194 |
|
---|
195 | if (fMm2Deg<0)
|
---|
196 | {
|
---|
197 | *fLog << warn << dbginf << "Warning - Sorry, no conversion factor for conversion available." << endl;
|
---|
198 | return;
|
---|
199 | }
|
---|
200 |
|
---|
201 | const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
|
---|
202 | MH::ScaleAxis(&fHAsym, scale);
|
---|
203 | MH::ScaleAxis(&fHM3Long, scale);
|
---|
204 | MH::ScaleAxis(&fHM3Trans, scale);
|
---|
205 |
|
---|
206 | if (mmscale)
|
---|
207 | {
|
---|
208 | fHAsym.SetXTitle("Asym [mm]");
|
---|
209 | fHM3Long.SetXTitle("3^{rd} M_{l} [mm]");
|
---|
210 | fHM3Trans.SetXTitle("3^{rd} M_{t} [mm]");
|
---|
211 | }
|
---|
212 | else
|
---|
213 | {
|
---|
214 | fHAsym.SetXTitle("Asym [\\circ]");
|
---|
215 | fHM3Long.SetXTitle("3^{rd} M_{l} [\\circ]");
|
---|
216 | fHM3Trans.SetXTitle("3^{rd} M_{t} [\\circ]");
|
---|
217 | }
|
---|
218 |
|
---|
219 | fUseMmScale = mmscale;
|
---|
220 | }
|
---|
221 |
|
---|
222 | // --------------------------------------------------------------------------
|
---|
223 | //
|
---|
224 | // Use this function to setup your own conversion factor between degrees
|
---|
225 | // and millimeters. The conversion factor should be the one calculated in
|
---|
226 | // MGeomCam. Use this function with Caution: You could create wrong values
|
---|
227 | // by setting up your own scale factor.
|
---|
228 | //
|
---|
229 | void MHHillasExt::SetMm2Deg(Float_t mmdeg)
|
---|
230 | {
|
---|
231 | if (mmdeg<0)
|
---|
232 | {
|
---|
233 | *fLog << warn << dbginf << "Warning - Conversion factor < 0 - nonsense. Ignored." << endl;
|
---|
234 | return;
|
---|
235 | }
|
---|
236 |
|
---|
237 | if (fMm2Deg>=0)
|
---|
238 | *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
|
---|
239 |
|
---|
240 | fMm2Deg = mmdeg;
|
---|
241 | }
|
---|
242 |
|
---|
243 | // --------------------------------------------------------------------------
|
---|
244 | //
|
---|
245 | // Draw clones of all four histograms. So that the object can be deleted
|
---|
246 | // and the histograms are still visible in the canvas.
|
---|
247 | // The cloned object are deleted together with the canvas if the canvas is
|
---|
248 | // destroyed. If you want to handle dostroying the canvas you can get a
|
---|
249 | // pointer to it from this function
|
---|
250 | //
|
---|
251 | TObject *MHHillasExt::DrawClone(Option_t *opt) const
|
---|
252 | {
|
---|
253 | return MH::DrawClone(opt, 720, 540);
|
---|
254 | }
|
---|
255 |
|
---|
256 | // --------------------------------------------------------------------------
|
---|
257 | //
|
---|
258 | // Creates a new canvas and draws the four histograms into it.
|
---|
259 | // Be careful: The histograms belongs to this object and won't get deleted
|
---|
260 | // together with the canvas.
|
---|
261 | //
|
---|
262 | void MHHillasExt::Draw(Option_t *)
|
---|
263 | {
|
---|
264 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 720, 540);
|
---|
265 | pad->SetBorderMode(0);
|
---|
266 |
|
---|
267 | AppendPad("");
|
---|
268 |
|
---|
269 | pad->Divide(2, 2);
|
---|
270 |
|
---|
271 | pad->cd(1);
|
---|
272 | gPad->SetBorderMode(0);
|
---|
273 | MH::Draw(fHConc1, fHConc, "Concentrations");
|
---|
274 |
|
---|
275 | pad->cd(2);
|
---|
276 | gPad->SetBorderMode(0);
|
---|
277 | fHAsym.Draw();
|
---|
278 |
|
---|
279 | pad->cd(3);
|
---|
280 | gPad->SetBorderMode(0);
|
---|
281 | fHM3Long.Draw();
|
---|
282 |
|
---|
283 | pad->cd(4);
|
---|
284 | gPad->SetBorderMode(0);
|
---|
285 | fHM3Trans.Draw();
|
---|
286 |
|
---|
287 | pad->Modified();
|
---|
288 | pad->Update();
|
---|
289 | }
|
---|
290 |
|
---|
291 | TH1 *MHHillasExt::GetHistByName(const TString name)
|
---|
292 | {
|
---|
293 | if (name.Contains("Conc", TString::kIgnoreCase))
|
---|
294 | return &fHConc;
|
---|
295 | if (name.Contains("Conc1", TString::kIgnoreCase))
|
---|
296 | return &fHConc1;
|
---|
297 | if (name.Contains("Asym", TString::kIgnoreCase))
|
---|
298 | return &fHAsym;
|
---|
299 | if (name.Contains("M3Long", TString::kIgnoreCase))
|
---|
300 | return &fHM3Long;
|
---|
301 | if (name.Contains("M3Trans", TString::kIgnoreCase))
|
---|
302 | return &fHM3Trans;
|
---|
303 |
|
---|
304 | return NULL;
|
---|
305 | }
|
---|