source: trunk/MagicSoft/Mars/mhist/MHMcDifRate.cc@ 1765

Last change on this file since 1765 was 1228, checked in by tbretz, 23 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.7 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): Javier Lopez 05/2001 <mailto:jlopez@ifae.es>
19! Author(s): Thomas Bretz 05/2001 <mailto:tbretz@uni-sw.gwdg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2001
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MHMcDifRate
29//
30// This class holds the information (histogram and fit function)
31// about the energy threshold for a particular trigger condition.
32//
33////////////////////////////////////////////////////////////////////////////
34#include "MHMcDifRate.h"
35
36#include <math.h>
37
38#include <TCanvas.h>
39
40#include "MH.h"
41#include "MBinning.h"
42
43#include "MHMcCollectionArea.h"
44
45ClassImp(MHMcDifRate);
46
47// -------------------------------------------------------------------------
48//
49// Default Constructor.
50//
51MHMcDifRate::MHMcDifRate(const char *name, const char *title)
52 : fHist()
53{
54 fName = name ? name : "MHMcDifRate";
55 fTitle = title ? title : "Differential Trigger Rate";
56
57 // - we initialize the histogram
58 // - we have to give diferent names for the diferent histograms because
59 // root don't allow us to have diferent histograms with the same name
60
61 fHist.SetName(fName);
62 fHist.SetTitle(fTitle);
63
64
65 fHist.SetDirectory(NULL);
66
67 fHist.SetXTitle("E [GeV]");
68 fHist.SetYTitle("dR/dE [Hz/GeV]");
69}
70
71void MHMcDifRate::SetName(const char *name)
72{
73 fName = name;
74 fHist.SetName(name);
75 fHist.SetDirectory(NULL);
76}
77
78void MHMcDifRate::SetTitle(const char *title)
79{
80 fTitle = title;
81 fHist.SetTitle(title);
82}
83
84//-------------------------------------------------------------------------
85//
86// Defualt Destructor
87//
88MHMcDifRate::~MHMcDifRate()
89{
90}
91
92// ------------------------------------------------------------------------
93//
94// Drawing function. It creates its own canvas.
95//
96void MHMcDifRate::Draw(Option_t *option)
97{
98 if (!gPad)
99 MH::MakeDefCanvas(&fHist);
100
101 gPad->SetLogx();
102
103 fHist.Draw(option);
104
105 gPad->Modified();
106 gPad->Update();
107}
108
109TObject *MHMcDifRate::DrawClone(Option_t *option) const
110{
111 TCanvas *c = MH::MakeDefCanvas(&fHist);
112
113 c->SetLogx();
114
115 //
116 // This is necessary to get the expected bahviour of DrawClone
117 //
118 gROOT->SetSelectedPad(NULL);
119
120 ((TH1D&)fHist).DrawCopy(option);
121
122 c->Modified();
123 c->Update();
124
125 return c;
126}
127/*
128void MHMcDifRate::Calc(const TH2D &hsel, const TH2D &hall)
129{
130 //
131 // Set the binning from the two axis of one of the two histograms
132 //
133 MH::SetBinning(&fHist, ((TH2D&)hsel).GetXaxis(), ((TH2D&)hsel).GetYaxis());
134
135 //
136 // This is necessary to initialize thze error calculation correctly
137 // (Nothing important: The histogram set the size of its internal
138 // array storing the errors to the correct size)
139 //
140 fHist.Sumw2();
141
142 //
143 // Calculate the efficiency by dividing the number of selected
144 // (eg. triggered) showers by the number of all showers per bin.
145 // Both histograms are weighted with weight 1, and for the error
146 // calculation we assume a binomial error calculation.
147 //
148 fHist.Divide((TH2D*)&hsel, (TH2D*)&hall, 1, 1, "B");
149
150 SetReadyToSave();
151}
152*/
153
154// --------------------------------------------------------------------------
155//
156// Calculate the DifRate and set the 'ReadyToSave' flag.
157// The DifRate is calculated as the number of selected showers
158// (eg. triggered ones) divided by the number of all showers.
159// For error calculation Binomial errors are computed.
160//
161void MHMcDifRate::Calc(const MHMcCollectionArea &cola, const TF1 &spect)
162{
163 /*const*/ TH1D &hcol = (TH1D&)*cola.GetHist();
164
165 fHist.Reset();
166
167 //
168 // Set the binning from the two axis of one of the two histograms
169 //
170 MH::SetBinning(&fHist, hcol.GetXaxis());
171
172 //
173 // This is necessary to initialize thze error calculation correctly
174 // (Nothing important: The histogram set the size of its internal
175 // array storing the errors to the correct size)
176 //
177 fHist.Sumw2();
178
179 fHist.Add(&hcol);
180 fHist.Multiply((TF1*)&spect);
181
182 SetReadyToSave();
183}
Note: See TracBrowser for help on using the repository browser.