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

Last change on this file since 1415 was 1415, checked in by wittek, 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 << "MHAlphaEnergyTheta : MEnergyEst not found... aborting." << endl;
82 return kFALSE;
83 }
84
85 fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
86 if (!fMcEvt)
87 {
88 *fLog << err << dbginf << "MHAlphaEnergyTheta : 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 << "MHAlphaEnergyTheta : 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 fHist.Sumw2();
106
107 return kTRUE;
108}
109
110// --------------------------------------------------------------------------
111//
112// Fill the histogram
113//
114Bool_t MHAlphaEnergyTheta::Fill(const MParContainer *par)
115{
116 MHillasSrc &hil = *(MHillasSrc*)par;
117
118 fHist.Fill(fabs(hil.GetAlpha()), fEnergy->GetEnergy(), fMcEvt->GetTheta()*kRad2Deg);
119
120 return kTRUE;
121}
122
123// --------------------------------------------------------------------------
124//
125// Draw the histogram
126//
127void MHAlphaEnergyTheta::Draw(Option_t *opt)
128{
129 if (!gPad)
130 MakeDefCanvas("AlphaEnergyTheta", fTitle);
131
132 gPad->Divide(2,2);
133
134 TH1 *h;
135
136 gPad->cd(1);
137 h = fHist.Project3D("expro");
138
139 h->SetTitle("Distribution of \\alpha [\\circ]");
140 h->SetXTitle("\\alpha [\\circ]");
141 h->SetYTitle("Counts");
142
143 h->Draw(opt);
144 h->SetBit(kCanDelete);
145
146 gPad->cd(2);
147 h = fHist.Project3D("eypro");
148
149 h->SetTitle("Distribution of E-est [GeV]");
150 h->SetXTitle("E-est [GeV] ");
151 h->SetYTitle("Counts");
152
153 h->Draw(opt);
154 h->SetBit(kCanDelete);
155 gPad->SetLogx();
156
157 gPad->cd(3);
158 h = fHist.Project3D("ezpro");
159
160 h->SetTitle("Distribution of \\Theta [\\circ]");
161 h->SetXTitle("\\Theta [\\circ]");
162 h->SetYTitle("Counts");
163
164 h->Draw(opt);
165 h->SetBit(kCanDelete);
166
167 gPad->cd(4);
168 fHist.Draw(opt);
169
170 gPad->Modified();
171 gPad->Update();
172}
173
174// --------------------------------------------------------------------------
175//
176// Draw copies of the histogram
177//
178TObject *MHAlphaEnergyTheta::DrawClone(Option_t *opt) const
179{
180 TCanvas &c = *MakeDefCanvas("AlphaEnergyTheta", fTitle);
181 c.Divide(2, 2);
182
183 gROOT->SetSelectedPad(NULL);
184
185 TH1 *h;
186
187 c.cd(1);
188 h = ((TH3*)(&fHist))->Project3D("expro");
189
190 h->SetTitle("Distribution of \\alpha [\\circ]");
191 h->SetXTitle("\\alpha [\\circ]");
192 h->SetYTitle("Counts");
193
194 h->Draw(opt);
195 h->SetBit(kCanDelete);
196
197 c.cd(2);
198 h = ((TH3*)(&fHist))->Project3D("eypro");
199
200 h->SetTitle("Distribution of E-est [GeV]");
201 h->SetXTitle("E-est [GeV] ");
202 h->SetYTitle("Counts");
203
204 h->Draw(opt);
205 h->SetBit(kCanDelete);
206 gPad->SetLogx();
207
208 c.cd(3);
209 h = ((TH3*)(&fHist))->Project3D("ezpro");
210
211 h->SetTitle("Distribution of \\Theta [\\circ]");
212 h->SetXTitle("\\Theta [\\circ]");
213 h->SetYTitle("Counts");
214
215 h->Draw(opt);
216 h->SetBit(kCanDelete);
217
218 c.cd(4);
219 ((TH3&)fHist).DrawCopy(opt);
220
221 c.Modified();
222 c.Update();
223
224 return &c;
225}
226
Note: See TracBrowser for help on using the repository browser.