source: branches/MarsMoreSimulationTruth/mhistmc/MHMcEnergyImpact.cc@ 20115

Last change on this file since 20115 was 2449, checked in by marcos, 21 years ago
*** empty log message ***
File size: 3.7 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
95Bool_t MHMcEnergyImpact::SetupFill(const MParList *pList)
96{
97 const MBinning *binsx = (MBinning*)pList->FindObject("BinningEnergy", "MBinning");
98 const MBinning *binsy = (MBinning*)pList->FindObject("BinningImpact", "MBinning");
99
100 if (!binsx || !binsy)
101 return kTRUE;
102
103 SetBinning(&fHist, binsx, binsy);
104
105 return kTRUE;
106}
107
108//--------------------------------------------------------------------------
109//
110// Fill the histogram with the log10 of the energy for triggered events.
111//
112Bool_t MHMcEnergyImpact::Fill(const MParContainer *cont, const Stat_t w)
113{
114 const MMcEvt &mcevt = *(MMcEvt*)cont;
115
116 const Float_t energy = mcevt.GetEnergy();
117 const Float_t impact = mcevt.GetImpact()/100.;
118
119 fHist.Fill(energy, impact, w);
120
121 return kTRUE;
122}
123
124// ------------------------------------------------------------------------
125//
126// Drawing function. It creates its own canvas.
127//
128void MHMcEnergyImpact::Draw(Option_t *option)
129{
130 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
131 pad->SetBorderMode(0);
132
133 AppendPad("");
134
135 pad->SetLogx();
136
137 fHist.Draw(option);
138
139 pad->Modified();
140 pad->Update();
141}
Note: See TracBrowser for help on using the repository browser.