source: trunk/MagicSoft/Mars/mhist/MHAlphaEnergyTheta.cc@ 1668

Last change on this file since 1668 was 1668, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 5.9 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 1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
19! Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2002
22!
23!
24\* ======================================================================== */
25
26//////////////////////////////////////////////////////////////////////////////
27// //
28// MHAlphaEnergyTheta //
29// //
30// 3D-histogram in alpha, E-est and Theta //
31// //
32//////////////////////////////////////////////////////////////////////////////
33
34#include "MHAlphaEnergyTheta.h"
35
36#include <TCanvas.h>
37
38#include <math.h>
39
40#include "MMcEvt.hxx"
41#include "MHillasSrc.h"
42#include "MEnergyEst.h"
43
44#include "MBinning.h"
45#include "MParList.h"
46
47#include "MLog.h"
48#include "MLogManip.h"
49
50ClassImp(MHAlphaEnergyTheta);
51
52// --------------------------------------------------------------------------
53//
54// Default Constructor. It sets name and title of the histogram.
55//
56MHAlphaEnergyTheta::MHAlphaEnergyTheta(const char *name, const char *title)
57{
58 //
59 // set the name and title of this object
60 //
61 fName = name ? name : "MHAlphaEnergyTheta";
62 fTitle = title ? title : "3-D histogram in alpha, energy and theta";
63
64 fHist.SetDirectory(NULL);
65
66 fHist.SetTitle("3D-plot of alpha, E_{est}, Theta");
67 fHist.SetXTitle("\\alpha [\\circ]");
68 fHist.SetYTitle("E_{est} [GeV]");
69 fHist.SetZTitle("\\Theta [\\circ]");
70}
71
72// --------------------------------------------------------------------------
73//
74// Set binnings and prepare filling of the histogram
75//
76Bool_t MHAlphaEnergyTheta::SetupFill(const MParList *plist)
77{
78 fEnergy = (MEnergyEst*)plist->FindObject("MEnergyEst");
79 if (!fEnergy)
80 {
81 *fLog << err << dbginf << "MEnergyEst not found... aborting." << endl;
82 return kFALSE;
83 }
84
85 fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
86 if (!fMcEvt)
87 {
88 *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
89 return kFALSE;
90 }
91
92 MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE");
93 MBinning* binsalphaflux = (MBinning*)plist->FindObject("BinningAlphaFlux");
94 MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta");
95 if (!binsenergy || !binsalphaflux || !binstheta)
96 {
97 *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
98 return kFALSE;
99 }
100
101 SetBinning(&fHist, binsalphaflux, binsenergy, binstheta);
102
103 fHist.Sumw2();
104
105 return kTRUE;
106}
107
108// --------------------------------------------------------------------------
109//
110// Fill the histogram
111//
112Bool_t MHAlphaEnergyTheta::Fill(const MParContainer *par)
113{
114 MHillasSrc &hil = *(MHillasSrc*)par;
115
116 fHist.Fill(fabs(hil.GetAlpha()), fEnergy->GetEnergy(),
117 fMcEvt->GetTelescopeTheta()*kRad2Deg);
118
119 return kTRUE;
120}
121
122// --------------------------------------------------------------------------
123//
124// Draw the histogram
125//
126void MHAlphaEnergyTheta::Draw(Option_t *opt)
127{
128 if (!gPad)
129 MakeDefCanvas("AlphaEnergyTheta", fTitle);
130
131 gPad->Divide(2,2);
132
133 TH1 *h;
134
135 gPad->cd(1);
136 h = fHist.Project3D("expro");
137
138 h->SetTitle("Distribution of \\alpha [\\circ]");
139 h->SetXTitle("\\alpha [\\circ]");
140 h->SetYTitle("Counts");
141
142 h->Draw(opt);
143 h->SetBit(kCanDelete);
144
145 gPad->cd(2);
146 h = fHist.Project3D("eypro");
147
148 h->SetTitle("Distribution of E-est [GeV]");
149 h->SetXTitle("E_{est} [GeV]");
150 h->SetYTitle("Counts");
151
152 h->Draw(opt);
153 h->SetBit(kCanDelete);
154 gPad->SetLogx();
155
156 gPad->cd(3);
157 h = fHist.Project3D("ezpro");
158
159 h->SetTitle("Distribution of \\Theta [\\circ]");
160 h->SetXTitle("\\Theta [\\circ]");
161 h->SetYTitle("Counts");
162
163 h->Draw(opt);
164 h->SetBit(kCanDelete);
165
166 gPad->cd(4);
167 fHist.Draw(opt);
168
169 gPad->Modified();
170 gPad->Update();
171}
172
173// --------------------------------------------------------------------------
174//
175// Draw copies of the histogram
176//
177TObject *MHAlphaEnergyTheta::DrawClone(Option_t *opt) const
178{
179 TCanvas &c = *MakeDefCanvas("AlphaEnergyTheta", fTitle);
180 c.Divide(2, 2);
181
182 gROOT->SetSelectedPad(NULL);
183
184 TH1 *h;
185
186 c.cd(1);
187 h = ((TH3*)(&fHist))->Project3D(fName+"_expro");
188
189 h->SetTitle("Distribution of \\alpha [\\circ]");
190 h->SetXTitle("\\alpha [\\circ]");
191 h->SetYTitle("Counts");
192
193 h->Draw(opt);
194 h->SetBit(kCanDelete);
195
196 c.cd(2);
197 h = ((TH3*)(&fHist))->Project3D(fName+"_eypro");
198
199 h->SetTitle("Distribution of E-est [GeV]");
200 h->SetXTitle("E_{est} [GeV]");
201 h->SetYTitle("Counts");
202
203 h->Draw(opt);
204 h->SetBit(kCanDelete);
205 gPad->SetLogx();
206
207 c.cd(3);
208 h = ((TH3*)(&fHist))->Project3D(fName+"_ezpro");
209
210 h->SetTitle("Distribution of \\Theta [\\circ]");
211 h->SetXTitle("\\Theta [\\circ]");
212 h->SetYTitle("Counts");
213
214 h->Draw(opt);
215 h->SetBit(kCanDelete);
216
217 c.cd(4);
218 ((TH3&)fHist).DrawCopy(opt);
219
220 c.Modified();
221 c.Update();
222
223 return &c;
224}
225
Note: See TracBrowser for help on using the repository browser.