Skip to content

Commit

Permalink
Merge pull request #35626 from rovere/ImproveFireworksGeometryAndProxies
Browse files Browse the repository at this point in the history
Improve fireworks geometry and proxies
  • Loading branch information
cmsbuild authored Oct 13, 2021
2 parents 5a55ef7 + e37b0dd commit 2cc775f
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 130 deletions.
149 changes: 76 additions & 73 deletions Fireworks/Calo/plugins/FWTracksterHitsProxyBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,33 @@ void FWTracksterHitsProxyBuilder::build(const ticl::Trackster &iData,
const size_t N = trackster.vertices().size();
const std::vector<reco::CaloCluster> &layerClusters = *layerClustersHandle_;

bool h_hex(false);
TEveBoxSet *hex_boxset = new TEveBoxSet();
if (!heatmap_)
hex_boxset->UseSingleColor();
hex_boxset->SetPickable(true);
hex_boxset->Reset(TEveBoxSet::kBT_Hex, true, 64);
hex_boxset->SetAntiFlick(true);

bool h_box(false);
TEveBoxSet *boxset = new TEveBoxSet();
if (!heatmap_)
boxset->UseSingleColor();
boxset->SetPickable(true);
boxset->Reset(TEveBoxSet::kBT_FreeBox, true, 64);
boxset->SetAntiFlick(true);

TEveStraightLineSet *seed_marker = nullptr;
if (enableSeedLines_) {
seed_marker = new TEveStraightLineSet("seeds");
seed_marker->SetLineWidth(2);
seed_marker->SetLineColor(kOrange + 10);
seed_marker->GetLinePlex().Reset(sizeof(TEveStraightLineSet::Line_t), 2 * N);
}

TEveStraightLineSet *position_marker = nullptr;
if (enablePositionLines_) {
position_marker = new TEveStraightLineSet("positions");
position_marker->SetLineWidth(2);
position_marker->SetLineColor(kOrange);
position_marker->GetLinePlex().Reset(sizeof(TEveStraightLineSet::Line_t), 2 * N);
}

for (size_t i = 0; i < N; ++i) {
const reco::CaloCluster layerCluster = layerClusters[trackster.vertices(i)];
Expand Down Expand Up @@ -159,36 +171,27 @@ void FWTracksterHitsProxyBuilder::build(const ticl::Trackster &iData,

// seed and cluster position
if (layerCluster.seed().rawId() == it->first.rawId()) {
const float crossScale = 1.0f + fmin(layerCluster.energy(), 5.0f);
const float crossScale = 0.2f + fmin(layerCluster.energy(), 5.0f);
if (enableSeedLines_) {
TEveStraightLineSet *marker = new TEveStraightLineSet;
marker->SetLineWidth(1);

// center of RecHit
const float center[3] = {corners[total_points * 3 + 0],
corners[total_points * 3 + 1],
corners[total_points * 3 + 2] + shapes[3] * 0.5f};

// draw 3D cross
marker->AddLine(center[0] - crossScale, center[1], center[2], center[0] + crossScale, center[1], center[2]);
marker->AddLine(center[0], center[1] - crossScale, center[2], center[0], center[1] + crossScale, center[2]);
marker->AddLine(center[0], center[1], center[2] - crossScale, center[0], center[1], center[2] + crossScale);

oItemHolder.AddElement(marker);
seed_marker->AddLine(
center[0] - crossScale, center[1], center[2], center[0] + crossScale, center[1], center[2]);
seed_marker->AddLine(
center[0], center[1] - crossScale, center[2], center[0], center[1] + crossScale, center[2]);
}

if (enablePositionLines_) {
TEveStraightLineSet *position_marker = new TEveStraightLineSet;
position_marker->SetLineWidth(2);
position_marker->SetLineColor(kOrange);
auto const &pos = layerCluster.position();
const float position_crossScale = crossScale * 0.5;
position_marker->AddLine(
pos.x() - position_crossScale, pos.y(), pos.z(), pos.x() + position_crossScale, pos.y(), pos.z());
position_marker->AddLine(
pos.x(), pos.y() - position_crossScale, pos.z(), pos.x(), pos.y() + position_crossScale, pos.z());

oItemHolder.AddElement(position_marker);
}
}

Expand All @@ -198,6 +201,8 @@ void FWTracksterHitsProxyBuilder::build(const ticl::Trackster &iData,
saturation_energy_,
1.0f);
const uint8_t colorFactor = gradient_steps * energy;
auto transparency = item()->modelInfo(iIndex).displayProperties().transparency();
UChar_t alpha = (255 * (100 - transparency)) / 100;

// Scintillator
if (!isSilicon) {
Expand All @@ -215,11 +220,10 @@ void FWTracksterHitsProxyBuilder::build(const ticl::Trackster &iData,
}
boxset->AddBox(&pnts[0]);
if (heatmap_) {
energy ? boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor])
: boxset->DigitColor(64, 64, 64);
energy
? boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor], alpha)
: boxset->DigitColor(64, 64, 64, alpha);
}

