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 
37 public:
39  ~FWElectronProxyBuilder() override;
40 
42  bool haveSingleProduct() const override { return false; }
44  void cleanLocal() override;
46  void buildViewType(const reco::GsfElectron& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*) override;
47 
49  void setItem(const FWEventItem* iItem) override;
50 
52 
53 private:
54  FWElectronProxyBuilder( const FWElectronProxyBuilder& ) = delete; // stop default
55  const FWElectronProxyBuilder& operator=( const FWElectronProxyBuilder& ) = delete; // stop default
56 
57 
58  TEveElementList* requestCommon();
59 
60  TEveElementList* m_common;
61 };
62 
63 
66 {
67  m_common = new TEveElementList( "common electron scene" );
68  m_common->IncDenyDestroy();
69 }
70 
72 {
73  m_common->DecDenyDestroy();
74 }
75 
76 
77 void
79 {
81 
82  if (iItem) {
83  iItem->getConfig()->assertParam("LineWidth", long(1), long(1), long(4));
84  }
85 }
86 
87 
88 TEveElementList*
90 {
91  if( m_common->HasChildren() == false )
92  {
93  int width = item()->getConfig()->value<long>("LineWidth");
94  for (int i = 0; i < static_cast<int>(item()->size()); ++i)
95  {
97 
98  TEveTrack* track(nullptr);
99  if( electron.gsfTrack().isAvailable() )
100  track = fireworks::prepareTrack( *electron.gsfTrack(),
102  else
103  track = fireworks::prepareCandidate( electron,
104  context().getTrackPropagator());
105  track->MakeTrack();
106  track->SetLineWidth(width);
107  setupElement( track );
108  m_common->AddElement( track );
109  }
110  }
111  return m_common;
112 }
113 
114 void
116 {
117  m_common->DestroyElements();
118 }
119 
120 void
121 FWElectronProxyBuilder::buildViewType(const reco::GsfElectron& electron, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*)
122 {
123  TEveElementList* tracks = requestCommon();
124  TEveElement::List_i trkIt = tracks->BeginChildren();
125  std::advance(trkIt, iIndex);
126  setupAddElement(*trkIt, &oItemHolder );
127 
128  if( type == FWViewType::kRhoPhi || type == FWViewType::kRhoPhiPF )
130  electron.superCluster(),
131  electron.phi(),
132  oItemHolder );
133  else if( type == FWViewType::kRhoZ )
135  electron.superCluster(),
136  electron.phi(),
137  oItemHolder );
138 }
139 
141 
142 
143 
145 //
146 // GLIMPSE specific proxy builder
147 //
149 
151 public:
155 
157 
158 private:
159  FWElectronGlimpseProxyBuilder(const FWElectronGlimpseProxyBuilder&) = delete; // stop default
160 
161  const FWElectronGlimpseProxyBuilder& operator=(const FWElectronGlimpseProxyBuilder&) = delete; // stop default
162 
163  void build(const reco::GsfElectron& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
164 };
165 
166 void
167 FWElectronGlimpseProxyBuilder::build( const reco::GsfElectron& iData, unsigned int iIndex,TEveElement& oItemHolder , const FWViewContext*)
168 {
169  TEveScalableStraightLineSet* marker = new TEveScalableStraightLineSet("", "");
170  marker->SetLineWidth(2);
171  fireworks::addStraightLineSegment( marker, &iData, 1.0 );
172  setupAddElement(marker, &oItemHolder);
173  //add to scaler at end so that it can scale the line after all ends have been added
174  // FIXME: It's not a part of a standard FWSimpleProxyBuilderTemplate: the scaler is not set!
175 // assert(scaler());
176 // scaler()->addElement(marker);
177 }
bool isAvailable() const
Definition: Ref.h:575
type
Definition: HCALResponse.h:21
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:186
const fireworks::Context & context() const
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:169
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:58
const FWElectronProxyBuilder & operator=(const FWElectronProxyBuilder &)=delete
TEveTrack * prepareTrack(const reco::Track &track, TEveTrackPropagator *propagator, const std::vector< TEveVector > &extraRefPoints=std::vector< TEveVector >())
Definition: TrackUtils.cc:63
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
#define nullptr
void buildViewType(const reco::GsfElectron &iData, unsigned int iIndex, TEveElement &oItemHolder, FWViewType::EType type, const FWViewContext *) override
void setItem(const FWEventItem *iItem) override
TEveTrackPropagator * getTrackPropagator() const
Definition: Context.h:73
virtual void cleanLocal()
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:59
virtual void setItem(const FWEventItem *iItem)
void addStraightLineSegment(TEveStraightLineSet *marker, reco::Candidate const *cand, double scale_factor=2)
bool haveSingleProduct() const override
bool makeRhoZSuperCluster(FWProxyBuilderBase *, const reco::SuperClusterRef &iCluster, float iPhi, TEveElement &oItemHolder)
FWGenericParameter< T > * assertParam(const std::string &name, T def)
virtual bool haveSingleProduct() const
TEveElementList * requestCommon()
size_t size() const
Definition: FWEventItem.cc:553
bool makeRhoPhiSuperCluster(FWProxyBuilderBase *, const reco::SuperClusterRef &iCluster, float iPhi, TEveElement &oItemHolder)
TEveTrack * prepareCandidate(const reco::Candidate &track, TEveTrackPropagator *propagator)
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:185
double phi() const final
momentum azimuthal angle
void setupElement(TEveElement *el, bool color=true) const