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

Last change on this file since 3025 was 2612, 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 ";
69 t += fUseEventTime ? "Time" : "Event Number";
70
71 fGraph.SetName("MCamEvent");
72 fGraph.SetTitle(t);
73}
74
75// --------------------------------------------------------------------------
76//
77// Delete the corresponding camera display if available
78//
79MHPixVsTime::~MHPixVsTime()
80{
81}
82
83// --------------------------------------------------------------------------
84//
85// Get the event (MPixVsTime) the histogram might be filled with. If
86// it is not given, it is assumed, that it is filled with the argument
87// of the Fill function.
88// Looks for the camera geometry MGeomCam and resets the sum histogram.
89//
90Bool_t MHPixVsTime::SetupFill(const MParList *plist)
91{
92 fEvt = (MCamEvent*)plist->FindObject(fNameEvt, "MCamEvent");
93 if (!fEvt)
94 {
95 if (!fNameEvt.IsNull())
96 {
97 *fLog << err << GetDescriptor() << ": No " << fNameEvt <<" [MCamEvent] available..." << endl;
98 return kFALSE;
99 }
100 *fLog << warn << GetDescriptor() << ": No MCamEvent available..." << endl;
101 }
102
103 fCam = (MGeomCam*)plist->FindObject("MGeomCam");
104 if (!fCam)
105 {
106 *fLog << err << "MGeomCam not found... aborting." << endl;
107 return kFALSE;
108 }
109
110 if (fUseEventTime)
111 {
112 fTime = (MTime*)plist->FindObject("MTime");
113 if (!fTime)
114 {
115 *fLog << err << "MTime not found... abort." << endl;
116 return kFALSE;
117 }
118 }
119 else
120 {
121 fHeader = (MRawEvtHeader*)plist->FindObject("MRawEvtHeader");
122 if (!fHeader)
123 {
124 *fLog << err << "MRawEvtHeader not found... abort." << endl;
125 return kFALSE;
126 }
127 }
128
129 return kTRUE;
130}
131
132// --------------------------------------------------------------------------
133//
134// Fill the histograms with data from a MPixVsTime-Container.
135//
136Bool_t MHPixVsTime::Fill(const MParContainer *par, const Stat_t w)
137{
138 const MCamEvent *evt = par ? dynamic_cast<const MCamEvent*>(par) : fEvt;
139 if (!evt)
140 {
141 *fLog << err << dbginf << "No MCamEvent found..." << endl;
142 return kFALSE;
143 }
144
145 Double_t val = 0;
146 evt->GetPixelContent(val, fIndex, *fCam, fType);
147 if (TMath::IsNaN(val))
148 return kCONTINUE;
149
150 Double_t t = 0;
151 if (fUseEventTime)
152 t = fTime->GetAxisTime();
153 else
154 t = fHeader ? fHeader->GetDAQEvtNumber() : fGraph.GetN();
155
156 fGraph.SetPoint(fGraph.GetN(), t, val);
157 return kTRUE;
158}
159
160// --------------------------------------------------------------------------
161//
162// Scale the sum container with the number of entries
163//
164Bool_t MHPixVsTime::Finalize()
165{
166 return kTRUE;
167}
168
169// --------------------------------------------------------------------------
170//
171// Return fSum.
172//
173TH1 *MHPixVsTime::GetHistByName(const TString name)
174{
175 return fGraph.GetHistogram();
176}
177
178void MHPixVsTime::Draw(Option_t *)
179{
180 /*
181 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
182 pad->SetBorderMode(0);
183
184 pad->Divide(2,2);
185
186 pad->cd(1);
187 gPad->SetBorderMode(0);
188 gPad->Divide(1,1);
189 gPad->cd(1);
190 gPad->SetBorderMode(0);
191 fSum->Draw();
192
193 pad->cd(3);
194 gPad->SetBorderMode(0);
195 fSum->Draw("EPhist");
196
197 fGraph->GetHistogram()->SetXTitle("Time");
198 fGraph->GetHistogram()->GetXaxis()->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00");
199 fGraph->GetHistogram()->GetXaxis()->SetTimeDisplay(1);
200 fGraph->GetHistogram()->GetXaxis()->SetLabelSize(0.033);
201 */
202}
Note: See TracBrowser for help on using the repository browser.