28#include <nlohmann/json.hpp>
89 return fData->RefSliceInfo(slice).fThreshold;
116 fData->SetSliceThreshold(slice, val);
124 return fData->RefSliceInfo(slice).fColor;
132 fData->SetSliceColor(slice, col);
173 using namespace TMath;
194 using namespace TMath;
212 using namespace TMath;
230 using namespace TMath;
243 if (data ==
fData)
return;
248 fData->AddNiece(
this);
261 fData->GetEtaLimits(min, max);
270 fData->GetPhiLimits(min, max);
271 delta = 0.5*(max - min);
273 fPhi = 0.5*(max + min);
367 if (
fData->Empty()) {
412 assert(
"fValueIsColor" &&
false);
433 j[
"dataId"] =
fData->GetElementId();
434 j[
"sliceColors"] = nlohmann::json::array();
435 for (
int i = 0; i <
fData->GetNSlices(); ++i)
437 j[
"sliceColors"].push_back(
fData->GetSliceColor(i));
439 j[
"fSecondarySelect"] =
true;
472 using namespace TMath;
473 Float_t z1, r1In, r1Out, z2, r2In, r2Out;
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;
541 float z1In, z1Out, z2In, z2Out;
605 fRenderData = std::make_unique<REveRenderData>(
"makeCalo3D");
613 Int_t prevTower = -1;
619 fData->GetCellData((*i), cellData);
621 if (tower != prevTower)
670 auto sarr = nlohmann::json::array();
674 fData->GetCellData(*i, cellData);
678 jsc[
"t"] = i->fTower;
679 jsc[
"s"] = i->fSlice;
680 jsc[
"f"] = i->fFraction;
685 nlohmann::json rec = {};
736 fData->ProcessSelection(sel, selectionId, multi);
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;
834 const TAxis* axis = isRPhi ?
fData->GetPhiBins() :
fData->GetEtaBins();
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) {
891 fData->GetCellData(*it, cellData);
911 const TAxis* axis = isRPhi ?
fData->GetPhiBins() :
fData->GetEtaBins();
914 for (
vBinCells_i it = outputCellLists.begin(); it != outputCellLists.end(); it++)
922 outputCellLists.clear();
924 outputCellLists.resize(nBins+1);
925 for (UInt_t
b = 0;
b <= nBins; ++
b)
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;
1045 UInt_t nPhiBins =
fData->GetPhiBins()->GetNbins();
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;
1060 fData->GetCellData((*i), cellData);
1061 sliceVal[i->fSlice] += cellData.
Value(
fPlotEt)*(*i).fFraction;
1064 for (
Int_t s=0; s<nSlices; ++s) sliceValRef[s] = 0;
1067 fData->GetCellData(*i, cellData);
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);
1087 UInt_t nEtaBins = axis->
GetNbins();
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.;
1111 fData->GetCellData(*i, cellData);
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;
1126 fData->GetCellData(*i, cellData);
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");
1175 bool isEmpty =
fData->Empty();
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;
1234 fData->GetCellData(*it, cellData);
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;
1338 Int_t nSlices = data->GetNSlices();
1343 UInt_t nPhi = data->GetPhiBins()->GetNbins();
1344 TAxis* axis = data->GetPhiBins();
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;
1401 fManager->GetProjection()->ProjectPoint(pntsOut[3*i], pntsOut[3*i+1], pntsOut[3*i + 2],
fDepth);
1410 bool is_upper = bin >= 0;
1416 if ((*it).fSlice == slice)
1425 fData->GetCellData(*it, cd);
1431 fData->ProcessSelection(sel, selectionId, multi);
1517 fData->GetEtaLimits(em, eM);
1518 fData->GetPhiLimits(pm, pM);
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
short Color_t
Color number (short).
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
Char_t fFrameTransparency
std::vector< CellId_t >::iterator vCellId_i
static Float_t EtaToTheta(Float_t eta)
std::vector< CellId_t > vCellId_t
void BuildCellIdCache() override
Build list of drawn cell IDs. For more information see REveCaloLegoGL:DirectDraw().
EProjection_e fProjection
Char_t fPlaneTransparency
virtual void SetData(REveCaloData *d)
void ComputeBBox() override
Fill bounding-box information of the base-class TAttBBox (virtual method).
REveCaloData::vCellId_t fCellList
Bool_t fHasFixedHeightIn2DMode
REveCaloLego(REveCaloData *data=nullptr, const char *n="REveCaloLego", const char *t="")
Constructor.
Int_t fDrawNumberCellPixels
Float_t fFixedHeightValIn2DMode
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.
REveCaloViz(REveCaloData *data=nullptr, const char *n="REveCaloViz", const char *t="")
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
! Vertex / normal / triangle index information for rendering.
ElementId_t GetElementId() const
REveElement(const std::string &name="", const std::string &title="")
Default constructor.
REveException Exception-type thrown by Eve classes.
REveProjectable()
Constructor.
virtual void SetProjection(REveProjectionManager *mng, REveProjectable *model)
Sets projection manager and reference in the projectable object.
REveProjected(const REveProjected &)=delete
REveProjectionManager * fManager
REveProjectionManager Manager class for steering of projections and managing projected objects.
REveProjection Base for specific classes that implement non-linear projections.
Color_t GetDefaultColor() const
Bool_t GetInterpolate() const
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)
Allocate and prepare for incremental filling.
Float_t * fBBox
! 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.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
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.
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Int_t CeilNint(Double_t x)
Returns the nearest integer of TMath::Ceil(x).
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Double_t Tan(Double_t)
Returns the tangent of an angle of x radians.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Float_t Value(Bool_t) const
Return energy value associated with the cell, usually Et.
Bool_t IsUpperRho() const