source: trunk/MagicSoft/Mars/mhist/MHTimeDiffTheta.cc@ 1211

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