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

Last change on this file since 4693 was 4669, checked in by gaug, 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 Int_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 << "Size mismatch in MCalibrationChargeBlindCam ... abort." << endl;
198 *fLog << err << "Size of MCalibrationChargeBlindCam: " << fCam->GetNumBlindPixels()
199 << "Size of MExtractedSignalBlindPixel: " << nblindpixels << endl;
200 return kFALSE;
201 }
202
203
204 const Int_t samples = fSignal->GetNumFADCSamples();
205 const Int_t integ = fSignal->IsExtractionType( MExtractBlindPixel::kIntegral );
206
207 if (fBlindPixelsArray->GetEntries()==0)
208 {
209
210 fBlindPixelsArray->Expand(nblindpixels);
211
212 for (Int_t i=0; i<nblindpixels; i++)
213 {
214 (*fBlindPixelsArray)[i] = new MHCalibrationChargeBlindPix;
215 (*this)[i].ChangeHistId(i);
216 if (integ)
217 {
218 (*this)[i].SetLast( samples * integ *
219 ((*this)[i].GetLast()+0.5) - 0.5 );
220 (*this)[i].SetSinglePheCut( samples * integ *
221 (*this)[i].GetSinglePheCut() );
222 }
223 (*this)[i].InitBins();
224 TH1F *h = (*this)[i].GetHGausHist();
225 h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
226 (*this)[i].ChangeFitFunc(fFitFunc);
227 (*this)[i].SetupFill(pList);
228 (*this)[i].SetCalibrationChargeBlindPix(&(*fCam)[i]);
229 }
230 }
231
232 for (Int_t i=0; i<nblindpixels; i++)
233 {
234 TH1F *h = (*this)[i].GetHGausHist();
235 h->SetTitle( Form("%s%i%s", h->GetTitle(),runnr," "));
236 }
237
238 return kTRUE;
239}
240
241
242//--------------------------------------------------------------------------------
243//
244// Retrieves from MExtractedSignalBlindPixel:
245// - number of blind pixels
246//
247// For all TObjArray's, the following steps are performed:
248//
249// 1) Test size and return kFALSE if not matching
250// 2)
251//
252Bool_t MHCalibrationChargeBlindCam::Fill(const MParContainer *par, const Stat_t w)
253{
254
255 const Int_t nblindpixels = fSignal->GetNumBlindPixels();
256
257 if (GetSize() != nblindpixels)
258 {
259 gLog << err << "ERROR - Size mismatch... abort." << endl;
260 return kFALSE;
261 }
262
263 for (Int_t i=0; i<nblindpixels; i++)
264 (*this)[i].Fill(par,w);
265
266 return kTRUE;
267}
268
269// --------------------------------------------------------------------------
270//
271// Calls the Finalize() function of the blind pixels
272//
273Bool_t MHCalibrationChargeBlindCam::Finalize()
274{
275
276 for (Int_t i=0; i<GetSize(); i++)
277 if (!(*this)[i].Finalize())
278 return kFALSE;
279
280 return kTRUE;
281}
282
283
284
285// -----------------------------------------------------------------------------
286//
287// Default draw:
288//
289// Displays the averaged areas, both High Gain and Low Gain
290//
291// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
292//
293void MHCalibrationChargeBlindCam::Draw(Option_t *opt)
294{
295
296 const Int_t size = fBlindPixelsArray->GetEntries();
297
298 if (size == 0)
299 return;
300
301 TString option(opt);
302 option.ToLower();
303
304 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
305 pad->SetBorderMode(0);
306
307 switch (size)
308 {
309 case 1:
310 break;
311 case 2:
312 pad->Divide(2,1);
313 break;
314 case 3:
315 case 4:
316 pad->Divide(2,2);
317 break;
318 default:
319 pad->Divide(size/2+1,size/2+1);
320 break;
321 }
322
323 for (Int_t i=0; i<size;i++)
324 {
325 pad->cd(i+1);
326 (*this)[i].Draw(option);
327 }
328
329 pad->Modified();
330 pad->Update();
331
332}
Note: See TracBrowser for help on using the repository browser.