source: trunk/MagicSoft/Mars/mhistmc/MHMcIntRate.cc@ 2017

Last change on this file since 2017 was 1974, 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
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// Drawing function. It creates its own canvas.
86//
87void MHMcIntRate::Draw(Option_t *option)
88{
89 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
90 pad->SetBorderMode(0);
91
92 AppendPad("");
93
94 pad->SetLogx();
95
96 fHist.Draw(option);
97
98 pad->Modified();
99 pad->Update();
100}
101
102// --------------------------------------------------------------------------
103//
104// Calculate the IntRate and set the 'ReadyToSave' flag.
105// The IntRate is calculated as the number of selected showers
106// (eg. triggered ones) divided by the number of all showers.
107// For error calculation Binomial errors are computed.
108//
109void MHMcIntRate::Calc(const MHMcDifRate &rate)
110{
111 /*const*/ TH1D &hist = (TH1D&)*rate.GetHist();
112 const TAxis &axis = *hist.GetXaxis();
113
114 //
115 // Set the binning from the two axis of one of the two histograms
116 //
117 MH::SetBinning(&fHist, &axis);
118
119 const Int_t nbinsx = axis.GetNbins();
120
121 for (Int_t i=1; i<=nbinsx; i++)
122 {
123 fHist.SetBinContent(i, hist.Integral(i, nbinsx, "width"));
124 fHist.SetBinError(i, hist.GetBinError(i)*axis.GetBinWidth(i));
125 }
126
127 fHist.SetEntries(hist.GetEntries());
128
129 SetReadyToSave();
130}
Note: See TracBrowser for help on using the repository browser.