29#include <nlohmann/json.hpp>
43 printf(
"%f, %f %f, %f \n", fEtaMin, fEtaMax, fPhiMin, fPhiMax);
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.",
90 printf(
"%f, %f %f, %f \n", fEtaMin, fEtaMax, fPhiMin, fPhiMax);
98 if (fBinData[bin] == -1)
100 fBinData[bin] = fSliceData.size();
102 for (
Int_t i=0; i<fNSlices; i++)
103 fSliceData.push_back(0.f);
106 return &fSliceData[fBinData[bin]];
142 fSelector->ProcessSelection(sel_cells, selectionId, multiple);
148 std::set<int> secondary_idcs;
149 for (
vCellId_i i = sel_cells.begin(); i != sel_cells.end(); ++i)
151 int id = (i->fSlice << 24) + i->fTower;
152 secondary_idcs.insert(
id);
267 auto sarr = nlohmann::json::array();
270 nlohmann::json slice = {};
271 slice[
"name"] = s.fName;
272 slice[
"threshold"] = s.fThreshold;
273 slice[
"color"] = s.fColor;
274 sarr.push_back(slice);
276 j[
"sliceInfos"] = sarr;
287 fSelector->GetCellsFromSecondaryIndices(secondary_idcs, cells);
291 for (
auto &
id : secondary_idcs ) {
294 int t =
id & 0xffffff;
296 cells.push_back(cell);
307 using namespace TMath;
310 return Pi() - 2*ATan(Exp(- Abs(eta)));
312 return 2*ATan(Exp(- Abs(eta)));
321 Bool_t single = secondary_idcs.size() == 1;
325 for (
auto &
id : secondary_idcs ) {
327 int slice = (
id >> 24);
328 int tower =
id & 0xffffff;
334 cellData.
Eta(), cellData.
Phi());
336 if (single)
return s;
364 fSliceVec.assign(nslices, std::vector<Float_t> ());
380 fSliceVec.push_back(std::vector<Float_t> ());
391 assert (etaMin < etaMax);
392 assert (phiMin < phiMax);
433 using namespace TMath;
435 Float_t etaMin = eta - etaD*0.5;
436 Float_t etaMax = eta + etaD*0.5;
438 Float_t phiMin = phi - phiD*0.5;
439 Float_t phiMax = phi + phiD*0.5;
444 Float_t fracx=0, fracy=0, frac;
460 minQ += TwoPi(); maxQ += TwoPi();
462 else if (minQ > phiMax)
464 minQ -= TwoPi(); maxQ -= TwoPi();
468 if (maxQ >= phiMin && minQ <= phiMax)
474 for (
Int_t s=0; s<nS; s++)
477 out.push_back(
CellId_t(tower, s, frac));
495 for (
vCellId_i it = ids.begin(); it != ids.end(); ++it)
502 for (
Int_t i = iMin; i <= iMax; ++i)
504 if (i < 0 || i > ax->
GetNbins())
continue;
505 for (
Int_t j = jMin; j <= jMax; ++j)
507 if (j < 0 || j > ay->
GetNbins())
continue;
515 slices[(*it).fSlice] += ratio * cd.
Value(et);
528 cellData.CellGeom_t::operator=(
fGeomVec[
id.fTower] );
537 using namespace TMath;
568 std::vector<Double_t> binX;
569 std::vector<Double_t> binY;
575 binX.push_back(ch.
EtaMin());
576 binX.push_back(ch.
EtaMax());
577 binY.push_back(ch.
PhiMin());
578 binY.push_back(ch.
PhiMax());
581 std::sort(binX.begin(), binX.end());
582 std::sort(binY.begin(), binY.end());
589 Double_t dx = binX.back() - binX.front();
591 std::vector<Double_t> newX;
592 newX.push_back(binX.front());
593 Int_t nX = binX.size()-1;
594 for(
Int_t i=0; i<nX; i++)
596 val = (
sum +binX[i])/(cnt+1);
597 if (binX[i+1] -val > epsX)
609 newX.push_back(binX.back());
614 std::vector<Double_t> newY;
615 Double_t dy = binY.back() - binY.front();
617 newY.push_back(binY.front());
618 Int_t nY = binY.size()-1;
619 for(
Int_t i=0 ; i<nY; i++)
621 val = (
sum +binY[i])/(cnt+1);
622 if (binY[i+1] -val > epsY )
635 newY.push_back(binY.back());
636 fEtaAxis = std::make_unique<TAxis>(newX.size()-1, &newX[0]);
637 fEtaAxis = std::make_unique<TAxis>(newY.size()-1, &newY[0]);
674 using namespace TMath;
713 using namespace TMath;
728 for (
Int_t ieta = 1; ieta <= nEta; ++ieta)
730 if (
fEtaAxis->GetBinLowEdge(ieta) >= etaMin &&
fEtaAxis->GetBinUpEdge(ieta) <= etaMax)
732 for (
Int_t iphi = 1; iphi <= nPhi; ++iphi)
737 (phiMin, phiMax,
fPhiAxis->GetBinLowEdge(iphi),
fPhiAxis->GetBinUpEdge(iphi));
741 accept =
fPhiAxis->GetBinLowEdge(iphi) >= phiMin &&
fPhiAxis->GetBinUpEdge(iphi) <= phiMax &&
742 fPhiAxis->GetBinLowEdge(iphi) >= phiMin &&
fPhiAxis->GetBinUpEdge(iphi) <= phiMax;
747 for (
Int_t s = 0; s < nSlices; ++s)
750 bin = hist->
GetBin(ieta, iphi);
773 for (
vCellId_i it=ids.begin(); it!=ids.end(); ++it)
776 GetHist(it->fSlice)->GetBinXYZ((*it).fTower, i, j,
w);
784 val[(*it).fSlice] += cd.
Value(et)*ratio;
832 assert(slice >= 0 && slice < fHStack->GetHists()->GetSize());
864 si->ProcessSelection(sel_cells, selectionId, multi);
878 si->GetCellsFromSecondaryIndices(idcs, out);
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
REveElement::List_t fNieces
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.
REveCaloDataHist()
Constructor.
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.
Int_t AddSlice()
Add new slice.
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(Int_t nslices)
~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.
void InvalidateCellIdCache()
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].
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.
virtual Color_t GetLineColor() const
Return the line color.
Class to manage histogram axis.
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
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...
2-D histogram with a float per channel (see TH1 documentation)
Service class for 2-D histogram classes.
Int_t GetBin(Int_t binx, Int_t biny, Int_t binz=0) const override
Return Global bin number corresponding to binx,y,z.
Double_t GetBinContent(Int_t binx, Int_t biny) const override
The Histogram stack class.
virtual void Add(TH1 *h, Option_t *option="")
Add a new histogram to the list.
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
const char * GetName() const override
Returns name of object.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
R__EXTERN REveManager * gEve
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
constexpr Double_t TwoPi()
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.
Float_t * GetSliceVals(Int_t bin)
std::vector< Int_t > fBinData
static uint64_t sum(uint64_t i)