source: trunk/MagicSoft/Mars/mmuon/MHMuonPar.cc@ 6987

Last change on this file since 6987 was 6984, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 6.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): Markus Meyer, 02/2005 <mailto:meyer@astro.uni-wuerzburg.de>
19! Author(s): Thomas Bretz, 04/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2005
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MHMuonPar
29//
30// This class is a histogram class for displaying muonparameters.
31// The folowing histgrams will be plotted:
32// - Radius (TH1F)
33// - ArcWidth (TH1F)
34// - ArcWidth/Radius vs Radius (TProfile) (it is the energy dependent
35// relative broadening of the muon ring)
36// - Size Vs Radius
37//
38// Inputcontainer:
39// - MGeomCam
40// - MMuonSearchPar
41// - MMuonCalibPar
42//
43////////////////////////////////////////////////////////////////////////////
44#include "MHMuonPar.h"
45
46#include <TH1.h>
47#include <TPad.h>
48#include <TCanvas.h>
49#include <TProfile.h>
50
51#include "MLog.h"
52#include "MLogManip.h"
53
54#include "MGeomCam.h"
55#include "MBinning.h"
56#include "MParList.h"
57
58#include "MMuonSearchPar.h"
59#include "MMuonCalibPar.h"
60
61ClassImp(MHMuonPar);
62
63using namespace std;
64
65// --------------------------------------------------------------------------
66//
67// Setup histograms
68//
69MHMuonPar::MHMuonPar(const char *name, const char *title) :
70 fMuonSearchPar(NULL), fMuonCalibPar(NULL)
71{
72 fName = name ? name : "MHMuonPar";
73 fTitle = title ? title : "Histograms of muon parameters";
74
75 fHistRadius.SetName("Radius");
76 fHistRadius.SetTitle("Distribution of Radius'");
77 fHistRadius.SetXTitle("R [\\circ]");
78 fHistRadius.SetYTitle("Counts");
79 fHistRadius.SetDirectory(NULL);
80 fHistRadius.UseCurrentStyle();
81 fHistRadius.SetFillStyle(4000);
82
83 fHistArcWidth.SetName("ArcWidth");
84 fHistArcWidth.SetTitle("Distribution of ArcWidth");
85 fHistArcWidth.SetXTitle("W [\\circ]");
86 fHistArcWidth.SetYTitle("Counts");
87 fHistArcWidth.SetDirectory(NULL);
88 fHistArcWidth.UseCurrentStyle();
89 fHistArcWidth.SetFillStyle(4000);
90
91 fHistBroad.SetName("RingBroadening");
92 fHistBroad.SetTitle("Profile of ArcWidth/Radius versus Radius");
93 fHistBroad.SetXTitle("R [\\circ]");
94 fHistBroad.SetYTitle("W/R [1]");
95 fHistBroad.SetDirectory(NULL);
96 fHistBroad.UseCurrentStyle();
97 fHistBroad.SetFillStyle(4000);
98
99 fHistSize.SetName("SizeVsRadius");
100 fHistSize.SetTitle("Profile of Muon Size vs. Radius");
101 fHistSize.SetXTitle("R [\\circ]");
102 fHistSize.SetYTitle("S [phe]");
103 fHistSize.SetDirectory(NULL);
104 fHistSize.UseCurrentStyle();
105 fHistSize.SetFillStyle(4000);
106
107 MBinning bins;
108
109 bins.SetEdges(20, 0.5, 1.5);
110 bins.Apply(fHistRadius);
111
112 bins.SetEdges(60, 0., 0.3);
113 bins.Apply(fHistArcWidth);
114
115 bins.SetEdges(20, 0.5, 1.5);
116 bins.Apply(fHistBroad);
117
118 bins.SetEdges(20, 0.5, 1.5);
119 bins.Apply(fHistSize);
120}
121
122// --------------------------------------------------------------------------
123//
124// Setup the Binning for the histograms automatically if the correct
125// instances of MBinning
126//
127Bool_t MHMuonPar::SetupFill(const MParList *plist)
128{
129 MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
130 if (!geom)
131 {
132 *fLog << warn << "MGeomCam not found... abort." << endl;
133 return kFALSE;
134 }
135 fMm2Deg = geom->GetConvMm2Deg();
136
137 fMuonSearchPar = (MMuonSearchPar*)plist->FindObject("MMuonSearchPar");
138 if (!fMuonSearchPar)
139 {
140 *fLog << warn << "MMuonSearchPar not found... abort." << endl;
141 return kFALSE;
142 }
143 fMuonCalibPar = (MMuonCalibPar*)plist->FindObject("MMuonCalibPar");
144 if (!fMuonCalibPar)
145 {
146 *fLog << warn << "MMuonCalibPar not found... abort." << endl;
147 return kFALSE;
148 }
149
150 ApplyBinning(*plist, "Radius", &fHistRadius);
151 ApplyBinning(*plist, "ArcWidth", &fHistArcWidth);
152 ApplyBinning(*plist, "RingBroadening", &fHistBroad);
153 ApplyBinning(*plist, "SizeVsRadius", &fHistSize);
154
155 return kTRUE;
156}
157
158// --------------------------------------------------------------------------
159//
160// Fill the histograms with data from a MMuonCalibPar and
161// MMuonSearchPar container.
162//
163Bool_t MHMuonPar::Fill(const MParContainer *par, const Stat_t w)
164{
165 fHistRadius.Fill(fMm2Deg*fMuonSearchPar->GetRadius(), w);
166
167 fHistArcWidth.Fill(fMuonCalibPar->GetArcWidth(), w);
168
169 fHistBroad.Fill(fMm2Deg*fMuonSearchPar->GetRadius(),
170 fMuonCalibPar->GetArcWidth()/(fMm2Deg*fMuonSearchPar->GetRadius()), w);
171
172 fHistSize.Fill(fMm2Deg*fMuonSearchPar->GetRadius(),
173 fMuonCalibPar->GetMuonSize(), w);
174
175 return kTRUE;
176}
177// --------------------------------------------------------------------------
178//
179// Creates a new canvas and draws the two histograms into it.
180// Be careful: The histograms belongs to this object and won't get deleted
181// together with the canvas.
182//
183void MHMuonPar::Draw(Option_t *)
184{
185 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
186 pad->SetBorderMode(0);
187
188 AppendPad("");
189
190 pad->Divide(2,2);
191
192 pad->cd(1);
193 gPad->SetBorderMode(0);
194 fHistRadius.Draw();
195
196 pad->cd(2);
197 gPad->SetBorderMode(0);
198 fHistArcWidth.Draw();
199
200 pad->cd(3);
201 gPad->SetBorderMode(0);
202 fHistSize.Draw();
203
204 pad->cd(4);
205 gPad->SetBorderMode(0);
206 fHistBroad.Draw();
207}
208/*
209TH1 *MHMuonPar::GetHistByName(const TString name)
210{
211 if (name.Contains("Radius", TString::kIgnoreCase))
212 return &fHistRadius;
213 if (name.Contains("ArcWidth", TString::kIgnoreCase))
214 return &fHistArcWidth;
215 return NULL;
216}
217*/
Note: See TracBrowser for help on using the repository browser.