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

Last change on this file since 2128 was 2128, checked in by wittek, 21 years ago
*** empty log message ***
File size: 4.8 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
46// -------------------------------------------------------------------------
47//
48// Default Constructor.
49//
50MHBlindPixels::MHBlindPixels(const char *name, const char *title)
51{
52 fName = name ? name : "MHBlindPixels";
53 fTitle = title ? title : "Histogram for Blind Pixels vs. Theta";
54
55 // - we initialize the histogram
56 // - we have to give different names for the different histograms because
57 // root don't allow us to have diferent histograms with the same name
58
59 fBlindId.SetName("2D-IdBlindPixels");
60 fBlindId.SetTitle("2D-IdBlindPixels");
61 fBlindId.SetDirectory(NULL);
62 fBlindId.SetXTitle("\\Theta [\\circ]");
63 fBlindId.SetYTitle("pixel Id");
64
65 fBlindN.SetName("2D-NBlindPixels");
66 fBlindN.SetTitle("2D-NBlindPixels");
67 fBlindN.SetDirectory(NULL);
68 fBlindN.SetXTitle("\\Theta [\\circ]");
69 fBlindN.SetYTitle("number of blind pixels");
70}
71
72// --------------------------------------------------------------------------
73//
74// Set the binnings and prepare the filling of the histogram
75//
76Bool_t MHBlindPixels::SetupFill(const MParList *plist)
77{
78 fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
79 if (!fMcEvt)
80 {
81 *fLog << err << "MMcEvt not found... aborting." << endl;
82 return kFALSE;
83 }
84
85 fPed = (MPedestalCam*)plist->FindObject("MPedestalCam");
86 if (!fPed)
87 {
88 *fLog << err << "MPedestalCam not found... aborting." << endl;
89 return kFALSE;
90 }
91
92
93 // Get Theta Binning
94 MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta", "MBinning");
95 if (!binstheta)
96 {
97 *fLog << err << "Object 'BinningTheta' [MBinning] not found... aborting" << endl;
98 return kFALSE;
99 }
100
101 // Get binning for pixel number
102 const UInt_t npix1 = fPed->GetSize()+1;
103
104 MBinning binspix("BinningPixel");
105 binspix.SetEdges(npix1, -0.5, npix1-0.5);
106
107 // Set binnings in histograms
108 SetBinning(&fBlindId, binstheta, &binspix);
109 SetBinning(&fBlindN, binstheta, &binspix);
110
111 return kTRUE;
112}
113
114// ------------------------------------------------------------------------
115//
116// Drawing function. It creates its own canvas.
117//
118void MHBlindPixels::Draw(Option_t *option)
119{
120 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
121 pad->SetBorderMode(0);
122
123 pad->Divide(2,2);
124
125 TH1D *h;
126
127 pad->cd(1);
128 fBlindId.Draw(option);
129
130 pad->cd(2);
131 fBlindN.Draw(option);
132
133 pad->cd(3);
134 gPad->SetBorderMode(0);
135 h = ((TH2*)&fBlindId)->ProjectionY("ProjY-pixId", -1, 9999, "");
136 h->SetDirectory(NULL);
137 h->SetTitle("Distribution of blind pixel Id");
138 h->SetXTitle("Id of blind pixel");
139 h->SetYTitle("No. of events");
140 h->Draw(option);
141 h->SetBit(kCanDelete);
142
143 pad->cd(4);
144 gPad->SetBorderMode(0);
145 h = ((TH2*)&fBlindN)->ProjectionY("ProjY-pixN", -1, 9999, "");
146 h->SetDirectory(NULL);
147 h->SetTitle("Distribution of no.of blind pixels");
148 h->SetXTitle("No. of blind pixels");
149 h->SetYTitle("No. of events");
150 h->Draw(option);
151 h->SetBit(kCanDelete);
152
153 pad->Modified();
154 pad->Update();
155}
156
157Bool_t MHBlindPixels::Fill(const MParContainer *par, const Stat_t w)
158{
159 if (!par)
160 return kFALSE;
161
162 Double_t theta = fMcEvt->GetTelescopeTheta()*kRad2Deg;
163 const MBlindPixels &bp = *(MBlindPixels*)par;
164
165 // FIXME: Slow.
166 const UInt_t npix = fPed->GetSize();
167
168 UInt_t nb = 0;
169 for (UInt_t i=0; i<npix; i++)
170 {
171 if (bp.IsBlind(i))
172 {
173 fBlindId.Fill(theta, i, w);
174 nb++;
175 }
176 }
177 fBlindN.Fill(theta, nb, w);
178
179 return kTRUE;
180}
181
182
183
184
185
186
187
188
189
190
191
192
Note: See TracBrowser for help on using the repository browser.