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  virtual ~FWElectronProxyBuilder();
40 
42  virtual bool haveSingleProduct() const override { return false; }
44  virtual void cleanLocal() override;
46  virtual void buildViewType(const reco::GsfElectron& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*) override;
47 
49  virtual void setItem(const FWEventItem* iItem) override;
50 
52 
53 private:
54  FWElectronProxyBuilder( const FWElectronProxyBuilder& ); // stop default
55  const FWElectronProxyBuilder& operator=( const FWElectronProxyBuilder& ); // stop default
56 
57 
58  TEveElementList* requestCommon();
59 
60  TEveElementList* m_common;
61 };
62 
63 
65  m_common(0)
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(0);
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:
160 
162 
163  virtual 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:577
type
Definition: HCALResponse.h:21
const fireworks::Context & context() const
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:170
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:58
TEveTrack * prepareTrack(const reco::Track &track, TEveTrackPropagator *propagator, const std::vector< TEveVector > &extraRefPoints=std::vector< TEveVector >())
Definition: TrackUtils.cc:69
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
virtual void buildViewType(const reco::GsfElectron &iData, unsigned int iIndex, TEveElement &oItemHolder, FWViewType::EType type, const FWViewContext *) override
virtual 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 double phi() const final
momentum azimuthal angle
virtual bool haveSingleProduct() const override
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: GsfElectron.h:184
virtual void setItem(const FWEventItem *iItem)
void addStraightLineSegment(TEveStraightLineSet *marker, reco::Candidate const *cand, double scale_factor=2)
bool makeRhoZSuperCluster(FWProxyBuilderBase *, const reco::SuperClusterRef &iCluster, float iPhi, TEveElement &oItemHolder)
FWGenericParameter< T > * assertParam(const std::string &name, T def)
virtual void cleanLocal() override
virtual bool haveSingleProduct() const
TEveElementList * requestCommon()
size_t size() const
Definition: FWEventItem.cc:550
bool makeRhoPhiSuperCluster(FWProxyBuilderBase *, const reco::SuperClusterRef &iCluster, float iPhi, TEveElement &oItemHolder)
const FWElectronProxyBuilder & operator=(const FWElectronProxyBuilder &)
TEveTrack * prepareCandidate(const reco::Candidate &track, TEveTrackPropagator *propagator)
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:185
void setupElement(TEveElement *el, bool color=true) const