1 | /* ======================================================================== *\
|
---|
2 | ! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.109 2008-06-30 09:36:38 tbretz Exp $
|
---|
3 | ! --------------------------------------------------------------------------
|
---|
4 | !
|
---|
5 | ! *
|
---|
6 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
7 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
8 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
9 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
10 | ! *
|
---|
11 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
12 | ! * documentation for any purpose is hereby granted without fee,
|
---|
13 | ! * provided that the above copyright notice appear in all copies and
|
---|
14 | ! * that both that copyright notice and this permission notice appear
|
---|
15 | ! * in supporting documentation. It is provided "as is" without express
|
---|
16 | ! * or implied warranty.
|
---|
17 | ! *
|
---|
18 | !
|
---|
19 | !
|
---|
20 | ! Author(s): Thomas Bretz, 05/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
21 | ! Author(s): Harald Kornmayer, 1/2001
|
---|
22 | ! Author(s): Markus Gaug, 03/2004 <mailto:markus@ifae.es>
|
---|
23 | !
|
---|
24 | ! Copyright: MAGIC Software Development, 2000-2008
|
---|
25 | !
|
---|
26 | !
|
---|
27 | \* ======================================================================== */
|
---|
28 |
|
---|
29 | /////////////////////////////////////////////////////////////////////////////
|
---|
30 | //
|
---|
31 | // MHCamera
|
---|
32 | //
|
---|
33 | // Camera Display, based on a TH1D. Pleas be carefull using the
|
---|
34 | // underlaying TH1D.
|
---|
35 | //
|
---|
36 | // To change the scale to a logarithmic scale SetLogy() of the Pad.
|
---|
37 | //
|
---|
38 | // You can correct for the abberation. Assuming that the distance
|
---|
39 | // between the mean position of the light distribution and the position
|
---|
40 | // of a perfect reflection on a perfect mirror in the distance r on
|
---|
41 | // the camera plane is dr it is d = a*dr while a is the abberation
|
---|
42 | // constant (for the MAGIC mirror it is roughly 0.0713). You can
|
---|
43 | // set this constant by calling SetAbberation(a) which results in a
|
---|
44 | // 'corrected' display (all outer pixels are shifted towards the center
|
---|
45 | // of the camera to correct for this abberation)
|
---|
46 | //
|
---|
47 | // Be carefull: Entries in this context means Entries/bin or Events
|
---|
48 | //
|
---|
49 | // FIXME? Maybe MHCamera can take the fLog object from MGeomCam?
|
---|
50 | //
|
---|
51 | ////////////////////////////////////////////////////////////////////////////
|
---|
52 | #include "MHCamera.h"
|
---|
53 |
|
---|
54 | #include <fstream>
|
---|
55 | #include <iostream>
|
---|
56 |
|
---|
57 | #include <TBox.h>
|
---|
58 | #include <TArrow.h>
|
---|
59 | #include <TLatex.h>
|
---|
60 | #include <TStyle.h>
|
---|
61 | #include <TCanvas.h>
|
---|
62 | #include <TArrayF.h>
|
---|
63 | #include <TRandom.h>
|
---|
64 | #include <TPaveText.h>
|
---|
65 | #include <TPaveStats.h>
|
---|
66 | #include <TClonesArray.h>
|
---|
67 | #include <THistPainter.h>
|
---|
68 | #include <THLimitsFinder.h>
|
---|
69 | #include <TProfile.h>
|
---|
70 | #include <TH1.h>
|
---|
71 | #include <TF1.h>
|
---|
72 | #include <TCanvas.h>
|
---|
73 | #include <TLegend.h>
|
---|
74 |
|
---|
75 | #include "MLog.h"
|
---|
76 | #include "MLogManip.h"
|
---|
77 |
|
---|
78 | #include "MH.h"
|
---|
79 | #include "MBinning.h"
|
---|
80 | #include "MHexagon.h"
|
---|
81 |
|
---|
82 | #include "MGeomPix.h"
|
---|
83 | #include "MGeomCam.h"
|
---|
84 |
|
---|
85 | #include "MCamEvent.h"
|
---|
86 |
|
---|
87 | #include "MArrayD.h"
|
---|
88 | #include "MMath.h" // MMath::GaussProb
|
---|
89 |
|
---|
90 | ClassImp(MHCamera);
|
---|
91 |
|
---|
92 | using namespace std;
|
---|
93 |
|
---|
94 | void MHCamera::Init()
|
---|
95 | {
|
---|
96 | Sumw2();
|
---|
97 |
|
---|
98 | UseCurrentStyle();
|
---|
99 |
|
---|
100 | SetDirectory(NULL);
|
---|
101 |
|
---|
102 | SetLineColor(kGreen);
|
---|
103 | SetMarkerStyle(kFullDotMedium);
|
---|
104 | SetXTitle("Pixel Index");
|
---|
105 |
|
---|
106 | fNotify = new TList;
|
---|
107 | fNotify->SetBit(kMustCleanup);
|
---|
108 | gROOT->GetListOfCleanups()->Add(fNotify);
|
---|
109 |
|
---|
110 | TVirtualPad *save = gPad;
|
---|
111 | gPad = 0;
|
---|
112 | /*
|
---|
113 | #if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)
|
---|
114 | SetPalette(1, 0);
|
---|
115 | #endif
|
---|
116 | */
|
---|
117 | /*
|
---|
118 | #if ROOT_VERSION_CODE < ROOT_VERSION(4,04,00)
|
---|
119 | SetPrettyPalette();
|
---|
120 | #elese
|
---|
121 | // WORAROUND - FIXME: Calling it many times becomes slower and slower
|
---|
122 | SetInvDeepBlueSeaPalette();
|
---|
123 | #endif
|
---|
124 | */
|
---|
125 | gPad = save;
|
---|
126 | }
|
---|
127 |
|
---|
128 | // ------------------------------------------------------------------------
|
---|
129 | //
|
---|
130 | // Default Constructor. To be used by the root system ONLY.
|
---|
131 | //
|
---|
132 | MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fAbberation(0)
|
---|
133 | {
|
---|
134 | Init();
|
---|
135 | }
|
---|
136 |
|
---|
137 | // ------------------------------------------------------------------------
|
---|
138 | //
|
---|
139 | // Constructor. Makes a clone of MGeomCam. Removed the TH1D from the
|
---|
140 | // current directory. Calls Sumw2(). Set the histogram line color
|
---|
141 | // (for error bars) to Green and the marker style to kFullDotMedium.
|
---|
142 | //
|
---|
143 | MHCamera::MHCamera(const MGeomCam &geom, const char *name, const char *title)
|
---|
144 | : fGeomCam(NULL), fAbberation(0)
|
---|
145 | {
|
---|
146 | //fGeomCam = (MGeomCam*)geom.Clone();
|
---|
147 | SetGeometry(geom, name, title);
|
---|
148 | Init();
|
---|
149 |
|
---|
150 | //
|
---|
151 | // root 3.02
|
---|
152 | // * base/inc/TObject.h:
|
---|
153 | // register BIT(8) as kNoContextMenu. If an object has this bit set it will
|
---|
154 | // not get an automatic context menu when clicked with the right mouse button.
|
---|
155 | }
|
---|
156 |
|
---|
157 | // ------------------------------------------------------------------------
|
---|
158 | //
|
---|
159 | // Clone the MHCamera via TH1D::Clone and make sure that the new object is
|
---|
160 | // not removed from the current directory.
|
---|
161 | //
|
---|
162 | TObject *MHCamera::Clone(const char *newname) const
|
---|
163 | {
|
---|
164 | MHCamera *rc = static_cast<MHCamera*>(TH1D::Clone(newname));
|
---|
165 | rc->SetDirectory(NULL);
|
---|
166 |
|
---|
167 | // fGeomCam need special treatment due to its TObjArray
|
---|
168 | if (rc->fGeomCam && fGeomCam)
|
---|
169 | {
|
---|
170 | delete rc->fGeomCam;
|
---|
171 | rc->fGeomCam = static_cast<MGeomCam*>(fGeomCam->Clone());
|
---|
172 | }
|
---|
173 |
|
---|
174 | return rc;
|
---|
175 | }
|
---|
176 |
|
---|
177 | void MHCamera::SetGeometry(const MGeomCam &geom, const char *name, const char *title)
|
---|
178 | {
|
---|
179 | SetNameTitle(name, title);
|
---|
180 |
|
---|
181 | TAxis &x = *GetXaxis();
|
---|
182 |
|
---|
183 | SetBins(geom.GetNumPixels(), 0, 1);
|
---|
184 | x.Set(geom.GetNumPixels(), -0.5, geom.GetNumPixels()-0.5);
|
---|
185 |
|
---|
186 | //SetBins(geom.GetNumPixels(), -0.5, geom.GetNumPixels()-0.5);
|
---|
187 | //Rebuild();
|
---|
188 |
|
---|
189 | if (fGeomCam)
|
---|
190 | delete fGeomCam;
|
---|
191 | fGeomCam = (MGeomCam*)geom.Clone();
|
---|
192 |
|
---|
193 | fUsed.Set(geom.GetNumPixels());
|
---|
194 | fUsed.Reset();
|
---|
195 |
|
---|
196 | fBinEntries.Set(geom.GetNumPixels()+2);
|
---|
197 | fBinEntries.Reset();
|
---|
198 | }
|
---|
199 |
|
---|
200 | // ------------------------------------------------------------------------
|
---|
201 | //
|
---|
202 | // Destructor. Deletes the cloned fGeomCam and the notification list.
|
---|
203 | //
|
---|
204 | MHCamera::~MHCamera()
|
---|
205 | {
|
---|
206 | if (fGeomCam)
|
---|
207 | delete fGeomCam;
|
---|
208 | if (fNotify)
|
---|
209 | delete fNotify;
|
---|
210 | }
|
---|
211 |
|
---|
212 | // ------------------------------------------------------------------------
|
---|
213 | //
|
---|
214 | // Return kTRUE for sector<0. Otherwise return kTRUE only if the specified
|
---|
215 | // sector idx matches the sector of the pixel with index idx.
|
---|
216 | //
|
---|
217 | Bool_t MHCamera::MatchSector(Int_t idx, const TArrayI §or, const TArrayI &aidx) const
|
---|
218 | {
|
---|
219 | const MGeomPix &pix = (*fGeomCam)[idx];
|
---|
220 | return FindVal(sector, pix.GetSector()) && FindVal(aidx, pix.GetAidx());
|
---|
221 | }
|
---|
222 |
|
---|
223 | // ------------------------------------------------------------------------
|
---|
224 | //
|
---|
225 | // Taken from TH1D::Fill(). Uses the argument directly as bin index.
|
---|
226 | // Doesn't increment the number of entries.
|
---|
227 | //
|
---|
228 | // -*-*-*-*-*-*-*-*Increment bin with abscissa X by 1*-*-*-*-*-*-*-*-*-*-*
|
---|
229 | // ==================================
|
---|
230 | //
|
---|
231 | // if x is less than the low-edge of the first bin, the Underflow bin is incremented
|
---|
232 | // if x is greater than the upper edge of last bin, the Overflow bin is incremented
|
---|
233 | //
|
---|
234 | // If the storage of the sum of squares of weights has been triggered,
|
---|
235 | // via the function Sumw2, then the sum of the squares of weights is incremented
|
---|
236 | // by 1 in the bin corresponding to x.
|
---|
237 | //
|
---|
238 | // -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
---|
239 | Int_t MHCamera::Fill(Axis_t x)
|
---|
240 | {
|
---|
241 | #if ROOT_VERSION_CODE > ROOT_VERSION(3,05,00)
|
---|
242 | if (fBuffer) return BufferFill(x,1);
|
---|
243 | #endif
|
---|
244 | const Int_t bin = (Int_t)x+1;
|
---|
245 | AddBinContent(bin);
|
---|
246 | fBinEntries[bin]++;
|
---|
247 | if (fSumw2.fN)
|
---|
248 | fSumw2.fArray[bin]++;
|
---|
249 |
|
---|
250 | if (bin<=0 || bin>fNcells-2)
|
---|
251 | return -1;
|
---|
252 |
|
---|
253 | fTsumw++;
|
---|
254 | fTsumw2++;
|
---|
255 | fTsumwx += x;
|
---|
256 | fTsumwx2 += x*x;
|
---|
257 | return bin;
|
---|
258 | }
|
---|
259 |
|
---|
260 | // ------------------------------------------------------------------------
|
---|
261 | //
|
---|
262 | // Taken from TH1D::Fill(). Uses the argument directly as bin index.
|
---|
263 | // Doesn't increment the number of entries.
|
---|
264 | //
|
---|
265 | // -*-*-*-*-*-*Increment bin with abscissa X with a weight w*-*-*-*-*-*-*-*
|
---|
266 | // =============================================
|
---|
267 | //
|
---|
268 | // if x is less than the low-edge of the first bin, the Underflow bin is incremented
|
---|
269 | // if x is greater than the upper edge of last bin, the Overflow bin is incremented
|
---|
270 | //
|
---|
271 | // If the storage of the sum of squares of weights has been triggered,
|
---|
272 | // via the function Sumw2, then the sum of the squares of weights is incremented
|
---|
273 | // by w^2 in the bin corresponding to x.
|
---|
274 | //
|
---|
275 | // -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
---|
276 | Int_t MHCamera::Fill(Axis_t x, Stat_t w)
|
---|
277 | {
|
---|
278 | #if ROOT_VERSION_CODE > ROOT_VERSION(3,05,00)
|
---|
279 | if (fBuffer) return BufferFill(x,w);
|
---|
280 | #endif
|
---|
281 | const Int_t bin = (Int_t)x+1;
|
---|
282 | AddBinContent(bin, w);
|
---|
283 | fBinEntries[bin]++;
|
---|
284 | if (fSumw2.fN)
|
---|
285 | fSumw2.fArray[bin] += w*w;
|
---|
286 |
|
---|
287 | if (bin<=0 || bin>fNcells-2)
|
---|
288 | return -1;
|
---|
289 |
|
---|
290 | const Stat_t z = (w > 0 ? w : -w);
|
---|
291 | fTsumw += z;
|
---|
292 | fTsumw2 += z*z;
|
---|
293 | fTsumwx += z*x;
|
---|
294 | fTsumwx2 += z*x*x;
|
---|
295 | return bin;
|
---|
296 | }
|
---|
297 |
|
---|
298 | // ------------------------------------------------------------------------
|
---|
299 | //
|
---|
300 | // Use x and y in millimeters
|
---|
301 | //
|
---|
302 | Int_t MHCamera::Fill(Axis_t x, Axis_t y, Stat_t w)
|
---|
303 | {
|
---|
304 | if (fNcells<=1 || IsFreezed())
|
---|
305 | return -1;
|
---|
306 |
|
---|
307 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
308 | {
|
---|
309 | MHexagon hex((*fGeomCam)[idx]);
|
---|
310 | if (hex.DistanceToPrimitive(x, y)>0)
|
---|
311 | continue;
|
---|
312 |
|
---|
313 | SetUsed(idx);
|
---|
314 | return Fill(idx, w);
|
---|
315 | }
|
---|
316 | return -1;
|
---|
317 | }
|
---|
318 |
|
---|
319 | // ------------------------------------------------------------------------
|
---|
320 | //
|
---|
321 | // Call this if you want to change the display status (displayed or not)
|
---|
322 | // for all pixels. val==0 means that the pixel is not displayed.
|
---|
323 | //
|
---|
324 | void MHCamera::SetUsed(const TArrayC &arr)
|
---|
325 | {
|
---|
326 | if (fNcells-2 != arr.GetSize())
|
---|
327 | {
|
---|
328 | gLog << warn << "WARNING - MHCamera::SetUsed: array size mismatch... ignored." << endl;
|
---|
329 | return;
|
---|
330 | }
|
---|
331 |
|
---|
332 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
333 | arr[idx] ? SetUsed(idx) : ResetUsed(idx);
|
---|
334 | }
|
---|
335 |
|
---|
336 | // ------------------------------------------------------------------------
|
---|
337 | //
|
---|
338 | // Return the mean value of all entries which are used if all=kFALSE and
|
---|
339 | // of all entries if all=kTRUE if sector<0. If sector>=0 only
|
---|
340 | // entries with match the given sector are taken into account.
|
---|
341 | //
|
---|
342 | Stat_t MHCamera::GetMeanSectors(const TArrayI §or, const TArrayI &aidx, Bool_t ball) const
|
---|
343 | {
|
---|
344 | if (fNcells<=1)
|
---|
345 | return 0;
|
---|
346 |
|
---|
347 | Int_t n=0;
|
---|
348 |
|
---|
349 | Stat_t mean = 0;
|
---|
350 | for (int i=0; i<fNcells-2; i++)
|
---|
351 | {
|
---|
352 | if ((ball || IsUsed(i)) && MatchSector(i, sector, aidx))
|
---|
353 | {
|
---|
354 | if (TestBit(kProfile) && fBinEntries[i+1]==0)
|
---|
355 | continue;
|
---|
356 |
|
---|
357 | mean += TestBit(kProfile) ? fArray[i+1]/fBinEntries[i+1] : fArray[i+1];
|
---|
358 | n++;
|
---|
359 | }
|
---|
360 | }
|
---|
361 |
|
---|
362 | return n==0 ? 0 : mean/n;
|
---|
363 | }
|
---|
364 |
|
---|
365 | // ------------------------------------------------------------------------
|
---|
366 | //
|
---|
367 | // Return the median value of all entries which are used if all=kFALSE and
|
---|
368 | // of all entries if all=kTRUE if sector<0. If sector>=0 only
|
---|
369 | // entries with match the given sector are taken into account.
|
---|
370 | //
|
---|
371 | Stat_t MHCamera::GetMedianSectors(const TArrayI §or, const TArrayI &aidx, Bool_t ball) const
|
---|
372 | {
|
---|
373 | if (fNcells<=1)
|
---|
374 | return 0;
|
---|
375 |
|
---|
376 | TArrayD arr(fNcells-2);
|
---|
377 | Int_t n=0;
|
---|
378 |
|
---|
379 | for (int i=0; i<fNcells-2; i++)
|
---|
380 | {
|
---|
381 | if ((ball || IsUsed(i)) && MatchSector(i, sector, aidx))
|
---|
382 | {
|
---|
383 | if (TestBit(kProfile) && fBinEntries[i+1]==0)
|
---|
384 | continue;
|
---|
385 |
|
---|
386 | arr[n++] = TestBit(kProfile) ? fArray[i+1]/fBinEntries[i+1] : fArray[i+1];
|
---|
387 | }
|
---|
388 | }
|
---|
389 |
|
---|
390 | // return Median of the profile data
|
---|
391 | return TMath::Median(n, arr.GetArray());
|
---|
392 | }
|
---|
393 |
|
---|
394 | // ------------------------------------------------------------------------
|
---|
395 | //
|
---|
396 | // Return the sqrt variance of all entries which are used if all=kFALSE and
|
---|
397 | // of all entries if all=kTRUE if sector<0. If sector>=0 only
|
---|
398 | // entries with match the given sector are taken into account.
|
---|
399 | //
|
---|
400 | Stat_t MHCamera::GetRmsSectors(const TArrayI §or, const TArrayI &aidx, Bool_t ball) const
|
---|
401 | {
|
---|
402 | if (fNcells<=1)
|
---|
403 | return -1;
|
---|
404 |
|
---|
405 | Int_t n=0;
|
---|
406 |
|
---|
407 | Stat_t sum = 0;
|
---|
408 | Stat_t sq = 0;
|
---|
409 | for (int i=0; i<fNcells-2; i++)
|
---|
410 | {
|
---|
411 | if ((ball || IsUsed(i)) && MatchSector(i, sector, aidx))
|
---|
412 | {
|
---|
413 | if (TestBit(kProfile) && fBinEntries[i+1]==0)
|
---|
414 | continue;
|
---|
415 |
|
---|
416 | const Double_t val = TestBit(kProfile) ? fArray[i+1]/fBinEntries[i+1] : fArray[i+1];
|
---|
417 |
|
---|
418 | sum += val;
|
---|
419 | sq += val*val;
|
---|
420 | n++;
|
---|
421 | }
|
---|
422 | }
|
---|
423 |
|
---|
424 | if (n==0)
|
---|
425 | return 0;
|
---|
426 |
|
---|
427 | sum /= n;
|
---|
428 | sq /= n;
|
---|
429 |
|
---|
430 | return TMath::Sqrt(sq-sum*sum);
|
---|
431 | }
|
---|
432 |
|
---|
433 | // ------------------------------------------------------------------------
|
---|
434 | //
|
---|
435 | // Return the median value (divided by MMath::GausProb(1.0)=68.3%) of the
|
---|
436 | // distribution of abs(y[i]-Median). This is my Median equivalent of the RMS.
|
---|
437 | // Return the deviation of all entries which are used if all=kFALSE and
|
---|
438 | // of all entries if all=kTRUE if sector<0. If sector>=0 only
|
---|
439 | // entries with match the given sector are taken into account.
|
---|
440 | //
|
---|
441 | Stat_t MHCamera::GetDevSectors(const TArrayI §or, const TArrayI &aidx, Bool_t ball) const
|
---|
442 | {
|
---|
443 | if (fNcells<=1)
|
---|
444 | return 0;
|
---|
445 |
|
---|
446 | TArrayD arr(fNcells-2);
|
---|
447 | Int_t n=0;
|
---|
448 |
|
---|
449 | for (int i=0; i<fNcells-2; i++)
|
---|
450 | {
|
---|
451 | if ((ball || IsUsed(i)) && MatchSector(i, sector, aidx))
|
---|
452 | {
|
---|
453 | if (TestBit(kProfile) && fBinEntries[i+1]==0)
|
---|
454 | continue;
|
---|
455 |
|
---|
456 | arr[n++] = TestBit(kProfile) ? fArray[i+1]/fBinEntries[i+1] : fArray[i+1];
|
---|
457 | }
|
---|
458 | }
|
---|
459 |
|
---|
460 | // return Median of the profile data
|
---|
461 | return MMath::MedianDev(n, arr.GetArray());
|
---|
462 | }
|
---|
463 |
|
---|
464 | // ------------------------------------------------------------------------
|
---|
465 | //
|
---|
466 | // Return the minimum contents of all pixels (if all is set, otherwise
|
---|
467 | // only of all 'used' pixels), fMinimum if fMinimum set. If sector>=0
|
---|
468 | // only pixels with matching sector number are taken into account.
|
---|
469 | //
|
---|
470 | Double_t MHCamera::GetMinimumSectors(const TArrayI §or, const TArrayI &aidx, Bool_t ball) const
|
---|
471 | {
|
---|
472 | if (fMinimum != -1111)
|
---|
473 | return fMinimum;
|
---|
474 |
|
---|
475 | if (fNcells<=1)
|
---|
476 | return 0;
|
---|
477 |
|
---|
478 | Double_t minimum=FLT_MAX;
|
---|
479 |
|
---|
480 | for (Int_t i=0; i<fNcells-2; i++)
|
---|
481 | {
|
---|
482 | if (TestBit(kProfile) && fBinEntries[i+1]==0)
|
---|
483 | continue;
|
---|
484 |
|
---|
485 | const Double_t val = TestBit(kProfile) ? fArray[i+1]/fBinEntries[i+1] : fArray[i+1];
|
---|
486 | if (MatchSector(i, sector, aidx) && (ball || IsUsed(i)) && val<minimum)
|
---|
487 | minimum = val;
|
---|
488 | }
|
---|
489 |
|
---|
490 | return minimum;
|
---|
491 | }
|
---|
492 |
|
---|
493 | // ------------------------------------------------------------------------
|
---|
494 | //
|
---|
495 | // Return the maximum contents of all pixels (if all is set, otherwise
|
---|
496 | // only of all 'used' pixels), fMaximum if fMaximum set. If sector>=0
|
---|
497 | // only pixels with matching sector number are taken into account.
|
---|
498 | //
|
---|
499 | Double_t MHCamera::GetMaximumSectors(const TArrayI §or, const TArrayI &aidx, Bool_t ball) const
|
---|
500 | {
|
---|
501 | if (fMaximum!=-1111)
|
---|
502 | return fMaximum;
|
---|
503 |
|
---|
504 | if (fNcells<=1)
|
---|
505 | return 1;
|
---|
506 |
|
---|
507 | Double_t maximum=-FLT_MAX;
|
---|
508 | for (Int_t i=0; i<fNcells-2; i++)
|
---|
509 | {
|
---|
510 | if (TestBit(kProfile) && fBinEntries[i+1]==0)
|
---|
511 | continue;
|
---|
512 |
|
---|
513 | const Double_t val = TestBit(kProfile) ? fArray[i+1]/fBinEntries[i+1] : fArray[i+1];
|
---|
514 | if (MatchSector(i, sector, aidx) && (ball || IsUsed(i)) && val>maximum)
|
---|
515 | maximum = val;
|
---|
516 | }
|
---|
517 |
|
---|
518 | return maximum;
|
---|
519 | }
|
---|
520 |
|
---|
521 | // ------------------------------------------------------------------------
|
---|
522 | //
|
---|
523 | // Return the number of bins (excluding under- and overflow) for which
|
---|
524 | // GetBinContent returns a value > t
|
---|
525 | //
|
---|
526 | Int_t MHCamera::GetNumBinsAboveThreshold(Double_t t) const
|
---|
527 | {
|
---|
528 | Int_t n = 0;
|
---|
529 | for (Int_t i=0; i<fNcells-2; i++)
|
---|
530 | if (GetBinContent(i+1)>t)
|
---|
531 | n++;
|
---|
532 |
|
---|
533 | return n;
|
---|
534 | }
|
---|
535 |
|
---|
536 | // ------------------------------------------------------------------------
|
---|
537 | //
|
---|
538 | // Return the number of bins (excluding under- and overflow) for which
|
---|
539 | // GetBinContent returns a value < t
|
---|
540 | //
|
---|
541 | Int_t MHCamera::GetNumBinsBelowThreshold(Double_t t) const
|
---|
542 | {
|
---|
543 | Int_t n = 0;
|
---|
544 | for (Int_t i=0; i<fNcells-2; i++)
|
---|
545 | if (GetBinContent(i+1)>t)
|
---|
546 | n++;
|
---|
547 |
|
---|
548 | return n;
|
---|
549 | }
|
---|
550 |
|
---|
551 | // ------------------------------------------------------------------------
|
---|
552 | //
|
---|
553 | // Call this function to draw the camera layout into your canvas.
|
---|
554 | // Setup a drawing canvas. Add this object and all child objects
|
---|
555 | // (hexagons, etc) to the current pad. If no pad exists a new one is
|
---|
556 | // created. (To access the 'real' pad containing the camera you have
|
---|
557 | // to do a cd(1) in the current layer.
|
---|
558 | //
|
---|
559 | // To draw a camera into its own pad do something like:
|
---|
560 | //
|
---|
561 | // MGeomCamMagic m;
|
---|
562 | // MHCamera *d=new MHCamera(m);
|
---|
563 | //
|
---|
564 | // TCanvas *c = new TCanvas;
|
---|
565 | // c->Divide(2,1);
|
---|
566 | // c->cd(1);
|
---|
567 | //
|
---|
568 | // d->FillRandom();
|
---|
569 | // d->Draw();
|
---|
570 | // d->SetBit(kCanDelete);
|
---|
571 | //
|
---|
572 | // There are several drawing options:
|
---|
573 | // 'hist' Draw as a standard TH1 histogram (value vs. pixel index)
|
---|
574 | // 'box' Draw hexagons which size is in respect to its contents
|
---|
575 | // 'nocol' Leave the 'boxed' hexagons empty
|
---|
576 | // 'pixelindex' Display the pixel index in each pixel
|
---|
577 | // 'sectorindex' Display the sector index in each pixel
|
---|
578 | // 'content' Display the relative content aligned to GetMaximum() and
|
---|
579 | // GeMinimum() ((val-min)/(max-min))
|
---|
580 | // 'text' Draw GetBinContent as char
|
---|
581 | // 'proj' Display the y-projection of the histogram
|
---|
582 | // 'pal0' Use Pretty palette
|
---|
583 | // 'pal1' Use Deep Blue Sea palette
|
---|
584 | // 'pal2' Use Inverse Depp Blue Sea palette
|
---|
585 | // 'same' Draw trandparent pixels on top of an existing pad. This
|
---|
586 | // makes it possible to draw the camera image on top of an
|
---|
587 | // existing TH2, but also allows for distorted camera images
|
---|
588 | //
|
---|
589 | void MHCamera::Draw(Option_t *option)
|
---|
590 | {
|
---|
591 | const Bool_t hassame = TString(option).Contains("same", TString::kIgnoreCase) && gPad;
|
---|
592 |
|
---|
593 | // root 3.02:
|
---|
594 | // gPad->SetFixedAspectRatio()
|
---|
595 | const Color_t col = gPad ? gPad->GetFillColor() : 16;
|
---|
596 | TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas("CamDisplay", "Mars Camera Display", 656, 600);
|
---|
597 |
|
---|
598 | if (!hassame)
|
---|
599 | {
|
---|
600 | pad->SetBorderMode(0);
|
---|
601 | pad->SetFillColor(col);
|
---|
602 |
|
---|
603 | //
|
---|
604 | // Create an own pad for the MHCamera-Object which can be
|
---|
605 | // resized in paint to keep the correct aspect ratio
|
---|
606 | //
|
---|
607 | // The margin != 0 is a workaround for a problem in root 4.02/00
|
---|
608 | pad->Divide(1, 1, 1e-10, 1e-10, col);
|
---|
609 | pad->cd(1);
|
---|
610 | gPad->SetBorderMode(0);
|
---|
611 | }
|
---|
612 |
|
---|
613 | AppendPad(option);
|
---|
614 | //fGeomCam->AppendPad();
|
---|
615 |
|
---|
616 | //
|
---|
617 | // Do not change gPad. The user should not see, that Draw
|
---|
618 | // changes gPad...
|
---|
619 | //
|
---|
620 | if (!hassame)
|
---|
621 | pad->cd();
|
---|
622 | }
|
---|
623 |
|
---|
624 | // ------------------------------------------------------------------------
|
---|
625 | //
|
---|
626 | // This is TObject::DrawClone but completely ignores
|
---|
627 | // gROOT->GetSelectedPad(). tbretz had trouble with this in the past.
|
---|
628 | // If this makes trouble please write a bug report.
|
---|
629 | //
|
---|
630 | TObject *MHCamera::DrawClone(Option_t *option) const
|
---|
631 | {
|
---|
632 | // Draw a clone of this object in the current pad
|
---|
633 |
|
---|
634 | //TVirtualPad *pad = gROOT->GetSelectedPad();
|
---|
635 | TVirtualPad *padsav = gPad;
|
---|
636 | //if (pad) pad->cd();
|
---|
637 |
|
---|
638 | TObject *newobj = Clone();
|
---|
639 |
|
---|
640 | if (!newobj)
|
---|
641 | return 0;
|
---|
642 |
|
---|
643 | /*
|
---|
644 | if (pad) {
|
---|
645 | if (strlen(option)) pad->GetListOfPrimitives()->Add(newobj,option);
|
---|
646 | else pad->GetListOfPrimitives()->Add(newobj,GetDrawOption());
|
---|
647 | pad->Modified(kTRUE);
|
---|
648 | pad->Update();
|
---|
649 | if (padsav) padsav->cd();
|
---|
650 | return newobj;
|
---|
651 | }
|
---|
652 | */
|
---|
653 |
|
---|
654 | TString opt(option);
|
---|
655 | opt.ToLower();
|
---|
656 |
|
---|
657 | newobj->Draw(opt.IsNull() ? GetDrawOption() : option);
|
---|
658 |
|
---|
659 | if (padsav)
|
---|
660 | padsav->cd();
|
---|
661 |
|
---|
662 | return newobj;
|
---|
663 | }
|
---|
664 |
|
---|
665 | // ------------------------------------------------------------------------
|
---|
666 | //
|
---|
667 | // Creates a TH1D which contains the projection of the contents of the
|
---|
668 | // MHCamera onto the y-axis. The maximum and minimum are calculated
|
---|
669 | // such that a slighly wider range than (GetMinimum(), GetMaximum()) is
|
---|
670 | // displayed using THLimitsFinder::OptimizeLimits.
|
---|
671 | //
|
---|
672 | // If no name is given the newly allocated histogram is removed from
|
---|
673 | // the current directory calling SetDirectory(0) in any other case
|
---|
674 | // the newly created histogram is removed from the current directory
|
---|
675 | // and added to gROOT such the gROOT->FindObject can find the histogram.
|
---|
676 | //
|
---|
677 | // If the standard name "_proj" is given "_proj" is appended to the name
|
---|
678 | // of the MHCamera and the corresponding histogram is searched using
|
---|
679 | // gROOT->FindObject and updated with the present projection.
|
---|
680 | //
|
---|
681 | // It is the responsibility of the user to make sure, that the newly
|
---|
682 | // created histogram is freed correctly.
|
---|
683 | //
|
---|
684 | // Currently the new histogram is restrictred to 50 bins.
|
---|
685 | // Maybe a optimal number can be calulated from the number of
|
---|
686 | // bins on the x-axis of the MHCamera?
|
---|
687 | //
|
---|
688 | // The code was taken mainly from TH2::ProjectX such the interface
|
---|
689 | // is more or less the same than to TH2-projections.
|
---|
690 | //
|
---|
691 | // If sector>=0 only entries with matching sector index are taken
|
---|
692 | // into account.
|
---|
693 | //
|
---|
694 | TH1D *MHCamera::ProjectionS(const TArrayI §or, const TArrayI &aidx, const char *name, const Int_t nbins) const
|
---|
695 | {
|
---|
696 |
|
---|
697 | // Create the projection histogram
|
---|
698 | TString pname(name);
|
---|
699 | if (pname=="_proj")
|
---|
700 | {
|
---|
701 | pname.Prepend(GetName());
|
---|
702 | if (sector.GetSize()>0)
|
---|
703 | {
|
---|
704 | pname += ";";
|
---|
705 | for (int i=0; i<sector.GetSize(); i++)
|
---|
706 | pname += sector[i];
|
---|
707 | }
|
---|
708 | if (aidx.GetSize()>0)
|
---|
709 | {
|
---|
710 | pname += ";";
|
---|
711 | for (int i=0; i<aidx.GetSize(); i++)
|
---|
712 | pname += aidx[i];
|
---|
713 | }
|
---|
714 | }
|
---|
715 |
|
---|
716 | TH1D *h1=0;
|
---|
717 |
|
---|
718 | //check if histogram with identical name exist
|
---|
719 | TObject *h1obj = gROOT->FindObject(pname);
|
---|
720 | if (h1obj && h1obj->InheritsFrom(TH1D::Class())) {
|
---|
721 | h1 = (TH1D*)h1obj;
|
---|
722 | h1->Reset();
|
---|
723 | }
|
---|
724 |
|
---|
725 | if (!h1)
|
---|
726 | {
|
---|
727 | h1 = new TH1D;
|
---|
728 | h1->UseCurrentStyle();
|
---|
729 | h1->SetName(pname);
|
---|
730 | h1->SetTitle(GetTitle());
|
---|
731 | h1->SetDirectory(0);
|
---|
732 | h1->SetXTitle(GetYaxis()->GetTitle());
|
---|
733 | h1->SetYTitle("Counts");
|
---|
734 | //h1->Sumw2();
|
---|
735 | }
|
---|
736 |
|
---|
737 | Double_t min = GetMinimumSectors(sector, aidx);
|
---|
738 | Double_t max = GetMaximumSectors(sector, aidx);
|
---|
739 |
|
---|
740 | if (min==max && max>0)
|
---|
741 | min=0;
|
---|
742 | if (min==max && min<0)
|
---|
743 | max=0;
|
---|
744 |
|
---|
745 | Int_t newbins=0;
|
---|
746 | THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE);
|
---|
747 |
|
---|
748 | MBinning bins(nbins, min, max);
|
---|
749 | bins.Apply(*h1);
|
---|
750 |
|
---|
751 | // Fill the projected histogram
|
---|
752 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
753 | if (IsUsed(idx) && MatchSector(idx, sector, aidx))
|
---|
754 | h1->Fill(GetBinContent(idx+1));
|
---|
755 |
|
---|
756 | return h1;
|
---|
757 | }
|
---|
758 |
|
---|
759 | // ------------------------------------------------------------------------
|
---|
760 | //
|
---|
761 | // Creates a TH1D which contains the projection of the contents of the
|
---|
762 | // MHCamera onto the radius from the camera center.
|
---|
763 | // The maximum and minimum are calculated
|
---|
764 | // such that a slighly wider range than (GetMinimum(), GetMaximum()) is
|
---|
765 | // displayed using THLimitsFinder::OptimizeLimits.
|
---|
766 | //
|
---|
767 | // If no name is given the newly allocated histogram is removed from
|
---|
768 | // the current directory calling SetDirectory(0) in any other case
|
---|
769 | // the newly created histogram is removed from the current directory
|
---|
770 | // and added to gROOT such the gROOT->FindObject can find the histogram.
|
---|
771 | //
|
---|
772 | // If the standard name "_rad" is given "_rad" is appended to the name
|
---|
773 | // of the MHCamera and the corresponding histogram is searched using
|
---|
774 | // gROOT->FindObject and updated with the present projection.
|
---|
775 | //
|
---|
776 | // It is the responsibility of the user to make sure, that the newly
|
---|
777 | // created histogram is freed correctly.
|
---|
778 | //
|
---|
779 | // Currently the new histogram is restrictred to 50 bins.
|
---|
780 | // Maybe a optimal number can be calulated from the number of
|
---|
781 | // bins on the x-axis of the MHCamera?
|
---|
782 | //
|
---|
783 | // The code was taken mainly from TH2::ProjectX such the interface
|
---|
784 | // is more or less the same than to TH2-projections.
|
---|
785 | //
|
---|
786 | // If sector>=0 only entries with matching sector index are taken
|
---|
787 | // into account.
|
---|
788 | //
|
---|
789 | TProfile *MHCamera::RadialProfileS(const TArrayI §or, const TArrayI &aidx, const char *name, const Int_t nbins) const
|
---|
790 | {
|
---|
791 | // Create the projection histogram
|
---|
792 | TString pname(name);
|
---|
793 | if (pname=="_rad")
|
---|
794 | {
|
---|
795 | pname.Prepend(GetName());
|
---|
796 | if (sector.GetSize()>0)
|
---|
797 | {
|
---|
798 | pname += ";";
|
---|
799 | for (int i=0; i<sector.GetSize(); i++)
|
---|
800 | pname += sector[i];
|
---|
801 | }
|
---|
802 | if (aidx.GetSize()>0)
|
---|
803 | {
|
---|
804 | pname += ";";
|
---|
805 | for (int i=0; i<aidx.GetSize(); i++)
|
---|
806 | pname += aidx[i];
|
---|
807 | }
|
---|
808 | }
|
---|
809 |
|
---|
810 | TProfile *h1=0;
|
---|
811 |
|
---|
812 | //check if histogram with identical name exist
|
---|
813 | TObject *h1obj = gROOT->FindObject(pname);
|
---|
814 | if (h1obj && h1obj->InheritsFrom(TProfile::Class())) {
|
---|
815 | h1 = (TProfile*)h1obj;
|
---|
816 | h1->Reset();
|
---|
817 | }
|
---|
818 |
|
---|
819 | if (!h1)
|
---|
820 | {
|
---|
821 | h1 = new TProfile;
|
---|
822 | h1->UseCurrentStyle();
|
---|
823 | h1->SetName(pname);
|
---|
824 | h1->SetTitle(GetTitle());
|
---|
825 | h1->SetDirectory(0);
|
---|
826 | h1->SetXTitle("Radius from camera center [mm]");
|
---|
827 | h1->SetYTitle(GetYaxis()->GetTitle());
|
---|
828 | }
|
---|
829 |
|
---|
830 | const Double_t m2d = fGeomCam->GetConvMm2Deg();
|
---|
831 |
|
---|
832 | Double_t min = 0.;
|
---|
833 | Double_t max = fGeomCam->GetMaxRadius()*m2d;
|
---|
834 |
|
---|
835 | Int_t newbins=0;
|
---|
836 |
|
---|
837 | THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE);
|
---|
838 |
|
---|
839 | MBinning bins(nbins, min, max);
|
---|
840 | bins.Apply(*h1);
|
---|
841 |
|
---|
842 | // Fill the projected histogram
|
---|
843 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
844 | if (IsUsed(idx) && MatchSector(idx, sector, aidx))
|
---|
845 | h1->Fill(TMath::Hypot((*fGeomCam)[idx].GetX(),(*fGeomCam)[idx].GetY())*m2d,
|
---|
846 | GetBinContent(idx+1));
|
---|
847 | return h1;
|
---|
848 | }
|
---|
849 |
|
---|
850 |
|
---|
851 | // ------------------------------------------------------------------------
|
---|
852 | //
|
---|
853 | // Creates a TH1D which contains the projection of the contents of the
|
---|
854 | // MHCamera onto the azimuth angle in the camera.
|
---|
855 | //
|
---|
856 | // If no name is given the newly allocated histogram is removed from
|
---|
857 | // the current directory calling SetDirectory(0) in any other case
|
---|
858 | // the newly created histogram is removed from the current directory
|
---|
859 | // and added to gROOT such the gROOT->FindObject can find the histogram.
|
---|
860 | //
|
---|
861 | // If the standard name "_az" is given "_az" is appended to the name
|
---|
862 | // of the MHCamera and the corresponding histogram is searched using
|
---|
863 | // gROOT->FindObject and updated with the present projection.
|
---|
864 | //
|
---|
865 | // It is the responsibility of the user to make sure, that the newly
|
---|
866 | // created histogram is freed correctly.
|
---|
867 | //
|
---|
868 | // Currently the new histogram is restrictred to 60 bins.
|
---|
869 | // Maybe a optimal number can be calulated from the number of
|
---|
870 | // bins on the x-axis of the MHCamera?
|
---|
871 | //
|
---|
872 | // The code was taken mainly from TH2::ProjectX such the interface
|
---|
873 | // is more or less the same than to TH2-projections.
|
---|
874 | //
|
---|
875 | TProfile *MHCamera::AzimuthProfileA(const TArrayI &aidx, const char *name, const Int_t nbins) const
|
---|
876 | {
|
---|
877 | // Create the projection histogram
|
---|
878 | TString pname(name);
|
---|
879 | if (pname=="_az")
|
---|
880 | {
|
---|
881 | pname.Prepend(GetName());
|
---|
882 | if (aidx.GetSize()>0)
|
---|
883 | {
|
---|
884 | pname += ";";
|
---|
885 | for (int i=0; i<aidx.GetSize(); i++)
|
---|
886 | pname += aidx[i];
|
---|
887 | }
|
---|
888 | }
|
---|
889 |
|
---|
890 | TProfile *h1=0;
|
---|
891 |
|
---|
892 | //check if histogram with identical name exist
|
---|
893 | TObject *h1obj = gROOT->FindObject(pname);
|
---|
894 | if (h1obj && h1obj->InheritsFrom(TProfile::Class())) {
|
---|
895 | h1 = (TProfile*)h1obj;
|
---|
896 | h1->Reset();
|
---|
897 | }
|
---|
898 |
|
---|
899 | if (!h1)
|
---|
900 | {
|
---|
901 |
|
---|
902 | h1 = new TProfile;
|
---|
903 | h1->UseCurrentStyle();
|
---|
904 | h1->SetName(pname);
|
---|
905 | h1->SetTitle(GetTitle());
|
---|
906 | h1->SetDirectory(0);
|
---|
907 | h1->SetXTitle("Azimuth in camera [deg]");
|
---|
908 | h1->SetYTitle(GetYaxis()->GetTitle());
|
---|
909 | }
|
---|
910 |
|
---|
911 | //Double_t min = 0;
|
---|
912 | //Double_t max = 360;
|
---|
913 |
|
---|
914 | //Int_t newbins=0;
|
---|
915 | //THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE);
|
---|
916 |
|
---|
917 | MBinning bins(nbins, 0, 360);
|
---|
918 | bins.Apply(*h1);
|
---|
919 |
|
---|
920 | // Fill the projected histogram
|
---|
921 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
922 | {
|
---|
923 | if (IsUsed(idx) && MatchSector(idx, TArrayI(), aidx))
|
---|
924 | h1->Fill(TMath::ATan2((*fGeomCam)[idx].GetY(),(*fGeomCam)[idx].GetX())*TMath::RadToDeg()+180,
|
---|
925 | GetPixContent(idx));
|
---|
926 |
|
---|
927 | }
|
---|
928 |
|
---|
929 | return h1;
|
---|
930 | }
|
---|
931 |
|
---|
932 |
|
---|
933 | // ------------------------------------------------------------------------
|
---|
934 | //
|
---|
935 | // Resizes the current pad so that the camera is displayed in its
|
---|
936 | // correct aspect ratio
|
---|
937 | //
|
---|
938 | void MHCamera::SetRange()
|
---|
939 | {
|
---|
940 | const Float_t range = fGeomCam->GetMaxRadius()*1.05;
|
---|
941 |
|
---|
942 | //
|
---|
943 | // Maintain aspect ratio
|
---|
944 | //
|
---|
945 | const float ratio = TestBit(kNoLegend) ? 1 : 1.15;
|
---|
946 |
|
---|
947 | //
|
---|
948 | // Calculate width and height of the current pad in pixels
|
---|
949 | //
|
---|
950 | Float_t w = gPad->GetWw();
|
---|
951 | Float_t h = gPad->GetWh()*ratio;
|
---|
952 |
|
---|
953 | //
|
---|
954 | // This prevents the pad from resizing itself wrongly
|
---|
955 | //
|
---|
956 | if (gPad->GetMother() != gPad)
|
---|
957 | {
|
---|
958 | w *= gPad->GetMother()->GetAbsWNDC();
|
---|
959 | h *= gPad->GetMother()->GetAbsHNDC();
|
---|
960 | }
|
---|
961 |
|
---|
962 | //
|
---|
963 | // Set Range (coordinate system) of pad
|
---|
964 | //
|
---|
965 | gPad->Range(-range, -range, (2*ratio-1)*range, range);
|
---|
966 |
|
---|
967 | //
|
---|
968 | // Resize Pad to given ratio
|
---|
969 | //
|
---|
970 | if (h<w)
|
---|
971 | gPad->SetPad((1.-h/w)/2, 0, (h/w+1.)/2, 1);
|
---|
972 | else
|
---|
973 | gPad->SetPad(0, (1.-w/h)/2, 1, (w/h+1.)/2);
|
---|
974 | }
|
---|
975 |
|
---|
976 | // ------------------------------------------------------------------------
|
---|
977 | //
|
---|
978 | // Updates the pixel colors and paints the pixels
|
---|
979 | //
|
---|
980 | void MHCamera::Update(Bool_t islog, Bool_t isbox, Bool_t iscol, Bool_t issame)
|
---|
981 | {
|
---|
982 | Double_t min = GetMinimum(kFALSE);
|
---|
983 | Double_t max = GetMaximum(kFALSE);
|
---|
984 | if (min==FLT_MAX)
|
---|
985 | {
|
---|
986 | min = 0;
|
---|
987 | max = 1;
|
---|
988 | }
|
---|
989 |
|
---|
990 | if (min==max)
|
---|
991 | max += 1;
|
---|
992 |
|
---|
993 | if (!issame)
|
---|
994 | UpdateLegend(min, max, islog);
|
---|
995 |
|
---|
996 | // Try to estimate the units of the current display. This is only
|
---|
997 | // necessary for 'same' option and allows distorted images of the camera!
|
---|
998 | const Float_t maxr = (1-fGeomCam->GetConvMm2Deg())*fGeomCam->GetMaxRadius()/2;
|
---|
999 | const Float_t conv = !issame ||
|
---|
1000 | gPad->GetX1()<-maxr || gPad->GetY1()<-maxr ||
|
---|
1001 | gPad->GetX2()> maxr || gPad->GetY2()>maxr ? 1 : fGeomCam->GetConvMm2Deg();
|
---|
1002 |
|
---|
1003 | MHexagon hex;
|
---|
1004 | for (Int_t i=0; i<fNcells-2; i++)
|
---|
1005 | {
|
---|
1006 | hex.SetFillStyle(issame || (IsTransparent() && !IsUsed(i)) ? 0 : 1001);
|
---|
1007 |
|
---|
1008 | if (!issame)
|
---|
1009 | {
|
---|
1010 | const Bool_t isnan = !TMath::Finite(fArray[i+1]);
|
---|
1011 | if (!IsUsed(i) || !iscol || isnan)
|
---|
1012 | {
|
---|
1013 | hex.SetFillColor(10);
|
---|
1014 |
|
---|
1015 | if (isnan)
|
---|
1016 | gLog << warn << "MHCamera::Update: " << GetName() << " <" << GetTitle() << "> - Pixel Index #" << i << " contents is not finite..." << endl;
|
---|
1017 | }
|
---|
1018 | else
|
---|
1019 | hex.SetFillColor(GetColor(GetBinContent(i+1), min, max, islog));
|
---|
1020 | }
|
---|
1021 |
|
---|
1022 | const MGeomPix &pix = (*fGeomCam)[i];
|
---|
1023 |
|
---|
1024 | Float_t x = pix.GetX()*conv/(fAbberation+1);
|
---|
1025 | Float_t y = pix.GetY()*conv/(fAbberation+1);
|
---|
1026 | Float_t d = pix.GetD()*conv;
|
---|
1027 |
|
---|
1028 | if (!isbox)
|
---|
1029 | if (IsUsed(i) || !TestBit(kNoUnused))
|
---|
1030 | hex.PaintHexagon(x, y, d);
|
---|
1031 | else
|
---|
1032 | if (IsUsed(i) && TMath::Finite(fArray[i+1]))
|
---|
1033 | {
|
---|
1034 | Float_t size = d*(GetBinContent(i+1)-min)/(max-min);
|
---|
1035 | if (size>d)
|
---|
1036 | size=d;
|
---|
1037 | hex.PaintHexagon(x, y, size);
|
---|
1038 | }
|
---|
1039 | }
|
---|
1040 | }
|
---|
1041 |
|
---|
1042 | // ------------------------------------------------------------------------
|
---|
1043 | //
|
---|
1044 | // Print minimum and maximum
|
---|
1045 | //
|
---|
1046 | void MHCamera::Print(Option_t *) const
|
---|
1047 | {
|
---|
1048 | gLog << all << "Minimum: " << GetMinimum();
|
---|
1049 | if (fMinimum==-1111)
|
---|
1050 | gLog << " <autoscaled>";
|
---|
1051 | gLog << endl;
|
---|
1052 | gLog << "Maximum: " << GetMaximum();
|
---|
1053 | if (fMaximum==-1111)
|
---|
1054 | gLog << " <autoscaled>";
|
---|
1055 | gLog << endl;
|
---|
1056 | }
|
---|
1057 |
|
---|
1058 | // ------------------------------------------------------------------------
|
---|
1059 | //
|
---|
1060 | // Paint the y-axis title
|
---|
1061 | //
|
---|
1062 | void MHCamera::PaintAxisTitle()
|
---|
1063 | {
|
---|
1064 | const Float_t range = fGeomCam->GetMaxRadius()*1.05;
|
---|
1065 | const Float_t w = (1 + 1.5/sqrt((float)(fNcells-2)))*range;
|
---|
1066 |
|
---|
1067 | TLatex *ptitle = new TLatex(w, -.90*range, GetYaxis()->GetTitle());
|
---|
1068 |
|
---|
1069 | ptitle->SetTextSize(0.05);
|
---|
1070 | ptitle->SetTextAlign(21);
|
---|
1071 |
|
---|
1072 | // box with the histogram title
|
---|
1073 | ptitle->SetTextColor(gStyle->GetTitleTextColor());
|
---|
1074 | #if ROOT_VERSION_CODE > ROOT_VERSION(3,05,01)
|
---|
1075 | ptitle->SetTextFont(gStyle->GetTitleFont(""));
|
---|
1076 | #endif
|
---|
1077 | ptitle->Paint();
|
---|
1078 | }
|
---|
1079 |
|
---|
1080 | // ------------------------------------------------------------------------
|
---|
1081 | //
|
---|
1082 | // Paints the camera.
|
---|
1083 | //
|
---|
1084 | void MHCamera::Paint(Option_t *o)
|
---|
1085 | {
|
---|
1086 | if (fNcells<=1)
|
---|
1087 | return;
|
---|
1088 |
|
---|
1089 | TString opt(o);
|
---|
1090 | opt.ToLower();
|
---|
1091 |
|
---|
1092 | if (opt.Contains("hist"))
|
---|
1093 | {
|
---|
1094 | opt.ReplaceAll("hist", "");
|
---|
1095 | opt.ReplaceAll("box", "");
|
---|
1096 | opt.ReplaceAll("pixelindex", "");
|
---|
1097 | opt.ReplaceAll("sectorindex", "");
|
---|
1098 | opt.ReplaceAll("abscontent", "");
|
---|
1099 | opt.ReplaceAll("content", "");
|
---|
1100 | opt.ReplaceAll("proj", "");
|
---|
1101 | opt.ReplaceAll("pal0", "");
|
---|
1102 | opt.ReplaceAll("pal1", "");
|
---|
1103 | opt.ReplaceAll("pal2", "");
|
---|
1104 | opt.ReplaceAll("nopal", "");
|
---|
1105 | TH1D::Paint(opt);
|
---|
1106 | return;
|
---|
1107 | }
|
---|
1108 |
|
---|
1109 | if (opt.Contains("proj"))
|
---|
1110 | {
|
---|
1111 | opt.ReplaceAll("proj", "");
|
---|
1112 | Projection(GetName())->Paint(opt);
|
---|
1113 | return;
|
---|
1114 | }
|
---|
1115 |
|
---|
1116 | const Bool_t hassame = opt.Contains("same");
|
---|
1117 | const Bool_t hasbox = opt.Contains("box");
|
---|
1118 | const Bool_t hascol = hasbox ? !opt.Contains("nocol") : kTRUE;
|
---|
1119 |
|
---|
1120 | if (!hassame)
|
---|
1121 | {
|
---|
1122 | gPad->Clear();
|
---|
1123 |
|
---|
1124 | // Maintain aspect ratio
|
---|
1125 | SetRange();
|
---|
1126 |
|
---|
1127 | if (GetPainter())
|
---|
1128 | {
|
---|
1129 | // Paint statistics
|
---|
1130 | if (!TestBit(TH1::kNoStats))
|
---|
1131 | fPainter->PaintStat(gStyle->GetOptStat(), NULL);
|
---|
1132 |
|
---|
1133 | // Paint primitives (pixels, color legend, photons, ...)
|
---|
1134 | if (fPainter->InheritsFrom(THistPainter::Class()))
|
---|
1135 | {
|
---|
1136 | static_cast<THistPainter*>(fPainter)->MakeChopt("");
|
---|
1137 | static_cast<THistPainter*>(fPainter)->PaintTitle();
|
---|
1138 | }
|
---|
1139 | }
|
---|
1140 | }
|
---|
1141 |
|
---|
1142 | const Bool_t pal1 = opt.Contains("pal1");
|
---|
1143 | const Bool_t pal2 = opt.Contains("pal2");
|
---|
1144 | const Bool_t nopal = opt.Contains("nopal");
|
---|
1145 |
|
---|
1146 | if (!pal1 && !pal2 && !nopal)
|
---|
1147 | SetPrettyPalette();
|
---|
1148 |
|
---|
1149 | if (pal1)
|
---|
1150 | SetDeepBlueSeaPalette();
|
---|
1151 |
|
---|
1152 | if (pal2)
|
---|
1153 | SetInvDeepBlueSeaPalette();
|
---|
1154 |
|
---|
1155 | // Update Contents of the pixels and paint legend
|
---|
1156 | Update(gPad->GetLogy(), hasbox, hascol, hassame);
|
---|
1157 |
|
---|
1158 | if (!hassame)
|
---|
1159 | PaintAxisTitle();
|
---|
1160 |
|
---|
1161 | if (opt.Contains("pixelindex"))
|
---|
1162 | {
|
---|
1163 | PaintIndices(0);
|
---|
1164 | return;
|
---|
1165 | }
|
---|
1166 | if (opt.Contains("sectorindex"))
|
---|
1167 | {
|
---|
1168 | PaintIndices(1);
|
---|
1169 | return;
|
---|
1170 | }
|
---|
1171 | if (opt.Contains("abscontent"))
|
---|
1172 | {
|
---|
1173 | PaintIndices(3);
|
---|
1174 | return;
|
---|
1175 | }
|
---|
1176 | if (opt.Contains("content"))
|
---|
1177 | {
|
---|
1178 | PaintIndices(2);
|
---|
1179 | return;
|
---|
1180 | }
|
---|
1181 | if (opt.Contains("pixelentries"))
|
---|
1182 | {
|
---|
1183 | PaintIndices(4);
|
---|
1184 | return;
|
---|
1185 | }
|
---|
1186 | if (opt.Contains("text"))
|
---|
1187 | {
|
---|
1188 | PaintIndices(5);
|
---|
1189 | return;
|
---|
1190 | }
|
---|
1191 | }
|
---|
1192 |
|
---|
1193 | void MHCamera::SetDrawOption(Option_t *option)
|
---|
1194 | {
|
---|
1195 | // This is a workaround. For some reason MHCamera is
|
---|
1196 | // stored in a TObjLink instead of a TObjOptLink
|
---|
1197 | if (!option || !gPad)
|
---|
1198 | return;
|
---|
1199 |
|
---|
1200 | TListIter next(gPad->GetListOfPrimitives());
|
---|
1201 | delete gPad->FindObject("Tframe");
|
---|
1202 | TObject *obj;
|
---|
1203 | while ((obj = next()))
|
---|
1204 | if (obj == this && (TString)next.GetOption()!=(TString)option)
|
---|
1205 | {
|
---|
1206 | gPad->GetListOfPrimitives()->Remove(this);
|
---|
1207 | gPad->GetListOfPrimitives()->AddFirst(this, option);
|
---|
1208 | return;
|
---|
1209 | }
|
---|
1210 | }
|
---|
1211 |
|
---|
1212 | // ------------------------------------------------------------------------
|
---|
1213 | //
|
---|
1214 | // With this function you can change the color palette. For more
|
---|
1215 | // information see TStyle::SetPalette. Only palettes with 50 colors
|
---|
1216 | // are allowed.
|
---|
1217 | // In addition you can use SetPalette(52, 0) to create an inverse
|
---|
1218 | // deep blue sea palette
|
---|
1219 | //
|
---|
1220 | void MHCamera::SetPalette(Int_t ncolors, Int_t *colors)
|
---|
1221 | {
|
---|
1222 | //
|
---|
1223 | // If not enough colors are specified skip this.
|
---|
1224 | //
|
---|
1225 | if (ncolors>1 && ncolors<50)
|
---|
1226 | {
|
---|
1227 | gLog << err << "MHCamera::SetPalette: Only default palettes with 50 colors are allowed... ignored." << endl;
|
---|
1228 | return;
|
---|
1229 | }
|
---|
1230 |
|
---|
1231 | //
|
---|
1232 | // If ncolors==52 create a reversed deep blue sea palette
|
---|
1233 | //
|
---|
1234 | if (ncolors==52)
|
---|
1235 | {
|
---|
1236 | gStyle->SetPalette(51, NULL);
|
---|
1237 |
|
---|
1238 | const Int_t n = GetContour()==0?50:GetContour();
|
---|
1239 |
|
---|
1240 | TArrayI c(n);
|
---|
1241 | for (int i=0; i<n; i++)
|
---|
1242 | c[n-i-1] = gStyle->GetColorPalette(i);
|
---|
1243 | gStyle->SetPalette(n, c.GetArray());
|
---|
1244 | }
|
---|
1245 | else
|
---|
1246 | gStyle->SetPalette(ncolors, colors);
|
---|
1247 | }
|
---|
1248 |
|
---|
1249 |
|
---|
1250 | // ------------------------------------------------------------------------
|
---|
1251 | //
|
---|
1252 | // Changes the palette of the displayed camera histogram.
|
---|
1253 | //
|
---|
1254 | // Change to the right pad first - otherwise GetDrawOption() might fail.
|
---|
1255 | //
|
---|
1256 | void MHCamera::SetPrettyPalette()
|
---|
1257 | {
|
---|
1258 | TString opt(GetDrawOption());
|
---|
1259 |
|
---|
1260 | if (!opt.Contains("hist", TString::kIgnoreCase))
|
---|
1261 | SetPalette(1, 0);
|
---|
1262 |
|
---|
1263 | opt.ReplaceAll("pal1", "");
|
---|
1264 | opt.ReplaceAll("pal2", "");
|
---|
1265 |
|
---|
1266 | SetDrawOption(opt);
|
---|
1267 | }
|
---|
1268 |
|
---|
1269 | // ------------------------------------------------------------------------
|
---|
1270 | //
|
---|
1271 | // Changes the palette of the displayed camera histogram.
|
---|
1272 | //
|
---|
1273 | // Change to the right pad first - otherwise GetDrawOption() might fail.
|
---|
1274 | //
|
---|
1275 | void MHCamera::SetDeepBlueSeaPalette()
|
---|
1276 | {
|
---|
1277 | TString opt(GetDrawOption());
|
---|
1278 |
|
---|
1279 | if (!opt.Contains("hist", TString::kIgnoreCase))
|
---|
1280 | SetPalette(51, 0);
|
---|
1281 |
|
---|
1282 | opt.ReplaceAll("pal1", "");
|
---|
1283 | opt.ReplaceAll("pal2", "");
|
---|
1284 | opt += "pal1";
|
---|
1285 |
|
---|
1286 | SetDrawOption(opt);
|
---|
1287 | }
|
---|
1288 |
|
---|
1289 | // ------------------------------------------------------------------------
|
---|
1290 | //
|
---|
1291 | // Changes the palette of the displayed camera histogram.
|
---|
1292 | //
|
---|
1293 | // Change to the right pad first - otherwise GetDrawOption() might fail.
|
---|
1294 | //
|
---|
1295 | void MHCamera::SetInvDeepBlueSeaPalette()
|
---|
1296 | {
|
---|
1297 | TString opt(GetDrawOption());
|
---|
1298 |
|
---|
1299 | if (!opt.Contains("hist", TString::kIgnoreCase))
|
---|
1300 | SetPalette(52, 0);
|
---|
1301 |
|
---|
1302 | opt.ReplaceAll("pal1", "");
|
---|
1303 | opt.ReplaceAll("pal2", "");
|
---|
1304 | opt += "pal2";
|
---|
1305 |
|
---|
1306 | SetDrawOption(opt);
|
---|
1307 | }
|
---|
1308 |
|
---|
1309 | // ------------------------------------------------------------------------
|
---|
1310 | //
|
---|
1311 | // Paint indices (as text) inside the pixels. Depending of the type-
|
---|
1312 | // argument we paint:
|
---|
1313 | // 0: pixel number
|
---|
1314 | // 1: sector number
|
---|
1315 | // 2: content
|
---|
1316 | // 5: Assume GetBinContent is a char
|
---|
1317 | //
|
---|
1318 | void MHCamera::PaintIndices(Int_t type)
|
---|
1319 | {
|
---|
1320 | if (fNcells<=1)
|
---|
1321 | return;
|
---|
1322 |
|
---|
1323 | const Double_t min = GetMinimum();
|
---|
1324 | const Double_t max = GetMaximum();
|
---|
1325 |
|
---|
1326 | if (type==2 && max==min)
|
---|
1327 | return;
|
---|
1328 |
|
---|
1329 | TText txt;
|
---|
1330 | if (type!=5)
|
---|
1331 | txt.SetTextFont(122);
|
---|
1332 | txt.SetTextAlign(22); // centered/centered
|
---|
1333 |
|
---|
1334 | for (Int_t i=0; i<fNcells-2; i++)
|
---|
1335 | {
|
---|
1336 | const MGeomPix &h = (*fGeomCam)[i];
|
---|
1337 |
|
---|
1338 | TString num;
|
---|
1339 | switch (type)
|
---|
1340 | {
|
---|
1341 | case 0: num += i; break;
|
---|
1342 | case 1: num += h.GetSector(); break;
|
---|
1343 | case 2: num += TMath::Nint((fArray[i+1]-min)/(max-min)); break;
|
---|
1344 | case 3: num += TMath::Nint(fArray[i+1]); break;
|
---|
1345 | case 4: num += fBinEntries[i+1]; break;
|
---|
1346 | case 5: num = (char)TMath::Nint(GetBinContent(i+1)); break;
|
---|
1347 | }
|
---|
1348 |
|
---|
1349 | // FIXME: Should depend on the color of the pixel...
|
---|
1350 | //(GetColor(GetBinContent(i+1), min, max, 0));
|
---|
1351 | txt.SetTextColor(kRed);
|
---|
1352 | txt.SetTextSize(0.3*h.GetD()/fGeomCam->GetMaxRadius()/1.05);
|
---|
1353 | txt.PaintText(h.GetX(), h.GetY(), num);
|
---|
1354 | }
|
---|
1355 | }
|
---|
1356 |
|
---|
1357 | // ------------------------------------------------------------------------
|
---|
1358 | //
|
---|
1359 | // Call this function to add a MCamEvent on top of the present contents.
|
---|
1360 | //
|
---|
1361 | void MHCamera::AddCamContent(const MCamEvent &event, Int_t type)
|
---|
1362 | {
|
---|
1363 | if (fNcells<=1 || IsFreezed())
|
---|
1364 | return;
|
---|
1365 |
|
---|
1366 | // FIXME: Security check missing!
|
---|
1367 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
1368 | {
|
---|
1369 | Double_t val=0;
|
---|
1370 | if (event.GetPixelContent(val, idx, *fGeomCam, type)/* && !IsUsed(idx)*/)
|
---|
1371 | {
|
---|
1372 | SetUsed(idx);
|
---|
1373 | Fill(idx, val); // FIXME: Slow!
|
---|
1374 | }
|
---|
1375 | }
|
---|
1376 | fEntries++;
|
---|
1377 | }
|
---|
1378 |
|
---|
1379 | // ------------------------------------------------------------------------
|
---|
1380 | //
|
---|
1381 | // Call this function to add a MCamEvent on top of the present contents.
|
---|
1382 | //
|
---|
1383 | void MHCamera::SetCamError(const MCamEvent &evt, Int_t type)
|
---|
1384 | {
|
---|
1385 |
|
---|
1386 | if (fNcells<=1 || IsFreezed())
|
---|
1387 | return;
|
---|
1388 |
|
---|
1389 | // FIXME: Security check missing!
|
---|
1390 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
1391 | {
|
---|
1392 | Double_t val=0;
|
---|
1393 | if (evt.GetPixelContent(val, idx, *fGeomCam, type)/* && !IsUsed(idx)*/)
|
---|
1394 | SetUsed(idx);
|
---|
1395 |
|
---|
1396 | SetBinError(idx+1, val); // FIXME: Slow!
|
---|
1397 | }
|
---|
1398 | }
|
---|
1399 |
|
---|
1400 | Stat_t MHCamera::GetBinContent(Int_t bin) const
|
---|
1401 | {
|
---|
1402 | if (fBuffer) ((TH1D*)this)->BufferEmpty();
|
---|
1403 | if (bin < 0) bin = 0;
|
---|
1404 | if (bin >= fNcells) bin = fNcells-1;
|
---|
1405 | if (!fArray) return 0;
|
---|
1406 |
|
---|
1407 | if (!TestBit(kProfile))
|
---|
1408 | return Stat_t (fArray[bin]);
|
---|
1409 |
|
---|
1410 | if (fBinEntries.fArray[bin] == 0) return 0;
|
---|
1411 | return fArray[bin]/fBinEntries.fArray[bin];
|
---|
1412 | }
|
---|
1413 |
|
---|
1414 | // ------------------------------------------------------------------------
|
---|
1415 | //
|
---|
1416 | // In the case the kProfile flag is set the spread of the bin is returned.
|
---|
1417 | // If you want to have the mean error instead set the kErrorMean bit via
|
---|
1418 | // SetBit(kErrorMean) first.
|
---|
1419 | //
|
---|
1420 | Stat_t MHCamera::GetBinError(Int_t bin) const
|
---|
1421 | {
|
---|
1422 | if (!TestBit(kProfile))
|
---|
1423 | return TH1D::GetBinError(bin);
|
---|
1424 |
|
---|
1425 | const UInt_t n = (UInt_t)fBinEntries[bin];
|
---|
1426 |
|
---|
1427 | if (n==0)
|
---|
1428 | return 0;
|
---|
1429 |
|
---|
1430 | const Double_t sqr = fSumw2.fArray[bin] / n;
|
---|
1431 | const Double_t val = fArray[bin] / n;
|
---|
1432 |
|
---|
1433 | const Double_t spread = sqr>val*val ? TMath::Sqrt(sqr - val*val) : 0;
|
---|
1434 |
|
---|
1435 | return TestBit(kErrorMean) ? spread/TMath::Sqrt(n) : spread;
|
---|
1436 |
|
---|
1437 | /*
|
---|
1438 | Double_t rc = 0;
|
---|
1439 | if (TestBit(kSqrtVariance) && GetEntries()>0) // error on the mean
|
---|
1440 | {
|
---|
1441 | const Double_t error = fSumw2.fArray[bin]/GetEntries();
|
---|
1442 | const Double_t val = fArray[bin]/GetEntries();
|
---|
1443 | rc = val*val>error ? 0 : TMath::Sqrt(error - val*val);
|
---|
1444 | }
|
---|
1445 | else
|
---|
1446 | rc = TH1D::GetBinError(bin);
|
---|
1447 |
|
---|
1448 | return Profile(rc);*/
|
---|
1449 | }
|
---|
1450 |
|
---|
1451 | // ------------------------------------------------------------------------
|
---|
1452 | //
|
---|
1453 | // Call this function to add a MHCamera on top of the present contents.
|
---|
1454 | // Type:
|
---|
1455 | // 0) bin content
|
---|
1456 | // 1) errors
|
---|
1457 | // 2) rel. errors
|
---|
1458 | //
|
---|
1459 | void MHCamera::AddCamContent(const MHCamera &d, Int_t type)
|
---|
1460 | {
|
---|
1461 | if (fNcells!=d.fNcells || IsFreezed())
|
---|
1462 | return;
|
---|
1463 |
|
---|
1464 | // FIXME: Security check missing!
|
---|
1465 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
1466 | if (d.IsUsed(idx))
|
---|
1467 | SetUsed(idx);
|
---|
1468 |
|
---|
1469 | switch (type)
|
---|
1470 | {
|
---|
1471 | case 1:
|
---|
1472 | // Under-/Overflow bins not handled!
|
---|
1473 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
1474 | if (d.IsUsed(idx))
|
---|
1475 | Fill(idx, d.GetBinError(idx+1));
|
---|
1476 | fEntries++;
|
---|
1477 | break;
|
---|
1478 | case 2:
|
---|
1479 | // Under-/Overflow bins not handled!
|
---|
1480 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
1481 | if (d.GetBinContent(idx+1)!=0 && d.IsUsed(idx))
|
---|
1482 | Fill(idx, TMath::Abs(d.GetBinError(idx+1)/d.GetBinContent(idx+1)));
|
---|
1483 | fEntries++;
|
---|
1484 | break;
|
---|
1485 | default:
|
---|
1486 | if (TestBit(kProfile)!=d.TestBit(kProfile))
|
---|
1487 | gLog << warn << "WARNING - You have tried to call AddCamContent for two different kind of histograms (kProfile set or not)." << endl;
|
---|
1488 |
|
---|
1489 | // environment
|
---|
1490 | fEntries += d.fEntries;
|
---|
1491 | fTsumw += d.fTsumw;
|
---|
1492 | fTsumw2 += d.fTsumw2;
|
---|
1493 | fTsumwx += d.fTsumwx;
|
---|
1494 | fTsumwx2 += d.fTsumwx2;
|
---|
1495 | // Bin contents
|
---|
1496 | for (Int_t idx=1; idx<fNcells-1; idx++)
|
---|
1497 | {
|
---|
1498 | if (!d.IsUsed(idx-1))
|
---|
1499 | continue;
|
---|
1500 |
|
---|
1501 | fArray[idx] += d.fArray[idx];
|
---|
1502 | fBinEntries[idx] += d.fBinEntries[idx];
|
---|
1503 | fSumw2.fArray[idx] += d.fSumw2.fArray[idx];
|
---|
1504 | }
|
---|
1505 | // Underflow bin
|
---|
1506 | fArray[0] += d.fArray[0];
|
---|
1507 | fBinEntries[0] += d.fBinEntries[0];
|
---|
1508 | fSumw2.fArray[0] += d.fSumw2.fArray[0];
|
---|
1509 | // Overflow bin
|
---|
1510 | fArray[fNcells-1] += d.fArray[fNcells-1];
|
---|
1511 | fBinEntries[fNcells-1] += d.fBinEntries[fNcells-1];
|
---|
1512 | fSumw2.fArray[fNcells-1] += d.fSumw2.fArray[fNcells-1];
|
---|
1513 | break;
|
---|
1514 | /* default:
|
---|
1515 | if (TestBit(kProfile)!=d.TestBit(kProfile))
|
---|
1516 | gLog << warn << "WARNING - You have tried to call AddCamContent for two different kind of histograms (kProfile set or not)." << endl;
|
---|
1517 |
|
---|
1518 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
1519 | Fill(idx, d.GetBinContent(idx+1));
|
---|
1520 | break;*/
|
---|
1521 | }
|
---|
1522 | fEntries++;
|
---|
1523 | }
|
---|
1524 |
|
---|
1525 | // ------------------------------------------------------------------------
|
---|
1526 | //
|
---|
1527 | // Call this function to add a TArrayD on top of the present contents.
|
---|
1528 | //
|
---|
1529 | void MHCamera::AddCamContent(const TArrayD &event, const TArrayC *used)
|
---|
1530 | {
|
---|
1531 | if (event.GetSize()!=fNcells-2 || IsFreezed())
|
---|
1532 | return;
|
---|
1533 |
|
---|
1534 | if (used && used->GetSize()!=fNcells-2)
|
---|
1535 | return;
|
---|
1536 |
|
---|
1537 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
1538 | {
|
---|
1539 | Fill(idx, event[idx]); // FIXME: Slow!
|
---|
1540 |
|
---|
1541 | if (!used || (*used)[idx])
|
---|
1542 | SetUsed(idx);
|
---|
1543 | }
|
---|
1544 | fEntries++;
|
---|
1545 | }
|
---|
1546 |
|
---|
1547 | // ------------------------------------------------------------------------
|
---|
1548 | //
|
---|
1549 | // Call this function to add a MArrayD on top of the present contents.
|
---|
1550 | //
|
---|
1551 | void MHCamera::AddCamContent(const MArrayD &event, const TArrayC *used)
|
---|
1552 | {
|
---|
1553 | if (event.GetSize()!=(UInt_t)(fNcells-2) || IsFreezed())
|
---|
1554 | return;
|
---|
1555 |
|
---|
1556 | if (used && used->GetSize()!=fNcells-2)
|
---|
1557 | return;
|
---|
1558 |
|
---|
1559 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
1560 | {
|
---|
1561 | Fill(idx, event[idx]); // FIXME: Slow!
|
---|
1562 |
|
---|
1563 | if (!used || (*used)[idx])
|
---|
1564 | SetUsed(idx);
|
---|
1565 | }
|
---|
1566 | fEntries++;
|
---|
1567 | }
|
---|
1568 |
|
---|
1569 | // ------------------------------------------------------------------------
|
---|
1570 | //
|
---|
1571 | // Call this function to add a MCamEvent on top of the present contents.
|
---|
1572 | // 1 is added to each pixel if the contents of MCamEvent>threshold (in case isabove is set to kTRUE == default)
|
---|
1573 | // 1 is added to each pixel if the contents of MCamEvent<threshold (in case isabove is set to kFALSE)
|
---|
1574 | //
|
---|
1575 | // in unused pixel is not counted if it didn't fullfill the condition.
|
---|
1576 | //
|
---|
1577 | void MHCamera::CntCamContent(const MCamEvent &event, Double_t threshold, Int_t type, Bool_t isabove)
|
---|
1578 | {
|
---|
1579 | if (fNcells<=1 || IsFreezed())
|
---|
1580 | return;
|
---|
1581 |
|
---|
1582 | // FIXME: Security check missing!
|
---|
1583 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
1584 | {
|
---|
1585 | Double_t val=threshold;
|
---|
1586 | const Bool_t rc = event.GetPixelContent(val, idx, *fGeomCam, type);
|
---|
1587 | if (rc)
|
---|
1588 | SetUsed(idx);
|
---|
1589 |
|
---|
1590 | const Bool_t cond =
|
---|
1591 | ( isabove && val>threshold) ||
|
---|
1592 | (!isabove && val<threshold);
|
---|
1593 |
|
---|
1594 | Fill(idx, rc && cond ? 1 : 0);
|
---|
1595 | }
|
---|
1596 | fEntries++;
|
---|
1597 | }
|
---|
1598 |
|
---|
1599 | // ------------------------------------------------------------------------
|
---|
1600 | //
|
---|
1601 | // Call this function to add a MCamEvent on top of the present contents.
|
---|
1602 | // - the contents of the pixels in event are added to each pixel
|
---|
1603 | // if the pixel of thresevt<threshold (in case isabove is set
|
---|
1604 | // to kTRUE == default)
|
---|
1605 | // - the contents of the pixels in event are added to each pixel
|
---|
1606 | // if the pixel of thresevt<threshold (in case isabove is set
|
---|
1607 | // to kFALSE)
|
---|
1608 | //
|
---|
1609 | // in unused pixel is not counted if it didn't fullfill the condition.
|
---|
1610 | //
|
---|
1611 | void MHCamera::CntCamContent(const MCamEvent &event, Int_t type1, const MCamEvent &thresevt, Int_t type2, Double_t threshold, Bool_t isabove)
|
---|
1612 | {
|
---|
1613 | if (fNcells<=1 || IsFreezed())
|
---|
1614 | return;
|
---|
1615 |
|
---|
1616 | // FIXME: Security check missing!
|
---|
1617 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
1618 | {
|
---|
1619 | Double_t th=0;
|
---|
1620 | if (!thresevt.GetPixelContent(th, idx, *fGeomCam, type2))
|
---|
1621 | continue;
|
---|
1622 |
|
---|
1623 | if ((isabove && th>threshold) || (!isabove && th<threshold))
|
---|
1624 | continue;
|
---|
1625 |
|
---|
1626 | Double_t val=th;
|
---|
1627 | if (event.GetPixelContent(val, idx, *fGeomCam, type1))
|
---|
1628 | {
|
---|
1629 | SetUsed(idx);
|
---|
1630 | Fill(idx, val);
|
---|
1631 | }
|
---|
1632 | }
|
---|
1633 | fEntries++;
|
---|
1634 | }
|
---|
1635 |
|
---|
1636 | // ------------------------------------------------------------------------
|
---|
1637 | //
|
---|
1638 | // Call this function to add a MCamEvent on top of the present contents.
|
---|
1639 | // 1 is added to each pixel if the contents of MCamEvent>threshold (in case isabove is set to kTRUE == default)
|
---|
1640 | // 1 is added to each pixel if the contents of MCamEvent<threshold (in case isabove is set to kFALSE)
|
---|
1641 | //
|
---|
1642 | // in unused pixel is not counted if it didn't fullfill the condition.
|
---|
1643 | //
|
---|
1644 | void MHCamera::CntCamContent(const MCamEvent &event, TArrayD threshold, Int_t type, Bool_t isabove)
|
---|
1645 | {
|
---|
1646 | if (fNcells<=1 || IsFreezed())
|
---|
1647 | return;
|
---|
1648 |
|
---|
1649 | // FIXME: Security check missing!
|
---|
1650 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
1651 | {
|
---|
1652 | Double_t val=threshold[idx];
|
---|
1653 | if (event.GetPixelContent(val, idx, *fGeomCam, type)/* && !IsUsed(idx)*/)
|
---|
1654 | {
|
---|
1655 | SetUsed(idx);
|
---|
1656 |
|
---|
1657 | if (val>threshold[idx] && isabove)
|
---|
1658 | Fill(idx);
|
---|
1659 | if (val<threshold[idx] && !isabove)
|
---|
1660 | Fill(idx);
|
---|
1661 | }
|
---|
1662 | }
|
---|
1663 | fEntries++;
|
---|
1664 | }
|
---|
1665 |
|
---|
1666 | // ------------------------------------------------------------------------
|
---|
1667 | //
|
---|
1668 | // Call this function to add a TArrayD on top of the present contents.
|
---|
1669 | // 1 is added to each pixel if the contents of MCamEvent>threshold
|
---|
1670 | //
|
---|
1671 | void MHCamera::CntCamContent(const TArrayD &event, Double_t threshold, Bool_t ispos)
|
---|
1672 | {
|
---|
1673 | if (event.GetSize()!=fNcells-2 || IsFreezed())
|
---|
1674 | return;
|
---|
1675 |
|
---|
1676 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
1677 | {
|
---|
1678 | if (event[idx]>threshold)
|
---|
1679 | Fill(idx);
|
---|
1680 |
|
---|
1681 | if (!ispos || fArray[idx+1]>0)
|
---|
1682 | SetUsed(idx);
|
---|
1683 | }
|
---|
1684 | fEntries++;
|
---|
1685 | }
|
---|
1686 |
|
---|
1687 | // ------------------------------------------------------------------------
|
---|
1688 | //
|
---|
1689 | // Fill the pixels with random contents.
|
---|
1690 | //
|
---|
1691 | void MHCamera::FillRandom()
|
---|
1692 | {
|
---|
1693 | if (fNcells<=1 || IsFreezed())
|
---|
1694 | return;
|
---|
1695 |
|
---|
1696 | Reset();
|
---|
1697 |
|
---|
1698 | // FIXME: Security check missing!
|
---|
1699 | for (Int_t idx=0; idx<fNcells-2; idx++)
|
---|
1700 | {
|
---|
1701 | Fill(idx, gRandom->Uniform()*fGeomCam->GetPixRatio(idx));
|
---|
1702 | SetUsed(idx);
|
---|
1703 | }
|
---|
1704 | fEntries=1;
|
---|
1705 | }
|
---|
1706 |
|
---|
1707 |
|
---|
1708 | // ------------------------------------------------------------------------
|
---|
1709 | //
|
---|
1710 | // The array must be in increasing order, eg: 2.5, 3.7, 4.9
|
---|
1711 | // The values in each bin are replaced by the interval in which the value
|
---|
1712 | // fits. In the example we have four intervals
|
---|
1713 | // (<2.5, 2.5-3.7, 3.7-4.9, >4.9). Maximum and minimum are set
|
---|
1714 | // accordingly.
|
---|
1715 | //
|
---|
1716 | void MHCamera::SetLevels(const TArrayF &arr)
|
---|
1717 | {
|
---|
1718 | if (fNcells<=1)
|
---|
1719 | return;
|
---|
1720 |
|
---|
1721 | for (Int_t i=0; i<fNcells-2; i++)
|
---|
1722 | {
|
---|
1723 | if (!IsUsed(i))
|
---|
1724 | continue;
|
---|
1725 |
|
---|
1726 | Int_t j = arr.GetSize();
|
---|
1727 | while (j && fArray[i+1]<arr[j-1])
|
---|
1728 | j--;
|
---|
1729 |
|
---|
1730 | fArray[i+1] = j;
|
---|
1731 | }
|
---|
1732 | SetMaximum(arr.GetSize());
|
---|
1733 | SetMinimum(0);
|
---|
1734 | }
|
---|
1735 |
|
---|
1736 | // ------------------------------------------------------------------------
|
---|
1737 | //
|
---|
1738 | // Reset the all pixel colors to a default value
|
---|
1739 | //
|
---|
1740 | void MHCamera::Reset(Option_t *opt)
|
---|
1741 | {
|
---|
1742 | if (fNcells<=1 || IsFreezed())
|
---|
1743 | return;
|
---|
1744 |
|
---|
1745 | TH1::Reset(opt);
|
---|
1746 |
|
---|
1747 | fUsed.Reset();
|
---|
1748 | fBinEntries.Reset();
|
---|
1749 |
|
---|
1750 | for (Int_t i=0; i<fNcells; i++)
|
---|
1751 | fArray[i] = 0;
|
---|
1752 | }
|
---|
1753 |
|
---|
1754 | // ------------------------------------------------------------------------
|
---|
1755 | //
|
---|
1756 | // Here we calculate the color index for the current value.
|
---|
1757 | // The color index is defined with the class TStyle and the
|
---|
1758 | // Color palette inside. We use the command gStyle->SetPalette(1,0)
|
---|
1759 | // for the display. So we have to convert the value "wert" into
|
---|
1760 | // a color index that fits the color palette.
|
---|
1761 | // The range of the color palette is defined by the values fMinPhe
|
---|
1762 | // and fMaxRange. Between this values we have 50 color index, starting
|
---|
1763 | // with 0 up to 49.
|
---|
1764 | //
|
---|
1765 | Int_t MHCamera::GetColor(Float_t val, Float_t min, Float_t max, Bool_t islog)
|
---|
1766 | {
|
---|
1767 | //
|
---|
1768 | // first treat the over- and under-flows
|
---|
1769 | //
|
---|
1770 | const Int_t ncol = GetContour()==0?50:GetContour();
|
---|
1771 |
|
---|
1772 | const Int_t maxcolidx = ncol-1;
|
---|
1773 |
|
---|
1774 | if (!TMath::Finite(val)) // FIXME: gLog!
|
---|
1775 | return maxcolidx/2;
|
---|
1776 |
|
---|
1777 | if (val >= max)
|
---|
1778 | return gStyle->GetColorPalette(maxcolidx);
|
---|
1779 |
|
---|
1780 | if (val <= min)
|
---|
1781 | return gStyle->GetColorPalette(0);
|
---|
1782 |
|
---|
1783 | //
|
---|
1784 | // calculate the color index
|
---|
1785 | //
|
---|
1786 | Float_t ratio;
|
---|
1787 | if (islog && min>0)
|
---|
1788 | ratio = log10(val/min) / log10(max/min);
|
---|
1789 | else
|
---|
1790 | ratio = (val-min) / (max-min);
|
---|
1791 |
|
---|
1792 | const Int_t colidx = TMath::FloorNint(ratio*ncol);
|
---|
1793 | return gStyle->GetColorPalette(colidx);
|
---|
1794 | }
|
---|
1795 |
|
---|
1796 | TPaveStats *MHCamera::GetStatisticBox()
|
---|
1797 | {
|
---|
1798 | TObject *obj = 0;
|
---|
1799 |
|
---|
1800 | TIter Next(fFunctions);
|
---|
1801 | while ((obj = Next()))
|
---|
1802 | if (obj->InheritsFrom(TPaveStats::Class()))
|
---|
1803 | return static_cast<TPaveStats*>(obj);
|
---|
1804 |
|
---|
1805 | return NULL;
|
---|
1806 | }
|
---|
1807 |
|
---|
1808 | // ------------------------------------------------------------------------
|
---|
1809 | //
|
---|
1810 | // Change the text on the legend according to the range of the Display
|
---|
1811 | //
|
---|
1812 | void MHCamera::UpdateLegend(Float_t min, Float_t max, Bool_t islog)
|
---|
1813 | {
|
---|
1814 | const Float_t range = fGeomCam->GetMaxRadius()*1.05;
|
---|
1815 |
|
---|
1816 | if (!TestBit(kNoScale))
|
---|
1817 | {
|
---|
1818 | TArrow arr;
|
---|
1819 | arr.PaintArrow(-range*.9, -range*.9, -range*.6, -range*.9, 0.025);
|
---|
1820 | arr.PaintArrow(-range*.9, -range*.9, -range*.9, -range*.6, 0.025);
|
---|
1821 |
|
---|
1822 | TString text;
|
---|
1823 | text += (int)(range*.3);
|
---|
1824 | text += "mm";
|
---|
1825 |
|
---|
1826 | TText newtxt2;
|
---|
1827 | newtxt2.SetTextSize(0.04);
|
---|
1828 | newtxt2.PaintText(-range*.85, -range*.85, text);
|
---|
1829 |
|
---|
1830 | text = "";
|
---|
1831 | text += Form("%.2f", range*.3*fGeomCam->GetConvMm2Deg());
|
---|
1832 | text += "\\circ";
|
---|
1833 | text = text.Strip(TString::kLeading);
|
---|
1834 |
|
---|
1835 | TLatex latex;
|
---|
1836 | latex.PaintLatex(-range*.85, -range*.75, 0, 0.04, text);
|
---|
1837 | }
|
---|
1838 |
|
---|
1839 | if (!TestBit(kNoLegend))
|
---|
1840 | {
|
---|
1841 | TPaveStats *stats = GetStatisticBox();
|
---|
1842 |
|
---|
1843 | const Float_t hndc = 0.92 - (stats ? stats->GetY1NDC() : 1);
|
---|
1844 | const Float_t H = (0.75-hndc)*range;
|
---|
1845 | const Float_t offset = hndc*range;
|
---|
1846 |
|
---|
1847 | const Int_t ncol = GetContour()==0 ? 50 : GetContour();
|
---|
1848 |
|
---|
1849 | const Float_t h = 2./ncol;
|
---|
1850 | const Float_t w = range/sqrt((float)(fNcells-2));
|
---|
1851 |
|
---|
1852 | TBox newbox;
|
---|
1853 | TText newtxt;
|
---|
1854 | newtxt.SetTextSize(0.03);
|
---|
1855 | newtxt.SetTextAlign(12);
|
---|
1856 | #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
|
---|
1857 | newtxt.SetBit(/*kNoContextMenu|*/kCannotPick);
|
---|
1858 | newbox.SetBit(/*kNoContextMenu|*/kCannotPick);
|
---|
1859 | #endif
|
---|
1860 |
|
---|
1861 | const Float_t step = (islog && min>0 ? log10(max/min) : max-min);
|
---|
1862 | const Int_t firsts = step/48*3 < 1e-8 ? 8 : (Int_t)floor(log10(step/48*3));
|
---|
1863 | const TString opt = Form("%%.%if", firsts>0 ? 0 : TMath::Abs(firsts));
|
---|
1864 | /*
|
---|
1865 | for (Int_t i=0; i<ncol+1; i+=3)
|
---|
1866 | {
|
---|
1867 | Float_t val;
|
---|
1868 | if (islog && min>0)
|
---|
1869 | val = pow(10, step*i) * min;
|
---|
1870 | else
|
---|
1871 | val = min + step*i;
|
---|
1872 |
|
---|
1873 | //const bool dispexp = max-min>1.5 && fabs(val)>0.1 && fabs(val)<1e6;
|
---|
1874 | newtxt.PaintText(range+1.5*w, H*(i*h-1)-offset, Form(opt, val));
|
---|
1875 | }
|
---|
1876 | */
|
---|
1877 | const MBinning bins(25, min, max, islog&&min>0?"log":"lin");
|
---|
1878 |
|
---|
1879 | for (Int_t i=0; i<=25; i++)
|
---|
1880 | newtxt.PaintText(range+1.5*w, H*(i*ncol/25*h-1)-offset, Form(opt, bins[i]));
|
---|
1881 |
|
---|
1882 | for (Int_t i=0; i<ncol; i++)
|
---|
1883 | {
|
---|
1884 | newbox.SetFillColor(gStyle->GetColorPalette(i));
|
---|
1885 | newbox.PaintBox(range, H*(i*h-1)-offset, range+w, H*((i+1)*h-1)-offset);
|
---|
1886 | }
|
---|
1887 | }
|
---|
1888 | }
|
---|
1889 |
|
---|
1890 | // ------------------------------------------------------------------------
|
---|
1891 | //
|
---|
1892 | // Save primitive as a C++ statement(s) on output stream out
|
---|
1893 | //
|
---|
1894 | void MHCamera::SavePrimitive(ostream &out, Option_t *opt)
|
---|
1895 | {
|
---|
1896 | gLog << err << "MHCamera::SavePrimitive: Must be rewritten!" << endl;
|
---|
1897 | /*
|
---|
1898 | if (!gROOT->ClassSaved(TCanvas::Class()))
|
---|
1899 | fDrawingPad->SavePrimitive(out, opt);
|
---|
1900 |
|
---|
1901 | out << " " << fDrawingPad->GetName() << "->SetWindowSize(";
|
---|
1902 | out << fDrawingPad->GetWw() << "," << fDrawingPad->GetWh() << ");" << endl;
|
---|
1903 | */
|
---|
1904 | }
|
---|
1905 |
|
---|
1906 | void MHCamera::SavePrimitive(ofstream &out, Option_t *)
|
---|
1907 | {
|
---|
1908 | MHCamera::SavePrimitive(static_cast<ostream&>(out), "");
|
---|
1909 | }
|
---|
1910 |
|
---|
1911 | // ------------------------------------------------------------------------
|
---|
1912 | //
|
---|
1913 | // compute the distance of a point (px,py) to the Camera
|
---|
1914 | // this functions needed for graphical primitives, that
|
---|
1915 | // means without this function you are not able to interact
|
---|
1916 | // with the graphical primitive with the mouse!!!
|
---|
1917 | //
|
---|
1918 | // All calcutations are done in pixel coordinates
|
---|
1919 | //
|
---|
1920 | Int_t MHCamera::DistancetoPrimitive(Int_t px, Int_t py)
|
---|
1921 | {
|
---|
1922 | if (fNcells<=1)
|
---|
1923 | return 999999;
|
---|
1924 |
|
---|
1925 | TPaveStats *box = (TPaveStats*)gPad->GetPrimitive("stats");
|
---|
1926 | if (box)
|
---|
1927 | {
|
---|
1928 | const Double_t w = box->GetY2NDC()-box->GetY1NDC();
|
---|
1929 | box->SetX1NDC(gStyle->GetStatX()-gStyle->GetStatW());
|
---|
1930 | box->SetY1NDC(gStyle->GetStatY()-w);
|
---|
1931 | box->SetX2NDC(gStyle->GetStatX());
|
---|
1932 | box->SetY2NDC(gStyle->GetStatY());
|
---|
1933 | }
|
---|
1934 |
|
---|
1935 | if (TString(GetDrawOption()).Contains("hist", TString::kIgnoreCase))
|
---|
1936 | return TH1D::DistancetoPrimitive(px, py);
|
---|
1937 |
|
---|
1938 | const Bool_t issame = TString(GetDrawOption()).Contains("same", TString::kIgnoreCase);
|
---|
1939 |
|
---|
1940 | const Float_t maxr = (1-fGeomCam->GetConvMm2Deg())*fGeomCam->GetMaxRadius()/2;
|
---|
1941 | const Float_t conv = !issame ||
|
---|
1942 | gPad->GetX1()<-maxr || gPad->GetY1()<-maxr ||
|
---|
1943 | gPad->GetX2()> maxr || gPad->GetY2()>maxr ? 1 : fGeomCam->GetConvMm2Deg();
|
---|
1944 |
|
---|
1945 | if (GetPixelIndex(px, py, conv)>=0)
|
---|
1946 | return 0;
|
---|
1947 |
|
---|
1948 | if (!box)
|
---|
1949 | return 999999;
|
---|
1950 |
|
---|
1951 | const Int_t dist = box->DistancetoPrimitive(px, py);
|
---|
1952 | if (dist > TPad::GetMaxPickDistance())
|
---|
1953 | return 999999;
|
---|
1954 |
|
---|
1955 | gPad->SetSelected(box);
|
---|
1956 | return dist;
|
---|
1957 | }
|
---|
1958 |
|
---|
1959 | // ------------------------------------------------------------------------
|
---|
1960 | //
|
---|
1961 | //
|
---|
1962 | Int_t MHCamera::GetPixelIndex(Int_t px, Int_t py, Float_t conv) const
|
---|
1963 | {
|
---|
1964 | if (fNcells<=1)
|
---|
1965 | return -1;
|
---|
1966 |
|
---|
1967 | Int_t i;
|
---|
1968 | for (i=0; i<fNcells-2; i++)
|
---|
1969 | {
|
---|
1970 | MHexagon hex((*fGeomCam)[i]);
|
---|
1971 | if (hex.DistancetoPrimitive(px, py, conv)>0)
|
---|
1972 | continue;
|
---|
1973 |
|
---|
1974 | return i;
|
---|
1975 | }
|
---|
1976 | return -1;
|
---|
1977 | }
|
---|
1978 |
|
---|
1979 | // ------------------------------------------------------------------------
|
---|
1980 | //
|
---|
1981 | // Returns string containing info about the object at position (px,py).
|
---|
1982 | // Returned string will be re-used (lock in MT environment).
|
---|
1983 | //
|
---|
1984 | char *MHCamera::GetObjectInfo(Int_t px, Int_t py) const
|
---|
1985 | {
|
---|
1986 | if (TString(GetDrawOption()).Contains("hist", TString::kIgnoreCase))
|
---|
1987 | return TH1D::GetObjectInfo(px, py);
|
---|
1988 |
|
---|
1989 | static char info[128];
|
---|
1990 |
|
---|
1991 | const Int_t idx=GetPixelIndex(px, py);
|
---|
1992 |
|
---|
1993 | if (idx<0)
|
---|
1994 | return TObject::GetObjectInfo(px, py);
|
---|
1995 |
|
---|
1996 | sprintf(info, "Software Pixel Idx: %d (Hardware Id=%d) c=%.1f <%s>",
|
---|
1997 | idx, idx+1, GetBinContent(idx+1), IsUsed(idx)?"on":"off");
|
---|
1998 | return info;
|
---|
1999 | }
|
---|
2000 |
|
---|
2001 | // ------------------------------------------------------------------------
|
---|
2002 | //
|
---|
2003 | // Add a MCamEvent which should be displayed when the user clicks on a
|
---|
2004 | // pixel.
|
---|
2005 | // Warning: The object MUST inherit from TObject AND MCamEvent
|
---|
2006 | //
|
---|
2007 | void MHCamera::AddNotify(TObject *obj)
|
---|
2008 | {
|
---|
2009 | // Make sure, that the object derives from MCamEvent!
|
---|
2010 | MCamEvent *evt = dynamic_cast<MCamEvent*>(obj);
|
---|
2011 | if (!evt)
|
---|
2012 | {
|
---|
2013 | gLog << err << "ERROR: MHCamera::AddNotify - TObject doesn't inherit from MCamEvent... ignored." << endl;
|
---|
2014 | return;
|
---|
2015 | }
|
---|
2016 |
|
---|
2017 | // Make sure, that it is deleted from the list too, if the obj is deleted
|
---|
2018 | obj->SetBit(kMustCleanup);
|
---|
2019 |
|
---|
2020 | // Add object to list
|
---|
2021 | fNotify->Add(obj);
|
---|
2022 | }
|
---|
2023 |
|
---|
2024 | // ------------------------------------------------------------------------
|
---|
2025 | //
|
---|
2026 | // Execute a mouse event on the camera
|
---|
2027 | //
|
---|
2028 | void MHCamera::ExecuteEvent(Int_t event, Int_t px, Int_t py)
|
---|
2029 | {
|
---|
2030 | if (TString(GetDrawOption()).Contains("hist", TString::kIgnoreCase))
|
---|
2031 | {
|
---|
2032 | TH1D::ExecuteEvent(event, px, py);
|
---|
2033 | return;
|
---|
2034 | }
|
---|
2035 | //if (event==kMouseMotion && fStatusBar)
|
---|
2036 | // fStatusBar->SetText(GetObjectInfo(px, py), 0);
|
---|
2037 | if (event!=kButton1Down)
|
---|
2038 | return;
|
---|
2039 |
|
---|
2040 | const Int_t idx = GetPixelIndex(px, py);
|
---|
2041 | if (idx<0)
|
---|
2042 | return;
|
---|
2043 |
|
---|
2044 | gLog << all << GetTitle() << " <" << GetName() << ">" << dec << endl;
|
---|
2045 | gLog << "Software Pixel Idx: " << idx << endl;
|
---|
2046 | gLog << "Hardware Pixel Id: " << idx+1 << endl;
|
---|
2047 | gLog << "Contents: " << GetBinContent(idx+1);
|
---|
2048 | if (GetBinError(idx+1)>0)
|
---|
2049 | gLog << " +/- " << GetBinError(idx+1);
|
---|
2050 | gLog << " <" << (IsUsed(idx)?"on":"off") << "> n=" << fBinEntries[idx+1] << endl;
|
---|
2051 |
|
---|
2052 | if (fNotify && fNotify->GetSize()>0)
|
---|
2053 | {
|
---|
2054 | // FIXME: Is there a simpler and more convinient way?
|
---|
2055 |
|
---|
2056 | // The name which is created here depends on the instance of
|
---|
2057 | // MHCamera and on the pad on which it is drawn --> The name
|
---|
2058 | // is unique. For ExecuteEvent gPad is always correctly set.
|
---|
2059 | const TString name = Form("%p;%p;PixelContent", this, gPad);
|
---|
2060 |
|
---|
2061 | TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
|
---|
2062 | if (old)
|
---|
2063 | old->cd();
|
---|
2064 | else
|
---|
2065 | new TCanvas(name);
|
---|
2066 |
|
---|
2067 | /*
|
---|
2068 | TIter Next(gPad->GetListOfPrimitives());
|
---|
2069 | TObject *o;
|
---|
2070 | while (o=Next()) cout << o << ": " << o->GetName() << " " << o->IsA()->GetName() << endl;
|
---|
2071 | */
|
---|
2072 |
|
---|
2073 | // FIXME: Make sure, that the old histograms are really deleted.
|
---|
2074 | // Are they already deleted?
|
---|
2075 |
|
---|
2076 | // The dynamic_cast is necessary here: We cannot use ForEach
|
---|
2077 | TIter Next(fNotify);
|
---|
2078 | MCamEvent *evt;
|
---|
2079 | while ((evt=dynamic_cast<MCamEvent*>(Next())))
|
---|
2080 | evt->DrawPixelContent(idx);
|
---|
2081 |
|
---|
2082 | gPad->Modified();
|
---|
2083 | gPad->Update();
|
---|
2084 | }
|
---|
2085 | }
|
---|
2086 |
|
---|
2087 | UInt_t MHCamera::GetNumPixels() const
|
---|
2088 | {
|
---|
2089 | return fGeomCam ? fGeomCam->GetNumPixels() : 0;
|
---|
2090 | }
|
---|
2091 |
|
---|
2092 | TH1 *MHCamera::DrawCopy() const
|
---|
2093 | {
|
---|
2094 | gPad=NULL;
|
---|
2095 | return TH1D::DrawCopy(fName+";cpy");
|
---|
2096 | }
|
---|
2097 |
|
---|
2098 | // --------------------------------------------------------------------------
|
---|
2099 | //
|
---|
2100 | // Draw a projection of MHCamera onto the y-axis values. Depending on the
|
---|
2101 | // variable fit, the following fits are performed:
|
---|
2102 | //
|
---|
2103 | // 0: No fit, simply draw the projection
|
---|
2104 | // 1: Single Gauss (for distributions flat-fielded over the whole camera)
|
---|
2105 | // 2: Double Gauss (for distributions different for inner and outer pixels)
|
---|
2106 | // 3: Triple Gauss (for distributions with inner, outer pixels and outliers)
|
---|
2107 | // 4: flat (for the probability distributions)
|
---|
2108 | // (1-4:) Moreover, sectors 6,1 and 2 of the camera and sectors 3,4 and 5 are
|
---|
2109 | // drawn separately, for inner and outer pixels.
|
---|
2110 | // 5: Fit Inner and Outer pixels separately by a single Gaussian
|
---|
2111 | // (only for MAGIC cameras)
|
---|
2112 | // 6: Fit Inner and Outer pixels separately by a single Gaussian and display
|
---|
2113 | // additionally the two camera halfs separately (for MAGIC camera)
|
---|
2114 | // 7: Single Gauss with TLegend to show the meaning of the colours
|
---|
2115 | //
|
---|
2116 | void MHCamera::DrawProjection(Int_t fit) const
|
---|
2117 | {
|
---|
2118 | TArrayI inner(1);
|
---|
2119 | inner[0] = 0;
|
---|
2120 |
|
---|
2121 | TArrayI outer(1);
|
---|
2122 | outer[0] = 1;
|
---|
2123 |
|
---|
2124 | if (fit==5 || fit==6)
|
---|
2125 | {
|
---|
2126 | if (GetGeomCam().InheritsFrom("MGeomCamMagic"))
|
---|
2127 | {
|
---|
2128 | TArrayI s0(6);
|
---|
2129 | s0[0] = 6;
|
---|
2130 | s0[1] = 1;
|
---|
2131 | s0[2] = 2;
|
---|
2132 | s0[3] = 3;
|
---|
2133 | s0[4] = 4;
|
---|
2134 | s0[5] = 5;
|
---|
2135 |
|
---|
2136 | TArrayI s1(3);
|
---|
2137 | s1[0] = 6;
|
---|
2138 | s1[1] = 1;
|
---|
2139 | s1[2] = 2;
|
---|
2140 |
|
---|
2141 | TArrayI s2(3);
|
---|
2142 | s2[0] = 3;
|
---|
2143 | s2[1] = 4;
|
---|
2144 | s2[2] = 5;
|
---|
2145 |
|
---|
2146 | gPad->Clear();
|
---|
2147 | TVirtualPad *pad = gPad;
|
---|
2148 | pad->Divide(2,1);
|
---|
2149 |
|
---|
2150 | TH1D *inout[2];
|
---|
2151 | inout[0] = ProjectionS(s0, inner, "Inner");
|
---|
2152 | inout[1] = ProjectionS(s0, outer, "Outer");
|
---|
2153 |
|
---|
2154 | inout[0]->SetDirectory(NULL);
|
---|
2155 | inout[1]->SetDirectory(NULL);
|
---|
2156 |
|
---|
2157 | for (int i=0; i<2; i++)
|
---|
2158 | {
|
---|
2159 | pad->cd(i+1);
|
---|
2160 | gPad->SetBorderMode(0);
|
---|
2161 |
|
---|
2162 | inout[i]->SetLineColor(kRed+i);
|
---|
2163 | inout[i]->SetBit(kCanDelete);
|
---|
2164 | inout[i]->Draw();
|
---|
2165 | inout[i]->Fit("gaus","Q");
|
---|
2166 |
|
---|
2167 | if (fit == 6)
|
---|
2168 | {
|
---|
2169 | TH1D *half[2];
|
---|
2170 | half[0] = ProjectionS(s1, i==0 ? inner : outer , "Sector 6-1-2");
|
---|
2171 | half[1] = ProjectionS(s2, i==0 ? inner : outer , "Sector 3-4-5");
|
---|
2172 |
|
---|
2173 | for (int j=0; j<2; j++)
|
---|
2174 | {
|
---|
2175 | half[j]->SetLineColor(kRed+i+2*j+1);
|
---|
2176 | half[j]->SetDirectory(NULL);
|
---|
2177 | half[j]->SetBit(kCanDelete);
|
---|
2178 | half[j]->Draw("same");
|
---|
2179 | }
|
---|
2180 | }
|
---|
2181 |
|
---|
2182 | }
|
---|
2183 | }
|
---|
2184 | return;
|
---|
2185 | }
|
---|
2186 |
|
---|
2187 | TH1D *obj2 = (TH1D*)Projection(GetName());
|
---|
2188 | obj2->SetDirectory(0);
|
---|
2189 | obj2->Draw();
|
---|
2190 | obj2->SetBit(kCanDelete);
|
---|
2191 |
|
---|
2192 | if (fit == 0)
|
---|
2193 | return;
|
---|
2194 |
|
---|
2195 | if (GetGeomCam().InheritsFrom("MGeomCamMagic"))
|
---|
2196 | {
|
---|
2197 | TArrayI s0(3);
|
---|
2198 | s0[0] = 6;
|
---|
2199 | s0[1] = 1;
|
---|
2200 | s0[2] = 2;
|
---|
2201 |
|
---|
2202 | TArrayI s1(3);
|
---|
2203 | s1[0] = 3;
|
---|
2204 | s1[1] = 4;
|
---|
2205 | s1[2] = 5;
|
---|
2206 |
|
---|
2207 | TH1D *halfInOut[4];
|
---|
2208 |
|
---|
2209 | // Just to get the right (maximum) binning
|
---|
2210 | halfInOut[0] = ProjectionS(s0, inner, "Sector 6-1-2 Inner");
|
---|
2211 | halfInOut[1] = ProjectionS(s1, inner, "Sector 3-4-5 Inner");
|
---|
2212 | halfInOut[2] = ProjectionS(s0, outer, "Sector 6-1-2 Outer");
|
---|
2213 | halfInOut[3] = ProjectionS(s1, outer, "Sector 3-4-5 Outer");
|
---|
2214 |
|
---|
2215 | TLegend *leg = new TLegend(0.05,0.65,0.35,0.9);
|
---|
2216 |
|
---|
2217 | for (int i=0; i<4; i++)
|
---|
2218 | {
|
---|
2219 | halfInOut[i]->SetLineColor(kRed+i);
|
---|
2220 | halfInOut[i]->SetDirectory(0);
|
---|
2221 | halfInOut[i]->SetBit(kCanDelete);
|
---|
2222 | halfInOut[i]->Draw("same");
|
---|
2223 | leg->AddEntry(halfInOut[i],halfInOut[i]->GetTitle(),"l");
|
---|
2224 | }
|
---|
2225 |
|
---|
2226 | if (fit==7)
|
---|
2227 | leg->Draw();
|
---|
2228 |
|
---|
2229 | gPad->Modified();
|
---|
2230 | gPad->Update();
|
---|
2231 | }
|
---|
2232 |
|
---|
2233 | const Double_t min = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
|
---|
2234 | const Double_t max = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
|
---|
2235 | const Double_t integ = obj2->Integral("width")/2.5;
|
---|
2236 | const Double_t mean = obj2->GetMean();
|
---|
2237 | const Double_t rms = obj2->GetRMS();
|
---|
2238 | const Double_t width = max-min;
|
---|
2239 |
|
---|
2240 | const TString dgausformula = "([0]-[3])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])"
|
---|
2241 | "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])";
|
---|
2242 |
|
---|
2243 | const TString tgausformula = "([0]-[3]-[6])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])"
|
---|
2244 | "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])"
|
---|
2245 | "+[6]/[8]*exp(-0.5*(x-[7])*(x-[7])/[8]/[8])";
|
---|
2246 |
|
---|
2247 | TF1 *f=0;
|
---|
2248 | switch (fit)
|
---|
2249 | {
|
---|
2250 | case 1:
|
---|
2251 | f = new TF1("sgaus", "gaus(0)", min, max);
|
---|
2252 | f->SetLineColor(kYellow);
|
---|
2253 | f->SetBit(kCanDelete);
|
---|
2254 | f->SetParNames("Area", "#mu", "#sigma");
|
---|
2255 | f->SetParameters(integ/rms, mean, rms);
|
---|
2256 | f->SetParLimits(0, 0, integ);
|
---|
2257 | f->SetParLimits(1, min, max);
|
---|
2258 | f->SetParLimits(2, 0, width/1.5);
|
---|
2259 |
|
---|
2260 | obj2->Fit(f, "QLR");
|
---|
2261 | break;
|
---|
2262 |
|
---|
2263 | case 2:
|
---|
2264 | f = new TF1("dgaus",dgausformula.Data(),min,max);
|
---|
2265 | f->SetLineColor(kYellow);
|
---|
2266 | f->SetBit(kCanDelete);
|
---|
2267 | f->SetParNames("A_{tot}", "#mu1", "#sigma1", "A2", "#mu2", "#sigma2");
|
---|
2268 | f->SetParameters(integ,(min+mean)/2.,width/4.,
|
---|
2269 | integ/width/2.,(max+mean)/2.,width/4.);
|
---|
2270 | // The left-sided Gauss
|
---|
2271 | f->SetParLimits(0,integ-1.5 , integ+1.5);
|
---|
2272 | f->SetParLimits(1,min+(width/10.), mean);
|
---|
2273 | f->SetParLimits(2,0 , width/2.);
|
---|
2274 | // The right-sided Gauss
|
---|
2275 | f->SetParLimits(3,0 , integ);
|
---|
2276 | f->SetParLimits(4,mean, max-(width/10.));
|
---|
2277 | f->SetParLimits(5,0 , width/2.);
|
---|
2278 | obj2->Fit(f,"QLRM");
|
---|
2279 | break;
|
---|
2280 |
|
---|
2281 | case 3:
|
---|
2282 | f = new TF1("tgaus",tgausformula.Data(),min,max);
|
---|
2283 | f->SetLineColor(kYellow);
|
---|
2284 | f->SetBit(kCanDelete);
|
---|
2285 | f->SetParNames("A_{tot}","#mu_{1}","#sigma_{1}",
|
---|
2286 | "A_{2}","#mu_{2}","#sigma_{2}",
|
---|
2287 | "A_{3}","#mu_{3}","#sigma_{3}");
|
---|
2288 | f->SetParameters(integ,(min+mean)/2,width/4.,
|
---|
2289 | integ/width/3.,(max+mean)/2.,width/4.,
|
---|
2290 | integ/width/3.,mean,width/2.);
|
---|
2291 | // The left-sided Gauss
|
---|
2292 | f->SetParLimits(0,integ-1.5,integ+1.5);
|
---|
2293 | f->SetParLimits(1,min+(width/10.),mean);
|
---|
2294 | f->SetParLimits(2,width/15.,width/2.);
|
---|
2295 | // The right-sided Gauss
|
---|
2296 | f->SetParLimits(3,0.,integ);
|
---|
2297 | f->SetParLimits(4,mean,max-(width/10.));
|
---|
2298 | f->SetParLimits(5,width/15.,width/2.);
|
---|
2299 | // The Gauss describing the outliers
|
---|
2300 | f->SetParLimits(6,0.,integ);
|
---|
2301 | f->SetParLimits(7,min,max);
|
---|
2302 | f->SetParLimits(8,width/4.,width/1.5);
|
---|
2303 | obj2->Fit(f,"QLRM");
|
---|
2304 | break;
|
---|
2305 |
|
---|
2306 | case 4:
|
---|
2307 | obj2->Fit("pol0", "Q");
|
---|
2308 | obj2->GetFunction("pol0")->SetLineColor(kYellow);
|
---|
2309 | break;
|
---|
2310 |
|
---|
2311 | case 9:
|
---|
2312 | break;
|
---|
2313 |
|
---|
2314 | default:
|
---|
2315 | obj2->Fit("gaus", "Q");
|
---|
2316 | obj2->GetFunction("gaus")->SetLineColor(kYellow);
|
---|
2317 | break;
|
---|
2318 | }
|
---|
2319 | }
|
---|
2320 |
|
---|
2321 | // --------------------------------------------------------------------------
|
---|
2322 | //
|
---|
2323 | // Draw a projection of MHCamera vs. the radius from the central pixel.
|
---|
2324 | //
|
---|
2325 | // The inner and outer pixels are drawn separately, both fitted by a polynomial
|
---|
2326 | // of grade 1.
|
---|
2327 | //
|
---|
2328 | void MHCamera::DrawRadialProfile() const
|
---|
2329 | {
|
---|
2330 | TProfile *obj2 = (TProfile*)RadialProfile(GetName());
|
---|
2331 | obj2->SetDirectory(0);
|
---|
2332 | obj2->Draw();
|
---|
2333 | obj2->SetBit(kCanDelete);
|
---|
2334 |
|
---|
2335 | if (GetGeomCam().InheritsFrom("MGeomCamMagic"))
|
---|
2336 | {
|
---|
2337 | TArrayI s0(6);
|
---|
2338 | s0[0] = 1;
|
---|
2339 | s0[1] = 2;
|
---|
2340 | s0[2] = 3;
|
---|
2341 | s0[3] = 4;
|
---|
2342 | s0[4] = 5;
|
---|
2343 | s0[5] = 6;
|
---|
2344 |
|
---|
2345 | TArrayI inner(1);
|
---|
2346 | inner[0] = 0;
|
---|
2347 |
|
---|
2348 | TArrayI outer(1);
|
---|
2349 | outer[0] = 1;
|
---|
2350 |
|
---|
2351 | // Just to get the right (maximum) binning
|
---|
2352 | TProfile *half[2];
|
---|
2353 | half[0] = RadialProfileS(s0, inner,Form("%sInner",GetName()));
|
---|
2354 | half[1] = RadialProfileS(s0, outer,Form("%sOuter",GetName()));
|
---|
2355 |
|
---|
2356 | for (Int_t i=0; i<2; i++)
|
---|
2357 | {
|
---|
2358 | Double_t min = GetGeomCam().GetMinRadius(i);
|
---|
2359 | Double_t max = GetGeomCam().GetMaxRadius(i);
|
---|
2360 |
|
---|
2361 | half[i]->SetLineColor(kRed+i);
|
---|
2362 | half[i]->SetDirectory(0);
|
---|
2363 | half[i]->SetBit(kCanDelete);
|
---|
2364 | half[i]->Draw("same");
|
---|
2365 | half[i]->Fit("pol1","Q","",min,max);
|
---|
2366 | half[i]->GetFunction("pol1")->SetLineColor(kRed+i);
|
---|
2367 | half[i]->GetFunction("pol1")->SetLineWidth(1);
|
---|
2368 | }
|
---|
2369 | }
|
---|
2370 | }
|
---|
2371 |
|
---|
2372 | // --------------------------------------------------------------------------
|
---|
2373 | //
|
---|
2374 | // Draw a projection of MHCamera vs. the azimuth angle inside the camera.
|
---|
2375 | //
|
---|
2376 | // The inner and outer pixels are drawn separately.
|
---|
2377 | // The general azimuth profile is fitted by a straight line
|
---|
2378 | //
|
---|
2379 | void MHCamera::DrawAzimuthProfile() const
|
---|
2380 | {
|
---|
2381 | TProfile *obj2 = (TProfile*)AzimuthProfile(GetName());
|
---|
2382 | obj2->SetDirectory(0);
|
---|
2383 | obj2->Draw();
|
---|
2384 | obj2->SetBit(kCanDelete);
|
---|
2385 | obj2->Fit("pol0","Q","");
|
---|
2386 | obj2->GetFunction("pol0")->SetLineWidth(1);
|
---|
2387 |
|
---|
2388 | if (GetGeomCam().InheritsFrom("MGeomCamMagic"))
|
---|
2389 | {
|
---|
2390 | TArrayI inner(1);
|
---|
2391 | inner[0] = 0;
|
---|
2392 |
|
---|
2393 | TArrayI outer(1);
|
---|
2394 | outer[0] = 1;
|
---|
2395 |
|
---|
2396 | // Just to get the right (maximum) binning
|
---|
2397 | TProfile *half[2];
|
---|
2398 | half[0] = AzimuthProfileA(inner,Form("%sInner",GetName()));
|
---|
2399 | half[1] = AzimuthProfileA(outer,Form("%sOuter",GetName()));
|
---|
2400 |
|
---|
2401 | for (Int_t i=0; i<2; i++)
|
---|
2402 | {
|
---|
2403 | half[i]->SetLineColor(kRed+i);
|
---|
2404 | half[i]->SetDirectory(0);
|
---|
2405 | half[i]->SetBit(kCanDelete);
|
---|
2406 | half[i]->SetMarkerSize(0.5);
|
---|
2407 | half[i]->Draw("same");
|
---|
2408 | }
|
---|
2409 | }
|
---|
2410 | }
|
---|
2411 |
|
---|
2412 | // --------------------------------------------------------------------------
|
---|
2413 | //
|
---|
2414 | // Draw the MHCamera into the MStatusDisplay:
|
---|
2415 | //
|
---|
2416 | // 1) Draw it as histogram (MHCamera::DrawCopy("hist")
|
---|
2417 | // 2) Draw it as a camera, with MHCamera::SetPrettyPalette() set.
|
---|
2418 | // 3) If "rad" is not zero, draw its values vs. the radius from the camera center.
|
---|
2419 | // (DrawRadialProfile())
|
---|
2420 | // 4) Depending on the variable "fit", draw the values projection on the y-axis
|
---|
2421 | // (DrawProjection()):
|
---|
2422 | // 0: don't draw
|
---|
2423 | // 1: Draw fit to Single Gauss (for distributions flat-fielded over the whole camera)
|
---|
2424 | // 2: Draw and fit to Double Gauss (for distributions different for inner and outer pixels)
|
---|
2425 | // 3: Draw and fit to Triple Gauss (for distributions with inner, outer pixels and outliers)
|
---|
2426 | // 4: Draw and fit to Polynomial grade 0: (for the probability distributions)
|
---|
2427 | // >4: Draw and don;t fit.
|
---|
2428 | //
|
---|
2429 | void MHCamera::CamDraw(TCanvas &c, const Int_t x, const Int_t y,
|
---|
2430 | const Int_t fit, const Int_t rad, const Int_t azi,
|
---|
2431 | TObject *notify)
|
---|
2432 | {
|
---|
2433 | c.cd(x);
|
---|
2434 | gPad->SetBorderMode(0);
|
---|
2435 | gPad->SetTicks();
|
---|
2436 | MHCamera *obj1=(MHCamera*)DrawCopy("hist");
|
---|
2437 | obj1->SetDirectory(NULL);
|
---|
2438 |
|
---|
2439 | if (notify)
|
---|
2440 | obj1->AddNotify(notify);
|
---|
2441 |
|
---|
2442 | c.cd(x+y);
|
---|
2443 | gPad->SetBorderMode(0);
|
---|
2444 | obj1->SetPrettyPalette();
|
---|
2445 | obj1->Draw();
|
---|
2446 |
|
---|
2447 | Int_t cnt = 2;
|
---|
2448 |
|
---|
2449 | if (rad)
|
---|
2450 | {
|
---|
2451 | c.cd(x+2*y);
|
---|
2452 | gPad->SetBorderMode(0);
|
---|
2453 | gPad->SetTicks();
|
---|
2454 | DrawRadialProfile();
|
---|
2455 | cnt++;
|
---|
2456 | }
|
---|
2457 |
|
---|
2458 | if (azi)
|
---|
2459 | {
|
---|
2460 | c.cd(x+cnt*y);
|
---|
2461 | gPad->SetBorderMode(0);
|
---|
2462 | gPad->SetTicks();
|
---|
2463 | DrawAzimuthProfile();
|
---|
2464 | cnt++;
|
---|
2465 | }
|
---|
2466 |
|
---|
2467 | if (!fit)
|
---|
2468 | return;
|
---|
2469 |
|
---|
2470 | c.cd(x + cnt*y);
|
---|
2471 | gPad->SetBorderMode(0);
|
---|
2472 | gPad->SetTicks();
|
---|
2473 | DrawProjection(fit);
|
---|
2474 | }
|
---|