source: trunk/MagicSoft/Mars/mhist/MHPixVsTime.cc@ 3043

Last change on this file since 3043 was 3043, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 5.3 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, 12/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MHPixVsTime
28//
29// A histogram to store the sum of camera events. This can be photons,
30// currents or enything else derived from MPixVsTime
31//
32/////////////////////////////////////////////////////////////////////////////
33#include "MHPixVsTime.h"
34
35#include <TCanvas.h>
36
37#include "MLog.h"
38#include "MLogManip.h"
39
40#include "MParList.h"
41#include "MCamEvent.h"
42
43#include "MGeomCam.h"
44
45#include "MRawEvtHeader.h"
46#include "MTime.h"
47
48ClassImp(MHPixVsTime);
49
50using namespace std;
51
52// --------------------------------------------------------------------------
53//
54// Initialize the name and title of the task.
55// Resets the sum histogram
56//
57MHPixVsTime::MHPixVsTime(Int_t idx, const char *name, const char *title)
58 : fIndex(idx), fEvt(NULL), fType(0)
59{
60 //
61 // set the name and title of this object
62 //
63 fName = name ? name : "MHPixVsTime";
64 fTitle = title ? title : "Average of MPixVsTimes";
65
66 TString t("Pixel Index #");
67 t += idx;
68 t += " vs Time";
69
70 fGraph.SetName("MCamEvent");
71 fGraph.SetTitle(t);
72}
73
74// --------------------------------------------------------------------------
75//
76// Delete the corresponding camera display if available
77//
78MHPixVsTime::~MHPixVsTime()
79{
80}
81
82// --------------------------------------------------------------------------
83//
84// Get the event (MPixVsTime) the histogram might be filled with. If
85// it is not given, it is assumed, that it is filled with the argument
86// of the Fill function.
87// Looks for the camera geometry MGeomCam and resets the sum histogram.
88//
89Bool_t MHPixVsTime::SetupFill(const MParList *plist)
90{
91 fEvt = (MCamEvent*)plist->FindObject(fNameEvt, "MCamEvent");
92 if (!fEvt)
93 {
94 if (!fNameEvt.IsNull())
95 {
96 *fLog << err << GetDescriptor() << ": No " << fNameEvt <<" [MCamEvent] available..." << endl;
97 return kFALSE;
98 }
99 *fLog << warn << GetDescriptor() << ": No MCamEvent available..." << endl;
100 }
101
102 fCam = (MGeomCam*)plist->FindObject("MGeomCam");
103 if (!fCam)
104 {
105 *fLog << err << "MGeomCam not found... aborting." << endl;
106 return kFALSE;
107 }
108
109 if (!fNameTime.IsNull())
110 {
111 fTime = (MTime*)plist->FindObject(fNameTime, "MTime");
112 if (!fTime)
113 {
114 *fLog << err << fNameTime << " [MTime] not found... abort." << endl;
115 return kFALSE;
116 }
117 }
118 else
119 {
120 fHeader = (MRawEvtHeader*)plist->FindObject("MRawEvtHeader");
121 if (!fHeader)
122 {
123 *fLog << err << "MRawEvtHeader not found... abort." << endl;
124 return kFALSE;
125 }
126 }
127
128 return kTRUE;
129}
130
131// --------------------------------------------------------------------------
132//
133// Fill the histograms with data from a MPixVsTime-Container.
134//
135Bool_t MHPixVsTime::Fill(const MParContainer *par, const Stat_t w)
136{
137 const MCamEvent *evt = par ? dynamic_cast<const MCamEvent*>(par) : fEvt;
138 if (!evt)
139 {
140 *fLog << err << dbginf << "No MCamEvent found..." << endl;
141 return kFALSE;
142 }
143
144 Double_t val = 0;
145 evt->GetPixelContent(val, fIndex, *fCam, fType);
146 if (TMath::IsNaN(val))
147 return kCONTINUE;
148
149 Double_t t = 0;
150 if (!fNameTime.IsNull())
151 t = fTime->GetAxisTime();
152 else
153 t = fHeader ? fHeader->GetDAQEvtNumber() : fGraph.GetN();
154
155 fGraph.SetPoint(fGraph.GetN(), t, val);
156 return kTRUE;
157}
158
159// --------------------------------------------------------------------------
160//
161// Scale the sum container with the number of entries
162//
163Bool_t MHPixVsTime::Finalize()
164{
165 return kTRUE;
166}
167
168// --------------------------------------------------------------------------
169//
170// Return fSum.
171//
172TH1 *MHPixVsTime::GetHistByName(const TString name)
173{
174 return fGraph.GetHistogram();
175}
176
177void MHPixVsTime::Draw(Option_t *)
178{
179 /*
180 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
181 pad->SetBorderMode(0);
182
183 pad->Divide(2,2);
184
185 pad->cd(1);
186 gPad->SetBorderMode(0);
187 gPad->Divide(1,1);
188 gPad->cd(1);
189 gPad->SetBorderMode(0);
190 fSum->Draw();
191
192 pad->cd(3);
193 gPad->SetBorderMode(0);
194 fSum->Draw("EPhist");
195
196 fGraph->GetHistogram()->SetXTitle("Time");
197 fGraph->GetHistogram()->GetXaxis()->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00");
198 fGraph->GetHistogram()->GetXaxis()->SetTimeDisplay(1);
199 fGraph->GetHistogram()->GetXaxis()->SetLabelSize(0.033);
200 */
201}
Note: See TracBrowser for help on using the repository browser.