h_box = true;
}
// Silicon
else {
Expand All @@ -230,72 +234,71 @@ void FWTracksterHitsProxyBuilder::build(const ticl::Trackster &iData,
float radius = fabs(corners[6] - corners[6 + offset]) / 2;
hex_boxset->AddHex(TEveVector(centerX, centerY, corners[2]), radius, 90.0, shapes[3]);
if (heatmap_) {
energy ? hex_boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor])
: hex_boxset->DigitColor(64, 64, 64);
energy ? hex_boxset->DigitColor(
gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor], alpha)
: hex_boxset->DigitColor(64, 64, 64, alpha);
} else {
hex_boxset->CSCApplyMainColorToMatchingChildren();
hex_boxset->CSCApplyMainTransparencyToMatchingChildren();
hex_boxset->SetMainColor(item()->modelInfo(iIndex).displayProperties().color());
hex_boxset->SetMainTransparency(item()->defaultDisplayProperties().transparency());
}

h_hex = true;
}
}
}
} // End of loop over rechits of a single layercluster
} // End loop over the layerclusters of the trackster

hex_boxset->RefitPlex();
boxset->RefitPlex();
setupAddElement(hex_boxset, &oItemHolder);
setupAddElement(boxset, &oItemHolder);

if (enableSeedLines_)
oItemHolder.AddElement(seed_marker);

if (enablePositionLines_)
oItemHolder.AddElement(position_marker);

