source: trunk/MagicSoft/Mars/mhist/MHEnergyTime.cc@ 1858

Last change on this file since 1858 was 1330, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 4.6 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@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2002
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26// //
27// MHEnergyTime //
28// //
29//////////////////////////////////////////////////////////////////////////////
30
31#include "MHEnergyTime.h"
32
33#include <TCanvas.h>
34
35#include "MMcEvt.hxx"
36#include "MTime.h"
37
38#include "MH.h"
39#include "MBinning.h"
40
41#include "MLog.h"
42#include "MLogManip.h"
43
44#include "MParList.h"
45
46ClassImp(MHEnergyTime);
47
48// --------------------------------------------------------------------------
49//
50// Creates the three necessary histograms:
51// - selected showers (input)
52// - all showers (input)
53// - collection area (result)
54//
55MHEnergyTime::MHEnergyTime(const char *name, const char *title)
56{
57 // initialize the histogram for the distribution r vs E
58 //
59 // we set the energy range from 1 Gev to 10000 GeV (in log 5 orders
60 // of magnitude) and for each order we take 10 subdivision --> 50 xbins
61 //
62 // we set the radius range from 0 m to 500 m with 10 m bin --> 50 ybins
63
64
65 fName = name ? name : "MHEnergyTime";
66 fTitle = title ? title : "Data to Calculate Collection Area";
67
68 fHist.SetDirectory(NULL);
69
70 fHist.SetXTitle("E [GeV]");
71 fHist.SetYTitle("t [s]");
72 fHist.SetZTitle("N");
73}
74
75Bool_t MHEnergyTime::SetupFill(const MParList *plist)
76{
77 fTime = (MTime*)plist->FindObject("MTime");
78 if (!fTime)
79 {
80 *fLog << err << dbginf << "MTime not found... aborting." << endl;
81 return kFALSE;
82 }
83
84 const MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE");
85 const MBinning* binstime = (MBinning*)plist->FindObject("BinningTime");
86 if (!binsenergy || !binstime)
87 {
88 *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
89 return kFALSE;
90 }
91
92 SetBinning(&fHist, binsenergy, binstime);
93
94 return kTRUE;
95}
96
97// --------------------------------------------------------------------------
98//
99// Delete the three histograms
100//
101MHEnergyTime::~MHEnergyTime()
102{
103}
104
105// --------------------------------------------------------------------------
106//
107// Fill data into the histogram which contains all showers
108//
109Bool_t MHEnergyTime::Fill(const MParContainer *par)
110{
111 const MMcEvt &mcevt = *(MMcEvt*)par;
112
113 fHist.Fill(mcevt.GetEnergy(), 0.0001*fTime->GetTimeLo());
114
115 return kTRUE;
116}
117
118// --------------------------------------------------------------------------
119//
120// Draw the histogram with all showers
121//
122void MHEnergyTime::Draw(Option_t* option)
123{
124 if (!gPad)
125 MakeDefCanvas(&fHist);
126
127 fHist.DrawCopy(option);
128 gPad->SetLogy();
129
130 gPad->Modified();
131 gPad->Update();
132}
133
134// --------------------------------------------------------------------------
135//
136// Creates a new canvas and draws the histogram into it.
137// Be careful: The histogram belongs to this object and won't get deleted
138// together with the canvas.
139//
140TObject *MHEnergyTime::DrawClone(Option_t* option) const
141{
142 TCanvas *c = MakeDefCanvas(&fHist);
143
144 //
145 // This is necessary to get the expected bahviour of DrawClone
146 //
147 gROOT->SetSelectedPad(NULL);
148
149 ((TH2D&)fHist).DrawCopy(option);
150 gPad->SetLogy();
151
152 c->Modified();
153 c->Update();
154
155 return c;
156}
157
158// --------------------------------------------------------------------------
159//
160// Calculate the Efficiency (collection area) and set the 'ReadyToSave'
161// flag
162//
163void MHEnergyTime::Divide(const TH2D *h1, const TH2D *h2)
164{
165 // Description!
166
167 fHist.Sumw2();
168 fHist.Divide((TH2D*)h1, (TH2D*)h2);
169
170 SetReadyToSave();
171}
Note: See TracBrowser for help on using the repository browser.