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
132////////////////////////////////////////////////////////////////////////////////
133/// Process newly selected cells with given select-record.
134
135void REveCaloData::ProcessSelection(vCellId_t& sel_cells, UInt_t selectionId, Bool_t multiple)
136{
137 if (fSelector)
138 {
139 fSelector->ProcessSelection(sel_cells, selectionId, multiple);
140 }
141 else
142 {
143 REveSelection* selection = dynamic_cast<REveSelection*> (ROOT::Experimental::gEve->FindElementById(selectionId));
144
145 std::set<int> secondary_idcs;
146 for (vCellId_i i = sel_cells.begin(); i != sel_cells.end(); ++i)
147 {
148 int id = (i->fSlice << 24) + i->fTower;
149 secondary_idcs.insert(id);
150 }
151 selection->NewElementPicked(GetElementId(), multiple, true, secondary_idcs);
152 }
153}
154
155////////////////////////////////////////////////////////////////////////////////
156/// Populate set impSelSet with derived / dependant elements.
157///
158
159void REveCaloData::FillImpliedSelectedSet(Set_t& impSelSet, const std::set<int>&)
160{
161 // printf("REveCaloData::FillImpliedSelectedSet\n");
162 for (auto &n : fNieces)
163 {
164 impSelSet.insert(n);
165 }
166}
167////////////////////////////////////////////////////////////////////////////////
168/// Set threshold for given slice.
169
171{
172 fSliceInfos[slice].fThreshold = val;
174}
175
176////////////////////////////////////////////////////////////////////////////////
177/// Get threshold for given slice.
178
180{
181 return fSliceInfos[slice].fThreshold;
182}
183
184////////////////////////////////////////////////////////////////////////////////
185/// Set color for given slice.
186
188{
189 fSliceInfos[slice].fColor = col;
190 for (auto &c : fNieces)
191 {
192 c->AddStamp(REveElement::kCBObjProps);
193 }
195}
196
197////////////////////////////////////////////////////////////////////////////////
198/// Get color for given slice.
199
201{
202 return fSliceInfos[slice].fColor;
203}
204
205////////////////////////////////////////////////////////////////////////////////
206/// Set transparency for given slice.
207
209{
210 fSliceInfos[slice].fTransparency = t;
211 for (auto &c : fNieces)
212 {
213 c->AddStamp(REveElement::kCBObjProps);
214 }
216}
217
218////////////////////////////////////////////////////////////////////////////////
219/// Get transparency for given slice.
220
222{
223 return fSliceInfos[slice].fTransparency;
224}
225
226////////////////////////////////////////////////////////////////////////////////
227/// Invalidate cell ids cache on back ptr references.
228
230{
231 REveCaloViz* calo;
232 for (auto &c : fNieces)
233 {
234 calo = dynamic_cast<REveCaloViz*>(c);
235 calo->InvalidateCellIdCache();
236 calo->StampObjProps();
237 }
239}
240
241////////////////////////////////////////////////////////////////////////////////
242/// Tell users (REveCaloViz instances using this data) that data
243/// has changed and they should update the limits/scales etc.
244/// This is done by calling REveCaloViz::DataChanged().
245
247{
248 REveCaloViz* calo;
249 for (auto &c : fNieces)
250 {
251 calo = dynamic_cast<REveCaloViz*>(c);
252 calo->DataChanged();
253 calo->StampObjProps();
254 }
255}
256
257
258////////////////////////////////////////////////////////////////////////////////
259
260Int_t REveCaloData::WriteCoreJson(nlohmann::json &j, Int_t rnr_offset)
261{
262 Int_t ret = REveElement::WriteCoreJson(j, rnr_offset);
263
264 auto sarr = nlohmann::json::array();
265 for (auto &s : fSliceInfos)
266 {
267 nlohmann::json slice = {};
268 slice["name"] = s.fName;
269 slice["threshold"] = s.fThreshold;
270 slice["color"] = s.fColor;
271 sarr.push_back(slice);
272 }
273 j["sliceInfos"] = sarr;
274 return ret;
275}
276////////////////////////////////////////////////////////////////////////////////
277
278void REveCaloData::FillExtraSelectionData(nlohmann::json& j, const std::set<int>& secondary_idcs) const
279{
280 vCellId_t cells;
281
282 if (fSelector)
283 {
284 fSelector->GetCellsFromSecondaryIndices(secondary_idcs, cells);
285 }
286 else
287 {
288 for (auto &id : secondary_idcs ) {
289
290 int s = (id >> 24);
291 int t = id & 0xffffff;
292 REveCaloData::CellId_t cell(t, s, 1.0f);
293 cells.push_back(cell);
294 }
295 }
296 for (auto &c : fNieces)
297 ((REveCaloViz*)c)->WriteCoreJsonSelection(j, cells);
298}
299
300////////////////////////////////////////////////////////////////////////////////
301
303{
304 using namespace TMath;
305
306 if (eta < 0)
307 return Pi() - 2*ATan(Exp(- Abs(eta)));
308 else
309 return 2*ATan(Exp(- Abs(eta)));
310}
311
312////////////////////////////////////////////////////////////////////////////////
313std::string REveCaloData::GetHighlightTooltip(const std::set<int>& secondary_idcs) const
314{
315 std::string s;
316 CellData_t cellData;
317
318 Bool_t single = secondary_idcs.size() == 1;
319 Float_t sum = 0;
320
321
322 for (auto &id : secondary_idcs ) {
323
324 int slice = (id >> 24);
325 int tower = id & 0xffffff;
326 REveCaloData::CellId_t cell(tower, slice, 1.0f);
327 GetCellData(cell, cellData);
328
329 s += TString::Format("%s %.2f (%.3f, %.3f)",
330 fSliceInfos[slice].fName.Data(), cellData.fValue,
331 cellData.Eta(), cellData.Phi());
332
333 if (single) return s;
334 s += "\n";
335 sum += cellData.fValue;
336 }
337 s += TString::Format("Sum = %.2f", sum);
338 return s;
339}
340
341/** \class REveCaloDataVec
342\ingroup REve
343Calo data for universal cell geometry.
344*/
345
346////////////////////////////////////////////////////////////////////////////////
347
349 REveCaloData(),
350
351 fTower(0),
352 fEtaMin( 1e3),
353 fEtaMax(-1e3),
354 fPhiMin( 1e3),
355 fPhiMax(-1e3)
356{
357 // Constructor.
358
359 fSliceInfos.assign(nslices, SliceInfo_t());
360
361 fSliceVec.assign(nslices, std::vector<Float_t> ());
362}
363
364////////////////////////////////////////////////////////////////////////////////
365/// Destructor.
366
368{
369}
370
371////////////////////////////////////////////////////////////////////////////////
372/// Add new slice.
373
375{
376 fSliceInfos.push_back(SliceInfo_t());
377 fSliceVec.push_back(std::vector<Float_t> ());
378 fSliceVec.back().resize(fGeomVec.size(), 0.f);
379
380 return fSliceInfos.size() - 1;
381}
382
383////////////////////////////////////////////////////////////////////////////////
384/// Add tower within eta/phi range.
385
387{
388 assert (etaMin < etaMax);
389 assert (phiMin < phiMax);
390
391 fGeomVec.push_back(CellGeom_t(etaMin, etaMax, phiMin, phiMax));
392
393 for (vvFloat_i it=fSliceVec.begin(); it!=fSliceVec.end(); ++it)
394 (*it).push_back(0);
395
396 if (etaMin < fEtaMin) fEtaMin = etaMin;
397 if (etaMax > fEtaMax) fEtaMax = etaMax;
398
399 if (phiMin < fPhiMin) fPhiMin = phiMin;
400 if (phiMax > fPhiMax) fPhiMax = phiMax;
401
402 fTower = fGeomVec.size() - 1;
403 return fTower;
404}
405
406////////////////////////////////////////////////////////////////////////////////
407/// Fill given slice in the current tower.
408
410{
411 fSliceVec[slice][fTower] = val;
412}
413
414////////////////////////////////////////////////////////////////////////////////
415/// Fill given slice in a given tower.
416
418{
419 fSliceVec[slice][tower] = val;
420}
421
422
423////////////////////////////////////////////////////////////////////////////////
424/// Get list of cell-ids for given eta/phi range.
425
427 Float_t phi, Float_t phiD,
428 REveCaloData::vCellId_t &out) const
429{
430 using namespace TMath;
431
432 Float_t etaMin = eta - etaD*0.5;
433 Float_t etaMax = eta + etaD*0.5;
434
435 Float_t phiMin = phi - phiD*0.5;
436 Float_t phiMax = phi + phiD*0.5;
437
438 Int_t nS = fSliceVec.size();
439
440 Int_t tower = 0;
441 Float_t fracx=0, fracy=0, frac;
442 Float_t minQ, maxQ;
443
444 for(vCellGeom_ci i=fGeomVec.begin(); i!=fGeomVec.end(); i++)
445 {
446 const CellGeom_t &cg = *i;
447 fracx = REveUtil::GetFraction(etaMin, etaMax, cg.fEtaMin, cg.fEtaMax);
448 if (fracx > 1e-3)
449 {
450 minQ = cg.fPhiMin;
451 maxQ = cg.fPhiMax;
452
453 if (fWrapTwoPi)
454 {
455 if (maxQ < phiMin)
456 {
457 minQ += TwoPi(); maxQ += TwoPi();
458 }
459 else if (minQ > phiMax)
460 {
461 minQ -= TwoPi(); maxQ -= TwoPi();
462 }
463 }
464
465 if (maxQ >= phiMin && minQ <= phiMax)
466 {
467 fracy = REveUtil::GetFraction(phiMin, phiMax, minQ, maxQ);
468 if (fracy > 1e-3)
469 {
470 frac = fracx*fracy;
471 for (Int_t s=0; s<nS; s++)
472 {
473 if (fSliceVec[s][tower] > fSliceInfos[s].fThreshold)
474 out.push_back(CellId_t(tower, s, frac));
475 }
476 }
477 }
478 }
479 tower++;
480 }
481}
482
483////////////////////////////////////////////////////////////////////////////////
484/// Rebin cells.
485
486void REveCaloDataVec::Rebin(TAxis* ax, TAxis* ay, vCellId_t &ids, Bool_t et, RebinData_t& rdata) const
487{
488 rdata.fNSlices = GetNSlices();
489 rdata.fBinData.assign((ax->GetNbins()+2)*(ay->GetNbins()+2), -1);
490
491 CellData_t cd;
492 for (vCellId_i it = ids.begin(); it != ids.end(); ++it)
493 {
494 GetCellData(*it, cd);
495 Int_t iMin = ax->FindBin(cd.EtaMin());
496 Int_t iMax = ax->FindBin(cd.EtaMax());
497 Int_t jMin = ay->FindBin(cd.PhiMin());
498 Int_t jMax = ay->FindBin(cd.PhiMax());
499 for (Int_t i = iMin; i <= iMax; ++i)
500 {
501 if (i < 0 || i > ax->GetNbins()) continue;
502 for (Int_t j = jMin; j <= jMax; ++j)
503 {
504 if (j < 0 || j > ay->GetNbins()) continue;
505
506 Double_t ratio = REveUtil::GetFraction(ax->GetBinLowEdge(i), ax->GetBinUpEdge(i), cd.EtaMin(), cd.EtaMax())
507 * REveUtil::GetFraction(ay->GetBinLowEdge(j), ay->GetBinUpEdge(j), cd.PhiMin(), cd.PhiMax());
508
509 if (ratio > 1e-6f)
510 {
511 Float_t* slices = rdata.GetSliceVals(i + j*(ax->GetNbins()+2));
512 slices[(*it).fSlice] += ratio * cd.Value(et);
513 }
514 }
515 }
516 }
517}
518
519////////////////////////////////////////////////////////////////////////////////
520/// Get cell geometry and value from cell ID.
521
523 REveCaloData::CellData_t& cellData) const
524{
525 cellData.CellGeom_t::operator=( fGeomVec[id.fTower] );
526 cellData.fValue = fSliceVec[id.fSlice][id.fTower];
527}
528
529////////////////////////////////////////////////////////////////////////////////
530/// Update limits and notify data users.
531
533{
534 using namespace TMath;
535
536 // update max E/Et values
537
538 fMaxValE = 0;
539 fMaxValEt = 0;
540 Float_t sum=0;
541 // printf("geom vec %d slices %d\n",fGeomVec.size(), fSliceVec.size() );
542
543 for (UInt_t tw=0; tw<fGeomVec.size(); tw++)
544 {
545 sum=0;
546 for (vvFloat_i it=fSliceVec.begin(); it!=fSliceVec.end(); ++it)
547 sum += (*it)[tw];
548
549 if (sum > fMaxValEt ) fMaxValEt=sum;
550
551 sum /= Abs(Sin(EtaToTheta(fGeomVec[tw].Eta())));
552
553 if (sum > fMaxValE) fMaxValE=sum;
554 }
555
557}
558
559
560////////////////////////////////////////////////////////////////////////////////
561/// Set XY axis from cells geometry.
562
564{
565 std::vector<Double_t> binX;
566 std::vector<Double_t> binY;
567
568 for(vCellGeom_ci i=fGeomVec.begin(); i!=fGeomVec.end(); i++)
569 {
570 const CellGeom_t &ch = *i;
571
572 binX.push_back(ch.EtaMin());
573 binX.push_back(ch.EtaMax());
574 binY.push_back(ch.PhiMin());
575 binY.push_back(ch.PhiMax());
576 }
577
578 std::sort(binX.begin(), binX.end());
579 std::sort(binY.begin(), binY.end());
580
581 Int_t cnt = 0;
582 Double_t sum = 0;
583 Double_t val;
584
585 // X axis
586 Double_t dx = binX.back() - binX.front();
587 epsX *= dx;
588 std::vector<Double_t> newX;
589 newX.push_back(binX.front()); // underflow
590 Int_t nX = binX.size()-1;
591 for(Int_t i=0; i<nX; i++)
592 {
593 val = (sum +binX[i])/(cnt+1);
594 if (binX[i+1] -val > epsX)
595 {
596 newX.push_back(val);
597 cnt = 0;
598 sum = 0;
599 }
600 else
601 {
602 sum += binX[i];
603 cnt++;
604 }
605 }
606 newX.push_back(binX.back()); // overflow
607
608 // Y axis
609 cnt = 0;
610 sum = 0;
611 std::vector<Double_t> newY;
612 Double_t dy = binY.back() - binY.front();
613 epsY *= dy;
614 newY.push_back(binY.front());// underflow
615 Int_t nY = binY.size()-1;
616 for(Int_t i=0 ; i<nY; i++)
617 {
618 val = (sum +binY[i])/(cnt+1);
619 if (binY[i+1] -val > epsY )
620 {
621 newY.push_back(val);
622 cnt = 0;
623 sum = 0;
624 }
625 else
626 {
627 sum += binY[i];
628 cnt++;
629 }
630
631 }
632 newY.push_back(binY.back()); // overflow
633 fEtaAxis = std::make_unique<TAxis>(newX.size()-1, &newX[0]);
634 fEtaAxis = std::make_unique<TAxis>(newY.size()-1, &newY[0]);
635 fEtaAxis->SetNdivisions(510);
636 fPhiAxis->SetNdivisions(510);
637}
638
639/** \class REveCaloDataHist
640\ingroup REve
641A central manager for calorimeter data of an event written in TH2F.
642X axis is used for eta and Y axis for phi.
643*/
644
645
646////////////////////////////////////////////////////////////////////////////////
647/// Constructor.
648
650 REveCaloData(),
651
652 fHStack(nullptr)
653{
654 fHStack = new THStack();
655 fEps = 1e-5;
656}
657
658////////////////////////////////////////////////////////////////////////////////
659/// Destructor.
660
662{
663 delete fHStack;
664}
665
666////////////////////////////////////////////////////////////////////////////////
667/// Update limits and notify data users.
668
670{
671 using namespace TMath;
672
673 // update max E/Et values
674 fMaxValE = 0;
675 fMaxValEt = 0;
676
677 if (GetNSlices() < 1) return;
678
679 TH2* hist = GetHist(0);
680 for (Int_t ieta = 1; ieta <= fEtaAxis->GetNbins(); ++ieta)
681 {
682 Double_t eta = fEtaAxis->GetBinCenter(ieta); // conversion E/Et
683 for (Int_t iphi = 1; iphi <= fPhiAxis->GetNbins(); ++iphi)
684 {
685 Double_t value = 0;
686 for (Int_t i = 0; i < GetNSlices(); ++i)
687 {
688 hist = GetHist(i);
689 Int_t bin = hist->GetBin(ieta, iphi);
690 value += hist->GetBinContent(bin);
691 }
692
693 if (value > fMaxValEt ) fMaxValEt = value;
694
695 value /= Abs(Sin(EtaToTheta(eta)));
696
697 if (value > fMaxValE) fMaxValE = value;
698 }
699 }
701}
702
703////////////////////////////////////////////////////////////////////////////////
704/// Get list of cell IDs in given eta and phi range.
705
707 Float_t phi, Float_t phiD,
708 REveCaloData::vCellId_t &out) const
709{
710 using namespace TMath;
711
712 Float_t etaMin = eta - etaD*0.5 -fEps;
713 Float_t etaMax = eta + etaD*0.5 +fEps;
714
715 Float_t phiMin = phi - phiD*0.5 -fEps;
716 Float_t phiMax = phi + phiD*0.5 +fEps;
717
718 Int_t nEta = fEtaAxis->GetNbins();
719 Int_t nPhi = fPhiAxis->GetNbins();
720 Int_t nSlices = GetNSlices();
721
722 Int_t bin = 0;
723
724 Bool_t accept;
725 for (Int_t ieta = 1; ieta <= nEta; ++ieta)
726 {
727 if (fEtaAxis->GetBinLowEdge(ieta) >= etaMin && fEtaAxis->GetBinUpEdge(ieta) <= etaMax)
728 {
729 for (Int_t iphi = 1; iphi <= nPhi; ++iphi)
730 {
731 if (fWrapTwoPi )
732 {
734 (phiMin, phiMax, fPhiAxis->GetBinLowEdge(iphi), fPhiAxis->GetBinUpEdge(iphi));
735 }
736 else
737 {
738 accept = fPhiAxis->GetBinLowEdge(iphi) >= phiMin && fPhiAxis->GetBinUpEdge(iphi) <= phiMax &&
739 fPhiAxis->GetBinLowEdge(iphi) >= phiMin && fPhiAxis->GetBinUpEdge(iphi) <= phiMax;
740 }
741
742 if (accept)
743 {
744 for (Int_t s = 0; s < nSlices; ++s)
745 {
746 TH2F *hist = GetHist(s);
747 bin = hist->GetBin(ieta, iphi);
748 if (hist->GetBinContent(bin) > fSliceInfos[s].fThreshold)
749 out.push_back(REveCaloData::CellId_t(bin, s));
750 } // hist slices
751 }
752 } // phi bins
753 }
754 } // eta bins
755}
756
757////////////////////////////////////////////////////////////////////////////////
758/// Rebin
759
761{
762 rdata.fNSlices = GetNSlices();
763 rdata.fBinData.assign((ax->GetNbins()+2)*(ay->GetNbins()+2), -1);
765 Float_t *val;
766 Int_t i, j, w;
767 Int_t binx, biny;
768 Int_t bin;
769
770 for (vCellId_i it=ids.begin(); it!=ids.end(); ++it)
771 {
772 GetCellData(*it, cd);
773 GetHist(it->fSlice)->GetBinXYZ((*it).fTower, i, j, w);
774 binx = ax->FindBin(fEtaAxis->GetBinCenter(i));
775 biny = ay->FindBin(fPhiAxis->GetBinCenter(j));
776 bin = biny*(ax->GetNbins()+2)+binx;
777 val = rdata.GetSliceVals(bin);
778 Double_t ratio = REveUtil::GetFraction(ax->GetBinLowEdge(binx), ax->GetBinUpEdge(binx), cd.EtaMin(), cd.EtaMax())
779 * REveUtil::GetFraction(ay->GetBinLowEdge(biny), ay->GetBinUpEdge(biny), cd.PhiMin(), cd.PhiMax());
780
781 val[(*it).fSlice] += cd.Value(et)*ratio;
782 }
783}
784
785////////////////////////////////////////////////////////////////////////////////
786/// Get cell geometry and value from cell ID.
787
789 REveCaloData::CellData_t& cellData) const
790{
791 TH2F* hist = GetHist(id.fSlice);
792
793 Int_t x, y, z;
794 hist->GetBinXYZ(id.fTower, x, y, z);
795
796 cellData.fValue = hist->GetBinContent(id.fTower);
797 cellData.Configure(hist->GetXaxis()->GetBinLowEdge(x),
798 hist->GetXaxis()->GetBinUpEdge(x),
799 hist->GetYaxis()->GetBinLowEdge(y),
800 hist->GetYaxis()->GetBinUpEdge(y));
801}
802
803////////////////////////////////////////////////////////////////////////////////
804/// Add new slice to calo tower. Updates cached variables fMaxValE
805/// and fMaxValEt
806/// Return last index in the vector of slice infos.
807
809{
810 if (!fEtaAxis) {
811 fEtaAxis = std::make_unique<TAxis>(*hist->GetXaxis());
812 fPhiAxis = std::make_unique<TAxis>(*hist->GetYaxis());
813 }
814 fHStack->Add(hist);
815 fSliceInfos.push_back(SliceInfo_t());
816 fSliceInfos.back().fName = hist->GetName();
817 fSliceInfos.back().fColor = hist->GetLineColor();
818
819 DataChanged();
820
821 return fSliceInfos.size() - 1;
822}
823
824////////////////////////////////////////////////////////////////////////////////
825/// Get histogram in given slice.
826
828{
829 assert(slice >= 0 && slice < fHStack->GetHists()->GetSize());
830 return (TH2F*) fHStack->GetHists()->At(slice);
831}
832
833////////////////////////////////////////////////////////////////////////////////
834/// Get eta limits.
835
837{
838 min = fEtaAxis->GetXmin();
839 max = fEtaAxis->GetXmax();
840}
841
842////////////////////////////////////////////////////////////////////////////////
843/// Get phi limits.
844
846{
847 min = fPhiAxis->GetXmin();
848 max = fPhiAxis->GetXmax();
849}
850
851////////////////////////////////////////////////////////////////////////////////
852/// Process selection. Called from REveCaloViz object
853
855{
856 // only one slice can be user selected at once
857 fActiveSlice = sel_cells.front().fSlice;
858 for (auto &si : fSliceSelectors)
859 {
860 if (si->GetSliceIndex() == fActiveSlice) {
861 si->ProcessSelection(sel_cells, selectionId, multi);
862 break;
863 }
864 }
865}
866
867////////////////////////////////////////////////////////////////////////////////
868/// GetCellsFromSecondaryIndices used in implied selection
869
871{
872 for (auto &si : fSliceSelectors)
873 {
874 if (si->GetSliceIndex() == fActiveSlice) {
875 si->GetCellsFromSecondaryIndices(idcs, out);
876 break;
877 }
878 }
879}
#define c(i)
Definition RSha256.hxx:101
#define e(i)
Definition RSha256.hxx:103
short Color_t
Definition RtypesCore.h:92
char Char_t
Definition RtypesCore.h:37
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
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 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:312
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:272
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:33
Class to manage histogram axis.
Definition TAxis.h:31
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
Definition TAxis.cxx:293
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition TAxis.cxx:518
Int_t GetNbins() const
Definition TAxis.h:125
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition TAxis.cxx:528
TAxis * GetXaxis()
Definition TH1.h:324
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:4938
TAxis * GetYaxis()
Definition TH1.h:325
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:295
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:1043
Double_t GetBinContent(Int_t binx, Int_t biny) const override
Definition TH2.h:89
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 Only 1-d and 2-d histograms currently supported.
Definition THStack.cxx:363
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:357
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:588
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