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

Last change on this file since 3140 was 3140, checked in by wittek, 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 "MPedPhotCam.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
88 fPedPhot = (MPedPhotCam*)plist->FindObject("MPedPhotCam");
89 if (!fPedPhot)
90 {
91 *fLog << err << "MPedPhotCam not found... aborting." << endl;
92 return kFALSE;
93 }
94
95
96 // Get Theta Binning
97 MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta", "MBinning");
98 if (!binstheta)
99 {
100 *fLog << err << "Object 'BinningTheta' [MBinning] not found... aborting" << endl;
101 return kFALSE;
102 }
103
104 // Get binning for pixel number
105 const UInt_t npix1 = fPedPhot->GetSize()+1;
106
107 MBinning binspix("BinningPixel");
108 binspix.SetEdges(npix1, -0.5, npix1-0.5);
109
110 // Set binnings in histograms
111 SetBinning(&fBlindId, binstheta, &binspix);
112 SetBinning(&fBlindN, binstheta, &binspix);
113
114 return kTRUE;
115}
116
117// ------------------------------------------------------------------------
118//
119// Drawing function. It creates its own canvas.
120//
121void MHBlindPixels::Draw(Option_t *option)
122{
123 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
124 pad->SetBorderMode(0);
125
126 pad->Divide(2,2);
127
128 TH1D *h;
129
130 pad->cd(1);
131 fBlindId.Draw(option);
132
133 pad->cd(2);
134 fBlindN.Draw(option);
135
136 pad->cd(3);
137 gPad->SetBorderMode(0);
138 h = ((TH2*)&fBlindId)->ProjectionY("ProjY-pixId", -1, 9999, "");
139 h->SetDirectory(NULL);
140 h->SetTitle("Distribution of blind pixel Id");
141 h->SetXTitle("Id of blind pixel");
142 h->SetYTitle("No. of events");
143 h->Draw(option);
144 h->SetBit(kCanDelete);
145
146 pad->cd(4);
147 gPad->SetBorderMode(0);
148 h = ((TH2*)&fBlindN)->ProjectionY("ProjY-pixN", -1, 9999, "");
149 h->SetDirectory(NULL);
150 h->SetTitle("Distribution of no.of blind pixels");
151 h->SetXTitle("No. of blind pixels");
152 h->SetYTitle("No. of events");
153 h->Draw(option);
154 h->SetBit(kCanDelete);
155
156 pad->Modified();
157 pad->Update();
158}
159
160Bool_t MHBlindPixels::Fill(const MParContainer *par, const Stat_t w)
161{
162 if (!par)
163 return kFALSE;
164
165 Double_t theta = fMcEvt->GetTelescopeTheta()*kRad2Deg;
166 const MBlindPixels &bp = *(MBlindPixels*)par;
167
168 // FIXME: Slow.
169 const UInt_t npix = fPedPhot->GetSize();
170
171 UInt_t nb = 0;
172 for (UInt_t i=0; i<npix; i++)
173 {
174 if (bp.IsBlind(i))
175 {
176 fBlindId.Fill(theta, i, w);
177 nb++;
178 }
179 }
180 fBlindN.Fill(theta, nb, w);
181
182 return kTRUE;
183}
184
185
186
187
188
189
190
191
192
193
194
195
Note: See TracBrowser for help on using the repository browser.