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 = {};
762 for(
UInt_t i = 0; i <
n; ++i) {
765 cids->clear();
delete cids;
772 for(
UInt_t i = 0; i <
n; ++i) {
775 cids->clear();
delete cids;
842 for (
Int_t ibin = 1; ibin <= nBins; ++ibin) {
850 delete clv; clv =
nullptr;
860 for (
Int_t ibin = 1; ibin <= nBins; ++ibin) {
864 if (low >= min && up <= max)
869 delete clv; clv =
nullptr;
884 for (
Int_t ibin = 1; ibin <= nBins; ++ibin) {
914 for (
vBinCells_i it = outputCellLists.begin(); it != outputCellLists.end(); it++)
922 outputCellLists.clear();
924 outputCellLists.resize(nBins+1);
926 outputCellLists[
b] =
nullptr;
928 for(
UInt_t bin = 1; bin <= nBins; ++bin)
938 if( (*i).fTower == (*j).fTower && (*i).fSlice == (*j).fSlice)
940 if (!outputCellLists[bin])
943 outputCellLists[bin]->emplace_back((*i).fTower, (*i).fSlice, (*j).fFraction);
998 x = -
r,
y = 0, z = 0;
1009 x = 0,
y =
r, z = 0;
1012 x = 0,
y = -
r, z = 0;
1032 static const REveException eh(
"REveCalo2D::WriteCoreJsonSelection ");
1033 auto sarr = nlohmann::json::array();
1037 std::vector<REveCaloData::vCellId_t*> cellLists;
1046 for(
UInt_t phiBin = 1; phiBin <= nPhiBins; ++phiBin)
1048 if (cellLists[phiBin])
1052 delete[] sliceValRef;
1053 throw eh +
"selected cell not in cell list cache.";
1057 for (
Int_t s=0; s<nSlices; ++s) sliceVal[s] = 0;
1061 sliceVal[i->fSlice] += cellData.
Value(
fPlotEt)*(*i).fFraction;
1064 for (
Int_t s=0; s<nSlices; ++s) sliceValRef[s] = 0;
1068 sliceValRef[i->fSlice] += cellData.
Value(
fPlotEt)*(*i).fFraction;
1072 for (
Int_t s = 0; s < nSlices; ++s) {
1073 if (sliceVal[s] > 0)
1078 jsc[
"f"] = sliceVal[s]/sliceValRef[s];
1079 sarr.push_back(jsc);
1090 std::vector<Float_t> sliceValsUp(nSlices, 0.);
1091 std::vector<Float_t> sliceValsLow(nSlices, 0.);
1092 std::vector<Float_t> sliceValsUpRef(nSlices, 0.);
1093 std::vector<Float_t> sliceValsLowRef(nSlices, 0.);
1098 for (
UInt_t etaBin = 1; etaBin <= nEtaBins; ++etaBin)
1100 if (cellLists[etaBin])
1103 throw(eh +
"selected cell not in cell list cache.");
1106 for (
Int_t s = 0; s < nSlices; ++s) {
1107 sliceValsUp[s] = sliceValsLow[s] = 0.;
1113 sliceValsUp [i->fSlice] += cellData.
Value(
fPlotEt)*(*i).fFraction;
1115 sliceValsLow[i->fSlice] += cellData.
Value(
fPlotEt)*(*i).fFraction;
1119 for (
Int_t s = 0; s < nSlices; ++s)
1121 sliceValsUpRef[s] = sliceValsLowRef[s] = 0;
1128 sliceValsUpRef [i->fSlice] += cellData.
Value(
fPlotEt)*(*i).fFraction;
1130 sliceValsLowRef[i->fSlice] += cellData.
Value(
fPlotEt)*(*i).fFraction;
1133 for (
Int_t s = 0; s < nSlices; ++s)
1137 if (sliceValsUp[s] > 0) {
1142 jsc[
"f"] = sliceValsUp[s]/sliceValsUpRef[s];
1143 sarr.push_back(jsc);
1148 if (sliceValsLow[s] > 0) {
1151 jsc[
"b"] =
Int_t(-etaBin);
1153 jsc[
"f"] = sliceValsLow[s]/sliceValsLowRef[s];
1154 sarr.push_back(jsc);
1161 nlohmann::json rec = {};
1163 rec[
"cells"] = sarr;
1173 fRenderData = std::make_unique<REveRenderData>(
"makeCalo2D");
1179 if ((*it) && (*it)->empty())
1185 if (isEmpty)
return;
1212 for (
UInt_t etaBin = 1; etaBin <= nEta; ++etaBin)
1226 for (
Int_t s = 0; s < nSlices; ++s) {
1227 sliceValsUp [s] = 0;
1228 sliceValsLow[s] = 0;
1236 sliceValsUp [it->fSlice] += cellData.
Value(
fPlotEt)*(*it).fFraction;
1238 sliceValsLow[it->fSlice] += cellData.
Value(
fPlotEt)*(*it).fFraction;
1241 isBarrel = !(etaMax > 0 && etaMax > transEtaF) && !(etaMin < 0 && etaMin < transEtaB);
1242 for (
Int_t s = 0; s < nSlices; ++s)
1256 if (sliceValsLow[s])
1271 delete [] sliceValsUp;
1272 delete [] sliceValsLow;
1281 using namespace TMath;
1294 pnts[0] = r1*sin1; pnts[1] = r1*cos1;
1295 pnts[2] = r2*sin1; pnts[3] = r2*cos1;
1296 pnts[4] = r2*sin2; pnts[5] = r2*cos2;
1297 pnts[6] = r1*sin2; pnts[7] = r1*cos2;
1305 if (thetaMax >= transThetaB)
1307 Float_t r1 = zE/Abs(Cos(0.5f*(thetaMin+thetaMax))) +
offset;
1310 pnts[0] = r1*sin1; pnts[1] = r1*cos1;
1311 pnts[2] = r2*sin1; pnts[3] = r2*cos1;
1312 pnts[4] = r2*sin2; pnts[5] = r2*cos2;
1313 pnts[6] = r1*sin2; pnts[7] = r1*cos2;
1318 for (
Int_t i = 0; i < 4; ++i)
1321 y = phiPlus ? Abs(pnts[2*i]) : -Abs(pnts[2*i]);
1325 int j = phiPlus ? i : (3 -i);
1327 pntsOut[j*3 + 1] =
y;
1328 pntsOut[j*3 + 2] = z;
1343 UInt_t nPhi =
data->GetPhiBins()->GetNbins();
1346 for(
UInt_t phiBin = 1; phiBin <= nPhi; ++phiBin)
1352 for (
Int_t s=0; s<nSlices; ++s)
1359 data->GetCellData(*it, cellData);
1360 sliceVal[(*it).fSlice] += cellData.
Value(
fPlotEt)*(*it).fFraction;
1362 for (
Int_t s = 0; s < nSlices; ++s)
1385 using namespace TMath;
1391 pnts[0] = r1*Cos(phiMin); pnts[1] = r1*Sin(phiMin);
1392 pnts[2] = r2*Cos(phiMin); pnts[3] = r2*Sin(phiMin);
1393 pnts[4] = r2*Cos(phiMax); pnts[5] = r2*Sin(phiMax);
1394 pnts[6] = r1*Cos(phiMax); pnts[7] = r1*Sin(phiMax);
1396 for (
Int_t i = 0; i < 4; ++i)
1398 pntsOut[i*3] = pnts[2*i];
1399 pntsOut[i*3+1] = pnts[2*i+1];
1400 pntsOut[i*3+2] = 0.f;
1410 bool is_upper = bin >= 0;
1416 if ((*it).fSlice == slice)
1448 fPlaneColor(
kRed-5),
1449 fPlaneTransparency(60),
1466 fHasFixedHeightIn2DMode(
kFALSE),
1467 fFixedHeightValIn2DMode(0.f),
1469 fDrawNumberCellPixels(18),
1470 fCellPixelFontSize(12)
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 bounding-box information of the base-class TAttBBox (virtual method).
~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 bounding-box information of the base-class TAttBBox (virtual method).
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 bounding-box information of the base-class TAttBBox (virtual method).
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.
std::unique_ptr< REveRenderData > fRenderData
Externally assigned and controlled user data.
ElementId_t GetElementId() const
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 BBoxCheckPoint(Float_t x, Float_t y, Float_t z)
void BBoxZero(Float_t epsilon=0, Float_t x=0, Float_t y=0, Float_t z=0)
Create cube of volume (2*epsilon)^3 at (x,y,z).
void BBoxInit(Float_t infinity=1e6)
Dynamic Float_t[6] X(min,max), Y(min,max), Z(min,max)
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.
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