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

Last change on this file since 6215 was 5994, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 5.5 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 /*
139 if (TString(o)==(TString)"log1" && fHistSatHi.GetMaximum()>0)
140 gPad->SetLogy();
141 if (TString(o)==(TString)"log2" && fHistIslands.GetMaximum()>0)
142 gPad->SetLogy();
143 */
144 if (fHistSatHi.GetMaximum()>0 && gPad->GetPad(1))
145 gPad->GetPad(1)->SetLogy();
146 if (fHistIslands.GetMaximum()>0 && gPad->GetPad(2))
147 gPad->GetPad(2)->SetLogy();
148}
149
150// --------------------------------------------------------------------------
151//
152// Creates a new canvas and draws the two histograms into it.
153// Be careful: The histograms belongs to this object and won't get deleted
154// together with the canvas.
155//
156void MHImagePar::Draw(Option_t *o)
157{
158 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
159 pad->SetBorderMode(0);
160
161 AppendPad("");
162
163 TString opt(o);
164 opt.ToLower();
165
166 // FIXME: If same-option given make two independant y-axis!
167 const Bool_t same = opt.Contains("same");
168
169 if (!same)
170 pad->Divide(1,2);
171 else
172 fHistIslands.SetLineColor(kGreen);
173
174 if (!same)
175 {
176 pad->cd(1);
177 gPad->SetBorderMode(0);
178 MH::DrawSame(fHistSatHi, fHistSatLo, "Saturating Pixels");
179 fHistSatHi.SetMinimum(); // switch off to allow log-scale
180 fHistSatLo.SetMinimum(); // switch off to allow log-scale
181 fHistSatLo.SetMaximum(0.1); // dummy value to allow log-scale
182 //AppendPad("log1");
183 }
184
185 pad->cd(2);
186 gPad->SetBorderMode(0);
187 fHistIslands.Draw(same?"same":"");
188 //AppendPad("log2");
189}
190
191TH1 *MHImagePar::GetHistByName(const TString name)
192{
193 if (name.Contains("SatHi", TString::kIgnoreCase))
194 return &fHistSatHi;
195 if (name.Contains("SatLo", TString::kIgnoreCase))
196 return &fHistSatLo;
197 if (name.Contains("Islands", TString::kIgnoreCase))
198 return &fHistIslands;
199
200 return NULL;
201}
Note: See TracBrowser for help on using the repository browser.