source: trunk/MagicSoft/Mars/mimage/MHImagePar.cc@ 5135

Last change on this file since 5135 was 4834, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 5.0 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): Wolfgang Wittek, 03/2003 <mailto:wittek@mppmu.mpg.de>
19! Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2004
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MHImagePar
29//
30////////////////////////////////////////////////////////////////////////////
31#include "MHImagePar.h"
32
33#include <math.h>
34
35#include <TH1.h>
36#include <TPad.h>
37#include <TCanvas.h>
38
39#include "MLog.h"
40#include "MLogManip.h"
41
42#include "MGeomCam.h"
43#include "MBinning.h"
44#include "MParList.h"
45
46#include "MHillas.h"
47#include "MImagePar.h"
48
49ClassImp(MHImagePar);
50
51using namespace std;
52
53// --------------------------------------------------------------------------
54//
55// Setup histograms
56//
57MHImagePar::MHImagePar(const char *name, const char *title)
58{
59 fName = name ? name : "MHImagePar";
60 fTitle = title ? title : "Histograms of image parameters";
61
62 fHistSatHi.SetName("SatHi");
63 fHistSatHi.SetTitle("Number of pixels with saturating hi-gains");
64 fHistSatHi.SetXTitle("Pixels");
65 fHistSatHi.SetYTitle("Counts");
66 fHistSatHi.SetDirectory(NULL);
67 fHistSatHi.UseCurrentStyle();
68 fHistSatHi.SetFillStyle(4000);
69
70 fHistSatLo.SetName("SatLo");
71 fHistSatLo.SetTitle("Number of pixels with saturating lo-gains");
72 fHistSatLo.SetXTitle("Pixels");
73 fHistSatLo.SetYTitle("Counts");
74 fHistSatLo.SetLineColor(kBlue);
75 fHistSatLo.SetDirectory(NULL);
76 fHistSatLo.UseCurrentStyle();
77 fHistSatLo.SetFillStyle(4000);
78
79 fHistIslands.SetName("Islands");
80 fHistIslands.SetTitle("Number of Islands");
81 fHistIslands.SetXTitle("N");
82 fHistIslands.SetYTitle("Counts");
83 fHistIslands.SetDirectory(NULL);
84 fHistIslands.UseCurrentStyle();
85 fHistIslands.SetLineColor(kBlue);
86 fHistIslands.SetFillStyle(4000);
87
88 MBinning bins;
89
90 bins.SetEdges(61, 0, 60);
91 bins.Apply(fHistSatHi);
92 bins.Apply(fHistSatHi);
93
94 bins.SetEdges(16, 0, 15);
95 bins.Apply(fHistIslands);
96}
97
98// --------------------------------------------------------------------------
99//
100// Setup the Binning for the histograms automatically if the correct
101// instances of MBinning
102//
103Bool_t MHImagePar::SetupFill(const MParList *plist)
104{
105 ApplyBinning(*plist, "Pixels", &fHistSatHi);
106 ApplyBinning(*plist, "Pixels", &fHistSatHi);
107
108 ApplyBinning(*plist, "Islands", &fHistIslands);
109
110 return kTRUE;
111}
112
113
114// --------------------------------------------------------------------------
115//
116// Fill the histograms with data from a MNewImagePar container.
117//
118Bool_t MHImagePar::Fill(const MParContainer *par, const Stat_t w)
119{
120 if (!par)
121 {
122 *fLog << err << "MImagePar::Fill: Pointer (!=NULL) expected." << endl;
123 return kFALSE;
124 }
125
126 const MImagePar &h = *(MImagePar*)par;
127
128 fHistSatHi.Fill(h.GetNumSatPixelsHG(), w);
129 fHistSatLo.Fill(h.GetNumSatPixelsLG(), w);
130
131 fHistIslands.Fill(h.GetNumIslands(), w);
132
133 return kTRUE;
134}
135
136void MHImagePar::Paint(Option_t *)
137{
138 TVirtualPad *savepad = gPad;
139 if (fHistSatHi.GetEntries()>0)
140 {
141 gPad->cd(1);
142 gPad->SetLogy();
143 }
144 gPad = savepad;
145}
146
147// --------------------------------------------------------------------------
148//
149// Creates a new canvas and draws the two histograms into it.
150// Be careful: The histograms belongs to this object and won't get deleted
151// together with the canvas.
152//
153void MHImagePar::Draw(Option_t *)
154{
155 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
156 pad->SetBorderMode(0);
157
158 AppendPad("");
159
160 pad->Divide(1,2);
161
162 pad->cd(1);
163 gPad->SetBorderMode(0);
164 MH::DrawSame(fHistSatHi, fHistSatLo, "Saturating Pixels");
165
166 fHistSatHi.SetMinimum(-1111); // switch off to allow log-scale
167 fHistSatLo.SetMinimum(-1111); // switch off to allow log-scale
168 fHistSatLo.SetMaximum(0.1); // dummy value to allow log-scale
169
170 pad->cd(2);
171 gPad->SetBorderMode(0);
172 fHistIslands.Draw();
173
174 pad->Modified();
175 pad->Update();
176}
177
178TH1 *MHImagePar::GetHistByName(const TString name)
179{
180 if (name.Contains("SatHi", TString::kIgnoreCase))
181 return &fHistSatHi;
182 if (name.Contains("SatLo", TString::kIgnoreCase))
183 return &fHistSatLo;
184 if (name.Contains("Islands", TString::kIgnoreCase))
185 return &fHistIslands;
186
187 return NULL;
188}
Note: See TracBrowser for help on using the repository browser.