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]];
139 fSelector->ProcessSelection(sel_cells, selectionId, multiple);
145 std::set<int> secondary_idcs;
146 for (
vCellId_i i = sel_cells.begin(); i != sel_cells.end(); ++i)
148 int id = (i->fSlice << 24) + i->fTower;
149 secondary_idcs.insert(
id);
264 auto sarr = nlohmann::json::array();
267 nlohmann::json slice = {};
268 slice[
"name"] = s.fName;
269 slice[
"threshold"] = s.fThreshold;
270 slice[
"color"] = s.fColor;
271 sarr.push_back(slice);
273 j[
"sliceInfos"] = sarr;
284 fSelector->GetCellsFromSecondaryIndices(secondary_idcs, cells);
288 for (
auto &
id : secondary_idcs ) {
291 int t =
id & 0xffffff;
293 cells.push_back(cell);
304 using namespace TMath;
307 return Pi() - 2*ATan(Exp(- Abs(eta)));
309 return 2*ATan(Exp(- Abs(eta)));
318 Bool_t single = secondary_idcs.size() == 1;
322 for (
auto &
id : secondary_idcs ) {
324 int slice = (
id >> 24);
325 int tower =
id & 0xffffff;
331 cellData.
Eta(), cellData.
Phi());
333 if (single)
return s;
361 fSliceVec.assign(nslices, std::vector<Float_t> ());
377 fSliceVec.push_back(std::vector<Float_t> ());
388 assert (etaMin < etaMax);
389 assert (phiMin < phiMax);
430 using namespace TMath;
432 Float_t etaMin = eta - etaD*0.5;
433 Float_t etaMax = eta + etaD*0.5;
435 Float_t phiMin = phi - phiD*0.5;
436 Float_t phiMax = phi + phiD*0.5;
441 Float_t fracx=0, fracy=0, frac;
457 minQ += TwoPi(); maxQ += TwoPi();
459 else if (minQ > phiMax)
461 minQ -= TwoPi(); maxQ -= TwoPi();
465 if (maxQ >= phiMin && minQ <= phiMax)
471 for (
Int_t s=0; s<nS; s++)
474 out.push_back(
CellId_t(tower, s, frac));
492 for (
vCellId_i it = ids.begin(); it != ids.end(); ++it)
499 for (
Int_t i = iMin; i <= iMax; ++i)
501 if (i < 0 || i > ax->
GetNbins())
continue;
502 for (
Int_t j = jMin; j <= jMax; ++j)
504 if (j < 0 || j > ay->
GetNbins())
continue;
512 slices[(*it).fSlice] += ratio * cd.
Value(et);
525 cellData.CellGeom_t::operator=(
fGeomVec[
id.fTower] );
534 using namespace TMath;
565 std::vector<Double_t> binX;
566 std::vector<Double_t> binY;
572 binX.push_back(ch.
EtaMin());
573 binX.push_back(ch.
EtaMax());
574 binY.push_back(ch.
PhiMin());
575 binY.push_back(ch.
PhiMax());
578 std::sort(binX.begin(), binX.end());
579 std::sort(binY.begin(), binY.end());
586 Double_t dx = binX.back() - binX.front();
588 std::vector<Double_t> newX;
589 newX.push_back(binX.front());
590 Int_t nX = binX.size()-1;
591 for(
Int_t i=0; i<nX; i++)
593 val = (
sum +binX[i])/(cnt+1);
594 if (binX[i+1] -val > epsX)
606 newX.push_back(binX.back());
611 std::vector<Double_t> newY;
612 Double_t dy = binY.back() - binY.front();
614 newY.push_back(binY.front());
615 Int_t nY = binY.size()-1;
616 for(
Int_t i=0 ; i<nY; i++)
618 val = (
sum +binY[i])/(cnt+1);
619 if (binY[i+1] -val > epsY )
632 newY.push_back(binY.back());
633 fEtaAxis = std::make_unique<TAxis>(newX.size()-1, &newX[0]);
634 fEtaAxis = std::make_unique<TAxis>(newY.size()-1, &newY[0]);
671 using namespace TMath;
710 using namespace TMath;
725 for (
Int_t ieta = 1; ieta <= nEta; ++ieta)
727 if (
fEtaAxis->GetBinLowEdge(ieta) >= etaMin &&
fEtaAxis->GetBinUpEdge(ieta) <= etaMax)
729 for (
Int_t iphi = 1; iphi <= nPhi; ++iphi)
734 (phiMin, phiMax,
fPhiAxis->GetBinLowEdge(iphi),
fPhiAxis->GetBinUpEdge(iphi));
738 accept =
fPhiAxis->GetBinLowEdge(iphi) >= phiMin &&
fPhiAxis->GetBinUpEdge(iphi) <= phiMax &&
739 fPhiAxis->GetBinLowEdge(iphi) >= phiMin &&
fPhiAxis->GetBinUpEdge(iphi) <= phiMax;
744 for (
Int_t s = 0; s < nSlices; ++s)
747 bin = hist->
GetBin(ieta, iphi);
770 for (
vCellId_i it=ids.begin(); it!=ids.end(); ++it)
773 GetHist(it->fSlice)->GetBinXYZ((*it).fTower, i, j,
w);
781 val[(*it).fSlice] += cd.
Value(et)*ratio;
829 assert(slice >= 0 && slice < fHStack->GetHists()->GetSize());
861 si->ProcessSelection(sel_cells, selectionId, multi);
875 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 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)