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

Last change on this file since 1209 was 1209, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 4.4 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 "MHillas.h"
41#include "MHillasSrc.h"
42
43ClassImp(MHHillasSrc);
44
45// --------------------------------------------------------------------------
46//
47// Setup four histograms for Alpha, and Dist
48//
49MHHillasSrc::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//
79MHHillasSrc::~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//
90Bool_t 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 return kTRUE;
98}
99
100// --------------------------------------------------------------------------
101//
102// Draw clones of all two histograms. So that the object can be deleted
103// and the histograms are still visible in the canvas.
104// The cloned object are deleted together with the canvas if the canvas is
105// destroyed. If you want to handle dostroying the canvas you can get a
106// pointer to it from this function
107//
108TObject *MHHillasSrc::DrawClone(Option_t *opt) const
109{
110 TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Source dependant Parameters",
111 350, 500);
112 c->Divide(1, 2);
113
114 // FIXME: Display Source position
115
116 gROOT->SetSelectedPad(NULL);
117
118 //
119 // This is necessary to get the expected bahviour of DrawClone
120 //
121 c->cd(1);
122 fAlpha->DrawCopy();
123
124 c->cd(2);
125 fDist->DrawCopy();
126
127 c->Modified();
128 c->Update();
129
130 return c;
131}
132
133// --------------------------------------------------------------------------
134//
135// Creates a new canvas and draws the two histograms into it.
136// Be careful: The histograms belongs to this object and won't get deleted
137// together with the canvas.
138//
139void MHHillasSrc::Draw(Option_t *)
140{
141 if (!gPad)
142 MakeDefCanvas("Hillas", "Histograms of Src dependant Parameters", 350, 500);
143
144 // FIXME: Display Source position
145
146 gPad->Divide(1, 2);
147
148 gPad->cd(1);
149 fAlpha->Draw();
150
151 gPad->cd(2);
152 fDist->Draw();
153
154 gPad->Modified();
155 gPad->Update();
156}
Note: See TracBrowser for help on using the repository browser.