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 //
12 #include "TEveCompound.h"
13 #include "TEveLine.h"
14 #include "TEveScalableStraightLineSet.h"
15 
20 
24 
27 
29 //
30 // 3D and RPZ proxy builder with shared track list
31 //
33 
34 class FWConversionProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Conversion> {
35 
36 public:
38  virtual ~FWConversionProxyBuilder();
39 
40  virtual bool haveSingleProduct() const override { return false; }
41  virtual void cleanLocal() override;
42 
44 
45 private:
46  FWConversionProxyBuilder( const FWConversionProxyBuilder& ); // stop default
47  const FWConversionProxyBuilder& operator=( const FWConversionProxyBuilder& ); // stop default
48 
49  virtual void buildViewType(const reco::Conversion& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*) override;
50 
51  TEveElementList* requestCommon();
52 
53  TEveElementList* m_common;
54 };
55 
56 
58  m_common(0)
59 {
60  m_common = new TEveElementList( "common conversion scene" );
61  m_common->IncDenyDestroy();
62 }
63 
65 {
66  m_common->DecDenyDestroy();
67 }
68 
69 TEveElementList*
71 {
72  if( m_common->HasChildren() == false )
73  {
74  for (int i = 0; i < static_cast<int>(item()->size()); ++i)
75  {
77  TEveLine* line = new TEveLine(0);
78  if (conversion.nTracks() == 2) {
79  if (fabs(conversion.zOfPrimaryVertexFromTracks()) < fireworks::Context::caloZ1())
80  line->SetNextPoint(0., 0., conversion.zOfPrimaryVertexFromTracks());
81  else
82  line->SetNextPoint(0., 0., 0.);
83 
84  float phi = conversion.pairMomentum().phi();
85  if (fabs(conversion.pairMomentum().eta()) < fireworks::Context::caloTransEta()) {
87  float z = radius/tan(conversion.pairMomentum().theta());
88  line->SetNextPoint(radius*cos(phi), radius*sin(phi), z);
89  }
90  else {
91  float z = fireworks::Context::caloZ1();
92  float radius = z*tan(conversion.pairMomentum().theta());
93  z *= (conversion.pairMomentum().eta()/fabs(conversion.pairMomentum().eta()));
94  line->SetNextPoint(radius*cos(phi), radius*sin(phi), z);
95  }
96  }
97  else {
98  line->SetNextPoint(0., 0., 0.);
99  line->SetNextPoint(0., 0., 0.);
100  }
101 
102  setupElement( line );
103  m_common->AddElement( line );
104  }
105  }
106 
107  return m_common;
108 }
109 
110 void
112 {
113  m_common->DestroyElements();
114 }
115 
116 void
117 FWConversionProxyBuilder::buildViewType(const reco::Conversion& conversion, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*)
118 {
119  TEveElementList* lines = requestCommon();
120  TEveElement::List_i linIt = lines->BeginChildren();
121  std::advance(linIt, iIndex);
122  TEveLine* line = (TEveLine*)((*linIt)->CloneElement());
123  TEveVector bvec = line->GetLineStart();
124  TEveVector evec = line->GetLineEnd();
125  if (bvec.Mag() != evec.Mag())
126  setupAddElement(*linIt, &oItemHolder );
127 }
128 
static float caloTransEta()
Definition: Context.cc:229
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:58
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:145
virtual bool haveSingleProduct() const override
float float float z
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:59
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static float caloR1(bool offset=true)
Definition: Context.cc:209
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
unsigned int nTracks() const
Number of tracks= 0,1,2.
Definition: Conversion.h:101
math::XYZVectorF pairMomentum() const
Conversion tracks momentum from the tracks inner momentum.
Definition: Conversion.cc:223
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9
size_t size() const
Definition: FWEventItem.cc:548
const FWConversionProxyBuilder & operator=(const FWConversionProxyBuilder &)
virtual void cleanLocal() override
static float caloZ1(bool offset=true)
Definition: Context.cc:219
volatile std::atomic< bool > shutdown_flag false
virtual void buildViewType(const reco::Conversion &iData, unsigned int iIndex, TEveElement &oItemHolder, FWViewType::EType type, const FWViewContext *) override
void setupElement(TEveElement *el, bool color=true) const
Definition: DDAxes.h:10