source: trunk/MagicSoft/Mars/mhistmc/MHMcEnergyMigration.cc@ 1985

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