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