source: trunk/Mars/mhistmc/MHMcIntRate.cc@ 18331

Last change on this file since 18331 was 2173, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.5 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// MHMcIntRate
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 "MHMcIntRate.h"
35
36#include <math.h>
37
38#include <TCanvas.h>
39
40#include "MH.h"
41#include "MBinning.h"
42
43#include "MHMcDifRate.h"
44
45ClassImp(MHMcIntRate);
46
47using namespace std;
48
49// -------------------------------------------------------------------------
50//
51// Default Constructor.
52//
53MHMcIntRate::MHMcIntRate(const char *name, const char *title)
54 : fHist()
55{
56 fName = name ? name : "MHMcIntRate";
57 fTitle = title ? title : "Integral Trigger Rate";
58
59 // - we initialize the histogram
60 // - we have to give diferent names for the diferent histograms because
61 // root don't allow us to have diferent histograms with the same name
62
63 fHist.SetName(fName);
64 fHist.SetTitle(fTitle);
65
66 fHist.SetDirectory(NULL);
67
68 fHist.SetXTitle("E [GeV]");
69 fHist.SetYTitle("Rate [Hz]");
70}
71
72void MHMcIntRate::SetName(const char *name)
73{
74 fName = name;
75 fHist.SetName(name);
76 fHist.SetDirectory(NULL);
77}
78
79void MHMcIntRate::SetTitle(const char *title)
80{
81 fTitle = title;
82 fHist.SetTitle(title);
83}
84
85// ------------------------------------------------------------------------
86//
87// Drawing function. It creates its own canvas.
88//
89void MHMcIntRate::Draw(Option_t *option)
90{
91 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
92 pad->SetBorderMode(0);
93
94 AppendPad("");
95
96 pad->SetLogx();
97
98 fHist.Draw(option);
99
100 pad->Modified();
101 pad->Update();
102}
103
104// --------------------------------------------------------------------------
105//
106// Calculate the IntRate and set the 'ReadyToSave' flag.
107// The IntRate is calculated as the number of selected showers
108// (eg. triggered ones) divided by the number of all showers.
109// For error calculation Binomial errors are computed.
110//
111void MHMcIntRate::Calc(const MHMcDifRate &rate)
112{
113 /*const*/ TH1D &hist = (TH1D&)*rate.GetHist();
114 const TAxis &axis = *hist.GetXaxis();
115
116 //
117 // Set the binning from the two axis of one of the two histograms
118 //
119 MH::SetBinning(&fHist, &axis);
120
121 const Int_t nbinsx = axis.GetNbins();
122
123 for (Int_t i=1; i<=nbinsx; i++)
124 {
125 fHist.SetBinContent(i, hist.Integral(i, nbinsx, "width"));
126 fHist.SetBinError(i, hist.GetBinError(i)*axis.GetBinWidth(i));
127 }
128
129 fHist.SetEntries(hist.GetEntries());
130
131 SetReadyToSave();
132}
Note: See TracBrowser for help on using the repository browser.