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

Last change on this file since 1214 was 1214, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 3.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// 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 c->cd(1);
101 ((TH2*)&fHist)->ProjectionX("ProX", -1, 9999, "E")->DrawCopy(opt);
102 gPad->SetLogy();
103
104 c->cd(2);
105 ((TH2*)&fHist)->ProjectionY("ProY", -1, 9999, "E")->DrawCopy(opt);
106
107 c->cd(3);
108 ((TH2*)&fHist)->DrawCopy(opt);
109
110 c->Modified();
111 c->Update();
112
113 return c;
114}
115
116void MHTimeDiffTime::Draw(Option_t *opt)
117{
118 if (!gPad)
119 MakeDefCanvas("DiffTimeTime", "Distrib of \\Delta t, t");
120
121 gPad->Divide(2,2);
122
123 gPad->cd(1);
124 fHist.ProjectionX("ProX", -1, 9999, "E")->DrawCopy(opt);
125 gPad->SetLogy();
126
127 gPad->cd(2);
128 fHist.ProjectionY("ProY", -1, 9999, "E")->DrawCopy(opt);
129
130 gPad->cd(3);
131 fHist.DrawCopy(opt);
132
133 gPad->Modified();
134 gPad->Update();
135}
136
137Bool_t MHTimeDiffTime::Fill(const MParContainer *par)
138{
139 const Int_t time = fTime->GetTimeLo();
140
141 fHist.Fill(0.0001*(time-fLastTime), 0.0001*time);
142
143 fLastTime = time;
144
145 return kTRUE;
146}
147
Note: See TracBrowser for help on using the repository browser.