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

Last change on this file since 1216 was 1216, checked in by tbretz, 23 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 5.7 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-2002
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 "MLog.h"
42#include "MLogManip.h"
43
44#include "MGeomCam.h"
45#include "MHillas.h"
46#include "MParList.h"
47
48ClassImp(MHHillas);
49
50// --------------------------------------------------------------------------
51//
52// Setup four histograms for Width, Length
53//
54MHHillas::MHHillas(const char *name, const char *title)
55 : fMm2Deg(1), fUseMmScale(kFALSE)
56{
57 //
58 // set the name and title of this object
59 //
60 fName = name ? name : "MHHillas";
61 fTitle = title ? title : "Container for Hillas histograms";
62
63 //
64 // loop over all Pixels and create two histograms
65 // one for the Low and one for the High gain
66 // connect all the histogram with the container fHist
67 //
68 fWidth = new TH1F("Width", "Width of Ellipse", 100, 0, 300);
69 fLength = new TH1F("Length", "Length of Ellipse", 100, 0, 300);
70
71 fLength->SetDirectory(NULL);
72 fWidth->SetDirectory(NULL);
73
74 fLength->GetXaxis()->SetTitle("Length [mm]");
75 fWidth->GetXaxis()->SetTitle("Width [mm]");
76
77 fLength->GetYaxis()->SetTitle("Counts");
78 fWidth->GetYaxis()->SetTitle("Counts");
79}
80
81// --------------------------------------------------------------------------
82//
83// Delete the four histograms
84//
85MHHillas::~MHHillas()
86{
87 delete fWidth;
88 delete fLength;
89}
90
91// --------------------------------------------------------------------------
92//
93// Setup the Binning for the histograms automatically if the correct
94// instances of MBinning (with the names 'BinningWidth' and 'BinningLength')
95// are found in the parameter list
96// Use this function if you want to set the conversion factor which
97// is used to convert the mm-scale in the camera plain into the deg-scale
98// used for histogram presentations. The conversion factor is part of
99// the camera geometry. Please create a corresponding MGeomCam container.
100//
101Bool_t MHHillas::SetupFill(const MParList *plist)
102{
103 const MBinning* binsw = (MBinning*)plist->FindObject("BinningWidth");
104 const MBinning* binsl = (MBinning*)plist->FindObject("BinningLength");
105 if (!binsw || !binsl)
106 {
107 *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
108 return kFALSE;
109 }
110
111 SetBinning(fWidth, binsw);
112 SetBinning(fLength, binsl);
113
114 const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
115 if (!geom)
116 {
117 *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
118 return kTRUE;
119 }
120
121 fLength->GetXaxis()->SetTitle("Length [\\circ]");
122 fWidth->GetXaxis()->SetTitle("Width [\\circ]");
123
124 fMm2Deg = geom->GetConvMm2Deg();
125
126 return kTRUE;
127}
128
129// --------------------------------------------------------------------------
130//
131// Fill the four histograms with data from a MHillas-Container.
132// Be careful: Only call this with an object of type MHillas
133//
134Bool_t MHHillas::Fill(const MParContainer *par)
135{
136 const MHillas &h = *(MHillas*)par;
137
138 if (fUseMmScale)
139 {
140 fWidth ->Fill(h.GetWidth());
141 fLength->Fill(h.GetLength());
142 }
143 else
144 {
145 fWidth ->Fill(fMm2Deg*h.GetWidth());
146 fLength->Fill(fMm2Deg*h.GetLength());
147 }
148
149 return kTRUE;
150}
151
152// --------------------------------------------------------------------------
153//
154// Draw clones of all four histograms. So that the object can be deleted
155// and the histograms are still visible in the canvas.
156// The cloned object are deleted together with the canvas if the canvas is
157// destroyed. If you want to handle dostroying the canvas you can get a
158// pointer to it from this function
159//
160TObject *MHHillas::DrawClone(Option_t *opt) const
161{
162 TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Hillas Parameters",
163 350, 500);
164 c->Divide(1, 2);
165
166 gROOT->SetSelectedPad(NULL);
167
168 //
169 // This is necessary to get the expected bahviour of DrawClone
170 //
171 c->cd(1);
172 fLength->DrawCopy();
173
174 c->cd(2);
175 fWidth->DrawCopy();
176
177 c->Modified();
178 c->Update();
179
180 return c;
181}
182
183// --------------------------------------------------------------------------
184//
185// Creates a new canvas and draws the four histograms into it.
186// Be careful: The histograms belongs to this object and won't get deleted
187// together with the canvas.
188//
189void MHHillas::Draw(Option_t *)
190{
191 if (!gPad)
192 MakeDefCanvas("Hillas", "Histograms of Hillas Parameters", 350, 500);
193
194 gPad->Divide(1, 2);
195
196 gPad->cd(1);
197 fLength->Draw();
198
199 gPad->cd(2);
200 fWidth->Draw();
201
202 gPad->Modified();
203 gPad->Update();
204}
Note: See TracBrowser for help on using the repository browser.