source: trunk/MagicSoft/Mars/mhist/MHEnergyTheta.cc@ 2001

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