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

Last change on this file since 5782 was 5142, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 5.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): 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(60, -0.5, 59.5);
91 bins.Apply(fHistSatHi);
92 bins.Apply(fHistSatHi);
93
94 bins.SetEdges(15, 0.5, 15.5);
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 *o)
137{
138 if (TString(o)==(TString)"log1" && fHistSatHi.GetMaximum()>0)
139 gPad->SetLogy();
140 if (TString(o)==(TString)"log2" && fHistIslands.GetMaximum()>0)
141 gPad->SetLogy();
142}
143
144// --------------------------------------------------------------------------
145//
146// Creates a new canvas and draws the two histograms into it.
147// Be careful: The histograms belongs to this object and won't get deleted
148// together with the canvas.
149//
150void MHImagePar::Draw(Option_t *)
151{
152 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
153 pad->SetBorderMode(0);
154
155 AppendPad("");
156
157 pad->Divide(1,2);
158
159 pad->cd(1);
160 gPad->SetBorderMode(0);
161 MH::DrawSame(fHistSatHi, fHistSatLo, "Saturating Pixels");
162 fHistSatHi.SetMinimum(); // switch off to allow log-scale
163 fHistSatLo.SetMinimum(); // switch off to allow log-scale
164 fHistSatLo.SetMaximum(0.1); // dummy value to allow log-scale
165 AppendPad("log1");
166
167 pad->cd(2);
168 gPad->SetBorderMode(0);
169 fHistIslands.Draw();
170 AppendPad("log2");
171}
172
173TH1 *MHImagePar::GetHistByName(const TString name)
174{
175 if (name.Contains("SatHi", TString::kIgnoreCase))
176 return &fHistSatHi;
177 if (name.Contains("SatLo", TString::kIgnoreCase))
178 return &fHistSatLo;
179 if (name.Contains("Islands", TString::kIgnoreCase))
180 return &fHistIslands;
181
182 return NULL;
183}
Note: See TracBrowser for help on using the repository browser.