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

Last change on this file since 1213 was 1211, checked in by tbretz, 23 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@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 gPad->cd(1);
120 fHist.Project3D("x")->Draw(opt);
121
122 gPad->cd(2);
123 fHist.Project3D("y")->Draw(opt);
124
125 gPad->cd(3);
126 fHist.Project3D("z")->Draw(opt);
127
128 gPad->cd(4);
129 fHist.Draw(opt);
130
131 gPad->Modified();
132 gPad->Update();
133}
134
135TObject *MHAlphaEnergyTime::DrawClone(Option_t *opt) const
136{
137 TCanvas *c = MakeDefCanvas("DiffTimeTheta", "Distrib of \\Delta t, t");
138 c->Divide(2, 2);
139
140 gROOT->SetSelectedPad(NULL);
141
142 //
143 // FIXME: ProjectionX,Y is not const within root
144 //
145 c->cd(1);
146 ((TH3D*)(&fHist))->Project3D("x")->DrawCopy(opt);
147
148 c->cd(2);
149 ((TH3D*)(&fHist))->Project3D("y")->DrawCopy(opt);
150
151 c->cd(3);
152 ((TH3D*)(&fHist))->Project3D("z")->DrawCopy(opt);
153
154 c->cd(4);
155 ((TH3D*)(&fHist))->DrawCopy(opt);
156
157 c->Modified();
158 c->Update();
159
160 return c;
161}
162
163void MHAlphaEnergyTime::Substract(const TH3D *h1, const TH3D *h2)
164{
165 MH::SetBinning(&fHist, h1);
166
167 fHist.Sumw2();
168 fHist.Add((TH1*)h1, (TH1*)h2, 1, -1); // ROOT: FIXME!
169}
170
171void MHAlphaEnergyTime::SetAlphaRange(Axis_t lo, Axis_t up)
172{
173 TAxis &axe = *fHist.GetXaxis();
174
175 //
176 // FIXME: ROOT Binning??? of projection
177 // root 3.02: SetRangeUser
178 axe.SetRange(axe.FindFixBin(lo), axe.FindFixBin(up));
179}
180
181TH2D *MHAlphaEnergyTime::GetAlphaProjection(Axis_t lo, Axis_t up)
182{
183 SetAlphaRange(lo, up);
184 return (TH2D*)fHist.Project3D("yz");
185}
Note: See TracBrowser for help on using the repository browser.