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 
39  virtual bool haveSingleProduct() const override { return false; }
40  virtual void cleanLocal() override;
41 
43 
44 private:
45  FWElectronProxyBuilder( const FWElectronProxyBuilder& ); // stop default
46  const FWElectronProxyBuilder& operator=( const FWElectronProxyBuilder& ); // stop default
47 
48  virtual void buildViewType(const reco::GsfElectron& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*) override;
49 
50  TEveElementList* requestCommon();
51 
52  TEveElementList* m_common;
53 };
54 
55 
57  m_common(0)
58 {
59  m_common = new TEveElementList( "common electron scene" );
60  m_common->IncDenyDestroy();
61 }
62 
64 {
65  m_common->DecDenyDestroy();
66 }
67 
68 TEveElementList*
70 {
71  if( m_common->HasChildren() == false )
72  {
73  for (int i = 0; i < static_cast<int>(item()->size()); ++i)
74  {
76 
77  TEveTrack* track(0);
78  if( electron.gsfTrack().isAvailable() )
79  track = fireworks::prepareTrack( *electron.gsfTrack(),
81  else
82  track = fireworks::prepareCandidate( electron,
83  context().getTrackPropagator());
84  track->MakeTrack();
85  setupElement( track );
86  m_common->AddElement( track );
87  }
88  }
89  return m_common;
90 }
91 
92 void
94 {
95  m_common->DestroyElements();
96 }
97 
98 void
99 FWElectronProxyBuilder::buildViewType(const reco::GsfElectron& electron, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*)
100 {
101  TEveElementList* tracks = requestCommon();
102  TEveElement::List_i trkIt = tracks->BeginChildren();
103  std::advance(trkIt, iIndex);
104  setupAddElement(*trkIt, &oItemHolder );
105 
106  if( type == FWViewType::kRhoPhi || type == FWViewType::kRhoPhiPF )
108  electron.superCluster(),
109  electron.phi(),
110  oItemHolder );
111  else if( type == FWViewType::kRhoZ )
113  electron.superCluster(),
114  electron.phi(),
115  oItemHolder );
116 }
117 
119 
120 
121 
123 //
124 // GLIMPSE specific proxy builder
125 //
127 
129 public:
132 
134 
135 private:
137 
139 
140  virtual void build(const reco::GsfElectron& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
141 };
142 
143 void
144 FWElectronGlimpseProxyBuilder::build( const reco::GsfElectron& iData, unsigned int iIndex,TEveElement& oItemHolder , const FWViewContext*)
145 {
146  TEveScalableStraightLineSet* marker = new TEveScalableStraightLineSet("", "");
147  marker->SetLineWidth(2);
148  fireworks::addStraightLineSegment( marker, &iData, 1.0 );
149  setupAddElement(marker, &oItemHolder);
150  //add to scaler at end so that it can scale the line after all ends have been added
151  // FIXME: It's not a part of a standard FWSimpleProxyBuilderTemplate: the scaler is not set!
152 // assert(scaler());
153 // scaler()->addElement(marker);
154 }
type
Definition: HCALResponse.h:21
const fireworks::Context & context() const
int i
Definition: DBlmapReader.cc:9
#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
bool isAvailable() const
Definition: Ref.h:276
TEveTrackPropagator * getTrackPropagator() const
Definition: Context.h:73
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:59
const FWElectronGlimpseProxyBuilder & operator=(const FWElectronGlimpseProxyBuilder &)
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: GsfElectron.h:168
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
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 GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:169
void setupElement(TEveElement *el, bool color=true) const