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

Last change on this file since 2632 was 2461, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.9 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
48using namespace std;
49
50// --------------------------------------------------------------------------
51//
52// Creates the three necessary histograms:
53// - selected showers (input)
54// - all showers (input)
55// - collection area (result)
56//
57MHEnergyTime::MHEnergyTime(const char *name, const char *title)
58{
59 // initialize the histogram for the distribution r vs E
60 //
61 // we set the energy range from 1 Gev to 10000 GeV (in log 5 orders
62 // of magnitude) and for each order we take 10 subdivision --> 50 xbins
63 //
64 // we set the radius range from 0 m to 500 m with 10 m bin --> 50 ybins
65
66 fName = name ? name : "MHEnergyTime";
67 fTitle = title ? title : "Data to Calculate Collection Area";
68
69 fHist.SetDirectory(NULL);
70
71 fHist.SetXTitle("E [GeV]");
72 fHist.SetYTitle("t [s]");
73 fHist.SetZTitle("N");
74}
75
76Bool_t MHEnergyTime::SetupFill(const MParList *plist)
77{
78 fTime = (MTime*)plist->FindObject("MTime");
79 if (!fTime)
80 {
81 *fLog << err << dbginf << "MTime not found... aborting." << endl;
82 return kFALSE;
83 }
84
85 const MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE");
86 const MBinning* binstime = (MBinning*)plist->FindObject("BinningTime");
87 if (!binsenergy || !binstime)
88 {
89 *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
90 return kFALSE;
91 }
92
93 SetBinning(&fHist, binsenergy, binstime);
94
95 return kTRUE;
96}
97
98// --------------------------------------------------------------------------
99//
100// Fill data into the histogram which contains all showers
101//
102Bool_t MHEnergyTime::Fill(const MParContainer *par, const Stat_t w)
103{
104 const MMcEvt &mcevt = *(MMcEvt*)par;
105
106 fHist.Fill(mcevt.GetEnergy(), *fTime, w);
107
108 return kTRUE;
109}
110
111// --------------------------------------------------------------------------
112//
113// Draw the histogram with all showers
114//
115void MHEnergyTime::Draw(Option_t* option)
116{
117 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
118 pad->SetBorderMode(0);
119
120 AppendPad("");
121
122 pad->SetLogy();
123 fHist.DrawCopy(option);
124
125 pad->Modified();
126 pad->Update();
127}
128
129// --------------------------------------------------------------------------
130//
131// Calculate the Efficiency (collection area) and set the 'ReadyToSave'
132// flag
133//
134void MHEnergyTime::Divide(const TH2D *h1, const TH2D *h2)
135{
136 // Description!
137
138 fHist.Sumw2();
139 fHist.Divide((TH2D*)h1, (TH2D*)h2);
140
141 SetReadyToSave();
142}
Note: See TracBrowser for help on using the repository browser.