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

Last change on this file since 2015 was 2015, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 4.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 the histogram
110//
111void MHMcEnergyMigration::Draw(Option_t *opt)
112{
113 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(fHist);
114 pad->SetBorderMode(0);
115
116 AppendPad("");
117
118 pad->Divide(2,2);
119
120 TH1 *h;
121
122 pad->cd(1);
123 gPad->SetBorderMode(0);
124 gPad->SetLogx();
125 h = fHist.Project3D("ex_pro");
126 h->SetTitle("Distribution of E_{true}");
127 h->SetXTitle("E_{true} [GeV]");
128 h->Draw(opt);
129 h->SetBit(kCanDelete);
130
131 pad->cd(2);
132 gPad->SetBorderMode(0);
133 gPad->SetLogx();
134 h = fHist.Project3D("ey_pro");
135 h->SetTitle("Distribution of E_{est}");
136 h->SetXTitle("E_{est} [GeV]");
137 h->Draw(opt);
138 h->SetBit(kCanDelete);
139
140 pad->cd(3);
141 gPad->SetBorderMode(0);
142 h = fHist.Project3D("ez_pro");
143 h->SetTitle("Distribution of \\Theta");
144 h->SetXTitle("\\Theta [\\circ]");
145 h->Draw(opt);
146 h->SetBit(kCanDelete);
147
148 pad->cd(4);
149 gPad->SetBorderMode(0);
150 fHist.Draw(opt);
151
152 pad->Modified();
153 pad->Update();
154}
155
156// --------------------------------------------------------------------------
157//
158// Fill the histogram
159//
160Bool_t MHMcEnergyMigration::Fill(const MParContainer *par, Double_t w)
161{
162 // MHillasSrc &hil = *(MHillasSrc*)par;
163 // fHist.Fill(fMcEvt->GetEnergy(), hil.GetSize());
164
165 // get E-true from fMcEvt and E-est from fEnergy
166 fHist.Fill(fMcEvt->GetEnergy(), fEnergy->GetEnergy(), fMcEvt->GetTheta()*kRad2Deg);
167
168 return kTRUE;
169}
Note: See TracBrowser for help on using the repository browser.