From 273b3f37081bcc61d1e9263a0fd9acb4311b8004 Mon Sep 17 00:00:00 2001 From: alja Date: Mon, 26 Jul 2021 13:42:37 -0700 Subject: [PATCH 1/3] Fix crash on edit of JET and MET after view destruction. --- Fireworks/Calo/plugins/FWJetProxyBuilder.cc | 53 ++++++++++----------- Fireworks/Calo/plugins/FWMETProxyBuilder.cc | 32 +++++-------- 2 files changed, 39 insertions(+), 46 deletions(-) diff --git a/Fireworks/Calo/plugins/FWJetProxyBuilder.cc b/Fireworks/Calo/plugins/FWJetProxyBuilder.cc index d5aa3cf6e0147..78e2a96e0a369 100644 --- a/Fireworks/Calo/plugins/FWJetProxyBuilder.cc +++ b/Fireworks/Calo/plugins/FWJetProxyBuilder.cc @@ -89,8 +89,6 @@ class FWJetProxyBuilder : public FWSimpleProxyBuilderTemplate { void setTextPos(fireworks::jetScaleMarker& s, const FWViewContext* vc, FWViewType::EType); TEveElementList* m_common; - - std::vector m_lines; }; //______________________________________________________________________________ @@ -134,9 +132,8 @@ void FWJetProxyBuilder::buildViewType(const reco::Jet& iData, // scale markers in projected views if (FWViewType::isProjected(type)) { - m_lines.push_back( - fireworks::jetScaleMarker(new TEveScalableStraightLineSet("jetline"), iData.et(), iData.energy(), vc)); - fireworks::jetScaleMarker& markers = m_lines.back(); + fireworks::jetScaleMarker markers(new TEveScalableStraightLineSet("jetline"), iData.et(), iData.energy(), vc); + float size = 1.f; // values are saved in scale double theta = iData.theta(); @@ -190,34 +187,13 @@ void FWJetProxyBuilder::localModelChanges(const FWModelId& iId, FWViewType::EType viewType, const FWViewContext* vc) { increaseComponentTransparency(iId.index(), iCompound, "TEveJetCone", 80); - - for (Lines_t::iterator i = m_lines.begin(); i != m_lines.end(); ++i) { - TEveStraightLineSetProjected* projLineSet = (TEveStraightLineSetProjected*)(*(*i).m_ls->BeginProjecteds()); - if (projLineSet) - projLineSet->UpdateProjection(); - } } void FWJetProxyBuilder::cleanLocal() { - m_lines.clear(); m_common->DestroyElements(); } -void FWJetProxyBuilder::scaleProduct(TEveElementList* parent, FWViewType::EType type, const FWViewContext* vc) { - for (Lines_t::iterator i = m_lines.begin(); i != m_lines.end(); ++i) { - if (vc == (*i).m_vc) { - float value = vc->getEnergyScale()->getPlotEt() ? (*i).m_et : (*i).m_energy; - - (*i).m_ls->SetScale(vc->getEnergyScale()->getScaleFactor3D() * value); - if ((*i).m_text) { - (*i).m_text->SetText(Form("%.1f", value)); - setTextPos(*i, vc, type); - } - TEveStraightLineSetProjected* projLineSet = (TEveStraightLineSetProjected*)(*(*i).m_ls->BeginProjecteds()); - projLineSet->UpdateProjection(); - } - } - +void FWJetProxyBuilder::scaleProduct(TEveElementList* product, FWViewType::EType viewType, const FWViewContext* vc) { // move jets to eventCenter fireworks::Context* contextGl = fireworks::Context::getInstance(); TEveVector cv; @@ -228,6 +204,29 @@ void FWJetProxyBuilder::scaleProduct(TEveElementList* parent, FWViewType::EType cone->SetApex(cv); } } + + // loop compounds in projected product + int idx = 0; + for (auto& c : product->RefChildren()) { + TEveElement* parent = c; + // check the compound has more than one element (the first one is jet) + if (parent->NumChildren() > 1) { + auto compIt = parent->BeginChildren(); + compIt++; + TEveScalableStraightLineSet* lineSet = dynamic_cast(*compIt); + if (lineSet) { + // compund index in the product is an index of model data in the collection + const void* modelData = item()->modelData(idx); + const reco::Jet* jet = (const reco::Jet*)(modelData); + float value = vc->getEnergyScale()->getPlotEt() ? jet->et() : jet->energy(); + lineSet->SetScale(vc->getEnergyScale()->getScaleFactor3D() * value); + for (TEveProjectable::ProjList_i j = lineSet->BeginProjecteds(); j != lineSet->EndProjecteds(); ++j) { + (*j)->UpdateProjection(); + } + } + } + idx++; + } } void FWJetProxyBuilder::setTextPos(fireworks::jetScaleMarker& s, const FWViewContext* vc, FWViewType::EType type) { diff --git a/Fireworks/Calo/plugins/FWMETProxyBuilder.cc b/Fireworks/Calo/plugins/FWMETProxyBuilder.cc index 6e051098fc7c6..64cb977d2a8a7 100644 --- a/Fireworks/Calo/plugins/FWMETProxyBuilder.cc +++ b/Fireworks/Calo/plugins/FWMETProxyBuilder.cc @@ -45,8 +45,6 @@ class FWMETProxyBuilder : public FWSimpleProxyBuilderTemplate { void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc) override; - void cleanLocal() override { m_lines.clear(); } - REGISTER_PROXYBUILDER_METHODS(); private: @@ -59,27 +57,24 @@ class FWMETProxyBuilder : public FWSimpleProxyBuilderTemplate { TEveElement& oItemHolder, FWViewType::EType type, const FWViewContext*) override; - - std::vector m_lines; }; -void FWMETProxyBuilder::scaleProduct(TEveElementList* parent, FWViewType::EType type, const FWViewContext* vc) { - typedef std::vector Lines_t; - FWViewEnergyScale* caloScale = vc->getEnergyScale(); - - // printf("MET %s %p -> %f\n", item()->name().c_str(), vc, caloScale->getScaleFactor3D() ); - for (Lines_t::iterator i = m_lines.begin(); i != m_lines.end(); ++i) { - if (vc == (*i).m_vc) { - // printf("lineset %s %p val %f ...%f\n", item()->name().c_str(), (*i).m_ls , (*i).m_et, caloScale->getScaleFactor3D()*(*i).m_et); - float value = caloScale->getPlotEt() ? (*i).m_et : (*i).m_energy; - - (*i).m_ls->SetScale(caloScale->getScaleFactor3D() * value); - - TEveProjectable* pable = static_cast((*i).m_ls); - for (TEveProjectable::ProjList_i j = pable->BeginProjecteds(); j != pable->EndProjecteds(); ++j) { +void FWMETProxyBuilder::scaleProduct(TEveElementList* product, FWViewType::EType type, const FWViewContext* vc) { + int idx = 0; + for (auto& c : product->RefChildren()) { + // line set element is added at the end of the buildViewType function, therefore last child + TEveScalableStraightLineSet* lineSet = dynamic_cast(c->LastChild()); + if (lineSet) { + // compund index in the product is an index of model data in the collection + const void* modelData = item()->modelData(idx); + const reco::MET* met = (const reco::MET*)(modelData); + float value = vc->getEnergyScale()->getPlotEt() ? met->et() : met->energy(); + lineSet->SetScale(vc->getEnergyScale()->getScaleFactor3D() * value); + for (TEveProjectable::ProjList_i j = lineSet->BeginProjecteds(); j != lineSet->EndProjecteds(); ++j) { (*j)->UpdateProjection(); } } + idx++; } } @@ -159,7 +154,6 @@ void FWMETProxyBuilder::buildViewType(const reco::MET& met, setupAddElement(marker, &oItemHolder); // printf("add line %s %f %f .... eta %f theta %f\n", item()->name().c_str(), met.et(), met.energy(), met.eta(), met.theta()); - m_lines.push_back(fireworks::scaleMarker(marker, met.et(), met.energy(), vc)); // register for scales context().voteMaxEtAndEnergy(met.et(), met.energy()); } From 9b4704a5800714f6b209d578cb6984e774333d0f Mon Sep 17 00:00:00 2001 From: alja Date: Tue, 27 Jul 2021 12:20:32 -0700 Subject: [PATCH 2/3] Fix crash on edit of PFTau after view destruction --- .../Calo/interface/FWTauProxyBuilderBase.h | 1 - Fireworks/Calo/src/FWTauProxyBuilderBase.cc | 30 +++++++++++-------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Fireworks/Calo/interface/FWTauProxyBuilderBase.h b/Fireworks/Calo/interface/FWTauProxyBuilderBase.h index 950b980539ce4..0a27cc5552bdd 100644 --- a/Fireworks/Calo/interface/FWTauProxyBuilderBase.h +++ b/Fireworks/Calo/interface/FWTauProxyBuilderBase.h @@ -74,7 +74,6 @@ class FWTauProxyBuilderBase : public FWProxyBuilderBase { void addConstituentTracks(const reco::BaseTau& tau, class TEveElement* product); // Add leading Track void addLeadTrack(const reco::BaseTau& tau, class TEveElement* product); - std::vector m_lines; }; #endif diff --git a/Fireworks/Calo/src/FWTauProxyBuilderBase.cc b/Fireworks/Calo/src/FWTauProxyBuilderBase.cc index 3c679ace64198..b1a6c193464f4 100644 --- a/Fireworks/Calo/src/FWTauProxyBuilderBase.cc +++ b/Fireworks/Calo/src/FWTauProxyBuilderBase.cc @@ -101,7 +101,6 @@ void FWTauProxyBuilderBase::buildBaseTau(const reco::BaseTau& iTau, FWViewEnergyScale* caloScale = vc->getEnergyScale(); marker->SetScale(caloScale->getScaleFactor3D() * (caloScale->getPlotEt() ? iTau.et() : iTau.energy())); setupAddElement(marker, comp); - m_lines.push_back(fireworks::scaleMarker(marker, iTau.et(), iTau.energy(), vc)); context().voteMaxEtAndEnergy(iTau.et(), iTau.energy()); } else if (iJet) { @@ -152,20 +151,25 @@ void FWTauProxyBuilderBase::localModelChanges(const FWModelId& iId, increaseComponentTransparency(iId.index(), iCompound, "TEveJetCone", 80); } -void FWTauProxyBuilderBase::scaleProduct(TEveElementList* parent, FWViewType::EType viewType, const FWViewContext* vc) { - if (FWViewType::isProjected(viewType)) { - typedef std::vector Lines_t; - FWViewEnergyScale* caloScale = vc->getEnergyScale(); - // printf("%p -> %f\n", this,caloScale->getValToHeight() ); - for (Lines_t::iterator i = m_lines.begin(); i != m_lines.end(); ++i) { - if (vc == (*i).m_vc) { - float value = caloScale->getPlotEt() ? (*i).m_et : (*i).m_energy; - (*i).m_ls->SetScale(caloScale->getScaleFactor3D() * value); - TEveProjected* proj = *(*i).m_ls->BeginProjecteds(); - proj->UpdateProjection(); +void FWTauProxyBuilderBase::scaleProduct(TEveElementList* product, FWViewType::EType viewType, const FWViewContext* vc) { + int idx = 0; + for (auto& c : product->RefChildren()) { + // check the compound has more than one element (the first one is jet) + for (auto& compChld : c->RefChildren()){ + TEveScalableStraightLineSet* lineSet = dynamic_cast(compChld); + if (lineSet) { + // compund index in the product is an index of model data in the collection + const void* modelData = item()->modelData(idx); + const reco::BaseTau* ptr = (const reco::BaseTau*)(modelData); + float value = vc->getEnergyScale()->getPlotEt() ? ptr->et() : ptr->energy(); + lineSet->SetScale(vc->getEnergyScale()->getScaleFactor3D() * value); + for (TEveProjectable::ProjList_i j = lineSet->BeginProjecteds(); j != lineSet->EndProjecteds(); ++j) { + (*j)->UpdateProjection(); + } } } + idx++; } } -void FWTauProxyBuilderBase::cleanLocal() { m_lines.clear(); } +void FWTauProxyBuilderBase::cleanLocal() { } From 7eb445b51ae725b1016757862f5c64d5e9d1af31 Mon Sep 17 00:00:00 2001 From: alja Date: Wed, 28 Jul 2021 12:48:23 -0700 Subject: [PATCH 3/3] code-format --- Fireworks/Calo/plugins/FWJetProxyBuilder.cc | 5 +---- Fireworks/Calo/src/FWTauProxyBuilderBase.cc | 8 +++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Fireworks/Calo/plugins/FWJetProxyBuilder.cc b/Fireworks/Calo/plugins/FWJetProxyBuilder.cc index 78e2a96e0a369..fd8e968cfca38 100644 --- a/Fireworks/Calo/plugins/FWJetProxyBuilder.cc +++ b/Fireworks/Calo/plugins/FWJetProxyBuilder.cc @@ -134,7 +134,6 @@ void FWJetProxyBuilder::buildViewType(const reco::Jet& iData, if (FWViewType::isProjected(type)) { fireworks::jetScaleMarker markers(new TEveScalableStraightLineSet("jetline"), iData.et(), iData.energy(), vc); - float size = 1.f; // values are saved in scale double theta = iData.theta(); double phi = iData.phi(); @@ -189,9 +188,7 @@ void FWJetProxyBuilder::localModelChanges(const FWModelId& iId, increaseComponentTransparency(iId.index(), iCompound, "TEveJetCone", 80); } -void FWJetProxyBuilder::cleanLocal() { - m_common->DestroyElements(); -} +void FWJetProxyBuilder::cleanLocal() { m_common->DestroyElements(); } void FWJetProxyBuilder::scaleProduct(TEveElementList* product, FWViewType::EType viewType, const FWViewContext* vc) { // move jets to eventCenter diff --git a/Fireworks/Calo/src/FWTauProxyBuilderBase.cc b/Fireworks/Calo/src/FWTauProxyBuilderBase.cc index b1a6c193464f4..71ef591c0dbb4 100644 --- a/Fireworks/Calo/src/FWTauProxyBuilderBase.cc +++ b/Fireworks/Calo/src/FWTauProxyBuilderBase.cc @@ -151,11 +151,13 @@ void FWTauProxyBuilderBase::localModelChanges(const FWModelId& iId, increaseComponentTransparency(iId.index(), iCompound, "TEveJetCone", 80); } -void FWTauProxyBuilderBase::scaleProduct(TEveElementList* product, FWViewType::EType viewType, const FWViewContext* vc) { +void FWTauProxyBuilderBase::scaleProduct(TEveElementList* product, + FWViewType::EType viewType, + const FWViewContext* vc) { int idx = 0; for (auto& c : product->RefChildren()) { // check the compound has more than one element (the first one is jet) - for (auto& compChld : c->RefChildren()){ + for (auto& compChld : c->RefChildren()) { TEveScalableStraightLineSet* lineSet = dynamic_cast(compChld); if (lineSet) { // compund index in the product is an index of model data in the collection @@ -172,4 +174,4 @@ void FWTauProxyBuilderBase::scaleProduct(TEveElementList* product, FWViewType::E } } -void FWTauProxyBuilderBase::cleanLocal() { } +void FWTauProxyBuilderBase::cleanLocal() {}