35 ClassImp(TEveCaloViz);
39 TEveCaloViz::TEveCaloViz(TEveCaloData* data,
const char* n,
const char* t) :
45 fCellIdCacheOK(kFALSE),
51 fPhiOffset(TMath::Pi()),
65 fValueIsColor(kFALSE),
71 SetElementNameTitle(n, t);
78 TEveCaloViz::~TEveCaloViz()
80 if (fPalette) fPalette->DecRefCount();
86 Float_t TEveCaloViz::GetDataSliceThreshold(Int_t slice)
const
88 return fData->RefSliceInfo(slice).fThreshold;
95 TEveElement* TEveCaloViz::ForwardSelection()
105 TEveElement* TEveCaloViz::ForwardEdit()
113 void TEveCaloViz::SetDataSliceThreshold(Int_t slice, Float_t val)
115 fData->SetSliceThreshold(slice, val);
121 Color_t TEveCaloViz::GetDataSliceColor(Int_t slice)
const
123 return fData->RefSliceInfo(slice).fColor;
129 void TEveCaloViz::SetDataSliceColor(Int_t slice, Color_t col)
131 fData->SetSliceColor(slice, col);
137 void TEveCaloViz::SetEta(Float_t l, Float_t u)
142 InvalidateCellIdCache();
148 void TEveCaloViz::SetPlotEt(Bool_t isEt)
152 fPalette->SetLimits(0, TMath::CeilNint(GetMaxVal()));
154 InvalidateCellIdCache();
159 Float_t TEveCaloViz::GetMaxVal()
const
163 return fData->GetMaxVal(fPlotEt);
170 void TEveCaloViz::SetPhiWithRng(Float_t phi, Float_t rng)
172 using namespace TMath;
177 InvalidateCellIdCache();
183 Float_t TEveCaloViz::GetTransitionTheta()
const
185 return TMath::ATan(fBarrelRadius/fEndCapPosF);
191 Float_t TEveCaloViz::GetTransitionEta()
const
193 using namespace TMath;
194 Float_t t = GetTransitionTheta()*0.5f;
201 Float_t TEveCaloViz::GetTransitionThetaForward()
const
203 return TMath::ATan(fBarrelRadius/fEndCapPosF);
209 Float_t TEveCaloViz::GetTransitionEtaForward()
const
211 using namespace TMath;
212 Float_t t = GetTransitionThetaForward()*0.5f;
219 Float_t TEveCaloViz::GetTransitionThetaBackward()
const
221 return TMath::ATan(fBarrelRadius/fEndCapPosB);
227 Float_t TEveCaloViz::GetTransitionEtaBackward()
const
229 using namespace TMath;
230 Float_t t = GetTransitionThetaBackward()*0.5f;
239 void TEveCaloViz::SetData(TEveCaloData* data)
242 if (data == fData)
return;
243 if (fData) fData->RemoveElement(
this);
247 fData->AddElement(
this);
256 void TEveCaloViz::DataChanged()
258 Double_t min, max, delta;
260 fData->GetEtaLimits(min, max);
265 if (fEtaMin < min) fEtaMin = min;
266 if (fEtaMax > max) fEtaMax = max;
269 fData->GetPhiLimits(min, max);
270 delta = 0.5*(max - min);
271 if (fAutoRange || fPhi < min || fPhi > max) {
272 fPhi = 0.5*(max + min);
275 if (fPhiOffset > delta) fPhiOffset = delta;
280 Int_t hlimit = TMath::CeilNint(GetMaxVal());
281 fPalette->SetLimits(0, hlimit);
283 fPalette->SetMax(hlimit);
286 InvalidateCellIdCache();
293 Bool_t TEveCaloViz::AssertCellIdCache()
const
295 TEveCaloViz* cv =
const_cast<TEveCaloViz*
>(
this);
296 if (!fCellIdCacheOK) {
297 cv->BuildCellIdCache();
307 Bool_t TEveCaloViz::CellInEtaPhiRng(TEveCaloData::CellData_t& cellData)
const
309 if (cellData.EtaMin() >= fEtaMin && cellData.EtaMax() <= fEtaMax)
311 if (TEveUtil::IsU1IntervalContainedByMinMax
312 (fPhi-fPhiOffset, fPhi+fPhiOffset, cellData.PhiMin(), cellData.PhiMax()))
321 void TEveCaloViz::AssignCaloVizParameters(TEveCaloViz* m)
325 fEtaMin = m->fEtaMin;
326 fEtaMax = m->fEtaMax;
329 fPhiOffset = m->fPhiOffset;
331 fBarrelRadius = m->fBarrelRadius;
332 fEndCapPosF = m->fEndCapPosF;
333 fEndCapPosB = m->fEndCapPosB;
337 TEveRGBAPalette& mp = * m->fPalette;
338 if (fPalette) fPalette->DecRefCount();
339 fPalette =
new TEveRGBAPalette(mp.GetMinVal(), mp.GetMaxVal(), mp.GetInterpolate());
340 fPalette->SetDefaultColor(mp.GetDefaultColor());
347 void TEveCaloViz::SetPalette(TEveRGBAPalette* p)
349 if ( fPalette == p)
return;
350 if (fPalette) fPalette->DecRefCount();
352 if (fPalette) fPalette->IncRefCount();
358 Float_t TEveCaloViz::GetValToHeight()
const
362 return fMaxTowerH/fMaxValAbs;
369 return fMaxTowerH/fData->GetMaxVal(fPlotEt);
378 TEveRGBAPalette* TEveCaloViz::AssertPalette()
381 fPalette =
new TEveRGBAPalette;
382 fPalette->SetDefaultColor((Color_t)4);
384 Int_t hlimit = TMath::CeilNint(GetMaxVal());
385 fPalette->SetLimits(0, hlimit);
387 fPalette->SetMax(hlimit);
396 void TEveCaloViz::Paint(Option_t* )
407 TClass* TEveCaloViz::ProjectedClass(
const TEveProjection*)
const
409 return TEveCalo2D::Class();
415 void TEveCaloViz::SetupColorHeight(Float_t value, Int_t slice, Float_t& outH)
const
419 outH = GetValToHeight()*fData->GetMaxVal(fPlotEt);
421 fPalette->ColorFromValue((Int_t)value, c);
422 c[3] = fData->GetSliceTransparency(slice);
423 TGLUtil::Color4ubv(c);
427 TGLUtil::ColorTransparency(fData->GetSliceColor(slice), fData->GetSliceTransparency(slice));
428 outH = GetValToHeight()*value;
437 ClassImp(TEveCalo3D);
442 TEveCalo3D::TEveCalo3D(TEveCaloData* d,
const char* n,
const char* t):
443 TEveCaloViz(d, n, t),
445 fRnrEndCapFrame (kTRUE),
446 fRnrBarrelFrame (kTRUE),
448 fFrameColor (kGray+1),
449 fFrameTransparency (80)
451 fCanEditMainColor = kTRUE;
452 fCanEditMainTransparency = kTRUE;
453 fMainColorPtr = &fFrameColor;
459 void TEveCalo3D::BuildCellIdCache()
463 fData->GetCellList(GetEta(), GetEtaRng(), GetPhi(), GetPhiRng(), fCellList);
464 fCellIdCacheOK = kTRUE;
471 void TEveCalo3D::ComputeBBox()
475 Float_t th = (fData) ? GetValToHeight() * fData->GetMaxVal(fPlotEt) : 0;
477 fBBox[0] = -fBarrelRadius - th;
478 fBBox[1] = fBarrelRadius + th;
481 fBBox[4] = fEndCapPosB - th;
482 fBBox[5] = fEndCapPosF + th;
490 ClassImp(TEveCalo2D);
495 TEveCalo2D::TEveCalo2D(
const char* n,
const char* t):
496 TEveCaloViz(0, n, t),
498 fOldProjectionType(TEveProjection::kPT_Unknown),
507 TEveCalo2D::~TEveCalo2D()
509 TEveCaloData::vCellId_t* cids;
513 n = fCellListsSelected.size();
514 for(UInt_t i = 0; i < n; ++i) {
515 cids = fCellListsSelected[i];
517 cids->clear();
delete cids;
520 fCellListsSelected.clear();
523 n = fCellLists.size();
524 for(UInt_t i = 0; i < n; ++i) {
525 cids = fCellLists[i];
527 cids->clear();
delete cids;
536 void TEveCalo2D::UpdateProjection()
538 if (fManager->GetProjection()->GetType() != fOldProjectionType)
540 fCellIdCacheOK=kFALSE;
541 fOldProjectionType = fManager->GetProjection()->GetType();
549 void TEveCalo2D::SetProjection(TEveProjectionManager* mng, TEveProjectable* model)
551 TEveProjected::SetProjection(mng, model);
552 TEveCaloViz* viz =
dynamic_cast<TEveCaloViz*
>(model);
553 AssignCaloVizParameters(viz);
559 void TEveCalo2D::BuildCellIdCache()
562 for (vBinCells_i it = fCellLists.begin(); it != fCellLists.end(); it++)
571 fCellLists.push_back(0);
573 TEveProjection::EPType_e pt = fManager->GetProjection()->GetType();
574 TEveCaloData::vCellId_t* clv;
576 Bool_t isRPhi = (pt == TEveProjection::kPT_RPhi);
578 const TAxis* axis = isRPhi ? fData->GetPhiBins() : fData->GetEtaBins();
579 Int_t nBins = axis->GetNbins();
584 min = GetPhiMin() - fData->GetEps();
585 max = GetPhiMax() + fData->GetEps();
586 for (Int_t ibin = 1; ibin <= nBins; ++ibin) {
588 if ( TEveUtil::IsU1IntervalOverlappingByMinMax
589 (min, max, axis->GetBinLowEdge(ibin), axis->GetBinUpEdge(ibin)))
591 clv =
new TEveCaloData::vCellId_t();
592 fData->GetCellList(GetEta(), GetEtaRng(), axis->GetBinCenter(ibin), axis->GetBinWidth(ibin), *clv);
597 fCellLists.push_back(clv);
602 min = GetEtaMin() - fData->GetEps();
603 max = GetEtaMax() + fData->GetEps();
604 for (Int_t ibin = 1; ibin <= nBins; ++ibin) {
606 Float_t low = axis->GetBinLowEdge(ibin);
607 Float_t up = axis->GetBinUpEdge(ibin) ;
608 if (low >= min && up <= max)
610 clv =
new TEveCaloData::vCellId_t();
611 fData->GetCellList(axis->GetBinCenter(ibin), axis->GetBinWidth(ibin), fPhi, GetPhiRng(), *clv);
616 fCellLists.push_back(clv);
627 TEveCaloData::CellData_t cellData;
628 for (Int_t ibin = 1; ibin <= nBins; ++ibin) {
629 TEveCaloData::vCellId_t* cids = fCellLists[ibin];
633 for (TEveCaloData::vCellId_i it = cids->begin(); it != cids->end(); it++)
635 fData->GetCellData(*it, cellData);
636 sumE += cellData.Value(kFALSE);
637 sumEt += cellData.Value(kTRUE);
639 fMaxESumBin = TMath::Max(fMaxESumBin, sumE);
640 fMaxEtSumBin = TMath::Max(fMaxEtSumBin, sumEt);
646 fCellIdCacheOK= kTRUE;
652 void TEveCalo2D::CellSelectionChanged()
654 CellSelectionChangedInternal(fData->GetCellsSelected(), fCellListsSelected);
655 CellSelectionChangedInternal(fData->GetCellsHighlighted(), fCellListsHighlighted);
661 void TEveCalo2D::CellSelectionChangedInternal(TEveCaloData::vCellId_t& inputCells, std::vector<TEveCaloData::vCellId_t*>& outputCellLists)
663 Bool_t isRPhi = (fManager->GetProjection()->GetType() == TEveProjection::kPT_RPhi);
664 const TAxis* axis = isRPhi ? fData->GetPhiBins() : fData->GetEtaBins();
667 for (vBinCells_i it = outputCellLists.begin(); it != outputCellLists.end(); it++)
675 outputCellLists.clear();
676 UInt_t nBins = axis->GetNbins();
677 outputCellLists.resize(nBins+1);
678 for (UInt_t b = 0; b <= nBins; ++b)
679 outputCellLists[b] = 0;
681 for(UInt_t bin = 1; bin <= nBins; ++bin)
683 TEveCaloData::vCellId_t* idsInBin = fCellLists[bin];
687 for (TEveCaloData::vCellId_i i = idsInBin->begin(); i != idsInBin->end(); i++)
689 for (TEveCaloData::vCellId_i j = inputCells.begin(); j != inputCells.end(); j++)
691 if( (*i).fTower == (*j).fTower && (*i).fSlice == (*j).fSlice)
693 if (!outputCellLists[bin])
694 outputCellLists[bin] =
new TEveCaloData::vCellId_t();
696 outputCellLists[bin]->push_back(TEveCaloData::CellId_t((*i).fTower, (*i).fSlice, (*i).fFraction));
706 void TEveCalo2D::SetScaleAbs(Bool_t sa)
708 TEveCaloViz::SetScaleAbs(sa);
716 Float_t TEveCalo2D::GetValToHeight()
const
722 return fMaxTowerH/fMaxValAbs;
730 return fMaxTowerH/fMaxEtSumBin;
732 return fMaxTowerH/fMaxESumBin;
740 void TEveCalo2D::ComputeBBox()
745 Float_t th = fMaxTowerH ;
746 Float_t r = fBarrelRadius + th;
749 fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
750 BBoxCheckPoint(x, y, z);
751 x = -r, y = 0, z = 0;
752 fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
753 BBoxCheckPoint(x, y, z);
755 x = 0, y = 0, z = fEndCapPosF + th;
756 fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
757 BBoxCheckPoint(x, y, z);
758 x = 0, y = 0, z = fEndCapPosB - th;
759 fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
760 BBoxCheckPoint(x, y, z);
763 fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
764 BBoxCheckPoint(x, y, z);
765 x = 0, y = -r, z = 0;
766 fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
767 BBoxCheckPoint(x, y, z);
776 ClassImp(TEveCaloLego);
781 TEveCaloLego::TEveCaloLego(TEveCaloData* d,
const char* n,
const char* t):
782 TEveCaloViz(d, n, t),
787 fPlaneTransparency(60),
795 fNormalizeRebin(kFALSE),
804 fHasFixedHeightIn2DMode(kFALSE),
805 fFixedHeightValIn2DMode(0.f),
807 fDrawNumberCellPixels(18),
808 fCellPixelFontSize(12)
811 SetElementNameTitle(
"TEveCaloLego",
"TEveCaloLego");
817 void TEveCaloLego::SetData(TEveCaloData* data)
819 TEveCaloViz::SetData(data);
825 void TEveCaloLego::BuildCellIdCache()
829 fData->GetCellList(GetEta(), GetEtaRng(), GetPhi(), GetPhiRng(), fCellList);
830 fCellIdCacheOK = kTRUE;
837 void TEveCaloLego::ComputeBBox()
854 Double_t em, eM, pm, pM;
855 fData->GetEtaLimits(em, eM);
856 fData->GetPhiLimits(pm, pM);
857 Double_t r = (eM-em)/(pM-pm);
870 if (fScaleAbs && !fData->Empty())
871 fBBox[5] = GetMaxVal()*GetValToHeight();
873 fBBox[5] = fMaxTowerH;