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

Last change on this file since 2566 was 2244, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.4 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
45ClassImp(MHPixVsTime);
46
47using namespace std;
48
49// --------------------------------------------------------------------------
50//
51// Initialize the name and title of the task.
52// Resets the sum histogram
53//
54MHPixVsTime::MHPixVsTime(Int_t idx, const char *name, const char *title)
55 : fIndex(idx), fEvt(NULL), fType(0)
56{
57 //
58 // set the name and title of this object
59 //
60 fName = name ? name : "MHPixVsTime";
61 fTitle = title ? title : "Average of MPixVsTimes";
62
63 TString t("Pixel Index #");
64 t += idx;
65 t += " vs. time";
66
67 fGraph.SetName("MCamEvent");
68 fGraph.SetTitle(t);
69}
70
71// --------------------------------------------------------------------------
72//
73// Delete the corresponding camera display if available
74//
75MHPixVsTime::~MHPixVsTime()
76{
77}
78
79// --------------------------------------------------------------------------
80//
81// Get the event (MPixVsTime) the histogram might be filled with. If
82// it is not given, it is assumed, that it is filled with the argument
83// of the Fill function.
84// Looks for the camera geometry MGeomCam and resets the sum histogram.
85//
86Bool_t MHPixVsTime::SetupFill(const MParList *plist)
87{
88 fEvt = (MCamEvent*)plist->FindObject(fNameEvt, "MCamEvent");
89 if (!fEvt)
90 {
91 if (!fNameEvt.IsNull())
92 {
93 *fLog << err << GetDescriptor() << ": No " << fNameEvt <<" [MCamEvent] available..." << endl;
94 return kFALSE;
95 }
96 *fLog << warn << GetDescriptor() << ": No MCamEvent available..." << endl;
97 }
98
99 fCam = (MGeomCam*)plist->FindObject("MGeomCam");
100 if (!fCam)
101 {
102 *fLog << err << "MGeomCam not found... aborting." << endl;
103 return kFALSE;
104 }
105
106 return kTRUE;
107}
108
109// --------------------------------------------------------------------------
110//
111// Fill the histograms with data from a MPixVsTime-Container.
112//
113Bool_t MHPixVsTime::Fill(const MParContainer *par, const Stat_t w)
114{
115 const MCamEvent *evt = par ? dynamic_cast<const MCamEvent*>(par) : fEvt;
116 if (!evt)
117 {
118 *fLog << err << dbginf << "No MCamEvent found..." << endl;
119 return kFALSE;
120 }
121
122 Double_t val = 0;
123 evt->GetPixelContent(val, fIndex, *fCam, fType);
124 if (TMath::IsNaN(val))
125 return kCONTINUE;
126
127 fGraph.SetPoint(fGraph.GetN(), fGraph.GetN(), val);
128 return kTRUE;
129}
130
131// --------------------------------------------------------------------------
132//
133// Scale the sum container with the number of entries
134//
135Bool_t MHPixVsTime::Finalize()
136{
137 return kTRUE;
138}
139
140// --------------------------------------------------------------------------
141//
142// Return fSum.
143//
144TH1 *MHPixVsTime::GetHistByName(const TString name)
145{
146 return fGraph.GetHistogram();
147}
148
149void MHPixVsTime::Draw(Option_t *)
150{
151 /*
152 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
153 pad->SetBorderMode(0);
154
155 pad->Divide(2,2);
156
157 pad->cd(1);
158 gPad->SetBorderMode(0);
159 gPad->Divide(1,1);
160 gPad->cd(1);
161 gPad->SetBorderMode(0);
162 fSum->Draw();
163
164 pad->cd(3);
165 gPad->SetBorderMode(0);
166 fSum->Draw("EPhist");
167 */
168}
Note: See TracBrowser for help on using the repository browser.