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

Last change on this file since 1227 was 1227, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 5.2 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@uni-sw.gwdg.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// //
31//////////////////////////////////////////////////////////////////////////////
32
33#include "MHAlphaEnergyTheta.h"
34
35#include <TCanvas.h>
36
37#include "MMcEvt.hxx"
38#include "MHillasSrc.h"
39#include "MEnergyEst.h"
40
41#include "MBinning.h"
42#include "MParList.h"
43
44#include "MLog.h"
45#include "MLogManip.h"
46
47ClassImp(MHAlphaEnergyTheta);
48
49// --------------------------------------------------------------------------
50//
51// Default Constructor. It sets name and title only. Typically you won't
52// need to change this.
53//
54MHAlphaEnergyTheta::MHAlphaEnergyTheta(const char *name, const char *title)
55{
56 //
57 // set the name and title of this object
58 //
59 fName = name ? name : "MHAlphaEnergyTheta";
60 fTitle = title ? title : "3-D histogram in alpha, energy and theta";
61
62 fHist.SetDirectory(NULL);
63
64 fHist.GetXaxis()->SetTitle("\\alpha [\\circ]");
65 fHist.GetYaxis()->SetTitle("E_{est} [GeV]");
66 fHist.GetZaxis()->SetTitle("\\Theta [\\circ]");
67}
68
69Bool_t MHAlphaEnergyTheta::SetupFill(const MParList *plist)
70{
71 fEnergy = (MEnergyEst*)plist->FindObject("MEnergyEst");
72 if (!fEnergy)
73 {
74 *fLog << err << dbginf << "MEnergyEst not found... aborting." << endl;
75 return kFALSE;
76 }
77
78 fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
79 if (!fMcEvt)
80 {
81 *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
82 return kFALSE;
83 }
84
85 MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE");
86 MBinning* binsalpha = (MBinning*)plist->FindObject("BinningAlpha");
87 MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta");
88 if (!binsenergy || !binsalpha || !binstheta)
89 {
90 *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
91 return kFALSE;
92 }
93
94 SetBinning(&fHist, binsalpha, binsenergy, binstheta);
95
96 return kTRUE;
97}
98
99Bool_t MHAlphaEnergyTheta::Fill(const MParContainer *par)
100{
101 MHillasSrc &hil = *(MHillasSrc*)par;
102
103 fHist.Fill(hil.GetAlpha(), fEnergy->GetEnergy(), fMcEvt->GetTheta()*kRad2Deg);
104
105 return kTRUE;
106}
107
108void MHAlphaEnergyTheta::Draw(Option_t *opt)
109{
110 if (!gPad)
111 MakeDefCanvas("AlphaEnergyTheta", "Distrib of alpha, E, Theta");
112
113 gPad->Divide(2,2);
114
115 TH1 *h;
116
117 gPad->cd(1);
118 h = fHist.Project3D("x");
119 h->Draw(opt);
120 h->SetBit(kCanDelete);
121
122 gPad->cd(2);
123 h = fHist.Project3D("y");
124 h->Draw(opt);
125 h->SetBit(kCanDelete);
126
127 gPad->cd(3);
128 h = fHist.Project3D("z");
129 h->Draw(opt);
130 h->SetBit(kCanDelete);
131
132 gPad->cd(4);
133 fHist.Draw(opt);
134
135 gPad->Modified();
136 gPad->Update();
137}
138
139TObject *MHAlphaEnergyTheta::DrawClone(Option_t *opt) const
140{
141 TCanvas *c = MakeDefCanvas("AlphaEnergyTheta", "Distrib of alpha, E, Theta");
142 c->Divide(2, 2);
143
144 gROOT->SetSelectedPad(NULL);
145
146 //
147 // FIXME: ProjectionX,Y is not const within root
148 //
149 TH1 *h;
150
151 c->cd(1);
152 h = ((TH3*)(&fHist))->Project3D("x");
153 h->Draw(opt);
154 h->SetBit(kCanDelete);
155
156 c->cd(2);
157 h = ((TH3*)(&fHist))->Project3D("y");
158 h->Draw(opt);
159 h->SetBit(kCanDelete);
160
161 c->cd(3);
162 h = ((TH3*)(&fHist))->Project3D("z");
163 h->Draw(opt);
164 h->SetBit(kCanDelete);
165
166 c->cd(4);
167 ((TH3&)fHist).DrawCopy(opt);
168
169 c->Modified();
170 c->Update();
171
172 return c;
173}
174
175void MHAlphaEnergyTheta::Substract(const TH3D *h1, const TH3D *h2)
176{
177 MH::SetBinning(&fHist, (TH1*)h1);
178
179 fHist.Sumw2();
180 fHist.Add((TH1*)h1, (TH1*)h2, 1, -1); // Root: FIXME
181}
182
183void MHAlphaEnergyTheta::SetAlphaRange(Axis_t lo, Axis_t up)
184{
185 TAxis &axe = *fHist.GetXaxis();
186
187 //
188 // FIXME: ROOT Binning??? of projection
189 // root 3.02: SetRangeUser
190#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
191 axe.SetRange(axe.FindFixBin(lo), axe.FindFixBin(up));
192#else
193 axe.SetRangeUser(lo, up);
194#endif
195}
196
197TH2D *MHAlphaEnergyTheta::GetAlphaProjection(Axis_t lo, Axis_t up)
198{
199 SetAlphaRange(lo, up);
200 return (TH2D*)fHist.Project3D("yz");
201}
Note: See TracBrowser for help on using the repository browser.