source: trunk/MagicSoft/Mars/mhist/MHCamEvent.cc@ 2221

Last change on this file since 2221 was 2221, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.1 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// MHCamEvent
28//
29/////////////////////////////////////////////////////////////////////////////
30#include "MHCamEvent.h"
31
32#include <TCanvas.h>
33
34#include "MLog.h"
35#include "MLogManip.h"
36
37#include "MParList.h"
38#include "MCamEvent.h"
39#include "MHCamera.h"
40
41#include "MGeomCam.h"
42#include "MGeomPix.h"
43
44ClassImp(MHCamEvent);
45
46using namespace std;
47
48// --------------------------------------------------------------------------
49//
50// Initialize the name and title of the task.
51// Resets the sum histogram
52//
53MHCamEvent::MHCamEvent(const char *name, const char *title)
54 : fSum(NULL), fEvt(NULL), fType(0)
55{
56 //
57 // set the name and title of this object
58 //
59 fName = name ? name : "MHCamEvent";
60 fTitle = title ? title : "Average of MCamEvents";
61}
62
63// --------------------------------------------------------------------------
64//
65// Delete the corresponding camera display if available
66//
67MHCamEvent::~MHCamEvent()
68{
69 if (fSum)
70 delete fSum;
71}
72
73// --------------------------------------------------------------------------
74//
75// Get the event (MCamEvent) the histogram might be filled with. If
76// it is not given, it is assumed, that it is filled with the argument
77// of the Fill function.
78// Looks for the camera geometry MGeomCam and resets the sum histogram.
79//
80Bool_t MHCamEvent::SetupFill(const MParList *plist)
81{
82 fEvt = (MCamEvent*)plist->FindObject(fNameEvt, "MCamEvent");
83 if (!fEvt)
84 {
85 if (!fNameEvt.IsNull())
86 {
87 *fLog << err << GetDescriptor() << ": No " << fNameEvt <<" [MCamEvent] available..." << endl;
88 return kFALSE;
89 }
90 *fLog << warn << GetDescriptor() << ": No MCamEvent available..." << endl;
91 }
92
93 MGeomCam *cam = (MGeomCam*)plist->FindObject("MGeomCam");
94 if (!cam)
95 *fLog << warn << GetDescriptor() << ": No MGeomCam found." << endl;
96
97 if (fSum)
98 delete (fSum);
99 fSum = new MHCamera(*cam, fNameEvt+";avg", fTitle);
100 fSum->SetYTitle("a.u.");
101
102 return kTRUE;
103}
104
105// --------------------------------------------------------------------------
106//
107// Fill the histograms with data from a MCamEvent-Container.
108//
109Bool_t MHCamEvent::Fill(const MParContainer *par, const Stat_t w)
110{
111 const MCamEvent *evt = par ? dynamic_cast<const MCamEvent*>(par) : fEvt;
112 if (!evt)
113 {
114 *fLog << err << dbginf << "No MCamEvent found..." << endl;
115 return kFALSE;
116 }
117 fSum->AddCamContent(*evt, fType);
118
119 return kTRUE;
120}
121
122// --------------------------------------------------------------------------
123//
124// Scale the sum container with the number of entries
125//
126Bool_t MHCamEvent::Finalize()
127{
128 if (fSum->GetEntries()>0)
129 fSum->Scale(100./fSum->GetEntries());
130 return kTRUE;
131}
132
133TH1 *MHCamEvent::GetHistByName(const TString name)
134{
135 return fSum;
136}
137
138void MHCamEvent::Draw(Option_t *)
139{
140 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
141 pad->SetBorderMode(0);
142
143 pad->Divide(2,2);
144
145 pad->cd(1);
146 gPad->SetBorderMode(0);
147 gPad->Divide(1,1);
148 gPad->cd(1);
149 gPad->SetBorderMode(0);
150 fSum->Draw();
151
152 pad->cd(3);
153 gPad->SetBorderMode(0);
154 fSum->Draw("EPhist");
155}
Note: See TracBrowser for help on using the repository browser.