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

Last change on this file since 2658 was 2173, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.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
52using namespace std;
53
54// --------------------------------------------------------------------------
55//
56// Default Constructor. It sets name and title of the histogram.
57//
58MHAlphaEnergyTheta::MHAlphaEnergyTheta(const char *name, const char *title)
59{
60 //
61 // set the name and title of this object
62 //
63 fName = name ? name : "MHAlphaEnergyTheta";
64 fTitle = title ? title : "3-D histogram in alpha, energy and theta";
65
66 fHist.SetDirectory(NULL);
67
68 fHist.SetTitle("3D-plot of alpha, E_{est}, Theta");
69 fHist.SetXTitle("\\alpha [\\circ]");
70 fHist.SetYTitle("E_{est} [GeV]");
71 fHist.SetZTitle("\\Theta [\\circ]");
72}
73
74// --------------------------------------------------------------------------
75//
76// Set binnings and prepare filling of the histogram
77//
78Bool_t MHAlphaEnergyTheta::SetupFill(const MParList *plist)
79{
80 fEnergy = (MEnergyEst*)plist->FindObject("MEnergyEst");
81 if (!fEnergy)
82 {
83 *fLog << err << dbginf << "MEnergyEst not found... aborting." << endl;
84 return kFALSE;
85 }
86
87 fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
88 if (!fMcEvt)
89 {
90 *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
91 return kFALSE;
92 }
93
94 MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE");
95 MBinning* binsalphaflux = (MBinning*)plist->FindObject("BinningAlphaFlux");
96 MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta");
97 if (!binsenergy || !binsalphaflux || !binstheta)
98 {
99 *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
100 return kFALSE;
101 }
102
103 SetBinning(&fHist, binsalphaflux, binsenergy, binstheta);
104
105 fHist.Sumw2();
106
107 return kTRUE;
108}
109
110// --------------------------------------------------------------------------
111//
112// Fill the histogram
113//
114Bool_t MHAlphaEnergyTheta::Fill(const MParContainer *par, const Stat_t w)
115{
116 MHillasSrc &hil = *(MHillasSrc*)par;
117
118 fHist.Fill(hil.GetAlpha(), fEnergy->GetEnergy(),
119 fMcEvt->GetTelescopeTheta()*kRad2Deg, w);
120
121 return kTRUE;
122}
123
124// --------------------------------------------------------------------------
125//
126// Draw the histogram
127//
128void MHAlphaEnergyTheta::Draw(Option_t *opt)
129{
130 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
131 pad->SetBorderMode(0);
132
133 AppendPad("");
134
135 pad->Divide(2,2);
136
137 TH1 *h;
138
139 pad->cd(1);
140 gPad->SetBorderMode(0);
141 h = fHist.Project3D("expro");
142 h->SetTitle("Distribution of \\alpha [\\circ]");
143 h->SetXTitle("\\alpha [\\circ]");
144 h->SetYTitle("Counts");
145 h->Draw(opt);
146 h->SetBit(kCanDelete);
147
148 pad->cd(2);
149 gPad->SetBorderMode(0);
150 gPad->SetLogx();
151 h = fHist.Project3D("eypro");
152 h->SetTitle("Distribution of E-est [GeV]");
153 h->SetXTitle("E_{est} [GeV]");
154 h->SetYTitle("Counts");
155 h->Draw(opt);
156 h->SetBit(kCanDelete);
157
158 pad->cd(3);
159 gPad->SetBorderMode(0);
160 h = fHist.Project3D("ezpro");
161 h->SetTitle("Distribution of \\Theta [\\circ]");
162 h->SetXTitle("\\Theta [\\circ]");
163 h->SetYTitle("Counts");
164 h->Draw(opt);
165 h->SetBit(kCanDelete);
166
167 pad->cd(4);
168 gPad->SetBorderMode(0);
169 fHist.Draw(opt);
170
171 pad->Modified();
172 pad->Update();
173}
Note: See TracBrowser for help on using the repository browser.