if (enableEdges_) {
auto &edges = trackster.edges();

TEveStraightLineSet *adjacent_marker = new TEveStraightLineSet("adj_edges");
adjacent_marker->SetLineWidth(2);
adjacent_marker->SetLineColor(kYellow);
adjacent_marker->GetLinePlex().Reset(sizeof(TEveStraightLineSet::Line_t), edges.size());

TEveStraightLineSet *non_adjacent_marker = new TEveStraightLineSet("non_adj_edges");
non_adjacent_marker->SetLineWidth(2);
non_adjacent_marker->SetLineColor(kRed);
non_adjacent_marker->GetLinePlex().Reset(sizeof(TEveStraightLineSet::Line_t), edges.size());

for (auto edge : edges) {
auto doublet = std::make_pair(layerClusters[edge[0]], layerClusters[edge[1]]);

int layerIn = item()->getGeom()->getParameters(doublet.first.seed())[1];
int layerOut = item()->getGeom()->getParameters(doublet.second.seed())[1];

const bool isAdjacent = (layerOut - layerIn) == 1;

TEveStraightLineSet *marker = new TEveStraightLineSet;
marker->SetLineWidth(2);
if (isAdjacent) {
marker->SetLineColor(kYellow);
} else {
marker->SetLineColor(kRed);
}
const bool isAdjacent = std::abs(layerOut - layerIn) == 1;

// draw 3D cross
if (layer_ == 0 || fabs(layerIn - layer_) == 0 || fabs(layerOut - layer_) == 0) {
marker->AddLine(doublet.first.x(),
doublet.first.y(),
doublet.first.z(),
doublet.second.x(),
doublet.second.y(),
doublet.second.z());
if (layer_ == 0 || std::abs(layerIn - layer_) == 0 || std::abs(layerOut - layer_) == 0) {
if (isAdjacent)
adjacent_marker->AddLine(doublet.first.x(),
doublet.first.y(),
doublet.first.z(),
doublet.second.x(),
doublet.second.y(),
doublet.second.z());
else
non_adjacent_marker->AddLine(doublet.first.x(),
doublet.first.y(),
doublet.first.z(),
doublet.second.x(),
doublet.second.y(),
doublet.second.z());
}

oItemHolder.AddElement(marker);
}
}

if (h_hex) {
hex_boxset->RefitPlex();

hex_boxset->CSCTakeAnyParentAsMaster();
if (!heatmap_) {
hex_boxset->CSCApplyMainColorToMatchingChildren();
hex_boxset->CSCApplyMainTransparencyToMatchingChildren();
hex_boxset->SetMainColor(item()->modelInfo(iIndex).displayProperties().color());
hex_boxset->SetMainTransparency(item()->defaultDisplayProperties().transparency());
}
oItemHolder.AddElement(hex_boxset);
}

if (h_box) {
boxset->RefitPlex();

boxset->CSCTakeAnyParentAsMaster();
if (!heatmap_) {
boxset->CSCApplyMainColorToMatchingChildren();
boxset->CSCApplyMainTransparencyToMatchingChildren();
boxset->SetMainColor(item()->modelInfo(iIndex).displayProperties().color());
boxset->SetMainTransparency(item()->defaultDisplayProperties().transparency());
}
oItemHolder.AddElement(boxset);
} // End of loop over all edges of the trackster
oItemHolder.AddElement(adjacent_marker);
oItemHolder.AddElement(non_adjacent_marker);
}
}

Expand Down
62 changes: 39 additions & 23 deletions Fireworks/Calo/plugins/FWTracksterLayersProxyBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ void FWTracksterLayersProxyBuilder::build(const ticl::Trackster &iData,
const ticl::Trackster &trackster = iData;
const size_t N = trackster.vertices().size();
const std::vector<reco::CaloCluster> &layerClusters = *layerClustersHandle_;
TEveStraightLineSet *position_marker = nullptr;

if (enablePositionLines_) {
position_marker = new TEveStraightLineSet;
position_marker->SetLineWidth(2);
position_marker->SetLineColor(kWhite);
}

for (size_t i = 0; i < N; ++i) {
const reco::CaloCluster layerCluster = layerClusters[trackster.vertices(i)];
Expand Down Expand Up @@ -161,7 +168,7 @@ void FWTracksterLayersProxyBuilder::build(const ticl::Trackster &iData,
radius = sqrt(nHits * area) / M_PI;
}

auto eveCircle = new TEveGeoShape("Circle");
auto *eveCircle = new TEveGeoShape("Circle");
auto tube = new TGeoTube(0., proportionalityFactor_ * radius, 0.1);
eveCircle->SetShape(tube);
eveCircle->InitMainTrans();
Expand All @@ -173,56 +180,65 @@ void FWTracksterLayersProxyBuilder::build(const ticl::Trackster &iData,
const uint8_t colorFactor = gradient_steps * normalized_energy;
eveCircle->SetFillColor(
TColor::GetColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]));
} else {
eveCircle->SetMainColor(item()->modelInfo(iIndex).displayProperties().color());
eveCircle->SetMainTransparency(item()->defaultDisplayProperties().transparency());
}

