source: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeBlindCam.cc@ 4833

Last change on this file since 4833 was 4694, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 8.7 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): Markus Gaug 02/2004 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24/////////////////////////////////////////////////////////////////////////////
25//
26// MHCalibrationChargeBlindCam
27//
28// Histogram class for blind pixels in the camera. Incorporates the TObjArray's:
29// - fBlindPixelsArray (for calibrated High Gains per pixel)
30//
31/////////////////////////////////////////////////////////////////////////////
32#include "MHCalibrationChargeBlindCam.h"
33#include "MHCalibrationChargeBlindPix.h"
34
35#include <TVirtualPad.h>
36#include <TCanvas.h>
37#include <TPad.h>
38
39#include "MLog.h"
40#include "MLogManip.h"
41
42#include "MCalibrationChargeBlindPix.h"
43#include "MCalibrationChargeBlindCam.h"
44
45#include "MExtractedSignalBlindPixel.h"
46
47#include "MParList.h"
48
49#include "MRawRunHeader.h"
50
51ClassImp(MHCalibrationChargeBlindCam);
52
53using namespace std;
54
55// --------------------------------------------------------------------------
56//
57// Default Constructor.
58//
59// Sets:
60// - all pointers to NULL
61//
62// Initializes and sets owner of:
63// - fBlindPixelsArray
64//
65// Sets fFitFunc to kEPoisson4
66//
67MHCalibrationChargeBlindCam::MHCalibrationChargeBlindCam(const char *name, const char *title)
68 : fCam(NULL), fRunHeader(NULL)
69{
70
71 fName = name ? name : "MHCalibrationChargeBlindCam";
72 fTitle = title ? title : "Class to fille the blind pixel histograms";
73
74 fBlindPixelsArray = new TObjArray;
75 fBlindPixelsArray->SetOwner();
76
77 fFitFunc = MHCalibrationChargeBlindPix::kEPoisson4;
78
79}
80
81// --------------------------------------------------------------------------
82//
83// Deletes the TClonesArray of:
84// - fBlindPixelsArray
85//
86MHCalibrationChargeBlindCam::~MHCalibrationChargeBlindCam()
87{
88 delete fBlindPixelsArray;
89}
90
91// --------------------------------------------------------------------------
92//
93// Get i-th High Gain pixel (pixel number)
94//
95MHCalibrationChargeBlindPix &MHCalibrationChargeBlindCam::operator[](UInt_t i)
96{
97 return *static_cast<MHCalibrationChargeBlindPix*>(fBlindPixelsArray->UncheckedAt(i));
98}
99
100// --------------------------------------------------------------------------
101//
102// Get i-th High Gain pixel (pixel number)
103//
104const MHCalibrationChargeBlindPix &MHCalibrationChargeBlindCam::operator[](UInt_t i) const
105{
106 return *static_cast<MHCalibrationChargeBlindPix*>(fBlindPixelsArray->UncheckedAt(i));
107}
108
109// --------------------------------------------------------------------------
110//
111// Our own clone function is necessary since root 3.01/06 or Mars 0.4
112// I don't know the reason.
113//
114// Creates new MHCalibrationChargeBlindCam
115// Deletes the TObjArray's and Clones them individually
116//
117TObject *MHCalibrationChargeBlindCam::Clone(const char *name) const
118{
119
120 const Int_t nhi = fBlindPixelsArray->GetEntries();
121
122 //
123 // FIXME, this might be done faster and more elegant, by direct copy.
124 //
125 MHCalibrationChargeBlindCam *cam = new MHCalibrationChargeBlindCam();
126
127 cam->fBlindPixelsArray->Expand(nhi);
128
129 for (int i=0; i<nhi; i++)
130 (*cam->fBlindPixelsArray)[i] = (*fBlindPixelsArray)[i]->Clone();
131
132 return cam;
133}
134
135// --------------------------------------------------------------------------
136//
137// Gets the pointers to:
138// - MRunHeader
139// - MExtractedSignalBlindPix
140//
141// Calls Delete-Function of:
142// - MHCalibrationChargeBlindCam::fBlindPixelsArray
143//
144Bool_t MHCalibrationChargeBlindCam::SetupFill(const MParList *pList)
145{
146
147 fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
148 if (!fRunHeader)
149 {
150 *fLog << warn << GetDescriptor()
151 << ": MRawRunHeader not found... will not store run numbers." << endl;
152 return kFALSE;
153 }
154
155 fSignal = (MExtractedSignalBlindPixel*)pList->FindObject("MExtractedSignalBlindPixel");
156 if (!fSignal)
157 {
158 *fLog << err << "MExtractedSignalBlindPixel not found... aborting " << endl;
159 return kFALSE;
160 }
161
162 fBlindPixelsArray->Delete();
163
164 return kTRUE;
165}
166
167
168// --------------------------------------------------------------------------
169//
170// Initializes, if empty to MExtractedSignalCam::GetSize() for:
171// - MHCalibrationChargeBlindCam::fBlindPixelsArray
172//
173// Calls InitializeHists() for every entry in:
174// - MHCalibrationChargeBlindCam::fBlindPixelsArray
175//
176// Retrieves the run numbers from MRawRunHeader and stores them in fRunNumbers
177//
178Bool_t MHCalibrationChargeBlindCam::ReInit(MParList *pList)
179{
180
181 const UInt_t nblindpixels = fSignal->GetNumBlindPixels();
182
183 Int_t runnr = 0;
184
185 if (fRunHeader)
186 runnr = fRunHeader->GetRunNumber();
187
188 fCam = (MCalibrationChargeBlindCam*)pList->FindCreateObj("MCalibrationChargeBlindCam");
189 if (!fCam)
190 {
191 *fLog << err << "Cannot find nor create MCalibrationChargeBlindCam ... abort." << endl;
192 return kFALSE;
193 }
194
195 if (fCam->GetNumBlindPixels() != nblindpixels)
196 {
197 *fLog << err;
198 *fLog << "Size mismatch in MCalibrationChargeBlindCam ... abort." << endl;
199 *fLog << " Size of MCalibrationChargeBlindCam: " << fCam->GetNumBlindPixels() << endl;
200 *fLog << " Size of MExtractedSignalBlindPixel: " << nblindpixels << endl;
201 return kFALSE;
202 }
203
204
205 const Int_t samples = fSignal->GetNumFADCSamples();
206 const Int_t integ = fSignal->IsExtractionType( MExtractBlindPixel::kIntegral );
207
208 if (fBlindPixelsArray->GetEntries()==0)
209 {
210
211 fBlindPixelsArray->Expand(nblindpixels);
212
213 for (UInt_t i=0; i<nblindpixels; i++)
214 {
215 (*fBlindPixelsArray)[i] = new MHCalibrationChargeBlindPix;
216 (*this)[i].ChangeHistId(i);
217 if (integ)
218 {
219 (*this)[i].SetLast( samples * integ *
220 ((*this)[i].GetLast()+0.5) - 0.5 );
221 (*this)[i].SetSinglePheCut( samples * integ *
222 (*this)[i].GetSinglePheCut() );
223 }
224 (*this)[i].InitBins();
225 TH1F *h = (*this)[i].GetHGausHist();
226 h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
227 (*this)[i].ChangeFitFunc(fFitFunc);
228 (*this)[i].SetupFill(pList);
229 (*this)[i].SetCalibrationChargeBlindPix(&(*fCam)[i]);
230 }
231 }
232
233 for (UInt_t i=0; i<nblindpixels; i++)
234 {
235 TH1F *h = (*this)[i].GetHGausHist();
236 h->SetTitle( Form("%s%i%s", h->GetTitle(),runnr," "));
237 }
238
239 return kTRUE;
240}
241
242
243//--------------------------------------------------------------------------------
244//
245// Retrieves from MExtractedSignalBlindPixel:
246// - number of blind pixels
247//
248// For all TObjArray's, the following steps are performed:
249//
250// 1) Test size and return kFALSE if not matching
251// 2)
252//
253Bool_t MHCalibrationChargeBlindCam::Fill(const MParContainer *par, const Stat_t w)
254{
255
256 const Int_t nblindpixels = fSignal->GetNumBlindPixels();
257
258 if (GetSize() != nblindpixels)
259 {
260 gLog << err << "ERROR - Size mismatch... abort." << endl;
261 return kFALSE;
262 }
263
264 for (Int_t i=0; i<nblindpixels; i++)
265 (*this)[i].Fill(par,w);
266
267 return kTRUE;
268}
269
270// --------------------------------------------------------------------------
271//
272// Calls the Finalize() function of the blind pixels
273//
274Bool_t MHCalibrationChargeBlindCam::Finalize()
275{
276
277 for (Int_t i=0; i<GetSize(); i++)
278 if (!(*this)[i].Finalize())
279 return kFALSE;
280
281 return kTRUE;
282}
283
284
285
286// -----------------------------------------------------------------------------
287//
288// Default draw:
289//
290// Displays the averaged areas, both High Gain and Low Gain
291//
292// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
293//
294void MHCalibrationChargeBlindCam::Draw(Option_t *opt)
295{
296
297 const Int_t size = fBlindPixelsArray->GetEntries();
298
299 if (size == 0)
300 return;
301
302 TString option(opt);
303 option.ToLower();
304
305 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
306 pad->SetBorderMode(0);
307
308 switch (size)
309 {
310 case 1:
311 break;
312 case 2:
313 pad->Divide(2,1);
314 break;
315 case 3:
316 case 4:
317 pad->Divide(2,2);
318 break;
319 default:
320 pad->Divide(size/2+1,size/2+1);
321 break;
322 }
323
324 for (Int_t i=0; i<size;i++)
325 {
326 pad->cd(i+1);
327 (*this)[i].Draw(option);
328 }
329
330 pad->Modified();
331 pad->Update();
332
333}
Note: See TracBrowser for help on using the repository browser.