source: trunk/MagicSoft/Mars/mhist/MHHillas.cc@ 1205

Last change on this file since 1205 was 1205, checked in by tbretz, 23 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.7 KB
Line 
1<<<<<<< MHHillas.cc
2/* ======================================================================== *\
3!
4! *
5! * This file is part of MARS, the MAGIC Analysis and Reconstruction
6! * Software. It is distributed to you in the hope that it can be a useful
7! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
8! * It is distributed WITHOUT ANY WARRANTY.
9! *
10! * Permission to use, copy, modify and distribute this software and its
11! * documentation for any purpose is hereby granted without fee,
12! * provided that the above copyright notice appear in all copies and
13! * that both that copyright notice and this permission notice appear
14! * in supporting documentation. It is provided "as is" without express
15! * or implied warranty.
16! *
17!
18!
19! Author(s): Thomas Bretz 2001 <mailto:tbretz@uni-sw.gwdg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2001
22!
23!
24\* ======================================================================== */
25
26///////////////////////////////////////////////////////////////////////
27//
28// MHHillas
29//
30// This class contains histograms for every Hillas parameter
31//
32///////////////////////////////////////////////////////////////////////
33
34#include "MHHillas.h"
35
36#include <math.h>
37
38#include <TH1.h>
39#include <TPad.h>
40#include <TCanvas.h>
41
42#include "MHillas.h"
43
44ClassImp(MHHillas);
45
46// --------------------------------------------------------------------------
47//
48// Setup four histograms for Alpha, Width, Length and Dist
49//
50MHHillas::MHHillas (const char *name, const char *title)
51{
52 //
53 // set the name and title of this object
54 //
55 fName = name ? name : "MHHillas" ;
56 fTitle = title ? title : "Container for Hillas histograms" ;
57
58 //
59 // loop over all Pixels and create two histograms
60 // one for the Low and one for the High gain
61 // connect all the histogram with the container fHist
62 //
63 fAlpha = new TH1F("Alpha [deg]", "Alpha of Hillas", 90, 0, 90);
64 fWidth = new TH1F("Width [mm]", "Width of Hillas", 100, 0, 300);
65 fLength = new TH1F("Length [mm]", "Length of Hillas", 100, 0, 300);
66 fDist = new TH1F("Dist [mm]", "Dist of Hillas", 100, 0, 300);
67
68 fAlpha->SetDirectory(NULL);
69 fLength->SetDirectory(NULL);
70 fDist->SetDirectory(NULL);
71 fWidth->SetDirectory(NULL);
72
73 fAlpha->GetXaxis()->SetTitle("\\alpha [\\circ]");
74 fLength->GetXaxis()->SetTitle("Length [mm]");
75 fDist->GetXaxis()->SetTitle("Dist [mm]");
76 fWidth->GetXaxis()->SetTitle("Width [mm]");
77
78 fAlpha->GetYaxis()->SetTitle("Counts");
79 fLength->GetYaxis()->SetTitle("Counts");
80 fDist->GetYaxis()->SetTitle("Counts");
81 fWidth->GetYaxis()->SetTitle("Counts");
82}
83
84// --------------------------------------------------------------------------
85//
86// Delete the four histograms
87//
88MHHillas::~MHHillas()
89{
90 delete fAlpha;
91 delete fWidth;
92 delete fLength;
93 delete fDist;
94}
95
96// --------------------------------------------------------------------------
97//
98// Fill the four histograms with data from a MHillas-Container.
99// Be careful: Only call this with an object of type MHillas
100//
101Bool_t MHHillas::Fill(const MParContainer *par)
102{
103 const MHillas &h = *(MHillas*)par;
104
105 fAlpha ->Fill(fabs(h.GetAlpha()));
106 fWidth ->Fill(h.GetWidth());
107 fLength->Fill(h.GetLength());
108 fDist ->Fill(h.GetDist());
109
110 return kTRUE;
111}
112
113// --------------------------------------------------------------------------
114//
115// Draw clones of all four histograms. So that the object can be deleted
116// and the histograms are still visible in the canvas.
117// The cloned object are deleted together with the canvas if the canvas is
118// destroyed. If you want to handle dostroying the canvas you can get a
119// pointer to it from this function
120//
121TObject *MHHillas::DrawClone(Option_t *opt) const
122{
123 TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Hillas Parameters");
124 c->Divide(2, 2);
125
126 gROOT->SetSelectedPad(NULL);
127
128 //
129 // This is necessary to get the expected bahviour of DrawClone
130 //
131 c->cd(1);
132 fAlpha->DrawCopy();
133
134 c->cd(2);
135 fLength->DrawCopy();
136
137 c->cd(3);
138 fDist->DrawCopy();
139
140 c->cd(4);
141 fWidth->DrawCopy();
142
143 c->Modified();
144 c->Update();
145
146 return c;
147}
148
149// --------------------------------------------------------------------------
150//
151// Creates a new canvas and draws the four histograms into it.
152// Be careful: The histograms belongs to this object and won't get deleted
153// together with the canvas.
154//
155void MHHillas::Draw(Option_t *)
156{
157 if (!gPad)
158 MakeDefCanvas("Hillas", "Histograms of Hillas Parameters");
159
160 gPad->Divide(2,2);
161
162 gPad->cd(1);
163 fAlpha->Draw();
164
165 gPad->cd(2);
166 fLength->Draw();
167
168 gPad->cd(3);
169 fDist->Draw();
170
171 gPad->cd(4);
172 fWidth->Draw();
173
174 gPad->Modified();
175 gPad->Update();
176}
Note: See TracBrowser for help on using the repository browser.