CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 //
29 // 3D and RPZ proxy builder with shared track list
30 //
32 
33 class FWElectronProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::GsfElectron> {
34 
35 public:
37  virtual ~FWElectronProxyBuilder();
38 
40  virtual bool haveSingleProduct() const override { return false; }
42  virtual void cleanLocal() override;
44  virtual void buildViewType(const reco::GsfElectron& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*) override;
45 
47 
48 private:
49  FWElectronProxyBuilder( const FWElectronProxyBuilder& ); // stop default
50  const FWElectronProxyBuilder& operator=( const FWElectronProxyBuilder& ); // stop default
51 
52 
53  TEveElementList* requestCommon();
54 
55  TEveElementList* m_common;
56 };
57 
58 
60  m_common(0)
61 {
62  m_common = new TEveElementList( "common electron scene" );
63  m_common->IncDenyDestroy();
64 }
65 
67 {
68  m_common->DecDenyDestroy();
69 }
70 
71 TEveElementList*
73 {
74  if( m_common->HasChildren() == false )
75  {
76  for (int i = 0; i < static_cast<int>(item()->size()); ++i)
77  {
79 
80  TEveTrack* track(0);
81  if( electron.gsfTrack().isAvailable() )
82  track = fireworks::prepareTrack( *electron.gsfTrack(),
84  else
85  track = fireworks::prepareCandidate( electron,
86  context().getTrackPropagator());
87  track->MakeTrack();
88  setupElement( track );
89  m_common->AddElement( track );
90  }
91  }
92  return m_common;
93 }
94 
95 void
97 {
98  m_common->DestroyElements();
99 }
100 
101 void
102 FWElectronProxyBuilder::buildViewType(const reco::GsfElectron& electron, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*)
103 {
104  TEveElementList* tracks = requestCommon();
105  TEveElement::List_i trkIt = tracks->BeginChildren();
106  std::advance(trkIt, iIndex);
107  setupAddElement(*trkIt, &oItemHolder );
108 
109  if( type == FWViewType::kRhoPhi || type == FWViewType::kRhoPhiPF )
111  electron.superCluster(),
112  electron.phi(),
113  oItemHolder );
114  else if( type == FWViewType::kRhoZ )
116  electron.superCluster(),
117  electron.phi(),
118  oItemHolder );
119 }
120 
122 
123 
124 
126 //
127 // GLIMPSE specific proxy builder
128 //
130 
132 public:
136 
138 
139 private:
141 
143 
144  virtual void build(const reco::GsfElectron& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
145 };
146 
147 void
148 FWElectronGlimpseProxyBuilder::build( const reco::GsfElectron& iData, unsigned int iIndex,TEveElement& oItemHolder , const FWViewContext*)
149 {
150  TEveScalableStraightLineSet* marker = new TEveScalableStraightLineSet("", "");
151  marker->SetLineWidth(2);
152  fireworks::addStraightLineSegment( marker, &iData, 1.0 );
153  setupAddElement(marker, &oItemHolder);
154  //add to scaler at end so that it can scale the line after all ends have been added
155  // FIXME: It's not a part of a standard FWSimpleProxyBuilderTemplate: the scaler is not set!
156 // assert(scaler());
157 // scaler()->addElement(marker);
158 }
bool isAvailable() const
Definition: Ref.h:576
type
Definition: HCALResponse.h:21
const fireworks::Context & context() const
int i
Definition: DBlmapReader.cc:9
#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:75
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
TEveTrackPropagator * getTrackPropagator() const
Definition: Context.h:73
virtual void cleanLocal()
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:59
const FWElectronGlimpseProxyBuilder & operator=(const FWElectronGlimpseProxyBuilder &)
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: GsfElectron.h:182
void addStraightLineSegment(TEveStraightLineSet *marker, reco::Candidate const *cand, double scale_factor=2)
bool makeRhoZSuperCluster(FWProxyBuilderBase *, const reco::SuperClusterRef &iCluster, float iPhi, TEveElement &oItemHolder)
virtual void cleanLocal() override
virtual bool haveSingleProduct() const
TEveElementList * requestCommon()
size_t size() const
Definition: FWEventItem.cc:548
tuple tracks
Definition: testEve_cfg.py:39
bool makeRhoPhiSuperCluster(FWProxyBuilderBase *, const reco::SuperClusterRef &iCluster, float iPhi, TEveElement &oItemHolder)
const FWElectronProxyBuilder & operator=(const FWElectronProxyBuilder &)
TEveTrack * prepareCandidate(const reco::Candidate &track, TEveTrackPropagator *propagator)
volatile std::atomic< bool > shutdown_flag false
virtual bool haveSingleProduct() const override
virtual double phi() const
momentum azimuthal angle
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:183
void setupElement(TEveElement *el, bool color=true) const