CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWConversionProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Conversions
4 // Class : FWConversionProxyBuilder
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Tue Dec 2 14:17:03 EST 2008
11 // $Id: FWConversionProxyBuilder.cc,v 1.1 2011/02/25 19:31:15 fgolf Exp $
12 //
13 #include "TEveCompound.h"
14 #include "TEveLine.h"
15 #include "TEveScalableStraightLineSet.h"
16 
21 
25 
28 
30 //
31 // 3D and RPZ proxy builder with shared track list
32 //
34 
35 class FWConversionProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Conversion> {
36 
37 public:
39  virtual ~FWConversionProxyBuilder();
40 
41  virtual bool haveSingleProduct() const { return false; }
42  virtual void cleanLocal();
43 
45 
46 private:
47  FWConversionProxyBuilder( const FWConversionProxyBuilder& ); // stop default
48  const FWConversionProxyBuilder& operator=( const FWConversionProxyBuilder& ); // stop default
49 
50  virtual void buildViewType(const reco::Conversion& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*);
51 
52  TEveElementList* requestCommon();
53 
54  TEveElementList* m_common;
55 };
56 
57 
59  m_common(0)
60 {
61  m_common = new TEveElementList( "common conversion scene" );
62  m_common->IncDenyDestroy();
63 }
64 
66 {
67  m_common->DecDenyDestroy();
68 }
69 
70 TEveElementList*
72 {
73  if( m_common->HasChildren() == false )
74  {
75  for (int i = 0; i < static_cast<int>(item()->size()); ++i)
76  {
78  TEveLine* line = new TEveLine(0);
79  if (conversion.nTracks() == 2) {
80  if (fabs(conversion.zOfPrimaryVertexFromTracks()) < fireworks::Context::caloZ1())
81  line->SetNextPoint(0., 0., conversion.zOfPrimaryVertexFromTracks());
82  else
83  line->SetNextPoint(0., 0., 0.);
84 
85  float phi = conversion.pairMomentum().phi();
86  if (fabs(conversion.pairMomentum().eta()) < fireworks::Context::caloTransEta()) {
88  float z = radius/tan(conversion.pairMomentum().theta());
89  line->SetNextPoint(radius*cos(phi), radius*sin(phi), z);
90  }
91  else {
92  float z = fireworks::Context::caloZ1();
93  float radius = z*tan(conversion.pairMomentum().theta());
94  z *= (conversion.pairMomentum().eta()/fabs(conversion.pairMomentum().eta()));
95  line->SetNextPoint(radius*cos(phi), radius*sin(phi), z);
96  }
97  }
98  else {
99  line->SetNextPoint(0., 0., 0.);
100  line->SetNextPoint(0., 0., 0.);
101  }
102 
103  setupElement( line );
104  m_common->AddElement( line );
105  }
106  }
107 
108  return m_common;
109 }
110 
111 void
113 {
114  m_common->DestroyElements();
115 }
116 
117 void
118 FWConversionProxyBuilder::buildViewType(const reco::Conversion& conversion, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*)
119 {
120  TEveElementList* lines = requestCommon();
121  TEveElement::List_i linIt = lines->BeginChildren();
122  std::advance(linIt, iIndex);
123  TEveLine* line = (TEveLine*)((*linIt)->CloneElement());
124  TEveVector bvec = line->GetLineStart();
125  TEveVector evec = line->GetLineEnd();
126  if (bvec.Mag() != evec.Mag())
127  setupAddElement(*linIt, &oItemHolder );
128 }
129 
static float caloTransEta()
Definition: Context.cc:230
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
virtual void buildViewType(const reco::Conversion &iData, unsigned int iIndex, TEveElement &oItemHolder, FWViewType::EType type, const FWViewContext *)
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:59
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double zOfPrimaryVertexFromTracks(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
Definition: Conversion.h:149
float float float z
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:60
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static float caloR1(bool offset=true)
Definition: Context.cc:210
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
virtual bool haveSingleProduct() const
unsigned int nTracks() const
Number of tracks= 0,1,2.
Definition: Conversion.h:105
math::XYZVectorF pairMomentum() const
Conversion tracks momentum from the tracks inner momentum.
Definition: Conversion.cc:227
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9
size_t size() const
Definition: FWEventItem.cc:549
const FWConversionProxyBuilder & operator=(const FWConversionProxyBuilder &)
static float caloZ1(bool offset=true)
Definition: Context.cc:220
void setupElement(TEveElement *el, bool color=true) const
Definition: DDAxes.h:10