source: branches/MarsGapdTimeJitter/mimage/MHNewImagePar2.cc@ 18294

Last change on this file since 18294 was 9343, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 4.2 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): Thomas Bretz, 03/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2009
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MHNewImagePar2
28//
29// ClassVersion 2:
30// ---------------
31// - fMm2Deg
32// - fUseMmScale
33//
34////////////////////////////////////////////////////////////////////////////
35#include "MHNewImagePar2.h"
36
37#include <math.h>
38
39#include <TH1.h>
40#include <TPad.h>
41#include <TCanvas.h>
42
43#include "MLog.h"
44#include "MLogManip.h"
45
46#include "MGeomCam.h"
47#include "MBinning.h"
48#include "MParList.h"
49
50#include "MHillas.h"
51#include "MNewImagePar2.h"
52
53ClassImp(MHNewImagePar2);
54
55using namespace std;
56
57// --------------------------------------------------------------------------
58//
59// Setup histograms
60//
61MHNewImagePar2::MHNewImagePar2(const char *name, const char *title)
62 : fGeom(0)
63{
64 fName = name ? name : "MHNewImagePar2";
65 fTitle = title ? title : "Histograms of new image parameters 2";
66
67 fHistBorder1.SetName("Border1");
68 fHistBorder1.SetTitle("Border Line of border pixels (pixel border)");
69 fHistBorder1.SetXTitle("Border [\\circ]]");
70 fHistBorder1.SetYTitle("Counts");
71 fHistBorder1.SetDirectory(NULL);
72 fHistBorder1.UseCurrentStyle();
73 fHistBorder1.SetFillStyle(4000);
74
75 fHistBorder2.SetName("Border2");
76 fHistBorder2.SetTitle("Border Line of border pixels (pixel center)");
77 fHistBorder2.SetXTitle("Border [\\circ]]");
78 fHistBorder2.SetYTitle("Counts");
79 fHistBorder2.SetDirectory(NULL);
80 fHistBorder2.UseCurrentStyle();
81 fHistBorder2.SetLineColor(kBlue);
82 fHistBorder2.SetFillStyle(4000);
83}
84
85// --------------------------------------------------------------------------
86//
87// Setup the Binning for the histograms automatically if the correct
88// instances of MBinning
89//
90Bool_t MHNewImagePar2::SetupFill(const MParList *plist)
91{
92 fGeom = (MGeomCam*)plist->FindObject("MGeomCam");
93 if (!fGeom)
94 {
95 *fLog << err << "MGeomCam not found... abort." << endl;
96 return kFALSE;
97 }
98
99 const MBinning *bins = (MBinning*)plist->FindObject("BinningBorder");
100 if (!bins)
101 {
102 MBinning b;
103 b.SetEdges(87, 0, 10);
104 b.Apply(fHistBorder1);
105 b.Apply(fHistBorder2);
106 }
107 else
108 {
109 bins->Apply(fHistBorder1);
110 bins->Apply(fHistBorder2);
111 }
112
113 return kTRUE;
114}
115
116
117// --------------------------------------------------------------------------
118//
119// Fill the histograms with data from a MNewImagePar2 container.
120//
121Int_t MHNewImagePar2::Fill(const MParContainer *par, const Stat_t w)
122{
123 const MNewImagePar2 *h = dynamic_cast<const MNewImagePar2*>(par);
124 if (!h)
125 {
126 *fLog << err << "MHNewImagePar2::Fill: Pointer (!=NULL) expected." << endl;
127 return kERROR;
128 }
129
130 const Double_t scale = fGeom->GetConvMm2Deg();
131
132 fHistBorder1.Fill(h->GetBorderLinePixel() *scale, w);
133 fHistBorder2.Fill(h->GetBorderLineCenter()*scale, w);
134
135 return kTRUE;
136}
137
138// --------------------------------------------------------------------------
139//
140// Creates a new canvas and draws the two histograms into it.
141// Be careful: The histograms belongs to this object and won't get deleted
142// together with the canvas.
143//
144void MHNewImagePar2::Draw(Option_t *)
145{
146 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
147 pad->SetBorderMode(0);
148
149 AppendPad("");
150
151 gPad->SetBorderMode(0);
152 MH::DrawSame(fHistBorder1, fHistBorder2, "Border Line");
153}
Note: See TracBrowser for help on using the repository browser.