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 "MHillas.h"
|
---|
41 | #include "MHillasSrc.h"
|
---|
42 |
|
---|
43 | ClassImp(MHHillasSrc);
|
---|
44 |
|
---|
45 | // --------------------------------------------------------------------------
|
---|
46 | //
|
---|
47 | // Setup four histograms for Alpha, and Dist
|
---|
48 | //
|
---|
49 | MHHillasSrc::MHHillasSrc(const char *name, const char *title)
|
---|
50 | {
|
---|
51 | //
|
---|
52 | // set the name and title of this object
|
---|
53 | //
|
---|
54 | fName = name ? name : "MHHillasSrc" ;
|
---|
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 | fDist = new TH1F("Dist [mm]", "Dist of Hillas", 100, 0, 600);
|
---|
64 |
|
---|
65 | fAlpha->SetDirectory(NULL);
|
---|
66 | fDist->SetDirectory(NULL);
|
---|
67 |
|
---|
68 | fAlpha->GetXaxis()->SetTitle("\\alpha [\\circ]");
|
---|
69 | fDist->GetXaxis()->SetTitle("Dist [mm]");
|
---|
70 |
|
---|
71 | fAlpha->GetYaxis()->SetTitle("Counts");
|
---|
72 | fDist->GetYaxis()->SetTitle("Counts");
|
---|
73 | }
|
---|
74 |
|
---|
75 | // --------------------------------------------------------------------------
|
---|
76 | //
|
---|
77 | // Delete the four histograms
|
---|
78 | //
|
---|
79 | MHHillasSrc::~MHHillasSrc()
|
---|
80 | {
|
---|
81 | delete fAlpha;
|
---|
82 | delete fDist;
|
---|
83 | }
|
---|
84 |
|
---|
85 | // --------------------------------------------------------------------------
|
---|
86 | //
|
---|
87 | // Fill the four histograms with data from a MHillas-Container.
|
---|
88 | // Be careful: Only call this with an object of type MHillas
|
---|
89 | //
|
---|
90 | void MHHillasSrc::Fill(const MParContainer *par)
|
---|
91 | {
|
---|
92 | const MHillasSrc &h = *(MHillasSrc*)par;
|
---|
93 |
|
---|
94 | fAlpha->Fill(fabs(h.GetAlpha()));
|
---|
95 | fDist ->Fill(h.GetDist());
|
---|
96 | }
|
---|
97 |
|
---|
98 | // --------------------------------------------------------------------------
|
---|
99 | //
|
---|
100 | // Draw clones of all four histograms. So that the object can be deleted
|
---|
101 | // and the histograms are still visible in the canvas.
|
---|
102 | // The cloned object are deleted together with the canvas if the canvas is
|
---|
103 | // destroyed. If you want to handle dostroying the canvas you can get a
|
---|
104 | // pointer to it from this function
|
---|
105 | //
|
---|
106 | TObject *MHHillasSrc::DrawClone(Option_t *opt) const
|
---|
107 | {
|
---|
108 | TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Hillas Parameters",
|
---|
109 | 350, 500);
|
---|
110 | c->Divide(1, 2);
|
---|
111 |
|
---|
112 | gROOT->SetSelectedPad(NULL);
|
---|
113 |
|
---|
114 | //
|
---|
115 | // This is necessary to get the expected bahviour of DrawClone
|
---|
116 | //
|
---|
117 | c->cd(1);
|
---|
118 | fAlpha->DrawCopy();
|
---|
119 |
|
---|
120 | c->cd(2);
|
---|
121 | fDist->DrawCopy();
|
---|
122 |
|
---|
123 | c->Modified();
|
---|
124 | c->Update();
|
---|
125 |
|
---|
126 | return c;
|
---|
127 | }
|
---|
128 |
|
---|
129 | // --------------------------------------------------------------------------
|
---|
130 | //
|
---|
131 | // Creates a new canvas and draws the four histograms into it.
|
---|
132 | // Be careful: The histograms belongs to this object and won't get deleted
|
---|
133 | // together with the canvas.
|
---|
134 | //
|
---|
135 | void MHHillasSrc::Draw(Option_t *)
|
---|
136 | {
|
---|
137 | if (!gPad)
|
---|
138 | MakeDefCanvas("Hillas", "Histograms of Hillas Parameters", 350, 500);
|
---|
139 |
|
---|
140 | gPad->Divide(1, 2);
|
---|
141 |
|
---|
142 | gPad->cd(1);
|
---|
143 | fAlpha->Draw();
|
---|
144 |
|
---|
145 | gPad->cd(2);
|
---|
146 | fDist->Draw();
|
---|
147 |
|
---|
148 | gPad->Modified();
|
---|
149 | gPad->Update();
|
---|
150 | }
|
---|