source: tags/Mars-V0.7/mhist/MHMcEnergyImpact.cc

Last change on this file was 1227, checked in by tbretz, 23 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.1 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// MHMcEnergyImpact
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 "MHMcEnergyImpact.h"
35
36#include <TH2.h>
37#include <TCanvas.h>
38
39#include "MParList.h"
40#include "MBinning.h"
41
42#include "MLog.h"
43#include "MLogManip.h"
44
45#include "MMcEvt.hxx"
46
47ClassImp(MHMcEnergyImpact);
48
49// -------------------------------------------------------------------------
50//
51// Default Constructor.
52//
53MHMcEnergyImpact::MHMcEnergyImpact(const char *name, const char *title)
54 : fHist()
55{
56 fName = name ? name : "MHMcEnergyImpact";
57 fTitle = title ? title : "Impact (radius) vs Energy distribution";
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("r [m]");
70 fHist.SetZTitle("N");
71
72 MBinning binsx;
73 binsx.SetEdgesLog(10, 1, 100000); // [GeV]
74
75 MBinning binsy;
76 binsy.SetEdges(9, 0, 450); // [m]
77
78 SetBinning(&fHist, &binsx, &binsy);
79
80}
81
82void MHMcEnergyImpact::SetName(const char *name)
83{
84 fName = name;
85 fHist.SetName(name);
86 fHist.SetDirectory(NULL);
87}
88
89void MHMcEnergyImpact::SetTitle(const char *title)
90{
91 fTitle = title;
92 fHist.SetName(title);
93}
94
95//-------------------------------------------------------------------------
96//
97// Defualt Destructor
98//
99MHMcEnergyImpact::~MHMcEnergyImpact()
100{
101}
102
103
104Bool_t MHMcEnergyImpact::SetupFill(const MParList *pList)
105{
106 const MBinning *binsx = (MBinning*)pList->FindObject("BinningEnergy", "MBinning");
107 const MBinning *binsy = (MBinning*)pList->FindObject("BinningImpact", "MBinning");
108
109 if (!binsx || !binsy)
110 return kTRUE;
111
112 SetBinning(&fHist, binsx, binsy);
113
114 return kTRUE;
115}
116
117//--------------------------------------------------------------------------
118//
119// Fill the histogram with the log10 of the energy for triggered events.
120//
121Bool_t MHMcEnergyImpact::Fill(const MParContainer *cont)
122{
123 const MMcEvt &mcevt = *(MMcEvt*)cont;
124
125 const Float_t energy = mcevt.GetEnergy();
126 const Float_t impact = mcevt.GetImpact()/100.;
127
128 fHist.Fill(energy, impact);
129
130 return kTRUE;
131}
132
133// ------------------------------------------------------------------------
134//
135// Drawing function. It creates its own canvas.
136//
137void MHMcEnergyImpact::Draw(Option_t *option)
138{
139 if (!gPad)
140 MH::MakeDefCanvas(&fHist);
141
142 gPad->SetLogx();
143
144 fHist.Draw(option);
145
146 gPad->Modified();
147 gPad->Update();
148}
149
150TObject *MHMcEnergyImpact::DrawClone(Option_t *option) const
151{
152 TCanvas *c = MH::MakeDefCanvas(&fHist);
153
154 c->SetLogx();
155
156 //
157 // This is necessary to get the expected bahviour of DrawClone
158 //
159 gROOT->SetSelectedPad(NULL);
160
161 ((TH2D&)fHist).DrawCopy(option);
162
163 c->Modified();
164 c->Update();
165
166 return c;
167}
168
Note: See TracBrowser for help on using the repository browser.