forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEveCalo.cxx
885 lines (708 loc) · 23.7 KB
/
TEveCalo.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
// @(#)root/eve:$Id$
// Author: Matevz Tadel 2007
/*************************************************************************
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "TEveCalo.h"
#include "TEveCaloData.h"
#include "TEveProjections.h"
#include "TEveProjectionManager.h"
#include "TEveRGBAPalette.h"
#include "TEveText.h"
#include "TEveTrans.h"
#include "TClass.h"
#include "TMathBase.h"
#include "TMath.h"
#include "TAxis.h"
#include "TGLUtil.h"
#include <cassert>
//==============================================================================
// TEveCaloViz
//==============================================================================
//______________________________________________________________________________
//
// Base class for calorimeter data visualization.
// See TEveCalo2D and TEveCalo3D for concrete implementations.
ClassImp(TEveCaloViz);
//______________________________________________________________________________
TEveCaloViz::TEveCaloViz(TEveCaloData* data, const char* n, const char* t) :
TEveElement(),
TNamed(n, t),
TEveProjectable(),
fData(0),
fCellIdCacheOK(kFALSE),
fEtaMin(-10),
fEtaMax(10),
fPhi(0.),
fPhiOffset(TMath::Pi()),
fAutoRange(kTRUE),
fBarrelRadius(-1.f),
fEndCapPosF(-1.f),
fEndCapPosB(-1.f),
fPlotEt(kTRUE),
fMaxTowerH(100),
fScaleAbs(kFALSE),
fMaxValAbs(100),
fValueIsColor(kFALSE),
fPalette(0)
{
// Constructor.
fPickable = kTRUE;
SetElementNameTitle(n, t);
SetData(data);
}
//______________________________________________________________________________
TEveCaloViz::~TEveCaloViz()
{
// Destructor.
if (fPalette) fPalette->DecRefCount();
}
//______________________________________________________________________________
Float_t TEveCaloViz::GetDataSliceThreshold(Int_t slice) const
{
// Get threshold for given slice.
return fData->RefSliceInfo(slice).fThreshold;
}
//______________________________________________________________________________
TEveElement* TEveCaloViz::ForwardSelection()
{
// Management of selection state and ownership of selected cell list
// is done in TEveCaloData. This is a reason selection is forwared to it.
return fData;
}
//______________________________________________________________________________
TEveElement* TEveCaloViz::ForwardEdit()
{
// Management of selection state and ownership of selected cell list
// is done in TEveCaloData. We still want GUI editor to disply
// concrete calo-viz object.
return this;
}
//______________________________________________________________________________
void TEveCaloViz::SetDataSliceThreshold(Int_t slice, Float_t val)
{
// Set threshold for given slice.
fData->SetSliceThreshold(slice, val);
}
//______________________________________________________________________________
Color_t TEveCaloViz::GetDataSliceColor(Int_t slice) const
{
// Get slice color from data.
return fData->RefSliceInfo(slice).fColor;
}
//______________________________________________________________________________
void TEveCaloViz::SetDataSliceColor(Int_t slice, Color_t col)
{
// Set slice color in data.
fData->SetSliceColor(slice, col);
}
//______________________________________________________________________________
void TEveCaloViz::SetEta(Float_t l, Float_t u)
{
// Set eta range.
fEtaMin=l;
fEtaMax=u;
InvalidateCellIdCache();
}
//______________________________________________________________________________
void TEveCaloViz::SetPlotEt(Bool_t isEt)
{
// Set E/Et plot.
fPlotEt=isEt;
if (fPalette)
fPalette->SetLimits(0, TMath::CeilNint(GetMaxVal()));
InvalidateCellIdCache();
}
//______________________________________________________________________________
Float_t TEveCaloViz::GetMaxVal() const
{
// Get maximum plotted value.
return fData->GetMaxVal(fPlotEt);
}
//______________________________________________________________________________
void TEveCaloViz::SetPhiWithRng(Float_t phi, Float_t rng)
{
// Set phi range.
using namespace TMath;
fPhi = phi;
fPhiOffset = rng;
InvalidateCellIdCache();
}
//______________________________________________________________________________
Float_t TEveCaloViz::GetTransitionTheta() const
{
// Get transition angle between barrel and end-cap cells, assuming fEndCapPosF = -fEndCapPosB.
return TMath::ATan(fBarrelRadius/fEndCapPosF);
}
//______________________________________________________________________________
Float_t TEveCaloViz::GetTransitionEta() const
{
// Get transition eta between barrel and end-cap cells, assuming fEndCapPosF = -fEndCapPosB.
using namespace TMath;
Float_t t = GetTransitionTheta()*0.5f;
return -Log(Tan(t));
}
//______________________________________________________________________________
Float_t TEveCaloViz::GetTransitionThetaForward() const
{
// Get transition angle between barrel and forward end-cap cells.
return TMath::ATan(fBarrelRadius/fEndCapPosF);
}
//______________________________________________________________________________
Float_t TEveCaloViz::GetTransitionEtaForward() const
{
// Get transition eta between barrel and forward end-cap cells.
using namespace TMath;
Float_t t = GetTransitionThetaForward()*0.5f;
return -Log(Tan(t));
}
//______________________________________________________________________________
Float_t TEveCaloViz::GetTransitionThetaBackward() const
{
// Get transition angle between barrel and backward end-cap cells.
return TMath::ATan(fBarrelRadius/fEndCapPosB);
}
//______________________________________________________________________________
Float_t TEveCaloViz::GetTransitionEtaBackward() const
{
// Get transition eta between barrel and backward end-cap cells.
using namespace TMath;
Float_t t = GetTransitionThetaBackward()*0.5f;
//negative theta means negative eta
return Log(-Tan(t));
}
//______________________________________________________________________________
void TEveCaloViz::SetData(TEveCaloData* data)
{
// Set calorimeter event data.
if (data == fData) return;
if (fData) fData->RemoveElement(this);
fData = data;
if (fData)
{
fData->AddElement(this);
DataChanged();
}
}
//______________________________________________________________________________
void TEveCaloViz::DataChanged()
{
// Update setting and cache on data changed.
// Called from TEvecaloData::BroadcastDataChange()
Double_t min, max, delta;
fData->GetEtaLimits(min, max);
if (fAutoRange) {
fEtaMin = min;
fEtaMax = max;
} else {
if (fEtaMin < min) fEtaMin = min;
if (fEtaMax > max) fEtaMax = max;
}
fData->GetPhiLimits(min, max);
delta = 0.5*(max - min);
if (fAutoRange || fPhi < min || fPhi > max) {
fPhi = 0.5*(max + min);
fPhiOffset = delta;
} else {
if (fPhiOffset > delta) fPhiOffset = delta;
}
if (fPalette)
{
Int_t hlimit = TMath::CeilNint(GetMaxVal());
fPalette->SetLimits(0, hlimit);
fPalette->SetMin(0);
fPalette->SetMax(hlimit);
}
InvalidateCellIdCache();
}
//______________________________________________________________________________
Bool_t TEveCaloViz::AssertCellIdCache() const
{
// Assert cell id cache is ok.
// Returns true if the cache has been updated.
TEveCaloViz* cv = const_cast<TEveCaloViz*>(this);
if (!fCellIdCacheOK) {
cv->BuildCellIdCache();
return kTRUE;
} else {
return kFALSE;
}
}
//______________________________________________________________________________
Bool_t TEveCaloViz::CellInEtaPhiRng(TEveCaloData::CellData_t& cellData) const
{
// Returns true if given cell is in the ceta phi range.
if (cellData.EtaMin() >= fEtaMin && cellData.EtaMax() <= fEtaMax)
{
if (TEveUtil::IsU1IntervalContainedByMinMax
(fPhi-fPhiOffset, fPhi+fPhiOffset, cellData.PhiMin(), cellData.PhiMax()))
return kTRUE;
}
return kFALSE;
}
//______________________________________________________________________________
void TEveCaloViz::AssignCaloVizParameters(TEveCaloViz* m)
{
// Assign paramteres from given model.
SetData(m->fData);
fEtaMin = m->fEtaMin;
fEtaMax = m->fEtaMax;
fPhi = m->fPhi;
fPhiOffset = m->fPhiOffset;
fBarrelRadius = m->fBarrelRadius;
fEndCapPosF = m->fEndCapPosF;
fEndCapPosB = m->fEndCapPosB;
if (m->fPalette)
{
TEveRGBAPalette& mp = * m->fPalette;
if (fPalette) fPalette->DecRefCount();
fPalette = new TEveRGBAPalette(mp.GetMinVal(), mp.GetMaxVal(), mp.GetInterpolate());
fPalette->SetDefaultColor(mp.GetDefaultColor());
}
}
//______________________________________________________________________________
void TEveCaloViz::SetPalette(TEveRGBAPalette* p)
{
// Set TEveRGBAPalette object pointer.
if ( fPalette == p) return;
if (fPalette) fPalette->DecRefCount();
fPalette = p;
if (fPalette) fPalette->IncRefCount();
}
//______________________________________________________________________________
Float_t TEveCaloViz::GetValToHeight() const
{
// Get transformation factor from E/Et to height
if (fScaleAbs)
{
return fMaxTowerH/fMaxValAbs;
}
else
{
if (fData->Empty())
return 1;
return fMaxTowerH/fData->GetMaxVal(fPlotEt);
}
}
//______________________________________________________________________________
TEveRGBAPalette* TEveCaloViz::AssertPalette()
{
// Make sure the TEveRGBAPalette pointer is not null.
// If it is not set, a new one is instantiated and the range is set
// to current min/max signal values.
if (fPalette == 0) {
fPalette = new TEveRGBAPalette;
fPalette->SetDefaultColor((Color_t)4);
Int_t hlimit = TMath::CeilNint(GetMaxVal());
fPalette->SetLimits(0, hlimit);
fPalette->SetMin(0);
fPalette->SetMax(hlimit);
}
return fPalette;
}
//______________________________________________________________________________
void TEveCaloViz::Paint(Option_t* /*option*/)
{
// Paint this object. Only direct rendering is supported.
if (fData)
{
PaintStandard(this);
}
}
//______________________________________________________________________________
TClass* TEveCaloViz::ProjectedClass(const TEveProjection*) const
{
// Virtual from TEveProjectable, returns TEveCalo2D class.
return TEveCalo2D::Class();
}
//______________________________________________________________________________
void TEveCaloViz::SetupColorHeight(Float_t value, Int_t slice, Float_t& outH) const
{
// Set color and height for a given value and slice using slice color or TEveRGBAPalette.
if (fValueIsColor)
{
outH = GetValToHeight()*fData->GetMaxVal(fPlotEt);
UChar_t c[4];
fPalette->ColorFromValue((Int_t)value, c);
c[3] = fData->GetSliceTransparency(slice);
TGLUtil::Color4ubv(c);
}
else
{
TGLUtil::ColorTransparency(fData->GetSliceColor(slice), fData->GetSliceTransparency(slice));
outH = GetValToHeight()*value;
}
}
//==============================================================================
// TEveCalo3D
//==============================================================================
//______________________________________________________________________________
//
// Visualization of a calorimeter event data in 3D.
ClassImp(TEveCalo3D);
TEveCalo3D::TEveCalo3D(TEveCaloData* d, const char* n, const char* t):
TEveCaloViz(d, n, t),
fRnrEndCapFrame (kTRUE),
fRnrBarrelFrame (kTRUE),
fFrameWidth (0.5),
fFrameColor (kGray+1),
fFrameTransparency (80)
{
// Constructor.
fCanEditMainColor = kTRUE;
fCanEditMainTransparency = kTRUE;
fMainColorPtr = &fFrameColor;
}
//______________________________________________________________________________
void TEveCalo3D::BuildCellIdCache()
{
// Build list of drawn cell IDs. See TEveCalo3DGL::DirectDraw().
fCellList.clear();
fData->GetCellList(GetEta(), GetEtaRng(), GetPhi(), GetPhiRng(), fCellList);
fCellIdCacheOK = kTRUE;
}
//______________________________________________________________________________
void TEveCalo3D::ComputeBBox()
{
// Fill bounding-box information of the base-class TAttBBox (virtual method).
// If member 'TEveFrameBox* fFrame' is set, frame's corners are used as bbox.
BBoxInit();
Float_t th = (fData) ? GetValToHeight() * fData->GetMaxVal(fPlotEt) : 0;
fBBox[0] = -fBarrelRadius - th;
fBBox[1] = fBarrelRadius + th;
fBBox[2] = fBBox[0];
fBBox[3] = fBBox[1];
fBBox[4] = fEndCapPosB - th;
fBBox[5] = fEndCapPosF + th;
}
//==============================================================================
// TEveCalo2D
//==============================================================================
//______________________________________________________________________________
//
// Visualization of a calorimeter event data in 2D.
ClassImp(TEveCalo2D);
//______________________________________________________________________________
TEveCalo2D::TEveCalo2D(const char* n, const char* t):
TEveCaloViz(0, n, t),
TEveProjected(),
fOldProjectionType(TEveProjection::kPT_Unknown),
fMaxESumBin( 0),
fMaxEtSumBin(0)
{
// Constructor.
}
//______________________________________________________________________________
TEveCalo2D::~TEveCalo2D()
{
// Destructor.
TEveCaloData::vCellId_t* cids;
UInt_t n;
// clear selected cell ids
n = fCellListsSelected.size();
for(UInt_t i = 0; i < n; ++i) {
cids = fCellListsSelected[i];
if (cids) {
cids->clear(); delete cids;
}
}
fCellListsSelected.clear();
// clear all cell dds
n = fCellLists.size();
for(UInt_t i = 0; i < n; ++i) {
cids = fCellLists[i];
if (cids) {
cids->clear(); delete cids;
}
}
fCellLists.clear();
}
//______________________________________________________________________________
void TEveCalo2D::UpdateProjection()
{
// This is virtual method from base-class TEveProjected.
if (fManager->GetProjection()->GetType() != fOldProjectionType)
{
fCellIdCacheOK=kFALSE;
fOldProjectionType = fManager->GetProjection()->GetType();
}
ComputeBBox();
}
//______________________________________________________________________________
void TEveCalo2D::SetProjection(TEveProjectionManager* mng, TEveProjectable* model)
{
// Set projection manager and model object.
TEveProjected::SetProjection(mng, model);
TEveCaloViz* viz = dynamic_cast<TEveCaloViz*>(model);
AssignCaloVizParameters(viz);
}
//______________________________________________________________________________
void TEveCalo2D::BuildCellIdCache()
{
// Build lists of drawn cell IDs. See TEveCalo2DGL::DirecDraw().
// clear old cache
for (vBinCells_i it = fCellLists.begin(); it != fCellLists.end(); it++)
{
if (*it)
{
(*it)->clear();
delete *it;
}
}
fCellLists.clear();
fCellLists.push_back(0);
TEveProjection::EPType_e pt = fManager->GetProjection()->GetType();
TEveCaloData::vCellId_t* clv; // ids per phi bin in r-phi projection else ids per eta bins in rho-z projection
Bool_t isRPhi = (pt == TEveProjection::kPT_RPhi);
const TAxis* axis = isRPhi ? fData->GetPhiBins() : fData->GetEtaBins();
Int_t nBins = axis->GetNbins();
Float_t min, max;
if (isRPhi)
{
min = GetPhiMin() - fData->GetEps();
max = GetPhiMax() + fData->GetEps();
for (Int_t ibin = 1; ibin <= nBins; ++ibin) {
clv = 0;
if ( TEveUtil::IsU1IntervalOverlappingByMinMax
(min, max, axis->GetBinLowEdge(ibin), axis->GetBinUpEdge(ibin)))
{
clv = new TEveCaloData::vCellId_t();
fData->GetCellList(GetEta(), GetEtaRng(), axis->GetBinCenter(ibin), axis->GetBinWidth(ibin), *clv);
if (!clv->size()) {
delete clv; clv = 0;
}
}
fCellLists.push_back(clv);
}
}
else
{
min = GetEtaMin() - fData->GetEps();
max = GetEtaMax() + fData->GetEps();
for (Int_t ibin = 1; ibin <= nBins; ++ibin) {
clv = 0;
Float_t low = axis->GetBinLowEdge(ibin);
Float_t up = axis->GetBinUpEdge(ibin) ;
if (low >= min && up <= max)
{
clv = new TEveCaloData::vCellId_t();
fData->GetCellList(axis->GetBinCenter(ibin), axis->GetBinWidth(ibin), fPhi, GetPhiRng(), *clv);
if (!clv->size()) {
delete clv; clv = 0;
}
}
fCellLists.push_back(clv);
}
}
// cache max bin sum for auto scale
if (!fScaleAbs)
{
fMaxESumBin = 0;
fMaxEtSumBin = 0;
Float_t sumE = 0;
Float_t sumEt = 0;
TEveCaloData::CellData_t cellData;
for (Int_t ibin = 1; ibin <= nBins; ++ibin) {
TEveCaloData::vCellId_t* cids = fCellLists[ibin];
if (cids)
{
sumE = 0; sumEt = 0;
for (TEveCaloData::vCellId_i it = cids->begin(); it != cids->end(); it++)
{
fData->GetCellData(*it, cellData);
sumE += cellData.Value(kFALSE);
sumEt += cellData.Value(kTRUE);
}
fMaxESumBin = TMath::Max(fMaxESumBin, sumE);
fMaxEtSumBin = TMath::Max(fMaxEtSumBin, sumEt);
}
}
ComputeBBox();
}
fCellIdCacheOK= kTRUE;
}
//______________________________________________________________________________
void TEveCalo2D::CellSelectionChanged()
{
// Sort slected cells in eta or phi bins for selection and highlight.
CellSelectionChangedInternal(fData->GetCellsSelected(), fCellListsSelected);
CellSelectionChangedInternal(fData->GetCellsHighlighted(), fCellListsHighlighted);
}
//______________________________________________________________________________
void TEveCalo2D::CellSelectionChangedInternal(TEveCaloData::vCellId_t& inputCells, std::vector<TEveCaloData::vCellId_t*>& outputCellLists)
{
// Sort slected cells in eta or phi bins.
Bool_t isRPhi = (fManager->GetProjection()->GetType() == TEveProjection::kPT_RPhi);
const TAxis* axis = isRPhi ? fData->GetPhiBins() : fData->GetEtaBins();
// clear old cache
for (vBinCells_i it = outputCellLists.begin(); it != outputCellLists.end(); it++)
{
if (*it)
{
(*it)->clear();
delete *it;
}
}
outputCellLists.clear();
UInt_t nBins = axis->GetNbins();
outputCellLists.resize(nBins+1);
for (UInt_t b = 0; b <= nBins; ++b)
outputCellLists[b] = 0;
for(UInt_t bin = 1; bin <= nBins; ++bin)
{
TEveCaloData::vCellId_t* idsInBin = fCellLists[bin];
if (!idsInBin)
continue;
for (TEveCaloData::vCellId_i i = idsInBin->begin(); i != idsInBin->end(); i++)
{
for (TEveCaloData::vCellId_i j = inputCells.begin(); j != inputCells.end(); j++)
{
if( (*i).fTower == (*j).fTower && (*i).fSlice == (*j).fSlice)
{
if (!outputCellLists[bin])
outputCellLists[bin] = new TEveCaloData::vCellId_t();
outputCellLists[bin]->push_back(TEveCaloData::CellId_t((*i).fTower, (*i).fSlice, (*i).fFraction));
}
}
}
}
}
//______________________________________________________________________________
void TEveCalo2D::SetScaleAbs(Bool_t sa)
{
// Set absolute scale in projected calorimeter.
TEveCaloViz::SetScaleAbs(sa);
BuildCellIdCache();
}
//______________________________________________________________________________
Float_t TEveCalo2D::GetValToHeight() const
{
// Virtual function of TEveCaloViz.
// Get transformation factor from E/Et to height.
AssertCellIdCache();
if (fScaleAbs)
{
return fMaxTowerH/fMaxValAbs;
}
else
{
if (fData->Empty())
return 1;
if (fPlotEt)
return fMaxTowerH/fMaxEtSumBin;
else
return fMaxTowerH/fMaxESumBin;
}
}
//______________________________________________________________________________
void TEveCalo2D::ComputeBBox()
{
// Fill bounding-box information of the base-class TAttBBox (virtual method).
// If member 'TEveFrameBox* fFrame' is set, frame's corners are used as bbox.
BBoxZero();
Float_t x, y, z;
Float_t th = fMaxTowerH ;
Float_t r = fBarrelRadius + th;
x = r, y = 0, z = 0;
fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
BBoxCheckPoint(x, y, z);
x = -r, y = 0, z = 0;
fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
BBoxCheckPoint(x, y, z);
x = 0, y = 0, z = fEndCapPosF + th;
fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
BBoxCheckPoint(x, y, z);
x = 0, y = 0, z = fEndCapPosB - th;
fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
BBoxCheckPoint(x, y, z);
x = 0, y = r, z = 0;
fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
BBoxCheckPoint(x, y, z);
x = 0, y = -r, z = 0;
fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
BBoxCheckPoint(x, y, z);
}
//==============================================================================
// TEveCaloLego
//==============================================================================
//______________________________________________________________________________
//
// Visualization of calorimeter data as eta/phi histogram.
ClassImp(TEveCaloLego);
//______________________________________________________________________________
TEveCaloLego::TEveCaloLego(TEveCaloData* d, const char* n, const char* t):
TEveCaloViz(d, n, t),
fFontColor(-1),
fGridColor(-1),
fPlaneColor(kRed-5),
fPlaneTransparency(60),
fNZSteps(6),
fZAxisStep(0.f),
fAutoRebin(kTRUE),
fPixelsPerBin(12),
fNormalizeRebin(kFALSE),
fProjection(kAuto),
f2DMode(kValSize),
fBoxMode(kBack),
fDrawHPlane(kFALSE),
fHPlaneVal(0),
fHasFixedHeightIn2DMode(kFALSE),
fFixedHeightValIn2DMode(0.f),
fDrawNumberCellPixels(18), // draw numbers on cell above 30 pixels
fCellPixelFontSize(12) // size of cell fonts in pixels
{
// Constructor.
fMaxTowerH = 1;
SetElementNameTitle("TEveCaloLego", "TEveCaloLego");
}
//______________________________________________________________________________
void TEveCaloLego::SetData(TEveCaloData* data)
{
TEveCaloViz::SetData(data);
}
//______________________________________________________________________________
void TEveCaloLego::BuildCellIdCache()
{
// Build list of drawn cell IDs. For more information see TEveCaloLegoGL:DirectDraw().
fCellList.clear();
fData->GetCellList(GetEta(), GetEtaRng(), GetPhi(), GetPhiRng(), fCellList);
fCellIdCacheOK = kTRUE;
}
//______________________________________________________________________________
void TEveCaloLego::ComputeBBox()
{
// Fill bounding-box information of the base-class TAttBBox (virtual method).
// If member 'TEveFrameBox* fFrame' is set, frame's corners are used as bbox.
// fBBox = Float_t[6] X(min,max), Y(min,max), Z(min,max)
BBoxZero();
Float_t ex = 1.2; // 20% offset for axis labels
Float_t a = 0.5*ex;
fBBox[0] = -a;
fBBox[1] = a;
fBBox[2] = -a;
fBBox[3] = a;
// scaling is relative to shortest XY axis
Double_t em, eM, pm, pM;
fData->GetEtaLimits(em, eM);
fData->GetPhiLimits(pm, pM);
Double_t r = (eM-em)/(pM-pm);
if (r<1)
{
fBBox[2] /= r;
fBBox[3] /= r;
}
else
{
fBBox[0] *= r;
fBBox[1] *= r;
}
fBBox[4] = 0;
if (fScaleAbs && !fData->Empty())
fBBox[5] = GetMaxVal()*GetValToHeight();
else
fBBox[5] = fMaxTowerH;
}