Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveCaloData.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Author: Matevz Tadel 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "ROOT/REveCaloData.hxx"
13#include "ROOT/REveCalo.hxx"
14#include "ROOT/REveUtil.hxx"
15#include "ROOT/REveManager.hxx"
17
18#include "TAxis.h"
19#include "THStack.h"
20#include "TH2.h"
21#include "TMath.h"
22#include "TList.h"
23
24#include <cassert>
25#include <algorithm>
26#include <memory>
27#include <set>
28
29#include <nlohmann/json.hpp>
30
31using namespace ROOT::Experimental;
32
33/** \class REveCaloData::CellGeom_t
34\ingroup REve
35Cell geometry inner structure.
36*/
37
38////////////////////////////////////////////////////////////////////////////////
39/// Print member data.
40
42{
43 printf("%f, %f %f, %f \n", fEtaMin, fEtaMax, fPhiMin, fPhiMax);
44}
45
46////////////////////////////////////////////////////////////////////////////////
47
49{
50 fEtaMin = etaMin;
51 fEtaMax = etaMax;
52
53 fPhiMin = phiMin;
54 fPhiMax = phiMax;
55
56 // Complain if phi is out of [-2*pi, 2*pi] range.
57 if (fPhiMin < - TMath::TwoPi() || fPhiMin > TMath::TwoPi() ||
58 fPhiMax < - TMath::TwoPi() || fPhiMax > TMath::TwoPi())
59 {
60 ::Error("REveCaloData::CellGeom_t::Configure", "phiMin and phiMax should be between -2*pi and 2*pi (min=%f, max=%f). RhoZ projection will be wrong.",
61 fPhiMin, fPhiMax);
62 }
63
64 fThetaMin = EtaToTheta(fEtaMax);
65 fThetaMax = EtaToTheta(fEtaMin);
66}
67
68/** \class REveCaloData::CellData_t
69\ingroup REve
70Cell data inner structure.
71*/
72
73////////////////////////////////////////////////////////////////////////////////
74/// Return energy value associated with the cell, usually Et.
75/// If isEt is false it is transformed into energy E.
76
78{
79 if (isEt)
80 return fValue;
81 else
82 return TMath::Abs(fValue/TMath::Sin(Theta()));
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Print member data.
87
89{
90 printf("%f, %f %f, %f \n", fEtaMin, fEtaMax, fPhiMin, fPhiMax);
91}
92
93////////////////////////////////////////////////////////////////////////////////
94
96{
97 // printf("get val vec bin %d size %d\n", bin, fBinData.size());
98 if (fBinData[bin] == -1)
99 {
100 fBinData[bin] = fSliceData.size();
101
102 for (Int_t i=0; i<fNSlices; i++)
103 fSliceData.push_back(0.f);
104 }
105
106 return &fSliceData[fBinData[bin]];
107}
108
109/** \class REveCaloData
110\ingroup REve
111A central manager for calorimeter event data. It provides a list of
112cells within requested phi and eta range.
113*/
114
115
116////////////////////////////////////////////////////////////////////////////////
117
118REveCaloData::REveCaloData(const char* n, const char* t):
119 REveElement(),
120
122
123 fMaxValEt(0),
124 fMaxValE(0),
125
126 fEps(0)
127{
128 SetNameTitle(n,t);
129 // Constructor.
130}
131
133void REveCaloData::SetSelector(REveCaloDataSelector* iSelector) { fSelector.reset(iSelector); }
134
135////////////////////////////////////////////////////////////////////////////////
136/// Process newly selected cells with given select-record.
137
138void REveCaloData::ProcessSelection(vCellId_t& sel_cells, UInt_t selectionId, Bool_t multiple)
139{
140 if (fSelector)
141 {
142 fSelector->ProcessSelection(sel_cells, selectionId, multiple);
143 }
144 else
145 {
146 REveSelection* selection = dynamic_cast<REveSelection*> (ROOT::Experimental::gEve->FindElementById(selectionId));
147
148 std::set<int> secondary_idcs;
149 for (vCellId_i i = sel_cells.begin(); i != sel_cells.end(); ++i)
150 {
151 int id = (i->fSlice << 24) + i->fTower;
152 secondary_idcs.insert(id);
153 }
154 selection->NewElementPicked(GetElementId(), multiple, true, secondary_idcs);
155 }
156}
157
158////////////////////////////////////////////////////////////////////////////////
159/// Populate set impSelSet with derived / dependant elements.
160///
161
162void REveCaloData::FillImpliedSelectedSet(Set_t& impSelSet, const std::set<int>&)
163{
164 // printf("REveCaloData::FillImpliedSelectedSet\n");
165 for (auto &n : fNieces)
166 {
167 impSelSet.insert(n);
168 }
169}
170////////////////////////////////////////////////////////////////////////////////
171/// Set threshold for given slice.
172
174{
175 fSliceInfos[slice].fThreshold = val;
177}
178
179////////////////////////////////////////////////////////////////////////////////
180/// Get threshold for given slice.
181
183{
184 return fSliceInfos[slice].fThreshold;
185}
186
187////////////////////////////////////////////////////////////////////////////////
188/// Set color for given slice.
189
191{
192 fSliceInfos[slice].fColor = col;
193 for (auto &c : fNieces)
194 {
195 c->AddStamp(REveElement::kCBObjProps);
196 }
198}
199
200////////////////////////////////////////////////////////////////////////////////
201/// Get color for given slice.
202
204{
205 return fSliceInfos[slice].fColor;
206}
207
208////////////////////////////////////////////////////////////////////////////////
209/// Set transparency for given slice.
210
212{
213 fSliceInfos[slice].fTransparency = t;
214 for (auto &c : fNieces)
215 {
216 c->AddStamp(REveElement::kCBObjProps);
217 }
219}
220
221////////////////////////////////////////////////////////////////////////////////
222/// Get transparency for given slice.
223
225{
226 return fSliceInfos[slice].fTransparency;
227}
228
229////////////////////////////////////////////////////////////////////////////////
230/// Invalidate cell ids cache on back ptr references.
231
233{
234 REveCaloViz* calo;
235 for (auto &c : fNieces)
236 {
237 calo = dynamic_cast<REveCaloViz*>(c);
238 calo->InvalidateCellIdCache();
239 calo->StampObjProps();
240 }
242}
243
244////////////////////////////////////////////////////////////////////////////////
245/// Tell users (REveCaloViz instances using this data) that data
246/// has changed and they should update the limits/scales etc.
247/// This is done by calling REveCaloViz::DataChanged().
248
250{
251 REveCaloViz* calo;
252 for (auto &c : fNieces)
253 {
254 calo = dynamic_cast<REveCaloViz*>(c);
255 calo->DataChanged();
256 calo->StampObjProps();
257 }
258}
259
260
261////////////////////////////////////////////////////////////////////////////////
262
263Int_t REveCaloData::WriteCoreJson(nlohmann::json &j, Int_t rnr_offset)
264{
265 Int_t ret = REveElement::WriteCoreJson(j, rnr_offset);
266
267 auto sarr = nlohmann::json::array();
268 for (auto &s : fSliceInfos)
269 {
270 nlohmann::json slice = {};
271 slice["name"] = s.fName;
272 slice["threshold"] = s.fThreshold;
273 slice["color"] = s.fColor;
274 sarr.push_back(slice);
275 }
276 j["sliceInfos"] = sarr;
277 return ret;
278}
279////////////////////////////////////////////////////////////////////////////////
280
281void REveCaloData::FillExtraSelectionData(nlohmann::json& j, const std::set<int>& secondary_idcs) const
282{
283 vCellId_t cells;
284
285 if (fSelector)
286 {
287 fSelector->GetCellsFromSecondaryIndices(secondary_idcs, cells);
288 }
289 else
290 {
291 for (auto &id : secondary_idcs ) {
292
293 int s = (id >> 24);
294 int t = id & 0xffffff;
295 REveCaloData::CellId_t cell(t, s, 1.0f);
296 cells.push_back(cell);
297 }
298 }
299 for (auto &c : fNieces)
300 ((REveCaloViz*)c)->WriteCoreJsonSelection(j, cells);
301}
302
303////////////////////////////////////////////////////////////////////////////////
304
306{
307 using namespace TMath;
308
309 if (eta < 0)
310 return Pi() - 2*ATan(Exp(- Abs(eta)));
311 else
312 return 2*ATan(Exp(- Abs(eta)));
313}
314
315////////////////////////////////////////////////////////////////////////////////
316std::string REveCaloData::GetHighlightTooltip(const std::set<int>& secondary_idcs) const
317{
318 std::string s;
319 CellData_t cellData;
320
321 Bool_t single = secondary_idcs.size() == 1;
322 Float_t sum = 0;
323
324
325 for (auto &id : secondary_idcs ) {
326
327 int slice = (id >> 24);
328 int tower = id & 0xffffff;
329 REveCaloData::CellId_t cell(tower, slice, 1.0f);
330 GetCellData(cell, cellData);
331
332 s += TString::Format("%s %.2f (%.3f, %.3f)",
333 fSliceInfos[slice].fName.Data(), cellData.fValue,
334 cellData.Eta(), cellData.Phi());
335
336 if (single) return s;
337 s += "\n";
338 sum += cellData.fValue;
339 }
340 s += TString::Format("Sum = %.2f", sum);
341 return s;
342}
343
344/** \class REveCaloDataVec
345\ingroup REve
346Calo data for universal cell geometry.
347*/
348
349////////////////////////////////////////////////////////////////////////////////
350
352 REveCaloData(),
353
354 fTower(0),
355 fEtaMin( 1e3),
356 fEtaMax(-1e3),
357 fPhiMin( 1e3),
358 fPhiMax(-1e3)
359{
360 // Constructor.
361
362 fSliceInfos.assign(nslices, SliceInfo_t());
363
364 fSliceVec.assign(nslices, std::vector<Float_t> ());
365}
366
367////////////////////////////////////////////////////////////////////////////////
368/// Destructor.
369
371{
372}
373
374////////////////////////////////////////////////////////////////////////////////
375/// Add new slice.
376
378{
379 fSliceInfos.push_back(SliceInfo_t());
380 fSliceVec.push_back(std::vector<Float_t> ());
381 fSliceVec.back().resize(fGeomVec.size(), 0.f);
382
383 return fSliceInfos.size() - 1;
384}
385
386////////////////////////////////////////////////////////////////////////////////
387/// Add tower within eta/phi range.
388
390{
391 assert (etaMin < etaMax);
392 assert (phiMin < phiMax);
393
394 fGeomVec.push_back(CellGeom_t(etaMin, etaMax, phiMin, phiMax));
395
396 for (vvFloat_i it=fSliceVec.begin(); it!=fSliceVec.end(); ++it)
397 (*it).push_back(0);
398
399 if (etaMin < fEtaMin) fEtaMin = etaMin;
400 if (etaMax > fEtaMax) fEtaMax = etaMax;
401
402 if (phiMin < fPhiMin) fPhiMin = phiMin;
403 if (phiMax > fPhiMax) fPhiMax = phiMax;
404
405 fTower = fGeomVec.size() - 1;
406 return fTower;
407}
408
409////////////////////////////////////////////////////////////////////////////////
410/// Fill given slice in the current tower.
411
413{
414 fSliceVec[slice][fTower] = val;
415}
416
417////////////////////////////////////////////////////////////////////////////////
418/// Fill given slice in a given tower.
419
421{
422 fSliceVec[slice][tower] = val;
423}
424
425
426////////////////////////////////////////////////////////////////////////////////
427/// Get list of cell-ids for given eta/phi range.
428
430 Float_t phi, Float_t phiD,
431 REveCaloData::vCellId_t &out) const
432{
433 using namespace TMath;
434
435 Float_t etaMin = eta - etaD*0.5;
436 Float_t etaMax = eta + etaD*0.5;
437
438 Float_t phiMin = phi - phiD*0.5;
439 Float_t phiMax = phi + phiD*0.5;
440
441 Int_t nS = fSliceVec.size();
442
443 Int_t tower = 0;
444 Float_t fracx=0, fracy=0, frac;
445 Float_t minQ, maxQ;
446
447 for(vCellGeom_ci i=fGeomVec.begin(); i!=fGeomVec.end(); i++)
448 {
449 const CellGeom_t &cg = *i;
450 fracx = REveUtil::GetFraction(etaMin, etaMax, cg.fEtaMin, cg.fEtaMax);
451 if (fracx > 1e-3)
452 {
453 minQ = cg.fPhiMin;
454 maxQ = cg.fPhiMax;
455
456 if (fWrapTwoPi)
457 {
458 if (maxQ < phiMin)
459 {
460 minQ += TwoPi(); maxQ += TwoPi();
461 }
462 else if (minQ > phiMax)
463 {
464 minQ -= TwoPi(); maxQ -= TwoPi();
465 }
466 }
467
468 if (maxQ >= phiMin && minQ <= phiMax)
469 {
470 fracy = REveUtil::GetFraction(phiMin, phiMax, minQ, maxQ);
471 if (fracy > 1e-3)
472 {
473 frac = fracx*fracy;
474 for (Int_t s=0; s<nS; s++)
475 {
476 if (fSliceVec[s][tower] > fSliceInfos[s].fThreshold)
477 out.push_back(CellId_t(tower, s, frac));
478 }
479 }
480 }
481 }
482 tower++;
483 }
484}
485
486////////////////////////////////////////////////////////////////////////////////
487/// Rebin cells.
488
489void REveCaloDataVec::Rebin(TAxis* ax, TAxis* ay, vCellId_t &ids, Bool_t et, RebinData_t& rdata) const
490{
491 rdata.fNSlices = GetNSlices();
492 rdata.fBinData.assign((ax->GetNbins()+2)*(ay->GetNbins()+2), -1);
493
494 CellData_t cd;
495 for (vCellId_i it = ids.begin(); it != ids.end(); ++it)
496 {
497 GetCellData(*it, cd);
498 Int_t iMin = ax->FindBin(cd.EtaMin());
499 Int_t iMax = ax->FindBin(cd.EtaMax());
500 Int_t jMin = ay->FindBin(cd.PhiMin());
501 Int_t jMax = ay->FindBin(cd.PhiMax());
502 for (Int_t i = iMin; i <= iMax; ++i)
503 {
504 if (i < 0 || i > ax->GetNbins()) continue;
505 for (Int_t j = jMin; j <= jMax; ++j)
506 {
507 if (j < 0 || j > ay->GetNbins()) continue;
508
509 Double_t ratio = REveUtil::GetFraction(ax->GetBinLowEdge(i), ax->GetBinUpEdge(i), cd.EtaMin(), cd.EtaMax())
510 * REveUtil::GetFraction(ay->GetBinLowEdge(j), ay->GetBinUpEdge(j), cd.PhiMin(), cd.PhiMax());
511
512 if (ratio > 1e-6f)
513 {
514 Float_t* slices = rdata.GetSliceVals(i + j*(ax->GetNbins()+2));
515 slices[(*it).fSlice] += ratio * cd.Value(et);
516 }
517 }
518 }
519 }
520}
521
522////////////////////////////////////////////////////////////////////////////////
523/// Get cell geometry and value from cell ID.
524
526 REveCaloData::CellData_t& cellData) const
527{
528 cellData.CellGeom_t::operator=( fGeomVec[id.fTower] );
529 cellData.fValue = fSliceVec[id.fSlice][id.fTower];
530}
531
532////////////////////////////////////////////////////////////////////////////////
533/// Update limits and notify data users.
534
536{
537 using namespace TMath;
538
539 // update max E/Et values
540
541 fMaxValE = 0;
542 fMaxValEt = 0;
543 Float_t sum=0;
544 // printf("geom vec %d slices %d\n",fGeomVec.size(), fSliceVec.size() );
545
546 for (UInt_t tw=0; tw<fGeomVec.size(); tw++)
547 {
548 sum=0;
549 for (vvFloat_i it=fSliceVec.begin(); it!=fSliceVec.end(); ++it)
550 sum += (*it)[tw];
551
552 if (sum > fMaxValEt ) fMaxValEt=sum;
553
554 sum /= Abs(Sin(EtaToTheta(fGeomVec[tw].Eta())));
555
556 if (sum > fMaxValE) fMaxValE=sum;
557 }
558
560}
561
562
563////////////////////////////////////////////////////////////////////////////////
564/// Set XY axis from cells geometry.
565
567{
568 std::vector<Double_t> binX;
569 std::vector<Double_t> binY;
570
571 for(vCellGeom_ci i=fGeomVec.begin(); i!=fGeomVec.end(); i++)
572 {
573 const CellGeom_t &ch = *i;
574
575 binX.push_back(ch.EtaMin());
576 binX.push_back(ch.EtaMax());
577 binY.push_back(ch.PhiMin());
578 binY.push_back(ch.PhiMax());
579 }
580
581 std::sort(binX.begin(), binX.end());
582 std::sort(binY.begin(), binY.end());
583
584 Int_t cnt = 0;
585 Double_t sum = 0;
586 Double_t val;
587
588 // X axis
589 Double_t dx = binX.back() - binX.front();
590 epsX *= dx;
591 std::vector<Double_t> newX;
592 newX.push_back(binX.front()); // underflow
593 Int_t nX = binX.size()-1;
594 for(Int_t i=0; i<nX; i++)
595 {
596 val = (sum +binX[i])/(cnt+1);
597 if (binX[i+1] -val > epsX)
598 {
599 newX.push_back(val);
600 cnt = 0;
601 sum = 0;
602 }
603 else
604 {
605 sum += binX[i];
606 cnt++;
607 }
608 }
609 newX.push_back(binX.back()); // overflow
610
611 // Y axis
612 cnt = 0;
613 sum = 0;
614 std::vector<Double_t> newY;
615 Double_t dy = binY.back() - binY.front();
616 epsY *= dy;
617 newY.push_back(binY.front());// underflow
618 Int_t nY = binY.size()-1;
619 for(Int_t i=0 ; i<nY; i++)
620 {
621 val = (sum +binY[i])/(cnt+1);
622 if (binY[i+1] -val > epsY )
623 {
624 newY.push_back(val);
625 cnt = 0;
626 sum = 0;
627 }
628 else
629 {
630 sum += binY[i];
631 cnt++;
632 }
633
634 }
635 newY.push_back(binY.back()); // overflow
636 fEtaAxis = std::make_unique<TAxis>(newX.size()-1, &newX[0]);
637 fEtaAxis = std::make_unique<TAxis>(newY.size()-1, &newY[0]);
638 fEtaAxis->SetNdivisions(510);
639 fPhiAxis->SetNdivisions(510);
640}
641
642/** \class REveCaloDataHist
643\ingroup REve
644A central manager for calorimeter data of an event written in TH2F.
645X axis is used for eta and Y axis for phi.
646*/
647
648
649////////////////////////////////////////////////////////////////////////////////
650/// Constructor.
651
653 REveCaloData(),
654
655 fHStack(nullptr)
656{
657 fHStack = new THStack();
658 fEps = 1e-5;
659}
660
661////////////////////////////////////////////////////////////////////////////////
662/// Destructor.
663
665{
666 delete fHStack;
667}
668
669////////////////////////////////////////////////////////////////////////////////
670/// Update limits and notify data users.
671
673{
674 using namespace TMath;
675
676 // update max E/Et values
677 fMaxValE = 0;
678 fMaxValEt = 0;
679
680 if (GetNSlices() < 1) return;
681
682 TH2* hist = GetHist(0);
683 for (Int_t ieta = 1; ieta <= fEtaAxis->GetNbins(); ++ieta)
684 {
685 Double_t eta = fEtaAxis->GetBinCenter(ieta); // conversion E/Et
686 for (Int_t iphi = 1; iphi <= fPhiAxis->GetNbins(); ++iphi)
687 {
688 Double_t value = 0;
689 for (Int_t i = 0; i < GetNSlices(); ++i)
690 {
691 hist = GetHist(i);
692 Int_t bin = hist->GetBin(ieta, iphi);
693 value += hist->GetBinContent(bin);
694 }
695
696 if (value > fMaxValEt ) fMaxValEt = value;
697
698 value /= Abs(Sin(EtaToTheta(eta)));
699
700 if (value > fMaxValE) fMaxValE = value;
701 }
702 }
704}
705
706////////////////////////////////////////////////////////////////////////////////
707/// Get list of cell IDs in given eta and phi range.
708
710 Float_t phi, Float_t phiD,
711 REveCaloData::vCellId_t &out) const
712{
713 using namespace TMath;
714
715 Float_t etaMin = eta - etaD*0.5 -fEps;
716 Float_t etaMax = eta + etaD*0.5 +fEps;
717
718 Float_t phiMin = phi - phiD*0.5 -fEps;
719 Float_t phiMax = phi + phiD*0.5 +fEps;
720
721 Int_t nEta = fEtaAxis->GetNbins();
722 Int_t nPhi = fPhiAxis->GetNbins();
723 Int_t nSlices = GetNSlices();
724
725 Int_t bin = 0;
726
727 Bool_t accept;
728 for (Int_t ieta = 1; ieta <= nEta; ++ieta)
729 {
730 if (fEtaAxis->GetBinLowEdge(ieta) >= etaMin && fEtaAxis->GetBinUpEdge(ieta) <= etaMax)
731 {
732 for (Int_t iphi = 1; iphi <= nPhi; ++iphi)
733 {
734 if (fWrapTwoPi )
735 {
737 (phiMin, phiMax, fPhiAxis->GetBinLowEdge(iphi), fPhiAxis->GetBinUpEdge(iphi));
738 }
739 else
740 {
741 accept = fPhiAxis->GetBinLowEdge(iphi) >= phiMin && fPhiAxis->GetBinUpEdge(iphi) <= phiMax &&
742 fPhiAxis->GetBinLowEdge(iphi) >= phiMin && fPhiAxis->GetBinUpEdge(iphi) <= phiMax;
743 }
744
745 if (accept)
746 {
747 for (Int_t s = 0; s < nSlices; ++s)
748 {
749 TH2F *hist = GetHist(s);
750 bin = hist->GetBin(ieta, iphi);
751 if (hist->GetBinContent(bin) > fSliceInfos[s].fThreshold)
752 out.push_back(REveCaloData::CellId_t(bin, s));
753 } // hist slices
754 }
755 } // phi bins
756 }
757 } // eta bins
758}
759
760////////////////////////////////////////////////////////////////////////////////
761/// Rebin
762
764{
765 rdata.fNSlices = GetNSlices();
766 rdata.fBinData.assign((ax->GetNbins()+2)*(ay->GetNbins()+2), -1);
768 Float_t *val;
769 Int_t i, j, w;
770 Int_t binx, biny;
771 Int_t bin;
772
773 for (vCellId_i it=ids.begin(); it!=ids.end(); ++it)
774 {
775 GetCellData(*it, cd);
776 GetHist(it->fSlice)->GetBinXYZ((*it).fTower, i, j, w);
777 binx = ax->FindBin(fEtaAxis->GetBinCenter(i));
778 biny = ay->FindBin(fPhiAxis->GetBinCenter(j));
779 bin = biny*(ax->GetNbins()+2)+binx;
780 val = rdata.GetSliceVals(bin);
781 Double_t ratio = REveUtil::GetFraction(ax->GetBinLowEdge(binx), ax->GetBinUpEdge(binx), cd.EtaMin(), cd.EtaMax())
782 * REveUtil::GetFraction(ay->GetBinLowEdge(biny), ay->GetBinUpEdge(biny), cd.PhiMin(), cd.PhiMax());
783
784 val[(*it).fSlice] += cd.Value(et)*ratio;
785 }
786}
787
788////////////////////////////////////////////////////////////////////////////////
789/// Get cell geometry and value from cell ID.
790
792 REveCaloData::CellData_t& cellData) const
793{
794 TH2F* hist = GetHist(id.fSlice);
795
796 Int_t x, y, z;
797 hist->GetBinXYZ(id.fTower, x, y, z);
798
799 cellData.fValue = hist->GetBinContent(id.fTower);
800 cellData.Configure(hist->GetXaxis()->GetBinLowEdge(x),
801 hist->GetXaxis()->GetBinUpEdge(x),
802 hist->GetYaxis()->GetBinLowEdge(y),
803 hist->GetYaxis()->GetBinUpEdge(y));
804}
805
806////////////////////////////////////////////////////////////////////////////////
807/// Add new slice to calo tower. Updates cached variables fMaxValE
808/// and fMaxValEt
809/// Return last index in the vector of slice infos.
810
812{
813 if (!fEtaAxis) {
814 fEtaAxis = std::make_unique<TAxis>(*hist->GetXaxis());
815 fPhiAxis = std::make_unique<TAxis>(*hist->GetYaxis());
816 }
817 fHStack->Add(hist);
818 fSliceInfos.push_back(SliceInfo_t());
819 fSliceInfos.back().fName = hist->GetName();
820 fSliceInfos.back().fColor = hist->GetLineColor();
821
822 DataChanged();
823
824 return fSliceInfos.size() - 1;
825}
826
827////////////////////////////////////////////////////////////////////////////////
828/// Get histogram in given slice.
829
831{
832 assert(slice >= 0 && slice < fHStack->GetHists()->GetSize());
833 return (TH2F*) fHStack->GetHists()->At(slice);
834}
835
836////////////////////////////////////////////////////////////////////////////////
837/// Get eta limits.
838
840{
841 min = fEtaAxis->GetXmin();
842 max = fEtaAxis->GetXmax();
843}
844
845////////////////////////////////////////////////////////////////////////////////
846/// Get phi limits.
847
849{
850 min = fPhiAxis->GetXmin();
851 max = fPhiAxis->GetXmax();
852}
853
854////////////////////////////////////////////////////////////////////////////////
855/// Process selection. Called from REveCaloViz object
856
858{
859 // only one slice can be user selected at once
860 fActiveSlice = sel_cells.front().fSlice;
861 for (auto &si : fSliceSelectors)
862 {
863 if (si->GetSliceIndex() == fActiveSlice) {
864 si->ProcessSelection(sel_cells, selectionId, multi);
865 break;
866 }
867 }
868}
869
870////////////////////////////////////////////////////////////////////////////////
871/// GetCellsFromSecondaryIndices used in implied selection
872
874{
875 for (auto &si : fSliceSelectors)
876 {
877 if (si->GetSliceIndex() == fActiveSlice) {
878 si->GetCellsFromSecondaryIndices(idcs, out);
879 break;
880 }
881 }
882}
#define c(i)
Definition RSha256.hxx:101
#define e(i)
Definition RSha256.hxx:103
short Color_t
Definition RtypesCore.h:85
char Char_t
Definition RtypesCore.h:37
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Int_t AddHistogram(TH2F *hist)
Add new slice to calo tower.
~REveCaloDataHist() override
Destructor.
void DataChanged() override
Update limits and notify data users.
TH2F * GetHist(Int_t slice) const
Get histogram in given slice.
void GetEtaLimits(Double_t &min, Double_t &max) const override
Get eta limits.
void GetCellData(const REveCaloData::CellId_t &id, REveCaloData::CellData_t &data) const override
Get cell geometry and value from cell ID.
void GetPhiLimits(Double_t &min, Double_t &max) const override
Get phi limits.
void GetCellList(Float_t etaMin, Float_t etaMax, Float_t phi, Float_t phiRng, vCellId_t &out) const override
Get list of cell IDs in given eta and phi range.
void Rebin(TAxis *ax, TAxis *ay, vCellId_t &in, Bool_t et, RebinData_t &out) const override
Rebin.
void GetCellsFromSecondaryIndices(const std::set< int > &, REveCaloData::vCellId_t &out)
GetCellsFromSecondaryIndices used in implied selection.
void ProcessSelection(REveCaloData::vCellId_t &sel_cells, UInt_t selectionId, Bool_t multi)
Process selection. Called from REveCaloViz object.
std::vector< std::unique_ptr< REveCaloDataSliceSelector > > fSliceSelectors
void GetCellData(const REveCaloData::CellId_t &id, REveCaloData::CellData_t &data) const override
Get cell geometry and value from cell ID.
void Rebin(TAxis *ax, TAxis *ay, vCellId_t &in, Bool_t et, RebinData_t &out) const override
Rebin cells.
void GetCellList(Float_t etaMin, Float_t etaMax, Float_t phi, Float_t phiRng, vCellId_t &out) const override
Get list of cell-ids for given eta/phi range.
Int_t AddTower(Float_t etaMin, Float_t etaMax, Float_t phiMin, Float_t phiMax)
Add tower within eta/phi range.
void SetAxisFromBins(Double_t epsX=0.001, Double_t epsY=0.001)
Set XY axis from cells geometry.
std::vector< vFloat_t >::iterator vvFloat_i
~REveCaloDataVec() override
Destructor.
void DataChanged() override
Update limits and notify data users.
void FillSlice(Int_t slice, Float_t value)
Fill given slice in the current tower.
Color_t GetSliceColor(Int_t slice) const
Get color for given slice.
Char_t GetSliceTransparency(Int_t slice) const
Get transparency for given slice.
std::vector< CellId_t >::iterator vCellId_i
void SetSliceThreshold(Int_t slice, Float_t threshold)
Set threshold for given slice.
virtual void GetCellData(const CellId_t &id, CellData_t &data) const =0
std::vector< CellGeom_t >::const_iterator vCellGeom_ci
void SetSliceTransparency(Int_t slice, Char_t t)
Set transparency for given slice.
static Float_t EtaToTheta(Float_t eta)
std::unique_ptr< REveCaloDataSelector > fSelector
REveCaloData(const char *n="REveCaloData", const char *t="")
std::unique_ptr< TAxis > fEtaAxis
void FillExtraSelectionData(nlohmann::json &, const std::set< int > &) const override
std::string GetHighlightTooltip(const std::set< int > &secondary_idcs) const override
virtual void DataChanged()
Tell users (REveCaloViz instances using this data) that data has changed and they should update the l...
std::unique_ptr< TAxis > fPhiAxis
void SetSelector(REveCaloDataSelector *iSelector)
void ProcessSelection(vCellId_t &sel_cells, UInt_t selectionId, Bool_t multi)
Process newly selected cells with given select-record.
Float_t GetSliceThreshold(Int_t slice) const
Get threshold for given slice.
virtual void InvalidateUsersCellIdCache()
Invalidate cell ids cache on back ptr references.
std::vector< CellId_t > vCellId_t
void SetSliceColor(Int_t slice, Color_t col)
Set color for given slice.
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Write core json.
void FillImpliedSelectedSet(Set_t &impSelSet, const std::set< int > &sec_idcs) override
Populate set impSelSet with derived / dependant elements.
void DataChanged()
Update setting and cache on data changed.
Definition REveCalo.cxx:257
void SetNameTitle(const std::string &name, const std::string &title)
Set name and title of an element.
virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset)
Write core json.
virtual void AddStamp(UChar_t bits)
Add (bitwise or) given stamps to fChangeBits.
std::set< REveElement * > Set_t
ElementId_t GetElementId() const
REveElement * FindElementById(ElementId_t id) const
Lookup ElementId in element map and return corresponding REveElement*.
REveSelection Container for selected and highlighted elements.
void NewElementPicked(ElementId_t id, bool multi, bool secondary, const std::set< int > &secondary_idcs={})
Called from GUI when user picks or un-picks an element.
static Float_t GetFraction(Float_t minM, Float_t maxM, Float_t minQ, Float_t maxQ)
Get fraction of interval [minQ, maxQ] in [minM, maxM].
Definition REveUtil.cxx:332
static Bool_t IsU1IntervalContainedByMinMax(Float_t minM, Float_t maxM, Float_t minQ, Float_t maxQ)
Return true if interval Q is contained within interval M for U1 variables.
Definition REveUtil.cxx:292
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:35
Class to manage histogram axis.
Definition TAxis.h:32
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
Definition TAxis.cxx:288
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition TAxis.cxx:513
Int_t GetNbins() const
Definition TAxis.h:127
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition TAxis.cxx:523
TAxis * GetXaxis()
Definition TH1.h:336
virtual void GetBinXYZ(Int_t binglobal, Int_t &binx, Int_t &biny, Int_t &binz) const
Return binx, biny, binz corresponding to the global bin number globalbin see TH1::GetBin function abo...
Definition TH1.cxx:4990
TAxis * GetYaxis()
Definition TH1.h:337
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:308
Service class for 2-D histogram classes.
Definition TH2.h:30
Int_t GetBin(Int_t binx, Int_t biny, Int_t binz=0) const override
Return Global bin number corresponding to binx,y,z.
Definition TH2.cxx:1083
Double_t GetBinContent(Int_t binx, Int_t biny) const override
Definition TH2.h:94
The Histogram stack class.
Definition THStack.h:40
TList * GetHists() const
Definition THStack.h:72
virtual void Add(TH1 *h, Option_t *option="")
Add a new histogram to the list.
Definition THStack.cxx:365
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:355
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
const char * GetHist()
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
R__EXTERN REveManager * gEve
TMath.
Definition TMathBase.h:35
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:592
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123
constexpr Double_t TwoPi()
Definition TMath.h:44
void Dump() const override
Print member data.
Float_t Value(Bool_t) const
Return energy value associated with the cell, usually Et.
void Configure(Float_t etaMin, Float_t etaMax, Float_t phiMin, Float_t phiMax)
virtual void Dump() const
Print member data.
static uint64_t sum(uint64_t i)
Definition Factory.cxx:2345