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 | // MHHillas
|
---|
28 | //
|
---|
29 | // This class contains histograms for every Hillas parameter
|
---|
30 | //
|
---|
31 | ///////////////////////////////////////////////////////////////////////
|
---|
32 |
|
---|
33 | #include "MHHillas.h"
|
---|
34 |
|
---|
35 | #include <math.h>
|
---|
36 |
|
---|
37 | #include <TH1.h>
|
---|
38 | #include <TPad.h>
|
---|
39 | #include <TCanvas.h>
|
---|
40 |
|
---|
41 | #include "MHillas.h"
|
---|
42 |
|
---|
43 | ClassImp(MHHillas);
|
---|
44 |
|
---|
45 | // --------------------------------------------------------------------------
|
---|
46 | //
|
---|
47 | // Setup four histograms for Alpha, Width, Length and Dist
|
---|
48 | //
|
---|
49 | MHHillas::MHHillas (const char *name, const char *title)
|
---|
50 | {
|
---|
51 | //
|
---|
52 | // set the name and title of this object
|
---|
53 | //
|
---|
54 | fName = name ? name : "MHHillas" ;
|
---|
55 | fTitle = title ? title : "Container for Hillas histograms" ;
|
---|
56 |
|
---|
57 | //
|
---|
58 | // loop over all Pixels and create two histograms
|
---|
59 | // one for the Low and one for the High gain
|
---|
60 | // connect all the histogram with the container fHist
|
---|
61 | //
|
---|
62 | fAlpha = new TH1F("Alpha [deg]", "Alpha of Hillas", 90, 0, 90);
|
---|
63 | fWidth = new TH1F("Width [mm]", "Width of Hillas", 100, 0, 300);
|
---|
64 | fLength = new TH1F("Length [mm]", "Length of Hillas", 100, 0, 300);
|
---|
65 | fDist = new TH1F("Dist [mm]", "Dist of Hillas", 100, 0, 300);
|
---|
66 |
|
---|
67 | fAlpha->SetDirectory(NULL);
|
---|
68 | fLength->SetDirectory(NULL);
|
---|
69 | fDist->SetDirectory(NULL);
|
---|
70 | fWidth->SetDirectory(NULL);
|
---|
71 |
|
---|
72 | fAlpha->GetXaxis()->SetTitle("\\alpha [\\circ]");
|
---|
73 | fLength->GetXaxis()->SetTitle("Length [mm]");
|
---|
74 | fDist->GetXaxis()->SetTitle("Dist [mm]");
|
---|
75 | fWidth->GetXaxis()->SetTitle("Width [mm]");
|
---|
76 |
|
---|
77 | fAlpha->GetYaxis()->SetTitle("Counts");
|
---|
78 | fLength->GetYaxis()->SetTitle("Counts");
|
---|
79 | fDist->GetYaxis()->SetTitle("Counts");
|
---|
80 | fWidth->GetYaxis()->SetTitle("Counts");
|
---|
81 | }
|
---|
82 |
|
---|
83 | // --------------------------------------------------------------------------
|
---|
84 | //
|
---|
85 | // Delete the four histograms
|
---|
86 | //
|
---|
87 | MHHillas::~MHHillas()
|
---|
88 | {
|
---|
89 | delete fAlpha;
|
---|
90 | delete fWidth;
|
---|
91 | delete fLength;
|
---|
92 | delete fDist;
|
---|
93 | }
|
---|
94 |
|
---|
95 | // --------------------------------------------------------------------------
|
---|
96 | //
|
---|
97 | // Fill the four histograms with data from a MHillas-Container.
|
---|
98 | // Be careful: Only call this with an object of type MHillas
|
---|
99 | //
|
---|
100 | void MHHillas::Fill(const MParContainer *par)
|
---|
101 | {
|
---|
102 | const MHillas &h = *(MHillas*)par;
|
---|
103 |
|
---|
104 | fAlpha ->Fill(fabs(h.GetAlpha()));
|
---|
105 | fWidth ->Fill(h.GetWidth());
|
---|
106 | fLength->Fill(h.GetLength());
|
---|
107 | fDist ->Fill(h.GetDist());
|
---|
108 | }
|
---|
109 |
|
---|
110 | // --------------------------------------------------------------------------
|
---|
111 | //
|
---|
112 | // Draw clones of all four histograms. So that the object can be deleted
|
---|
113 | // and the histograms are still visible in the canvas.
|
---|
114 | // The cloned object are deleted together with the canvas if the canvas is
|
---|
115 | // destroyed. If you want to handle dostroying the canvas you can get a
|
---|
116 | // pointer to it from this function
|
---|
117 | //
|
---|
118 | TObject *MHHillas::DrawClone(Option_t *opt) const
|
---|
119 | {
|
---|
120 | TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Hillas Parameters");
|
---|
121 | c->Divide(2, 2);
|
---|
122 |
|
---|
123 | gROOT->SetSelectedPad(NULL);
|
---|
124 |
|
---|
125 | //
|
---|
126 | // This is necessary to get the expected bahviour of DrawClone
|
---|
127 | //
|
---|
128 | c->cd(1);
|
---|
129 | fAlpha->DrawCopy();
|
---|
130 |
|
---|
131 | c->cd(2);
|
---|
132 | fLength->DrawCopy();
|
---|
133 |
|
---|
134 | c->cd(3);
|
---|
135 | fDist->DrawCopy();
|
---|
136 |
|
---|
137 | c->cd(4);
|
---|
138 | fWidth->DrawCopy();
|
---|
139 |
|
---|
140 | c->Modified();
|
---|
141 | c->Update();
|
---|
142 |
|
---|
143 | return c;
|
---|
144 | }
|
---|
145 |
|
---|
146 | // --------------------------------------------------------------------------
|
---|
147 | //
|
---|
148 | // Creates a new canvas and draws the four histograms into it.
|
---|
149 | // Be careful: The histograms belongs to this object and won't get deleted
|
---|
150 | // together with the canvas.
|
---|
151 | //
|
---|
152 | void MHHillas::Draw(Option_t *)
|
---|
153 | {
|
---|
154 | if (!gPad)
|
---|
155 | MakeDefCanvas("Hillas", "Histograms of Hillas Parameters");
|
---|
156 |
|
---|
157 | gPad->Divide(2,2);
|
---|
158 |
|
---|
159 | gPad->cd(1);
|
---|
160 | fAlpha->Draw();
|
---|
161 |
|
---|
162 | gPad->cd(2);
|
---|
163 | fLength->Draw();
|
---|
164 |
|
---|
165 | gPad->cd(3);
|
---|
166 | fDist->Draw();
|
---|
167 |
|
---|
168 | gPad->cd(4);
|
---|
169 | fWidth->Draw();
|
---|
170 |
|
---|
171 | gPad->Modified();
|
---|
172 | gPad->Update();
|
---|
173 | }
|
---|