source: trunk/MagicSoft/Mars/mhist/MHTimeDiffTheta.cc@ 1263

Last change on this file since 1263 was 1263, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 4.3 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// MHTimeDiffTheta //
29// //
30// //
31//////////////////////////////////////////////////////////////////////////////
32
33#include "MHTimeDiffTheta.h"
34
35#include <TCanvas.h>
36
37#include "MTime.h"
38#include "MMcEvt.hxx"
39
40#include "MBinning.h"
41#include "MParList.h"
42
43#include "MLog.h"
44#include "MLogManip.h"
45
46ClassImp(MHTimeDiffTheta);
47
48
49// --------------------------------------------------------------------------
50//
51// Default Constructor. It sets name and title only. Typically you won't
52// need to change this.
53//
54MHTimeDiffTheta::MHTimeDiffTheta(const char *name, const char *title)
55 : fLastTime(0), fHist()
56{
57 //
58 // set the name and title of this object
59 //
60 fName = name ? name : "MHTimeDiffTheta";
61 fTitle = title ? title : "2-D histogram in time and time difference";
62
63 fHist.SetDirectory(NULL);
64
65 fHist.GetXaxis()->SetTitle("\\Delta t [s]");
66 fHist.GetYaxis()->SetTitle("\\Theta [\\circ]");
67}
68
69Bool_t MHTimeDiffTheta::SetupFill(const MParList *plist)
70{
71 fTime = (MTime*)plist->FindObject("MTime");
72 if (!fTime)
73 {
74 *fLog << err << dbginf << "MTime 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 const MBinning* binsdtime = (MBinning*)plist->FindObject("BinningTimeDiff");
86 const MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta");
87 if (!binstheta || !binsdtime)
88 {
89 *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
90 return kFALSE;
91 }
92
93 SetBinning(&fHist, binsdtime, binstheta);
94
95 return kTRUE;
96}
97
98TObject *MHTimeDiffTheta::DrawClone(Option_t *opt) const
99{
100 TCanvas *c = MakeDefCanvas("DiffTimeTheta", "Distrib of Delta t, Theta");
101 c->Divide(2, 2);
102
103 gROOT->SetSelectedPad(NULL);
104
105 //
106 // FIXME: ProjectionX,Y is not const within root
107 //
108 TH1D *h;
109
110 c->cd(1);
111 h = ((TH2*)&fHist)->ProjectionX("ProX", -1, 9999, "E");
112 h->DrawCopy(opt);
113 delete h;
114 gPad->SetLogy();
115
116 c->cd(2);
117 h = ((TH2*)&fHist)->ProjectionY("ProY", -1, 9999, "E");
118 h->DrawCopy(opt);
119 delete h;
120
121 c->cd(3);
122 ((TH2*)&fHist)->DrawCopy(opt);
123
124 c->Modified();
125 c->Update();
126
127 return c;
128}
129
130void MHTimeDiffTheta::Draw(Option_t *opt)
131{
132 if (!gPad)
133 MakeDefCanvas("DiffTimeTheta", "Distrib of Delta t, Theta");
134
135 TH1D *h;
136
137 gPad->Divide(2,2);
138
139 gPad->cd(1);
140 h = fHist.ProjectionX("ProX", -1, 9999, "E");
141 h->DrawCopy(opt);
142 delete h;
143 gPad->SetLogy();
144
145 gPad->cd(2);
146 h = fHist.ProjectionY("ProY", -1, 9999, "E");
147 h->DrawCopy(opt);
148 delete h;
149
150 gPad->cd(3);
151 fHist.Draw(opt);
152
153 gPad->Modified();
154 gPad->Update();
155}
156
157Bool_t MHTimeDiffTheta::Fill(const MParContainer *par)
158{
159 const Int_t time = fTime->GetTimeLo();
160
161 fHist.Fill(0.0001*(time-fLastTime), fMcEvt->GetTheta()*kRad2Deg);
162 fLastTime = time;
163
164 return kTRUE;
165}
166
Note: See TracBrowser for help on using the repository browser.