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", 90, 0, 90);
|
---|
71 | fDist = new TH1F("Dist", "Dist of Ellipse", 100, 0, 600);
|
---|
72 |
|
---|
73 | fAlpha->SetDirectory(NULL);
|
---|
74 | fDist->SetDirectory(NULL);
|
---|
75 |
|
---|
76 | fAlpha->SetXTitle("\\alpha [mm]");
|
---|
77 | fDist->SetXTitle("Dist [mm]");
|
---|
78 |
|
---|
79 | fAlpha->SetYTitle("Counts");
|
---|
80 | fDist->SetYTitle("Counts");
|
---|
81 | }
|
---|
82 |
|
---|
83 | // --------------------------------------------------------------------------
|
---|
84 | //
|
---|
85 | // Delete the four histograms
|
---|
86 | //
|
---|
87 | MHHillasSrc::~MHHillasSrc()
|
---|
88 | {
|
---|
89 | delete fAlpha;
|
---|
90 | delete fDist;
|
---|
91 | }
|
---|
92 |
|
---|
93 | // --------------------------------------------------------------------------
|
---|
94 | //
|
---|
95 | // Setup the Binning for the histograms automatically if the correct
|
---|
96 | // instances of MBinning (with the names 'BinningAlpha' and 'BinningDist')
|
---|
97 | // are found in the parameter list
|
---|
98 | // Use this function if you want to set the conversion factor which
|
---|
99 | // is used to convert the mm-scale in the camera plain into the deg-scale
|
---|
100 | // used for histogram presentations. The conversion factor is part of
|
---|
101 | // the camera geometry. Please create a corresponding MGeomCam container.
|
---|
102 | //
|
---|
103 | Bool_t MHHillasSrc::SetupFill(const MParList *plist)
|
---|
104 | {
|
---|
105 | const MBinning* binsa = (MBinning*)plist->FindObject("BinningAlpha");
|
---|
106 | const MBinning* binsd = (MBinning*)plist->FindObject("BinningDist");
|
---|
107 | if (!binsa || !binsd)
|
---|
108 | {
|
---|
109 | *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
|
---|
110 | return kFALSE;
|
---|
111 | }
|
---|
112 |
|
---|
113 | SetBinning(fAlpha, binsa);
|
---|
114 | SetBinning(fDist, binsd);
|
---|
115 |
|
---|
116 | const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
|
---|
117 | if (!geom)
|
---|
118 | {
|
---|
119 | *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
|
---|
120 | return kTRUE;
|
---|
121 | }
|
---|
122 |
|
---|
123 | fDist->SetXTitle("Dist [\\circ]");
|
---|
124 |
|
---|
125 | fMm2Deg = geom->GetConvMm2Deg();
|
---|
126 | fUseMmScale = kFALSE;
|
---|
127 |
|
---|
128 | return kTRUE;
|
---|
129 | }
|
---|
130 |
|
---|
131 | // --------------------------------------------------------------------------
|
---|
132 | //
|
---|
133 | // Fill the four histograms with data from a MHillas-Container.
|
---|
134 | // Be careful: Only call this with an object of type MHillas
|
---|
135 | //
|
---|
136 | Bool_t MHHillasSrc::Fill(const MParContainer *par)
|
---|
137 | {
|
---|
138 | const MHillasSrc &h = *(MHillasSrc*)par;
|
---|
139 |
|
---|
140 | fAlpha->Fill(fabs(h.GetAlpha()));
|
---|
141 | fDist ->Fill(fUseMmScale ? h.GetDist() : fMm2Deg*h.GetDist());
|
---|
142 |
|
---|
143 | return kTRUE;
|
---|
144 | }
|
---|
145 |
|
---|
146 | // --------------------------------------------------------------------------
|
---|
147 | //
|
---|
148 | // Draw clones of all two histograms. So that the object can be deleted
|
---|
149 | // and the histograms are still visible in the canvas.
|
---|
150 | // The cloned object are deleted together with the canvas if the canvas is
|
---|
151 | // destroyed. If you want to handle dostroying the canvas you can get a
|
---|
152 | // pointer to it from this function
|
---|
153 | //
|
---|
154 | TObject *MHHillasSrc::DrawClone(Option_t *opt) const
|
---|
155 | {
|
---|
156 | TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Source dependant Parameters",
|
---|
157 | 350, 500);
|
---|
158 | c->Divide(1, 2);
|
---|
159 |
|
---|
160 | // FIXME: Display Source position
|
---|
161 |
|
---|
162 | gROOT->SetSelectedPad(NULL);
|
---|
163 |
|
---|
164 | //
|
---|
165 | // This is necessary to get the expected bahviour of DrawClone
|
---|
166 | //
|
---|
167 | c->cd(1);
|
---|
168 | fAlpha->DrawCopy();
|
---|
169 |
|
---|
170 | c->cd(2);
|
---|
171 | fDist->DrawCopy();
|
---|
172 |
|
---|
173 | c->Modified();
|
---|
174 | c->Update();
|
---|
175 |
|
---|
176 | return c;
|
---|
177 | }
|
---|
178 |
|
---|
179 | // --------------------------------------------------------------------------
|
---|
180 | //
|
---|
181 | // Creates a new canvas and draws the two histograms into it.
|
---|
182 | // Be careful: The histograms belongs to this object and won't get deleted
|
---|
183 | // together with the canvas.
|
---|
184 | //
|
---|
185 | void MHHillasSrc::Draw(Option_t *)
|
---|
186 | {
|
---|
187 | if (!gPad)
|
---|
188 | MakeDefCanvas("Hillas", "Histograms of Src dependant Parameters", 350, 500);
|
---|
189 |
|
---|
190 | // FIXME: Display Source position
|
---|
191 |
|
---|
192 | gPad->Divide(1, 2);
|
---|
193 |
|
---|
194 | gPad->cd(1);
|
---|
195 | fAlpha->Draw();
|
---|
196 |
|
---|
197 | gPad->cd(2);
|
---|
198 | fDist->Draw();
|
---|
199 |
|
---|
200 | gPad->Modified();
|
---|
201 | gPad->Update();
|
---|
202 | }
|
---|