source: trunk/MagicSoft/Mars/mhist/MHTimeDiffTime.cc@ 1502

Last change on this file since 1502 was 1295, checked in by wittek, 22 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// MHTimeDiffTime //
29// //
30// calculates the 2D-histogram time-difference vs. time //
31// //
32// //
33//////////////////////////////////////////////////////////////////////////////
34
35#include "MHTimeDiffTime.h"
36
37#include <TCanvas.h>
38
39#include "MTime.h"
40
41#include "MBinning.h"
42#include "MParList.h"
43
44#include "MLog.h"
45#include "MLogManip.h"
46
47ClassImp(MHTimeDiffTime);
48
49
50// --------------------------------------------------------------------------
51//
52// Default Constructor. It sets name and title of the histogram
53//
54MHTimeDiffTime::MHTimeDiffTime(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 : "MHTimeDiffTime";
61 fTitle = title ? title : "2-D histogram in time and time difference";
62
63 fHist.SetDirectory(NULL);
64
65 fHist.SetXTitle("\\Delta t [s]");
66 fHist.SetYTitle("t [s]");
67}
68
69// --------------------------------------------------------------------------
70//
71// Set the binnings and prepare the filling of the histogram
72//
73Bool_t MHTimeDiffTime::SetupFill(const MParList *plist)
74{
75 fTime = (MTime*)plist->FindObject("MTime");
76 if (!fTime)
77 {
78 *fLog << err << dbginf << "MTime not found... aborting." << endl;
79 return kFALSE;
80 }
81
82 const MBinning* binsdtime = (MBinning*)plist->FindObject("BinningTimeDiff");
83 const MBinning* binstime = (MBinning*)plist->FindObject("BinningTime");
84 if (!binstime || !binsdtime)
85 {
86 *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
87 return kFALSE;
88 }
89
90 SetBinning(&fHist, binsdtime, binstime);
91
92 return kTRUE;
93}
94
95// --------------------------------------------------------------------------
96//
97// Draw a copy of the histogram
98//
99TObject *MHTimeDiffTime::DrawClone(Option_t *opt) const
100{
101
102 TCanvas &c = *MakeDefCanvas("DiffTimeTime", "Distrib of \\Delta t, time");
103
104 c.Divide(2, 2);
105
106 gROOT->SetSelectedPad(NULL);
107
108 TH1D *h;
109
110 c.cd(1);
111 h = ((TH2*)&fHist)->ProjectionX("ProjX-sumtime", -1, 9999, "E");
112
113 h->SetTitle("Distribution of \\Delta t [s]");
114 h->SetXTitle("\\Delta t [s]");
115 h->SetYTitle("Counts");
116
117 h->Draw(opt);
118 h->SetBit(kCanDelete);
119 gPad->SetLogy();
120
121 c.cd(2);
122 h = ((TH2*)&fHist)->ProjectionY("ProjY-sumtimediff", -1, 9999, "E");
123
124 h->SetTitle("Distribution of time [s]");
125 h->SetXTitle("time [s]");
126 h->SetYTitle("Counts");
127
128 h->Draw(opt);
129 h->SetBit(kCanDelete);
130
131 c.cd(3);
132 ((TH2*)&fHist)->DrawCopy(opt);
133
134 c.Modified();
135 c.Update();
136
137 return &c;
138}
139
140// --------------------------------------------------------------------------
141//
142// Draw the histogram
143//
144void MHTimeDiffTime::Draw(Option_t *opt)
145{
146 if (!gPad)
147 MakeDefCanvas("DiffTimeTime", "Distrib of \\Delta t, time");
148
149 gPad->Divide(2,2);
150
151 TH1D *h;
152
153 gPad->cd(1);
154 h = fHist.ProjectionX("ProjX_sumtime", -1, 9999, "E");
155
156 h->SetTitle("Distribution of \\Delta t [s]");
157 h->SetXTitle("\\Delta t [s]");
158 h->SetYTitle("Counts");
159
160 h->Draw(opt);
161 h->SetBit(kCanDelete);
162 gPad->SetLogy();
163
164 gPad->cd(2);
165 h = fHist.ProjectionY("ProjY_sumtimediff", -1, 9999, "E");
166
167 h->SetTitle("Distribution of time [s]");
168 h->SetXTitle("time [s]");
169 h->SetYTitle("Counts");
170
171 h->Draw(opt);
172 h->SetBit(kCanDelete);
173
174 gPad->cd(3);
175 fHist.DrawCopy(opt);
176
177 gPad->Modified();
178 gPad->Update();
179
180}
181
182// --------------------------------------------------------------------------
183//
184// Fill the histogram
185//
186Bool_t MHTimeDiffTime::Fill(const MParContainer *par)
187{
188 const Int_t time = fTime->GetTimeLo();
189
190 fHist.Fill(0.0001*(time-fLastTime), 0.0001*time);
191
192 fLastTime = time;
193
194 return kTRUE;
195}
196
197
198
199
Note: See TracBrowser for help on using the repository browser.