source: trunk/MagicSoft/Mars/mhist/MHAlphaEnergyTime.cc@ 1215

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