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

Last change on this file since 2229 was 2173, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.2 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
49using namespace std;
50
51// --------------------------------------------------------------------------
52//
53// Default Constructor. It sets name and title of the histogram
54//
55MHTimeDiffTime::MHTimeDiffTime(const char *name, const char *title)
56 : fLastTime(0), fHist()
57{
58 //
59 // set the name and title of this object
60 //
61 fName = name ? name : "MHTimeDiffTime";
62 fTitle = title ? title : "2-D histogram in time and time difference";
63
64 fHist.SetDirectory(NULL);
65
66 fHist.SetXTitle("\\Delta t [s]");
67 fHist.SetYTitle("t [s]");
68}
69
70// --------------------------------------------------------------------------
71//
72// Set the binnings and prepare the filling of the histogram
73//
74Bool_t MHTimeDiffTime::SetupFill(const MParList *plist)
75{
76 fTime = (MTime*)plist->FindObject("MTime");
77 if (!fTime)
78 {
79 *fLog << err << dbginf << "MTime not found... aborting." << endl;
80 return kFALSE;
81 }
82
83 const MBinning* binsdtime = (MBinning*)plist->FindObject("BinningTimeDiff");
84 const MBinning* binstime = (MBinning*)plist->FindObject("BinningTime");
85 if (!binstime || !binsdtime)
86 {
87 *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
88 return kFALSE;
89 }
90
91 SetBinning(&fHist, binsdtime, binstime);
92
93 return kTRUE;
94}
95
96// --------------------------------------------------------------------------
97//
98// Draw the histogram
99//
100void MHTimeDiffTime::Draw(Option_t *opt)
101{
102 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
103 pad->SetBorderMode(0);
104
105 AppendPad("");
106
107 pad->Divide(2,2);
108
109 TH1D *h;
110
111 pad->cd(1);
112 gPad->SetLogy();
113 h = fHist.ProjectionX("ProjX_sumtime", -1, 9999, "E");
114 h->SetTitle("Distribution of \\Delta t [s]");
115 h->SetXTitle("\\Delta t [s]");
116 h->SetYTitle("Counts");
117 h->Draw(opt);
118 h->SetBit(kCanDelete);
119
120 pad->cd(2);
121 h = fHist.ProjectionY("ProjY_sumtimediff", -1, 9999, "E");
122 h->SetTitle("Distribution of time [s]");
123 h->SetXTitle("time [s]");
124 h->SetYTitle("Counts");
125 h->Draw(opt);
126 h->SetBit(kCanDelete);
127
128 pad->cd(3);
129 fHist.DrawCopy(opt);
130
131 pad->Modified();
132 pad->Update();
133}
134
135// --------------------------------------------------------------------------
136//
137// Fill the histogram
138//
139Bool_t MHTimeDiffTime::Fill(const MParContainer *par, const Stat_t w)
140{
141 const Double_t time = 200e-9*fTime->GetTimeLo() + fTime->GetTimeHi();
142
143 fHist.Fill(time-fLastTime, time, w);
144 fLastTime = time;
145
146 return kTRUE;
147}
148
149
150
151
Note: See TracBrowser for help on using the repository browser.