source: trunk/MagicSoft/Mars/mhflux/MHThreshold.cc@ 7202

Last change on this file since 7202 was 7178, checked in by tbretz, 19 years ago
*** empty log message ***
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): Thomas Bretz 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
19! Author(s): Harald Kornmayer 1/2001
20!
21! Copyright: MAGIC Software Development, 2000-2002
22!
23!
24\* ======================================================================== */
25
26//////////////////////////////////////////////////////////////////////////////
27//
28// MHThreshold
29//
30//////////////////////////////////////////////////////////////////////////////
31#include "MHThreshold.h"
32
33#include <TF1.h>
34#include <TLatex.h>
35#include <TCanvas.h>
36#include <TPaveStats.h>
37
38#include "MLog.h"
39#include "MLogManip.h"
40
41#include "MBinning.h"
42
43#include "MMcEvt.hxx"
44
45#include "MParList.h"
46
47ClassImp(MHThreshold);
48
49using namespace std;
50
51// --------------------------------------------------------------------------
52//
53// Creates the three necessary histograms:
54// - selected showers (input)
55// - all showers (input)
56// - collection area (result)
57//
58MHThreshold::MHThreshold(const char *name, const char *title)
59{
60 // initialize the histogram for the distribution r vs E
61 //
62 // we set the energy range from 2 Gev to 20000 GeV (in log 4 orders
63 // of magnitude) and for each order we take 25 subdivision --> 100 xbins
64 //
65 // we set the radius range from 0 m to 500 m with 10 m bin --> 50 ybins
66 //
67 fName = name ? name : "MHThreshold";
68 fTitle = title ? title : "Collection Area vs. Energy/Theta";
69
70 fHEnergy.SetName("Threshold");
71 fHEnergy.SetTitle("Energy Thrshold");
72 fHEnergy.SetXTitle("E [GeV]");
73 fHEnergy.SetYTitle("dN/dE [GeV^{-1}]");
74 fHEnergy.SetDirectory(NULL);
75 fHEnergy.UseCurrentStyle();
76 fHEnergy.Sumw2();
77
78 MBinning binse(80, 10, 1000000, "", "log");
79 binse.Apply(fHEnergy);
80}
81
82Bool_t MHThreshold::SetupFill(const MParList *pl)
83{
84 fMcEvt = (MMcEvt*)pl->FindObject("MMcEvt");
85 if (!fMcEvt)
86 {
87 *fLog << err << "MMcEvt not found... abort." << endl;
88 return kFALSE;
89 }
90/*
91 MBinning binse;
92 binse.SetEdges(fHEnergy, 'x');
93
94 MBinning *bins = (MBinning*)pl->FindObject("BinningEnergyEst", "MBinning");
95 if (bins)
96 binse.SetEdges(*bins);
97
98 binse.Apply(fHEnergy);
99 */
100 return kTRUE;
101}
102
103void MHThreshold::Paint(Option_t *option)
104{
105 const TAxis &axe = *fHEnergy.GetXaxis();
106
107 const Int_t bin = fHEnergy.GetMaximumBin();
108
109 // Assume that the energy binning is logarithmic
110 const Axis_t maxe = TMath::Sqrt(axe.GetBinLowEdge(bin)*axe.GetBinUpEdge(bin));
111
112 TLatex text(0.30, 0.95, Form("E_{max}=%dGeV", TMath::Nint(maxe)));
113 text.SetBit(TLatex::kTextNDC);
114 text.SetTextSize(0.04);
115 text.Paint();
116}
117
118void MHThreshold::Draw(Option_t *option)
119{
120 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
121
122 // Do the projection before painting the histograms into
123 // the individual pads
124 pad->SetBorderMode(0);
125
126 gPad->SetLogx();
127 gPad->SetLogy();
128
129 fHEnergy.Draw();
130
131 AppendPad();
132}
133
134Bool_t MHThreshold::Fill(const MParContainer *par, const Stat_t weight)
135{
136 const Double_t energy = fMcEvt->GetEnergy();
137
138 fHEnergy.Fill(energy, weight/energy);
139
140 return kTRUE;
141}
Note: See TracBrowser for help on using the repository browser.