source: trunk/MagicSoft/Mars/mbadpixels/MHBadPixels.cc@ 4909

Last change on this file since 4909 was 4887, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 4.8 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 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MHBadPixels
28//
29////////////////////////////////////////////////////////////////////////////
30#include "MHBadPixels.h"
31
32#include <TCanvas.h>
33
34#include "MPointingPos.h"
35#include "MBadPixelsCam.h"
36#include "MGeomCam.h"
37#include "MParList.h"
38#include "MBinning.h"
39
40#include "MLog.h"
41#include "MLogManip.h"
42
43ClassImp(MHBadPixels);
44
45using namespace std;
46
47// -------------------------------------------------------------------------
48//
49// Default Constructor.
50//
51MHBadPixels::MHBadPixels(const char *name, const char *title)
52 : fNamePedPhotCam("MPedPhotCam")
53{
54 fName = name ? name : "MHBadPixels";
55 fTitle = title ? title : "Histogram for Bad Pixels vs. Theta";
56
57 fBadId.SetName("2D-IdBadPixels");
58 fBadId.SetTitle("2D-IdBadPixels");
59 fBadId.SetDirectory(NULL);
60 fBadId.SetXTitle("\\Theta [\\circ]");
61 fBadId.SetYTitle("pixel Id");
62
63 fBadN.SetName("2D-NBadPixels");
64 fBadN.SetTitle("2D-NBadPixels");
65 fBadN.SetDirectory(NULL);
66 fBadN.SetXTitle("\\Theta [\\circ]");
67 fBadN.SetYTitle("number of bad pixels");
68
69}
70
71// --------------------------------------------------------------------------
72//
73// Set the binnings and prepare the filling of the histogram
74//
75Bool_t MHBadPixels::SetupFill(const MParList *plist)
76{
77 MGeomCam *fCam = (MGeomCam*)plist->FindObject(AddSerialNumber("MGeomCam"));
78 if (!fCam)
79 {
80 *fLog << err << "MGeomCam not found... aborting." << endl;
81 return kFALSE;
82 }
83 fPointPos = (MPointingPos*)plist->FindObject("MPointingPos");
84 if (!fPointPos)
85 {
86 *fLog << err << "MPointingPos not found... aborting." << endl;
87 return kFALSE;
88 }
89
90 //----------------------------------------------------
91 // Get Theta Binning
92 MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta", "MBinning");
93 if (!binstheta)
94 {
95 *fLog << err << "BinningTheta [MBinning] not found... aborting" << endl;
96 return kFALSE;
97 }
98
99 // Get binning for pixel number
100 const UInt_t npix1 = fCam->GetNumPixels()+1;
101
102 MBinning binspix("BinningPixel");
103 binspix.SetEdges(npix1, -0.5, npix1-0.5);
104
105 // Set binnings in histograms
106 SetBinning(&fBadId, binstheta, &binspix);
107 SetBinning(&fBadN, binstheta, &binspix);
108
109 return kTRUE;
110}
111
112// ------------------------------------------------------------------------
113//
114// Fill the histograms
115//
116
117Bool_t MHBadPixels::Fill(const MParContainer *par, const Stat_t w)
118{
119 if (!par)
120 return kFALSE;
121
122 Double_t theta = fPointPos->GetZd();
123
124 const MBadPixelsCam *badpixels = (MBadPixelsCam*)par;
125
126 const UInt_t entries = badpixels->GetSize();
127
128 UInt_t nb = 0;
129 for (UInt_t i=0; i<entries; i++)
130 {
131 if ( (*badpixels)[i].IsUnsuitable() )
132 {
133 fBadId.Fill(theta, i, w);
134 nb++;
135 }
136 }
137 fBadN.Fill(theta, nb, w);
138
139 return kTRUE;
140}
141
142// --------------------------------------------------------------------
143//
144// Draw the histograms
145//
146void MHBadPixels::Draw(Option_t *option)
147{
148 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
149 pad->SetBorderMode(0);
150
151 pad->Divide(2,2);
152
153 TH1D *h;
154
155 pad->cd(1);
156 fBadId.Draw(option);
157
158 pad->cd(2);
159 fBadN.Draw(option);
160
161 pad->cd(3);
162 gPad->SetBorderMode(0);
163 h = ((TH2*)&fBadId)->ProjectionY("ProjY-pixId", -1, 9999, "");
164 h->SetDirectory(NULL);
165 h->SetTitle("Distribution of bad pixel Id");
166 h->SetXTitle("Id of bad pixel");
167 h->SetYTitle("No. of events");
168 h->Draw(option);
169 h->SetBit(kCanDelete);
170
171 pad->cd(4);
172 gPad->SetBorderMode(0);
173 h = ((TH2*)&fBadN)->ProjectionY("ProjY-pixN", -1, 9999, "");
174 h->SetDirectory(NULL);
175 h->SetTitle("Distribution of no.of bad pixels");
176 h->SetXTitle("No. of bad pixels");
177 h->SetYTitle("No. of events");
178 h->Draw(option);
179 h->SetBit(kCanDelete);
180
181 pad->Modified();
182 pad->Update();
183}
Note: See TracBrowser for help on using the repository browser.