// seed and cluster position
const float crossScale = 1.0f + fmin(energy, 5.0f);
if (enablePositionLines_) {
TEveStraightLineSet *position_marker = new TEveStraightLineSet;
position_marker->SetLineWidth(2);
position_marker->SetLineColor(kWhite);
auto const &pos = layerCluster.position();
const float position_crossScale = crossScale * 0.5;
position_marker->AddLine(
pos.x() - position_crossScale, pos.y(), pos.z(), pos.x() + position_crossScale, pos.y(), pos.z());
position_marker->AddLine(
pos.x(), pos.y() - position_crossScale, pos.z(), pos.x(), pos.y() + position_crossScale, pos.z());

oItemHolder.AddElement(position_marker);
}
}

if (enablePositionLines_)
oItemHolder.AddElement(position_marker);

if (enableEdges_) {
auto &edges = trackster.edges();

TEveStraightLineSet *adjacent_marker = new TEveStraightLineSet;
adjacent_marker->SetLineWidth(2);
adjacent_marker->SetLineColor(kYellow);

TEveStraightLineSet *non_adjacent_marker = new TEveStraightLineSet;
non_adjacent_marker->SetLineWidth(2);
non_adjacent_marker->SetLineColor(kRed);

for (auto edge : edges) {
auto doublet = std::make_pair(layerClusters[edge[0]], layerClusters[edge[1]]);

int layerIn = item()->getGeom()->getParameters(doublet.first.seed())[1];
int layerOut = item()->getGeom()->getParameters(doublet.second.seed())[1];

const bool isAdjacent = (layerOut - layerIn) == 1;

TEveStraightLineSet *marker = new TEveStraightLineSet;
marker->SetLineWidth(2);
if (isAdjacent) {
marker->SetLineColor(kYellow);
} else {
marker->SetLineColor(kRed);
}
const bool isAdjacent = std::abs(layerOut - layerIn) == 1;

// draw 3D cross
if (layer_ == 0 || fabs(layerIn - layer_) == 0 || fabs(layerOut - layer_) == 0) {
marker->AddLine(doublet.first.x(),
doublet.first.y(),
doublet.first.z(),
doublet.second.x(),
doublet.second.y(),
doublet.second.z());
if (isAdjacent)
adjacent_marker->AddLine(doublet.first.x(),
doublet.first.y(),
doublet.first.z(),
doublet.second.x(),
doublet.second.y(),
doublet.second.z());
else
non_adjacent_marker->AddLine(doublet.first.x(),
doublet.first.y(),
doublet.first.z(),
doublet.second.x(),
doublet.second.y(),
doublet.second.z());
}

oItemHolder.AddElement(marker);
}
oItemHolder.AddElement(adjacent_marker);
oItemHolder.AddElement(non_adjacent_marker);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Fireworks/Core/src/FW3DViewBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void FW3DViewBase::updateClipPlanes(bool resetCamera) {
bmarker->SetMarkerSize(0.2);
for (int i = 0; i < 8; ++i)
bmarker->SetPoint(i, bbox[i].X(), bbox[i].Y(), bbox[i].Z());
eventScene()->AddElement(bmarker);
eventScene()->AddElement(bmarker);
*/

TGLCamera& cam = viewerGL()->CurrentCamera();
Expand Down Expand Up @@ -411,7 +411,7 @@ void FW3DViewBase::updateHGCalVisibility(bool) {
if (HGCalHSi) {
for (const auto& it : HGCalHSi->RefChildren()) {
std::string title(it->GetElementTitle());
int layer = stoi(title.substr(title.length() - 2)) + 28;
int layer = stoi(title.substr(title.length() - 2));
it->SetRnrState(layer >= r_lmin && layer <= r_lmax);
}
}
Expand All @@ -420,7 +420,7 @@ void FW3DViewBase::updateHGCalVisibility(bool) {
if (HGCalHSc) {
for (const auto& it : HGCalHSc->RefChildren()) {
std::string title(it->GetElementTitle());
int layer = stoi(title.substr(title.length() - 2)) + 28;
int layer = stoi(title.substr(title.length() - 2));
it->SetRnrState(layer >= r_lmin && layer <= r_lmax);
}
}
Expand Down
Loading

0 comments on commit 2cc775f

Please sign in to comment.