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

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