source: trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc@ 1210

Last change on this file since 1210 was 1210, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 5.0 KB
Line 
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 "MParList.h"
41
42#include "MHillas.h"
43#include "MHillasSrc.h"
44
45ClassImp(MHHillasSrc);
46
47// --------------------------------------------------------------------------
48//
49// Setup four histograms for Alpha, and Dist
50//
51MHHillasSrc::MHHillasSrc(const char *name, const char *title)
52{
53 //
54 // set the name and title of this object
55 //
56 fName = name ? name : "MHHillasSrc";
57 fTitle = title ? title : "Container for Hillas histograms";
58
59 //
60 // loop over all Pixels and create two histograms
61 // one for the Low and one for the High gain
62 // connect all the histogram with the container fHist
63 //
64 fAlpha = new TH1F("Alpha [deg]", "Alpha of Hillas", 90, 0, 90);
65 fDist = new TH1F("Dist [mm]", "Dist of Hillas", 100, 0, 600);
66
67 fAlpha->SetDirectory(NULL);
68 fDist->SetDirectory(NULL);
69
70 fAlpha->GetXaxis()->SetTitle("\\alpha [\\circ]");
71 fDist->GetXaxis()->SetTitle("Dist [mm]");
72
73 fAlpha->GetYaxis()->SetTitle("Counts");
74 fDist->GetYaxis()->SetTitle("Counts");
75}
76
77// --------------------------------------------------------------------------
78//
79// Delete the four histograms
80//
81MHHillasSrc::~MHHillasSrc()
82{
83 delete fAlpha;
84 delete fDist;
85}
86
87// --------------------------------------------------------------------------
88//
89// Setup the Binning for the histograms automatically if the correct
90// instances of MBinning (with the names 'BinningAlpha' and 'BinningDist')
91// are found in the parameter list
92//
93Bool_t MHHillasSrc::SetupFill(const MParList *plist)
94{
95 const MBinning* binsa = (MBinning*)plist->FindObject("BinningAlpha");
96 const MBinning* binsd = (MBinning*)plist->FindObject("BinningDist");
97
98 if (binsa)
99 SetBinning(fAlpha, binsa);
100
101 if (binsd)
102 SetBinning(fDist, binsd);
103
104 return kTRUE;
105}
106
107// --------------------------------------------------------------------------
108//
109// Fill the four histograms with data from a MHillas-Container.
110// Be careful: Only call this with an object of type MHillas
111//
112Bool_t MHHillasSrc::Fill(const MParContainer *par)
113{
114 const MHillasSrc &h = *(MHillasSrc*)par;
115
116 fAlpha->Fill(fabs(h.GetAlpha()));
117 fDist ->Fill(h.GetDist());
118
119 return kTRUE;
120}
121
122// --------------------------------------------------------------------------
123//
124// Draw clones of all two histograms. So that the object can be deleted
125// and the histograms are still visible in the canvas.
126// The cloned object are deleted together with the canvas if the canvas is
127// destroyed. If you want to handle dostroying the canvas you can get a
128// pointer to it from this function
129//
130TObject *MHHillasSrc::DrawClone(Option_t *opt) const
131{
132 TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Source dependant Parameters",
133 350, 500);
134 c->Divide(1, 2);
135
136 // FIXME: Display Source position
137
138 gROOT->SetSelectedPad(NULL);
139
140 //
141 // This is necessary to get the expected bahviour of DrawClone
142 //
143 c->cd(1);
144 fAlpha->DrawCopy();
145
146 c->cd(2);
147 fDist->DrawCopy();
148
149 c->Modified();
150 c->Update();
151
152 return c;
153}
154
155// --------------------------------------------------------------------------
156//
157// Creates a new canvas and draws the two histograms into it.
158// Be careful: The histograms belongs to this object and won't get deleted
159// together with the canvas.
160//
161void MHHillasSrc::Draw(Option_t *)
162{
163 if (!gPad)
164 MakeDefCanvas("Hillas", "Histograms of Src dependant Parameters", 350, 500);
165
166 // FIXME: Display Source position
167
168 gPad->Divide(1, 2);
169
170 gPad->cd(1);
171 fAlpha->Draw();
172
173 gPad->cd(2);
174 fDist->Draw();
175
176 gPad->Modified();
177 gPad->Update();
178}
Note: See TracBrowser for help on using the repository browser.