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

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