source: trunk/MagicSoft/Mars/mhist/MHMcIntRate.cc@ 1361

Last change on this file since 1361 was 1228, checked in by tbretz, 23 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.8 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
47// -------------------------------------------------------------------------
48//
49// Default Constructor.
50//
51MHMcIntRate::MHMcIntRate(const char *name, const char *title)
52 : fHist()
53{
54 fName = name ? name : "MHMcIntRate";
55 fTitle = title ? title : "Integral 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 fHist.SetDirectory(NULL);
65
66 fHist.SetXTitle("E [GeV]");
67 fHist.SetYTitle("Rate [Hz]");
68}
69
70void MHMcIntRate::SetName(const char *name)
71{
72 fName = name;
73 fHist.SetName(name);
74 fHist.SetDirectory(NULL);
75}
76
77void MHMcIntRate::SetTitle(const char *title)
78{
79 fTitle = title;
80 fHist.SetTitle(title);
81}
82
83//-------------------------------------------------------------------------
84//
85// Defualt Destructor
86//
87MHMcIntRate::~MHMcIntRate()
88{
89}
90
91// ------------------------------------------------------------------------
92//
93// Drawing function. It creates its own canvas.
94//
95void MHMcIntRate::Draw(Option_t *option)
96{
97 if (!gPad)
98 MH::MakeDefCanvas(&fHist);
99
100 gPad->SetLogx();
101
102 fHist.Draw(option);
103
104 gPad->Modified();
105 gPad->Update();
106}
107
108TObject *MHMcIntRate::DrawClone(Option_t *option) const
109{
110 TCanvas *c = MH::MakeDefCanvas(&fHist);
111
112 c->SetLogx();
113
114 //
115 // This is necessary to get the expected bahviour of DrawClone
116 //
117 gROOT->SetSelectedPad(NULL);
118
119 ((TH1D&)fHist).DrawCopy(option);
120
121 c->Modified();
122 c->Update();
123
124 return c;
125}
126
127// --------------------------------------------------------------------------
128//
129// Calculate the IntRate and set the 'ReadyToSave' flag.
130// The IntRate is calculated as the number of selected showers
131// (eg. triggered ones) divided by the number of all showers.
132// For error calculation Binomial errors are computed.
133//
134void MHMcIntRate::Calc(const MHMcDifRate &rate)
135{
136 /*const*/ TH1D &hist = (TH1D&)*rate.GetHist();
137 const TAxis &axis = *hist.GetXaxis();
138
139 //
140 // Set the binning from the two axis of one of the two histograms
141 //
142 MH::SetBinning(&fHist, &axis);
143
144 const Int_t nbinsx = axis.GetNbins();
145
146 for (Int_t i=1; i<=nbinsx; i++)
147 fHist.SetBinContent(i, hist.Integral(i, nbinsx, "width"));
148
149 SetReadyToSave();
150}
Note: See TracBrowser for help on using the repository browser.