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 |
|
---|
49 | ClassImp(MHImagePar);
|
---|
50 |
|
---|
51 | using namespace std;
|
---|
52 |
|
---|
53 | // --------------------------------------------------------------------------
|
---|
54 | //
|
---|
55 | // Setup histograms
|
---|
56 | //
|
---|
57 | MHImagePar::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(75, 0, 150);
|
---|
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 | //
|
---|
103 | Bool_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 | //
|
---|
118 | Bool_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 |
|
---|
136 | // --------------------------------------------------------------------------
|
---|
137 | //
|
---|
138 | // Creates a new canvas and draws the two histograms into it.
|
---|
139 | // Be careful: The histograms belongs to this object and won't get deleted
|
---|
140 | // together with the canvas.
|
---|
141 | //
|
---|
142 | void MHImagePar::Draw(Option_t *)
|
---|
143 | {
|
---|
144 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
---|
145 | pad->SetBorderMode(0);
|
---|
146 |
|
---|
147 | AppendPad("");
|
---|
148 |
|
---|
149 | pad->Divide(1,2);
|
---|
150 |
|
---|
151 | pad->cd(1);
|
---|
152 | gPad->SetBorderMode(0);
|
---|
153 | /*
|
---|
154 | gPad->SetLogy();
|
---|
155 | TAxis &x = *fHistSatHi.GetXaxis();
|
---|
156 | x.SetRangeUser(0.0, x.GetXmax());
|
---|
157 | fHistSatHi.SetMinimum(0.1);
|
---|
158 | fHistSatLo.SetMinimum(0.1);
|
---|
159 | fHistSatHi.SetMaximum(0.1);
|
---|
160 | fHistSatLo.SetMaximum(0.1);
|
---|
161 | */
|
---|
162 | MH::DrawSame(fHistSatHi, fHistSatLo, "Saturating Pixels");
|
---|
163 |
|
---|
164 | pad->cd(2);
|
---|
165 | gPad->SetBorderMode(0);
|
---|
166 | fHistIslands.Draw();
|
---|
167 |
|
---|
168 | pad->Modified();
|
---|
169 | pad->Update();
|
---|
170 | }
|
---|
171 |
|
---|
172 | TH1 *MHImagePar::GetHistByName(const TString name)
|
---|
173 | {
|
---|
174 | if (name.Contains("SatHi", TString::kIgnoreCase))
|
---|
175 | return &fHistSatHi;
|
---|
176 | if (name.Contains("SatLo", TString::kIgnoreCase))
|
---|
177 | return &fHistSatLo;
|
---|
178 | if (name.Contains("Islands", TString::kIgnoreCase))
|
---|
179 | return &fHistIslands;
|
---|
180 |
|
---|
181 | return NULL;
|
---|
182 | }
|
---|