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

Last change on this file since 3492 was 2461, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.8 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@astro.uni-wuerzburg.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#include "MHTimeDiffTime.h"
35
36#include <TCanvas.h>
37
38#include "MTime.h"
39
40#include "MBinning.h"
41#include "MParList.h"
42
43#include "MLog.h"
44#include "MLogManip.h"
45
46ClassImp(MHTimeDiffTime);
47
48using namespace std;
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 the histogram
98//
99void MHTimeDiffTime::Draw(Option_t *opt)
100{
101 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
102 pad->SetBorderMode(0);
103
104 AppendPad("");
105
106 pad->Divide(2,2);
107
108 TH1D *h;
109
110 pad->cd(1);
111 gPad->SetLogy();
112 h = fHist.ProjectionX("ProjX_sumtime", -1, 9999, "E");
113 h->SetTitle("Distribution of \\Delta t [s]");
114 h->SetXTitle("\\Delta t [s]");
115 h->SetYTitle("Counts");
116 h->Draw(opt);
117 h->SetBit(kCanDelete);
118
119 pad->cd(2);
120 h = fHist.ProjectionY("ProjY_sumtimediff", -1, 9999, "E");
121 h->SetTitle("Distribution of time [s]");
122 h->SetXTitle("time [s]");
123 h->SetYTitle("Counts");
124 h->Draw(opt);
125 h->SetBit(kCanDelete);
126
127 pad->cd(3);
128 fHist.DrawCopy(opt);
129
130 pad->Modified();
131 pad->Update();
132}
133
134// --------------------------------------------------------------------------
135//
136// Fill the histogram
137//
138Bool_t MHTimeDiffTime::Fill(const MParContainer *par, const Stat_t w)
139{
140 const Double_t time = *fTime;
141
142 fHist.Fill(time-fLastTime, time, w);
143 fLastTime = time;
144
145 return kTRUE;
146}
Note: See TracBrowser for help on using the repository browser.