source: trunk/MagicSoft/Mars/mhistmc/MHMcDifRate.cc@ 2951

Last change on this file since 2951 was 2017, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.3 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// Drawing function. It creates its own canvas.
87//
88void MHMcDifRate::Draw(Option_t *option)
89{
90 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
91 pad->SetBorderMode(0);
92
93 AppendPad("");
94
95 pad->SetLogx();
96
97 fHist.Draw(option);
98
99 pad->Modified();
100 pad->Update();
101}
102/*
103void MHMcDifRate::Calc(const TH2D &hsel, const TH2D &hall)
104{
105 //
106 // Set the binning from the two axis of one of the two histograms
107 //
108 MH::SetBinning(&fHist, ((TH2D&)hsel).GetXaxis(), ((TH2D&)hsel).GetYaxis());
109
110 //
111 // This is necessary to initialize thze error calculation correctly
112 // (Nothing important: The histogram set the size of its internal
113 // array storing the errors to the correct size)
114 //
115 fHist.Sumw2();
116
117 //
118 // Calculate the efficiency by dividing the number of selected
119 // (eg. triggered) showers by the number of all showers per bin.
120 // Both histograms are weighted with weight 1, and for the error
121 // calculation we assume a binomial error calculation.
122 //
123 fHist.Divide((TH2D*)&hsel, (TH2D*)&hall, 1, 1, "B");
124
125 SetReadyToSave();
126}
127*/
128
129// --------------------------------------------------------------------------
130//
131// Calculate the DifRate and set the 'ReadyToSave' flag.
132// The DifRate is calculated as the number of selected showers
133// (eg. triggered ones) divided by the number of all showers.
134// For error calculation Binomial errors are computed.
135//
136void MHMcDifRate::Calc(const MHMcCollectionArea &cola, const TF1 &spect)
137{
138 /*const*/ TH1D &hcol = (TH1D&)*cola.GetHist();
139
140 fHist.Reset();
141
142 //
143 // Set the binning from the two axis of one of the two histograms
144 //
145 MH::SetBinning(&fHist, hcol.GetXaxis());
146
147 //
148 // This is necessary to initialize thze error calculation correctly
149 // (Nothing important: The histogram set the size of its internal
150 // array storing the errors to the correct size)
151 //
152 fHist.Sumw2();
153
154 fHist.Add(&hcol);
155 fHist.Multiply((TF1*)&spect);
156
157 SetReadyToSave();
158}
Note: See TracBrowser for help on using the repository browser.