source: trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindCam.cc@ 4976

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