28#include <nlohmann/json.hpp>
42 printf(
"%f, %f %f, %f \n", fEtaMin, fEtaMax, fPhiMin, fPhiMax);
59 ::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.",
89 printf(
"%f, %f %f, %f \n", fEtaMin, fEtaMax, fPhiMin, fPhiMax);
97 if (fBinData[bin] == -1)
99 fBinData[bin] = fSliceData.size();
101 for (
Int_t i=0; i<fNSlices; i++)
102 fSliceData.push_back(0.f);
105 return &fSliceData[fBinData[bin]];
138 fSelector->ProcessSelection(sel_cells, selectionId, multiple);
144 std::set<int> secondary_idcs;
145 for (
vCellId_i i = sel_cells.begin(); i != sel_cells.end(); ++i)
147 int id = (i->fSlice << 24) + i->fTower;
148 secondary_idcs.insert(
id);
263 auto sarr = nlohmann::json::array();
267 slice[
"name"] = s.fName;
268 slice[
"threshold"] = s.fThreshold;
269 slice[
"color"] = s.fColor;
270 sarr.push_back(slice);
272 j[
"sliceInfos"] = sarr;
283 fSelector->GetCellsFromSecondaryIndices(secondary_idcs, cells);
287 for (
auto &
id : secondary_idcs ) {
290 int t =
id & 0xffffff;
292 cells.push_back(cell);
303 using namespace TMath;
306 return Pi() - 2*ATan(Exp(- Abs(eta)));
308 return 2*ATan(Exp(- Abs(eta)));
317 Bool_t single = secondary_idcs.size() == 1;
321 for (
auto &
id : secondary_idcs ) {
323 int slice = (
id >> 24);
324 int tower =
id & 0xffffff;
330 cellData.
Eta(), cellData.
Phi());
332 if (single)
return s;
360 fSliceVec.assign(nslices, std::vector<Float_t> ());
376 fSliceVec.push_back(std::vector<Float_t> ());
387 assert (etaMin < etaMax);
388 assert (phiMin < phiMax);
429 using namespace TMath;
431 Float_t etaMin = eta - etaD*0.5;
432 Float_t etaMax = eta + etaD*0.5;
434 Float_t phiMin = phi - phiD*0.5;
435 Float_t phiMax = phi + phiD*0.5;
440 Float_t fracx=0, fracy=0, frac;
456 minQ += TwoPi(); maxQ += TwoPi();
458 else if (minQ > phiMax)
460 minQ -= TwoPi(); maxQ -= TwoPi();
464 if (maxQ >= phiMin && minQ <= phiMax)
470 for (
Int_t s=0; s<nS; s++)
473 out.push_back(
CellId_t(tower, s, frac));
491 for (
vCellId_i it = ids.begin(); it != ids.end(); ++it)
498 for (
Int_t i = iMin; i <= iMax; ++i)
500 if (i < 0 || i > ax->
GetNbins())
continue;
501 for (
Int_t j = jMin; j <= jMax; ++j)
503 if (j < 0 || j > ay->
GetNbins())
continue;
511 slices[(*it).fSlice] += ratio * cd.
Value(et);
524 cellData.CellGeom_t::operator=(
fGeomVec[
id.fTower] );
533 using namespace TMath;
564 std::vector<Double_t> binX;
565 std::vector<Double_t> binY;
571 binX.push_back(ch.
EtaMin());
572 binX.push_back(ch.
EtaMax());
573 binY.push_back(ch.
PhiMin());
574 binY.push_back(ch.
PhiMax());
577 std::sort(binX.begin(), binX.end());
578 std::sort(binY.begin(), binY.end());
585 Double_t dx = binX.back() - binX.front();
587 std::vector<Double_t> newX;
588 newX.push_back(binX.front());
589 Int_t nX = binX.size()-1;
590 for(
Int_t i=0; i<nX; i++)
592 val = (
sum +binX[i])/(cnt+1);
593 if (binX[i+1] -val > epsX)
605 newX.push_back(binX.back());
610 std::vector<Double_t> newY;
611 Double_t dy = binY.back() - binY.front();
613 newY.push_back(binY.front());
614 Int_t nY = binY.size()-1;
615 for(
Int_t i=0 ; i<nY; i++)
617 val = (
sum +binY[i])/(cnt+1);
618 if (binY[i+1] -val > epsY )
631 newY.push_back(binY.back());
632 fEtaAxis = std::make_unique<TAxis>(newX.size()-1, &newX[0]);
633 fEtaAxis = std::make_unique<TAxis>(newY.size()-1, &newY[0]);
670 using namespace TMath;
709 using namespace TMath;
724 for (
Int_t ieta = 1; ieta <= nEta; ++ieta)
726 if (
fEtaAxis->GetBinLowEdge(ieta) >= etaMin &&
fEtaAxis->GetBinUpEdge(ieta) <= etaMax)
728 for (
Int_t iphi = 1; iphi <= nPhi; ++iphi)
733 (phiMin, phiMax,
fPhiAxis->GetBinLowEdge(iphi),
fPhiAxis->GetBinUpEdge(iphi));
737 accept =
fPhiAxis->GetBinLowEdge(iphi) >= phiMin &&
fPhiAxis->GetBinUpEdge(iphi) <= phiMax &&
738 fPhiAxis->GetBinLowEdge(iphi) >= phiMin &&
fPhiAxis->GetBinUpEdge(iphi) <= phiMax;
743 for (
Int_t s = 0; s < nSlices; ++s)
746 bin = hist->
GetBin(ieta, iphi);
769 for (
vCellId_i it=ids.begin(); it!=ids.end(); ++it)
772 GetHist(it->fSlice)->GetBinXYZ((*it).fTower, i, j, w);
780 val[(*it).fSlice] += cd.
Value(et)*ratio;
828 assert(slice >= 0 && slice < fHStack->GetHists()->GetSize());
860 si->ProcessSelection(sel_cells, selectionId, multi);
874 si->GetCellsFromSecondaryIndices(idcs, out);
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
REveElement::List_t fNieces
Int_t AddHistogram(TH2F *hist)
Add new slice to calo tower.
virtual void Rebin(TAxis *ax, TAxis *ay, vCellId_t &in, Bool_t et, RebinData_t &out) const
Rebin.
TH2F * GetHist(Int_t slice) const
Get histogram in given slice.
virtual void GetCellList(Float_t etaMin, Float_t etaMax, Float_t phi, Float_t phiRng, vCellId_t &out) const
Get list of cell IDs in given eta and phi range.
virtual void GetPhiLimits(Double_t &min, Double_t &max) const
Get phi limits.
virtual void GetCellData(const REveCaloData::CellId_t &id, REveCaloData::CellData_t &data) const
Get cell geometry and value from cell ID.
virtual ~REveCaloDataHist()
Destructor.
virtual void GetEtaLimits(Double_t &min, Double_t &max) const
Get eta limits.
virtual void DataChanged()
Update limits and notify data users.
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
Int_t AddSlice()
Add new slice.
virtual void GetCellList(Float_t etaMin, Float_t etaMax, Float_t phi, Float_t phiRng, vCellId_t &out) const
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.
virtual void Rebin(TAxis *ax, TAxis *ay, vCellId_t &in, Bool_t et, RebinData_t &out) const
Rebin cells.
void SetAxisFromBins(Double_t epsX=0.001, Double_t epsY=0.001)
Set XY axis from cells geometry.
virtual void DataChanged()
Update limits and notify data users.
std::vector< vFloat_t >::iterator vvFloat_i
REveCaloDataVec(Int_t nslices)
virtual ~REveCaloDataVec()
Destructor.
virtual void GetCellData(const REveCaloData::CellId_t &id, REveCaloData::CellData_t &data) const
Get cell geometry and value from cell ID.
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.
void FillImpliedSelectedSet(Set_t &impSelSet) override
Populate set impSelSet with derived / dependant elements.
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 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.
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
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.
virtual Int_t GetBin(Int_t binx, Int_t biny, Int_t binz=0) const
Return Global bin number corresponding to binx,y,z.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
The Histogram stack class.
virtual void Add(TH1 *h, Option_t *option="")
add a new histogram to the list Only 1-d and 2-d histograms currently supported.
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
virtual const char * GetName() const
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
constexpr Double_t TwoPi()
basic_json< std::map, std::vector, std::string, bool, std::int64_t, std::uint64_t, double, std::allocator, adl_serializer, std::vector< std::uint8_t > > json
virtual void Dump() const
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)