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

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