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

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