CMS 3D CMS Logo

FWElectronProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Electrons
4 // Class : FWElectronProxyBuilder
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Tue Dec 2 14:17:03 EST 2008
11 //
12 #include "TEveCompound.h"
13 #include "TEveTrack.h"
14 #include "TEveScalableStraightLineSet.h"
15 
19 
23 
26 
28 
30 //
31 // 3D and RPZ proxy builder with shared track list
32 //
34 
35 class FWElectronProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::GsfElectron> {
36 public:
38  ~FWElectronProxyBuilder() override;
39 
41  bool haveSingleProduct() const override { return false; }
43  void cleanLocal() override;
45  void buildViewType(const reco::GsfElectron& iData,
46  unsigned int iIndex,
47  TEveElement& oItemHolder,
49  const FWViewContext*) override;
50 
52  void setItem(const FWEventItem* iItem) override;
53 
55 
56  FWElectronProxyBuilder(const FWElectronProxyBuilder&) = delete; // stop default
57  const FWElectronProxyBuilder& operator=(const FWElectronProxyBuilder&) = delete; // stop default
58 
59 private:
60  TEveElementList* requestCommon();
61 
62  TEveElementList* m_common;
63 };
64 
66  m_common = new TEveElementList("common electron scene");
67  m_common->IncDenyDestroy();
68 }
69 
71 
74 
75  if (iItem) {
76  iItem->getConfig()->assertParam("LineWidth", long(1), long(1), long(4));
77  }
78 }
79 
81  if (m_common->HasChildren() == false) {
82  int width = item()->getConfig()->value<long>("LineWidth");
83  for (int i = 0; i < static_cast<int>(item()->size()); ++i) {
85 
86  TEveTrack* track(nullptr);
87  if (electron.gsfTrack().isAvailable())
89  else
90  track = fireworks::prepareCandidate(electron, context().getTrackPropagator());
91  track->MakeTrack();
92  track->SetLineWidth(width);
94  m_common->AddElement(track);
95  }
96  }
97  return m_common;
98 }
99 
100 void FWElectronProxyBuilder::cleanLocal() { m_common->DestroyElements(); }
101 
103  unsigned int iIndex,
104  TEveElement& oItemHolder,
106  const FWViewContext*) {
107  TEveElementList* tracks = requestCommon();
108  TEveElement::List_i trkIt = tracks->BeginChildren();
109  std::advance(trkIt, iIndex);
110  setupAddElement(*trkIt, &oItemHolder);
111 
113  fireworks::makeRhoPhiSuperCluster(this, electron.superCluster(), electron.phi(), oItemHolder);
114  else if (type == FWViewType::kRhoZ)
115  fireworks::makeRhoZSuperCluster(this, electron.superCluster(), electron.phi(), oItemHolder);
116 }
117 
120  "Electrons",
122 
124 //
125 // GLIMPSE specific proxy builder
126 //
128 
130 public:
134 
136 
137  FWElectronGlimpseProxyBuilder(const FWElectronGlimpseProxyBuilder&) = delete; // stop default
138 
139  const FWElectronGlimpseProxyBuilder& operator=(const FWElectronGlimpseProxyBuilder&) = delete; // stop default
140 
141 private:
142  void build(const reco::GsfElectron& iData,
143  unsigned int iIndex,
144  TEveElement& oItemHolder,
145  const FWViewContext*) override;
146 };
147 
149  unsigned int iIndex,
150  TEveElement& oItemHolder,
151  const FWViewContext*) {
152  TEveScalableStraightLineSet* marker = new TEveScalableStraightLineSet("", "");
153  marker->SetLineWidth(2);
154  fireworks::addStraightLineSegment(marker, &iData, 1.0);
155  setupAddElement(marker, &oItemHolder);
156  //add to scaler at end so that it can scale the line after all ends have been added
157  // FIXME: It's not a part of a standard FWSimpleProxyBuilderTemplate: the scaler is not set!
158  // assert(scaler());
159  // scaler()->addElement(marker);
160 }
size_t size() const
Definition: FWEventItem.cc:457
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:67
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
const FWElectronProxyBuilder & operator=(const FWElectronProxyBuilder &)=delete
TEveTrackPropagator * getTrackPropagator() const
Definition: Context.h:62
TEveTrack * prepareTrack(const reco::Track &track, TEveTrackPropagator *propagator, const std::vector< TEveVector > &extraRefPoints=std::vector< TEveVector >())
Definition: TrackUtils.cc:62
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:150
void buildViewType(const reco::GsfElectron &iData, unsigned int iIndex, TEveElement &oItemHolder, FWViewType::EType type, const FWViewContext *) override
void setItem(const FWEventItem *iItem) override
virtual void cleanLocal()
virtual bool haveSingleProduct() const
static const int kAll3DBits
Definition: FWViewType.h:68
const fireworks::Context & context() const
virtual void setItem(const FWEventItem *iItem)
bool haveSingleProduct() const override
void addStraightLineSegment(TEveStraightLineSet *marker, reco::Candidate const *cand, double scale_factor=2)
const FWElectronGlimpseProxyBuilder & operator=(const FWElectronGlimpseProxyBuilder &)=delete
void setupElement(TEveElement *el, bool color=true) const
bool makeRhoZSuperCluster(FWProxyBuilderBase *, const reco::SuperClusterRef &iCluster, float iPhi, TEveElement &oItemHolder)
FWGenericParameter< T > * assertParam(const std::string &name, T def)
TEveElementList * requestCommon()
auto const & tracks
cannot be loose
bool makeRhoPhiSuperCluster(FWProxyBuilderBase *, const reco::SuperClusterRef &iCluster, float iPhi, TEveElement &oItemHolder)
TEveTrack * prepareCandidate(const reco::Candidate &track, TEveTrackPropagator *propagator)
const FWEventItem * item() const