28#include <nlohmann/json.hpp>
52 fPhiOffset(
TMath::Pi()),
173 using namespace TMath;
194 using namespace TMath;
212 using namespace TMath;
230 using namespace TMath;
271 delta = 0.5*(max - min);
273 fPhi = 0.5*(max + min);
401 return TClass::GetClass<REveCalo2D>();
412 assert(
"fValueIsColor" &&
false);
434 j[
"sliceColors"] = nlohmann::json::array();
439 j[
"fSecondarySelect"] =
true;
455 fRnrEndCapFrame (
kTRUE),
456 fRnrBarrelFrame (
kTRUE),
458 fFrameColor (
kGray+1),
459 fFrameTransparency (80)
472 using namespace TMath;
473 Float_t z1, r1In, r1Out, z2, r2In, r2Out;
480 r1Out = z1*Tan(cellData.
ThetaMax());
481 r2Out = z2*Tan(cellData.
ThetaMax());
510 pnts[0] = r1Out*cos1;
511 pnts[1] = r1Out*sin1;
515 pnts[0] = r1Out*cos2;
516 pnts[1] = r1Out*sin2;
520 pnts[0] = r2Out*cos2;
521 pnts[1] = r2Out*sin2;
525 pnts[0] = r2Out*cos1;
526 pnts[1] = r2Out*sin1;
537 using namespace TMath;
540 float r2 = r1 + towerH*Sin(cellData.
ThetaMin());
541 float z1In, z1Out, z2In, z2Out;
544 z1Out = r2/Tan(cellData.
ThetaMax());
546 z2Out = r2/Tan(cellData.
ThetaMin());
548 float cos1 = Cos(cellData.
PhiMin());
549 float sin1 = Sin(cellData.
PhiMin());
550 float cos2 = Cos(cellData.
PhiMax());
551 float sin2 = Sin(cellData.
PhiMax());
605 fRenderData = std::make_unique<REveRenderData>(
"makeCalo3D");
613 Int_t prevTower = -1;
621 if (tower != prevTower)
670 auto sarr = nlohmann::json::array();
678 jsc[
"t"] = i->fTower;
679 jsc[
"s"] = i->fSlice;
680 jsc[
"f"] = i->fFraction;
685 nlohmann::json rec = {};
759 for(
UInt_t i = 0; i <
n; ++i) {
762 cids->clear();
delete cids;
769 for(
UInt_t i = 0; i <
n; ++i) {
772 cids->clear();
delete cids;
839 for (
Int_t ibin = 1; ibin <= nBins; ++ibin) {
847 delete clv; clv =
nullptr;
857 for (
Int_t ibin = 1; ibin <= nBins; ++ibin) {
861 if (low >= min && up <= max)
866 delete clv; clv =
nullptr;
881 for (
Int_t ibin = 1; ibin <= nBins; ++ibin) {
911 for (
vBinCells_i it = outputCellLists.begin(); it != outputCellLists.end(); it++)
919 outputCellLists.clear();
921 outputCellLists.resize(nBins+1);
923 outputCellLists[
b] =
nullptr;
925 for(
UInt_t bin = 1; bin <= nBins; ++bin)
935 if( (*i).fTower == (*j).fTower && (*i).fSlice == (*j).fSlice)
937 if (!outputCellLists[bin])
940 outputCellLists[bin]->emplace_back((*i).fTower, (*i).fSlice, (*j).fFraction);
995 x = -
r,
y = 0, z = 0;
1006 x = 0,
y =
r, z = 0;
1009 x = 0,
y = -
r, z = 0;
1029 static const REveException eh(
"REveCalo2D::WriteCoreJsonSelection ");
1030 auto sarr = nlohmann::json::array();
1034 std::vector<REveCaloData::vCellId_t*> cellLists;
1043 for(
UInt_t phiBin = 1; phiBin <= nPhiBins; ++phiBin)
1045 if (cellLists[phiBin])
1049 delete[] sliceValRef;
1050 throw eh +
"selected cell not in cell list cache.";
1054 for (
Int_t s=0; s<nSlices; ++s) sliceVal[s] = 0;
1058 sliceVal[i->fSlice] += cellData.
Value(
fPlotEt)*(*i).fFraction;
1061 for (
Int_t s=0; s<nSlices; ++s) sliceValRef[s] = 0;
1065 sliceValRef[i->fSlice] += cellData.
Value(
fPlotEt)*(*i).fFraction;
1069 for (
Int_t s = 0; s < nSlices; ++s) {
1070 if (sliceVal[s] > 0)
1075 jsc[
"f"] = sliceVal[s]/sliceValRef[s];
1076 sarr.push_back(jsc);
1087 std::vector<Float_t> sliceValsUp(nSlices, 0.);
1088 std::vector<Float_t> sliceValsLow(nSlices, 0.);
1089 std::vector<Float_t> sliceValsUpRef(nSlices, 0.);
1090 std::vector<Float_t> sliceValsLowRef(nSlices, 0.);
1095 for (
UInt_t etaBin = 1; etaBin <= nEtaBins; ++etaBin)
1097 if (cellLists[etaBin])
1100 throw(eh +
"selected cell not in cell list cache.");
1103 for (
Int_t s = 0; s < nSlices; ++s) {
1104 sliceValsUp[s] = sliceValsLow[s] = 0.;
1110 sliceValsUp [i->fSlice] += cellData.
Value(
fPlotEt)*(*i).fFraction;
1112 sliceValsLow[i->fSlice] += cellData.
Value(
fPlotEt)*(*i).fFraction;
1116 for (
Int_t s = 0; s < nSlices; ++s)
1118 sliceValsUpRef[s] = sliceValsLowRef[s] = 0;
1125 sliceValsUpRef [i->fSlice] += cellData.
Value(
fPlotEt)*(*i).fFraction;
1127 sliceValsLowRef[i->fSlice] += cellData.
Value(
fPlotEt)*(*i).fFraction;
1130 for (
Int_t s = 0; s < nSlices; ++s)
1134 if (sliceValsUp[s] > 0) {
1139 jsc[
"f"] = sliceValsUp[s]/sliceValsUpRef[s];
1140 sarr.push_back(jsc);
1145 if (sliceValsLow[s] > 0) {
1148 jsc[
"b"] =
Int_t(-etaBin);
1150 jsc[
"f"] = sliceValsLow[s]/sliceValsLowRef[s];
1151 sarr.push_back(jsc);
1158 nlohmann::json rec = {};
1160 rec[
"cells"] = sarr;
1170 fRenderData = std::make_unique<REveRenderData>(
"makeCalo2D");
1176 if ((*it) && (*it)->empty())
1182 if (isEmpty)
return;
1209 for (
UInt_t etaBin = 1; etaBin <= nEta; ++etaBin)
1223 for (
Int_t s = 0; s < nSlices; ++s) {
1224 sliceValsUp [s] = 0;
1225 sliceValsLow[s] = 0;
1233 sliceValsUp [it->fSlice] += cellData.
Value(
fPlotEt)*(*it).fFraction;
1235 sliceValsLow[it->fSlice] += cellData.
Value(
fPlotEt)*(*it).fFraction;
1238 isBarrel = !(etaMax > 0 && etaMax > transEtaF) && !(etaMin < 0 && etaMin < transEtaB);
1239 for (
Int_t s = 0; s < nSlices; ++s)
1253 if (sliceValsLow[s])
1268 delete [] sliceValsUp;
1269 delete [] sliceValsLow;
1278 using namespace TMath;
1291 pnts[0] = r1*sin1; pnts[1] = r1*cos1;
1292 pnts[2] = r2*sin1; pnts[3] = r2*cos1;
1293 pnts[4] = r2*sin2; pnts[5] = r2*cos2;
1294 pnts[6] = r1*sin2; pnts[7] = r1*cos2;
1302 if (thetaMax >= transThetaB)
1304 Float_t r1 = zE/Abs(Cos(0.5f*(thetaMin+thetaMax))) +
offset;
1307 pnts[0] = r1*sin1; pnts[1] = r1*cos1;
1308 pnts[2] = r2*sin1; pnts[3] = r2*cos1;
1309 pnts[4] = r2*sin2; pnts[5] = r2*cos2;
1310 pnts[6] = r1*sin2; pnts[7] = r1*cos2;
1315 for (
Int_t i = 0; i < 4; ++i)
1318 y = phiPlus ? Abs(pnts[2*i]) : -Abs(pnts[2*i]);
1322 int j = phiPlus ? i : (3 -i);
1324 pntsOut[j*3 + 1] =
y;
1325 pntsOut[j*3 + 2] = z;
1340 UInt_t nPhi =
data->GetPhiBins()->GetNbins();
1343 for(
UInt_t phiBin = 1; phiBin <= nPhi; ++phiBin)
1349 for (
Int_t s=0; s<nSlices; ++s)
1356 data->GetCellData(*it, cellData);
1357 sliceVal[(*it).fSlice] += cellData.
Value(
fPlotEt)*(*it).fFraction;
1359 for (
Int_t s = 0; s < nSlices; ++s)
1382 using namespace TMath;
1388 pnts[0] = r1*Cos(phiMin); pnts[1] = r1*Sin(phiMin);
1389 pnts[2] = r2*Cos(phiMin); pnts[3] = r2*Sin(phiMin);
1390 pnts[4] = r2*Cos(phiMax); pnts[5] = r2*Sin(phiMax);
1391 pnts[6] = r1*Cos(phiMax); pnts[7] = r1*Sin(phiMax);
1393 for (
Int_t i = 0; i < 4; ++i)
1395 pntsOut[i*3] = pnts[2*i];
1396 pntsOut[i*3+1] = pnts[2*i+1];
1397 pntsOut[i*3+2] = 0.f;
1407 bool is_upper = bin >= 0;
1413 if ((*it).fSlice == slice)
1445 fPlaneColor(
kRed-5),
1446 fPlaneTransparency(60),
1463 fHasFixedHeightIn2DMode(
kFALSE),
1464 fFixedHeightValIn2DMode(0.f),
1466 fDrawNumberCellPixels(18),
1467 fCellPixelFontSize(12)
int Int_t
Signed integer 4 bytes (int)
short Color_t
Color number (short)
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t sel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
virtual void AddNiece(REveElement *el)
void BuildRenderData() override
Creates 2D point array for rendering.
void SetProjection(REveProjectionManager *proj, REveProjectable *model) override
Set projection manager and model object.
void MakeRhoZCell(Float_t thetaMin, Float_t thetaMax, Float_t &offset, Bool_t isBarrel, Bool_t phiPlus, Float_t towerH, float *pntsOut) const
Get cell vertices in RhoZ projection.
void BuildRenderDataRPhi()
Creates 2D point array in RPhi() projection.
bool IsRPhi() const
Is current projection type RPhi.
void WriteCoreJsonSelection(nlohmann::json &j, REveCaloData::vCellId_t) override
Fill core part of JSON representation for selection.
void ComputeBBox() override
Fill the bounding box (virtual from REveElement).
~REveCalo2D() override
Destructor.
std::vector< REveCaloData::vCellId_t * >::iterator vBinCells_i
void NewBinPicked(Int_t bin, Int_t slice, Int_t selectionId, Bool_t multi)
Client callback.
void CellSelectionChangedInternal(REveCaloData::vCellId_t &cells, std::vector< REveCaloData::vCellId_t * > &cellLists)
s////////////////////////////////// Sort selected cells in eta or phi bins.
REveProjection::EPType_e fOldProjectionType
REveCalo2D(const char *n="REveCalo2D", const char *t="")
Constructor.
void UpdateProjection() override
This is virtual method from base-class REveProjected.
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Fill core part of JSON representation.
std::vector< REveCaloData::vCellId_t * > fCellLists
std::vector< REveCaloData::vCellId_t * > fCellListsSelected
void BuildCellIdCache() override
Build lists of drawn cell IDs. See REveCalo2DGL::DirecDraw().
void BuildRenderDataRhoZ()
Creates 2D point array in RhoZ projection.
Float_t GetValToHeight() const override
Virtual function of REveCaloViz.
void MakeRPhiCell(Float_t phiMin, Float_t phiMax, Float_t towerH, Float_t offset, float *pntsOut) const
Calculate vertices for the calorimeter cell in RPhi projection.
void SetScaleAbs(Bool_t) override
Set absolute scale in projected calorimeter.
REveCalo3D(REveCaloData *d=nullptr, const char *n="REveCalo3D", const char *t="")
Constructor.
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Fill core part of JSON representation.
void ComputeBBox() override
Fill the bounding box (virtual from REveElement).
void MakeBarrelCell(const REveCaloData::CellGeom_t &cellData, float towerH, Float_t &offset, float *pnts) const
Make endcap cell.
void MakeEndCapCell(const REveCaloData::CellGeom_t &cellData, float towerH, Float_t &offset, float *pnts) const
Make endcap cell.
void WriteCoreJsonSelection(nlohmann::json &j, REveCaloData::vCellId_t) override
Fill core part of JSON representation for selection.
void BuildRenderData() override
Crates 3D point array for rendering.
void BuildCellIdCache() override
Build list of drawn cell IDs. See REveCalo3DGL::DirectDraw().
void NewTowerPicked(Int_t tower, Int_t slice, Int_t selectionId, Bool_t multi)
Client selection callback.
REveCaloData::vCellId_t fCellList
Color_t GetSliceColor(Int_t slice) const
Get color for given slice.
virtual Float_t GetMaxVal(Bool_t et) const
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
virtual TAxis * GetEtaBins() const
static Float_t EtaToTheta(Float_t eta)
virtual Float_t GetEps() const
void ProcessSelection(vCellId_t &sel_cells, UInt_t selectionId, Bool_t multi)
Process newly selected cells with given select-record.
SliceInfo_t & RefSliceInfo(Int_t s)
virtual void GetEtaLimits(Double_t &min, Double_t &max) const =0
virtual void GetCellList(Float_t etaMin, Float_t etaMax, Float_t phi, Float_t phiRng, vCellId_t &out) const =0
virtual TAxis * GetPhiBins() const
std::vector< CellId_t > vCellId_t
void SetSliceColor(Int_t slice, Color_t col)
Set color for given slice.
virtual void GetPhiLimits(Double_t &min, Double_t &max) const =0
void BuildCellIdCache() override
Build list of drawn cell IDs. For more information see REveCaloLegoGL:DirectDraw().
virtual void SetData(REveCaloData *d)
void ComputeBBox() override
Fill the bounding box (virtual from REveElement).
REveCaloData::vCellId_t fCellList
REveCaloLego(REveCaloData *data=nullptr, const char *n="REveCaloLego", const char *t="")
Constructor.
Float_t GetPhiMax() const
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Fill core part of JSON representation.
virtual REveElement * ForwardSelection()
Management of selection state and ownership of selected cell list is done in REveCaloData.
Float_t GetPhiRng() const
Float_t GetBarrelRadius() const
Float_t GetEtaMin() const
Float_t GetMaxVal() const
Float_t GetEtaMax() const
Float_t GetBackwardEndCapPos() const
void SetPlotEt(Bool_t x)
Set E/Et plot.
Float_t GetTransitionTheta() const
Get transition angle between barrel and end-cap cells, assuming fEndCapPosF = -fEndCapPosB.
virtual void BuildCellIdCache()=0
void SetPalette(REveRGBAPalette *p)
Set REveRGBAPalette object pointer.
Float_t GetPhiMin() const
virtual void SetScaleAbs(Bool_t x)
Float_t GetTransitionEtaForward() const
Get transition eta between barrel and forward end-cap cells.
void DataChanged()
Update setting and cache on data changed.
void SetDataSliceColor(Int_t slice, Color_t col)
Set slice color in data.
Float_t GetTransitionEta() const
Get transition eta between barrel and end-cap cells, assuming fEndCapPosF = -fEndCapPosB.
Color_t GetDataSliceColor(Int_t slice) const
Get slice color from data.
Float_t GetTransitionEtaBackward() const
Get transition eta between barrel and backward end-cap cells.
Bool_t AssertCellIdCache() const
Assert cell id cache is ok.
void SetPhiWithRng(Float_t x, Float_t r)
Set phi range.
~REveCaloViz() override
Destructor.
virtual Float_t GetValToHeight() const
Get transformation factor from E/Et to height.
TClass * ProjectedClass(const REveProjection *p) const override
Virtual from REveProjectable, returns REveCalo2D class.
Float_t GetDataSliceThreshold(Int_t slice) const
Get threshold for given slice.
Float_t GetForwardEndCapPos() const
Bool_t CellInEtaPhiRng(REveCaloData::CellData_t &) const
Returns true if given cell is in the ceta phi range.
void SetupHeight(Float_t value, Int_t slice, Float_t &height) const
Set color and height for a given value and slice using slice color or REveRGBAPalette.
Float_t GetEtaRng() const
Float_t GetTransitionThetaForward() const
Get transition angle between barrel and forward end-cap cells.
void SetData(REveCaloData *d)
Set calorimeter event data.
void InvalidateCellIdCache()
Float_t GetTransitionThetaBackward() const
Get transition angle between barrel and backward end-cap cells.
void AssignCaloVizParameters(REveCaloViz *cv)
Assign parameters from given model.
virtual REveElement * ForwardEdit()
Management of selection state and ownership of selected cell list is done in REveCaloData.
void SetDataSliceThreshold(Int_t slice, Float_t val)
Set threshold for given slice.
REveRGBAPalette * fPalette
REveRGBAPalette * AssertPalette()
Make sure the REveRGBAPalette pointer is not null.
void SetEta(Float_t l, Float_t u)
Set eta range.
void SetNameTitle(const std::string &name, const std::string &title)
Set name and title of an element.
Bool_t fCanEditMainTransparency
virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset)
Write core json.
void BBoxCheckPoint(const REveVector &v)
std::unique_ptr< REveRenderData > fRenderData
! Vertex / normal / triangle index information for rendering.
void BBoxZero(Float_t epsilon=0, Float_t x=0, Float_t y=0, Float_t z=0)
Set the bounding box to a cube of half-side epsilon at (x, y, z); with the defaults,...
void BBoxInit()
Start filling the bounding box with BBoxCheckPoint(): min at +infinity, max at -infinity,...
ElementId_t GetElementId() const
REveVector fBBoxMin
! Bounding box in the element's own frame.
REveException Exception-type thrown by Eve classes.
virtual void SetProjection(REveProjectionManager *mng, REveProjectable *model)
Sets projection manager and reference in the projectable object.
REveProjectionManager * fManager
REveProjectionManager Manager class for steering of projections and managing projected objects.
REveProjection * GetProjection()
REveProjection Base for specific classes that implement non-linear projections.
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e p=kPP_Full)=0
Color_t GetDefaultColor() const
void SetMin(Int_t min)
Set current min value.
Bool_t GetInterpolate() const
void SetMax(Int_t max)
Set current max value.
void SetLimits(Int_t low, Int_t high)
Set low/high limits on signal value.
void SetDefaultColor(Color_t ci)
Set default color.
static Bool_t IsU1IntervalOverlappingByMinMax(Float_t minM, Float_t maxM, Float_t minQ, Float_t maxQ)
Return true if interval Q is overlapping within interval M for U1 variables.
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.
void Set(const Float_t *v)
Class to manage histogram axis.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Namespace for ROOT features in testing.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t ATan(Double_t)
Returns the principal value of the arc tangent of x, expressed in radians.
T1 Sign(T1 a, T2 b)
Returns a value with the magnitude of a and the sign of b.
Int_t CeilNint(Double_t x)
Returns the nearest integer of TMath::Ceil(x).
Float_t Value(Bool_t) const
Return energy value associated with the cell, usually Et.
Bool_t IsUpperRho() const