source: trunk/MagicSoft/Mars/mhist/MHBlindPixels.cc@ 3002

Last change on this file since 3002 was 2173, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.9 KB
Line 
1
2/* ======================================================================== *\
3!
4! *
5! * This file is part of MARS, the MAGIC Analysis and Reconstruction
6! * Software. It is distributed to you in the hope that it can be a useful
7! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
8! * It is distributed WITHOUT ANY WARRANTY.
9! *
10! * Permission to use, copy, modify and distribute this software and its
11! * documentation for any purpose is hereby granted without fee,
12! * provided that the above copyright notice appear in all copies and
13! * that both that copyright notice and this permission notice appear
14! * in supporting documentation. It is provided "as is" without express
15! * or implied warranty.
16! *
17!
18!
19! Author(s): Thomas Bretz 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2003
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MHBlindPixels
29//
30////////////////////////////////////////////////////////////////////////////
31#include "MHBlindPixels.h"
32
33#include <TCanvas.h>
34
35#include "MMcEvt.hxx"
36#include "MBlindPixels.h"
37#include "MPedestalCam.h"
38#include "MParList.h"
39#include "MBinning.h"
40
41#include "MLog.h"
42#include "MLogManip.h"
43
44ClassImp(MHBlindPixels);
45
46using namespace std;
47
48// -------------------------------------------------------------------------
49//
50// Default Constructor.
51//
52MHBlindPixels::MHBlindPixels(const char *name, const char *title)
53{
54 fName = name ? name : "MHBlindPixels";
55 fTitle = title ? title : "Histogram for Blind Pixels vs. Theta";
56
57 // - we initialize the histogram
58 // - we have to give different names for the different histograms because
59 // root don't allow us to have diferent histograms with the same name
60
61 fBlindId.SetName("2D-IdBlindPixels");
62 fBlindId.SetTitle("2D-IdBlindPixels");
63 fBlindId.SetDirectory(NULL);
64 fBlindId.SetXTitle("\\Theta [\\circ]");
65 fBlindId.SetYTitle("pixel Id");
66
67 fBlindN.SetName("2D-NBlindPixels");
68 fBlindN.SetTitle("2D-NBlindPixels");
69 fBlindN.SetDirectory(NULL);
70 fBlindN.SetXTitle("\\Theta [\\circ]");
71 fBlindN.SetYTitle("number of blind pixels");
72}
73
74// --------------------------------------------------------------------------
75//
76// Set the binnings and prepare the filling of the histogram
77//
78Bool_t MHBlindPixels::SetupFill(const MParList *plist)
79{
80 fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
81 if (!fMcEvt)
82 {
83 *fLog << err << "MMcEvt not found... aborting." << endl;
84 return kFALSE;
85 }
86
87 fPed = (MPedestalCam*)plist->FindObject("MPedestalCam");
88 if (!fPed)
89 {
90 *fLog << err << "MPedestalCam not found... aborting." << endl;
91 return kFALSE;
92 }
93
94
95 // Get Theta Binning
96 MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta", "MBinning");
97 if (!binstheta)
98 {
99 *fLog << err << "Object 'BinningTheta' [MBinning] not found... aborting" << endl;
100 return kFALSE;
101 }
102
103 // Get binning for pixel number
104 const UInt_t npix1 = fPed->GetSize()+1;
105
106 MBinning binspix("BinningPixel");
107 binspix.SetEdges(npix1, -0.5, npix1-0.5);
108
109 // Set binnings in histograms
110 SetBinning(&fBlindId, binstheta, &binspix);
111 SetBinning(&fBlindN, binstheta, &binspix);
112
113 return kTRUE;
114}
115
116// ------------------------------------------------------------------------
117//
118// Drawing function. It creates its own canvas.
119//
120void MHBlindPixels::Draw(Option_t *option)
121{
122 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
123 pad->SetBorderMode(0);
124
125 pad->Divide(2,2);
126
127 TH1D *h;
128
129 pad->cd(1);
130 fBlindId.Draw(option);
131
132 pad->cd(2);
133 fBlindN.Draw(option);
134
135 pad->cd(3);
136 gPad->SetBorderMode(0);
137 h = ((TH2*)&fBlindId)->ProjectionY("ProjY-pixId", -1, 9999, "");
138 h->SetDirectory(NULL);
139 h->SetTitle("Distribution of blind pixel Id");
140 h->SetXTitle("Id of blind pixel");
141 h->SetYTitle("No. of events");
142 h->Draw(option);
143 h->SetBit(kCanDelete);
144
145 pad->cd(4);
146 gPad->SetBorderMode(0);
147 h = ((TH2*)&fBlindN)->ProjectionY("ProjY-pixN", -1, 9999, "");
148 h->SetDirectory(NULL);
149 h->SetTitle("Distribution of no.of blind pixels");
150 h->SetXTitle("No. of blind pixels");
151 h->SetYTitle("No. of events");
152 h->Draw(option);
153 h->SetBit(kCanDelete);
154
155 pad->Modified();
156 pad->Update();
157}
158
159Bool_t MHBlindPixels::Fill(const MParContainer *par, const Stat_t w)
160{
161 if (!par)
162 return kFALSE;
163
164 Double_t theta = fMcEvt->GetTelescopeTheta()*kRad2Deg;
165 const MBlindPixels &bp = *(MBlindPixels*)par;
166
167 // FIXME: Slow.
168 const UInt_t npix = fPed->GetSize();
169
170 UInt_t nb = 0;
171 for (UInt_t i=0; i<npix; i++)
172 {
173 if (bp.IsBlind(i))
174 {
175 fBlindId.Fill(theta, i, w);
176 nb++;
177 }
178 }
179 fBlindN.Fill(theta, nb, w);
180
181 return kTRUE;
182}
183
184
185
186
187
188
189
190
191
192
193
194
Note: See TracBrowser for help on using the repository browser.