diff --git a/Fireworks/Calo/interface/FWTauProxyBuilderBase.h b/Fireworks/Calo/interface/FWTauProxyBuilderBase.h index 27f34622d0143..0a27cc5552bdd 100644 --- a/Fireworks/Calo/interface/FWTauProxyBuilderBase.h +++ b/Fireworks/Calo/interface/FWTauProxyBuilderBase.h @@ -5,7 +5,7 @@ // // Package: Calo // Class : FWTauProxyBuilderBase -// +// /**\class FWTauProxyBuilderBase FWTauProxyBuilderBase.h Fireworks/Calo/interface/FWTauProxyBuilderBase.h Description: [one line class summary] @@ -15,7 +15,7 @@ */ // -// Original Author: Alja Mrak-Tadel +// Original Author: Alja Mrak-Tadel // Created: Thu Oct 21 20:40:32 CEST 2010 // @@ -27,52 +27,53 @@ class TEveScalableStraightLineSet; class FWViewContext; -namespace reco -{ -class Jet; -class BaseTau; -} +namespace reco { + class Jet; + class BaseTau; +} // namespace reco -namespace fireworks -{ -class Context; +namespace fireworks { + class Context; } - -class FWTauProxyBuilderBase : public FWProxyBuilderBase -{ +class FWTauProxyBuilderBase : public FWProxyBuilderBase { public: - FWTauProxyBuilderBase(); - ~FWTauProxyBuilderBase() override; - - bool haveSingleProduct() const override { return false; } - bool havePerViewProduct(FWViewType::EType) const override { return true; } - void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc) override; - void cleanLocal() override; - - void setItem(const FWEventItem* iItem) override; - + FWTauProxyBuilderBase(); + ~FWTauProxyBuilderBase() override; + + bool haveSingleProduct() const override { return false; } + bool havePerViewProduct(FWViewType::EType) const override { return true; } + void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc) override; + void cleanLocal() override; + + void setItem(const FWEventItem* iItem) override; + protected: - float m_minTheta; - float m_maxTheta; - std::vector m_phis; - void buildBaseTau( const reco::BaseTau& iTau, const reco::Jet* iJet, TEveElement* comp, FWViewType::EType type, const FWViewContext* vc); + float m_minTheta; + float m_maxTheta; + std::vector m_phis; + void buildBaseTau(const reco::BaseTau& iTau, + const reco::Jet* iJet, + TEveElement* comp, + FWViewType::EType type, + const FWViewContext* vc); + + void localModelChanges(const FWModelId& iId, + TEveElement* iCompound, + FWViewType::EType viewType, + const FWViewContext* vc) override; - void localModelChanges(const FWModelId& iId, TEveElement* iCompound, - FWViewType::EType viewType, const FWViewContext* vc) override; private: - FWTauProxyBuilderBase(const FWTauProxyBuilderBase&) = delete; // stop default + FWTauProxyBuilderBase(const FWTauProxyBuilderBase&) = delete; // stop default - const FWTauProxyBuilderBase& operator=(const FWTauProxyBuilderBase&) = delete; // stop default + const FWTauProxyBuilderBase& operator=(const FWTauProxyBuilderBase&) = delete; // stop default - // ---------- member data -------------------------------- - // Add Tracks which passed quality cuts and - // are inside a tracker signal cone around leading Track - 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; + // ---------- member data -------------------------------- + // Add Tracks which passed quality cuts and + // are inside a tracker signal cone around leading Track + void addConstituentTracks(const reco::BaseTau& tau, class TEveElement* product); + // Add leading Track + void addLeadTrack(const reco::BaseTau& tau, class TEveElement* product); }; - #endif diff --git a/Fireworks/Calo/plugins/FWJetProxyBuilder.cc b/Fireworks/Calo/plugins/FWJetProxyBuilder.cc index 1fda3eeaed405..78e2a96e0a369 100644 --- a/Fireworks/Calo/plugins/FWJetProxyBuilder.cc +++ b/Fireworks/Calo/plugins/FWJetProxyBuilder.cc @@ -29,258 +29,231 @@ #include "DataFormats/JetReco/interface/Jet.h" - namespace fireworks { -struct jetScaleMarker : public scaleMarker { - jetScaleMarker(TEveScalableStraightLineSet* ls, float et, float e, const FWViewContext* vc): - scaleMarker(ls, et, e, vc) , m_text(nullptr) {} - - FWEveText* m_text; -}; -} + struct jetScaleMarker : public scaleMarker { + jetScaleMarker(TEveScalableStraightLineSet* ls, float et, float e, const FWViewContext* vc) + : scaleMarker(ls, et, e, vc), m_text(nullptr) {} + + FWEveText* m_text; + }; +} // namespace fireworks static const std::string kJetLabelsRhoPhiOn("Draw Labels in RhoPhi View"); static const std::string kJetLabelsRhoZOn("Draw Labels in RhoZ View"); static const std::string kJetOffset("Label Offset"); static const std::string kJetApexBeamSpot("Place Apex In BeamSpot"); - -class FWJetProxyBuilder : public FWSimpleProxyBuilderTemplate -{ +class FWJetProxyBuilder : public FWSimpleProxyBuilderTemplate { public: - FWJetProxyBuilder(); - ~FWJetProxyBuilder() override; + FWJetProxyBuilder(); + ~FWJetProxyBuilder() override; - bool havePerViewProduct(FWViewType::EType) const override { return true; } - bool haveSingleProduct() const override { return false; } // different view types - void cleanLocal() override; + bool havePerViewProduct(FWViewType::EType) const override { return true; } + bool haveSingleProduct() const override { return false; } // different view types + void cleanLocal() override; - void setItem(const FWEventItem* iItem) override - { - FWProxyBuilderBase::setItem(iItem); - if (iItem) { + void setItem(const FWEventItem* iItem) override { + FWProxyBuilderBase::setItem(iItem); + if (iItem) { iItem->getConfig()->assertParam(kJetLabelsRhoPhiOn, false); iItem->getConfig()->assertParam(kJetLabelsRhoZOn, false); iItem->getConfig()->assertParam(kJetOffset, 2.1, 1.0, 5.0); - } - } + } + } - REGISTER_PROXYBUILDER_METHODS(); - -protected: - using FWSimpleProxyBuilderTemplate::buildViewType; - void buildViewType(const reco::Jet& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*) override; + REGISTER_PROXYBUILDER_METHODS(); +protected: + using FWSimpleProxyBuilderTemplate::buildViewType; + void buildViewType(const reco::Jet& iData, + unsigned int iIndex, + TEveElement& oItemHolder, + FWViewType::EType type, + const FWViewContext*) override; - void localModelChanges(const FWModelId& iId, TEveElement* iCompound, - FWViewType::EType viewType, const FWViewContext* vc) override; + void localModelChanges(const FWModelId& iId, + TEveElement* iCompound, + FWViewType::EType viewType, + const FWViewContext* vc) override; - void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc) override; + void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc) override; private: - typedef std::vector Lines_t; - - FWJetProxyBuilder( const FWJetProxyBuilder& ) = delete; // stop default - const FWJetProxyBuilder& operator=( const FWJetProxyBuilder& ) = delete; // stop default + typedef std::vector Lines_t; - TEveElementList* requestCommon(); - void setTextPos(fireworks::jetScaleMarker& s, const FWViewContext* vc, FWViewType::EType); + FWJetProxyBuilder(const FWJetProxyBuilder&) = delete; // stop default + const FWJetProxyBuilder& operator=(const FWJetProxyBuilder&) = delete; // stop default - TEveElementList* m_common; + TEveElementList* requestCommon(); + void setTextPos(fireworks::jetScaleMarker& s, const FWViewContext* vc, FWViewType::EType); - std::vector m_lines; + TEveElementList* m_common; }; - //______________________________________________________________________________ -FWJetProxyBuilder::FWJetProxyBuilder(): - m_common(nullptr) -{ - m_common = new TEveElementList( "common electron scene" ); - m_common->IncDenyDestroy(); +FWJetProxyBuilder::FWJetProxyBuilder() : m_common(nullptr) { + m_common = new TEveElementList("common electron scene"); + m_common->IncDenyDestroy(); } -FWJetProxyBuilder::~FWJetProxyBuilder() -{ - m_common->DecDenyDestroy(); -} +FWJetProxyBuilder::~FWJetProxyBuilder() { m_common->DecDenyDestroy(); } -TEveElementList* -FWJetProxyBuilder::requestCommon() -{ - if( m_common->HasChildren() == false ) - { - for (int i = 0; i < static_cast(item()->size()); ++i) - { - TEveJetCone* cone = fireworks::makeEveJetCone(modelData(i), context()); - - cone->SetFillColor(item()->defaultDisplayProperties().color()); - cone->SetLineColor(item()->defaultDisplayProperties().color()); - - m_common->AddElement(cone); - } - } - return m_common; +TEveElementList* FWJetProxyBuilder::requestCommon() { + if (m_common->HasChildren() == false) { + for (int i = 0; i < static_cast(item()->size()); ++i) { + TEveJetCone* cone = fireworks::makeEveJetCone(modelData(i), context()); + + cone->SetFillColor(item()->defaultDisplayProperties().color()); + cone->SetLineColor(item()->defaultDisplayProperties().color()); + + m_common->AddElement(cone); + } + } + return m_common; } -void -FWJetProxyBuilder::buildViewType(const reco::Jet& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext* vc) -{ - // add cone from shared pool - TEveElementList* cones = requestCommon(); - TEveElement::List_i coneIt = cones->BeginChildren(); - std::advance(coneIt, iIndex); - - const FWDisplayProperties &dp = item()->defaultDisplayProperties(); - setupAddElement( *coneIt, &oItemHolder ); - (*coneIt)->SetMainTransparency(TMath::Min(100, 80 + dp.transparency() / 5)); - - TEveVector p1; - TEveVector p2; - - // 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(); - - float size = 1.f; // values are saved in scale - double theta = iData.theta(); - double phi = iData.phi(); - - if ( type == FWViewType::kRhoZ ) - { - static const float_t offr = 4; - float r_ecal = context().caloR1() + offr; - float z_ecal = context().caloZ1() + offr/tan(context().caloTransAngle()); - double r(0); - if ( theta < context().caloTransAngle() || M_PI-theta < context().caloTransAngle()) - { - z_ecal = context().caloZ2() + offr/tan(context().caloTransAngle()); - r = z_ecal/fabs(cos(theta)); - } - else - { - r = r_ecal/sin(theta); - } - - p1.Set( 0., (phi>0 ? r*fabs(sin(theta)) : -r*fabs(sin(theta))), r*cos(theta)); - p2.Set( 0., (phi>0 ? (r+size)*fabs(sin(theta)) : -(r+size)*fabs(sin(theta))), (r+size)*cos(theta) ); - } - else - { - float ecalR = context().caloR1() + 4; - p1.Set(ecalR*cos(phi), ecalR*sin(phi), 0); - p2.Set((ecalR+size)*cos(phi), (ecalR+size)*sin(phi), 0); +void FWJetProxyBuilder::buildViewType(const reco::Jet& iData, + unsigned int iIndex, + TEveElement& oItemHolder, + FWViewType::EType type, + const FWViewContext* vc) { + // add cone from shared pool + TEveElementList* cones = requestCommon(); + TEveElement::List_i coneIt = cones->BeginChildren(); + std::advance(coneIt, iIndex); + + const FWDisplayProperties& dp = item()->defaultDisplayProperties(); + setupAddElement(*coneIt, &oItemHolder); + (*coneIt)->SetMainTransparency(TMath::Min(100, 80 + dp.transparency() / 5)); + + TEveVector p1; + TEveVector p2; + + // scale markers in projected views + 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(); + + if (type == FWViewType::kRhoZ) { + static const float_t offr = 4; + float r_ecal = context().caloR1() + offr; + float z_ecal = context().caloZ1() + offr / tan(context().caloTransAngle()); + double r(0); + if (theta < context().caloTransAngle() || M_PI - theta < context().caloTransAngle()) { + z_ecal = context().caloZ2() + offr / tan(context().caloTransAngle()); + r = z_ecal / fabs(cos(theta)); + } else { + r = r_ecal / sin(theta); } - - - markers.m_ls->SetScaleCenter(p1.fX, p1.fY, p1.fZ); - markers.m_ls->AddLine(p1, p2); - - markers.m_ls->SetLineWidth(4); - markers.m_ls->SetLineColor(dp.color()); - FWViewEnergyScale* caloScale = vc->getEnergyScale(); - markers.m_ls->SetScale(caloScale->getScaleFactor3D()*(caloScale->getPlotEt() ? iData.et() : iData.energy())); - - if ((type == FWViewType::kRhoZ && item()->getConfig()->value(kJetLabelsRhoZOn))|| - (type == FWViewType::kRhoPhi && item()->getConfig()->value(kJetLabelsRhoPhiOn) ) ) - { - markers.m_text = new FWEveText(Form("%.1f", vc->getEnergyScale()->getPlotEt() ? iData.et() : iData.energy())); - markers.m_text->SetMainColor( item()->defaultDisplayProperties().color()); - setTextPos(markers, vc, type); - } - - markers.m_ls->SetMarkerColor(markers.m_ls->GetMainColor()); - setupAddElement( markers.m_ls, &oItemHolder ); - if (markers.m_text) setupAddElement( markers.m_text, &oItemHolder , false); - } - context().voteMaxEtAndEnergy(iData.et(), iData.energy()); - + p1.Set(0., (phi > 0 ? r * fabs(sin(theta)) : -r * fabs(sin(theta))), r * cos(theta)); + p2.Set(0., (phi > 0 ? (r + size) * fabs(sin(theta)) : -(r + size) * fabs(sin(theta))), (r + size) * cos(theta)); + } else { + float ecalR = context().caloR1() + 4; + p1.Set(ecalR * cos(phi), ecalR * sin(phi), 0); + p2.Set((ecalR + size) * cos(phi), (ecalR + size) * sin(phi), 0); + } + + markers.m_ls->SetScaleCenter(p1.fX, p1.fY, p1.fZ); + markers.m_ls->AddLine(p1, p2); + + markers.m_ls->SetLineWidth(4); + markers.m_ls->SetLineColor(dp.color()); + FWViewEnergyScale* caloScale = vc->getEnergyScale(); + markers.m_ls->SetScale(caloScale->getScaleFactor3D() * (caloScale->getPlotEt() ? iData.et() : iData.energy())); + + if ((type == FWViewType::kRhoZ && item()->getConfig()->value(kJetLabelsRhoZOn)) || + (type == FWViewType::kRhoPhi && item()->getConfig()->value(kJetLabelsRhoPhiOn))) { + markers.m_text = new FWEveText(Form("%.1f", vc->getEnergyScale()->getPlotEt() ? iData.et() : iData.energy())); + markers.m_text->SetMainColor(item()->defaultDisplayProperties().color()); + setTextPos(markers, vc, type); + } + + markers.m_ls->SetMarkerColor(markers.m_ls->GetMainColor()); + setupAddElement(markers.m_ls, &oItemHolder); + if (markers.m_text) + setupAddElement(markers.m_text, &oItemHolder, false); + } + context().voteMaxEtAndEnergy(iData.et(), iData.energy()); } -void -FWJetProxyBuilder::localModelChanges(const FWModelId& iId, TEveElement* iCompound, - 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::localModelChanges(const FWModelId& iId, + TEveElement* iCompound, + FWViewType::EType viewType, + const FWViewContext* vc) { + increaseComponentTransparency(iId.index(), iCompound, "TEveJetCone", 80); } - -void -FWJetProxyBuilder::cleanLocal() -{ - m_lines.clear(); - m_common->DestroyElements(); +void FWJetProxyBuilder::cleanLocal() { + 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; + contextGl->commonPrefs()->getEventCenter(cv.Arr()); + for (TEveElement::List_i i = m_common->BeginChildren(); i != m_common->EndChildren(); ++i) { + TEveJetCone* cone = dynamic_cast(*i); + if (cone) { + 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(); + } } - } - - // move jets to eventCenter - fireworks::Context* contextGl = fireworks::Context::getInstance(); - TEveVector cv; - contextGl->commonPrefs()->getEventCenter(cv.Arr()); - for (TEveElement::List_i i = m_common->BeginChildren(); i!= m_common->EndChildren(); ++ i) - { - TEveJetCone* cone = dynamic_cast(*i); - if (cone) { - cone->SetApex(cv); - } - } + } + idx++; + } } - -void FWJetProxyBuilder::setTextPos(fireworks::jetScaleMarker& s, const FWViewContext* vc, FWViewType::EType type) -{ - TEveChunkManager::iterator li( s.m_ls->GetLinePlex() ); - li.next(); - TEveStraightLineSet::Line_t &l = * ( TEveStraightLineSet::Line_t* ) li(); - TEveVector v(l.fV2[0] - l.fV1[0], l.fV2[1] - l.fV1[1], l.fV2[2] - l.fV1[2] ); - v.Normalize(); - - - double off = item()->getConfig()->value(kJetOffset) -1; - float value = vc->getEnergyScale()->getPlotEt() ? s.m_et : s.m_energy; - double trs = off * 130 * value/context().getMaxEnergyInEvent(vc->getEnergyScale()->getPlotEt()); - v *= trs; - - float x = l.fV1[0] + v[0]; - float y = l.fV1[1] + v[1]; - float z = l.fV1[2] + v[2]; - - s.m_text->m_offsetZ = value/context().getMaxEnergyInEvent(vc->getEnergyScale()->getPlotEt()); - s.m_text->RefMainTrans().SetPos(x, y, z); - if ((s.m_text)->BeginProjecteds() != (s.m_text)->EndProjecteds()) { - FWEveTextProjected* textProjected = (FWEveTextProjected*)(*(s.m_text)->BeginProjecteds()); - textProjected->UpdateProjection(); - } - +void FWJetProxyBuilder::setTextPos(fireworks::jetScaleMarker& s, const FWViewContext* vc, FWViewType::EType type) { + TEveChunkManager::iterator li(s.m_ls->GetLinePlex()); + li.next(); + TEveStraightLineSet::Line_t& l = *(TEveStraightLineSet::Line_t*)li(); + TEveVector v(l.fV2[0] - l.fV1[0], l.fV2[1] - l.fV1[1], l.fV2[2] - l.fV1[2]); + v.Normalize(); + + double off = item()->getConfig()->value(kJetOffset) - 1; + float value = vc->getEnergyScale()->getPlotEt() ? s.m_et : s.m_energy; + double trs = off * 130 * value / context().getMaxEnergyInEvent(vc->getEnergyScale()->getPlotEt()); + v *= trs; + + float x = l.fV1[0] + v[0]; + float y = l.fV1[1] + v[1]; + float z = l.fV1[2] + v[2]; + + s.m_text->m_offsetZ = value / context().getMaxEnergyInEvent(vc->getEnergyScale()->getPlotEt()); + s.m_text->RefMainTrans().SetPos(x, y, z); + if ((s.m_text)->BeginProjecteds() != (s.m_text)->EndProjecteds()) { + FWEveTextProjected* textProjected = (FWEveTextProjected*)(*(s.m_text)->BeginProjecteds()); + textProjected->UpdateProjection(); + } } -REGISTER_FWPROXYBUILDER( FWJetProxyBuilder, reco::Jet, "Jets", FWViewType::kAll3DBits | FWViewType::kAllRPZBits | FWViewType::kGlimpseBit); +REGISTER_FWPROXYBUILDER(FWJetProxyBuilder, + reco::Jet, + "Jets", + FWViewType::kAll3DBits | FWViewType::kAllRPZBits | FWViewType::kGlimpseBit); diff --git a/Fireworks/Calo/plugins/FWMETProxyBuilder.cc b/Fireworks/Calo/plugins/FWMETProxyBuilder.cc index e0139c72af85e..64cb977d2a8a7 100644 --- a/Fireworks/Calo/plugins/FWMETProxyBuilder.cc +++ b/Fireworks/Calo/plugins/FWMETProxyBuilder.cc @@ -12,6 +12,7 @@ // system include files #include "TEveGeoNode.h" +#include "TEveGeoShape.h" #include "TEveScalableStraightLineSet.h" #include "TGeoTube.h" #include "TMath.h" @@ -30,142 +31,131 @@ //////////////////////////////////////////////////////////////////////////////// // // RPZ proxy builder with shared MET shape -// +// //////////////////////////////////////////////////////////////////////////////// -class FWMETProxyBuilder : public FWSimpleProxyBuilderTemplate -{ +class FWMETProxyBuilder : public FWSimpleProxyBuilderTemplate { public: - FWMETProxyBuilder() {} - ~FWMETProxyBuilder() override {} + FWMETProxyBuilder() {} + ~FWMETProxyBuilder() override {} + + bool haveSingleProduct() const override { return false; } // use buildViewType instead of buildView - bool haveSingleProduct() const override { return false; } // use buildViewType instead of buildView + bool havePerViewProduct(FWViewType::EType) const override { return true; } // used energy scaling - bool havePerViewProduct(FWViewType::EType) const override { return true; } // used energy scaling - - void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc) override; - - void cleanLocal() override { m_lines.clear(); } + void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc) override; - REGISTER_PROXYBUILDER_METHODS(); + REGISTER_PROXYBUILDER_METHODS(); private: - - FWMETProxyBuilder( const FWMETProxyBuilder& ) = delete; // stop default - const FWMETProxyBuilder& operator=( const FWMETProxyBuilder& ) = delete; // stop default - - using FWSimpleProxyBuilderTemplate::buildViewType; - void buildViewType(const reco::MET& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*) override; - - std::vector m_lines; + FWMETProxyBuilder(const FWMETProxyBuilder&) = delete; // stop default + const FWMETProxyBuilder& operator=(const FWMETProxyBuilder&) = delete; // stop default + + using FWSimpleProxyBuilderTemplate::buildViewType; + void buildViewType(const reco::MET& iData, + unsigned int iIndex, + TEveElement& oItemHolder, + FWViewType::EType type, + const FWViewContext*) override; }; -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) - { - (*j)->UpdateProjection(); - } +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++; + } } - -void -FWMETProxyBuilder::buildViewType(const reco::MET& met, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext* vc) -{ - using namespace TMath; - double phi = met.phi(); - double theta = met.theta(); - double size = 1.f; - - FWViewEnergyScale* caloScale = vc->getEnergyScale(); - - TEveScalableStraightLineSet* marker = new TEveScalableStraightLineSet( "MET marker" ); - marker->SetLineWidth( 2 ); - - - - if ( type == FWViewType::kRhoZ ) - { - // body - double r0; - if (TMath::Abs(met.eta()) < context().caloTransEta()) - { - r0 = context().caloR1()/sin(theta); - } - else - { - r0 = context().caloZ1()/fabs(cos(theta)); - } - marker->SetScaleCenter( 0., Sign(r0*sin(theta), phi), r0*cos(theta) ); - double r1 = r0 + 1; - marker->AddLine( 0., Sign(r0*sin(theta), phi), r0*cos(theta), - 0., Sign(r1*sin(theta), phi), r1*cos(theta) ); - - // arrow pointer - double r2 = r1 - 0.1; - double dy = 0.05*size; - marker->AddLine( 0., Sign(r2*sin(theta) + dy*cos(theta), phi), r2*cos(theta) -dy*sin(theta), - 0., Sign(r1*sin(theta), phi), r1*cos(theta) ); - dy = -dy; - marker->AddLine( 0., Sign(r2*sin(theta) + dy*cos(theta), phi), r2*cos(theta) -dy*sin(theta), - 0., Sign(r1*sin(theta), phi), r1*cos(theta) ); - - // segment - fireworks::addRhoZEnergyProjection( this, &oItemHolder, context().caloR1() -1, context().caloZ1() -1, - theta - 0.04, theta + 0.04, - phi ); - } - else - { - // body - double r0 = context().caloR1(); - double r1 = r0 + 1; - marker->SetScaleCenter( r0*cos(phi), r0*sin(phi), 0 ); - marker->AddLine( r0*cos(phi), r0*sin(phi), 0, - r1*cos(phi), r1*sin(phi), 0); - - // arrow pointer, xy rotate offset point .. - double r2 = r1 - 0.1; - double dy = 0.05*size; - - marker->AddLine( r2*cos(phi) -dy*sin(phi), r2*sin(phi) + dy*cos(phi), 0, - r1*cos(phi), r1*sin(phi), 0); - dy = -dy; - marker->AddLine( r2*cos(phi) -dy*sin(phi), r2*sin(phi) + dy*cos(phi), 0, - r1*cos(phi), r1*sin(phi), 0); - - // segment - double min_phi = phi-M_PI/36/2; - double max_phi = phi+M_PI/36/2; - TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur()); - TEveGeoShape *element = fireworks::getShape( "spread", new TGeoTubeSeg( r0 - 2, r0, 1, min_phi*180/M_PI, max_phi*180/M_PI ), 0 ); - element->SetPickable( kTRUE ); - setupAddElement( element, &oItemHolder ); - } - - marker->SetScale(caloScale->getScaleFactor3D()*(caloScale->getPlotEt() ? met.et() : met.energy())); - 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()); + +void FWMETProxyBuilder::buildViewType(const reco::MET& met, + unsigned int iIndex, + TEveElement& oItemHolder, + FWViewType::EType type, + const FWViewContext* vc) { + using namespace TMath; + double phi = met.phi(); + double theta = met.theta(); + double size = 1.f; + + FWViewEnergyScale* caloScale = vc->getEnergyScale(); + + TEveScalableStraightLineSet* marker = new TEveScalableStraightLineSet("MET marker"); + marker->SetLineWidth(2); + + if (type == FWViewType::kRhoZ) { + // body + double r0; + if (TMath::Abs(met.eta()) < context().caloTransEta()) { + r0 = context().caloR1() / sin(theta); + } else { + r0 = context().caloZ1() / fabs(cos(theta)); + } + marker->SetScaleCenter(0., Sign(r0 * sin(theta), phi), r0 * cos(theta)); + double r1 = r0 + 1; + marker->AddLine(0., Sign(r0 * sin(theta), phi), r0 * cos(theta), 0., Sign(r1 * sin(theta), phi), r1 * cos(theta)); + + // arrow pointer + double r2 = r1 - 0.1; + double dy = 0.05 * size; + marker->AddLine(0., + Sign(r2 * sin(theta) + dy * cos(theta), phi), + r2 * cos(theta) - dy * sin(theta), + 0., + Sign(r1 * sin(theta), phi), + r1 * cos(theta)); + dy = -dy; + marker->AddLine(0., + Sign(r2 * sin(theta) + dy * cos(theta), phi), + r2 * cos(theta) - dy * sin(theta), + 0., + Sign(r1 * sin(theta), phi), + r1 * cos(theta)); + + // segment + fireworks::addRhoZEnergyProjection( + this, &oItemHolder, context().caloR1() - 1, context().caloZ1() - 1, theta - 0.04, theta + 0.04, phi); + } else { + // body + double r0 = context().caloR1(); + double r1 = r0 + 1; + marker->SetScaleCenter(r0 * cos(phi), r0 * sin(phi), 0); + marker->AddLine(r0 * cos(phi), r0 * sin(phi), 0, r1 * cos(phi), r1 * sin(phi), 0); + + // arrow pointer, xy rotate offset point .. + double r2 = r1 - 0.1; + double dy = 0.05 * size; + + marker->AddLine(r2 * cos(phi) - dy * sin(phi), r2 * sin(phi) + dy * cos(phi), 0, r1 * cos(phi), r1 * sin(phi), 0); + dy = -dy; + marker->AddLine(r2 * cos(phi) - dy * sin(phi), r2 * sin(phi) + dy * cos(phi), 0, r1 * cos(phi), r1 * sin(phi), 0); + + // segment + double min_phi = phi - M_PI / 36 / 2; + double max_phi = phi + M_PI / 36 / 2; + TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur()); + TEveGeoShape* element = + fireworks::getShape("spread", new TGeoTubeSeg(r0 - 2, r0, 1, min_phi * 180 / M_PI, max_phi * 180 / M_PI), 0); + element->SetPickable(kTRUE); + setupAddElement(element, &oItemHolder); + } + + marker->SetScale(caloScale->getScaleFactor3D() * (caloScale->getPlotEt() ? met.et() : met.energy())); + 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()); + + context().voteMaxEtAndEnergy(met.et(), met.energy()); } -REGISTER_FWPROXYBUILDER( FWMETProxyBuilder, reco::MET, "recoMET", FWViewType::kAllRPZBits ); +REGISTER_FWPROXYBUILDER(FWMETProxyBuilder, reco::MET, "recoMET", FWViewType::kAllRPZBits); diff --git a/Fireworks/Calo/src/FWTauProxyBuilderBase.cc b/Fireworks/Calo/src/FWTauProxyBuilderBase.cc index 866127baea02b..861edf98a4a4d 100644 --- a/Fireworks/Calo/src/FWTauProxyBuilderBase.cc +++ b/Fireworks/Calo/src/FWTauProxyBuilderBase.cc @@ -2,7 +2,7 @@ // // Package: Calo // Class : FWTauProxyBuilderBase -// +// // Implementation: // [Notes on implementation] // @@ -16,6 +16,7 @@ #include "TGeoTube.h" #include "TEveJetCone.h" #include "TEveGeoNode.h" +#include "TEveGeoShape.h" #include "TEveScalableStraightLineSet.h" #include "TEveTrack.h" @@ -35,166 +36,145 @@ #include "DataFormats/TauReco/interface/BaseTau.h" #include "DataFormats/TrackReco/interface/Track.h" - static const std::string kTauApexBeamSpot("Place Apex In BeamSpot"); -FWTauProxyBuilderBase::FWTauProxyBuilderBase(): - m_minTheta(0), - m_maxTheta(0) -{ -} - -FWTauProxyBuilderBase::~FWTauProxyBuilderBase() -{ -} +FWTauProxyBuilderBase::FWTauProxyBuilderBase() : m_minTheta(0), m_maxTheta(0) {} - -void FWTauProxyBuilderBase::setItem(const FWEventItem* iItem) -{FWProxyBuilderBase::setItem(iItem); - if (iItem) { - iItem->getConfig()->assertParam(kTauApexBeamSpot, false); - } +FWTauProxyBuilderBase::~FWTauProxyBuilderBase() {} +void FWTauProxyBuilderBase::setItem(const FWEventItem* iItem) { + FWProxyBuilderBase::setItem(iItem); + if (iItem) { + iItem->getConfig()->assertParam(kTauApexBeamSpot, false); + } } - -void -FWTauProxyBuilderBase::buildBaseTau( const reco::BaseTau& iTau, const reco::Jet* iJet, TEveElement* comp, FWViewType::EType type, const FWViewContext* vc) -{ - // track - addLeadTrack( iTau, comp ); - addConstituentTracks( iTau, comp ); - - // projected markers - if (FWViewType::isProjected(type)) - { - double phi = iTau.phi(); - double theta = iTau.theta(); - double size = 1; - - bool barrel = (theta< context().caloTransAngle() || theta > (TMath::Pi() - context().caloTransAngle())); - float ecalR = barrel ? context().caloR1() : context().caloR2(); - float ecalZ = barrel ? context().caloZ1() : context().caloZ2(); - - TEveScalableStraightLineSet* marker = new TEveScalableStraightLineSet( "energy" ); - - if( type == FWViewType::kRhoZ ) - { - double r(0); - ( theta < context().caloTransAngle() || M_PI-theta < context().caloTransAngle()) ? - r = ecalZ/fabs(cos(theta)) : - r = ecalR/sin(theta); - - fireworks::addRhoZEnergyProjection( this, comp, ecalR, ecalZ, m_minTheta-0.003, m_maxTheta+0.003, phi); - - marker->SetScaleCenter( 0., (phi>0 ? r*fabs(sin(theta)) : -r*fabs(sin(theta))), r*cos(theta) ); - marker->AddLine(0., (phi>0 ? r*fabs(sin(theta)) : -r*fabs(sin(theta))), r*cos(theta), - 0., (phi>0 ? (r+size)*fabs(sin(theta)) : -(r+size)*fabs(sin(theta))), (r+size)*cos(theta) ); - } - else - { - std::pair phiRange = fireworks::getPhiRange( m_phis, phi ); - double min_phi = phiRange.first-M_PI/36/2; - double max_phi = phiRange.second+M_PI/36/2; - if( fabs(phiRange.first-phiRange.first)<1e-3 ) { - min_phi = phi-M_PI/36/2; - max_phi = phi+M_PI/36/2; - } - TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur()); - TGeoBBox *sc_box = new TGeoTubeSeg(ecalR - 1, ecalR + 1, 1, min_phi * 180 / M_PI, max_phi * 180 / M_PI); - TEveGeoShape *shape = fireworks::getShape( "spread", sc_box, item()->defaultDisplayProperties().color() ); - shape->SetPickable(kTRUE); - setupAddElement( shape, comp ); - - marker->SetScaleCenter(ecalR*cos(phi), ecalR*sin(phi), 0); - marker->AddLine( ecalR*cos( phi ), ecalR*sin( phi ), 0, - ( ecalR+size )*cos( phi ), ( ecalR+size )*sin( phi ), 0); - } - marker->SetLineWidth(4); - 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) - { - // jet - TEveJetCone* cone = fireworks::makeEveJetCone(*iJet, context()); - if (item()->getConfig()->value(kTauApexBeamSpot)) +void FWTauProxyBuilderBase::buildBaseTau(const reco::BaseTau& iTau, + const reco::Jet* iJet, + TEveElement* comp, + FWViewType::EType type, + const FWViewContext* vc) { + // track + addLeadTrack(iTau, comp); + addConstituentTracks(iTau, comp); + + // projected markers + if (FWViewType::isProjected(type)) { + double phi = iTau.phi(); + double theta = iTau.theta(); + double size = 1; + + bool barrel = (theta < context().caloTransAngle() || theta > (TMath::Pi() - context().caloTransAngle())); + float ecalR = barrel ? context().caloR1() : context().caloR2(); + float ecalZ = barrel ? context().caloZ1() : context().caloZ2(); + + TEveScalableStraightLineSet* marker = new TEveScalableStraightLineSet("energy"); + + if (type == FWViewType::kRhoZ) { + double r(0); + (theta < context().caloTransAngle() || M_PI - theta < context().caloTransAngle()) ? r = ecalZ / fabs(cos(theta)) + : r = ecalR / sin(theta); + + fireworks::addRhoZEnergyProjection(this, comp, ecalR, ecalZ, m_minTheta - 0.003, m_maxTheta + 0.003, phi); + + marker->SetScaleCenter(0., (phi > 0 ? r * fabs(sin(theta)) : -r * fabs(sin(theta))), r * cos(theta)); + marker->AddLine(0., + (phi > 0 ? r * fabs(sin(theta)) : -r * fabs(sin(theta))), + r * cos(theta), + 0., + (phi > 0 ? (r + size) * fabs(sin(theta)) : -(r + size) * fabs(sin(theta))), + (r + size) * cos(theta)); + + } else { + std::pair phiRange = fireworks::getPhiRange(m_phis, phi); + double min_phi = phiRange.first - M_PI / 36 / 2; + double max_phi = phiRange.second + M_PI / 36 / 2; + if (fabs(phiRange.first - phiRange.first) < 1e-3) { - FWBeamSpot* bs = context().getBeamSpot(); - cone->SetApex(TEveVector(bs->x0(), bs->y0(), bs->z0())); + min_phi = phi - M_PI / 36 / 2; + max_phi = phi + M_PI / 36 / 2; } - const FWDisplayProperties &dp = item()->defaultDisplayProperties(); - cone->SetFillColor(dp.color()); - cone->SetLineColor(dp.color()); - setupAddElement( cone, comp ); - cone->SetMainTransparency(TMath::Min(100, 80 + dp.transparency() / 5)); - } + TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur()); + TGeoBBox* sc_box = new TGeoTubeSeg(ecalR - 1, ecalR + 1, 1, min_phi * 180 / M_PI, max_phi * 180 / M_PI); + TEveGeoShape* shape = fireworks::getShape("spread", sc_box, item()->defaultDisplayProperties().color()); + shape->SetPickable(kTRUE); + setupAddElement(shape, comp); + + marker->SetScaleCenter(ecalR * cos(phi), ecalR * sin(phi), 0); + marker->AddLine(ecalR * cos(phi), ecalR * sin(phi), 0, (ecalR + size) * cos(phi), (ecalR + size) * sin(phi), 0); + } + marker->SetLineWidth(4); + FWViewEnergyScale* caloScale = vc->getEnergyScale(); + marker->SetScale(caloScale->getScaleFactor3D() * (caloScale->getPlotEt() ? iTau.et() : iTau.energy())); + setupAddElement(marker, comp); + + context().voteMaxEtAndEnergy(iTau.et(), iTau.energy()); + } else if (iJet) { + // jet + TEveJetCone* cone = fireworks::makeEveJetCone(*iJet, context()); + if (item()->getConfig()->value(kTauApexBeamSpot)) { + FWBeamSpot* bs = context().getBeamSpot(); + cone->SetApex(TEveVector(bs->x0(), bs->y0(), bs->z0())); + } + const FWDisplayProperties& dp = item()->defaultDisplayProperties(); + cone->SetFillColor(dp.color()); + cone->SetLineColor(dp.color()); + setupAddElement(cone, comp); + cone->SetMainTransparency(TMath::Min(100, 80 + dp.transparency() / 5)); + } } // Tracks which passed quality cuts and are inside a tracker signal cone around leading Track -void -FWTauProxyBuilderBase::addConstituentTracks( const reco::BaseTau &tau, class TEveElement* product ) -{ - for( reco::TrackRefVector::iterator i = tau.signalTracks().begin(), iEnd = tau.signalTracks().end(); - i != iEnd; ++i ) { - TEveTrack* track( nullptr ); - if( i->isAvailable() ) { - track = fireworks::prepareTrack( **i, context().getTrackPropagator() ); - track->MakeTrack(); - setupAddElement( track, product ); - } - } +void FWTauProxyBuilderBase::addConstituentTracks(const reco::BaseTau& tau, class TEveElement* product) { + for (reco::TrackRefVector::iterator i = tau.signalTracks().begin(), iEnd = tau.signalTracks().end(); i != iEnd; ++i) { + TEveTrack* track(nullptr); + if (i->isAvailable()) { + track = fireworks::prepareTrack(**i, context().getTrackPropagator()); + track->MakeTrack(); + setupAddElement(track, product); + } + } } // Leading Track -void -FWTauProxyBuilderBase::addLeadTrack( const reco::BaseTau &tau, class TEveElement *product ) -{ - const reco::TrackRef leadTrack = tau.leadTrack(); - if( !leadTrack ) return; - - TEveTrack* track = fireworks::prepareTrack( *leadTrack, context().getTrackPropagator() ); - if( track ) - { - track->MakeTrack(); - setupAddElement( track, product ); - } +void FWTauProxyBuilderBase::addLeadTrack(const reco::BaseTau& tau, class TEveElement* product) { + const reco::TrackRef leadTrack = tau.leadTrack(); + if (!leadTrack) + return; + + TEveTrack* track = fireworks::prepareTrack(*leadTrack, context().getTrackPropagator()); + if (track) { + track->MakeTrack(); + setupAddElement(track, product); + } } -void -FWTauProxyBuilderBase::localModelChanges(const FWModelId& iId, TEveElement* iCompound, - FWViewType::EType viewType, const FWViewContext* vc) -{ - if (FWViewType::isProjected(viewType)) - increaseComponentTransparency(iId.index(), iCompound, "TEveJetCone", 80); +void FWTauProxyBuilderBase::localModelChanges(const FWModelId& iId, + TEveElement* iCompound, + FWViewType::EType viewType, + const FWViewContext* vc) { + if (FWViewType::isProjected(viewType)) + 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() { }