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