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

Last change on this file since 2124 was 2043, checked in by tbretz, 22 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
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, const Stat_t w)
113{
114 MHillasSrc &hil = *(MHillasSrc*)par;
115
116 fHist.Fill(fabs(hil.GetAlpha()), fEnergy->GetEnergy(),
117 fMcEvt->GetTelescopeTheta()*kRad2Deg, w);
118
119 return kTRUE;
120}
121
122// --------------------------------------------------------------------------
123//
124// Draw the histogram
125//
126void MHAlphaEnergyTheta::Draw(Option_t *opt)
127{
128 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
129 pad->SetBorderMode(0);
130
131 AppendPad("");
132
133 pad->Divide(2,2);
134
135 TH1 *h;
136
137 pad->cd(1);
138 gPad->SetBorderMode(0);
139 h = fHist.Project3D("expro");
140 h->SetTitle("Distribution of \\alpha [\\circ]");
141 h->SetXTitle("\\alpha [\\circ]");
142 h->SetYTitle("Counts");
143 h->Draw(opt);
144 h->SetBit(kCanDelete);
145
146 pad->cd(2);
147 gPad->SetBorderMode(0);
148 gPad->SetLogx();
149 h = fHist.Project3D("eypro");
150 h->SetTitle("Distribution of E-est [GeV]");
151 h->SetXTitle("E_{est} [GeV]");
152 h->SetYTitle("Counts");
153 h->Draw(opt);
154 h->SetBit(kCanDelete);
155
156 pad->cd(3);
157 gPad->SetBorderMode(0);
158 h = fHist.Project3D("ezpro");
159 h->SetTitle("Distribution of \\Theta [\\circ]");
160 h->SetXTitle("\\Theta [\\circ]");
161 h->SetYTitle("Counts");
162 h->Draw(opt);
163 h->SetBit(kCanDelete);
164
165 pad->cd(4);
166 gPad->SetBorderMode(0);
167 fHist.Draw(opt);
168
169 pad->Modified();
170 pad->Update();
171}
Note: See TracBrowser for help on using the repository browser.